Add storage key to csv
This commit is contained in:
parent
0f2880a019
commit
29f5c3ce86
@ -248,8 +248,10 @@ func (sdb *builder) buildStorageDiffsIncremental(oldSR common.Hash, newSR common
|
||||
if it.Leaf() {
|
||||
log.Debug("Found leaf in storage", "path", pathToStr(it))
|
||||
path := pathToStr(it)
|
||||
storageKey:= hexutil.Encode(it.LeafKey())
|
||||
storageValue := hexutil.Encode(it.LeafBlob())
|
||||
storageDiffs[path] = DiffStorage{
|
||||
Key: &storageKey,
|
||||
Value: &storageValue,
|
||||
}
|
||||
}
|
||||
|
@ -73,6 +73,8 @@ func TestBuilder(t *testing.T) {
|
||||
nonce3 = uint64(3)
|
||||
originalContractRoot = "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421"
|
||||
newContractRoot = "0x9e676b23802aff85d29b4f0243939bc6ecfdca2a41532310091781854d6ffeb2"
|
||||
storageLocation = common.HexToHash("2")
|
||||
newStorageKey = crypto.Keccak256Hash(storageLocation[:]).String()
|
||||
newStorageValue = "0x03"
|
||||
)
|
||||
|
||||
@ -222,6 +224,7 @@ func TestBuilder(t *testing.T) {
|
||||
ContractRoot: b.DiffString{Value: &newContractRoot},
|
||||
Storage: map[string]b.DiffStorage{
|
||||
"0x405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace": {
|
||||
Key: &newStorageKey,
|
||||
Value: &newStorageValue},
|
||||
},
|
||||
},
|
||||
|
@ -64,6 +64,7 @@ type AccountDiff struct {
|
||||
}
|
||||
|
||||
type DiffStorage struct {
|
||||
Key *string `json:"key" gencodec:"optional"`
|
||||
Value *string `json:"value" gencodec:"optional"`
|
||||
}
|
||||
type DiffString struct {
|
||||
|
@ -14,7 +14,7 @@ var (
|
||||
Headers = []string{
|
||||
"blockNumber", "blockHash", "accountAction", "codeHash",
|
||||
"nonceValue", "balanceValue", "contractRoot", "storageDiffPaths",
|
||||
"accountAddress", "storageValue",
|
||||
"accountAddress", "storageKey", "storageValue",
|
||||
}
|
||||
|
||||
timeStampFormat = "20060102150405.00000"
|
||||
@ -88,7 +88,8 @@ func formatAccountData(accountAddr common.Address, accountDiff builder.AccountDi
|
||||
newContractRoot := accountDiff.ContractRoot.Value
|
||||
address := accountAddr.String()
|
||||
var result [][]string
|
||||
for storagePath, storageValue := range accountDiff.Storage {
|
||||
|
||||
for storagePath, storage := range accountDiff.Storage {
|
||||
formattedAccountData := []string{
|
||||
blockNumberString,
|
||||
blockHash,
|
||||
@ -99,7 +100,8 @@ func formatAccountData(accountAddr common.Address, accountDiff builder.AccountDi
|
||||
*newContractRoot,
|
||||
storagePath,
|
||||
address,
|
||||
*storageValue.Value,
|
||||
*storage.Key,
|
||||
*storage.Value,
|
||||
}
|
||||
|
||||
result = append(result, formattedAccountData)
|
||||
|
@ -35,6 +35,7 @@ var expectedCreatedAccountRow = []string{
|
||||
testhelpers.ContractRoot,
|
||||
testhelpers.StoragePath,
|
||||
testhelpers.ContractAddress,
|
||||
"0000000000000000000000000000000000000000000000000000000000000001",
|
||||
testhelpers.StorageValue,
|
||||
}
|
||||
|
||||
@ -48,6 +49,7 @@ var expectedUpdatedAccountRow = []string{
|
||||
testhelpers.ContractRoot,
|
||||
testhelpers.StoragePath,
|
||||
testhelpers.ContractAddress,
|
||||
"0000000000000000000000000000000000000000000000000000000000000001",
|
||||
testhelpers.StorageValue,
|
||||
}
|
||||
|
||||
@ -61,6 +63,7 @@ var expectedDeletedAccountRow = []string{
|
||||
testhelpers.ContractRoot,
|
||||
testhelpers.StoragePath,
|
||||
testhelpers.ContractAddress,
|
||||
"0000000000000000000000000000000000000000000000000000000000000001",
|
||||
testhelpers.StorageValue,
|
||||
}
|
||||
|
||||
|
@ -15,8 +15,12 @@ var (
|
||||
NewBalanceValue = rand.Int63()
|
||||
ContractRoot = "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421"
|
||||
StoragePath = "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470"
|
||||
StorageKey = "0000000000000000000000000000000000000000000000000000000000000001"
|
||||
StorageValue = "0x03"
|
||||
storage = map[string]builder.DiffStorage{StoragePath: {Value: &StorageValue}}
|
||||
storage = map[string]builder.DiffStorage{StoragePath: {
|
||||
Key: &StorageKey,
|
||||
Value: &StorageValue,
|
||||
}}
|
||||
address = common.HexToAddress("0xaE9BEa628c4Ce503DcFD7E305CaB4e29E7476592")
|
||||
ContractAddress = address.String()
|
||||
CreatedAccountDiffs = map[common.Address]builder.AccountDiff{address: {
|
||||
|
Loading…
Reference in New Issue
Block a user