diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index d4ef50e0e..4198cf6bb 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -56,10 +56,10 @@ import ( "github.com/ethereum/go-ethereum/p2p/nat" "github.com/ethereum/go-ethereum/p2p/netutil" "github.com/ethereum/go-ethereum/params" + "github.com/ethereum/go-ethereum/statediff" + "github.com/ethereum/go-ethereum/statediff/service" whisper "github.com/ethereum/go-ethereum/whisper/whisperv6" "gopkg.in/urfave/cli.v1" - "github.com/ethereum/go-ethereum/statediff/service" - "github.com/ethereum/go-ethereum/statediff" ) var ( @@ -638,18 +638,18 @@ var ( } StateDiffFlag = cli.BoolFlag{ - Name: "statediff", + Name: "statediff", Usage: "Enables the calculation of state diffs between each block, persists these state diffs the configured persistence mode.", } StateDiffModeFlag = cli.StringFlag{ - Name: "statediff.mode", + Name: "statediff.mode", Usage: "Enables the user to determine which persistence mode they'd like to store the state diffs in.", Value: "csv", } StateDiffPathFlag = cli.StringFlag{ - Name: "statediff.path", + Name: "statediff.path", Usage: "Enables the user to determine where to persist the state diffs.", Value: ".", } diff --git a/statediff/builder/builder.go b/statediff/builder/builder.go index 825869150..1d66db380 100644 --- a/statediff/builder/builder.go +++ b/statediff/builder/builder.go @@ -113,7 +113,7 @@ func (sdb *builder) collectDiffNodes(a, b trie.NodeIterator) (map[common.Address it, _ := trie.NewDifferenceIterator(a, b) for { - log.Debug("Current Path and Hash", "path", pathToStr(it), "hashold", common.Hash(it.Hash())) + log.Debug("Current Path and Hash", "path", pathToStr(it), "hashold", it.Hash()) if it.Leaf() { // lookup address @@ -242,7 +242,7 @@ func buildStorageDiffsFromTrie(it trie.NodeIterator) map[string]DiffStorage { if it.Leaf() { log.Debug("Found leaf in storage", "path", pathToStr(it)) path := pathToStr(it) - storageKey:= hexutil.Encode(it.LeafKey()) + storageKey := hexutil.Encode(it.LeafKey()) storageValue := hexutil.Encode(it.LeafBlob()) storageDiffs[path] = DiffStorage{ Key: &storageKey, diff --git a/statediff/builder/builder_test.go b/statediff/builder/builder_test.go index 72ebfff18..6354a13e2 100644 --- a/statediff/builder/builder_test.go +++ b/statediff/builder/builder_test.go @@ -23,14 +23,14 @@ var ( testBankFunds = big.NewInt(100000000) genesis = core.GenesisBlockForTesting(testdb, testBankAddress, testBankFunds) - account1Key, _ = crypto.HexToECDSA("8a1f9a8f95be41cd7ccb6168179afb4504aefe388d1e14474d32c45c72ce7b7a") - account2Key, _ = crypto.HexToECDSA("49a7b37aa6f6645917e7b807e9d1c00d4fa71f18343b0d4122a4d2df64dd6fee") - account1Addr = crypto.PubkeyToAddress(account1Key.PublicKey) //0x703c4b2bD70c169f5717101CaeE543299Fc946C7 - account2Addr = crypto.PubkeyToAddress(account2Key.PublicKey) //0x0D3ab14BBaD3D99F4203bd7a11aCB94882050E7e - contractCode = common.Hex2Bytes("608060405234801561001057600080fd5b50602060405190810160405280600160ff16815250600090600161003592919061003b565b506100a5565b826064810192821561006f579160200282015b8281111561006e578251829060ff1690559160200191906001019061004e565b5b50905061007c9190610080565b5090565b6100a291905b8082111561009e576000816000905550600101610086565b5090565b90565b610124806100b46000396000f3fe6080604052348015600f57600080fd5b5060043610604f576000357c01000000000000000000000000000000000000000000000000000000009004806360cd2685146054578063c16431b9146093575b600080fd5b607d60048036036020811015606857600080fd5b810190808035906020019092919050505060c8565b6040518082815260200191505060405180910390f35b60c66004803603604081101560a757600080fd5b81019080803590602001909291908035906020019092919050505060e0565b005b6000808260648110151560d757fe5b01549050919050565b8060008360648110151560ef57fe5b0181905550505056fea165627a7a7230582064e918c3140a117bf3aa65865a9b9e83fae21ad1720506e7933b2a9f54bb40260029") - contractAddr common.Address - emptyAccountDiffEventualMap = make(map[common.Address]b.AccountDiff) - emptyAccountDiffIncrementalMap = make(map[common.Address]b.AccountDiff) + account1Key, _ = crypto.HexToECDSA("8a1f9a8f95be41cd7ccb6168179afb4504aefe388d1e14474d32c45c72ce7b7a") + account2Key, _ = crypto.HexToECDSA("49a7b37aa6f6645917e7b807e9d1c00d4fa71f18343b0d4122a4d2df64dd6fee") + account1Addr = crypto.PubkeyToAddress(account1Key.PublicKey) //0x703c4b2bD70c169f5717101CaeE543299Fc946C7 + account2Addr = crypto.PubkeyToAddress(account2Key.PublicKey) //0x0D3ab14BBaD3D99F4203bd7a11aCB94882050E7e + contractCode = common.Hex2Bytes("608060405234801561001057600080fd5b50602060405190810160405280600160ff16815250600090600161003592919061003b565b506100a5565b826064810192821561006f579160200282015b8281111561006e578251829060ff1690559160200191906001019061004e565b5b50905061007c9190610080565b5090565b6100a291905b8082111561009e576000816000905550600101610086565b5090565b90565b610124806100b46000396000f3fe6080604052348015600f57600080fd5b5060043610604f576000357c01000000000000000000000000000000000000000000000000000000009004806360cd2685146054578063c16431b9146093575b600080fd5b607d60048036036020811015606857600080fd5b810190808035906020019092919050505060c8565b6040518082815260200191505060405180910390f35b60c66004803603604081101560a757600080fd5b81019080803590602001909291908035906020019092919050505060e0565b005b6000808260648110151560d757fe5b01549050919050565b8060008360648110151560ef57fe5b0181905550505056fea165627a7a7230582064e918c3140a117bf3aa65865a9b9e83fae21ad1720506e7933b2a9f54bb40260029") + contractAddr common.Address + emptyAccountDiffEventualMap = make(map[common.Address]b.AccountDiff) + emptyAccountDiffIncrementalMap = make(map[common.Address]b.AccountDiff) block0Hash, block1Hash, block2Hash, block3Hash common.Hash block0, block1, block2, block3 *types.Block builder b.Builder @@ -73,10 +73,10 @@ func TestBuilder(t *testing.T) { newContractRoot = "0x71e0d14b2b93e5c7f9748e69e1fe5f17498a1c3ac3cec29f96af13d7f8a4e070" originalStorageLocation = common.HexToHash("0") originalStorageKey = crypto.Keccak256Hash(originalStorageLocation[:]).String() - updatedStorageLocation = common.HexToHash("2") - updatedStorageKey = crypto.Keccak256Hash(updatedStorageLocation[:]).String() - originalStorageValue = "0x01" - updatedStorageValue = "0x03" + updatedStorageLocation = common.HexToHash("2") + updatedStorageKey = crypto.Keccak256Hash(updatedStorageLocation[:]).String() + originalStorageValue = "0x01" + updatedStorageValue = "0x03" ) var tests = []struct { diff --git a/statediff/builder/struct.go b/statediff/builder/struct.go index e3ad599f1..295b09f10 100644 --- a/statediff/builder/struct.go +++ b/statediff/builder/struct.go @@ -64,7 +64,7 @@ type AccountDiff struct { } type DiffStorage struct { - Key *string `json:"key" gencodec:"optional"` + Key *string `json:"key" gencodec:"optional"` Value *string `json:"value" gencodec:"optional"` } type DiffString struct { diff --git a/statediff/publisher/csv.go b/statediff/publisher/csv.go index 82eb3e466..8be88ed7f 100644 --- a/statediff/publisher/csv.go +++ b/statediff/publisher/csv.go @@ -2,12 +2,12 @@ package publisher import ( "encoding/csv" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/statediff/builder" "os" "path/filepath" "strconv" "time" - "github.com/ethereum/go-ethereum/common" ) var ( diff --git a/statediff/testhelpers/test_data.go b/statediff/testhelpers/test_data.go index e7d94b373..34194d2f4 100644 --- a/statediff/testhelpers/test_data.go +++ b/statediff/testhelpers/test_data.go @@ -21,12 +21,12 @@ var ( Key: &StorageKey, Value: &StorageValue, }} - emptyStorage = map[string]builder.DiffStorage{} + emptyStorage = map[string]builder.DiffStorage{} address = common.HexToAddress("0xaE9BEa628c4Ce503DcFD7E305CaB4e29E7476592") anotherAddress = common.HexToAddress("0xaE9BEa628c4Ce503DcFD7E305CaB4e29E7476593") ContractAddress = address.String() AnotherContractAddress = anotherAddress.String() - CreatedAccountDiffs = map[common.Address]builder.AccountDiff{ + CreatedAccountDiffs = map[common.Address]builder.AccountDiff{ address: { Nonce: builder.DiffUint64{Value: &NewNonceValue}, Balance: builder.DiffBigInt{Value: big.NewInt(NewBalanceValue)},