Remove old values from created/deleted accounts
This commit is contained in:
parent
8152f5562f
commit
96caa16268
@ -162,7 +162,7 @@ func (sdb *builder) buildDiffEventual(accounts map[common.Address]*state.Account
|
||||
if created {
|
||||
nonce := DiffUint64{ Value: &val.Nonce }
|
||||
balance := DiffBigInt{ Value: val.Balance }
|
||||
contractRoot := DiffString{ NewValue: &hexRoot }
|
||||
contractRoot := DiffString{ Value: &hexRoot }
|
||||
accountDiffs[addr] = AccountDiffEventual{
|
||||
Nonce: nonce,
|
||||
Balance: balance,
|
||||
@ -174,7 +174,7 @@ func (sdb *builder) buildDiffEventual(accounts map[common.Address]*state.Account
|
||||
} else {
|
||||
nonce := DiffUint64{ Value: &val.Nonce }
|
||||
balance := DiffBigInt{ Value: val.Balance }
|
||||
contractRoot := DiffString{ OldValue: &hexRoot }
|
||||
contractRoot := DiffString{ Value: &hexRoot }
|
||||
accountDiffs[addr] = AccountDiffEventual{
|
||||
Nonce: nonce,
|
||||
Balance: balance,
|
||||
@ -204,7 +204,7 @@ func (sdb *builder) buildDiffIncremental(creations map[common.Address]*state.Acc
|
||||
codeHash := hexutil.Encode(createdAcc.CodeHash)
|
||||
|
||||
nHexRoot := createdAcc.Root.Hex()
|
||||
contractRoot := DiffString{ NewValue: &nHexRoot }
|
||||
contractRoot := DiffString{ Value: &nHexRoot }
|
||||
|
||||
updatedAccounts[common.HexToAddress(val)] = AccountDiffIncremental{
|
||||
Nonce: nonce,
|
||||
@ -234,11 +234,7 @@ func (sdb *builder) buildStorageDiffsEventual(sr common.Hash, creation bool) (ma
|
||||
log.Debug("Found leaf in storage", "path", pathToStr(it))
|
||||
path := pathToStr(it)
|
||||
value := hexutil.Encode(it.LeafBlob())
|
||||
if creation {
|
||||
storageDiffs[path] = DiffString{NewValue: &value}
|
||||
} else {
|
||||
storageDiffs[path] = DiffString{OldValue: &value}
|
||||
}
|
||||
storageDiffs[path] = DiffString{Value: &value}
|
||||
}
|
||||
cont := it.Next(true)
|
||||
if !cont {
|
||||
@ -268,7 +264,7 @@ func (sdb *builder) buildStorageDiffsIncremental(oldSR common.Hash, newSR common
|
||||
log.Debug("Found leaf in storage", "path", pathToStr(it))
|
||||
path := pathToStr(it)
|
||||
value := hexutil.Encode(it.LeafBlob())
|
||||
storageDiffs[path] = DiffString{NewValue: &value}
|
||||
storageDiffs[path] = DiffString{Value: &value}
|
||||
}
|
||||
|
||||
cont := it.Next(true)
|
||||
|
@ -116,7 +116,7 @@ func TestBuilder(t *testing.T) {
|
||||
Balance: b.DiffBigInt{ Value: big.NewInt(balanceChange10000) },
|
||||
Code: nil,
|
||||
CodeHash: "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470",
|
||||
ContractRoot: b.DiffString{ NewValue: &originalContractRoot, OldValue: nil },
|
||||
ContractRoot: b.DiffString{ Value: &originalContractRoot },
|
||||
Storage: map[string]b.DiffString{},
|
||||
},
|
||||
burnAddress: {
|
||||
@ -124,7 +124,7 @@ func TestBuilder(t *testing.T) {
|
||||
Balance: b.DiffBigInt{ Value: big.NewInt(miningReward)},
|
||||
Code: nil,
|
||||
CodeHash: "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470",
|
||||
ContractRoot: b.DiffString{ NewValue: &originalContractRoot, OldValue: nil },
|
||||
ContractRoot: b.DiffString{ Value: &originalContractRoot },
|
||||
Storage: map[string]b.DiffString{},
|
||||
},
|
||||
},
|
||||
@ -134,7 +134,7 @@ func TestBuilder(t *testing.T) {
|
||||
Nonce: b.DiffUint64{ Value: &nonce1 },
|
||||
Balance: b.DiffBigInt{ Value: big.NewInt(testBankFunds.Int64() - balanceChange10000) },
|
||||
CodeHash: "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470",
|
||||
ContractRoot: b.DiffString{ NewValue: &originalContractRoot },
|
||||
ContractRoot: b.DiffString{ Value: &originalContractRoot },
|
||||
Storage: map[string]b.DiffString{},
|
||||
},
|
||||
},
|
||||
@ -159,7 +159,7 @@ func TestBuilder(t *testing.T) {
|
||||
Balance: b.DiffBigInt{ Value: big.NewInt(balanceChange1000) },
|
||||
Code: nil,
|
||||
CodeHash: "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470",
|
||||
ContractRoot: b.DiffString{ NewValue: &originalContractRoot},
|
||||
ContractRoot: b.DiffString{ Value: &originalContractRoot},
|
||||
Storage: map[string]b.DiffString{},
|
||||
},
|
||||
contractAddr: {
|
||||
@ -167,7 +167,7 @@ func TestBuilder(t *testing.T) {
|
||||
Balance: b.DiffBigInt{ Value: big.NewInt(0) },
|
||||
Code: []byte{96, 96, 96, 64, 82, 96, 0, 53, 124, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 144, 4, 128, 99, 96, 205, 38, 133, 20, 96, 65, 87, 128, 99, 193, 100, 49, 185, 20, 96, 107, 87, 96, 63, 86, 91, 0, 91, 96, 85, 96, 4, 128, 128, 53, 144, 96, 32, 1, 144, 145, 144, 80, 80, 96, 169, 86, 91, 96, 64, 81, 128, 130, 129, 82, 96, 32, 1, 145, 80, 80, 96, 64, 81, 128, 145, 3, 144, 243, 91, 96, 136, 96, 4, 128, 128, 53, 144, 96, 32, 1, 144, 145, 144, 128, 53, 144, 96, 32, 1, 144, 145, 144, 80, 80, 96, 138, 86, 91, 0, 91, 128, 96, 0, 96, 0, 80, 131, 96, 100, 129, 16, 21, 96, 2, 87, 144, 144, 1, 96, 0, 91, 80, 129, 144, 85, 80, 91, 80, 80, 86, 91, 96, 0, 96, 0, 96, 0, 80, 130, 96, 100, 129, 16, 21, 96, 2, 87, 144, 144, 1, 96, 0, 91, 80, 84, 144, 80, 96, 199, 86, 91, 145, 144, 80, 86},
|
||||
CodeHash: "0x1c671ee4ae8abbacab7da59d6f8785cce8295eb086551ce7ac266a2e93666c0f",
|
||||
ContractRoot: b.DiffString{ NewValue: &originalContractRoot},
|
||||
ContractRoot: b.DiffString{ Value: &originalContractRoot},
|
||||
Storage: map[string]b.DiffString{},
|
||||
},
|
||||
},
|
||||
@ -177,21 +177,21 @@ func TestBuilder(t *testing.T) {
|
||||
Nonce: b.DiffUint64{ Value: &nonce2 },
|
||||
Balance: b.DiffBigInt{ Value: big.NewInt(block1BankBalance - balanceChange1000) },
|
||||
CodeHash: "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470",
|
||||
ContractRoot: b.DiffString{ NewValue: &originalContractRoot },
|
||||
ContractRoot: b.DiffString{ Value: &originalContractRoot },
|
||||
Storage: map[string]b.DiffString{},
|
||||
},
|
||||
account1Addr: {
|
||||
Nonce: b.DiffUint64{ Value: &nonce2 },
|
||||
Balance: b.DiffBigInt{ Value: big.NewInt(block1Account1Balance - balanceChange1000 + balanceChange1000) },
|
||||
CodeHash: "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470",
|
||||
ContractRoot: b.DiffString{ NewValue: &originalContractRoot },
|
||||
ContractRoot: b.DiffString{ Value: &originalContractRoot },
|
||||
Storage: map[string]b.DiffString{},
|
||||
},
|
||||
burnAddress: {
|
||||
Nonce: b.DiffUint64{ Value: &nonce0 },
|
||||
Balance: b.DiffBigInt{ Value: big.NewInt(miningReward + miningReward) },
|
||||
CodeHash: "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470",
|
||||
ContractRoot: b.DiffString{ NewValue: &originalContractRoot },
|
||||
ContractRoot: b.DiffString{ Value: &originalContractRoot },
|
||||
Storage: map[string]b.DiffString{},
|
||||
},
|
||||
},
|
||||
@ -217,24 +217,24 @@ func TestBuilder(t *testing.T) {
|
||||
Nonce: b.DiffUint64{ Value: &nonce0 },
|
||||
Balance: b.DiffBigInt{ Value: big.NewInt(block2Account2Balance + miningReward) },
|
||||
CodeHash: "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470",
|
||||
ContractRoot: b.DiffString{ NewValue: &originalContractRoot },
|
||||
ContractRoot: b.DiffString{ Value: &originalContractRoot },
|
||||
Storage: map[string]b.DiffString{},
|
||||
},
|
||||
contractAddr: {
|
||||
Nonce: b.DiffUint64{ Value: &nonce1 },
|
||||
Balance: b.DiffBigInt{ Value: big.NewInt(0) },
|
||||
CodeHash: "0x1c671ee4ae8abbacab7da59d6f8785cce8295eb086551ce7ac266a2e93666c0f",
|
||||
ContractRoot: b.DiffString{ NewValue: &newContractRoot },
|
||||
ContractRoot: b.DiffString{ Value: &newContractRoot },
|
||||
Storage: map[string]b.DiffString{
|
||||
"0x405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace": {
|
||||
NewValue: &newStorageValue },
|
||||
Value: &newStorageValue },
|
||||
},
|
||||
},
|
||||
testBankAddress: {
|
||||
Nonce: b.DiffUint64{ Value: &nonce3 },
|
||||
Balance: b.DiffBigInt{ Value: big.NewInt(99989000) },
|
||||
CodeHash: "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470",
|
||||
ContractRoot: b.DiffString{ NewValue: &originalContractRoot },
|
||||
ContractRoot: b.DiffString{ Value: &originalContractRoot },
|
||||
Storage: map[string]b.DiffString{},
|
||||
},
|
||||
},
|
||||
|
@ -72,9 +72,6 @@ type AccountDiffIncremental struct {
|
||||
Storage map[string]DiffString `json:"storage" gencodec:"required"`
|
||||
}
|
||||
|
||||
type DiffString struct {
|
||||
NewValue *string `json:"newValue" gencodec:"optional"`
|
||||
OldValue *string `json:"oldValue" gencodec:"optional"`
|
||||
}
|
||||
type DiffUint64 struct { Value *uint64 `json:"value" gencodec:"optional"` }
|
||||
type DiffBigInt struct { Value *big.Int `json:"value" gencodec:"optional"` }
|
||||
type DiffString struct{ Value *string `json:"value" gencodec:"optional"` }
|
||||
type DiffUint64 struct{ Value *uint64 `json:"value" gencodec:"optional"` }
|
||||
type DiffBigInt struct{ Value *big.Int `json:"value" gencodec:"optional"` }
|
||||
|
Loading…
Reference in New Issue
Block a user