Skip to content

Commit 7f22b59

Browse files
fjlholiman
authored andcommitted
core/state: simplify proof methods (#17965)
This fixes the import cycle build error in core/vm tests. There is no need to refer to core/vm for a type definition.
1 parent 4c0883e commit 7f22b59

2 files changed

Lines changed: 13 additions & 17 deletions

File tree

‎core/state/statedb.go‎

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import (
2626

2727
"github.com/ethereum/go-ethereum/common"
2828
"github.com/ethereum/go-ethereum/core/types"
29-
"github.com/ethereum/go-ethereum/core/vm"
3029
"github.com/ethereum/go-ethereum/crypto"
3130
"github.com/ethereum/go-ethereum/log"
3231
"github.com/ethereum/go-ethereum/rlp"
@@ -46,6 +45,13 @@ var (
4645
emptyCode = crypto.Keccak256Hash(nil)
4746
)
4847

48+
type proofList [][]byte
49+
50+
func (n *proofList) Put(key []byte, value []byte) error {
51+
*n = append(*n, value)
52+
return nil
53+
}
54+
4955
// StateDBs within the ethereum protocol are used to store anything
5056
// within the merkle trie. StateDBs take care of caching and storing
5157
// nested states. It's the general query interface to retrieve:
@@ -259,21 +265,21 @@ func (self *StateDB) GetState(addr common.Address, hash common.Hash) common.Hash
259265
}
260266

261267
// GetProof returns the MerkleProof for a given Account
262-
func (self *StateDB) GetProof(a common.Address) (vm.ProofList, error) {
263-
var proof vm.ProofList
268+
func (self *StateDB) GetProof(a common.Address) ([][]byte, error) {
269+
var proof proofList
264270
err := self.trie.Prove(crypto.Keccak256(a.Bytes()), 0, &proof)
265-
return proof, err
271+
return [][]byte(proof), err
266272
}
267273

268274
// GetProof returns the StorageProof for given key
269-
func (self *StateDB) GetStorageProof(a common.Address, key common.Hash) (vm.ProofList, error) {
270-
var proof vm.ProofList
275+
func (self *StateDB) GetStorageProof(a common.Address, key common.Hash) ([][]byte, error) {
276+
var proof proofList
271277
trie := self.StorageTrie(a)
272278
if trie == nil {
273279
return proof, errors.New("storage trie for requested address does not exist")
274280
}
275281
err := trie.Prove(crypto.Keccak256(key.Bytes()), 0, &proof)
276-
return proof, err
282+
return [][]byte(proof), err
277283
}
278284

279285
// GetCommittedState retrieves a value from the given account's committed storage trie.

‎core/vm/interface.go‎

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ type StateDB interface {
3535
SetNonce(common.Address, uint64)
3636

3737
GetCodeHash(common.Address) common.Hash
38-
GetProof(common.Address) (ProofList, error)
39-
GetStorageProof(common.Address, common.Hash) (ProofList, error)
4038
GetCode(common.Address) []byte
4139
SetCode(common.Address, []byte)
4240
GetCodeSize(common.Address) int
@@ -80,11 +78,3 @@ type CallContext interface {
8078
// Create a new contract
8179
Create(env *EVM, me ContractRef, data []byte, gas, value *big.Int) ([]byte, common.Address, error)
8280
}
83-
84-
// MerkleProof
85-
type ProofList [][]byte
86-
87-
func (n *ProofList) Put(key []byte, value []byte) error {
88-
*n = append(*n, value)
89-
return nil
90-
}

0 commit comments

Comments
 (0)