Skip to content

Instantly share code, notes, and snippets.

@larry0x
Last active January 31, 2025 15:26
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.

@penso
Copy link

penso commented Jan 31, 2025

What I had to do for Dango:

git clone https://github.com/cometbft/cometbft
cd cometbft
git checkout v0.38.10
make install
git clone https://github.com/left-curve/grug
cd grug
just install
just optimize
cometbft init
RUST_BACKTRACE=1 cargo run --example build_genesis -- dev-6 2025-01-31T00:00:00Z
cometbft start
cargo run -p dango-cli start

@penso
Copy link

penso commented Jan 31, 2025

cleaning code:

cometbft unsafe-reset-all
dango db reset

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