Update publisher to account for only storing current account values
This commit is contained in:
parent
96caa16268
commit
7604eb8f9a
@ -13,11 +13,8 @@ import (
|
||||
var (
|
||||
Headers = []string{
|
||||
"blockNumber", "blockHash", "accountAction",
|
||||
"code", "codeHash",
|
||||
"oldNonceValue", "newNonceValue",
|
||||
"oldBalanceValue", "newBalanceValue",
|
||||
"oldContractRoot", "newContractRoot",
|
||||
"storageDiffPaths",
|
||||
"code", "codeHash", "nonceValue",
|
||||
"balanceValue", "contractRoot", "storageDiffPaths",
|
||||
}
|
||||
|
||||
timeStampFormat = "20060102150405.00000"
|
||||
@ -103,8 +100,7 @@ func accumulateCreatedAccountRows(sd builder.StateDiff) [][]string {
|
||||
}
|
||||
|
||||
func formatAccountDiffEventual(accountDiff builder.AccountDiffEventual, sd builder.StateDiff, accountAction string) []string {
|
||||
oldContractRoot := accountDiff.ContractRoot.OldValue
|
||||
newContractRoot := accountDiff.ContractRoot.NewValue
|
||||
newContractRoot := accountDiff.ContractRoot.Value
|
||||
var storageDiffPaths []string
|
||||
for k := range accountDiff.Storage {
|
||||
storageDiffPaths = append(storageDiffPaths, k)
|
||||
@ -115,11 +111,8 @@ func formatAccountDiffEventual(accountDiff builder.AccountDiffEventual, sd build
|
||||
accountAction,
|
||||
string(accountDiff.Code),
|
||||
accountDiff.CodeHash,
|
||||
strconv.FormatUint(*accountDiff.Nonce.OldValue, 10),
|
||||
strconv.FormatUint(*accountDiff.Nonce.NewValue, 10),
|
||||
accountDiff.Balance.OldValue.String(),
|
||||
accountDiff.Balance.NewValue.String(),
|
||||
*oldContractRoot,
|
||||
strconv.FormatUint(*accountDiff.Nonce.Value, 10),
|
||||
accountDiff.Balance.Value.String(),
|
||||
*newContractRoot,
|
||||
strings.Join(storageDiffPaths, ","),
|
||||
}
|
||||
@ -127,8 +120,7 @@ func formatAccountDiffEventual(accountDiff builder.AccountDiffEventual, sd build
|
||||
}
|
||||
|
||||
func formatAccountDiffIncremental(accountDiff builder.AccountDiffIncremental, sd builder.StateDiff, accountAction string) []string {
|
||||
oldContractRoot := accountDiff.ContractRoot.OldValue
|
||||
newContractRoot := accountDiff.ContractRoot.NewValue
|
||||
newContractRoot := accountDiff.ContractRoot.Value
|
||||
var storageDiffPaths []string
|
||||
for k := range accountDiff.Storage {
|
||||
storageDiffPaths = append(storageDiffPaths, k)
|
||||
@ -139,11 +131,8 @@ func formatAccountDiffIncremental(accountDiff builder.AccountDiffIncremental, sd
|
||||
accountAction,
|
||||
"",
|
||||
accountDiff.CodeHash,
|
||||
strconv.FormatUint(*accountDiff.Nonce.OldValue, 10),
|
||||
strconv.FormatUint(*accountDiff.Nonce.NewValue, 10),
|
||||
accountDiff.Balance.OldValue.String(),
|
||||
accountDiff.Balance.NewValue.String(),
|
||||
*oldContractRoot,
|
||||
strconv.FormatUint(*accountDiff.Nonce.Value, 10),
|
||||
accountDiff.Balance.Value.String(),
|
||||
*newContractRoot,
|
||||
strings.Join(storageDiffPaths, ","),
|
||||
}
|
||||
|
@ -30,12 +30,9 @@ var expectedCreatedAccountRow = []string{
|
||||
"created",
|
||||
"created account code",
|
||||
testhelpers.CodeHash,
|
||||
strconv.FormatUint(testhelpers.OldNonceValue, 10),
|
||||
strconv.FormatUint(testhelpers.NewNonceValue, 10),
|
||||
strconv.FormatInt(testhelpers.OldBalanceValue, 10),
|
||||
strconv.FormatInt(testhelpers.NewBalanceValue, 10),
|
||||
testhelpers.ContractRoot,
|
||||
testhelpers.ContractRoot,
|
||||
testhelpers.StoragePath,
|
||||
}
|
||||
|
||||
@ -45,12 +42,9 @@ var expectedUpdatedAccountRow = []string{
|
||||
"updated",
|
||||
"",
|
||||
testhelpers.CodeHash,
|
||||
strconv.FormatUint(testhelpers.OldNonceValue, 10),
|
||||
strconv.FormatUint(testhelpers.NewNonceValue, 10),
|
||||
strconv.FormatInt(testhelpers.OldBalanceValue, 10),
|
||||
strconv.FormatInt(testhelpers.NewBalanceValue, 10),
|
||||
testhelpers.ContractRoot,
|
||||
testhelpers.ContractRoot,
|
||||
testhelpers.StoragePath,
|
||||
}
|
||||
|
||||
@ -60,17 +54,12 @@ var expectedDeletedAccountRow = []string{
|
||||
"deleted",
|
||||
"deleted account code",
|
||||
testhelpers.CodeHash,
|
||||
strconv.FormatUint(testhelpers.OldNonceValue, 10),
|
||||
strconv.FormatUint(testhelpers.NewNonceValue, 10),
|
||||
strconv.FormatInt(testhelpers.OldBalanceValue, 10),
|
||||
strconv.FormatInt(testhelpers.NewBalanceValue, 10),
|
||||
testhelpers.ContractRoot,
|
||||
testhelpers.ContractRoot,
|
||||
testhelpers.StoragePath,
|
||||
}
|
||||
|
||||
|
||||
|
||||
func TestPublisher(t *testing.T) {
|
||||
dir, err = ioutil.TempDir(tempDir, testFilePrefix)
|
||||
if err != nil {
|
||||
|
@ -19,59 +19,29 @@ var (
|
||||
StoragePath = "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470"
|
||||
oldStorage = "0x0"
|
||||
newStorage = "0x03"
|
||||
storage = map[string]builder.DiffString{StoragePath: {
|
||||
NewValue: &newStorage,
|
||||
OldValue: &oldStorage,
|
||||
}}
|
||||
storage = map[string]builder.DiffString{StoragePath: { Value: &newStorage }}
|
||||
address = common.HexToAddress("0xaE9BEa628c4Ce503DcFD7E305CaB4e29E7476592")
|
||||
CreatedAccountDiffs = map[common.Address]builder.AccountDiffEventual{address: {
|
||||
Nonce: builder.DiffUint64{
|
||||
NewValue: &NewNonceValue,
|
||||
OldValue: &OldNonceValue,
|
||||
},
|
||||
Balance: builder.DiffBigInt{
|
||||
NewValue: big.NewInt(NewBalanceValue),
|
||||
OldValue: big.NewInt(OldBalanceValue),
|
||||
},
|
||||
ContractRoot: builder.DiffString{
|
||||
NewValue: &ContractRoot,
|
||||
OldValue: &ContractRoot,
|
||||
},
|
||||
Nonce: builder.DiffUint64{ Value: &NewNonceValue },
|
||||
Balance: builder.DiffBigInt{ Value: big.NewInt(NewBalanceValue) },
|
||||
ContractRoot: builder.DiffString{ Value: &ContractRoot },
|
||||
Code: []byte("created account code"),
|
||||
CodeHash: CodeHash,
|
||||
Storage: storage,
|
||||
}}
|
||||
|
||||
UpdatedAccountDiffs = map[common.Address]builder.AccountDiffIncremental{address: {
|
||||
Nonce: builder.DiffUint64{
|
||||
NewValue: &NewNonceValue,
|
||||
OldValue: &OldNonceValue,
|
||||
},
|
||||
Balance: builder.DiffBigInt{
|
||||
NewValue: big.NewInt(NewBalanceValue),
|
||||
OldValue: big.NewInt(OldBalanceValue),
|
||||
},
|
||||
Nonce: builder.DiffUint64{ Value: &NewNonceValue },
|
||||
Balance: builder.DiffBigInt{ Value: big.NewInt(NewBalanceValue) },
|
||||
CodeHash: CodeHash,
|
||||
ContractRoot: builder.DiffString{
|
||||
NewValue: &ContractRoot,
|
||||
OldValue: &ContractRoot,
|
||||
},
|
||||
ContractRoot: builder.DiffString{ Value: &ContractRoot },
|
||||
Storage: storage,
|
||||
}}
|
||||
|
||||
DeletedAccountDiffs = map[common.Address]builder.AccountDiffEventual{address: {
|
||||
Nonce: builder.DiffUint64{
|
||||
NewValue: &NewNonceValue,
|
||||
OldValue: &OldNonceValue,
|
||||
},
|
||||
Balance: builder.DiffBigInt{
|
||||
NewValue: big.NewInt(NewBalanceValue),
|
||||
OldValue: big.NewInt(OldBalanceValue),
|
||||
},
|
||||
ContractRoot: builder.DiffString{
|
||||
NewValue: &ContractRoot,
|
||||
OldValue: &ContractRoot,
|
||||
},
|
||||
Nonce: builder.DiffUint64{ Value: &NewNonceValue },
|
||||
Balance: builder.DiffBigInt{ Value: big.NewInt(NewBalanceValue) },
|
||||
ContractRoot: builder.DiffString{ Value: &ContractRoot },
|
||||
Code: []byte("deleted account code"),
|
||||
CodeHash: CodeHash,
|
||||
Storage: storage,
|
||||
|
Loading…
Reference in New Issue
Block a user