Commit c83cd947 authored by OptimismBot's avatar OptimismBot Committed by GitHub

Merge pull request #7314 from ethereum-optimism/op-geth-v1_13_1

go: update op-geth to include v1.13.1 changes [depends on #7313]
parents 499adbe5 543f8990
...@@ -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.2 github.com/ethereum/go-ethereum v1.13.1
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
...@@ -50,6 +50,7 @@ require ( ...@@ -50,6 +50,7 @@ require (
require ( require (
github.com/DataDog/zstd v1.5.2 // indirect github.com/DataDog/zstd v1.5.2 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/VictoriaMetrics/fastcache v1.10.0 // indirect github.com/VictoriaMetrics/fastcache v1.10.0 // indirect
github.com/allegro/bigcache v1.2.1 // indirect github.com/allegro/bigcache v1.2.1 // indirect
github.com/benbjohnson/clock v1.3.5 // indirect github.com/benbjohnson/clock v1.3.5 // indirect
...@@ -61,7 +62,7 @@ require ( ...@@ -61,7 +62,7 @@ require (
github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/cockroachdb/errors v1.9.1 // indirect github.com/cockroachdb/errors v1.9.1 // indirect
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect
github.com/cockroachdb/pebble v0.0.0-20230209160836-829675f94811 // indirect github.com/cockroachdb/pebble v0.0.0-20230906160148-46873a6a7a06 // indirect
github.com/cockroachdb/redact v1.1.3 // indirect github.com/cockroachdb/redact v1.1.3 // indirect
github.com/consensys/bavard v0.1.13 // indirect github.com/consensys/bavard v0.1.13 // indirect
github.com/consensys/gnark-crypto v0.10.0 // indirect github.com/consensys/gnark-crypto v0.10.0 // indirect
...@@ -76,9 +77,8 @@ require ( ...@@ -76,9 +77,8 @@ require (
github.com/decred/dcrd/crypto/blake256 v1.0.1 // indirect github.com/decred/dcrd/crypto/blake256 v1.0.1 // indirect
github.com/deepmap/oapi-codegen v1.8.2 // indirect github.com/deepmap/oapi-codegen v1.8.2 // indirect
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/go-units v0.5.0 // indirect github.com/docker/go-units v0.5.0 // indirect
github.com/dop251/goja v0.0.0-20230605162241-28ee0ee714f3 // indirect github.com/dop251/goja v0.0.0-20230806174421-c933cf95e127 // indirect
github.com/elastic/gosigar v0.14.2 // indirect github.com/elastic/gosigar v0.14.2 // indirect
github.com/ethereum/c-kzg-4844 v0.3.1 // 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
...@@ -108,7 +108,7 @@ require ( ...@@ -108,7 +108,7 @@ require (
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/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.3.0 // indirect
github.com/influxdata/influxdb-client-go/v2 v2.4.0 // indirect github.com/influxdata/influxdb-client-go/v2 v2.4.0 // indirect
github.com/influxdata/influxdb1-client v0.0.0-20220302092344-a9ab5670611c // indirect github.com/influxdata/influxdb1-client v0.0.0-20220302092344-a9ab5670611c // indirect
github.com/influxdata/line-protocol v0.0.0-20210311194329-9aa0e372d097 // indirect github.com/influxdata/line-protocol v0.0.0-20210311194329-9aa0e372d097 // indirect
...@@ -120,7 +120,7 @@ require ( ...@@ -120,7 +120,7 @@ require (
github.com/jackpal/go-nat-pmp v1.0.2 // indirect github.com/jackpal/go-nat-pmp v1.0.2 // indirect
github.com/jbenet/go-temp-err-catcher v0.1.0 // indirect github.com/jbenet/go-temp-err-catcher v0.1.0 // indirect
github.com/jbenet/goprocess v0.1.4 // indirect github.com/jbenet/goprocess v0.1.4 // indirect
github.com/jedisct1/go-minisign v0.0.0-20190909160543-45766022959e // indirect github.com/jedisct1/go-minisign v0.0.0-20230811132847-661be99b8267 // 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.3-0.20230711191512-61db3e06439c // indirect github.com/karalabe/usb v0.0.3-0.20230711191512-61db3e06439c // indirect
...@@ -185,8 +185,8 @@ require ( ...@@ -185,8 +185,8 @@ require (
github.com/stretchr/objx v0.5.0 // indirect github.com/stretchr/objx v0.5.0 // indirect
github.com/supranational/blst v0.3.11 // indirect github.com/supranational/blst v0.3.11 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20220614013038-64ee5596c38a // indirect github.com/syndtr/goleveldb v1.0.1-0.20220614013038-64ee5596c38a // indirect
github.com/tklauser/go-sysconf v0.3.10 // indirect github.com/tklauser/go-sysconf v0.3.12 // indirect
github.com/tklauser/numcpus v0.5.0 // indirect github.com/tklauser/numcpus v0.6.1 // indirect
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
...@@ -202,13 +202,12 @@ require ( ...@@ -202,13 +202,12 @@ require (
golang.org/x/tools v0.13.0 // indirect golang.org/x/tools v0.13.0 // indirect
google.golang.org/protobuf v1.30.0 // indirect google.golang.org/protobuf v1.30.0 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect
lukechampine.com/blake3 v1.2.1 // indirect lukechampine.com/blake3 v1.2.1 // indirect
rsc.io/tmplfunc v0.0.3 // indirect rsc.io/tmplfunc v0.0.3 // indirect
) )
replace github.com/ethereum/go-ethereum v1.12.2 => github.com/ethereum-optimism/op-geth v1.101200.2-rc.1.0.20230922185314-7997a6fed17c replace github.com/ethereum/go-ethereum v1.13.1 => github.com/ethereum-optimism/op-geth v1.101202.0-rc.1.0.20230925151842-7dfe72eb2d63
//replace github.com/ethereum/go-ethereum v1.12.2 => ../go-ethereum //replace github.com/ethereum/go-ethereum v1.13.1 => ../go-ethereum
This diff is collapsed.
...@@ -10,6 +10,8 @@ import ( ...@@ -10,6 +10,8 @@ import (
"github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/core/rawdb"
"github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/trie"
"github.com/ethereum/go-ethereum/trie/triedb/hashdb"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils" "github.com/ethereum-optimism/optimism/op-e2e/e2eutils"
...@@ -58,7 +60,8 @@ func TestL1Replica_ActL1Sync(gt *testing.T) { ...@@ -58,7 +60,8 @@ func TestL1Replica_ActL1Sync(gt *testing.T) {
genesisBlock := sd.L1Cfg.ToBlock() genesisBlock := sd.L1Cfg.ToBlock()
consensus := beacon.New(ethash.NewFaker()) consensus := beacon.New(ethash.NewFaker())
db := rawdb.NewMemoryDatabase() db := rawdb.NewMemoryDatabase()
sd.L1Cfg.MustCommit(db) tdb := trie.NewDatabase(db, &trie.Config{HashDB: hashdb.Defaults})
sd.L1Cfg.MustCommit(db, tdb)
chainA, _ := core.GenerateChain(sd.L1Cfg.Config, genesisBlock, consensus, db, 10, func(n int, g *core.BlockGen) { chainA, _ := core.GenerateChain(sd.L1Cfg.Config, genesisBlock, consensus, db, 10, func(n int, g *core.BlockGen) {
g.SetCoinbase(common.Address{'A'}) g.SetCoinbase(common.Address{'A'})
......
...@@ -13,6 +13,8 @@ import ( ...@@ -13,6 +13,8 @@ import (
"github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/core/rawdb"
"github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/trie"
"github.com/ethereum/go-ethereum/trie/triedb/hashdb"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/log"
...@@ -32,7 +34,8 @@ func TestL2EngineAPI(gt *testing.T) { ...@@ -32,7 +34,8 @@ func TestL2EngineAPI(gt *testing.T) {
genesisBlock := sd.L2Cfg.ToBlock() genesisBlock := sd.L2Cfg.ToBlock()
consensus := beacon.New(ethash.NewFaker()) consensus := beacon.New(ethash.NewFaker())
db := rawdb.NewMemoryDatabase() db := rawdb.NewMemoryDatabase()
sd.L2Cfg.MustCommit(db) tdb := trie.NewDatabase(db, &trie.Config{HashDB: hashdb.Defaults})
sd.L2Cfg.MustCommit(db, tdb)
engine := NewL2Engine(t, log, sd.L2Cfg, sd.RollupCfg.Genesis.L1, jwtPath) engine := NewL2Engine(t, log, sd.L2Cfg, sd.RollupCfg.Genesis.L1, jwtPath)
...@@ -94,7 +97,8 @@ func TestL2EngineAPIBlockBuilding(gt *testing.T) { ...@@ -94,7 +97,8 @@ func TestL2EngineAPIBlockBuilding(gt *testing.T) {
log := testlog.Logger(t, log.LvlDebug) log := testlog.Logger(t, log.LvlDebug)
genesisBlock := sd.L2Cfg.ToBlock() genesisBlock := sd.L2Cfg.ToBlock()
db := rawdb.NewMemoryDatabase() db := rawdb.NewMemoryDatabase()
sd.L2Cfg.MustCommit(db) tdb := trie.NewDatabase(db, &trie.Config{HashDB: hashdb.Defaults})
sd.L2Cfg.MustCommit(db, tdb)
engine := NewL2Engine(t, log, sd.L2Cfg, sd.RollupCfg.Genesis.L1, jwtPath) engine := NewL2Engine(t, log, sd.L2Cfg, sd.RollupCfg.Genesis.L1, jwtPath)
t.Cleanup(func() { t.Cleanup(func() {
......
...@@ -7,7 +7,6 @@ import ( ...@@ -7,7 +7,6 @@ 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"
...@@ -95,7 +94,7 @@ func TestReorgOrphanBlock(gt *testing.T) { ...@@ -95,7 +94,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().Add([]*txpool.Transaction{{Tx: batchTx}}, true, true)[0]) require.NoError(t, miner.eth.TxPool().Add([]*types.Transaction{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)
...@@ -174,7 +173,7 @@ func TestReorgFlipFlop(gt *testing.T) { ...@@ -174,7 +173,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().Add([]*txpool.Transaction{{Tx: batchTxA}}, true, true)[0]) require.NoError(t, miner.eth.TxPool().Add([]*types.Transaction{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)
...@@ -230,7 +229,7 @@ func TestReorgFlipFlop(gt *testing.T) { ...@@ -230,7 +229,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().Add([]*txpool.Transaction{{Tx: batchTxA}}, true, true)[0]) // replay chain A batches, but now in A2 instead of A1 require.NoError(t, miner.eth.TxPool().Add([]*types.Transaction{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)
......
...@@ -15,6 +15,8 @@ import ( ...@@ -15,6 +15,8 @@ import (
"github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/ethdb/memorydb" "github.com/ethereum/go-ethereum/ethdb/memorydb"
"github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/trie"
"github.com/ethereum/go-ethereum/trie/triedb/hashdb"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )
...@@ -109,7 +111,8 @@ func TestPut(t *testing.T) { ...@@ -109,7 +111,8 @@ func TestPut(t *testing.T) {
func TestSupportsStateDBOperations(t *testing.T) { func TestSupportsStateDBOperations(t *testing.T) {
l2Genesis := createGenesis() l2Genesis := createGenesis()
realDb := rawdb.NewDatabase(memorydb.New()) realDb := rawdb.NewDatabase(memorydb.New())
genesisBlock := l2Genesis.MustCommit(realDb) trieDB := trie.NewDatabase(realDb, &trie.Config{HashDB: hashdb.Defaults})
genesisBlock := l2Genesis.MustCommit(realDb, trieDB)
loader := test.NewKvStateOracle(t, realDb) loader := test.NewKvStateOracle(t, realDb)
assertStateDataAvailable(t, NewOracleBackedDB(loader), l2Genesis, genesisBlock) assertStateDataAvailable(t, NewOracleBackedDB(loader), l2Genesis, genesisBlock)
...@@ -120,7 +123,8 @@ func TestUpdateState(t *testing.T) { ...@@ -120,7 +123,8 @@ func TestUpdateState(t *testing.T) {
oracle := test.NewStubStateOracle(t) oracle := test.NewStubStateOracle(t)
db := rawdb.NewDatabase(NewOracleBackedDB(oracle)) db := rawdb.NewDatabase(NewOracleBackedDB(oracle))
genesisBlock := l2Genesis.MustCommit(db) trieDB := trie.NewDatabase(db, &trie.Config{HashDB: hashdb.Defaults})
genesisBlock := l2Genesis.MustCommit(db, trieDB)
assertStateDataAvailable(t, db, l2Genesis, genesisBlock) assertStateDataAvailable(t, db, l2Genesis, genesisBlock)
statedb, err := state.New(genesisBlock.Root(), state.NewDatabase(rawdb.NewDatabase(db)), nil) statedb, err := state.New(genesisBlock.Root(), state.NewDatabase(rawdb.NewDatabase(db)), nil)
......
...@@ -40,7 +40,7 @@ func (o *OracleEngine) L2OutputRoot() (eth.Bytes32, error) { ...@@ -40,7 +40,7 @@ func (o *OracleEngine) L2OutputRoot() (eth.Bytes32, error) {
if err != nil { if err != nil {
return eth.Bytes32{}, fmt.Errorf("failed to open L2 state db at block %s: %w", outBlock.Hash(), err) return eth.Bytes32{}, fmt.Errorf("failed to open L2 state db at block %s: %w", outBlock.Hash(), err)
} }
withdrawalsTrie, err := stateDB.StorageTrie(predeploys.L2ToL1MessagePasserAddr) withdrawalsTrie, err := stateDB.Database().OpenStorageTrie(outBlock.Root, predeploys.L2ToL1MessagePasserAddr, stateDB.GetStorageRoot(predeploys.L2ToL1MessagePasserAddr))
if err != nil { if err != nil {
return eth.Bytes32{}, fmt.Errorf("withdrawals trie unavailable at block %v: %w", outBlock.Hash(), err) return eth.Bytes32{}, fmt.Errorf("withdrawals trie unavailable at block %v: %w", outBlock.Hash(), err)
} }
......
...@@ -19,6 +19,8 @@ import ( ...@@ -19,6 +19,8 @@ import (
"github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/trie"
"github.com/ethereum/go-ethereum/trie/triedb/hashdb"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )
...@@ -229,9 +231,10 @@ func setupOracle(t *testing.T, blockCount int, headBlockNumber int) (*params.Cha ...@@ -229,9 +231,10 @@ func setupOracle(t *testing.T, blockCount int, headBlockNumber int) (*params.Cha
chainCfg := l2Genesis.Config chainCfg := l2Genesis.Config
consensus := beacon.New(nil) consensus := beacon.New(nil)
db := rawdb.NewMemoryDatabase() db := rawdb.NewMemoryDatabase()
trieDB := trie.NewDatabase(db, &trie.Config{HashDB: hashdb.Defaults})
// Set minimal amount of stuff to avoid nil references later // Set minimal amount of stuff to avoid nil references later
genesisBlock := l2Genesis.MustCommit(db) genesisBlock := l2Genesis.MustCommit(db, trieDB)
blocks, _ := core.GenerateChain(chainCfg, genesisBlock, consensus, db, blockCount, func(i int, gen *core.BlockGen) {}) blocks, _ := core.GenerateChain(chainCfg, genesisBlock, consensus, db, blockCount, func(i int, gen *core.BlockGen) {})
blocks = append([]*types.Block{genesisBlock}, blocks...) blocks = append([]*types.Block{genesisBlock}, blocks...)
......
...@@ -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) }, nil, 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
......
...@@ -9,6 +9,7 @@ import ( ...@@ -9,6 +9,7 @@ import (
"github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/rlp" "github.com/ethereum/go-ethereum/rlp"
"github.com/ethereum/go-ethereum/trie" "github.com/ethereum/go-ethereum/trie"
"github.com/ethereum/go-ethereum/trie/triedb/hashdb"
) )
// ReadTrie takes a Merkle Patricia Trie (MPT) root of a "DerivableList", and a pre-image oracle getter, // ReadTrie takes a Merkle Patricia Trie (MPT) root of a "DerivableList", and a pre-image oracle getter,
...@@ -46,7 +47,7 @@ func ReadTrie(root common.Hash, getPreimage func(key common.Hash) []byte) []hexu ...@@ -46,7 +47,7 @@ func ReadTrie(root common.Hash, getPreimage func(key common.Hash) []byte) []hexu
// //
// For now we just use the state DB trie approach. // For now we just use the state DB trie approach.
tdb := trie.NewDatabase(odb) tdb := trie.NewDatabase(odb, &trie.Config{HashDB: hashdb.Defaults})
tr, err := trie.New(trie.TrieID(root), tdb) tr, err := trie.New(trie.TrieID(root), tdb)
if err != nil { if err != nil {
panic(err) panic(err)
......
...@@ -78,6 +78,12 @@ func (ch *Cheater) Close() error { ...@@ -78,6 +78,12 @@ func (ch *Cheater) Close() error {
return ch.DB.Close() return ch.DB.Close()
} }
func openStorageTrie(s *state.StateDB, addr common.Address) (state.Trie, error) {
stateRoot := s.IntermediateRoot(true)
storageRoot := s.GetStorageRoot(addr)
return s.Database().OpenStorageTrie(stateRoot, addr, storageRoot)
}
type HeadFn func(header *types.Header, 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),
...@@ -192,7 +198,7 @@ func StorageGet(address common.Address, key common.Hash, w io.Writer) HeadFn { ...@@ -192,7 +198,7 @@ func StorageGet(address common.Address, key common.Hash, w io.Writer) HeadFn {
// 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(_ *types.Header, headState *state.StateDB) error { return func(_ *types.Header, headState *state.StateDB) error {
storage, err := headState.StorageTrie(address) storage, err := openStorageTrie(headState, 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)
} }
...@@ -229,14 +235,14 @@ func dbValueToHash(enc []byte) common.Hash { ...@@ -229,14 +235,14 @@ func dbValueToHash(enc []byte) common.Hash {
// 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(_ *types.Header, headState *state.StateDB) error { return func(_ *types.Header, headState *state.StateDB) error {
aStorage, err := headState.StorageTrie(addressA) aStorage, err := openStorageTrie(headState, 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)
} }
if aStorage == nil { if aStorage == nil {
return fmt.Errorf("no storage trie in state for account A %s", addressA) return fmt.Errorf("no storage trie in state for account A %s", addressA)
} }
bStorage, err := headState.StorageTrie(addressB) bStorage, err := openStorageTrie(headState, addressB)
if err != nil { if err != nil {
return fmt.Errorf("failed to open storage trie of addr B %s: %w", addressB, err) return fmt.Errorf("failed to open storage trie of addr B %s: %w", addressB, err)
} }
......
...@@ -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, nil, nil, nil) payloadEnv := engine.BlockToExecutableData(copyHead, 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
} }
......
...@@ -17,6 +17,7 @@ import ( ...@@ -17,6 +17,7 @@ import (
"github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/trie" "github.com/ethereum/go-ethereum/trie"
"github.com/ethereum/go-ethereum/trie/triedb/hashdb"
) )
// ABI types // ABI types
...@@ -272,7 +273,7 @@ func main() { ...@@ -272,7 +273,7 @@ func main() {
// Create a secure trie for state // Create a secure trie for state
state, err := trie.NewStateTrie( state, err := trie.NewStateTrie(
trie.TrieID(types.EmptyRootHash), trie.TrieID(types.EmptyRootHash),
trie.NewDatabase(rawdb.NewMemoryDatabase()), trie.NewDatabase(rawdb.NewMemoryDatabase(), &trie.Config{HashDB: hashdb.Defaults}),
) )
checkErr(err, "Error creating secure trie") checkErr(err, "Error creating secure trie")
...@@ -283,7 +284,7 @@ func main() { ...@@ -283,7 +284,7 @@ func main() {
// Create a secure trie for the world state // Create a secure trie for the world state
world, err := trie.NewStateTrie( world, err := trie.NewStateTrie(
trie.TrieID(types.EmptyRootHash), trie.TrieID(types.EmptyRootHash),
trie.NewDatabase(rawdb.NewMemoryDatabase()), trie.NewDatabase(rawdb.NewMemoryDatabase(), &trie.Config{HashDB: hashdb.Defaults}),
) )
checkErr(err, "Error creating secure trie") checkErr(err, "Error creating secure trie")
......
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