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 (
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-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/go-chi/chi/v5 v5.0.10
github.com/go-chi/docgen v1.2.0
......@@ -68,8 +68,8 @@ require (
github.com/containerd/cgroups v1.1.0 // indirect
github.com/coreos/go-systemd/v22 v22.5.0 // 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-kzg-4844 v0.2.0 // indirect
github.com/crate-crypto/go-ipa v0.0.0-20230601170251-1830d0757c80 // indirect
github.com/crate-crypto/go-kzg-4844 v0.3.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c // indirect
github.com/deckarep/golang-set/v2 v2.1.0 // indirect
......@@ -78,16 +78,16 @@ require (
github.com/dlclark/regexp2 v1.7.0 // indirect
github.com/docker/docker v20.10.24+incompatible // 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/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/felixge/fgprof v0.9.3 // indirect
github.com/fjl/memsize v0.0.1 // indirect
github.com/flynn/noise v1.0.0 // indirect
github.com/francoispqt/gojay v1.2.13 // 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/go-ole/go-ole v1.2.6 // indirect
github.com/go-sourcemap/sourcemap v2.1.3+incompatible // indirect
......@@ -106,6 +106,7 @@ require (
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-bexpr v0.1.11 // 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/huin/goupnp v1.2.0 // indirect
github.com/influxdata/influxdb-client-go/v2 v2.4.0 // indirect
......@@ -122,7 +123,7 @@ require (
github.com/jedisct1/go-minisign v0.0.0-20190909160543-45766022959e // indirect
github.com/jinzhu/inflection v1.0.0 // 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/cpuid/v2 v2.2.5 // indirect
github.com/koron/go-ssdp v0.0.4 // indirect
......@@ -189,6 +190,7 @@ require (
github.com/tyler-smith/go-bip39 v1.1.0 // indirect
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // 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/fx v1.20.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
......@@ -207,6 +209,6 @@ require (
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 {
func NewMemoryStateDB(genesis *core.Genesis) *MemoryStateDB {
if genesis == nil {
genesis = core.DeveloperGenesisBlock(15, 15_000_000, common.Address{})
genesis = core.DeveloperGenesisBlock(15_000_000, common.Address{})
}
return &MemoryStateDB{
......@@ -235,12 +235,16 @@ func (db *MemoryStateDB) DeleteState(addr common.Address, key common.Hash) {
db.genesis.Alloc[addr] = account
}
func (db *MemoryStateDB) Suicide(common.Address) bool {
panic("Suicide unimplemented")
func (db *MemoryStateDB) SelfDestruct(common.Address) {
panic("SelfDestruct unimplemented")
}
func (db *MemoryStateDB) HasSuicided(common.Address) bool {
panic("HasSuicided unimplemented")
func (db *MemoryStateDB) HasSelfDestructed(common.Address) bool {
panic("HasSelfDestructed unimplemented")
}
func (db *MemoryStateDB) Selfdestruct6780(common.Address) {
panic("Selfdestruct6780 unimplemented")
}
// Exist reports whether the given account exists in state.
......
......@@ -4,7 +4,7 @@ import (
"math/big"
"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/state"
"github.com/ethereum/go-ethereum/core/types"
......@@ -67,7 +67,7 @@ func (s *L1Miner) ActL1StartBlock(timeDelta uint64) Action {
MixDigest: common.Hash{}, // TODO: maybe randomize this (prev-randao value)
}
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.
if !s.l1Cfg.Config.IsLondon(parent.Number) {
header.GasLimit = parent.GasLimit * s.l1Cfg.Config.ElasticityMultiplier()
......@@ -151,7 +151,7 @@ func (s *L1Miner) ActL1EndBlock(t Testing) {
}
// 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 {
t.Fatalf("l1 state write error: %v", err)
}
......
......@@ -161,12 +161,12 @@ func (s *L1Replica) MockL1RPCErrors(fn func() error) {
}
func (s *L1Replica) EthClient() *ethclient.Client {
cl, _ := s.node.Attach() // never errors
cl := s.node.Attach()
return ethclient.NewClient(cl)
}
func (s *L1Replica) RPCClient() client.RPC {
cl, _ := s.node.Attach() // never errors
cl := s.node.Attach()
return testutils.RPCErrFaker{
RPC: client.NewBaseRPCClient(cl),
ErrFn: func() error {
......
......@@ -132,17 +132,17 @@ func (e *engineApiBackend) Genesis() *core.Genesis {
}
func (s *L2Engine) EthClient() *ethclient.Client {
cl, _ := s.node.Attach() // never errors
cl := s.node.Attach()
return ethclient.NewClient(cl)
}
func (s *L2Engine) GethClient() *gethclient.Client {
cl, _ := s.node.Attach() // never errors
cl := s.node.Attach()
return gethclient.New(cl)
}
func (e *L2Engine) RPCClient() client.RPC {
cl, _ := e.node.Attach() // never errors
cl := e.node.Attach()
return testutils.RPCErrFaker{
RPC: client.NewBaseRPCClient(cl),
ErrFn: func() error {
......
......@@ -7,6 +7,7 @@ import (
"testing"
"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/eth/ethconfig"
"github.com/ethereum/go-ethereum/log"
......@@ -94,7 +95,7 @@ func TestReorgOrphanBlock(gt *testing.T) {
miner.ActL1SetFeeRecipient(common.Address{'C'})
// 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.
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
miner.ActL1IncludeTx(sd.RollupCfg.Genesis.SystemConfig.BatcherAddr)(t)
miner.ActL1EndBlock(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
miner.ActL1SetFeeRecipient(common.Address{'B', 1})
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.ActL1EndBlock(t)
......@@ -229,7 +230,7 @@ func TestReorgFlipFlop(gt *testing.T) {
miner.ActL1SetFeeRecipient(common.Address{'A', 2})
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.ActL1EndBlock(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")
checkPending("prepared", 0)
rpcClient, err := opGeth.node.Attach()
require.NoError(t, err)
rpcClient := opGeth.node.Attach()
defer rpcClient.Close()
// 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) {
_, err = sys.Mocknet.ConnectPeers(sys.RollupNodes["bob"].P2P().Host().ID(), syncerNode.P2P().Host().ID())
require.NoError(t, err)
rpc, err := syncerL2Engine.Attach()
require.NoError(t, err)
rpc := syncerL2Engine.Attach()
l2Verif := ethclient.NewClient(rpc)
// 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) {
}
state.SetBalance(from, BytesToBigInt([]byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}))
state.SetCode(addr, common.FromHex(bindings.OptimismPortalDeployedBin))
_, err = state.Commit(false)
_, err = state.Commit(0, false)
if err != nil {
t.Fatal(err)
}
......
......@@ -136,7 +136,7 @@ func TestUpdateState(t *testing.T) {
require.Equal(t, []byte{1}, statedb.GetCode(codeAccount))
// 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)
err = statedb.Database().TrieDB().Commit(newRoot, true)
require.NoError(t, err)
......
......@@ -8,7 +8,7 @@ import (
"github.com/ethereum-optimism/optimism/op-service/eth"
"github.com/ethereum/go-ethereum/common"
"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/state"
"github.com/ethereum/go-ethereum/core/types"
......@@ -68,7 +68,7 @@ func NewBlockProcessorFromHeader(provider BlockDataProvider, h *types.Header) (*
return nil, fmt.Errorf("get parent state: %w", err)
}
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
gasPool := new(core.GasPool).AddGas(header.GasLimit)
return &BlockProcessor{
......@@ -107,7 +107,7 @@ func (b *BlockProcessor) Assemble() (*types.Block, 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 {
return fmt.Errorf("state write error: %w", err)
}
......
......@@ -294,7 +294,7 @@ func (ea *L2EngineAPI) NewPayloadV1(ctx context.Context, payload *eth.ExecutionP
BaseFeePerGas: payload.BaseFeePerGas.ToBig(),
BlockHash: payload.BlockHash,
Transactions: txs,
})
}, nil)
if err != nil {
log.Debug("Invalid NewPayload params", "params", payload, "error", err)
return &eth.PayloadStatusV1{Status: eth.ExecutionInvalidBlockHash}, nil
......
......@@ -94,11 +94,11 @@ func (p *DB) ModifyAncients(f func(ethdb.AncientWriteOp) error) (int64, error) {
panic("not supported")
}
func (p *DB) TruncateHead(n uint64) error {
func (p *DB) TruncateHead(n uint64) (uint64, error) {
panic("not supported")
}
func (p *DB) TruncateTail(n uint64) error {
func (p *DB) TruncateTail(n uint64) (uint64, error) {
panic("not supported")
}
......@@ -114,4 +114,4 @@ func (p *DB) AncientDatadir() (string, error) {
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
if err != nil {
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)
// as key for item 0, causing it to come last.
......
......@@ -78,7 +78,7 @@ func (ch *Cheater) Close() error {
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),
// 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 {
_ = ch.Close()
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()
return fmt.Errorf("failed to run state change: %w", err)
}
......@@ -102,7 +102,7 @@ func (ch *Cheater) RunAndClose(fn HeadFn) error {
}
// 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 {
_ = ch.Close()
return fmt.Errorf("failed to commit state change: %w", err)
......@@ -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.
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)
return nil
}
......@@ -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.
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)
_, err := io.WriteString(w, value.Hex())
return err
......@@ -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,
// to another account (maybe even in a different database!).
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)
if err != nil {
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 {
if storage == nil {
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() {
if _, err := fmt.Fprintf(w, "+ %x = %x\n", iter.Key, dbValueToHash(iter.Value)); err != nil {
return err
......@@ -224,7 +228,7 @@ func dbValueToHash(enc []byte) common.Hash {
// 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.
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)
if err != nil {
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 {
if bStorage == nil {
return fmt.Errorf("no storage trie in state for account B %s", addressB)
}
aIter := trie.NewIterator(aStorage.NodeIterator(nil))
bIter := trie.NewIterator(bStorage.NodeIterator(nil))
aNodeIter, err := aStorage.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()
hasB := bIter.Next()
for {
......@@ -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.
// Comments (#) and empty lines are ignored.
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)
i := 0
for s.Scan() {
......@@ -312,7 +324,7 @@ func StoragePatch(patch io.Reader, address common.Address) HeadFn {
}
i += 1
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)
}
}
......@@ -329,7 +341,7 @@ type OvmOwnersConfig struct {
}
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 l1SBProxy common.Address // Proxy__OVM_L1StandardBridge
var l1XDMProxy common.Address // Proxy__OVM_L1CrossDomainMessenger
......@@ -374,21 +386,21 @@ func OvmOwners(conf *OvmOwnersConfig) 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)
return nil
}
}
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)
return nil
}
}
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)
return nil
}
......
......@@ -296,7 +296,7 @@ func Copy(ctx context.Context, copyFrom client.RPC, copyTo client.RPC) error {
if err != nil {
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 {
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