diff --git a/playground/artifacts.go b/playground/artifacts.go index b9dd7cd..4cd79a2 100644 --- a/playground/artifacts.go +++ b/playground/artifacts.go @@ -60,12 +60,18 @@ var opState []byte var clConfigContent []byte type ArtifactsBuilder struct { + // Shared options + prefundedAccounts []string + + // L1 options applyLatestL1Fork bool genesisDelay uint64 - applyLatestL2Fork *uint64 l1BlockTimeInSeconds uint64 + + // Op-stack options + l2Enabled bool + applyLatestL2Fork *uint64 opBlockTimeInSeconds uint64 - prefundedAccounts []string } func NewArtifactsBuilder() *ArtifactsBuilder { @@ -97,6 +103,11 @@ func (b *ArtifactsBuilder) L1BlockTime(blockTimeSeconds uint64) *ArtifactsBuilde return b } +func (b *ArtifactsBuilder) WithL2() *ArtifactsBuilder { + b.l2Enabled = true + return b +} + func (b *ArtifactsBuilder) OpBlockTime(blockTimeSeconds uint64) *ArtifactsBuilder { b.opBlockTimeInSeconds = blockTimeSeconds return b @@ -168,7 +179,7 @@ func (b *ArtifactsBuilder) Build(out *output) error { } // Apply Optimism pre-state - { + if b.l2Enabled { opAllocs, err := readOptimismL1Allocs() if err != nil { return err @@ -231,7 +242,7 @@ func (b *ArtifactsBuilder) Build(out *output) error { } slog.Debug("Done writing artifacts.") - { + if b.l2Enabled { // We have to start slightly ahead of L1 genesis time opTimestamp := genesisTime + 2 diff --git a/playground/artifacts_test.go b/playground/artifacts_test.go index a67b1f5..461c99e 100644 --- a/playground/artifacts_test.go +++ b/playground/artifacts_test.go @@ -25,6 +25,7 @@ func TestL2PrefundedAccounts(t *testing.T) { o := newTestOutput(t) b := NewArtifactsBuilder() + b.WithL2() require.NoError(t, b.Build(o)) genesisRaw, err := o.Read("l2-genesis.json") diff --git a/playground/recipe_opstack.go b/playground/recipe_opstack.go index e658db0..ab318c9 100644 --- a/playground/recipe_opstack.go +++ b/playground/recipe_opstack.go @@ -67,6 +67,7 @@ func (o *OpRecipe) Flags() *flag.FlagSet { func (o *OpRecipe) Artifacts() *ArtifactsBuilder { builder := NewArtifactsBuilder() + builder.WithL2() builder.ApplyLatestL2Fork(o.enableLatestFork) builder.OpBlockTime(o.blockTime) return builder