Skip to content

Instantly share code, notes, and snippets.

@larry0x
Last active August 7, 2024 12:55
Show Gist options
  • Save larry0x/c509d531d144b1fb9346394401288856 to your computer and use it in GitHub Desktop.
Save larry0x/c509d531d144b1fb9346394401288856 to your computer and use it in GitHub Desktop.
How to spin up a local Grug devnet

How to spin up a local devnet

  1. Compile CometBFT, i.e. the sequencing layer:
git clone https://github.com/cometbft/cometbft
cd cometbft
git checkout v0.38.10
make install
  1. Compile Grug, i.e. the execution layer:
git clone https://github.com/left-curve/grug
cd grug
just install
  1. Compile necessary contracts:
just optimize
  1. Initialize CometBFT. This will create a directory ~/.cometbft, which most notably includes the genesis file at ~/.cometbft/config/genesis.json. However, the app genesis state (the app_state field in the JSON) is left empty for now:
cometbft init
  1. Generate two keys. We will create register two accounts during genesis, which will use these two keys, respectively:
grug keys add test1
grug keys add test2
  1. Prepare the genesis file. This runs an example script, which utilizes grug_sdk::GenesisBuilder to create an app genesis state and populate in the CometBFT genesis file:
cargo run -p grug-sdk --example build_genesis
  1. Start the node. Generally, when starting, start grug first, then cometbft; when shutting down, stop cometbft first, then grug:
grug start
cometbft start
  1. Optional: deleting existing chain data and restart anew:
cometbft unsafe-reset-all
grug db reset
  1. How to shut down the node

Use CTRL+C to kill CometBFT first, then CTRL+C to kill Grug.

Generally, when starting, start Grug first then start CometBFT; then stopping, kill CometBFT then kill Grug.

Don't worry, you won't mess up anything if you get the order wrong. This is just the intended order the software are designed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment