Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Geth v1.9.11 #17

Closed
wants to merge 165 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
165 commits
Select commit Hold shift + click to select a range
00e0056
Write state diff to CSV (#2)
elizabethengelman Jan 28, 2019
837a66a
Apply go fmt changes to statediff
elizabethengelman Jan 30, 2019
ddb53ad
Apply goimports to statediff
elizabethengelman Jan 31, 2019
db01237
Apply gosimple changes to statediff
elizabethengelman Jan 31, 2019
2f34966
Gracefully exit geth command(#4)
elizabethengelman Feb 11, 2019
2b68430
Statediff for full node (#6)
elizabethengelman Feb 21, 2019
e18f462
refactoring/reorganizing packages
i-norden Apr 26, 2019
df1bfba
refactoring statediff builder and types and adjusted to relay proofs …
i-norden Apr 26, 2019
e69ab97
refactoring state diff service and adding api which allows for stream…
i-norden Apr 26, 2019
4e8d812
make proofs and paths optional + compress service loop into single fo…
i-norden May 13, 2019
adf43ec
option to process intermediate nodes
i-norden May 15, 2019
2cf3403
make state diff rlp serializable
i-norden May 16, 2019
ea34704
cli parameter to limit statediffing to select account addresses + test
i-norden May 17, 2019
bed68d4
review fixes and fixes for issues ran into in integration
i-norden May 17, 2019
f682030
review fixes; proper method signature for api; adjust service so that…
i-norden Jun 5, 2019
7096c9c
adjust buffering to improve stability; doc.go; fix notifier
i-norden Jun 7, 2019
a87a06f
relay receipts with the rest of the data + review fixes/changes
i-norden Jul 18, 2019
8c2f200
core: add blockchain test too for revert cornercase
holiman Sep 16, 2019
e00e187
params: release Geth v1.9.7
karalabe Nov 7, 2019
92e94dc
params: begin v1.9.8 release cycle
karalabe Nov 7, 2019
03a3783
p2p/enode: mock DNS resolver in URL parsing test (#20252)
fjl Nov 7, 2019
8a6bd87
travis: enable test suite on ARM64 (#20219)
gballet Nov 8, 2019
8489a29
p2p: fix bug in TestPeerDisconnect (#20277)
Nov 13, 2019
539ca8c
dashboard: send current block to the dashboard client (#19762)
kurkomisi Nov 13, 2019
ff0b463
miner: increase worker test timeout (#20268)
gballet Nov 13, 2019
c255367
les: implement server priority API (#20070)
zsfelfoldi Nov 13, 2019
e2482ae
accounts/abi/bind, cmd/abigen: implement alias for abigen (#20244)
rjl493456442 Nov 14, 2019
a672c10
rpc: fix typo example code (#20284)
Jorropo Nov 14, 2019
e2198a1
cmd/faucet: use github.com/gorilla/websocket (#20283)
fjl Nov 14, 2019
6329ba8
dashboard: remove the dashboard (#20279)
fjl Nov 14, 2019
a747953
whisper/whisperv6: fix staticcheck issues (#20288)
gballet Nov 14, 2019
0e3e967
build: gather info to investigate why builds fail on ARM (#20281)
gballet Nov 14, 2019
3c889e7
params: finish sentence in comment (#20291)
meowsbits Nov 14, 2019
d946ff0
core/vm: fix tracer interface parameter name (#20294)
nebojsa94 Nov 15, 2019
cc86617
internal/ethapi: don't query wallets at every execution of gas estima…
holiman Nov 11, 2019
3c1fbf9
cmd/evm: Allow loading input from file (#20273)
michaelforney Nov 17, 2019
f3fa942
rpc, p2p/simulations: use github.com/gorilla/websocket (#20289)
fjl Nov 18, 2019
cb1ba11
build: use golangci-lint (#20295)
fjl Nov 18, 2019
ef27606
travis: remove traces and use travis_wait in ARM build (#20296)
gballet Nov 18, 2019
3e06a55
core: s/isEIP155/isHomestead/g (fix IntrinsicGas signature var name) …
meowsbits Nov 18, 2019
4f9d21d
les: rename UpdateBalance to AddBalance and simplify return format (#…
zsfelfoldi Nov 18, 2019
0f3164d
travis: use travis_wait for both install and build (#20309)
gballet Nov 18, 2019
efc8f80
build: add test cmd flag -v for verbose logs (#20298)
meowsbits Nov 18, 2019
38888ac
cmd/clef: fix staticcheck warnings (#20314)
fjl Nov 18, 2019
40a8484
consensus/clique: add clique_status API method (#20103)
holiman Nov 18, 2019
5fd9461
consensus/clique: fix struct tags for status API (#20316)
fjl Nov 18, 2019
db93da5
cmd/ethkey: fix file permissions in changepassword command (#20313)
fjl Nov 19, 2019
756ed51
p2p/netutil: fix staticcheck warning (#20315)
fjl Nov 19, 2019
a2ea532
core/rawdb: check hash before return data from ancient db (#20195)
rjl493456442 Nov 19, 2019
c0428c4
travis: deactivate arm build during push (#20321)
gballet Nov 19, 2019
7364229
ethclient: remove use of common.ToHex (#20326)
fjl Nov 19, 2019
b1e2868
cmd/wnode: remove uses of common.ToHex (#20327)
fjl Nov 19, 2019
88e5154
event: remove unused field 'closed' (#20324)
fjl Nov 19, 2019
2153dbe
.github: remove 'nonsense' from CODEOWNERS (#20329)
gballet Nov 19, 2019
b01dccb
whisper/whisperv6: fix staticcheck warnings (#20328)
fjl Nov 19, 2019
2b8f3c4
p2p: remove unused code (#20325)
fjl Nov 19, 2019
67e9f39
p2p/simulations: fix staticcheck warnings (#20322)
fjl Nov 19, 2019
81d1bfd
internal/web3ext, les: update clique JS and make it work with the lig…
fjl Nov 19, 2019
06df38e
rpc: remove 'exported or builtin' restriction for parameters (#20332)
fjl Nov 20, 2019
0cc6974
core: fix staticcheck warnings (#20323)
fjl Nov 20, 2019
af3806f
miner: fix data race in tests (#20310)
rjl493456442 Nov 20, 2019
01a6254
cmd/puppeth: update chain spec of parity (#20241)
rjl493456442 Nov 20, 2019
46496e8
go.mod, vendor: switch to Go modules
karalabe Nov 18, 2019
93bb6c3
travis: explicitly enable go modules in Go 1.11 and 1.12
karalabe Nov 18, 2019
0e8c205
accounts/abi/bind: switch binding test to go modules
karalabe Nov 18, 2019
f19cbb0
travis, build: aggregate and upload go mod dependencies for PPA
karalabe Nov 18, 2019
f024339
go.mod: tidy up the modules to avoid xgo writes to go.sum
karalabe Nov 18, 2019
d83c9fa
build, internal/build: drop own file/folder copier
karalabe Nov 18, 2019
6f31c1f
travis: fake build ppa only for go module dependencies
karalabe Nov 18, 2019
fbc3611
mobile: fix CopyFile switch to package cp
karalabe Nov 18, 2019
c1dabf8
tests: refactor TestState to dedupe walk callback
meowsbits Nov 20, 2019
1887cd7
build, travis: use ephemeral debsrc GOPATH to get mod deps
karalabe Nov 20, 2019
3383739
tests: enable TransactionTests Istanbul case (#20337)
meowsbits Nov 20, 2019
13b28f7
cmd/puppeth: x-spec nonce data type, use types.BlockNonce
meowsbits Nov 20, 2019
419268f
cmd/puppeth: make ssh prompt more user-friendly
holiman Nov 21, 2019
62d423f
common/hexutil: improve GraphQL error messages (#20353)
fjl Nov 21, 2019
3d46043
build: pull in ci.go dependencies for the PPA builder
karalabe Nov 21, 2019
6ccf0a7
common: improve GraphQL error messages (#20354)
fjl Nov 21, 2019
d58ad8d
core/types: remove BlockBy sorting code (#20355)
fjl Nov 21, 2019
7be6449
build: skip go clean on PPA, messes with the module trick
karalabe Nov 21, 2019
76efa96
accounts/abi/bind/backends: remove unused assignment (#20359)
fjl Nov 21, 2019
9fa5359
accounts/abi: fix staticcheck warnings (#20358)
fjl Nov 21, 2019
4c2ce94
core/state: fix staticcheck warnings (#20357)
fjl Nov 22, 2019
747e449
metrics: fix issues reported by staticcheck (#20365)
gballet Nov 22, 2019
30af43f
trie: remove unused code (#20366)
fjl Nov 22, 2019
31cec2a
p2p/discv5: add deprecation warning and remove unused code (#20367)
fjl Nov 22, 2019
eaf136e
tests, signer: remove staticcheck warnings (#20364)
gballet Nov 23, 2019
fca48e2
core/asm: allow numbers in labels (#20362)
michaelforney Nov 23, 2019
d6a0772
miner: fix staticcheck warnings (#20375)
gballet Nov 24, 2019
e3f2545
eth/tracers: fix staticcheck warnings (#20379)
gballet Nov 24, 2019
ab5e0e3
trie: replace bigcache with fastcache (#19971)
rjl493456442 Nov 25, 2019
8e35276
cmd/geth: remove network id from version cmd
meowsbits Nov 25, 2019
397c3e2
rlp: fix staticcheck warnings (#20368)
fjl Nov 25, 2019
0d3bcbb
accounts/abi/bind: avoid reclaring structs (#20381)
rjl493456442 Nov 25, 2019
809a085
accounts/keystore: fix staticcheck warnings (#20373)
gballet Nov 25, 2019
070afb0
p2p/discover: slow down lookups on empty table (#20389)
fjl Nov 26, 2019
946f889
les: fix clientInfo deadlock (#20395)
zsfelfoldi Nov 26, 2019
572d244
params: release go-ethereum v1.9.8
karalabe Nov 26, 2019
3b549fa
params: begin v1.9.9 release cycle
karalabe Nov 26, 2019
d534abf
cmd: fix command help messages in modules (#20203)
zacscoding Nov 26, 2019
3784499
les: fix staticcheck warnings (#20371)
gballet Nov 27, 2019
0046347
core: fix staticcheck warnings (#20384)
gballet Nov 27, 2019
e7a06d5
core/rawdb: fix reinit regression caused by the hash check PR
karalabe Nov 27, 2019
9c04887
deps: update fastcache to 1.5.3
holiman Nov 27, 2019
b41940f
consensus/ethash: refactor remote sealer (#20335)
fjl Nov 28, 2019
e6f0294
log: fix staticcheck warnings (#20388)
gballet Nov 28, 2019
44e7bec
trie: remove dead code (#20405)
rjl493456442 Nov 28, 2019
376e876
cmd/faucet, cmd/geth: fix staticcheck warnings (#20374)
gballet Nov 29, 2019
84ce2ed
internal: fix staticcheck warnings (#20380)
gballet Nov 29, 2019
98e0b8c
accounts/scwallet: fix staticcheck warnings (#20370)
gballet Nov 29, 2019
05b3c16
internal/web3ext: add debug_accountRange (#20410)
xinluyin Nov 29, 2019
db26dfc
accounts/usbwallet: fix staticcheck warnings (#20372)
gballet Nov 29, 2019
72e8fb3
core, miner: remove PostChainEvents (#19396)
rjl493456442 Nov 29, 2019
091e9db
accounts/abi/bind: fix destructive packing of *big.Int (#20412)
MariusVanDerWijden Dec 2, 2019
4c4e8e8
trie: track dirty cache metrics, track clean writes on commit
karalabe Dec 2, 2019
0c7ae69
params: update CHTs for v1.9.9 release
karalabe Dec 5, 2019
04998d1
p2p/enode: remove data race in sliceIter (#20421)
MariusVanDerWijden Dec 5, 2019
e142beb
consensus/ethash, params: eip-2384: bump difficulty bomb (#20347)
holiman Dec 6, 2019
4a2e08d
params: release Geth v1.9.9
karalabe Dec 6, 2019
844ed25
Update test block hashes
elizabethengelman Dec 20, 2019
ed2bc05
Cleanup after rebasing v1.9.9
elizabethengelman Dec 20, 2019
d66903b
Add warning to statediff docs that empty payloads may be sent to sub
elizabethengelman Jan 27, 2020
95203db
Merge pull request #4 from makerdao/statediffing-service
Jan 28, 2020
6ab17fc
Merge pull request #7 from makerdao/statediff-check
Jan 28, 2020
4cc89a5
internal/build: don't crash in DownloadFile when offline (#20595)
fjl Feb 3, 2020
5a9c964
trie: separate hashes and committer, collapse on commit
holiman Feb 3, 2020
33791db
tracers: avoid panic on invalid arguments (#20612)
tintinweb Feb 4, 2020
058a4ac
core/evm: less iteration in blockhash (#20589)
holiman Feb 4, 2020
711ed74
cmd/geth: add 'dumpgenesis' command (#20191)
meowsbits Feb 4, 2020
a1313b5
trie: make hasher parallel when number of changes are large (#20488)
holiman Feb 4, 2020
976a0f5
cmd/devp2p: fix Route53 TXT record splitting (#20626)
fjl Feb 5, 2020
4a231cd
internal/ethapi: return non-null "number" for pending block (#20616)
holiman Feb 7, 2020
675f4e7
README.md: update evm usage example (#20635)
wolflo Feb 9, 2020
34bb132
graphql: add transaction signature values (#20623)
AmitBRD Feb 9, 2020
172f777
rpc: add error when call result parameter is not addressable (#20638)
adamschmideg Feb 11, 2020
8694d14
signer: add bytes32 as valid primitive (#20609)
chabashilah Feb 11, 2020
dcffb77
cmd/geth retesteth: add eth_getBlockByHash (#20621)
winsvega Feb 11, 2020
049e171
core, eth: implement eth/65 transaction fetcher
rjl493456442 Oct 28, 2019
c22fdec
common/mclock: add NewTimer and Timer.Reset (#20634)
fjl Feb 11, 2020
8045504
les: log disconnect reason when light server is not synced (#20643)
adamschmideg Feb 11, 2020
1821328
event: add missing unlock before panic (#20653)
Feb 12, 2020
46c4b69
accounts/abi/bind/backends: add support for historical state (#20644)
MariusVanDerWijden Feb 12, 2020
a9614c3
event, p2p/simulations/adapters: fix rare goroutine leaks (#20657)
Feb 12, 2020
5f2002b
accounts: add walletsNoLock to avoid double read lock (#20655)
Feb 12, 2020
90caa2c
p2p: new dial scheduler (#20592)
fjl Feb 13, 2020
9938d95
eth: rework tx fetcher to use O(1) ops + manage network requests
karalabe Jan 22, 2020
eddcecc
Merge pull request #20234 from rjl493456442/newtxhashes_2
karalabe Feb 13, 2020
38d1b0c
cmd/geth: enable DNS discovery by default (#20660)
fjl Feb 13, 2020
8556905
core: ensure state exists for prefetcher (#20627)
holiman Feb 14, 2020
37531b1
cmd/faucet: protect f.reqs with Rlock to prevent data race (#20669)
BurtonQin Feb 15, 2020
36a1e0b
eth: don't enforce minimum broadcast, fix broadcast test
karalabe Feb 17, 2020
fef8c98
travis, appveyor, build: bump builder Go to 1.13.8
karalabe Feb 17, 2020
26284ec
Merge pull request #20681 from karalabe/go1.13.8
karalabe Feb 17, 2020
ac72787
p2p: remove MeteredPeerEvent (#20679)
fjl Feb 17, 2020
1c4c486
cmd/ethkey: speed up test by using weaker scrypt parameters (#20680)
fjl Feb 17, 2020
c211798
Merge pull request #20678 from karalabe/broadcast-sqrt-proper
karalabe Feb 17, 2020
57d4898
p2p/dnsdisc: re-check tree root when leaf resolution fails (#20682)
fjl Feb 17, 2020
1b9c5b3
all: fix goroutine leaks in unit tests by adding 1-elem channel buffe…
BurtonQin Feb 17, 2020
91b2289
rpc: remove startup error for invalid modules, log it instead (#20684)
fjl Feb 17, 2020
4f55e24
params: update CHTs for the v1.9.11 release
karalabe Feb 18, 2020
05ccbb5
Merge pull request #20687 from karalabe/cht-1.9.11
karalabe Feb 18, 2020
dae3aee
les: add bootstrap nodes as initial discoveries (#20688)
fjl Feb 18, 2020
6a62fe3
params: release Geth v1.9.11 stable
karalabe Feb 18, 2020
b808126
Merge commit '6a62fe399b68ab9e3625ef5e7900394f389adc3a' into geth-v1.…
yaoandrew Feb 21, 2020
60bb77b
Clean up after merge
yaoandrew Feb 21, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
make proofs and paths optional + compress service loop into single fo…
…r loop (may be missing something here)
  • Loading branch information
i-norden authored and elizabethengelman committed Dec 30, 2019
commit 4e8d8129c23684f3bb4b2d1d9c694b307d3f5f79
2 changes: 2 additions & 0 deletions cmd/geth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ var (
utils.EWASMInterpreterFlag,
utils.EVMInterpreterFlag,
utils.StateDiffFlag,
utils.StateDiffPathsAndProofs,
utils.StateDiffLeafNodesOnly,
configFileFlag,
}

Expand Down
2 changes: 2 additions & 0 deletions cmd/geth/usage.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,8 @@ var AppHelpFlagGroups = []flagGroup{
Name: "STATE DIFF",
Flags: []cli.Flag{
utils.StateDiffFlag,
utils.StateDiffPathsAndProofs,
utils.StateDiffLeafNodesOnly,
},
},
{
Expand Down
14 changes: 13 additions & 1 deletion cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -763,6 +763,14 @@ var (
Name: "statediff",
Usage: "Enables the calculation of state diffs between each block, persists these state diffs the configured persistence mode.",
}
StateDiffPathsAndProofs = cli.BoolFlag{
Name: "statediff.pathsandproofs",
Usage: "Path and proof sets for the state and storage nodes are generated",
}
StateDiffLeafNodesOnly = cli.BoolFlag{
Name: "statediff.leafs",
Usage: "Consider only leaf nodes of the storage and state tries",
}
)

// MakeDataDir retrieves the currently requested data directory, terminating
Expand Down Expand Up @@ -1626,12 +1634,16 @@ func RegisterGraphQLService(stack *node.Node, endpoint string, cors, vhosts []st

// RegisterStateDiffService configures and registers a service to stream state diff data over RPC
func RegisterStateDiffService(stack *node.Node, ctx *cli.Context) {
config := statediff.Config{
PathsAndProofs: ctx.GlobalBool(StateDiffPathsAndProofs.Name),
LeafsOnly: ctx.GlobalBool(StateDiffLeafNodesOnly.Name),
}
if err := stack.Register(func(ctx *node.ServiceContext) (node.Service, error) {
var ethServ *eth.Ethereum
ctx.Service(&ethServ)
chainDb := ethServ.ChainDb()
blockChain := ethServ.BlockChain()
return statediff.NewStateDiffService(chainDb, blockChain)
return statediff.NewStateDiffService(chainDb, blockChain, config)
}); err != nil {
Fatalf("Failed to register State Diff Service", err)
}
Expand Down
191 changes: 120 additions & 71 deletions statediff/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
package statediff

import (
"fmt"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/core"
Expand All @@ -37,13 +38,15 @@ type Builder interface {

type builder struct {
chainDB ethdb.Database
config Config
blockChain *core.BlockChain
}

// NewBuilder is used to create a builder
func NewBuilder(db ethdb.Database, blockChain *core.BlockChain) Builder {
// NewBuilder is used to create a state diff builder
func NewBuilder(db ethdb.Database, blockChain *core.BlockChain, config Config) Builder {
return &builder{
chainDB: db,
config: config,
blockChain: blockChain,
}
}
Expand All @@ -54,31 +57,27 @@ func (sdb *builder) BuildStateDiff(oldStateRoot, newStateRoot common.Hash, block
stateCache := sdb.blockChain.StateCache()
oldTrie, err := stateCache.OpenTrie(oldStateRoot)
if err != nil {
log.Error("Error creating trie for oldStateRoot", "error", err)
return StateDiff{}, err
return StateDiff{}, fmt.Errorf("error creating trie for oldStateRoot: %v", err)
}
newTrie, err := stateCache.OpenTrie(newStateRoot)
if err != nil {
log.Error("Error creating trie for newStateRoot", "error", err)
return StateDiff{}, err
return StateDiff{}, fmt.Errorf("error creating trie for newStateRoot: %v", err)
}

// Find created accounts
oldIt := oldTrie.NodeIterator([]byte{})
newIt := newTrie.NodeIterator([]byte{})
creations, err := sdb.collectDiffNodes(oldIt, newIt)
if err != nil {
log.Error("Error collecting creation diff nodes", "error", err)
return StateDiff{}, err
return StateDiff{}, fmt.Errorf("error collecting creation diff nodes: %v", err)
}

// Find deleted accounts
oldIt = oldTrie.NodeIterator([]byte{})
newIt = newTrie.NodeIterator([]byte{})
deletions, err := sdb.collectDiffNodes(newIt, oldIt)
if err != nil {
log.Error("Error collecting deletion diff nodes", "error", err)
return StateDiff{}, err
return StateDiff{}, fmt.Errorf("error collecting deletion diff nodes: %v", err)
}

// Find all the diffed keys
Expand All @@ -89,18 +88,15 @@ func (sdb *builder) BuildStateDiff(oldStateRoot, newStateRoot common.Hash, block
// Build and return the statediff
updatedAccounts, err := sdb.buildDiffIncremental(creations, deletions, updatedKeys)
if err != nil {
log.Error("Error building diff for updated accounts", "error", err)
return StateDiff{}, err
return StateDiff{}, fmt.Errorf("error building diff for updated accounts: %v", err)
}
createdAccounts, err := sdb.buildDiffEventual(creations)
if err != nil {
log.Error("Error building diff for created accounts", "error", err)
return StateDiff{}, err
return StateDiff{}, fmt.Errorf("error building diff for created accounts: %v", err)
}
deletedAccounts, err := sdb.buildDiffEventual(deletions)
if err != nil {
log.Error("Error building diff for deleted accounts", "error", err)
return StateDiff{}, err
return StateDiff{}, fmt.Errorf("error building diff for deleted accounts: %v", err)
}

return StateDiff{
Expand All @@ -116,38 +112,69 @@ func (sdb *builder) collectDiffNodes(a, b trie.NodeIterator) (AccountsMap, error
var diffAccounts = make(AccountsMap)
it, _ := trie.NewDifferenceIterator(a, b)

for {
log.Debug("Current Path and Hash", "path", pathToStr(it), "hashold", it.Hash())
if it.Leaf() {
leafProof := make([][]byte, len(it.LeafProof()))
copy(leafProof, it.LeafProof())
leafPath := make([]byte, len(it.Path()))
copy(leafPath, it.Path())
leafKey := make([]byte, len(it.LeafKey()))
copy(leafKey, it.LeafKey())
leafKeyHash := common.BytesToHash(leafKey)
leafValue := make([]byte, len(it.LeafBlob()))
copy(leafValue, it.LeafBlob())
// lookup account state
var account state.Account
if err := rlp.DecodeBytes(leafValue, &account); err != nil {
log.Error("Error looking up account via address", "address", leafKeyHash, "error", err)
return nil, err
if sdb.config.PathsAndProofs {
for {
log.Debug("Current Path and Hash", "path", pathToStr(it), "hashold", it.Hash())
if it.Leaf() {
leafProof := make([][]byte, len(it.LeafProof()))
copy(leafProof, it.LeafProof())
leafPath := make([]byte, len(it.Path()))
copy(leafPath, it.Path())
leafKey := make([]byte, len(it.LeafKey()))
copy(leafKey, it.LeafKey())
leafKeyHash := common.BytesToHash(leafKey)
leafValue := make([]byte, len(it.LeafBlob()))
copy(leafValue, it.LeafBlob())
// lookup account state
var account state.Account
if err := rlp.DecodeBytes(leafValue, &account); err != nil {
return nil, fmt.Errorf("error looking up account via address: %s, error: %v", leafKeyHash.Hex(), err)
}
aw := accountWrapper{
Account: account,
RawKey: leafKey,
RawValue: leafValue,
Proof: leafProof,
Path: leafPath,
}
// record account to diffs (creation if we are looking at new - old; deletion if old - new)
log.Debug("Account lookup successful", "address", leafKeyHash, "account", account)
diffAccounts[leafKeyHash] = aw
}
aw := accountWrapper{
Account: account,
RawKey: leafKey,
RawValue: leafValue,
Proof: leafProof,
Path: leafPath,
cont := it.Next(true)
if !cont {
break
}
// record account to diffs (creation if we are looking at new - old; deletion if old - new)
log.Debug("Account lookup successful", "address", leafKeyHash, "account", account)
diffAccounts[leafKeyHash] = aw
}
cont := it.Next(true)
if !cont {
break
} else {
for {
log.Debug("Current Path and Hash", "path", pathToStr(it), "old hash", it.Hash())
if it.Leaf() {
leafKey := make([]byte, len(it.LeafKey()))
copy(leafKey, it.LeafKey())
leafKeyHash := common.BytesToHash(leafKey)
leafValue := make([]byte, len(it.LeafBlob()))
copy(leafValue, it.LeafBlob())
// lookup account state
var account state.Account
if err := rlp.DecodeBytes(leafValue, &account); err != nil {
return nil, fmt.Errorf("error looking up account via address: %s, error: %v", leafKeyHash.Hex(), err)
}
aw := accountWrapper{
Account: account,
RawKey: leafKey,
RawValue: leafValue,
Proof: nil,
Path: nil,
}
// record account to diffs (creation if we are looking at new - old; deletion if old - new)
log.Debug("Account lookup successful", "address", leafKeyHash, "account", account)
diffAccounts[leafKeyHash] = aw
}
cont := it.Next(true)
if !cont {
break
}
}
}

Expand All @@ -159,8 +186,7 @@ func (sdb *builder) buildDiffEventual(accounts AccountsMap) (AccountDiffsMap, er
for _, val := range accounts {
storageDiffs, err := sdb.buildStorageDiffsEventual(val.Account.Root)
if err != nil {
log.Error("Failed building eventual storage diffs", "Address", common.BytesToHash(val.RawKey), "error", err)
return nil, err
return nil, fmt.Errorf("failed building eventual storage diffs for address: %s, error: %v", common.BytesToHash(val.RawKey), err)
}
accountDiffs[common.BytesToHash(val.RawKey)] = AccountDiff{
Key: val.RawKey,
Expand Down Expand Up @@ -209,7 +235,7 @@ func (sdb *builder) buildStorageDiffsEventual(sr common.Hash) ([]StorageDiff, er
return nil, err
}
it := sTrie.NodeIterator(make([]byte, 0))
storageDiffs := buildStorageDiffsFromTrie(it)
storageDiffs := sdb.buildStorageDiffsFromTrie(it)
return storageDiffs, nil
}

Expand All @@ -229,35 +255,58 @@ func (sdb *builder) buildStorageDiffsIncremental(oldSR common.Hash, newSR common
oldIt := oldTrie.NodeIterator(make([]byte, 0))
newIt := newTrie.NodeIterator(make([]byte, 0))
it, _ := trie.NewDifferenceIterator(oldIt, newIt)
storageDiffs := buildStorageDiffsFromTrie(it)
storageDiffs := sdb.buildStorageDiffsFromTrie(it)

return storageDiffs, nil
}

func buildStorageDiffsFromTrie(it trie.NodeIterator) []StorageDiff {
func (sdb *builder) buildStorageDiffsFromTrie(it trie.NodeIterator) []StorageDiff {
storageDiffs := make([]StorageDiff, 0)
for {
log.Debug("Iterating over state at path ", "path", pathToStr(it))
if it.Leaf() {
log.Debug("Found leaf in storage", "path", pathToStr(it))
leafProof := make([][]byte, len(it.LeafProof()))
copy(leafProof, it.LeafProof())
leafPath := make([]byte, len(it.Path()))
copy(leafPath, it.Path())
leafKey := make([]byte, len(it.LeafKey()))
copy(leafKey, it.LeafKey())
leafValue := make([]byte, len(it.LeafBlob()))
copy(leafValue, it.LeafBlob())
storageDiffs = append(storageDiffs, StorageDiff{
Key: leafKey,
Value: leafValue,
Path: leafPath,
Proof: leafProof,
})
if sdb.config.PathsAndProofs {
for {
log.Debug("Iterating over state at path ", "path", pathToStr(it))
if it.Leaf() {
log.Debug("Found leaf in storage", "path", pathToStr(it))
leafProof := make([][]byte, len(it.LeafProof()))
copy(leafProof, it.LeafProof())
leafPath := make([]byte, len(it.Path()))
copy(leafPath, it.Path())
leafKey := make([]byte, len(it.LeafKey()))
copy(leafKey, it.LeafKey())
leafValue := make([]byte, len(it.LeafBlob()))
copy(leafValue, it.LeafBlob())
storageDiffs = append(storageDiffs, StorageDiff{
Key: leafKey,
Value: leafValue,
Path: leafPath,
Proof: leafProof,
})
}
cont := it.Next(true)
if !cont {
break
}
}
cont := it.Next(true)
if !cont {
break
} else {
for {
log.Debug("Iterating over state at path ", "path", pathToStr(it))
if it.Leaf() {
log.Debug("Found leaf in storage", "path", pathToStr(it))
leafKey := make([]byte, len(it.LeafKey()))
copy(leafKey, it.LeafKey())
leafValue := make([]byte, len(it.LeafBlob()))
copy(leafValue, it.LeafBlob())
storageDiffs = append(storageDiffs, StorageDiff{
Key: leafKey,
Value: leafValue,
Path: nil,
Proof: nil,
})
}
cont := it.Next(true)
if !cont {
break
}
}
}

Expand Down
5 changes: 4 additions & 1 deletion statediff/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ func TestBuilder(t *testing.T) {
block1 = blockMap[block1Hash]
block2 = blockMap[block2Hash]
block3 = blockMap[block3Hash]
builder = statediff.NewBuilder(testhelpers.Testdb, chain)
config := statediff.Config{
PathsAndProofs: true,
}
builder = statediff.NewBuilder(testhelpers.Testdb, chain, config)

type arguments struct {
oldStateRoot common.Hash
Expand Down
23 changes: 23 additions & 0 deletions statediff/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright 2019 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
// The go-ethereum library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// The go-ethereum library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.

package statediff

// Config is used to carry in parameters from CLI configuration
type Config struct {
PathsAndProofs bool
LeafsOnly bool
}
Loading