Skip to content

Commit a9447a1

Browse files
authored
Parametrise Op block time (#116)
* Leggo * Update
1 parent 10a0f50 commit a9447a1

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

internal/artifacts.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ import (
3636
)
3737

3838
var (
39-
opBlockTimeSeconds = uint64(2)
40-
defaultDiscoveryPrivKey = "a11ac89899cd86e36b6fb881ec1255b8a92a688790b7d950f8b7d8dd626671fb"
41-
defaultDiscoveryEnodeID = "3479db4d9217fb5d7a8ed4d61ac36e120b05d36c2eefb795dc42ff2e971f251a2315f5649ea1833271e020b9adc98d5db9973c7ed92d6b2f1f2223088c3d852f"
39+
defaultOpBlockTimeSeconds = uint64(2)
40+
defaultDiscoveryPrivKey = "a11ac89899cd86e36b6fb881ec1255b8a92a688790b7d950f8b7d8dd626671fb"
41+
defaultDiscoveryEnodeID = "3479db4d9217fb5d7a8ed4d61ac36e120b05d36c2eefb795dc42ff2e971f251a2315f5649ea1833271e020b9adc98d5db9973c7ed92d6b2f1f2223088c3d852f"
4242
)
4343

4444
// minimumGenesisDelay is the minimum delay for the genesis time. This is required
@@ -66,13 +66,15 @@ type ArtifactsBuilder struct {
6666
applyLatestL1Fork bool
6767
genesisDelay uint64
6868
applyLatestL2Fork *uint64
69+
OpblockTime uint64
6970
}
7071

7172
func NewArtifactsBuilder() *ArtifactsBuilder {
7273
return &ArtifactsBuilder{
7374
outputDir: "",
7475
applyLatestL1Fork: false,
7576
genesisDelay: MinimumGenesisDelay,
77+
OpblockTime: defaultOpBlockTimeSeconds,
7678
}
7779
}
7880

@@ -96,6 +98,11 @@ func (b *ArtifactsBuilder) GenesisDelay(genesisDelaySeconds uint64) *ArtifactsBu
9698
return b
9799
}
98100

101+
func (b *ArtifactsBuilder) OpBlockTime(blockTimeSeconds uint64) *ArtifactsBuilder {
102+
b.OpblockTime = blockTimeSeconds
103+
return b
104+
}
105+
99106
type Artifacts struct {
100107
Out *output
101108
}
@@ -258,7 +265,7 @@ func (b *ArtifactsBuilder) Build() (*Artifacts, error) {
258265
forkTime = new(uint64)
259266

260267
if *b.applyLatestL2Fork != 0 {
261-
*forkTime = opTimestamp + opBlockTimeSeconds*(*b.applyLatestL2Fork)
268+
*forkTime = opTimestamp + b.OpblockTime*(*b.applyLatestL2Fork)
262269
} else {
263270
*forkTime = 0
264271
}
@@ -317,6 +324,7 @@ func (b *ArtifactsBuilder) Build() (*Artifacts, error) {
317324
"number": 0,
318325
},
319326
},
327+
"block_time": b.OpblockTime,
320328
"chain_op_config": map[string]interface{}{ // TODO: Read this from somewhere (genesis??)
321329
"eip1559Elasticity": 6,
322330
"eip1559Denominator": 50,

internal/recipe_opstack.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ type OpRecipe struct {
1414

1515
// whether to enable the latest fork isthmus and when
1616
enableLatestFork *uint64
17+
18+
// blockTime is the block time to use for the rollup
19+
// (default is 2 seconds)
20+
blockTime uint64
1721
}
1822

1923
func (o *OpRecipe) Name() string {
@@ -28,12 +32,14 @@ func (o *OpRecipe) Flags() *flag.FlagSet {
2832
flags := flag.NewFlagSet("opstack", flag.ContinueOnError)
2933
flags.StringVar(&o.externalBuilder, "external-builder", "", "External builder URL")
3034
flags.Var(&nullableUint64Value{&o.enableLatestFork}, "enable-latest-fork", "Enable latest fork isthmus (nil or empty = disabled, otherwise enabled at specified block)")
35+
flags.Uint64Var(&o.blockTime, "block-time", defaultOpBlockTimeSeconds, "Block time to use for the rollup")
3136
return flags
3237
}
3338

3439
func (o *OpRecipe) Artifacts() *ArtifactsBuilder {
3540
builder := NewArtifactsBuilder()
3641
builder.ApplyLatestL2Fork(o.enableLatestFork)
42+
builder.OpBlockTime(o.blockTime)
3743
return builder
3844
}
3945

0 commit comments

Comments
 (0)