Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions playground/artifacts.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions playground/artifacts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
1 change: 1 addition & 0 deletions playground/recipe_opstack.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down