Merge v1.10.9-statediff-0.0.27 to v1.10.9-statediff #126

Merged
arijitAD merged 3 commits from v1.10.9-statediff-0.0.27 into v1.10.9-statediff 2021-09-30 14:43:53 +00:00
12 changed files with 57 additions and 56 deletions

View File

@ -6,6 +6,9 @@ jobs:
linter-check: linter-check:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/setup-go@v2
with:
go-version: '1.16.x'
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: Run linter - name: Run linter
run: go run build/ci.go lint run: go run build/ci.go lint

View File

@ -3,6 +3,7 @@ name: Docker Build and publish to Github
on: on:
push: push:
branches: branches:
- v1.10.9-statediff
- v1.10.8-statediff - v1.10.8-statediff
- v1.10.7-statediff - v1.10.7-statediff
- v1.10.6-statediff - v1.10.6-statediff

View File

@ -15,7 +15,7 @@ jobs:
name: Run geth unit test name: Run geth unit test
strategy: strategy:
matrix: matrix:
go-version: [ 1.15.x] go-version: [ 1.16.x]
platform: [ubuntu-latest] platform: [ubuntu-latest]
runs-on: ${{ matrix.platform }} runs-on: ${{ matrix.platform }}
env: env:
@ -43,7 +43,7 @@ jobs:
GOPATH: /tmp/go GOPATH: /tmp/go
strategy: strategy:
matrix: matrix:
go-version: [ 1.15.x] go-version: [ 1.16.x]
platform: [ubuntu-latest] platform: [ubuntu-latest]
runs-on: ${{ matrix.platform }} runs-on: ${{ matrix.platform }}
steps: steps:

View File

@ -112,7 +112,7 @@ func (sdb *builder) buildStateTrie(it trie.NodeIterator) ([]StateNode, []CodeAnd
} }
switch node.NodeType { switch node.NodeType {
case Leaf: case Leaf:
var account state.Account var account types.StateAccount
if err := rlp.DecodeBytes(nodeElements[1].([]byte), &account); err != nil { if err := rlp.DecodeBytes(nodeElements[1].([]byte), &account); err != nil {
return nil, nil, fmt.Errorf("error decoding account for leaf node at path %x nerror: %v", node.Path, err) return nil, nil, fmt.Errorf("error decoding account for leaf node at path %x nerror: %v", node.Path, err)
} }
@ -305,7 +305,7 @@ func (sdb *builder) createdAndUpdatedState(a, b trie.NodeIterator, watchedAddres
if node.NodeType == Leaf { if node.NodeType == Leaf {
// created vs updated is important for leaf nodes since we need to diff their storage // created vs updated is important for leaf nodes since we need to diff their storage
// so we need to map all changed accounts at B to their leafkey, since account can change pathes but not leafkey // so we need to map all changed accounts at B to their leafkey, since account can change pathes but not leafkey
var account state.Account var account types.StateAccount
if err := rlp.DecodeBytes(nodeElements[1].([]byte), &account); err != nil { if err := rlp.DecodeBytes(nodeElements[1].([]byte), &account); err != nil {
return nil, nil, fmt.Errorf("error decoding account for leaf node at path %x nerror: %v", node.Path, err) return nil, nil, fmt.Errorf("error decoding account for leaf node at path %x nerror: %v", node.Path, err)
} }
@ -350,7 +350,7 @@ func (sdb *builder) createdAndUpdatedStateWithIntermediateNodes(a, b trie.NodeIt
case Leaf: case Leaf:
// created vs updated is important for leaf nodes since we need to diff their storage // created vs updated is important for leaf nodes since we need to diff their storage
// so we need to map all changed accounts at B to their leafkey, since account can change paths but not leafkey // so we need to map all changed accounts at B to their leafkey, since account can change paths but not leafkey
var account state.Account var account types.StateAccount
if err := rlp.DecodeBytes(nodeElements[1].([]byte), &account); err != nil { if err := rlp.DecodeBytes(nodeElements[1].([]byte), &account); err != nil {
return nil, nil, fmt.Errorf("error decoding account for leaf node at path %x nerror: %v", node.Path, err) return nil, nil, fmt.Errorf("error decoding account for leaf node at path %x nerror: %v", node.Path, err)
} }
@ -401,7 +401,7 @@ func (sdb *builder) deletedOrUpdatedState(a, b trie.NodeIterator, diffPathsAtB m
switch node.NodeType { switch node.NodeType {
case Leaf: case Leaf:
// map all different accounts at A to their leafkey // map all different accounts at A to their leafkey
var account state.Account var account types.StateAccount
if err := rlp.DecodeBytes(nodeElements[1].([]byte), &account); err != nil { if err := rlp.DecodeBytes(nodeElements[1].([]byte), &account); err != nil {
return nil, fmt.Errorf("error decoding account for leaf node at path %x nerror: %v", node.Path, err) return nil, fmt.Errorf("error decoding account for leaf node at path %x nerror: %v", node.Path, err)
} }

View File

@ -25,7 +25,6 @@ import (
"testing" "testing"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/rlp" "github.com/ethereum/go-ethereum/rlp"
@ -79,7 +78,7 @@ var (
slot0StorageValue, slot0StorageValue,
}) })
contractAccountAtBlock2, _ = rlp.EncodeToBytes(state.Account{ contractAccountAtBlock2, _ = rlp.EncodeToBytes(types.StateAccount{
Nonce: 1, Nonce: 1,
Balance: big.NewInt(0), Balance: big.NewInt(0),
CodeHash: common.HexToHash("0xaaea5efba4fd7b45d7ec03918ac5d8b31aa93b48986af0e6b591f0f087c80127").Bytes(), CodeHash: common.HexToHash("0xaaea5efba4fd7b45d7ec03918ac5d8b31aa93b48986af0e6b591f0f087c80127").Bytes(),
@ -89,7 +88,7 @@ var (
common.Hex2Bytes("3114658a74d9cc9f7acf2c5cd696c3494d7c344d78bfec3add0d91ec4e8d1c45"), common.Hex2Bytes("3114658a74d9cc9f7acf2c5cd696c3494d7c344d78bfec3add0d91ec4e8d1c45"),
contractAccountAtBlock2, contractAccountAtBlock2,
}) })
contractAccountAtBlock3, _ = rlp.EncodeToBytes(state.Account{ contractAccountAtBlock3, _ = rlp.EncodeToBytes(types.StateAccount{
Nonce: 1, Nonce: 1,
Balance: big.NewInt(0), Balance: big.NewInt(0),
CodeHash: common.HexToHash("0xaaea5efba4fd7b45d7ec03918ac5d8b31aa93b48986af0e6b591f0f087c80127").Bytes(), CodeHash: common.HexToHash("0xaaea5efba4fd7b45d7ec03918ac5d8b31aa93b48986af0e6b591f0f087c80127").Bytes(),
@ -99,7 +98,7 @@ var (
common.Hex2Bytes("3114658a74d9cc9f7acf2c5cd696c3494d7c344d78bfec3add0d91ec4e8d1c45"), common.Hex2Bytes("3114658a74d9cc9f7acf2c5cd696c3494d7c344d78bfec3add0d91ec4e8d1c45"),
contractAccountAtBlock3, contractAccountAtBlock3,
}) })
contractAccountAtBlock4, _ = rlp.EncodeToBytes(state.Account{ contractAccountAtBlock4, _ = rlp.EncodeToBytes(types.StateAccount{
Nonce: 1, Nonce: 1,
Balance: big.NewInt(0), Balance: big.NewInt(0),
CodeHash: common.HexToHash("0xaaea5efba4fd7b45d7ec03918ac5d8b31aa93b48986af0e6b591f0f087c80127").Bytes(), CodeHash: common.HexToHash("0xaaea5efba4fd7b45d7ec03918ac5d8b31aa93b48986af0e6b591f0f087c80127").Bytes(),
@ -109,7 +108,7 @@ var (
common.Hex2Bytes("3114658a74d9cc9f7acf2c5cd696c3494d7c344d78bfec3add0d91ec4e8d1c45"), common.Hex2Bytes("3114658a74d9cc9f7acf2c5cd696c3494d7c344d78bfec3add0d91ec4e8d1c45"),
contractAccountAtBlock4, contractAccountAtBlock4,
}) })
contractAccountAtBlock5, _ = rlp.EncodeToBytes(state.Account{ contractAccountAtBlock5, _ = rlp.EncodeToBytes(types.StateAccount{
Nonce: 1, Nonce: 1,
Balance: big.NewInt(0), Balance: big.NewInt(0),
CodeHash: common.HexToHash("0xaaea5efba4fd7b45d7ec03918ac5d8b31aa93b48986af0e6b591f0f087c80127").Bytes(), CodeHash: common.HexToHash("0xaaea5efba4fd7b45d7ec03918ac5d8b31aa93b48986af0e6b591f0f087c80127").Bytes(),
@ -120,7 +119,7 @@ var (
contractAccountAtBlock5, contractAccountAtBlock5,
}) })
minerAccountAtBlock1, _ = rlp.EncodeToBytes(state.Account{ minerAccountAtBlock1, _ = rlp.EncodeToBytes(types.StateAccount{
Nonce: 0, Nonce: 0,
Balance: big.NewInt(2000002625000000000), Balance: big.NewInt(2000002625000000000),
CodeHash: testhelpers.NullCodeHash.Bytes(), CodeHash: testhelpers.NullCodeHash.Bytes(),
@ -130,7 +129,7 @@ var (
common.Hex2Bytes("3380c7b7ae81a58eb98d9c78de4a1fd7fd9535fc953ed2be602daaa41767312a"), common.Hex2Bytes("3380c7b7ae81a58eb98d9c78de4a1fd7fd9535fc953ed2be602daaa41767312a"),
minerAccountAtBlock1, minerAccountAtBlock1,
}) })
minerAccountAtBlock2, _ = rlp.EncodeToBytes(state.Account{ minerAccountAtBlock2, _ = rlp.EncodeToBytes(types.StateAccount{
Nonce: 0, Nonce: 0,
Balance: big.NewInt(4000111203461610525), Balance: big.NewInt(4000111203461610525),
CodeHash: testhelpers.NullCodeHash.Bytes(), CodeHash: testhelpers.NullCodeHash.Bytes(),
@ -141,7 +140,7 @@ var (
minerAccountAtBlock2, minerAccountAtBlock2,
}) })
account1AtBlock1, _ = rlp.EncodeToBytes(state.Account{ account1AtBlock1, _ = rlp.EncodeToBytes(types.StateAccount{
Nonce: 0, Nonce: 0,
Balance: testhelpers.Block1Account1Balance, Balance: testhelpers.Block1Account1Balance,
CodeHash: testhelpers.NullCodeHash.Bytes(), CodeHash: testhelpers.NullCodeHash.Bytes(),
@ -151,7 +150,7 @@ var (
common.Hex2Bytes("3926db69aaced518e9b9f0f434a473e7174109c943548bb8f23be41ca76d9ad2"), common.Hex2Bytes("3926db69aaced518e9b9f0f434a473e7174109c943548bb8f23be41ca76d9ad2"),
account1AtBlock1, account1AtBlock1,
}) })
account1AtBlock2, _ = rlp.EncodeToBytes(state.Account{ account1AtBlock2, _ = rlp.EncodeToBytes(types.StateAccount{
Nonce: 2, Nonce: 2,
Balance: big.NewInt(999555797000009000), Balance: big.NewInt(999555797000009000),
CodeHash: testhelpers.NullCodeHash.Bytes(), CodeHash: testhelpers.NullCodeHash.Bytes(),
@ -161,7 +160,7 @@ var (
common.Hex2Bytes("3926db69aaced518e9b9f0f434a473e7174109c943548bb8f23be41ca76d9ad2"), common.Hex2Bytes("3926db69aaced518e9b9f0f434a473e7174109c943548bb8f23be41ca76d9ad2"),
account1AtBlock2, account1AtBlock2,
}) })
account1AtBlock5, _ = rlp.EncodeToBytes(state.Account{ account1AtBlock5, _ = rlp.EncodeToBytes(types.StateAccount{
Nonce: 2, Nonce: 2,
Balance: big.NewInt(2999566008847709960), Balance: big.NewInt(2999566008847709960),
CodeHash: testhelpers.NullCodeHash.Bytes(), CodeHash: testhelpers.NullCodeHash.Bytes(),
@ -171,7 +170,7 @@ var (
common.Hex2Bytes("3926db69aaced518e9b9f0f434a473e7174109c943548bb8f23be41ca76d9ad2"), common.Hex2Bytes("3926db69aaced518e9b9f0f434a473e7174109c943548bb8f23be41ca76d9ad2"),
account1AtBlock5, account1AtBlock5,
}) })
account1AtBlock6, _ = rlp.EncodeToBytes(state.Account{ account1AtBlock6, _ = rlp.EncodeToBytes(types.StateAccount{
Nonce: 3, Nonce: 3,
Balance: big.NewInt(2999537516847709960), Balance: big.NewInt(2999537516847709960),
CodeHash: testhelpers.NullCodeHash.Bytes(), CodeHash: testhelpers.NullCodeHash.Bytes(),
@ -182,7 +181,7 @@ var (
account1AtBlock6, account1AtBlock6,
}) })
account2AtBlock2, _ = rlp.EncodeToBytes(state.Account{ account2AtBlock2, _ = rlp.EncodeToBytes(types.StateAccount{
Nonce: 0, Nonce: 0,
Balance: big.NewInt(1000), Balance: big.NewInt(1000),
CodeHash: testhelpers.NullCodeHash.Bytes(), CodeHash: testhelpers.NullCodeHash.Bytes(),
@ -192,7 +191,7 @@ var (
common.Hex2Bytes("3957f3e2f04a0764c3a0491b175f69926da61efbcc8f61fa1455fd2d2b4cdd45"), common.Hex2Bytes("3957f3e2f04a0764c3a0491b175f69926da61efbcc8f61fa1455fd2d2b4cdd45"),
account2AtBlock2, account2AtBlock2,
}) })
account2AtBlock3, _ = rlp.EncodeToBytes(state.Account{ account2AtBlock3, _ = rlp.EncodeToBytes(types.StateAccount{
Nonce: 0, Nonce: 0,
Balance: big.NewInt(2000013574009435976), Balance: big.NewInt(2000013574009435976),
CodeHash: testhelpers.NullCodeHash.Bytes(), CodeHash: testhelpers.NullCodeHash.Bytes(),
@ -202,7 +201,7 @@ var (
common.Hex2Bytes("3957f3e2f04a0764c3a0491b175f69926da61efbcc8f61fa1455fd2d2b4cdd45"), common.Hex2Bytes("3957f3e2f04a0764c3a0491b175f69926da61efbcc8f61fa1455fd2d2b4cdd45"),
account2AtBlock3, account2AtBlock3,
}) })
account2AtBlock4, _ = rlp.EncodeToBytes(state.Account{ account2AtBlock4, _ = rlp.EncodeToBytes(types.StateAccount{
Nonce: 0, Nonce: 0,
Balance: big.NewInt(4000048088163070348), Balance: big.NewInt(4000048088163070348),
CodeHash: testhelpers.NullCodeHash.Bytes(), CodeHash: testhelpers.NullCodeHash.Bytes(),
@ -212,7 +211,7 @@ var (
common.Hex2Bytes("3957f3e2f04a0764c3a0491b175f69926da61efbcc8f61fa1455fd2d2b4cdd45"), common.Hex2Bytes("3957f3e2f04a0764c3a0491b175f69926da61efbcc8f61fa1455fd2d2b4cdd45"),
account2AtBlock4, account2AtBlock4,
}) })
account2AtBlock6, _ = rlp.EncodeToBytes(state.Account{ account2AtBlock6, _ = rlp.EncodeToBytes(types.StateAccount{
Nonce: 0, Nonce: 0,
Balance: big.NewInt(6000063293259748636), Balance: big.NewInt(6000063293259748636),
CodeHash: testhelpers.NullCodeHash.Bytes(), CodeHash: testhelpers.NullCodeHash.Bytes(),
@ -223,7 +222,7 @@ var (
account2AtBlock6, account2AtBlock6,
}) })
bankAccountAtBlock0, _ = rlp.EncodeToBytes(state.Account{ bankAccountAtBlock0, _ = rlp.EncodeToBytes(types.StateAccount{
Nonce: 0, Nonce: 0,
Balance: big.NewInt(testhelpers.TestBankFunds.Int64()), Balance: big.NewInt(testhelpers.TestBankFunds.Int64()),
CodeHash: testhelpers.NullCodeHash.Bytes(), CodeHash: testhelpers.NullCodeHash.Bytes(),
@ -235,7 +234,7 @@ var (
}) })
block1BankBalance = big.NewInt(testhelpers.TestBankFunds.Int64() - testhelpers.BalanceChange10000 - testhelpers.GasFees) block1BankBalance = big.NewInt(testhelpers.TestBankFunds.Int64() - testhelpers.BalanceChange10000 - testhelpers.GasFees)
bankAccountAtBlock1, _ = rlp.EncodeToBytes(state.Account{ bankAccountAtBlock1, _ = rlp.EncodeToBytes(types.StateAccount{
Nonce: 1, Nonce: 1,
Balance: block1BankBalance, Balance: block1BankBalance,
CodeHash: testhelpers.NullCodeHash.Bytes(), CodeHash: testhelpers.NullCodeHash.Bytes(),
@ -247,7 +246,7 @@ var (
}) })
block2BankBalance = block1BankBalance.Int64() - testhelpers.BalanceChange1Ether - testhelpers.GasFees block2BankBalance = block1BankBalance.Int64() - testhelpers.BalanceChange1Ether - testhelpers.GasFees
bankAccountAtBlock2, _ = rlp.EncodeToBytes(state.Account{ bankAccountAtBlock2, _ = rlp.EncodeToBytes(types.StateAccount{
Nonce: 2, Nonce: 2,
Balance: big.NewInt(block2BankBalance), Balance: big.NewInt(block2BankBalance),
CodeHash: testhelpers.NullCodeHash.Bytes(), CodeHash: testhelpers.NullCodeHash.Bytes(),
@ -257,7 +256,7 @@ var (
common.Hex2Bytes("30bf49f440a1cd0527e4d06e2765654c0f56452257516d793a9b8d604dcfdf2a"), common.Hex2Bytes("30bf49f440a1cd0527e4d06e2765654c0f56452257516d793a9b8d604dcfdf2a"),
bankAccountAtBlock2, bankAccountAtBlock2,
}) })
bankAccountAtBlock3, _ = rlp.EncodeToBytes(state.Account{ bankAccountAtBlock3, _ = rlp.EncodeToBytes(types.StateAccount{
Nonce: 3, Nonce: 3,
Balance: big.NewInt(999914255999990000), Balance: big.NewInt(999914255999990000),
CodeHash: testhelpers.NullCodeHash.Bytes(), CodeHash: testhelpers.NullCodeHash.Bytes(),
@ -267,7 +266,7 @@ var (
common.Hex2Bytes("30bf49f440a1cd0527e4d06e2765654c0f56452257516d793a9b8d604dcfdf2a"), common.Hex2Bytes("30bf49f440a1cd0527e4d06e2765654c0f56452257516d793a9b8d604dcfdf2a"),
bankAccountAtBlock3, bankAccountAtBlock3,
}) })
bankAccountAtBlock4, _ = rlp.EncodeToBytes(state.Account{ bankAccountAtBlock4, _ = rlp.EncodeToBytes(types.StateAccount{
Nonce: 6, Nonce: 6,
Balance: big.NewInt(999826859999990000), Balance: big.NewInt(999826859999990000),
CodeHash: testhelpers.NullCodeHash.Bytes(), CodeHash: testhelpers.NullCodeHash.Bytes(),
@ -277,7 +276,7 @@ var (
common.Hex2Bytes("30bf49f440a1cd0527e4d06e2765654c0f56452257516d793a9b8d604dcfdf2a"), common.Hex2Bytes("30bf49f440a1cd0527e4d06e2765654c0f56452257516d793a9b8d604dcfdf2a"),
bankAccountAtBlock4, bankAccountAtBlock4,
}) })
bankAccountAtBlock5, _ = rlp.EncodeToBytes(state.Account{ bankAccountAtBlock5, _ = rlp.EncodeToBytes(types.StateAccount{
Nonce: 7, Nonce: 7,
Balance: big.NewInt(999805027999990000), Balance: big.NewInt(999805027999990000),
CodeHash: testhelpers.NullCodeHash.Bytes(), CodeHash: testhelpers.NullCodeHash.Bytes(),
@ -1727,7 +1726,7 @@ var (
slot00StorageValue, slot00StorageValue,
}) })
contractAccountAtBlock01, _ = rlp.EncodeToBytes(state.Account{ contractAccountAtBlock01, _ = rlp.EncodeToBytes(types.StateAccount{
Nonce: 1, Nonce: 1,
Balance: big.NewInt(0), Balance: big.NewInt(0),
CodeHash: common.HexToHash("0xaaea5efba4fd7b45d7ec03918ac5d8b31aa93b48986af0e6b591f0f087c80127").Bytes(), CodeHash: common.HexToHash("0xaaea5efba4fd7b45d7ec03918ac5d8b31aa93b48986af0e6b591f0f087c80127").Bytes(),
@ -1738,7 +1737,7 @@ var (
contractAccountAtBlock01, contractAccountAtBlock01,
}) })
bankAccountAtBlock01, _ = rlp.EncodeToBytes(state.Account{ bankAccountAtBlock01, _ = rlp.EncodeToBytes(types.StateAccount{
Nonce: 1, Nonce: 1,
Balance: big.NewInt(3999629697375000000), Balance: big.NewInt(3999629697375000000),
CodeHash: testhelpers.NullCodeHash.Bytes(), CodeHash: testhelpers.NullCodeHash.Bytes(),
@ -1748,7 +1747,7 @@ var (
common.Hex2Bytes("30bf49f440a1cd0527e4d06e2765654c0f56452257516d793a9b8d604dcfdf2a"), common.Hex2Bytes("30bf49f440a1cd0527e4d06e2765654c0f56452257516d793a9b8d604dcfdf2a"),
bankAccountAtBlock01, bankAccountAtBlock01,
}) })
bankAccountAtBlock02, _ = rlp.EncodeToBytes(state.Account{ bankAccountAtBlock02, _ = rlp.EncodeToBytes(types.StateAccount{
Nonce: 2, Nonce: 2,
Balance: big.NewInt(5999607323457344852), Balance: big.NewInt(5999607323457344852),
CodeHash: testhelpers.NullCodeHash.Bytes(), CodeHash: testhelpers.NullCodeHash.Bytes(),

View File

@ -23,8 +23,12 @@ import (
"math/big" "math/big"
"time" "time"
"github.com/ipfs/go-cid"
node "github.com/ipfs/go-ipld-format"
"github.com/jmoiron/sqlx"
"github.com/multiformats/go-multihash"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/log"
@ -36,10 +40,6 @@ import (
"github.com/ethereum/go-ethereum/statediff/indexer/postgres" "github.com/ethereum/go-ethereum/statediff/indexer/postgres"
"github.com/ethereum/go-ethereum/statediff/indexer/shared" "github.com/ethereum/go-ethereum/statediff/indexer/shared"
sdtypes "github.com/ethereum/go-ethereum/statediff/types" sdtypes "github.com/ethereum/go-ethereum/statediff/types"
"github.com/ipfs/go-cid"
node "github.com/ipfs/go-ipld-format"
"github.com/jmoiron/sqlx"
"github.com/multiformats/go-multihash"
) )
var ( var (
@ -487,7 +487,7 @@ func (sdi *StateDiffIndexer) PushStateNode(tx *BlockTx, stateNode sdtypes.StateN
if len(i) != 2 { if len(i) != 2 {
return fmt.Errorf("eth IPLDPublisher expected state leaf node rlp to decode into two elements") return fmt.Errorf("eth IPLDPublisher expected state leaf node rlp to decode into two elements")
} }
var account state.Account var account types.StateAccount
if err := rlp.DecodeBytes(i[1].([]byte), &account); err != nil { if err := rlp.DecodeBytes(i[1].([]byte), &account); err != nil {
return fmt.Errorf("error decoding state account rlp: %s", err.Error()) return fmt.Errorf("error decoding state account rlp: %s", err.Error())
} }

View File

@ -20,6 +20,9 @@ import (
"bytes" "bytes"
"errors" "errors"
"github.com/ipfs/go-cid"
mh "github.com/multiformats/go-multihash"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/core/rawdb"
"github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/ethdb"
@ -27,8 +30,6 @@ import (
sdtrie "github.com/ethereum/go-ethereum/statediff/trie" sdtrie "github.com/ethereum/go-ethereum/statediff/trie"
sdtypes "github.com/ethereum/go-ethereum/statediff/types" sdtypes "github.com/ethereum/go-ethereum/statediff/types"
"github.com/ethereum/go-ethereum/trie" "github.com/ethereum/go-ethereum/trie"
"github.com/ipfs/go-cid"
mh "github.com/multiformats/go-multihash"
) )
// IPLD Codecs for Ethereum // IPLD Codecs for Ethereum
@ -131,7 +132,7 @@ func (lt *localTrie) rootHash() []byte {
func (lt *localTrie) commit() error { func (lt *localTrie) commit() error {
// commit trie nodes to trieDB // commit trie nodes to trieDB
var err error var err error
_, err = lt.trie.Commit(nil) _, _, err = lt.trie.Commit(nil)
if err != nil { if err != nil {
return err return err
} }

View File

@ -27,7 +27,6 @@ import (
"github.com/ethereum/go-ethereum/trie" "github.com/ethereum/go-ethereum/trie"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/log"
@ -113,7 +112,7 @@ var (
ContractRoot = "0x821e2556a290c86405f8160a2d662042a431ba456b9db265c79bb837c04be5f0" ContractRoot = "0x821e2556a290c86405f8160a2d662042a431ba456b9db265c79bb837c04be5f0"
ContractCodeHash = common.HexToHash("0x753f98a8d4328b15636e46f66f2cb4bc860100aa17967cc145fcd17d1d4710ea") ContractCodeHash = common.HexToHash("0x753f98a8d4328b15636e46f66f2cb4bc860100aa17967cc145fcd17d1d4710ea")
ContractLeafKey = testhelpers.AddressToLeafKey(ContractAddress) ContractLeafKey = testhelpers.AddressToLeafKey(ContractAddress)
ContractAccount, _ = rlp.EncodeToBytes(state.Account{ ContractAccount, _ = rlp.EncodeToBytes(types.StateAccount{
Nonce: nonce1, Nonce: nonce1,
Balance: big.NewInt(0), Balance: big.NewInt(0),
CodeHash: ContractCodeHash.Bytes(), CodeHash: ContractCodeHash.Bytes(),
@ -130,7 +129,7 @@ var (
AccountCodeHash = common.HexToHash("0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470") AccountCodeHash = common.HexToHash("0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470")
AccountLeafKey = testhelpers.Account2LeafKey AccountLeafKey = testhelpers.Account2LeafKey
RemovedLeafKey = testhelpers.Account1LeafKey RemovedLeafKey = testhelpers.Account1LeafKey
Account, _ = rlp.EncodeToBytes(state.Account{ Account, _ = rlp.EncodeToBytes(types.StateAccount{
Nonce: nonce0, Nonce: nonce0,
Balance: big.NewInt(1000), Balance: big.NewInt(1000),
CodeHash: AccountCodeHash.Bytes(), CodeHash: AccountCodeHash.Bytes(),

View File

@ -30,7 +30,6 @@ import (
"github.com/ethereum/go-ethereum/consensus/ethash" "github.com/ethereum/go-ethereum/consensus/ethash"
"github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/core/rawdb"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/crypto"
@ -51,7 +50,7 @@ var (
emptyStorage = make([]sdtypes.StorageNode, 0) emptyStorage = make([]sdtypes.StorageNode, 0)
// block 1 data // block 1 data
block1CoinbaseAccount, _ = rlp.EncodeToBytes(state.Account{ block1CoinbaseAccount, _ = rlp.EncodeToBytes(types.StateAccount{
Nonce: 0, Nonce: 0,
Balance: big.NewInt(5000000000000000000), Balance: big.NewInt(5000000000000000000),
CodeHash: testhelpers.NullCodeHash.Bytes(), CodeHash: testhelpers.NullCodeHash.Bytes(),
@ -123,7 +122,7 @@ var (
}) })
// block 2 data // block 2 data
block2CoinbaseAccount, _ = rlp.EncodeToBytes(state.Account{ block2CoinbaseAccount, _ = rlp.EncodeToBytes(types.StateAccount{
Nonce: 0, Nonce: 0,
Balance: big.NewInt(5000000000000000000), Balance: big.NewInt(5000000000000000000),
CodeHash: testhelpers.NullCodeHash.Bytes(), CodeHash: testhelpers.NullCodeHash.Bytes(),
@ -135,7 +134,7 @@ var (
}) })
block2CoinbaseLeafNodeHash = crypto.Keccak256(block2CoinbaseLeafNode) block2CoinbaseLeafNodeHash = crypto.Keccak256(block2CoinbaseLeafNode)
block2MovedPremineBalance, _ = new(big.Int).SetString("4000000000000000000000", 10) block2MovedPremineBalance, _ = new(big.Int).SetString("4000000000000000000000", 10)
block2MovedPremineAccount, _ = rlp.EncodeToBytes(state.Account{ block2MovedPremineAccount, _ = rlp.EncodeToBytes(types.StateAccount{
Nonce: 0, Nonce: 0,
Balance: block2MovedPremineBalance, Balance: block2MovedPremineBalance,
CodeHash: testhelpers.NullCodeHash.Bytes(), CodeHash: testhelpers.NullCodeHash.Bytes(),
@ -229,7 +228,7 @@ var (
// block3 data // block3 data
// path 060e0f // path 060e0f
blcok3CoinbaseBalance, _ = new(big.Int).SetString("5156250000000000000", 10) blcok3CoinbaseBalance, _ = new(big.Int).SetString("5156250000000000000", 10)
block3CoinbaseAccount, _ = rlp.EncodeToBytes(state.Account{ block3CoinbaseAccount, _ = rlp.EncodeToBytes(types.StateAccount{
Nonce: 0, Nonce: 0,
Balance: blcok3CoinbaseBalance, Balance: blcok3CoinbaseBalance,
CodeHash: testhelpers.NullCodeHash.Bytes(), CodeHash: testhelpers.NullCodeHash.Bytes(),
@ -242,7 +241,7 @@ var (
block3CoinbaseLeafNodeHash = crypto.Keccak256(block3CoinbaseLeafNode) block3CoinbaseLeafNodeHash = crypto.Keccak256(block3CoinbaseLeafNode)
// path 0c0e050703 // path 0c0e050703
block3MovedPremineBalance1, _ = new(big.Int).SetString("3750000000000000000", 10) block3MovedPremineBalance1, _ = new(big.Int).SetString("3750000000000000000", 10)
block3MovedPremineAccount1, _ = rlp.EncodeToBytes(state.Account{ block3MovedPremineAccount1, _ = rlp.EncodeToBytes(types.StateAccount{
Nonce: 0, Nonce: 0,
Balance: block3MovedPremineBalance1, Balance: block3MovedPremineBalance1,
CodeHash: testhelpers.NullCodeHash.Bytes(), CodeHash: testhelpers.NullCodeHash.Bytes(),
@ -255,7 +254,7 @@ var (
block3MovedPremineLeafNodeHash1 = crypto.Keccak256(block3MovedPremineLeafNode1) block3MovedPremineLeafNodeHash1 = crypto.Keccak256(block3MovedPremineLeafNode1)
// path 0c0e050708 // path 0c0e050708
block3MovedPremineBalance2, _ = new(big.Int).SetString("1999944000000000000000", 10) block3MovedPremineBalance2, _ = new(big.Int).SetString("1999944000000000000000", 10)
block3MovedPremineAccount2, _ = rlp.EncodeToBytes(state.Account{ block3MovedPremineAccount2, _ = rlp.EncodeToBytes(types.StateAccount{
Nonce: 0, Nonce: 0,
Balance: block3MovedPremineBalance2, Balance: block3MovedPremineBalance2,
CodeHash: testhelpers.NullCodeHash.Bytes(), CodeHash: testhelpers.NullCodeHash.Bytes(),

View File

@ -605,7 +605,7 @@ func (sds *Service) StreamCodeAndCodeHash(blockNumber uint64, outChan chan<- Cod
return return
default: default:
} }
account := new(state.Account) account := new(types.StateAccount)
if err := rlp.DecodeBytes(leafIt.Value, account); err != nil { if err := rlp.DecodeBytes(leafIt.Value, account); err != nil {
log.Error("error decoding state account", "err", err) log.Error("error decoding state account", "err", err)
return return

View File

@ -26,7 +26,6 @@ import (
"testing" "testing"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/rlp" "github.com/ethereum/go-ethereum/rlp"
"github.com/ethereum/go-ethereum/rpc" "github.com/ethereum/go-ethereum/rpc"
@ -39,7 +38,7 @@ var (
emptyStorage = make([]sdtypes.StorageNode, 0) emptyStorage = make([]sdtypes.StorageNode, 0)
block0, block1 *types.Block block0, block1 *types.Block
minerLeafKey = testhelpers.AddressToLeafKey(common.HexToAddress("0x0")) minerLeafKey = testhelpers.AddressToLeafKey(common.HexToAddress("0x0"))
account1, _ = rlp.EncodeToBytes(state.Account{ account1, _ = rlp.EncodeToBytes(types.StateAccount{
Nonce: uint64(0), Nonce: uint64(0),
Balance: big.NewInt(10000), Balance: big.NewInt(10000),
CodeHash: common.HexToHash("0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470").Bytes(), CodeHash: common.HexToHash("0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470").Bytes(),
@ -49,7 +48,7 @@ var (
common.Hex2Bytes("3926db69aaced518e9b9f0f434a473e7174109c943548bb8f23be41ca76d9ad2"), common.Hex2Bytes("3926db69aaced518e9b9f0f434a473e7174109c943548bb8f23be41ca76d9ad2"),
account1, account1,
}) })
minerAccount, _ = rlp.EncodeToBytes(state.Account{ minerAccount, _ = rlp.EncodeToBytes(types.StateAccount{
Nonce: uint64(0), Nonce: uint64(0),
Balance: big.NewInt(2000002625000000000), Balance: big.NewInt(2000002625000000000),
CodeHash: common.HexToHash("0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470").Bytes(), CodeHash: common.HexToHash("0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470").Bytes(),
@ -59,7 +58,7 @@ var (
common.Hex2Bytes("3380c7b7ae81a58eb98d9c78de4a1fd7fd9535fc953ed2be602daaa41767312a"), common.Hex2Bytes("3380c7b7ae81a58eb98d9c78de4a1fd7fd9535fc953ed2be602daaa41767312a"),
minerAccount, minerAccount,
}) })
bankAccount, _ = rlp.EncodeToBytes(state.Account{ bankAccount, _ = rlp.EncodeToBytes(types.StateAccount{
Nonce: uint64(1), Nonce: uint64(1),
Balance: big.NewInt(1999978999999990000), Balance: big.NewInt(1999978999999990000),
CodeHash: common.HexToHash("0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470").Bytes(), CodeHash: common.HexToHash("0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470").Bytes(),

View File

@ -24,7 +24,7 @@ import (
"math/big" "math/big"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/state" ctypes "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/statediff/types" "github.com/ethereum/go-ethereum/statediff/types"
) )
@ -105,7 +105,7 @@ type AccountMap map[string]accountWrapper
// accountWrapper is used to temporary associate the unpacked node with its raw values // accountWrapper is used to temporary associate the unpacked node with its raw values
type accountWrapper struct { type accountWrapper struct {
Account *state.Account Account *ctypes.StateAccount
NodeType types.NodeType NodeType types.NodeType
Path []byte Path []byte
NodeValue []byte NodeValue []byte