Skip to content

Commit

Permalink
Upgrade geth after schema changes (#97)
Browse files Browse the repository at this point in the history
* Include intermediate nodes in builder tests for watched addresses

* Upgrade geth
  • Loading branch information
prathamesh0 authored Jul 12, 2022
1 parent 0c56037 commit 1f898f6
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 12 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,4 @@ require (
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
)

replace github.com/ethereum/go-ethereum v1.10.19 => github.com/vulcanize/go-ethereum v1.10.19-statediff-4.0.4-alpha
replace github.com/ethereum/go-ethereum v1.10.19 => github.com/vulcanize/go-ethereum v1.10.19-statediff-4.1.0-alpha
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -727,8 +727,8 @@ github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPU
github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ=
github.com/vulcanize/go-eth-state-node-iterator v1.1.1 h1:/9zKsUzF1zlQDriAljdspmp1ixcIpOcbetiyHCPhbU0=
github.com/vulcanize/go-eth-state-node-iterator v1.1.1/go.mod h1:pL9jDztI5Yv9OOCKpCyo08/v+27othmbQlggoqH84Zo=
github.com/vulcanize/go-ethereum v1.10.19-statediff-4.0.4-alpha h1:fcUztJhvVHytSMwFzjoVR1RIPDkuAoZG8uqQUb7wBMg=
github.com/vulcanize/go-ethereum v1.10.19-statediff-4.0.4-alpha/go.mod h1:5tMN+CDbK/qI2UlfN307HJykDmVIOCB1FM5RcHK9Kp8=
github.com/vulcanize/go-ethereum v1.10.19-statediff-4.1.0-alpha h1:8ge2ban6t/e53XDwe6s28jcCevT7Ggo51lNJ0Eo1PgA=
github.com/vulcanize/go-ethereum v1.10.19-statediff-4.1.0-alpha/go.mod h1:5tMN+CDbK/qI2UlfN307HJykDmVIOCB1FM5RcHK9Kp8=
github.com/vulcanize/leveldb-ethdb-rpc v0.1.3 h1:R0+2GNMQKPXsKVWjTc6h5khD/aZzSarxxVsPEtBHiHU=
github.com/vulcanize/leveldb-ethdb-rpc v0.1.3/go.mod h1:A3aI/tDglAHGpB9/vmtwS/mWOvfGl1UFJ1jCbhIPMAM=
github.com/whyrusleeping/go-logging v0.0.0-20170515211332-0457bb6b88fc h1:9lDbC6Rz4bwmou+oE6Dt4Cb2BGMur5eR/GYptkKUVHo=
Expand Down
1 change: 0 additions & 1 deletion pkg/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ func (sdb *builder) WriteStateDiffObject(args sdtypes.StateRoots, params sd.Para
defer wg.Done()
var err error
if !params.IntermediateStateNodes {
// if we are watching only specific accounts then we are only diffing leaf nodes
err = sdb.BuildStateDiffWithoutIntermediateStateNodes(iterPairs[worker], params, nodeSender, codeSender)
} else {
err = sdb.BuildStateDiffWithIntermediateStateNodes(iterPairs[worker], params, nodeSender, codeSender)
Expand Down
91 changes: 88 additions & 3 deletions pkg/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -999,7 +999,9 @@ func TestBuilderWithWatchedAddressList(t *testing.T) {
block2 = blocks[1]
block3 = blocks[2]
params := sd.Params{
WatchedAddresses: []common.Address{test_helpers.Account1Addr, test_helpers.ContractAddr},
IntermediateStateNodes: true,
IntermediateStorageNodes: true,
WatchedAddresses: []common.Address{test_helpers.Account1Addr, test_helpers.ContractAddr},
}
params.ComputeWatchedAddressesLeafPaths()

Expand Down Expand Up @@ -1050,6 +1052,12 @@ func TestBuilderWithWatchedAddressList(t *testing.T) {
BlockNumber: block1.Number(),
BlockHash: block1.Hash(),
Nodes: []sdtypes.StateNode{
{
Path: []byte{},
NodeType: sdtypes.Branch,
NodeValue: block1BranchRootNode,
StorageNodes: emptyStorage,
},
{
Path: []byte{'\x0e'},
NodeType: sdtypes.Leaf,
Expand All @@ -1074,12 +1082,23 @@ func TestBuilderWithWatchedAddressList(t *testing.T) {
BlockNumber: block2.Number(),
BlockHash: block2.Hash(),
Nodes: []sdtypes.StateNode{
{
Path: []byte{},
NodeType: sdtypes.Branch,
NodeValue: block2BranchRootNode,
StorageNodes: emptyStorage,
},
{
Path: []byte{'\x06'},
NodeType: sdtypes.Leaf,
LeafKey: contractLeafKey,
NodeValue: contractAccountAtBlock2LeafNode,
StorageNodes: []sdtypes.StorageNode{
{
Path: []byte{},
NodeType: sdtypes.Branch,
NodeValue: block2StorageBranchRootNode,
},
{
Path: []byte{'\x02'},
NodeType: sdtypes.Leaf,
Expand Down Expand Up @@ -1124,12 +1143,23 @@ func TestBuilderWithWatchedAddressList(t *testing.T) {
BlockNumber: block3.Number(),
BlockHash: block3.Hash(),
Nodes: []sdtypes.StateNode{
{
Path: []byte{},
NodeType: sdtypes.Branch,
NodeValue: block3BranchRootNode,
StorageNodes: emptyStorage,
},
{
Path: []byte{'\x06'},
NodeType: sdtypes.Leaf,
LeafKey: contractLeafKey,
NodeValue: contractAccountAtBlock3LeafNode,
StorageNodes: []sdtypes.StorageNode{
{
Path: []byte{},
NodeType: sdtypes.Branch,
NodeValue: block3StorageBranchRootNode,
},
{
Path: []byte{'\x0c'},
NodeType: sdtypes.Leaf,
Expand Down Expand Up @@ -1611,7 +1641,9 @@ func TestBuilderWithRemovedNonWatchedAccount(t *testing.T) {
block5 = blocks[4]
block6 = blocks[5]
params := sd.Params{
WatchedAddresses: []common.Address{test_helpers.Account1Addr, test_helpers.Account2Addr},
IntermediateStateNodes: true,
IntermediateStorageNodes: true,
WatchedAddresses: []common.Address{test_helpers.Account1Addr, test_helpers.Account2Addr},
}
params.ComputeWatchedAddressesLeafPaths()

Expand All @@ -1632,6 +1664,12 @@ func TestBuilderWithRemovedNonWatchedAccount(t *testing.T) {
BlockNumber: block4.Number(),
BlockHash: block4.Hash(),
Nodes: []sdtypes.StateNode{
{
Path: []byte{},
NodeType: sdtypes.Branch,
NodeValue: block4BranchRootNode,
StorageNodes: emptyStorage,
},
{
Path: []byte{'\x0c'},
NodeType: sdtypes.Leaf,
Expand All @@ -1654,6 +1692,12 @@ func TestBuilderWithRemovedNonWatchedAccount(t *testing.T) {
BlockNumber: block5.Number(),
BlockHash: block5.Hash(),
Nodes: []sdtypes.StateNode{
{
Path: []byte{},
NodeType: sdtypes.Branch,
NodeValue: block5BranchRootNode,
StorageNodes: emptyStorage,
},
{
Path: []byte{'\x0e'},
NodeType: sdtypes.Leaf,
Expand All @@ -1676,6 +1720,12 @@ func TestBuilderWithRemovedNonWatchedAccount(t *testing.T) {
BlockNumber: block6.Number(),
BlockHash: block6.Hash(),
Nodes: []sdtypes.StateNode{
{
Path: []byte{},
NodeType: sdtypes.Branch,
NodeValue: block6BranchRootNode,
StorageNodes: emptyStorage,
},
{
Path: []byte{'\x0c'},
NodeType: sdtypes.Leaf,
Expand Down Expand Up @@ -1729,7 +1779,9 @@ func TestBuilderWithRemovedWatchedAccount(t *testing.T) {
block5 = blocks[4]
block6 = blocks[5]
params := sd.Params{
WatchedAddresses: []common.Address{test_helpers.Account1Addr, test_helpers.ContractAddr},
IntermediateStateNodes: true,
IntermediateStorageNodes: true,
WatchedAddresses: []common.Address{test_helpers.Account1Addr, test_helpers.ContractAddr},
}
params.ComputeWatchedAddressesLeafPaths()

Expand All @@ -1750,12 +1802,23 @@ func TestBuilderWithRemovedWatchedAccount(t *testing.T) {
BlockNumber: block4.Number(),
BlockHash: block4.Hash(),
Nodes: []sdtypes.StateNode{
{
Path: []byte{},
NodeType: sdtypes.Branch,
NodeValue: block4BranchRootNode,
StorageNodes: emptyStorage,
},
{
Path: []byte{'\x06'},
NodeType: sdtypes.Leaf,
LeafKey: contractLeafKey,
NodeValue: contractAccountAtBlock4LeafNode,
StorageNodes: []sdtypes.StorageNode{
{
Path: []byte{},
NodeType: sdtypes.Branch,
NodeValue: block4StorageBranchRootNode,
},
{
Path: []byte{'\x04'},
NodeType: sdtypes.Leaf,
Expand Down Expand Up @@ -1791,12 +1854,23 @@ func TestBuilderWithRemovedWatchedAccount(t *testing.T) {
BlockNumber: block5.Number(),
BlockHash: block5.Hash(),
Nodes: []sdtypes.StateNode{
{
Path: []byte{},
NodeType: sdtypes.Branch,
NodeValue: block5BranchRootNode,
StorageNodes: emptyStorage,
},
{
Path: []byte{'\x06'},
NodeType: sdtypes.Leaf,
LeafKey: contractLeafKey,
NodeValue: contractAccountAtBlock5LeafNode,
StorageNodes: []sdtypes.StorageNode{
{
Path: []byte{},
NodeType: sdtypes.Branch,
NodeValue: block5StorageBranchRootNode,
},
{
Path: []byte{'\x0c'},
NodeType: sdtypes.Leaf,
Expand Down Expand Up @@ -1833,12 +1907,23 @@ func TestBuilderWithRemovedWatchedAccount(t *testing.T) {
BlockNumber: block6.Number(),
BlockHash: block6.Hash(),
Nodes: []sdtypes.StateNode{
{
Path: []byte{},
NodeType: sdtypes.Branch,
NodeValue: block6BranchRootNode,
StorageNodes: emptyStorage,
},
{
Path: []byte{'\x06'},
NodeType: sdtypes.Removed,
LeafKey: contractLeafKey,
NodeValue: []byte{},
StorageNodes: []sdtypes.StorageNode{
{
Path: []byte{},
NodeType: sdtypes.Removed,
NodeValue: []byte{},
},
{
Path: []byte{'\x02'},
NodeType: sdtypes.Removed,
Expand Down
10 changes: 5 additions & 5 deletions pkg/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ func (sds *Service) StateDiffAt(blockNumber uint64, params sd.Params) (*sd.Paylo
}
logrus.Infof("sending state diff at block %d", blockNumber)

// compute leaf keys of watched addresses in the params
// compute leaf paths of watched addresses in the params
params.ComputeWatchedAddressesLeafPaths()

if blockNumber == 0 {
Expand All @@ -217,7 +217,7 @@ func (sds *Service) StateDiffFor(blockHash common.Hash, params sd.Params) (*sd.P
}
logrus.Infof("sending state diff at block %s", blockHash.Hex())

// compute leaf keys of watched addresses in the params
// compute leaf paths of watched addresses in the params
params.ComputeWatchedAddressesLeafPaths()

if currentBlock.NumberU64() == 0 {
Expand Down Expand Up @@ -290,7 +290,7 @@ func (sds *Service) StateTrieAt(blockNumber uint64, params sd.Params) (*sd.Paylo
}
logrus.Infof("sending state trie at block %d", blockNumber)

// compute leaf keys of watched addresses in the params
// compute leaf paths of watched addresses in the params
params.ComputeWatchedAddressesLeafPaths()

return sds.processStateTrie(currentBlock, params)
Expand Down Expand Up @@ -333,7 +333,7 @@ func (sds *Service) WriteStateDiffAt(blockNumber uint64, params sd.Params) error
return err
}

// compute leaf keys of watched addresses in the params
// compute leaf paths of watched addresses in the params
params.ComputeWatchedAddressesLeafPaths()

parentRoot := common.Hash{}
Expand All @@ -358,7 +358,7 @@ func (sds *Service) WriteStateDiffFor(blockHash common.Hash, params sd.Params) e
return err
}

// compute leaf keys of watched addresses in the params
// compute leaf paths of watched addresses in the params
params.ComputeWatchedAddressesLeafPaths()

parentRoot := common.Hash{}
Expand Down

0 comments on commit 1f898f6

Please sign in to comment.