Skip to content

Commit aec0114

Browse files
authored
Merge pull request #126 from vulcanize/v1.10.9-statediff-0.0.27
Merge v1.10.9-statediff-0.0.27 to v1.10.9-statediff
2 parents 681d57a + 690eb15 commit aec0114

File tree

12 files changed

+57
-56
lines changed

12 files changed

+57
-56
lines changed

.github/workflows/checks.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ jobs:
66
linter-check:
77
runs-on: ubuntu-latest
88
steps:
9+
- uses: actions/setup-go@v2
10+
with:
11+
go-version: '1.16.x'
912
- uses: actions/checkout@v2
1013
- name: Run linter
1114
run: go run build/ci.go lint

.github/workflows/on-master.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ name: Docker Build and publish to Github
33
on:
44
push:
55
branches:
6+
- v1.10.9-statediff
67
- v1.10.8-statediff
78
- v1.10.7-statediff
89
- v1.10.6-statediff

.github/workflows/on-pr.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
name: Run geth unit test
1616
strategy:
1717
matrix:
18-
go-version: [ 1.15.x]
18+
go-version: [ 1.16.x]
1919
platform: [ubuntu-latest]
2020
runs-on: ${{ matrix.platform }}
2121
env:
@@ -43,7 +43,7 @@ jobs:
4343
GOPATH: /tmp/go
4444
strategy:
4545
matrix:
46-
go-version: [ 1.15.x]
46+
go-version: [ 1.16.x]
4747
platform: [ubuntu-latest]
4848
runs-on: ${{ matrix.platform }}
4949
steps:

statediff/builder.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ func (sdb *builder) buildStateTrie(it trie.NodeIterator) ([]StateNode, []CodeAnd
112112
}
113113
switch node.NodeType {
114114
case Leaf:
115-
var account state.Account
115+
var account types.StateAccount
116116
if err := rlp.DecodeBytes(nodeElements[1].([]byte), &account); err != nil {
117117
return nil, nil, fmt.Errorf("error decoding account for leaf node at path %x nerror: %v", node.Path, err)
118118
}
@@ -305,7 +305,7 @@ func (sdb *builder) createdAndUpdatedState(a, b trie.NodeIterator, watchedAddres
305305
if node.NodeType == Leaf {
306306
// created vs updated is important for leaf nodes since we need to diff their storage
307307
// so we need to map all changed accounts at B to their leafkey, since account can change pathes but not leafkey
308-
var account state.Account
308+
var account types.StateAccount
309309
if err := rlp.DecodeBytes(nodeElements[1].([]byte), &account); err != nil {
310310
return nil, nil, fmt.Errorf("error decoding account for leaf node at path %x nerror: %v", node.Path, err)
311311
}
@@ -350,7 +350,7 @@ func (sdb *builder) createdAndUpdatedStateWithIntermediateNodes(a, b trie.NodeIt
350350
case Leaf:
351351
// created vs updated is important for leaf nodes since we need to diff their storage
352352
// so we need to map all changed accounts at B to their leafkey, since account can change paths but not leafkey
353-
var account state.Account
353+
var account types.StateAccount
354354
if err := rlp.DecodeBytes(nodeElements[1].([]byte), &account); err != nil {
355355
return nil, nil, fmt.Errorf("error decoding account for leaf node at path %x nerror: %v", node.Path, err)
356356
}
@@ -401,7 +401,7 @@ func (sdb *builder) deletedOrUpdatedState(a, b trie.NodeIterator, diffPathsAtB m
401401
switch node.NodeType {
402402
case Leaf:
403403
// map all different accounts at A to their leafkey
404-
var account state.Account
404+
var account types.StateAccount
405405
if err := rlp.DecodeBytes(nodeElements[1].([]byte), &account); err != nil {
406406
return nil, fmt.Errorf("error decoding account for leaf node at path %x nerror: %v", node.Path, err)
407407
}

statediff/builder_test.go

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import (
2525
"testing"
2626

2727
"github.com/ethereum/go-ethereum/common"
28-
"github.com/ethereum/go-ethereum/core/state"
2928
"github.com/ethereum/go-ethereum/core/types"
3029
"github.com/ethereum/go-ethereum/crypto"
3130
"github.com/ethereum/go-ethereum/rlp"
@@ -79,7 +78,7 @@ var (
7978
slot0StorageValue,
8079
})
8180

82-
contractAccountAtBlock2, _ = rlp.EncodeToBytes(state.Account{
81+
contractAccountAtBlock2, _ = rlp.EncodeToBytes(types.StateAccount{
8382
Nonce: 1,
8483
Balance: big.NewInt(0),
8584
CodeHash: common.HexToHash("0xaaea5efba4fd7b45d7ec03918ac5d8b31aa93b48986af0e6b591f0f087c80127").Bytes(),
@@ -89,7 +88,7 @@ var (
8988
common.Hex2Bytes("3114658a74d9cc9f7acf2c5cd696c3494d7c344d78bfec3add0d91ec4e8d1c45"),
9089
contractAccountAtBlock2,
9190
})
92-
contractAccountAtBlock3, _ = rlp.EncodeToBytes(state.Account{
91+
contractAccountAtBlock3, _ = rlp.EncodeToBytes(types.StateAccount{
9392
Nonce: 1,
9493
Balance: big.NewInt(0),
9594
CodeHash: common.HexToHash("0xaaea5efba4fd7b45d7ec03918ac5d8b31aa93b48986af0e6b591f0f087c80127").Bytes(),
@@ -99,7 +98,7 @@ var (
9998
common.Hex2Bytes("3114658a74d9cc9f7acf2c5cd696c3494d7c344d78bfec3add0d91ec4e8d1c45"),
10099
contractAccountAtBlock3,
101100
})
102-
contractAccountAtBlock4, _ = rlp.EncodeToBytes(state.Account{
101+
contractAccountAtBlock4, _ = rlp.EncodeToBytes(types.StateAccount{
103102
Nonce: 1,
104103
Balance: big.NewInt(0),
105104
CodeHash: common.HexToHash("0xaaea5efba4fd7b45d7ec03918ac5d8b31aa93b48986af0e6b591f0f087c80127").Bytes(),
@@ -109,7 +108,7 @@ var (
109108
common.Hex2Bytes("3114658a74d9cc9f7acf2c5cd696c3494d7c344d78bfec3add0d91ec4e8d1c45"),
110109
contractAccountAtBlock4,
111110
})
112-
contractAccountAtBlock5, _ = rlp.EncodeToBytes(state.Account{
111+
contractAccountAtBlock5, _ = rlp.EncodeToBytes(types.StateAccount{
113112
Nonce: 1,
114113
Balance: big.NewInt(0),
115114
CodeHash: common.HexToHash("0xaaea5efba4fd7b45d7ec03918ac5d8b31aa93b48986af0e6b591f0f087c80127").Bytes(),
@@ -120,7 +119,7 @@ var (
120119
contractAccountAtBlock5,
121120
})
122121

123-
minerAccountAtBlock1, _ = rlp.EncodeToBytes(state.Account{
122+
minerAccountAtBlock1, _ = rlp.EncodeToBytes(types.StateAccount{
124123
Nonce: 0,
125124
Balance: big.NewInt(2000002625000000000),
126125
CodeHash: testhelpers.NullCodeHash.Bytes(),
@@ -130,7 +129,7 @@ var (
130129
common.Hex2Bytes("3380c7b7ae81a58eb98d9c78de4a1fd7fd9535fc953ed2be602daaa41767312a"),
131130
minerAccountAtBlock1,
132131
})
133-
minerAccountAtBlock2, _ = rlp.EncodeToBytes(state.Account{
132+
minerAccountAtBlock2, _ = rlp.EncodeToBytes(types.StateAccount{
134133
Nonce: 0,
135134
Balance: big.NewInt(4000111203461610525),
136135
CodeHash: testhelpers.NullCodeHash.Bytes(),
@@ -141,7 +140,7 @@ var (
141140
minerAccountAtBlock2,
142141
})
143142

144-
account1AtBlock1, _ = rlp.EncodeToBytes(state.Account{
143+
account1AtBlock1, _ = rlp.EncodeToBytes(types.StateAccount{
145144
Nonce: 0,
146145
Balance: testhelpers.Block1Account1Balance,
147146
CodeHash: testhelpers.NullCodeHash.Bytes(),
@@ -151,7 +150,7 @@ var (
151150
common.Hex2Bytes("3926db69aaced518e9b9f0f434a473e7174109c943548bb8f23be41ca76d9ad2"),
152151
account1AtBlock1,
153152
})
154-
account1AtBlock2, _ = rlp.EncodeToBytes(state.Account{
153+
account1AtBlock2, _ = rlp.EncodeToBytes(types.StateAccount{
155154
Nonce: 2,
156155
Balance: big.NewInt(999555797000009000),
157156
CodeHash: testhelpers.NullCodeHash.Bytes(),
@@ -161,7 +160,7 @@ var (
161160
common.Hex2Bytes("3926db69aaced518e9b9f0f434a473e7174109c943548bb8f23be41ca76d9ad2"),
162161
account1AtBlock2,
163162
})
164-
account1AtBlock5, _ = rlp.EncodeToBytes(state.Account{
163+
account1AtBlock5, _ = rlp.EncodeToBytes(types.StateAccount{
165164
Nonce: 2,
166165
Balance: big.NewInt(2999566008847709960),
167166
CodeHash: testhelpers.NullCodeHash.Bytes(),
@@ -171,7 +170,7 @@ var (
171170
common.Hex2Bytes("3926db69aaced518e9b9f0f434a473e7174109c943548bb8f23be41ca76d9ad2"),
172171
account1AtBlock5,
173172
})
174-
account1AtBlock6, _ = rlp.EncodeToBytes(state.Account{
173+
account1AtBlock6, _ = rlp.EncodeToBytes(types.StateAccount{
175174
Nonce: 3,
176175
Balance: big.NewInt(2999537516847709960),
177176
CodeHash: testhelpers.NullCodeHash.Bytes(),
@@ -182,7 +181,7 @@ var (
182181
account1AtBlock6,
183182
})
184183

185-
account2AtBlock2, _ = rlp.EncodeToBytes(state.Account{
184+
account2AtBlock2, _ = rlp.EncodeToBytes(types.StateAccount{
186185
Nonce: 0,
187186
Balance: big.NewInt(1000),
188187
CodeHash: testhelpers.NullCodeHash.Bytes(),
@@ -192,7 +191,7 @@ var (
192191
common.Hex2Bytes("3957f3e2f04a0764c3a0491b175f69926da61efbcc8f61fa1455fd2d2b4cdd45"),
193192
account2AtBlock2,
194193
})
195-
account2AtBlock3, _ = rlp.EncodeToBytes(state.Account{
194+
account2AtBlock3, _ = rlp.EncodeToBytes(types.StateAccount{
196195
Nonce: 0,
197196
Balance: big.NewInt(2000013574009435976),
198197
CodeHash: testhelpers.NullCodeHash.Bytes(),
@@ -202,7 +201,7 @@ var (
202201
common.Hex2Bytes("3957f3e2f04a0764c3a0491b175f69926da61efbcc8f61fa1455fd2d2b4cdd45"),
203202
account2AtBlock3,
204203
})
205-
account2AtBlock4, _ = rlp.EncodeToBytes(state.Account{
204+
account2AtBlock4, _ = rlp.EncodeToBytes(types.StateAccount{
206205
Nonce: 0,
207206
Balance: big.NewInt(4000048088163070348),
208207
CodeHash: testhelpers.NullCodeHash.Bytes(),
@@ -212,7 +211,7 @@ var (
212211
common.Hex2Bytes("3957f3e2f04a0764c3a0491b175f69926da61efbcc8f61fa1455fd2d2b4cdd45"),
213212
account2AtBlock4,
214213
})
215-
account2AtBlock6, _ = rlp.EncodeToBytes(state.Account{
214+
account2AtBlock6, _ = rlp.EncodeToBytes(types.StateAccount{
216215
Nonce: 0,
217216
Balance: big.NewInt(6000063293259748636),
218217
CodeHash: testhelpers.NullCodeHash.Bytes(),
@@ -223,7 +222,7 @@ var (
223222
account2AtBlock6,
224223
})
225224

226-
bankAccountAtBlock0, _ = rlp.EncodeToBytes(state.Account{
225+
bankAccountAtBlock0, _ = rlp.EncodeToBytes(types.StateAccount{
227226
Nonce: 0,
228227
Balance: big.NewInt(testhelpers.TestBankFunds.Int64()),
229228
CodeHash: testhelpers.NullCodeHash.Bytes(),
@@ -235,7 +234,7 @@ var (
235234
})
236235

237236
block1BankBalance = big.NewInt(testhelpers.TestBankFunds.Int64() - testhelpers.BalanceChange10000 - testhelpers.GasFees)
238-
bankAccountAtBlock1, _ = rlp.EncodeToBytes(state.Account{
237+
bankAccountAtBlock1, _ = rlp.EncodeToBytes(types.StateAccount{
239238
Nonce: 1,
240239
Balance: block1BankBalance,
241240
CodeHash: testhelpers.NullCodeHash.Bytes(),
@@ -247,7 +246,7 @@ var (
247246
})
248247

249248
block2BankBalance = block1BankBalance.Int64() - testhelpers.BalanceChange1Ether - testhelpers.GasFees
250-
bankAccountAtBlock2, _ = rlp.EncodeToBytes(state.Account{
249+
bankAccountAtBlock2, _ = rlp.EncodeToBytes(types.StateAccount{
251250
Nonce: 2,
252251
Balance: big.NewInt(block2BankBalance),
253252
CodeHash: testhelpers.NullCodeHash.Bytes(),
@@ -257,7 +256,7 @@ var (
257256
common.Hex2Bytes("30bf49f440a1cd0527e4d06e2765654c0f56452257516d793a9b8d604dcfdf2a"),
258257
bankAccountAtBlock2,
259258
})
260-
bankAccountAtBlock3, _ = rlp.EncodeToBytes(state.Account{
259+
bankAccountAtBlock3, _ = rlp.EncodeToBytes(types.StateAccount{
261260
Nonce: 3,
262261
Balance: big.NewInt(999914255999990000),
263262
CodeHash: testhelpers.NullCodeHash.Bytes(),
@@ -267,7 +266,7 @@ var (
267266
common.Hex2Bytes("30bf49f440a1cd0527e4d06e2765654c0f56452257516d793a9b8d604dcfdf2a"),
268267
bankAccountAtBlock3,
269268
})
270-
bankAccountAtBlock4, _ = rlp.EncodeToBytes(state.Account{
269+
bankAccountAtBlock4, _ = rlp.EncodeToBytes(types.StateAccount{
271270
Nonce: 6,
272271
Balance: big.NewInt(999826859999990000),
273272
CodeHash: testhelpers.NullCodeHash.Bytes(),
@@ -277,7 +276,7 @@ var (
277276
common.Hex2Bytes("30bf49f440a1cd0527e4d06e2765654c0f56452257516d793a9b8d604dcfdf2a"),
278277
bankAccountAtBlock4,
279278
})
280-
bankAccountAtBlock5, _ = rlp.EncodeToBytes(state.Account{
279+
bankAccountAtBlock5, _ = rlp.EncodeToBytes(types.StateAccount{
281280
Nonce: 7,
282281
Balance: big.NewInt(999805027999990000),
283282
CodeHash: testhelpers.NullCodeHash.Bytes(),
@@ -1727,7 +1726,7 @@ var (
17271726
slot00StorageValue,
17281727
})
17291728

1730-
contractAccountAtBlock01, _ = rlp.EncodeToBytes(state.Account{
1729+
contractAccountAtBlock01, _ = rlp.EncodeToBytes(types.StateAccount{
17311730
Nonce: 1,
17321731
Balance: big.NewInt(0),
17331732
CodeHash: common.HexToHash("0xaaea5efba4fd7b45d7ec03918ac5d8b31aa93b48986af0e6b591f0f087c80127").Bytes(),
@@ -1738,7 +1737,7 @@ var (
17381737
contractAccountAtBlock01,
17391738
})
17401739

1741-
bankAccountAtBlock01, _ = rlp.EncodeToBytes(state.Account{
1740+
bankAccountAtBlock01, _ = rlp.EncodeToBytes(types.StateAccount{
17421741
Nonce: 1,
17431742
Balance: big.NewInt(3999629697375000000),
17441743
CodeHash: testhelpers.NullCodeHash.Bytes(),
@@ -1748,7 +1747,7 @@ var (
17481747
common.Hex2Bytes("30bf49f440a1cd0527e4d06e2765654c0f56452257516d793a9b8d604dcfdf2a"),
17491748
bankAccountAtBlock01,
17501749
})
1751-
bankAccountAtBlock02, _ = rlp.EncodeToBytes(state.Account{
1750+
bankAccountAtBlock02, _ = rlp.EncodeToBytes(types.StateAccount{
17521751
Nonce: 2,
17531752
Balance: big.NewInt(5999607323457344852),
17541753
CodeHash: testhelpers.NullCodeHash.Bytes(),

statediff/indexer/indexer.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,12 @@ import (
2323
"math/big"
2424
"time"
2525

26+
"github.com/ipfs/go-cid"
27+
node "github.com/ipfs/go-ipld-format"
28+
"github.com/jmoiron/sqlx"
29+
"github.com/multiformats/go-multihash"
30+
2631
"github.com/ethereum/go-ethereum/common"
27-
"github.com/ethereum/go-ethereum/core/state"
2832
"github.com/ethereum/go-ethereum/core/types"
2933
"github.com/ethereum/go-ethereum/crypto"
3034
"github.com/ethereum/go-ethereum/log"
@@ -36,10 +40,6 @@ import (
3640
"github.com/ethereum/go-ethereum/statediff/indexer/postgres"
3741
"github.com/ethereum/go-ethereum/statediff/indexer/shared"
3842
sdtypes "github.com/ethereum/go-ethereum/statediff/types"
39-
"github.com/ipfs/go-cid"
40-
node "github.com/ipfs/go-ipld-format"
41-
"github.com/jmoiron/sqlx"
42-
"github.com/multiformats/go-multihash"
4343
)
4444

4545
var (
@@ -487,7 +487,7 @@ func (sdi *StateDiffIndexer) PushStateNode(tx *BlockTx, stateNode sdtypes.StateN
487487
if len(i) != 2 {
488488
return fmt.Errorf("eth IPLDPublisher expected state leaf node rlp to decode into two elements")
489489
}
490-
var account state.Account
490+
var account types.StateAccount
491491
if err := rlp.DecodeBytes(i[1].([]byte), &account); err != nil {
492492
return fmt.Errorf("error decoding state account rlp: %s", err.Error())
493493
}

statediff/indexer/ipfs/ipld/shared.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,16 @@ import (
2020
"bytes"
2121
"errors"
2222

23+
"github.com/ipfs/go-cid"
24+
mh "github.com/multiformats/go-multihash"
25+
2326
"github.com/ethereum/go-ethereum/common"
2427
"github.com/ethereum/go-ethereum/core/rawdb"
2528
"github.com/ethereum/go-ethereum/ethdb"
2629
"github.com/ethereum/go-ethereum/rlp"
2730
sdtrie "github.com/ethereum/go-ethereum/statediff/trie"
2831
sdtypes "github.com/ethereum/go-ethereum/statediff/types"
2932
"github.com/ethereum/go-ethereum/trie"
30-
"github.com/ipfs/go-cid"
31-
mh "github.com/multiformats/go-multihash"
3233
)
3334

3435
// IPLD Codecs for Ethereum
@@ -131,7 +132,7 @@ func (lt *localTrie) rootHash() []byte {
131132
func (lt *localTrie) commit() error {
132133
// commit trie nodes to trieDB
133134
var err error
134-
_, err = lt.trie.Commit(nil)
135+
_, _, err = lt.trie.Commit(nil)
135136
if err != nil {
136137
return err
137138
}

statediff/indexer/mocks/test_data.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import (
2727
"github.com/ethereum/go-ethereum/trie"
2828

2929
"github.com/ethereum/go-ethereum/common"
30-
"github.com/ethereum/go-ethereum/core/state"
3130
"github.com/ethereum/go-ethereum/core/types"
3231
"github.com/ethereum/go-ethereum/crypto"
3332
"github.com/ethereum/go-ethereum/log"
@@ -113,7 +112,7 @@ var (
113112
ContractRoot = "0x821e2556a290c86405f8160a2d662042a431ba456b9db265c79bb837c04be5f0"
114113
ContractCodeHash = common.HexToHash("0x753f98a8d4328b15636e46f66f2cb4bc860100aa17967cc145fcd17d1d4710ea")
115114
ContractLeafKey = testhelpers.AddressToLeafKey(ContractAddress)
116-
ContractAccount, _ = rlp.EncodeToBytes(state.Account{
115+
ContractAccount, _ = rlp.EncodeToBytes(types.StateAccount{
117116
Nonce: nonce1,
118117
Balance: big.NewInt(0),
119118
CodeHash: ContractCodeHash.Bytes(),
@@ -130,7 +129,7 @@ var (
130129
AccountCodeHash = common.HexToHash("0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470")
131130
AccountLeafKey = testhelpers.Account2LeafKey
132131
RemovedLeafKey = testhelpers.Account1LeafKey
133-
Account, _ = rlp.EncodeToBytes(state.Account{
132+
Account, _ = rlp.EncodeToBytes(types.StateAccount{
134133
Nonce: nonce0,
135134
Balance: big.NewInt(1000),
136135
CodeHash: AccountCodeHash.Bytes(),

0 commit comments

Comments
 (0)