aboutsummaryrefslogtreecommitdiffstats
path: root/core/state
diff options
context:
space:
mode:
authorSimon Jentzsch <simon@slock.it>2018-10-19 03:41:22 +0800
committerMartin Holst Swende <martin@swende.se>2018-10-19 03:41:22 +0800
commit97fb08342d227bbd126516083b0ddaf74e6e8468 (patch)
treeb47c7d9d8b6c1f7afdf2767d1099265a39a5fce0 /core/state
parentcdf5982cfca2cd7d5fea85c226af5e48fde837df (diff)
downloaddexon-97fb08342d227bbd126516083b0ddaf74e6e8468.tar.gz
dexon-97fb08342d227bbd126516083b0ddaf74e6e8468.tar.zst
dexon-97fb08342d227bbd126516083b0ddaf74e6e8468.zip
EIP-1186 eth_getProof (#17737)
* first impl of eth_getProof * fixed docu * added comments and refactored based on comments from holiman * created structs * handle errors correctly * change Value to *hexutil.Big in order to have the same output as parity * use ProofList as return type
Diffstat (limited to 'core/state')
-rw-r--r--core/state/statedb.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/core/state/statedb.go b/core/state/statedb.go
index 216667ce9..b1bb53ed0 100644
--- a/core/state/statedb.go
+++ b/core/state/statedb.go
@@ -18,6 +18,7 @@
package state
import (
+ "errors"
"fmt"
"math/big"
"sort"
@@ -25,6 +26,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
+ "github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/rlp"
@@ -256,6 +258,24 @@ func (self *StateDB) GetState(addr common.Address, hash common.Hash) common.Hash
return common.Hash{}
}
+// GetProof returns the MerkleProof for a given Account
+func (self *StateDB) GetProof(a common.Address) (vm.ProofList, error) {
+ var proof vm.ProofList
+ err := self.trie.Prove(crypto.Keccak256(a.Bytes()), 0, &proof)
+ return proof, err
+}
+
+// GetProof returns the StorageProof for given key
+func (self *StateDB) GetStorageProof(a common.Address, key common.Hash) (vm.ProofList, error) {
+ var proof vm.ProofList
+ trie := self.StorageTrie(a)
+ if trie == nil {
+ return proof, errors.New("storage trie for requested address does not exist")
+ }
+ err := trie.Prove(crypto.Keccak256(key.Bytes()), 0, &proof)
+ return proof, err
+}
+
// GetCommittedState retrieves a value from the given account's committed storage trie.
func (self *StateDB) GetCommittedState(addr common.Address, hash common.Hash) common.Hash {
stateObject := self.getStateObject(addr)