Skip to content

Commit

Permalink
update geth moar
Browse files Browse the repository at this point in the history
  • Loading branch information
roberto-bayardo committed Mar 21, 2024
1 parent 5bcae37 commit 36325bf
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 66 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ require (
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0
github.com/ethereum-optimism/go-ethereum-hdwallet v0.1.3
github.com/ethereum-optimism/superchain-registry/superchain v0.0.0-20240306093353-c557df8e6f41
github.com/ethereum/go-ethereum v1.13.8
github.com/ethereum/go-ethereum v1.13.9
github.com/fsnotify/fsnotify v1.7.0
github.com/go-chi/chi/v5 v5.0.12
github.com/go-chi/docgen v1.2.0
Expand Down Expand Up @@ -217,7 +217,7 @@ require (
rsc.io/tmplfunc v0.0.3 // indirect
)

replace github.com/ethereum/go-ethereum v1.13.8 => github.com/roberto-bayardo/op-geth v0.0.0-20240321010510-953d48bf7ab5
replace github.com/ethereum/go-ethereum v1.13.9 => github.com/roberto-bayardo/op-geth v0.0.0-20240321212348-438dd5ed418e

// replace github.com/ethereum-optimism/superchain-registry/superchain => ../superchain-registry/superchain

Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -679,8 +679,8 @@ github.com/raulk/go-watchdog v1.3.0/go.mod h1:fIvOnLbF0b0ZwkB9YU4mOW9Did//4vPZtD
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.4.3 h1:utMvzDsuh3suAEnhH0RdHmoPbU648o6CvXxTx4SBMOw=
github.com/rivo/uniseg v0.4.3/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
github.com/roberto-bayardo/op-geth v0.0.0-20240321010510-953d48bf7ab5 h1:Iyl99gawRUzc/MsL5/UGAnN+onjoRsGbnZhLT9hxKMU=
github.com/roberto-bayardo/op-geth v0.0.0-20240321010510-953d48bf7ab5/go.mod h1:k0UbrLuOITLD8goCyA2xWebAL03n2BZUCfwos0rxz60=
github.com/roberto-bayardo/op-geth v0.0.0-20240321212348-438dd5ed418e h1:DJb7sxdfBGUJbXZ8pTfqTfALvIbSp2yypsRfIHUS9g4=
github.com/roberto-bayardo/op-geth v0.0.0-20240321212348-438dd5ed418e/go.mod h1:k0UbrLuOITLD8goCyA2xWebAL03n2BZUCfwos0rxz60=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
Expand Down
2 changes: 1 addition & 1 deletion op-chain-ops/crossdomain/legacy_withdrawal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ func findPassMessage(trace *callFrame) *callFrame {

// findCrossDomainMessage will parse a CrossDomainMessage from a receipt
func findCrossDomainMessage(receipt *types.Receipt) (*crossdomain.CrossDomainMessage, error) {
backend := backends.NewSimulatedBackend(nil, 15000000)
backend := backends.NewSimulatedBackend(nil, 15000000) // nolint:staticcheck
l2xdm, err := bindings.NewL2CrossDomainMessenger(predeploys.L2CrossDomainMessengerAddr, backend)
if err != nil {
return nil, err
Expand Down
75 changes: 22 additions & 53 deletions op-chain-ops/deployer/deployer.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@ import (
"github.com/ethereum/go-ethereum/accounts/abi/bind/backends"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/consensus/beacon"
"github.com/ethereum/go-ethereum/consensus/ethash"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/eth/ethconfig"
"github.com/ethereum/go-ethereum/params"
)

Expand Down Expand Up @@ -50,54 +49,25 @@ type Deployer func(*backends.SimulatedBackend, *bind.TransactOpts, Constructor)
// NewL1Backend returns a SimulatedBackend suitable for L1. It has
// the latest L1 hardforks enabled.
func NewL1Backend() (*backends.SimulatedBackend, error) {
backend, err := NewBackendWithGenesisTimestamp(ChainID, 0, true, nil)
backend, err := NewBackendWithGenesisTimestamp(ChainID, 0, nil)
return backend, err
}

// NewL2Backend returns a SimulatedBackend suitable for L2.
// It has the latest L2 hardforks enabled.
func NewL2Backend() (*backends.SimulatedBackend, error) {
backend, err := NewBackendWithGenesisTimestamp(ChainID, 0, false, nil)
backend, err := NewBackendWithGenesisTimestamp(ChainID, 0, nil)
return backend, err
}

// NewL2BackendWithChainIDAndPredeploys returns a SimulatedBackend suitable for L2.
// It has the latest L2 hardforks enabled, and allows for the configuration of the network's chain ID and predeploys.
func NewL2BackendWithChainIDAndPredeploys(chainID *big.Int, predeploys map[string]*common.Address) (*backends.SimulatedBackend, error) {
backend, err := NewBackendWithGenesisTimestamp(chainID, 0, false, predeploys)
backend, err := NewBackendWithGenesisTimestamp(chainID, 0, predeploys)
return backend, err
}

func NewBackendWithGenesisTimestamp(chainID *big.Int, ts uint64, shanghai bool, predeploys map[string]*common.Address) (*backends.SimulatedBackend, error) {
chainConfig := params.ChainConfig{
ChainID: chainID,
HomesteadBlock: big.NewInt(0),
DAOForkBlock: nil,
DAOForkSupport: false,
EIP150Block: big.NewInt(0),
EIP155Block: big.NewInt(0),
EIP158Block: big.NewInt(0),
ByzantiumBlock: big.NewInt(0),
ConstantinopleBlock: big.NewInt(0),
PetersburgBlock: big.NewInt(0),
IstanbulBlock: big.NewInt(0),
MuirGlacierBlock: big.NewInt(0),
BerlinBlock: big.NewInt(0),
LondonBlock: big.NewInt(0),
ArrowGlacierBlock: big.NewInt(0),
GrayGlacierBlock: big.NewInt(0),
// Activated proof of stake. We manually build/commit blocks in the simulator anyway,
// and the timestamp verification of PoS is not against the wallclock,
// preventing blocks from getting stuck temporarily in the future-blocks queue, decreasing setup time a lot.
MergeNetsplitBlock: big.NewInt(0),
TerminalTotalDifficulty: big.NewInt(0),
TerminalTotalDifficultyPassed: true,
}

if shanghai {
chainConfig.ShanghaiTime = u64ptr(0)
}

func NewBackendWithGenesisTimestamp(chainID *big.Int, ts uint64, predeploys map[string]*common.Address) (*backends.SimulatedBackend, error) {
alloc := core.GenesisAlloc{
crypto.PubkeyToAddress(TestKey.PublicKey): core.GenesisAccount{
Balance: thousandETH,
Expand All @@ -113,19 +83,18 @@ func NewBackendWithGenesisTimestamp(chainID *big.Int, ts uint64, shanghai bool,
}
}

return backends.NewSimulatedBackendWithOpts(
backends.WithCacheConfig(&core.CacheConfig{
Preimages: true,
}),
backends.WithGenesis(core.Genesis{
Config: &chainConfig,
Timestamp: ts,
Difficulty: big.NewInt(0),
Alloc: alloc,
GasLimit: 30_000_000,
}),
backends.WithConsensus(beacon.New(ethash.NewFaker())),
), nil
cfg := ethconfig.Defaults
cfg.Preimages = true
config := params.AllDevChainProtocolChanges
config.Ethash = new(params.EthashConfig)
cfg.Genesis = &core.Genesis{
Config: config,
Timestamp: ts,
Difficulty: big.NewInt(0),
Alloc: alloc,
GasLimit: 30_000_000,
}
return backends.NewSimulatedBackendFromConfig(cfg), nil
}

func Deploy(backend *backends.SimulatedBackend, constructors []Constructor, cb Deployer) ([]Deployment, error) {
Expand Down Expand Up @@ -188,7 +157,11 @@ func Deploy(backend *backends.SimulatedBackend, constructors []Constructor, cb D
// The function logs a fatal error and exits if there are any issues with transaction mining, if the deployment fails,
// or if the deployed bytecode is not found at the computed address.
func DeployWithDeterministicDeployer(backend *backends.SimulatedBackend, contractName string) ([]byte, error) {
opts, err := bind.NewKeyedTransactorWithChainID(TestKey, backend.Blockchain().Config().ChainID)
cid, err := backend.ChainID(context.Background())
if err != nil {
return nil, err
}
opts, err := bind.NewKeyedTransactorWithChainID(TestKey, cid)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -242,10 +215,6 @@ func DeployWithDeterministicDeployer(backend *backends.SimulatedBackend, contrac
return code, nil
}

func u64ptr(n uint64) *uint64 {
return &n
}

// create2Address computes the Ethereum address for a contract created using the CREATE2 opcode.
//
// The CREATE2 opcode allows for more deterministic address generation in Ethereum, as it computes the
Expand Down
2 changes: 1 addition & 1 deletion op-chain-ops/genesis/layer_one_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func TestBuildL1DeveloperGenesis(t *testing.T) {
genesis, err := BuildL1DeveloperGenesis(config, dump, nil)
require.NoError(t, err)

sim := backends.NewSimulatedBackend(
sim := backends.NewSimulatedBackend( // nolint:staticcheck
genesis.Alloc,
15000000,
)
Expand Down
2 changes: 1 addition & 1 deletion op-chain-ops/genesis/layer_two_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ var testKey, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d

// Tests the BuildL2MainnetGenesis factory with the provided config.
func testBuildL2Genesis(t *testing.T, config *genesis.DeployConfig) *core.Genesis {
backend := backends.NewSimulatedBackend(
backend := backends.NewSimulatedBackend( // nolint:staticcheck
core.GenesisAlloc{
crypto.PubkeyToAddress(testKey.PublicKey): {Balance: big.NewInt(10000000000000000)},
},
Expand Down
2 changes: 1 addition & 1 deletion op-chain-ops/state/state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func TestSetAndGetStorageSlots(t *testing.T) {
slots, err := state.ComputeStorageSlots(&layout, values)
require.Nil(t, err)

backend := backends.NewSimulatedBackend(
backend := backends.NewSimulatedBackend( // nolint:staticcheck
core.GenesisAlloc{
crypto.PubkeyToAddress(testKey.PublicKey): {Balance: big.NewInt(10000000000000000)},
},
Expand Down
2 changes: 1 addition & 1 deletion op-proposer/proposer/abi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func simulatedBackend() (privateKey *ecdsa.PrivateKey, address common.Address, o
if err != nil {
return nil, common.Address{}, nil, nil, err
}
backend = backends.NewSimulatedBackend(core.GenesisAlloc{from: {Balance: big.NewInt(params.Ether)}}, 50_000_000)
backend = backends.NewSimulatedBackend(core.GenesisAlloc{from: {Balance: big.NewInt(params.Ether)}}, 50_000_000) // nolint:staticcheck

return privateKey, from, opts, backend, nil
}
Expand Down
4 changes: 2 additions & 2 deletions op-ufm/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
cloud.google.com/go/kms v1.12.1
github.com/BurntSushi/toml v1.3.2
github.com/ethereum-optimism/optimism v1.6.2-0.20240222202618-f707883038d5
github.com/ethereum/go-ethereum v1.13.8
github.com/ethereum/go-ethereum v1.13.9
github.com/gorilla/mux v1.8.0
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.19.0
Expand Down Expand Up @@ -98,6 +98,6 @@ require (
rsc.io/tmplfunc v0.0.3 // indirect
)

replace github.com/ethereum/go-ethereum v1.13.8 => github.com/ethereum-optimism/op-geth v1.101308.2-rc.2
replace github.com/ethereum/go-ethereum v1.13.9 => github.com/roberto-bayardo/op-geth v0.0.0-20240321212348-438dd5ed418e

replace github.com/ethereum-optimism/optimism => ../.
4 changes: 2 additions & 2 deletions op-ufm/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@ github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1m
github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk=
github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0=
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/ethereum-optimism/op-geth v1.101308.2-rc.2 h1:Tjm2n7/actyINbRIbqeDS+SyWAcIl+pRfOHODwW7lpQ=
github.com/ethereum-optimism/op-geth v1.101308.2-rc.2/go.mod h1:RPqVhnX00rJNys/YRDK4Wl4PvS6dgFrLqhsopIZOhEw=
github.com/ethereum-optimism/superchain-registry/superchain v0.0.0-20240306093353-c557df8e6f41 h1:WKJvsRyW/YNgyT0P2x5U530ITOY8Dv9TrZnbliqSXd8=
github.com/ethereum-optimism/superchain-registry/superchain v0.0.0-20240306093353-c557df8e6f41/go.mod h1:7xh2awFQqsiZxFrHKTgEd+InVfDRrkKVUIuK8SAFHp0=
github.com/ethereum/c-kzg-4844 v0.4.0 h1:3MS1s4JtA868KpJxroZoepdV0ZKBp3u/O5HcZ7R3nlY=
Expand Down Expand Up @@ -240,6 +238,8 @@ github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3c
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.4.3 h1:utMvzDsuh3suAEnhH0RdHmoPbU648o6CvXxTx4SBMOw=
github.com/rivo/uniseg v0.4.3/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
github.com/roberto-bayardo/op-geth v0.0.0-20240321212348-438dd5ed418e h1:DJb7sxdfBGUJbXZ8pTfqTfALvIbSp2yypsRfIHUS9g4=
github.com/roberto-bayardo/op-geth v0.0.0-20240321212348-438dd5ed418e/go.mod h1:k0UbrLuOITLD8goCyA2xWebAL03n2BZUCfwos0rxz60=
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
Expand Down

0 comments on commit 36325bf

Please sign in to comment.