Skip to content
Closed
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
20 changes: 20 additions & 0 deletions playground/artifacts.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,9 @@ func (b *ArtifactsBuilder) Build(out *output) error {
return err
}

// add Safe Singleton Factory (deterministic CREATE2 deployer)
appendSafeSingletonFactoryToAlloc(&gen.Alloc)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Safe Singleton Factory is added before Optimism L1 allocs are applied via maps.Copy (line 277). If the Optimism allocs ever include the same address (0x914d7Fec6aaC8cd542e72Bca78B30650d45643d7), maps.Copy will silently overwrite it. Consider moving this call after the Optimism allocs are applied, or at least after line 277, to ensure the factory is always present.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dvush WDYT?


// Apply Optimism pre-state
var l2Fork *l2ForkConfig
if b.l2Enabled {
Expand Down Expand Up @@ -363,6 +366,9 @@ func (b *ArtifactsBuilder) Build(out *output) error {
return err
}

// add Safe Singleton Factory (deterministic CREATE2 deployer)
appendSafeSingletonFactoryToAlloc(&allocs)

// override l2 genesis, make the timestamp start 2 seconds after the L1 genesis
input := map[string]interface{}{
"timestamp": hexutil.Uint64(opTimestamp).String(),
Expand Down Expand Up @@ -848,6 +854,20 @@ func appendPrefundedAccountsToAlloc(allocs *types.GenesisAlloc, privKeys []strin
return nil
}

// safeSingletonFactoryAddress is the canonical address of the Safe Singleton Factory
// (deterministic CREATE2 deployer) from https://github.com/safe-global/safe-singleton-factory
var safeSingletonFactoryAddress = gethcommon.HexToAddress("0x914d7Fec6aaC8cd542e72Bca78B30650d45643d7")

// safeSingletonFactoryCode is the runtime bytecode of the Safe Singleton Factory
var safeSingletonFactoryCode = gethcommon.FromHex("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3")

func appendSafeSingletonFactoryToAlloc(allocs *types.GenesisAlloc) {
(*allocs)[safeSingletonFactoryAddress] = types.Account{
Balance: big.NewInt(0),
Code: safeSingletonFactoryCode,
}
}

func appendPredeploysToAlloc(allocs *types.GenesisAlloc, predeploys types.GenesisAlloc) error {
for addr, account := range predeploys {
if _, exists := (*allocs)[addr]; exists {
Expand Down
3 changes: 1 addition & 2 deletions playground/components.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@ package playground

import (
"context"
_ "embed"
"fmt"
"os"
"strconv"
"strings"
"time"

_ "embed"

"github.com/ethereum/go-ethereum/common/hexutil"
mevboostrelay "github.com/flashbots/builder-playground/mev-boost-relay"
"github.com/flashbots/go-boost-utils/bls"
Expand Down