diff --git a/go.mod b/go.mod index 5454732a74a04..f0c41e07d509f 100644 --- a/go.mod +++ b/go.mod @@ -215,7 +215,6 @@ require ( github.com/shirou/gopsutil v3.21.11+incompatible // indirect github.com/sirupsen/logrus v1.9.3 // indirect github.com/spaolacci/murmur3 v1.1.0 // indirect - github.com/status-im/keycard-go v0.2.0 // indirect github.com/stretchr/objx v0.5.2 // indirect github.com/supranational/blst v0.3.13 // indirect github.com/syndtr/goleveldb v1.0.1-0.20220614013038-64ee5596c38a // indirect @@ -250,9 +249,11 @@ require ( rsc.io/tmplfunc v0.0.3 // indirect ) -replace github.com/ethereum/go-ethereum => github.com/ethereum-optimism/op-geth v1.101411.2-rc.2 +//replace github.com/ethereum/go-ethereum => github.com/ethereum-optimism/op-geth v1.101411.2-rc.2 -//replace github.com/ethereum/go-ethereum => ../go-ethereum +replace github.com/ethereum/go-ethereum => github.com/roberto-bayardo/op-geth v0.0.0-20241120170924-fdfd720a3d60 + +//replace github.com/ethereum/go-ethereum => ../op-geth // replace github.com/ethereum-optimism/superchain-registry/superchain => ../superchain-registry/superchain diff --git a/go.sum b/go.sum index 60b90554c2e86..3268f18dffc51 100644 --- a/go.sum +++ b/go.sum @@ -187,8 +187,6 @@ github.com/elastic/gosigar v0.14.3 h1:xwkKwPia+hSfg9GqrCUKYdId102m9qTJIIr7egmK/u github.com/elastic/gosigar v0.14.3/go.mod h1:iXRIGg2tLnu7LBdpqzyQfGDEidKCfWcCMS0WKyPWoMs= github.com/ethereum-optimism/go-ethereum-hdwallet v0.1.3 h1:RWHKLhCrQThMfch+QJ1Z8veEq5ZO3DfIhZ7xgRP9WTc= github.com/ethereum-optimism/go-ethereum-hdwallet v0.1.3/go.mod h1:QziizLAiF0KqyLdNJYD7O5cpDlaFMNZzlxYNcWsJUxs= -github.com/ethereum-optimism/op-geth v1.101411.2-rc.2 h1:3suWTU9DwBdY8Yy/ZgZLB/yBy3TwpntpkUn61mZgNpY= -github.com/ethereum-optimism/op-geth v1.101411.2-rc.2/go.mod h1:dITJzx1KXsV2KusscsktidEb00blTSyFhalq8CjfsUY= github.com/ethereum-optimism/superchain-registry/superchain v0.0.0-20241119111730-bee358f6d6e6 h1:+AIYWDX7FeWRLnBVqPiwireTacLLGGww1slGyv+YN0o= github.com/ethereum-optimism/superchain-registry/superchain v0.0.0-20241119111730-bee358f6d6e6/go.mod h1:9feO8jcL5OZ1tvRjEfNAHz4Aggvd6373l+ZxmZZAyZs= github.com/ethereum/c-kzg-4844 v1.0.0 h1:0X1LBXxaEtYD9xsyj9B9ctQEZIpnvVDeoBx8aHEwTNA= @@ -711,6 +709,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.4 h1:8TfxU8dW6PdqD27gjM8MVNuicgxIjxpm4K7x4jp8sis= github.com/rivo/uniseg v0.4.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= +github.com/roberto-bayardo/op-geth v0.0.0-20241120170924-fdfd720a3d60 h1:ayTFlteIPMYAFu4L0kx/DJCgmP/m8AeZj3AYAHdg3ZA= +github.com/roberto-bayardo/op-geth v0.0.0-20241120170924-fdfd720a3d60/go.mod h1:RSgQAtx+b5n1GsLTZU6rURjXXfDIUOziVK7O1DJNVRI= 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= @@ -760,8 +760,6 @@ github.com/sourcegraph/syntaxhighlight v0.0.0-20170531221838-bd320f5d308e/go.mod github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI= github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= -github.com/status-im/keycard-go v0.2.0 h1:QDLFswOQu1r5jsycloeQh3bVU8n/NatHHaZobtDnDzA= -github.com/status-im/keycard-go v0.2.0/go.mod h1:wlp8ZLbsmrF6g6WjugPAx+IzoLrkdf9+mHxBEeo3Hbg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= diff --git a/op-chain-ops/cmd/check-canyon/main.go b/op-chain-ops/cmd/check-canyon/main.go index d0f3bdb89d0e5..a560840a08d6d 100644 --- a/op-chain-ops/cmd/check-canyon/main.go +++ b/op-chain-ops/cmd/check-canyon/main.go @@ -17,7 +17,6 @@ import ( "github.com/mattn/go-isatty" "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/common/math" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/ethclient" @@ -48,9 +47,10 @@ func CalcBaseFee(parent eth.BlockInfo, elasticity uint64, canyonActive bool) *bi num.Mul(num, parent.BaseFee()) num.Div(num, denom.SetUint64(parentGasTarget)) num.Div(num, denom.SetUint64(denomUint)) - baseFeeDelta := math.BigMax(num, common.Big1) - - return num.Add(parent.BaseFee(), baseFeeDelta) + if num.Cmp(common.Big1) < 0 { + num.Set(common.Big1) + } + return num.Add(num, parent.BaseFee()) } else { // Otherwise if the parent block used less gas than its target, the baseFee should decrease. // max(0, parentBaseFee * gasUsedDelta / parentGasTarget / baseFeeChangeDenominator) @@ -58,9 +58,11 @@ func CalcBaseFee(parent eth.BlockInfo, elasticity uint64, canyonActive bool) *bi num.Mul(num, parent.BaseFee()) num.Div(num, denom.SetUint64(parentGasTarget)) num.Div(num, denom.SetUint64(denomUint)) - baseFee := num.Sub(parent.BaseFee(), num) - - return math.BigMax(baseFee, common.Big0) + num.Sub(parent.BaseFee(), num) + if num.Cmp(common.Big0) < 0 { + return common.Big0 + } + return num } } diff --git a/op-chain-ops/genesis/genesis.go b/op-chain-ops/genesis/genesis.go index ee78368523588..74361a3c6bb91 100644 --- a/op-chain-ops/genesis/genesis.go +++ b/op-chain-ops/genesis/genesis.go @@ -42,35 +42,34 @@ func NewL2Genesis(config *DeployConfig, l1StartHeader *types.Header) (*core.Gene l1StartTime := l1StartHeader.Time optimismChainConfig := params.ChainConfig{ - ChainID: new(big.Int).SetUint64(config.L2ChainID), - 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), - MergeNetsplitBlock: big.NewInt(0), - TerminalTotalDifficulty: big.NewInt(0), - TerminalTotalDifficultyPassed: true, - BedrockBlock: new(big.Int).SetUint64(uint64(config.L2GenesisBlockNumber)), - RegolithTime: config.RegolithTime(l1StartTime), - CanyonTime: config.CanyonTime(l1StartTime), - ShanghaiTime: config.CanyonTime(l1StartTime), - CancunTime: config.EcotoneTime(l1StartTime), - EcotoneTime: config.EcotoneTime(l1StartTime), - FjordTime: config.FjordTime(l1StartTime), - GraniteTime: config.GraniteTime(l1StartTime), - HoloceneTime: config.HoloceneTime(l1StartTime), - InteropTime: config.InteropTime(l1StartTime), + ChainID: new(big.Int).SetUint64(config.L2ChainID), + 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), + MergeNetsplitBlock: big.NewInt(0), + TerminalTotalDifficulty: big.NewInt(0), + BedrockBlock: new(big.Int).SetUint64(uint64(config.L2GenesisBlockNumber)), + RegolithTime: config.RegolithTime(l1StartTime), + CanyonTime: config.CanyonTime(l1StartTime), + ShanghaiTime: config.CanyonTime(l1StartTime), + CancunTime: config.EcotoneTime(l1StartTime), + EcotoneTime: config.EcotoneTime(l1StartTime), + FjordTime: config.FjordTime(l1StartTime), + GraniteTime: config.GraniteTime(l1StartTime), + HoloceneTime: config.HoloceneTime(l1StartTime), + InteropTime: config.InteropTime(l1StartTime), Optimism: ¶ms.OptimismConfig{ EIP1559Denominator: eip1559Denom, EIP1559Elasticity: eip1559Elasticity, @@ -143,9 +142,8 @@ func NewL1Genesis(config *DeployConfig) (*core.Genesis, error) { ShanghaiTime: u64ptr(0), CancunTime: u64ptr(0), // To enable post-Merge consensus at genesis - MergeNetsplitBlock: big.NewInt(0), - TerminalTotalDifficulty: big.NewInt(0), - TerminalTotalDifficultyPassed: true, + MergeNetsplitBlock: big.NewInt(0), + TerminalTotalDifficulty: big.NewInt(0), } gasLimit := config.L1GenesisBlockGasLimit diff --git a/op-chain-ops/script/forking/db.go b/op-chain-ops/script/forking/db.go index 0a073500d247c..7e90afa818a36 100644 --- a/op-chain-ops/script/forking/db.go +++ b/op-chain-ops/script/forking/db.go @@ -109,10 +109,10 @@ func (f *ForkDB) TrieDB() *triedb.Database { IsVerkle: false, HashDB: nil, PathDB: &pathdb.Config{ - StateHistory: 0, - CleanCacheSize: 0, - DirtyCacheSize: 0, - ReadOnly: true, + StateHistory: 0, + CleanCacheSize: 0, + WriteBufferSize: 0, + ReadOnly: true, }, }) return tdb diff --git a/op-chain-ops/script/forking/state.go b/op-chain-ops/script/forking/state.go index c3b6da1e32366..e59b1c4bc2922 100644 --- a/op-chain-ops/script/forking/state.go +++ b/op-chain-ops/script/forking/state.go @@ -250,12 +250,12 @@ func (fst *ForkableState) CreateContract(address common.Address) { fst.stateFor(address).CreateContract(address) } -func (fst *ForkableState) SubBalance(address common.Address, u *uint256.Int, reason tracing.BalanceChangeReason) { - fst.stateFor(address).SubBalance(address, u, reason) +func (fst *ForkableState) SubBalance(address common.Address, u *uint256.Int, reason tracing.BalanceChangeReason) uint256.Int { + return fst.stateFor(address).SubBalance(address, u, reason) } -func (fst *ForkableState) AddBalance(address common.Address, u *uint256.Int, reason tracing.BalanceChangeReason) { - fst.stateFor(address).AddBalance(address, u, reason) +func (fst *ForkableState) AddBalance(address common.Address, u *uint256.Int, reason tracing.BalanceChangeReason) uint256.Int { + return fst.stateFor(address).AddBalance(address, u, reason) } func (fst *ForkableState) GetBalance(address common.Address) *uint256.Int { @@ -306,8 +306,8 @@ func (fst *ForkableState) GetState(address common.Address, k common.Hash) common return fst.stateFor(address).GetState(address, k) } -func (fst *ForkableState) SetState(address common.Address, k common.Hash, v common.Hash) { - fst.stateFor(address).SetState(address, k, v) +func (fst *ForkableState) SetState(address common.Address, k common.Hash, v common.Hash) common.Hash { + return fst.stateFor(address).SetState(address, k, v) } func (fst *ForkableState) GetStorageRoot(addr common.Address) common.Hash { @@ -322,16 +322,16 @@ func (fst *ForkableState) SetTransientState(addr common.Address, key, value comm fst.stateFor(addr).SetTransientState(addr, key, value) } -func (fst *ForkableState) SelfDestruct(address common.Address) { - fst.stateFor(address).SelfDestruct(address) +func (fst *ForkableState) SelfDestruct(address common.Address) uint256.Int { + return fst.stateFor(address).SelfDestruct(address) } func (fst *ForkableState) HasSelfDestructed(address common.Address) bool { return fst.stateFor(address).HasSelfDestructed(address) } -func (fst *ForkableState) Selfdestruct6780(address common.Address) { - fst.stateFor(address).Selfdestruct6780(address) +func (fst *ForkableState) SelfDestruct6780(address common.Address) (uint256.Int, bool) { + return fst.stateFor(address).SelfDestruct6780(address) } func (fst *ForkableState) Exist(address common.Address) bool { diff --git a/op-chain-ops/script/script.go b/op-chain-ops/script/script.go index 9a3d9ae80201d..f1b2399884d9b 100644 --- a/op-chain-ops/script/script.go +++ b/op-chain-ops/script/script.go @@ -209,12 +209,11 @@ func NewHost( GrayGlacierBlock: big.NewInt(0), MergeNetsplitBlock: big.NewInt(0), // Ethereum forks in proof-of-stake era. - TerminalTotalDifficulty: big.NewInt(1), - TerminalTotalDifficultyPassed: true, - ShanghaiTime: new(uint64), - CancunTime: new(uint64), - PragueTime: nil, - VerkleTime: nil, + TerminalTotalDifficulty: big.NewInt(1), + ShanghaiTime: new(uint64), + CancunTime: new(uint64), + PragueTime: nil, + VerkleTime: nil, // OP-Stack forks are disabled, since we use this for L1. BedrockBlock: nil, RegolithTime: nil, diff --git a/op-program/client/l2/db.go b/op-program/client/l2/db.go index 4f901ac9304e4..bf6ca05365b5e 100644 --- a/op-program/client/l2/db.go +++ b/op-program/client/l2/db.go @@ -72,6 +72,10 @@ func (o *OracleKeyValueStore) Delete(key []byte) error { panic("not supported") } +func (o *OracleKeyValueStore) DeleteRange(start, end []byte) error { + panic("not supported") +} + func (o *OracleKeyValueStore) Stat() (string, error) { panic("not supported") } diff --git a/op-program/client/l2/engineapi/l2_engine_api.go b/op-program/client/l2/engineapi/l2_engine_api.go index 273483893b375..c9a3ef526d3d7 100644 --- a/op-program/client/l2/engineapi/l2_engine_api.go +++ b/op-program/client/l2/engineapi/l2_engine_api.go @@ -301,7 +301,7 @@ func (ea *L2EngineAPI) NewPayloadV1(ctx context.Context, payload *eth.ExecutionP return ð.PayloadStatusV1{Status: eth.ExecutionInvalid}, engine.InvalidParams.With(errors.New("withdrawals not supported in V1")) } - return ea.newPayload(ctx, payload, nil, nil) + return ea.newPayload(ctx, payload, nil, nil, nil) } func (ea *L2EngineAPI) NewPayloadV2(ctx context.Context, payload *eth.ExecutionPayload) (*eth.PayloadStatusV1, error) { @@ -313,7 +313,7 @@ func (ea *L2EngineAPI) NewPayloadV2(ctx context.Context, payload *eth.ExecutionP return ð.PayloadStatusV1{Status: eth.ExecutionInvalid}, engine.InvalidParams.With(errors.New("non-nil withdrawals pre-shanghai")) } - return ea.newPayload(ctx, payload, nil, nil) + return ea.newPayload(ctx, payload, nil, nil, nil) } // Ported from: https://github.com/ethereum-optimism/op-geth/blob/c50337a60a1309a0f1dca3bf33ed1bb38c46cdd7/eth/catalyst/api.go#L486C1-L507 @@ -342,7 +342,7 @@ func (ea *L2EngineAPI) NewPayloadV3(ctx context.Context, params *eth.ExecutionPa } } - return ea.newPayload(ctx, params, versionedHashes, beaconRoot) + return ea.newPayload(ctx, params, versionedHashes, beaconRoot, nil) } func (ea *L2EngineAPI) getPayload(_ context.Context, payloadId eth.PayloadID) (*eth.ExecutionPayloadEnvelope, error) { @@ -479,7 +479,7 @@ func toGethWithdrawals(payload *eth.ExecutionPayload) []*types.Withdrawal { return result } -func (ea *L2EngineAPI) newPayload(_ context.Context, payload *eth.ExecutionPayload, hashes []common.Hash, root *common.Hash) (*eth.PayloadStatusV1, error) { +func (ea *L2EngineAPI) newPayload(_ context.Context, payload *eth.ExecutionPayload, hashes []common.Hash, root *common.Hash, requests [][]byte) (*eth.PayloadStatusV1, error) { ea.log.Trace("L2Engine API request received", "method", "ExecutePayload", "number", payload.BlockNumber, "hash", payload.BlockHash) txs := make([][]byte, len(payload.Transactions)) for i, tx := range payload.Transactions { @@ -503,7 +503,7 @@ func (ea *L2EngineAPI) newPayload(_ context.Context, payload *eth.ExecutionPaylo Withdrawals: toGethWithdrawals(payload), ExcessBlobGas: (*uint64)(payload.ExcessBlobGas), BlobGasUsed: (*uint64)(payload.BlobGasUsed), - }, hashes, root) + }, hashes, root, requests) if err != nil { log.Debug("Invalid NewPayload params", "params", payload, "error", err) return ð.PayloadStatusV1{Status: eth.ExecutionInvalidBlockHash}, nil diff --git a/op-program/client/mpt/db.go b/op-program/client/mpt/db.go index f190529912895..e6cc79160b1cc 100644 --- a/op-program/client/mpt/db.go +++ b/op-program/client/mpt/db.go @@ -31,6 +31,10 @@ func (p DB) Delete(key []byte) error { return nil } +func (p *DB) DeleteRange(start, end []byte) error { + panic("not supported") +} + func (p DB) Stat() (string, error) { panic("not supported") } diff --git a/op-wheel/cheat/cheat.go b/op-wheel/cheat/cheat.go index 1b5089c283648..1cd031d43592e 100644 --- a/op-wheel/cheat/cheat.go +++ b/op-wheel/cheat/cheat.go @@ -23,6 +23,7 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/ethdb" + "github.com/ethereum/go-ethereum/ethdb/leveldb" "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/rlp" "github.com/ethereum/go-ethereum/trie" @@ -43,18 +44,14 @@ type Cheater struct { func OpenGethRawDB(dataDirPath string, readOnly bool) (ethdb.Database, error) { // don't use readonly mode in actual DB, it doesn't work with Geth. - db, err := rawdb.Open(rawdb.OpenOptions{ - Type: "leveldb", - Directory: dataDirPath, - AncientsDirectory: filepath.Join(dataDirPath, "ancient"), - Namespace: "", - Cache: 2048, - Handles: 500, - ReadOnly: readOnly, - }) + kvs, err := leveldb.New(dataDirPath, 2048, 500, "", readOnly) if err != nil { return nil, fmt.Errorf("failed to open leveldb: %w", err) } + db, err := rawdb.NewDatabaseWithFreezer(kvs, filepath.Join(dataDirPath, "ancient"), "", readOnly) + if err != nil { + return nil, fmt.Errorf("failed to open db with freezer: %w", err) + } return db, nil }