From aee14ebee966d6d32b80f42da360cddeb7b969eb Mon Sep 17 00:00:00 2001 From: philip-morlier Date: Thu, 6 Apr 2023 18:09:53 -0700 Subject: [PATCH 1/4] Initial commit of work to expose state trie --- .../wrappers/backendwrapper/backendwrapper.go | 19 +++ .../wrappers/backendwrapper/triewrapper.go | 131 ++++++++++++++++++ 2 files changed, 150 insertions(+) create mode 100644 plugins/wrappers/backendwrapper/triewrapper.go diff --git a/plugins/wrappers/backendwrapper/backendwrapper.go b/plugins/wrappers/backendwrapper/backendwrapper.go index 0027ac223..4e532b211 100644 --- a/plugins/wrappers/backendwrapper/backendwrapper.go +++ b/plugins/wrappers/backendwrapper/backendwrapper.go @@ -11,10 +11,13 @@ import ( "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/common" gcore "github.com/ethereum/go-ethereum/core" + "github.com/ethereum/go-ethereum/core/state" + "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/event" "github.com/ethereum/go-ethereum/internal/ethapi" "github.com/ethereum/go-ethereum/log" + "github.com/ethereum/go-ethereum/trie" "github.com/ethereum/go-ethereum/rlp" "github.com/ethereum/go-ethereum/rpc" @@ -460,3 +463,19 @@ func (b *Backend) ChainConfig() *params.ChainConfig { } return b.chainConfig } + +func (b *Backend) GetTrie(h core.Hash) state.Trie { + return NewWrappedTrie(trie.New(trie.TrieID(common.Hash(h)), trie.NewDatabase(b.b.ChainDb()))) +} + +func (b *Backend) GetAccountTrie(stateRoot core.Hash, account core.Address) (state.Trie, error) { + tr := b.GetTrie(common.Hash(stateRoot)) + act := tr.TryGetAccount(common.Address(account)) + tr, _ := trie.NewStateTrie(trie.StorageTrieID(common.Hash(stateRoot), crypto.Keccak256Hash(account[:]), act.Root), b.b.ChainDb().triedb) + return tr, nil +} + + + + + diff --git a/plugins/wrappers/backendwrapper/triewrapper.go b/plugins/wrappers/backendwrapper/triewrapper.go new file mode 100644 index 000000000..11cfd0d8d --- /dev/null +++ b/plugins/wrappers/backendwrapper/triewrapper.go @@ -0,0 +1,131 @@ +package backendwrapper + +import ( + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/ethdb" + "github.com/ethereum/go-ethereum/core/state" + "github.com/ethereum/go-ethereum/trie" + "github.com/ethereum/go-ethereum/core/types" + + "github.com/openrelayxyz/plugeth-utils/core" +) + +type WrappedTrie struct { + t state.Trie +} + +func NewWrappedTrie(t state.Trie) WrappedTrie { + return WrappedTrie{t} +} + +func (t WrappedTrie) GetKey(b []byte) []byte { + return t.t.GetKey(b) +} + +func (t WrappedTrie) TryGet(key []byte) ([]byte, error) { + return t.t.TryGet(key) +} + +func (t WrappedTrie) TryGetAccount(address common.Address) (*core.StateAccount, error) { + act, err := t.t.TryGetAccount(address) + if err != nil { + return nil, err + } + return NewWrappedStateAccount(act), nil +} + +func (t WrappedTrie) TryUpdate(key, value []byte) error { + return nil +} + +func (t WrappedTrie) TryUpdateAccount(address core.Address, account *core.StateAccount) error { + return nil +} + +func (t WrappedTrie) TryDelete(key []byte) error { + return nil +} + +func (t WrappedTrie) TryDeleteAccount(address common.Address) error { + return nil +} + +func (t WrappedTrie) Hash() core.Hash { + return core.Hash(t.t.Hash()) +} + +func (t WrappedTrie) Commit(collectLeaf bool) (core.Hash, *trie.NodeSet) { + //EmptyRootHash + return core.Hash(core.HexToHash("56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421")), nil +} + +func (t WrappedTrie) NodeIterator(startKey []byte) core.NodeIterator { + return t.t.NodeIterator(startKey) +} + +func (t WrappedTrie) Prove(key []byte, fromLevel uint, proofDb ethdb.KeyValueWriter) error { + return nil +} + +type WrappedStateAccount struct { + s *types.StateAccount +} + +func NewWrappedStateAccount(s *types.StateAccount) *WrappedStateAccount { + return &WrappedStateAccount{s} +} + +// Nonce uint64 +// Balance *big.Int +// Root Hash // merkle root of the storage trie +// CodeHash []byte +// } + +type WrappedNodeIterator struct { + n trie.NodeInterator +} + +func (n WrappedNodeIterator) Next(b bool) bool { + return n.n.Next() +} + +func (n WrappedNodeIterator) Error() error { + return n.n.Error() +} + +func (n WrappedNodeIterator) Hash() core.Hash { + return core.Hash(n.n.Hash()) +} + +func (n WrappedNodeIterator) Parent() core.Hash { + return core.Hash(n.n.Parent()) +} + +func (n WrappedNodeIterator) Path() []byte { + return n.n.Path() +} + +func (n WrappedNodeIterator) NodeBlob() []byte { + return n.n.NodeBlob() +} + +func (n WrappedNodeIterator) Leaf() bool { + return n.n.Leaf() +} + +func (n WrappedNodeIterator) LeafKey() []byte { + return n.n.LeafKey() +} + +func (n WrappedNodeIterator) LeafBlob() []byte { + return n.n.LeafBlob() +} + +func (n WrappedNodeIterator) LeafProof() [][]byte { + return n.n.LeafProof() +} + +func (n WrappedNodeIterator) AddResolver(trie.NodeResolver) { + return n.n.AddResolver() +} + From f92264d3421dea603e5875aca7d3cc9277953955 Mon Sep 17 00:00:00 2001 From: philip-morlier Date: Thu, 6 Apr 2023 22:49:14 -0700 Subject: [PATCH 2/4] further work on state trie wrapper --- .../wrappers/backendwrapper/backendwrapper.go | 24 +++++------ .../wrappers/backendwrapper/triewrapper.go | 41 +++++++++++++++---- 2 files changed, 46 insertions(+), 19 deletions(-) diff --git a/plugins/wrappers/backendwrapper/backendwrapper.go b/plugins/wrappers/backendwrapper/backendwrapper.go index 4e532b211..1a0d051a8 100644 --- a/plugins/wrappers/backendwrapper/backendwrapper.go +++ b/plugins/wrappers/backendwrapper/backendwrapper.go @@ -11,13 +11,13 @@ import ( "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/common" gcore "github.com/ethereum/go-ethereum/core" - "github.com/ethereum/go-ethereum/core/state" - "github.com/ethereum/go-ethereum/crypto" + // "github.com/ethereum/go-ethereum/core/state" + // "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/event" "github.com/ethereum/go-ethereum/internal/ethapi" "github.com/ethereum/go-ethereum/log" - "github.com/ethereum/go-ethereum/trie" + // "github.com/ethereum/go-ethereum/trie" "github.com/ethereum/go-ethereum/rlp" "github.com/ethereum/go-ethereum/rpc" @@ -464,16 +464,16 @@ func (b *Backend) ChainConfig() *params.ChainConfig { return b.chainConfig } -func (b *Backend) GetTrie(h core.Hash) state.Trie { - return NewWrappedTrie(trie.New(trie.TrieID(common.Hash(h)), trie.NewDatabase(b.b.ChainDb()))) -} +// func (b *Backend) GetTrie(h core.Hash) state.Trie { +// return NewWrappedTrie(trie.New(trie.TrieID(common.Hash(h)), trie.NewDatabase(b.b.ChainDb()))) +// } -func (b *Backend) GetAccountTrie(stateRoot core.Hash, account core.Address) (state.Trie, error) { - tr := b.GetTrie(common.Hash(stateRoot)) - act := tr.TryGetAccount(common.Address(account)) - tr, _ := trie.NewStateTrie(trie.StorageTrieID(common.Hash(stateRoot), crypto.Keccak256Hash(account[:]), act.Root), b.b.ChainDb().triedb) - return tr, nil -} +// func (b *Backend) GetAccountTrie(stateRoot core.Hash, account core.Address) (state.Trie, error) { +// tr := b.GetTrie(common.Hash(stateRoot)) +// act := tr.TryGetAccount(common.Address(account)) +// stTr, _ := trie.NewStateTrie(trie.StorageTrieID(common.Hash(stateRoot), crypto.Keccak256Hash(account[:]), act.Root), b.b.ChainDb().triedb) +// return stTr, nil +// } diff --git a/plugins/wrappers/backendwrapper/triewrapper.go b/plugins/wrappers/backendwrapper/triewrapper.go index 11cfd0d8d..da3b6ec0a 100644 --- a/plugins/wrappers/backendwrapper/triewrapper.go +++ b/plugins/wrappers/backendwrapper/triewrapper.go @@ -1,6 +1,8 @@ package backendwrapper import ( + "math/big" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/core/state" @@ -26,12 +28,13 @@ func (t WrappedTrie) TryGet(key []byte) ([]byte, error) { return t.t.TryGet(key) } -func (t WrappedTrie) TryGetAccount(address common.Address) (*core.StateAccount, error) { - act, err := t.t.TryGetAccount(address) +func (t WrappedTrie) TryGetAccount(address core.Address) (*WrappedStateAccount, error) { + act, err := t.t.TryGetAccount(common.Address(address)) if err != nil { return nil, err } return NewWrappedStateAccount(act), nil + // return act, nil } func (t WrappedTrie) TryUpdate(key, value []byte) error { @@ -56,7 +59,7 @@ func (t WrappedTrie) Hash() core.Hash { func (t WrappedTrie) Commit(collectLeaf bool) (core.Hash, *trie.NodeSet) { //EmptyRootHash - return core.Hash(core.HexToHash("56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421")), nil + return core.HexToHash("56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421"), nil } func (t WrappedTrie) NodeIterator(startKey []byte) core.NodeIterator { @@ -75,6 +78,21 @@ func NewWrappedStateAccount(s *types.StateAccount) *WrappedStateAccount { return &WrappedStateAccount{s} } +func (w *WrappedStateAccount) Nonce() uint64 { + return w.s.Nonce +} + +func (w *WrappedStateAccount) Balance() *big.Int { + return w.s.Balance +} + +func (w *WrappedStateAccount) Root() core.Hash { + return core.Hash(w.s.Root) +} + +func (w *WrappedStateAccount) CodeHash() []byte { + return w.s.CodeHash +} // Nonce uint64 // Balance *big.Int // Root Hash // merkle root of the storage trie @@ -82,11 +100,11 @@ func NewWrappedStateAccount(s *types.StateAccount) *WrappedStateAccount { // } type WrappedNodeIterator struct { - n trie.NodeInterator + n trie.NodeIterator } func (n WrappedNodeIterator) Next(b bool) bool { - return n.n.Next() + return n.n.Next(b) } func (n WrappedNodeIterator) Error() error { @@ -125,7 +143,16 @@ func (n WrappedNodeIterator) LeafProof() [][]byte { return n.n.LeafProof() } -func (n WrappedNodeIterator) AddResolver(trie.NodeResolver) { - return n.n.AddResolver() +func (n WrappedNodeIterator) AddResolver(c core.NodeResolver) { + // nr := NewWrappedNodeResolver(trie.NodeResolver) + return n.n.AddResolver(c) +} + +type WrappedNodeResolver struct { + r core.NodeResolver +} + +func NewWrappedNodeResolver(r trie.NodeResolver) WrappedNodeResolver { + return WrappedNodeResolver{r} } From 5470afdeb84a643b381e2d71f6b5eabf46e2f585 Mon Sep 17 00:00:00 2001 From: philip-morlier Date: Fri, 7 Apr 2023 10:39:10 -0700 Subject: [PATCH 3/4] State Trie exposed to plugins The StateTrie interface is exposed via triewrapper.go and then implemented via two methods appended to the backend object. --- .../wrappers/backendwrapper/backendwrapper.go | 36 ++++--- .../wrappers/backendwrapper/triewrapper.go | 98 +++++-------------- 2 files changed, 46 insertions(+), 88 deletions(-) diff --git a/plugins/wrappers/backendwrapper/backendwrapper.go b/plugins/wrappers/backendwrapper/backendwrapper.go index 1a0d051a8..18f874f3c 100644 --- a/plugins/wrappers/backendwrapper/backendwrapper.go +++ b/plugins/wrappers/backendwrapper/backendwrapper.go @@ -11,13 +11,12 @@ import ( "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/common" gcore "github.com/ethereum/go-ethereum/core" - // "github.com/ethereum/go-ethereum/core/state" - // "github.com/ethereum/go-ethereum/crypto" + "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/event" "github.com/ethereum/go-ethereum/internal/ethapi" "github.com/ethereum/go-ethereum/log" - // "github.com/ethereum/go-ethereum/trie" + "github.com/ethereum/go-ethereum/trie" "github.com/ethereum/go-ethereum/rlp" "github.com/ethereum/go-ethereum/rpc" @@ -464,16 +463,29 @@ func (b *Backend) ChainConfig() *params.ChainConfig { return b.chainConfig } -// func (b *Backend) GetTrie(h core.Hash) state.Trie { -// return NewWrappedTrie(trie.New(trie.TrieID(common.Hash(h)), trie.NewDatabase(b.b.ChainDb()))) -// } +func (b *Backend) GetTrie(h core.Hash) (core.Trie, error) { + tr, err := trie.NewStateTrie(trie.TrieID(common.Hash(h)), trie.NewDatabase(b.b.ChainDb())) + if err != nil { + return nil, err + } + return NewWrappedTrie(tr), nil +} -// func (b *Backend) GetAccountTrie(stateRoot core.Hash, account core.Address) (state.Trie, error) { -// tr := b.GetTrie(common.Hash(stateRoot)) -// act := tr.TryGetAccount(common.Address(account)) -// stTr, _ := trie.NewStateTrie(trie.StorageTrieID(common.Hash(stateRoot), crypto.Keccak256Hash(account[:]), act.Root), b.b.ChainDb().triedb) -// return stTr, nil -// } +func (b *Backend) GetAccountTrie(stateRoot core.Hash, account core.Address) (core.Trie, error) { + tr, err := b.GetTrie(stateRoot) + if err != nil { + return nil, err + } + act, err := tr.TryGetAccount(account) + if err != nil { + return nil, err + } + acTr, err := trie.NewStateTrie(trie.StorageTrieID(common.Hash(stateRoot), crypto.Keccak256Hash(account[:]), common.Hash(act.Root)), trie.NewDatabase(b.b.ChainDb())) + if err != nil { + return nil, err + } + return NewWrappedTrie(acTr), nil +} diff --git a/plugins/wrappers/backendwrapper/triewrapper.go b/plugins/wrappers/backendwrapper/triewrapper.go index da3b6ec0a..0033cc065 100644 --- a/plugins/wrappers/backendwrapper/triewrapper.go +++ b/plugins/wrappers/backendwrapper/triewrapper.go @@ -1,13 +1,9 @@ package backendwrapper import ( - "math/big" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/trie" - "github.com/ethereum/go-ethereum/core/types" "github.com/openrelayxyz/plugeth-utils/core" ) @@ -16,89 +12,43 @@ type WrappedTrie struct { t state.Trie } -func NewWrappedTrie(t state.Trie) WrappedTrie { - return WrappedTrie{t} +func NewWrappedTrie(t state.Trie) core.Trie { + return &WrappedTrie{t} } -func (t WrappedTrie) GetKey(b []byte) []byte { +func (t *WrappedTrie) GetKey(b []byte) []byte { return t.t.GetKey(b) } - -func (t WrappedTrie) TryGet(key []byte) ([]byte, error) { +func (t *WrappedTrie) TryGet(key []byte) ([]byte, error) { return t.t.TryGet(key) } -func (t WrappedTrie) TryGetAccount(address core.Address) (*WrappedStateAccount, error) { +func (t *WrappedTrie) TryGetAccount(address core.Address) (*core.StateAccount, error) { act, err := t.t.TryGetAccount(common.Address(address)) if err != nil { return nil, err } - return NewWrappedStateAccount(act), nil - // return act, nil + return &core.StateAccount{ + Nonce: act.Nonce, + Balance: act.Balance, + Root: core.Hash(act.Root), + CodeHash: act.CodeHash, + }, nil } -func (t WrappedTrie) TryUpdate(key, value []byte) error { - return nil -} - -func (t WrappedTrie) TryUpdateAccount(address core.Address, account *core.StateAccount) error { - return nil -} - -func (t WrappedTrie) TryDelete(key []byte) error { - return nil -} - -func (t WrappedTrie) TryDeleteAccount(address common.Address) error { - return nil -} - -func (t WrappedTrie) Hash() core.Hash { +func (t *WrappedTrie) Hash() core.Hash { return core.Hash(t.t.Hash()) } -func (t WrappedTrie) Commit(collectLeaf bool) (core.Hash, *trie.NodeSet) { - //EmptyRootHash - return core.HexToHash("56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421"), nil +func (t *WrappedTrie) NodeIterator(startKey []byte) core.NodeIterator { + itr := t.t.NodeIterator(startKey) + return &WrappedNodeIterator{itr} } -func (t WrappedTrie) NodeIterator(startKey []byte) core.NodeIterator { - return t.t.NodeIterator(startKey) -} - -func (t WrappedTrie) Prove(key []byte, fromLevel uint, proofDb ethdb.KeyValueWriter) error { +func (t *WrappedTrie) Prove(key []byte, fromLevel uint, proofDb core.KeyValueWriter) error { return nil } -type WrappedStateAccount struct { - s *types.StateAccount -} - -func NewWrappedStateAccount(s *types.StateAccount) *WrappedStateAccount { - return &WrappedStateAccount{s} -} - -func (w *WrappedStateAccount) Nonce() uint64 { - return w.s.Nonce -} - -func (w *WrappedStateAccount) Balance() *big.Int { - return w.s.Balance -} - -func (w *WrappedStateAccount) Root() core.Hash { - return core.Hash(w.s.Root) -} - -func (w *WrappedStateAccount) CodeHash() []byte { - return w.s.CodeHash -} -// Nonce uint64 -// Balance *big.Int -// Root Hash // merkle root of the storage trie -// CodeHash []byte -// } - type WrappedNodeIterator struct { n trie.NodeIterator } @@ -144,15 +94,11 @@ func (n WrappedNodeIterator) LeafProof() [][]byte { } func (n WrappedNodeIterator) AddResolver(c core.NodeResolver) { - // nr := NewWrappedNodeResolver(trie.NodeResolver) - return n.n.AddResolver(c) -} - -type WrappedNodeResolver struct { - r core.NodeResolver -} - -func NewWrappedNodeResolver(r trie.NodeResolver) WrappedNodeResolver { - return WrappedNodeResolver{r} + n.n.AddResolver(WrappedNodeResolver(c)) } +func WrappedNodeResolver(fn core.NodeResolver) trie.NodeResolver { + return func(owner common.Hash, path []byte, hash common.Hash) []byte { + return fn(core.Hash(owner), path, core.Hash(hash) ) + } +} \ No newline at end of file From 829b8c48215d7827d24f7dcda0372d2ddd9c07d9 Mon Sep 17 00:00:00 2001 From: philip-morlier Date: Fri, 5 May 2023 14:14:15 -0700 Subject: [PATCH 4/4] Expose state trie to plugins Also merged changes in support geth v1.11.6. Updated to plugeth-utils v1.1.0. --- go.mod | 2 +- go.sum | 8 ++------ plugins/wrappers/backendwrapper/backendwrapper.go | 2 +- plugins/wrappers/backendwrapper/triewrapper.go | 7 ++----- 4 files changed, 6 insertions(+), 13 deletions(-) diff --git a/go.mod b/go.mod index 8d8201807..71c374bd0 100644 --- a/go.mod +++ b/go.mod @@ -50,7 +50,7 @@ require ( github.com/mattn/go-isatty v0.0.16 github.com/naoina/toml v0.1.2-0.20170918210437-9fafd6967416 github.com/olekukonko/tablewriter v0.0.5 - github.com/openrelayxyz/plugeth-utils v0.0.25 + github.com/openrelayxyz/plugeth-utils v1.1.0 github.com/peterh/liner v1.1.1-0.20190123174540-a2c9a5303de7 github.com/rs/cors v1.7.0 github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible diff --git a/go.sum b/go.sum index f5ee013c0..225d0091a 100644 --- a/go.sum +++ b/go.sum @@ -226,8 +226,6 @@ github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09 github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/holiman/bloomfilter/v2 v2.0.3 h1:73e0e/V0tCydx14a0SCYS/EWCxgwLZ18CZcZKVu0fao= github.com/holiman/bloomfilter/v2 v2.0.3/go.mod h1:zpoh+gs7qcpqrHr3dB55AMiJwo0iURXE7ZOP9L9hSkA= -github.com/holiman/uint256 v1.2.0 h1:gpSYcPLWGv4sG43I2mVLiDZCNDh/EpGjSk8tmtxitHM= -github.com/holiman/uint256 v1.2.0/go.mod h1:y4ga/t+u+Xwd7CpDgZESaRcWy0I7XMlTMA25ApIH5Jw= github.com/holiman/uint256 v1.2.2-0.20230321075855-87b91420868c h1:DZfsyhDK1hnSS5lH8l+JggqzEleHteTYfutAiVlSUM8= github.com/holiman/uint256 v1.2.2-0.20230321075855-87b91420868c/go.mod h1:SC8Ryt4n+UBbPbIBKaG9zbbDlp4jOru9xFZmPzLUTxw= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= @@ -351,10 +349,8 @@ github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9k github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.10.1 h1:o0+MgICZLuZ7xjH7Vx6zS/zcu93/BEp1VwkIW1mEXCE= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= -github.com/openrelayxyz/plugeth-utils v0.0.24 h1:Q2BR3SlwHovNFLbEtGrFFqgOCnL+ONyrwTC9wKKAej4= -github.com/openrelayxyz/plugeth-utils v0.0.24/go.mod h1:W1Hwwhv04MCuNCcI6a62/kL6eWbH7OO+KvpBEyQTgIs= -github.com/openrelayxyz/plugeth-utils v0.0.25 h1:UG9XNBA+V3ZVSXRpBIBXpa7fQIPd5MczrnBQTMpK1GY= -github.com/openrelayxyz/plugeth-utils v0.0.25/go.mod h1:W1Hwwhv04MCuNCcI6a62/kL6eWbH7OO+KvpBEyQTgIs= +github.com/openrelayxyz/plugeth-utils v1.1.0 h1:pK02TCFT32G/o/GNgAF+i3CihWfa/G71i0/vB9PHG3k= +github.com/openrelayxyz/plugeth-utils v1.1.0/go.mod h1:W1Hwwhv04MCuNCcI6a62/kL6eWbH7OO+KvpBEyQTgIs= github.com/opentracing/opentracing-go v1.1.0 h1:pWlfV3Bxv7k65HYwkikxat0+s3pV4bsqf19k25Ur8rU= github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= diff --git a/plugins/wrappers/backendwrapper/backendwrapper.go b/plugins/wrappers/backendwrapper/backendwrapper.go index 18f874f3c..c2421ddc9 100644 --- a/plugins/wrappers/backendwrapper/backendwrapper.go +++ b/plugins/wrappers/backendwrapper/backendwrapper.go @@ -476,7 +476,7 @@ func (b *Backend) GetAccountTrie(stateRoot core.Hash, account core.Address) (cor if err != nil { return nil, err } - act, err := tr.TryGetAccount(account) + act, err := tr.GetAccount(account) if err != nil { return nil, err } diff --git a/plugins/wrappers/backendwrapper/triewrapper.go b/plugins/wrappers/backendwrapper/triewrapper.go index 0033cc065..c3190fe8e 100644 --- a/plugins/wrappers/backendwrapper/triewrapper.go +++ b/plugins/wrappers/backendwrapper/triewrapper.go @@ -19,12 +19,9 @@ func NewWrappedTrie(t state.Trie) core.Trie { func (t *WrappedTrie) GetKey(b []byte) []byte { return t.t.GetKey(b) } -func (t *WrappedTrie) TryGet(key []byte) ([]byte, error) { - return t.t.TryGet(key) -} -func (t *WrappedTrie) TryGetAccount(address core.Address) (*core.StateAccount, error) { - act, err := t.t.TryGetAccount(common.Address(address)) +func (t *WrappedTrie) GetAccount(address core.Address) (*core.StateAccount, error) { + act, err := t.t.GetAccount(common.Address(address)) if err != nil { return nil, err }