Commit e791c38d authored by protolambda's avatar protolambda

go: update op-geth to include v1.12.2 changes

parent 76b65894
...@@ -9,7 +9,7 @@ require ( ...@@ -9,7 +9,7 @@ require (
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0
github.com/ethereum-optimism/go-ethereum-hdwallet v0.1.3 github.com/ethereum-optimism/go-ethereum-hdwallet v0.1.3
github.com/ethereum-optimism/superchain-registry/superchain v0.0.0-20230921190252-f29074de9e36 github.com/ethereum-optimism/superchain-registry/superchain v0.0.0-20230921190252-f29074de9e36
github.com/ethereum/go-ethereum v1.12.0 github.com/ethereum/go-ethereum v1.12.2
github.com/fsnotify/fsnotify v1.6.0 github.com/fsnotify/fsnotify v1.6.0
github.com/go-chi/chi/v5 v5.0.10 github.com/go-chi/chi/v5 v5.0.10
github.com/go-chi/docgen v1.2.0 github.com/go-chi/docgen v1.2.0
...@@ -68,8 +68,8 @@ require ( ...@@ -68,8 +68,8 @@ require (
github.com/containerd/cgroups v1.1.0 // indirect github.com/containerd/cgroups v1.1.0 // indirect
github.com/coreos/go-systemd/v22 v22.5.0 // indirect github.com/coreos/go-systemd/v22 v22.5.0 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
github.com/crate-crypto/go-ipa v0.0.0-20220523130400-f11357ae11c7 // indirect github.com/crate-crypto/go-ipa v0.0.0-20230601170251-1830d0757c80 // indirect
github.com/crate-crypto/go-kzg-4844 v0.2.0 // indirect github.com/crate-crypto/go-kzg-4844 v0.3.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect github.com/davecgh/go-spew v1.1.1 // indirect
github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c // indirect github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c // indirect
github.com/deckarep/golang-set/v2 v2.1.0 // indirect github.com/deckarep/golang-set/v2 v2.1.0 // indirect
...@@ -78,16 +78,16 @@ require ( ...@@ -78,16 +78,16 @@ require (
github.com/dlclark/regexp2 v1.7.0 // indirect github.com/dlclark/regexp2 v1.7.0 // indirect
github.com/docker/docker v20.10.24+incompatible // indirect github.com/docker/docker v20.10.24+incompatible // indirect
github.com/docker/go-units v0.5.0 // indirect github.com/docker/go-units v0.5.0 // indirect
github.com/dop251/goja v0.0.0-20230122112309-96b1610dd4f7 // indirect github.com/dop251/goja v0.0.0-20230605162241-28ee0ee714f3 // indirect
github.com/elastic/gosigar v0.14.2 // indirect github.com/elastic/gosigar v0.14.2 // indirect
github.com/ethereum/c-kzg-4844 v0.2.0 // indirect github.com/ethereum/c-kzg-4844 v0.3.1 // indirect
github.com/fatih/color v1.7.0 // indirect github.com/fatih/color v1.7.0 // indirect
github.com/felixge/fgprof v0.9.3 // indirect github.com/felixge/fgprof v0.9.3 // indirect
github.com/fjl/memsize v0.0.1 // indirect github.com/fjl/memsize v0.0.1 // indirect
github.com/flynn/noise v1.0.0 // indirect github.com/flynn/noise v1.0.0 // indirect
github.com/francoispqt/gojay v1.2.13 // indirect github.com/francoispqt/gojay v1.2.13 // indirect
github.com/gballet/go-libpcsclite v0.0.0-20191108122812-4678299bea08 // indirect github.com/gballet/go-libpcsclite v0.0.0-20191108122812-4678299bea08 // indirect
github.com/gballet/go-verkle v0.0.0-20220902153445-097bd83b7732 // indirect github.com/gballet/go-verkle v0.0.0-20230607174250-df487255f46b // indirect
github.com/getsentry/sentry-go v0.18.0 // indirect github.com/getsentry/sentry-go v0.18.0 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect github.com/go-ole/go-ole v1.2.6 // indirect
github.com/go-sourcemap/sourcemap v2.1.3+incompatible // indirect github.com/go-sourcemap/sourcemap v2.1.3+incompatible // indirect
...@@ -106,6 +106,7 @@ require ( ...@@ -106,6 +106,7 @@ require (
github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-bexpr v0.1.11 // indirect github.com/hashicorp/go-bexpr v0.1.11 // indirect
github.com/hashicorp/golang-lru/arc/v2 v2.0.5 // indirect github.com/hashicorp/golang-lru/arc/v2 v2.0.5 // indirect
github.com/holiman/billy v0.0.0-20230718173358-1c7e68d277a7 // indirect
github.com/holiman/bloomfilter/v2 v2.0.3 // indirect github.com/holiman/bloomfilter/v2 v2.0.3 // indirect
github.com/huin/goupnp v1.2.0 // indirect github.com/huin/goupnp v1.2.0 // indirect
github.com/influxdata/influxdb-client-go/v2 v2.4.0 // indirect github.com/influxdata/influxdb-client-go/v2 v2.4.0 // indirect
...@@ -122,7 +123,7 @@ require ( ...@@ -122,7 +123,7 @@ require (
github.com/jedisct1/go-minisign v0.0.0-20190909160543-45766022959e // indirect github.com/jedisct1/go-minisign v0.0.0-20190909160543-45766022959e // indirect
github.com/jinzhu/inflection v1.0.0 // indirect github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect github.com/jinzhu/now v1.1.5 // indirect
github.com/karalabe/usb v0.0.2 // indirect github.com/karalabe/usb v0.0.3-0.20230711191512-61db3e06439c // indirect
github.com/klauspost/compress v1.16.7 // indirect github.com/klauspost/compress v1.16.7 // indirect
github.com/klauspost/cpuid/v2 v2.2.5 // indirect github.com/klauspost/cpuid/v2 v2.2.5 // indirect
github.com/koron/go-ssdp v0.0.4 // indirect github.com/koron/go-ssdp v0.0.4 // indirect
...@@ -189,6 +190,7 @@ require ( ...@@ -189,6 +190,7 @@ require (
github.com/tyler-smith/go-bip39 v1.1.0 // indirect github.com/tyler-smith/go-bip39 v1.1.0 // indirect
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
github.com/yusufpapurcu/wmi v1.2.2 // indirect github.com/yusufpapurcu/wmi v1.2.2 // indirect
go.uber.org/automaxprocs v1.5.2 // indirect
go.uber.org/dig v1.17.0 // indirect go.uber.org/dig v1.17.0 // indirect
go.uber.org/fx v1.20.0 // indirect go.uber.org/fx v1.20.0 // indirect
go.uber.org/multierr v1.11.0 // indirect go.uber.org/multierr v1.11.0 // indirect
...@@ -207,6 +209,6 @@ require ( ...@@ -207,6 +209,6 @@ require (
rsc.io/tmplfunc v0.0.3 // indirect rsc.io/tmplfunc v0.0.3 // indirect
) )
replace github.com/ethereum/go-ethereum v1.12.0 => github.com/ethereum-optimism/op-geth v1.101200.2-rc.1.0.20230914224024-b84ba11915a0 replace github.com/ethereum/go-ethereum v1.12.2 => github.com/ethereum-optimism/op-geth v1.101200.2-rc.1.0.20230920123712-40033c03a5ca
//replace github.com/ethereum/go-ethereum v1.12.0 => ../go-ethereum //replace github.com/ethereum/go-ethereum v1.12.2 => ../go-ethereum
This diff is collapsed.
...@@ -28,7 +28,7 @@ type MemoryStateDB struct { ...@@ -28,7 +28,7 @@ type MemoryStateDB struct {
func NewMemoryStateDB(genesis *core.Genesis) *MemoryStateDB { func NewMemoryStateDB(genesis *core.Genesis) *MemoryStateDB {
if genesis == nil { if genesis == nil {
genesis = core.DeveloperGenesisBlock(15, 15_000_000, common.Address{}) genesis = core.DeveloperGenesisBlock(15_000_000, common.Address{})
} }
return &MemoryStateDB{ return &MemoryStateDB{
...@@ -235,12 +235,16 @@ func (db *MemoryStateDB) DeleteState(addr common.Address, key common.Hash) { ...@@ -235,12 +235,16 @@ func (db *MemoryStateDB) DeleteState(addr common.Address, key common.Hash) {
db.genesis.Alloc[addr] = account db.genesis.Alloc[addr] = account
} }
func (db *MemoryStateDB) Suicide(common.Address) bool { func (db *MemoryStateDB) SelfDestruct(common.Address) {
panic("Suicide unimplemented") panic("SelfDestruct unimplemented")
} }
func (db *MemoryStateDB) HasSuicided(common.Address) bool { func (db *MemoryStateDB) HasSelfDestructed(common.Address) bool {
panic("HasSuicided unimplemented") panic("HasSelfDestructed unimplemented")
}
func (db *MemoryStateDB) Selfdestruct6780(common.Address) {
panic("Selfdestruct6780 unimplemented")
} }
// Exist reports whether the given account exists in state. // Exist reports whether the given account exists in state.
......
...@@ -4,7 +4,7 @@ import ( ...@@ -4,7 +4,7 @@ import (
"math/big" "math/big"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/consensus/misc" "github.com/ethereum/go-ethereum/consensus/misc/eip1559"
"github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/types"
...@@ -67,7 +67,7 @@ func (s *L1Miner) ActL1StartBlock(timeDelta uint64) Action { ...@@ -67,7 +67,7 @@ func (s *L1Miner) ActL1StartBlock(timeDelta uint64) Action {
MixDigest: common.Hash{}, // TODO: maybe randomize this (prev-randao value) MixDigest: common.Hash{}, // TODO: maybe randomize this (prev-randao value)
} }
if s.l1Cfg.Config.IsLondon(header.Number) { if s.l1Cfg.Config.IsLondon(header.Number) {
header.BaseFee = misc.CalcBaseFee(s.l1Cfg.Config, parent) header.BaseFee = eip1559.CalcBaseFee(s.l1Cfg.Config, parent)
// At the transition, double the gas limit so the gas target is equal to the old gas limit. // At the transition, double the gas limit so the gas target is equal to the old gas limit.
if !s.l1Cfg.Config.IsLondon(parent.Number) { if !s.l1Cfg.Config.IsLondon(parent.Number) {
header.GasLimit = parent.GasLimit * s.l1Cfg.Config.ElasticityMultiplier() header.GasLimit = parent.GasLimit * s.l1Cfg.Config.ElasticityMultiplier()
...@@ -151,7 +151,7 @@ func (s *L1Miner) ActL1EndBlock(t Testing) { ...@@ -151,7 +151,7 @@ func (s *L1Miner) ActL1EndBlock(t Testing) {
} }
// Write state changes to db // Write state changes to db
root, err := s.l1BuildingState.Commit(s.l1Cfg.Config.IsEIP158(s.l1BuildingHeader.Number)) root, err := s.l1BuildingState.Commit(s.l1BuildingHeader.Number.Uint64(), s.l1Cfg.Config.IsEIP158(s.l1BuildingHeader.Number))
if err != nil { if err != nil {
t.Fatalf("l1 state write error: %v", err) t.Fatalf("l1 state write error: %v", err)
} }
......
...@@ -161,12 +161,12 @@ func (s *L1Replica) MockL1RPCErrors(fn func() error) { ...@@ -161,12 +161,12 @@ func (s *L1Replica) MockL1RPCErrors(fn func() error) {
} }
func (s *L1Replica) EthClient() *ethclient.Client { func (s *L1Replica) EthClient() *ethclient.Client {
cl, _ := s.node.Attach() // never errors cl := s.node.Attach()
return ethclient.NewClient(cl) return ethclient.NewClient(cl)
} }
func (s *L1Replica) RPCClient() client.RPC { func (s *L1Replica) RPCClient() client.RPC {
cl, _ := s.node.Attach() // never errors cl := s.node.Attach()
return testutils.RPCErrFaker{ return testutils.RPCErrFaker{
RPC: client.NewBaseRPCClient(cl), RPC: client.NewBaseRPCClient(cl),
ErrFn: func() error { ErrFn: func() error {
......
...@@ -132,17 +132,17 @@ func (e *engineApiBackend) Genesis() *core.Genesis { ...@@ -132,17 +132,17 @@ func (e *engineApiBackend) Genesis() *core.Genesis {
} }
func (s *L2Engine) EthClient() *ethclient.Client { func (s *L2Engine) EthClient() *ethclient.Client {
cl, _ := s.node.Attach() // never errors cl := s.node.Attach()
return ethclient.NewClient(cl) return ethclient.NewClient(cl)
} }
func (s *L2Engine) GethClient() *gethclient.Client { func (s *L2Engine) GethClient() *gethclient.Client {
cl, _ := s.node.Attach() // never errors cl := s.node.Attach()
return gethclient.New(cl) return gethclient.New(cl)
} }
func (e *L2Engine) RPCClient() client.RPC { func (e *L2Engine) RPCClient() client.RPC {
cl, _ := e.node.Attach() // never errors cl := e.node.Attach()
return testutils.RPCErrFaker{ return testutils.RPCErrFaker{
RPC: client.NewBaseRPCClient(cl), RPC: client.NewBaseRPCClient(cl),
ErrFn: func() error { ErrFn: func() error {
......
...@@ -7,6 +7,7 @@ import ( ...@@ -7,6 +7,7 @@ import (
"testing" "testing"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/txpool"
"github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/eth/ethconfig" "github.com/ethereum/go-ethereum/eth/ethconfig"
"github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/log"
...@@ -94,7 +95,7 @@ func TestReorgOrphanBlock(gt *testing.T) { ...@@ -94,7 +95,7 @@ func TestReorgOrphanBlock(gt *testing.T) {
miner.ActL1SetFeeRecipient(common.Address{'C'}) miner.ActL1SetFeeRecipient(common.Address{'C'})
// note: the geth tx pool reorgLoop is too slow (responds to chain head events, but async), // note: the geth tx pool reorgLoop is too slow (responds to chain head events, but async),
// and there's no way to manually trigger runReorg, so we re-insert it ourselves. // and there's no way to manually trigger runReorg, so we re-insert it ourselves.
require.NoError(t, miner.eth.TxPool().AddLocal(batchTx)) require.NoError(t, miner.eth.TxPool().Add([]*txpool.Transaction{{Tx: batchTx}}, true, true)[0])
// need to re-insert previously included tx into the block // need to re-insert previously included tx into the block
miner.ActL1IncludeTx(sd.RollupCfg.Genesis.SystemConfig.BatcherAddr)(t) miner.ActL1IncludeTx(sd.RollupCfg.Genesis.SystemConfig.BatcherAddr)(t)
miner.ActL1EndBlock(t) miner.ActL1EndBlock(t)
...@@ -173,7 +174,7 @@ func TestReorgFlipFlop(gt *testing.T) { ...@@ -173,7 +174,7 @@ func TestReorgFlipFlop(gt *testing.T) {
// re-include the batch tx that submitted L2 chain data that pointed to A0, in the new block B1 // re-include the batch tx that submitted L2 chain data that pointed to A0, in the new block B1
miner.ActL1SetFeeRecipient(common.Address{'B', 1}) miner.ActL1SetFeeRecipient(common.Address{'B', 1})
miner.ActL1StartBlock(12)(t) miner.ActL1StartBlock(12)(t)
require.NoError(t, miner.eth.TxPool().AddLocal(batchTxA)) require.NoError(t, miner.eth.TxPool().Add([]*txpool.Transaction{{Tx: batchTxA}}, true, true)[0])
miner.ActL1IncludeTx(sd.RollupCfg.Genesis.SystemConfig.BatcherAddr)(t) miner.ActL1IncludeTx(sd.RollupCfg.Genesis.SystemConfig.BatcherAddr)(t)
miner.ActL1EndBlock(t) miner.ActL1EndBlock(t)
...@@ -229,7 +230,7 @@ func TestReorgFlipFlop(gt *testing.T) { ...@@ -229,7 +230,7 @@ func TestReorgFlipFlop(gt *testing.T) {
miner.ActL1SetFeeRecipient(common.Address{'A', 2}) miner.ActL1SetFeeRecipient(common.Address{'A', 2})
miner.ActL1StartBlock(12)(t) miner.ActL1StartBlock(12)(t)
require.NoError(t, miner.eth.TxPool().AddLocal(batchTxA)) // replay chain A batches, but now in A2 instead of A1 require.NoError(t, miner.eth.TxPool().Add([]*txpool.Transaction{{Tx: batchTxA}}, true, true)[0]) // replay chain A batches, but now in A2 instead of A1
miner.ActL1IncludeTx(sd.RollupCfg.Genesis.SystemConfig.BatcherAddr)(t) miner.ActL1IncludeTx(sd.RollupCfg.Genesis.SystemConfig.BatcherAddr)(t)
miner.ActL1EndBlock(t) miner.ActL1EndBlock(t)
......
...@@ -157,8 +157,7 @@ func TestGethOnlyPendingBlockIsLatest(t *testing.T) { ...@@ -157,8 +157,7 @@ func TestGethOnlyPendingBlockIsLatest(t *testing.T) {
require.NoError(t, opGeth.L2Client.SendTransaction(ctx, tx), "send tx to make pending work different") require.NoError(t, opGeth.L2Client.SendTransaction(ctx, tx), "send tx to make pending work different")
checkPending("prepared", 0) checkPending("prepared", 0)
rpcClient, err := opGeth.node.Attach() rpcClient := opGeth.node.Attach()
require.NoError(t, err)
defer rpcClient.Close() defer rpcClient.Close()
// Wait for tx to be in tx-pool, for it to be picked up in block building // Wait for tx to be in tx-pool, for it to be picked up in block building
......
...@@ -720,8 +720,7 @@ func TestSystemP2PAltSync(t *testing.T) { ...@@ -720,8 +720,7 @@ func TestSystemP2PAltSync(t *testing.T) {
_, err = sys.Mocknet.ConnectPeers(sys.RollupNodes["bob"].P2P().Host().ID(), syncerNode.P2P().Host().ID()) _, err = sys.Mocknet.ConnectPeers(sys.RollupNodes["bob"].P2P().Host().ID(), syncerNode.P2P().Host().ID())
require.NoError(t, err) require.NoError(t, err)
rpc, err := syncerL2Engine.Attach() rpc := syncerL2Engine.Attach()
require.NoError(t, err)
l2Verif := ethclient.NewClient(rpc) l2Verif := ethclient.NewClient(rpc)
// It may take a while to sync, but eventually we should see the sequenced data show up // It may take a while to sync, but eventually we should see the sequenced data show up
......
...@@ -222,7 +222,7 @@ func FuzzUnmarshallLogEvent(f *testing.F) { ...@@ -222,7 +222,7 @@ func FuzzUnmarshallLogEvent(f *testing.F) {
} }
state.SetBalance(from, BytesToBigInt([]byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff})) state.SetBalance(from, BytesToBigInt([]byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}))
state.SetCode(addr, common.FromHex(bindings.OptimismPortalDeployedBin)) state.SetCode(addr, common.FromHex(bindings.OptimismPortalDeployedBin))
_, err = state.Commit(false) _, err = state.Commit(0, false)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
......
...@@ -136,7 +136,7 @@ func TestUpdateState(t *testing.T) { ...@@ -136,7 +136,7 @@ func TestUpdateState(t *testing.T) {
require.Equal(t, []byte{1}, statedb.GetCode(codeAccount)) require.Equal(t, []byte{1}, statedb.GetCode(codeAccount))
// Changes should be available under the new state root after committing // Changes should be available under the new state root after committing
newRoot, err := statedb.Commit(false) newRoot, err := statedb.Commit(genesisBlock.NumberU64()+1, false)
require.NoError(t, err) require.NoError(t, err)
err = statedb.Database().TrieDB().Commit(newRoot, true) err = statedb.Database().TrieDB().Commit(newRoot, true)
require.NoError(t, err) require.NoError(t, err)
......
...@@ -8,7 +8,7 @@ import ( ...@@ -8,7 +8,7 @@ import (
"github.com/ethereum-optimism/optimism/op-service/eth" "github.com/ethereum-optimism/optimism/op-service/eth"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/consensus" "github.com/ethereum/go-ethereum/consensus"
"github.com/ethereum/go-ethereum/consensus/misc" "github.com/ethereum/go-ethereum/consensus/misc/eip1559"
"github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/types"
...@@ -68,7 +68,7 @@ func NewBlockProcessorFromHeader(provider BlockDataProvider, h *types.Header) (* ...@@ -68,7 +68,7 @@ func NewBlockProcessorFromHeader(provider BlockDataProvider, h *types.Header) (*
return nil, fmt.Errorf("get parent state: %w", err) return nil, fmt.Errorf("get parent state: %w", err)
} }
header.Number = new(big.Int).Add(parentHeader.Number, common.Big1) header.Number = new(big.Int).Add(parentHeader.Number, common.Big1)
header.BaseFee = misc.CalcBaseFee(provider.Config(), parentHeader) header.BaseFee = eip1559.CalcBaseFee(provider.Config(), parentHeader)
header.GasUsed = 0 header.GasUsed = 0
gasPool := new(core.GasPool).AddGas(header.GasLimit) gasPool := new(core.GasPool).AddGas(header.GasLimit)
return &BlockProcessor{ return &BlockProcessor{
...@@ -107,7 +107,7 @@ func (b *BlockProcessor) Assemble() (*types.Block, error) { ...@@ -107,7 +107,7 @@ func (b *BlockProcessor) Assemble() (*types.Block, error) {
} }
func (b *BlockProcessor) Commit() error { func (b *BlockProcessor) Commit() error {
root, err := b.state.Commit(b.dataProvider.Config().IsEIP158(b.header.Number)) root, err := b.state.Commit(b.header.Number.Uint64(), b.dataProvider.Config().IsEIP158(b.header.Number))
if err != nil { if err != nil {
return fmt.Errorf("state write error: %w", err) return fmt.Errorf("state write error: %w", err)
} }
......
...@@ -294,7 +294,7 @@ func (ea *L2EngineAPI) NewPayloadV1(ctx context.Context, payload *eth.ExecutionP ...@@ -294,7 +294,7 @@ func (ea *L2EngineAPI) NewPayloadV1(ctx context.Context, payload *eth.ExecutionP
BaseFeePerGas: payload.BaseFeePerGas.ToBig(), BaseFeePerGas: payload.BaseFeePerGas.ToBig(),
BlockHash: payload.BlockHash, BlockHash: payload.BlockHash,
Transactions: txs, Transactions: txs,
}) }, nil)
if err != nil { if err != nil {
log.Debug("Invalid NewPayload params", "params", payload, "error", err) log.Debug("Invalid NewPayload params", "params", payload, "error", err)
return &eth.PayloadStatusV1{Status: eth.ExecutionInvalidBlockHash}, nil return &eth.PayloadStatusV1{Status: eth.ExecutionInvalidBlockHash}, nil
......
...@@ -94,11 +94,11 @@ func (p *DB) ModifyAncients(f func(ethdb.AncientWriteOp) error) (int64, error) { ...@@ -94,11 +94,11 @@ func (p *DB) ModifyAncients(f func(ethdb.AncientWriteOp) error) (int64, error) {
panic("not supported") panic("not supported")
} }
func (p *DB) TruncateHead(n uint64) error { func (p *DB) TruncateHead(n uint64) (uint64, error) {
panic("not supported") panic("not supported")
} }
func (p *DB) TruncateTail(n uint64) error { func (p *DB) TruncateTail(n uint64) (uint64, error) {
panic("not supported") panic("not supported")
} }
...@@ -114,4 +114,4 @@ func (p *DB) AncientDatadir() (string, error) { ...@@ -114,4 +114,4 @@ func (p *DB) AncientDatadir() (string, error) {
panic("not supported") panic("not supported")
} }
var _ ethdb.KeyValueStore = (*DB)(nil) var _ ethdb.Database = (*DB)(nil)
...@@ -51,7 +51,10 @@ func ReadTrie(root common.Hash, getPreimage func(key common.Hash) []byte) []hexu ...@@ -51,7 +51,10 @@ func ReadTrie(root common.Hash, getPreimage func(key common.Hash) []byte) []hexu
if err != nil { if err != nil {
panic(err) panic(err)
} }
iter := tr.NodeIterator(nil) iter, err := tr.NodeIterator(nil)
if err != nil {
panic(err)
}
// With small lists the iterator seems to use 0x80 (RLP empty string, unlike the others) // With small lists the iterator seems to use 0x80 (RLP empty string, unlike the others)
// as key for item 0, causing it to come last. // as key for item 0, causing it to come last.
......
...@@ -78,7 +78,7 @@ func (ch *Cheater) Close() error { ...@@ -78,7 +78,7 @@ func (ch *Cheater) Close() error {
return ch.DB.Close() return ch.DB.Close()
} }
type HeadFn func(headState *state.StateDB) error type HeadFn func(header *types.Header, headState *state.StateDB) error
// RunAndClose runs the given function on the head-state, and then persists any changes (if not ReadOnly), // RunAndClose runs the given function on the head-state, and then persists any changes (if not ReadOnly),
// and updates the blockchain headers indexes to reflect the new state-root, so geth will believe the cheat // and updates the blockchain headers indexes to reflect the new state-root, so geth will believe the cheat
...@@ -93,7 +93,7 @@ func (ch *Cheater) RunAndClose(fn HeadFn) error { ...@@ -93,7 +93,7 @@ func (ch *Cheater) RunAndClose(fn HeadFn) error {
_ = ch.Close() _ = ch.Close()
return fmt.Errorf("failed to look up head state: %w", err) return fmt.Errorf("failed to look up head state: %w", err)
} }
if err := fn(state); err != nil { if err := fn(preHeader, state); err != nil {
_ = ch.Close() _ = ch.Close()
return fmt.Errorf("failed to run state change: %w", err) return fmt.Errorf("failed to run state change: %w", err)
} }
...@@ -102,7 +102,7 @@ func (ch *Cheater) RunAndClose(fn HeadFn) error { ...@@ -102,7 +102,7 @@ func (ch *Cheater) RunAndClose(fn HeadFn) error {
} }
// commit the changes, and then update the state-root // commit the changes, and then update the state-root
stateRoot, err := state.Commit(true) stateRoot, err := state.Commit(preHeader.Number.Uint64()+1, true)
if err != nil { if err != nil {
_ = ch.Close() _ = ch.Close()
return fmt.Errorf("failed to commit state change: %w", err) return fmt.Errorf("failed to commit state change: %w", err)
...@@ -171,7 +171,7 @@ func (ch *Cheater) RunAndClose(fn HeadFn) error { ...@@ -171,7 +171,7 @@ func (ch *Cheater) RunAndClose(fn HeadFn) error {
// StorageSet modifies the storage of the given address at the given key to the given value. // StorageSet modifies the storage of the given address at the given key to the given value.
func StorageSet(address common.Address, key common.Hash, value common.Hash) HeadFn { func StorageSet(address common.Address, key common.Hash, value common.Hash) HeadFn {
return func(headState *state.StateDB) error { return func(_ *types.Header, headState *state.StateDB) error {
headState.SetState(address, key, value) headState.SetState(address, key, value)
return nil return nil
} }
...@@ -179,7 +179,7 @@ func StorageSet(address common.Address, key common.Hash, value common.Hash) Head ...@@ -179,7 +179,7 @@ func StorageSet(address common.Address, key common.Hash, value common.Hash) Head
// StorageGet just reads the storage of the given address at the given key. // StorageGet just reads the storage of the given address at the given key.
func StorageGet(address common.Address, key common.Hash, w io.Writer) HeadFn { func StorageGet(address common.Address, key common.Hash, w io.Writer) HeadFn {
return func(headState *state.StateDB) error { return func(_ *types.Header, headState *state.StateDB) error {
value := headState.GetState(address, key) value := headState.GetState(address, key)
_, err := io.WriteString(w, value.Hex()) _, err := io.WriteString(w, value.Hex())
return err return err
...@@ -191,7 +191,7 @@ func StorageGet(address common.Address, key common.Hash, w io.Writer) HeadFn { ...@@ -191,7 +191,7 @@ func StorageGet(address common.Address, key common.Hash, w io.Writer) HeadFn {
// Combined with StoragePatch this allows for quick surgery of 1 account in one database, // Combined with StoragePatch this allows for quick surgery of 1 account in one database,
// to another account (maybe even in a different database!). // to another account (maybe even in a different database!).
func StorageReadAll(address common.Address, w io.Writer) HeadFn { func StorageReadAll(address common.Address, w io.Writer) HeadFn {
return func(headState *state.StateDB) error { return func(_ *types.Header, headState *state.StateDB) error {
storage, err := headState.StorageTrie(address) storage, err := headState.StorageTrie(address)
if err != nil { if err != nil {
return fmt.Errorf("failed to open storage trie of addr %s: %w", address, err) return fmt.Errorf("failed to open storage trie of addr %s: %w", address, err)
...@@ -199,7 +199,11 @@ func StorageReadAll(address common.Address, w io.Writer) HeadFn { ...@@ -199,7 +199,11 @@ func StorageReadAll(address common.Address, w io.Writer) HeadFn {
if storage == nil { if storage == nil {
return fmt.Errorf("no storage trie in state for account %s", address) return fmt.Errorf("no storage trie in state for account %s", address)
} }
iter := trie.NewIterator(storage.NodeIterator(nil)) nodeIter, err := storage.NodeIterator(nil)
if err != nil {
return fmt.Errorf("failed to create node iterator for storage of %s: %w", address, err)
}
iter := trie.NewIterator(nodeIter)
for iter.Next() { for iter.Next() {
if _, err := fmt.Fprintf(w, "+ %x = %x\n", iter.Key, dbValueToHash(iter.Value)); err != nil { if _, err := fmt.Fprintf(w, "+ %x = %x\n", iter.Key, dbValueToHash(iter.Value)); err != nil {
return err return err
...@@ -224,7 +228,7 @@ func dbValueToHash(enc []byte) common.Hash { ...@@ -224,7 +228,7 @@ func dbValueToHash(enc []byte) common.Hash {
// StorageDiff compares the storage of two different accounts, and writes a patch with differences. // StorageDiff compares the storage of two different accounts, and writes a patch with differences.
// Each difference is expressed with 1 character + or - to indicate the change from a to b, followed by key = value. // Each difference is expressed with 1 character + or - to indicate the change from a to b, followed by key = value.
func StorageDiff(out io.Writer, addressA, addressB common.Address) HeadFn { func StorageDiff(out io.Writer, addressA, addressB common.Address) HeadFn {
return func(headState *state.StateDB) error { return func(_ *types.Header, headState *state.StateDB) error {
aStorage, err := headState.StorageTrie(addressA) aStorage, err := headState.StorageTrie(addressA)
if err != nil { if err != nil {
return fmt.Errorf("failed to open storage trie of addr A %s: %w", addressA, err) return fmt.Errorf("failed to open storage trie of addr A %s: %w", addressA, err)
...@@ -239,8 +243,16 @@ func StorageDiff(out io.Writer, addressA, addressB common.Address) HeadFn { ...@@ -239,8 +243,16 @@ func StorageDiff(out io.Writer, addressA, addressB common.Address) HeadFn {
if bStorage == nil { if bStorage == nil {
return fmt.Errorf("no storage trie in state for account B %s", addressB) return fmt.Errorf("no storage trie in state for account B %s", addressB)
} }
aIter := trie.NewIterator(aStorage.NodeIterator(nil)) aNodeIter, err := aStorage.NodeIterator(nil)
bIter := trie.NewIterator(bStorage.NodeIterator(nil)) if err != nil {
return fmt.Errorf("failed to create node iterator for storage of %s (A): %w", addressA, err)
}
bNodeIter, err := bStorage.NodeIterator(nil)
if err != nil {
return fmt.Errorf("failed to create node iterator for storage of %s (b): %w", addressB, err)
}
aIter := trie.NewIterator(aNodeIter)
bIter := trie.NewIterator(bNodeIter)
hasA := aIter.Next() hasA := aIter.Next()
hasB := bIter.Next() hasB := bIter.Next()
for { for {
...@@ -284,7 +296,7 @@ func StorageDiff(out io.Writer, addressA, addressB common.Address) HeadFn { ...@@ -284,7 +296,7 @@ func StorageDiff(out io.Writer, addressA, addressB common.Address) HeadFn {
// Deletions are prefixed with (-) and overwrite it to a zero value. // Deletions are prefixed with (-) and overwrite it to a zero value.
// Comments (#) and empty lines are ignored. // Comments (#) and empty lines are ignored.
func StoragePatch(patch io.Reader, address common.Address) HeadFn { func StoragePatch(patch io.Reader, address common.Address) HeadFn {
return func(headState *state.StateDB) error { return func(head *types.Header, headState *state.StateDB) error {
s := bufio.NewScanner(patch) s := bufio.NewScanner(patch)
i := 0 i := 0
for s.Scan() { for s.Scan() {
...@@ -312,7 +324,7 @@ func StoragePatch(patch io.Reader, address common.Address) HeadFn { ...@@ -312,7 +324,7 @@ func StoragePatch(patch io.Reader, address common.Address) HeadFn {
} }
i += 1 i += 1
if i%1000 == 0 { // for every 1000 values, commit to disk if i%1000 == 0 { // for every 1000 values, commit to disk
if _, err := headState.Commit(true); err != nil { if _, err := headState.Commit(head.Number.Uint64(), true); err != nil {
return fmt.Errorf("failed to commit state to disk after patching %d entries: %w", i, err) return fmt.Errorf("failed to commit state to disk after patching %d entries: %w", i, err)
} }
} }
...@@ -329,7 +341,7 @@ type OvmOwnersConfig struct { ...@@ -329,7 +341,7 @@ type OvmOwnersConfig struct {
} }
func OvmOwners(conf *OvmOwnersConfig) HeadFn { func OvmOwners(conf *OvmOwnersConfig) HeadFn {
return func(headState *state.StateDB) error { return func(_ *types.Header, headState *state.StateDB) error {
var addressManager common.Address // Lib_AddressManager var addressManager common.Address // Lib_AddressManager
var l1SBProxy common.Address // Proxy__OVM_L1StandardBridge var l1SBProxy common.Address // Proxy__OVM_L1StandardBridge
var l1XDMProxy common.Address // Proxy__OVM_L1CrossDomainMessenger var l1XDMProxy common.Address // Proxy__OVM_L1CrossDomainMessenger
...@@ -374,21 +386,21 @@ func OvmOwners(conf *OvmOwnersConfig) HeadFn { ...@@ -374,21 +386,21 @@ func OvmOwners(conf *OvmOwnersConfig) HeadFn {
} }
func SetBalance(addr common.Address, amount *big.Int) HeadFn { func SetBalance(addr common.Address, amount *big.Int) HeadFn {
return func(headState *state.StateDB) error { return func(_ *types.Header, headState *state.StateDB) error {
headState.SetBalance(addr, amount) headState.SetBalance(addr, amount)
return nil return nil
} }
} }
func SetCode(addr common.Address, code hexutil.Bytes) HeadFn { func SetCode(addr common.Address, code hexutil.Bytes) HeadFn {
return func(headState *state.StateDB) error { return func(_ *types.Header, headState *state.StateDB) error {
headState.SetCode(addr, code) headState.SetCode(addr, code)
return nil return nil
} }
} }
func SetNonce(addr common.Address, nonce uint64) HeadFn { func SetNonce(addr common.Address, nonce uint64) HeadFn {
return func(headState *state.StateDB) error { return func(_ *types.Header, headState *state.StateDB) error {
headState.SetNonce(addr, nonce) headState.SetNonce(addr, nonce)
return nil return nil
} }
......
...@@ -296,7 +296,7 @@ func Copy(ctx context.Context, copyFrom client.RPC, copyTo client.RPC) error { ...@@ -296,7 +296,7 @@ func Copy(ctx context.Context, copyFrom client.RPC, copyTo client.RPC) error {
if err != nil { if err != nil {
return err return err
} }
payloadEnv := engine.BlockToExecutableData(copyHead, nil) payloadEnv := engine.BlockToExecutableData(copyHead, nil, nil, nil, nil)
if err := updateForkchoice(ctx, copyTo, copyHead.ParentHash(), copySafe.Hash(), copyFinalized.Hash()); err != nil { if err := updateForkchoice(ctx, copyTo, copyHead.ParentHash(), copySafe.Hash(), copyFinalized.Hash()); err != nil {
return err return err
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment