Skip to content

Commit 79cc094

Browse files
authored
refactor(pkg/config)!: move da start height to genesis (#2727)
<!-- Please read and fill out this form before submitting your PR. Please make sure you have reviewed our contributors guide before submitting your first PR. NOTE: PR titles should follow semantic commits: https://www.conventionalcommits.org/en/v1.0.0/ --> ## Overview UX improvement to move da height from user config to developer config. The flow is as follow: The developer once starting is sequencer is able to query its node to get the da start height They should add it in the genesis they share with the others node operators. Nodes will fetch directly from the correct DA height. <!-- Please provide an explanation of the PR, including the appropriate context, background, goal, and rationale. If there is an issue with this information, please provide a tl;dr and link the issue. Ex: Closes #<issue number> -->
1 parent c364b17 commit 79cc094

File tree

15 files changed

+70
-72
lines changed

15 files changed

+70
-72
lines changed

apps/evm/single/README.md

Lines changed: 42 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -15,26 +15,28 @@ This directory contains the implementation of a single EVM sequencer using Ev-no
1515

1616
2. Build the sequencer:
1717

18-
```bash
19-
go build -o evm-single .
20-
```
18+
```bash
19+
go build -o evm-single .
20+
```
2121

2222
3. Initialize the sequencer:
2323

24-
```bash
25-
./evm-single init --rollkit.node.aggregator=true --rollkit.signer.passphrase secret
26-
```
24+
```bash
25+
./evm-single init --rollkit.node.aggregator=true --rollkit.signer.passphrase secret
26+
```
2727

2828
4. Start the sequencer:
2929

30-
```bash
31-
./evm-single start \
32-
--evm.jwt-secret $(cat <path_to>/execution/evm/docker/jwttoken/jwt.hex) \
33-
--evm.genesis-hash 0x2b8bbb1ea1e04f9c9809b4b278a8687806edc061a356c7dbc491930d8e922503 \
34-
--rollkit.node.block_time 1s \
35-
--rollkit.node.aggregator=true \
36-
--rollkit.signer.passphrase secret
37-
```
30+
```bash
31+
./evm-single start \
32+
--evm.jwt-secret $(cat <path_to>/execution/evm/docker/jwttoken/jwt.hex) \
33+
--evm.genesis-hash 0x2b8bbb1ea1e04f9c9809b4b278a8687806edc061a356c7dbc491930d8e922503 \
34+
--rollkit.node.block_time 1s \
35+
--rollkit.node.aggregator=true \
36+
--rollkit.signer.passphrase secret
37+
```
38+
39+
Share your `genesis.json` with other node operators. Add `da_start_height` field corresponding to the first DA included block of the chain (can be queried on the sequencer node).
3840

3941
Note: Replace `<path_to>` with the actual path to the rollkit repository. If you'd ever like to restart a fresh node, make sure to remove the originally created sequencer node directory using:
4042

@@ -58,41 +60,43 @@ The sequencer can be configured using various command-line flags. The most impor
5860

5961
2. Initialize the full node:
6062

61-
```bash
62-
./evm-single init --home ~/.evm-single-full-node
63-
```
63+
```bash
64+
./evm-single init --home ~/.evm-single-full-node
65+
```
6466

6567
3. Copy the genesis file from the sequencer node:
6668

67-
```bash
68-
cp ~/.evm-single/config/genesis.json ~/.evm-single-full-node/config/genesis.json
69-
```
69+
```bash
70+
cp ~/.evm-single/config/genesis.json ~/.evm-single-full-node/config/genesis.json
71+
```
72+
73+
Verify the `da_start_height` value in the genesis file is set. If not, ask the chain developer to share it.
7074

7175
4. Identify the sequencer node's P2P address from its logs. It will look similar to:
7276

73-
```sh
74-
1:55PM INF listening on address=/ip4/127.0.0.1/tcp/7676/p2p/12D3KooWJ1J5W7vpHuyktcvc71iuduRgb9pguY9wKMNVVPwweWPk module=main
75-
```
77+
```sh
78+
1:55PM INF listening on address=/ip4/127.0.0.1/tcp/7676/p2p/12D3KooWJ1J5W7vpHuyktcvc71iuduRgb9pguY9wKMNVVPwweWPk module=main
79+
```
7680

77-
Create an environment variable with the P2P address:
81+
Create an environment variable with the P2P address:
7882

79-
```bash
80-
export P2P_ID="12D3KooWJbD9TQoMSSSUyfhHMmgVY3LqCjxYFz8wQ92Qa6DAqtmh"
81-
```
83+
```bash
84+
export P2P_ID="12D3KooWJbD9TQoMSSSUyfhHMmgVY3LqCjxYFz8wQ92Qa6DAqtmh"
85+
```
8286

8387
5. Start the full node:
8488

85-
```bash
86-
./evm-single start \
87-
--home ~/.evm-single-full-node \
88-
--evm.jwt-secret $(cat <path_to>/execution/evm/docker/jwttoken/jwt.hex) \
89-
--evm.genesis-hash 0x2b8bbb1ea1e04f9c9809b4b278a8687806edc061a356c7dbc491930d8e922503 \
90-
--rollkit.rpc.address=127.0.0.1:46657 \
91-
--rollkit.p2p.listen_address=/ip4/127.0.0.1/tcp/7677 \
92-
--rollkit.p2p.peers=/ip4/127.0.0.1/tcp/7676/p2p/$P2P_ID \
93-
--evm.engine-url http://localhost:8561 \
94-
--evm.eth-url http://localhost:8555
95-
```
89+
```bash
90+
./evm-single start \
91+
--home ~/.evm-single-full-node \
92+
--evm.jwt-secret $(cat <path_to>/execution/evm/docker/jwttoken/jwt.hex) \
93+
--evm.genesis-hash 0x2b8bbb1ea1e04f9c9809b4b278a8687806edc061a356c7dbc491930d8e922503 \
94+
--rollkit.rpc.address=127.0.0.1:46657 \
95+
--rollkit.p2p.listen_address=/ip4/127.0.0.1/tcp/7677 \
96+
--rollkit.p2p.peers=/ip4/127.0.0.1/tcp/7676/p2p/$P2P_ID \
97+
--evm.engine-url http://localhost:8561 \
98+
--evm.eth-url http://localhost:8555
99+
```
96100

97101
If you'd ever like to restart a fresh node, make sure to remove the originally created full node directory using:
98102

apps/evm/single/cmd/run.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ var RunCmd = &cobra.Command{
6767
return fmt.Errorf("failed to load genesis: %w", err)
6868
}
6969

70+
if genesis.DAStartHeight == 0 && !nodeConfig.Node.Aggregator {
71+
logger.Warn().Msg("da_start_height is not set in genesis.json, ask your chain developer")
72+
}
73+
7074
singleMetrics, err := single.DefaultMetricsProvider(nodeConfig.Instrumentation.IsPrometheusEnabled())(genesis.ChainID)
7175
if err != nil {
7276
return err

apps/grpc/single/cmd/run.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ The execution client must implement the Evolve execution gRPC interface.`,
6969
return err
7070
}
7171

72+
if genesis.DAStartHeight == 0 && !nodeConfig.Node.Aggregator {
73+
logger.Warn().Msg("da_start_height is not set in genesis.json, ask your chain developer")
74+
}
75+
7276
// Create metrics provider
7377
singleMetrics, err := single.DefaultMetricsProvider(nodeConfig.Instrumentation.IsPrometheusEnabled())(genesis.ChainID)
7478
if err != nil {

apps/testapp/cmd/run.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ var RunCmd = &cobra.Command{
8888
return fmt.Errorf("failed to load genesis: %w", err)
8989
}
9090

91+
if genesis.DAStartHeight == 0 && !nodeConfig.Node.Aggregator {
92+
logger.Warn().Msg("da_start_height is not set in genesis.json, ask your chain developer")
93+
}
94+
9195
sequencer, err := single.NewSequencer(
9296
ctx,
9397
logger,

block/internal/syncing/syncer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ func (s *Syncer) initializeState() error {
190190
s.SetLastState(state)
191191

192192
// Set DA height
193-
daHeight := max(state.DAHeight, s.config.DA.StartHeight)
193+
daHeight := max(state.DAHeight, s.genesis.DAStartHeight)
194194
s.SetDAHeight(daHeight)
195195

196196
s.logger.Info().

block/internal/syncing/syncer_backoff_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,13 +318,13 @@ func setupTestSyncer(t *testing.T, daBlockTime time.Duration) *Syncer {
318318

319319
cfg := config.DefaultConfig()
320320
cfg.DA.BlockTime.Duration = daBlockTime
321-
cfg.DA.StartHeight = 100
322321

323322
gen := genesis.Genesis{
324323
ChainID: "test-chain",
325324
InitialHeight: 1,
326325
StartTime: time.Now().Add(-time.Hour), // Start in past
327326
ProposerAddress: addr,
327+
DAStartHeight: 100,
328328
}
329329

330330
syncer := NewSyncer(

block/internal/syncing/syncer_benchmark_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,7 @@ func newBenchFixture(b *testing.B, totalHeights uint64, shuffledTx bool, daDelay
8787
cfg := config.DefaultConfig()
8888
// keep P2P ticker dormant unless we manually inject P2P events
8989
cfg.Node.BlockTime = config.DurationWrapper{Duration: 1}
90-
cfg.DA.StartHeight = daHeightOffset
91-
gen := genesis.Genesis{ChainID: "bchain", InitialHeight: 1, StartTime: time.Now().Add(-time.Second), ProposerAddress: addr}
90+
gen := genesis.Genesis{ChainID: "bchain", InitialHeight: 1, StartTime: time.Now().Add(-time.Second), ProposerAddress: addr, DAStartHeight: daHeightOffset}
9291

9392
mockExec := testmocks.NewMockExecutor(b)
9493
// if execDelay > 0, sleep on ExecuteTxs to simulate slow consumer

block/internal/syncing/syncer_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,8 +320,7 @@ func TestSyncLoopPersistState(t *testing.T) {
320320

321321
addr, pub, signer := buildSyncTestSigner(t)
322322
cfg := config.DefaultConfig()
323-
cfg.DA.StartHeight = myDAHeightOffset
324-
gen := genesis.Genesis{ChainID: "tchain", InitialHeight: 1, StartTime: time.Now().Add(-time.Second), ProposerAddress: addr}
323+
gen := genesis.Genesis{ChainID: "tchain", InitialHeight: 1, StartTime: time.Now().Add(-time.Second), ProposerAddress: addr, DAStartHeight: myDAHeightOffset}
325324

326325
dummyExec := execution.NewDummyExecutor()
327326

docs/guides/create-genesis.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,15 @@ For example, start the simple ignite chain with the following command:
116116
gmd start --evnode.node.aggregator
117117
```
118118

119+
## Share the genesis file
120+
121+
Once the sequencer is running, share the genesis file with your peers. You can find the genesis file at `~/.${CHAIN_ID}/config/genesis.json`.
122+
Before doing so, add a `da_start_height` field to the genesis file, that corresponds to the height at which the first height was included on the DA layer. This height can be fetched directly from the [sequencer RPC](https://github.com/evstack/ev-node/blob/v1.0.0-beta.5/proto/evnode/v1/state_rpc.proto).
123+
124+
```sh
125+
jq '.da_start_height = 1' ~/.$CHAIN_ID/config/genesis.json > temp.json && mv temp.json ~/.$CHAIN_ID/config/genesis.json
126+
```
127+
119128
## Summary
120129

121130
By following these steps, you will set up the genesis for your chain, initialize the validator, add a genesis account, and start the chain. This guide provides a basic framework for configuring and starting your chain using the gm-world binary. Make sure you initialized your chain correctly, and use the `gmd` command for all operations.

docs/guides/da/celestia-da.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ gmd start \
135135
--evnode.da.auth_token $AUTH_TOKEN \
136136
--evnode.da.header_namespace $DA_NAMESPACE \
137137
--evnode.da.data_namespace $DA_NAMESPACE \
138-
--evnode.da.start_height $DA_BLOCK_HEIGHT \
139138
--evnode.da.address $DA_ADDRESS
140139
```
141140

0 commit comments

Comments
 (0)