Remove old storage value from updated accounts
This commit is contained in:
parent
1a8a889ef2
commit
8152f5562f
@ -268,12 +268,7 @@ func (sdb *builder) buildStorageDiffsIncremental(oldSR common.Hash, newSR common
|
|||||||
log.Debug("Found leaf in storage", "path", pathToStr(it))
|
log.Debug("Found leaf in storage", "path", pathToStr(it))
|
||||||
path := pathToStr(it)
|
path := pathToStr(it)
|
||||||
value := hexutil.Encode(it.LeafBlob())
|
value := hexutil.Encode(it.LeafBlob())
|
||||||
if oldVal, err := oldTrie.TryGet(it.LeafKey()); err != nil {
|
storageDiffs[path] = DiffString{NewValue: &value}
|
||||||
log.Error("Failed to look up value in oldTrie", "path", path, "error", err)
|
|
||||||
} else {
|
|
||||||
hexOldVal := hexutil.Encode(oldVal)
|
|
||||||
storageDiffs[path] = DiffString{OldValue: &hexOldVal, NewValue: &value}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cont := it.Next(true)
|
cont := it.Next(true)
|
||||||
|
@ -39,12 +39,10 @@ var (
|
|||||||
builder b.Builder
|
builder b.Builder
|
||||||
miningReward = int64(3000000000000000000)
|
miningReward = int64(3000000000000000000)
|
||||||
burnAddress = common.HexToAddress("0x0")
|
burnAddress = common.HexToAddress("0x0")
|
||||||
diff *b.StateDiff
|
|
||||||
err error
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestBuilder(t *testing.T) {
|
func TestBuilder(t *testing.T) {
|
||||||
_, blocks := makeChain(3, 0, genesis)
|
_, blocks := makeChain(3, genesis)
|
||||||
block0Hash = common.HexToHash("0xd1721cfd0b29c36fd7a68f25c128e86413fb666a6e1d68e89b875bd299262661")
|
block0Hash = common.HexToHash("0xd1721cfd0b29c36fd7a68f25c128e86413fb666a6e1d68e89b875bd299262661")
|
||||||
block1Hash = common.HexToHash("0x47c398dd688eaa4dd11b006888156783fe32df83d59b197c0fcd303408103d39")
|
block1Hash = common.HexToHash("0x47c398dd688eaa4dd11b006888156783fe32df83d59b197c0fcd303408103d39")
|
||||||
block2Hash = common.HexToHash("0x351b2f531838683ba457e8ca4d3a844cc48147dceafbcb589dc6e3227856ee75")
|
block2Hash = common.HexToHash("0x351b2f531838683ba457e8ca4d3a844cc48147dceafbcb589dc6e3227856ee75")
|
||||||
@ -76,7 +74,6 @@ func TestBuilder(t *testing.T) {
|
|||||||
nonce3 = uint64(3)
|
nonce3 = uint64(3)
|
||||||
originalContractRoot = "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421"
|
originalContractRoot = "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421"
|
||||||
newContractRoot = "0x9e676b23802aff85d29b4f0243939bc6ecfdca2a41532310091781854d6ffeb2"
|
newContractRoot = "0x9e676b23802aff85d29b4f0243939bc6ecfdca2a41532310091781854d6ffeb2"
|
||||||
oldStorageValue = "0x"
|
|
||||||
newStorageValue = "0x03"
|
newStorageValue = "0x03"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -230,9 +227,7 @@ func TestBuilder(t *testing.T) {
|
|||||||
ContractRoot: b.DiffString{ NewValue: &newContractRoot },
|
ContractRoot: b.DiffString{ NewValue: &newContractRoot },
|
||||||
Storage: map[string]b.DiffString{
|
Storage: map[string]b.DiffString{
|
||||||
"0x405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace": {
|
"0x405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace": {
|
||||||
NewValue: &newStorageValue,
|
NewValue: &newStorageValue },
|
||||||
OldValue: &oldStorageValue,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
testBankAddress: {
|
testBankAddress: {
|
||||||
@ -288,7 +283,7 @@ func equals(actual, expected interface{}) (success bool) {
|
|||||||
// the returned hash chain is ordered head->parent. In addition, every 3rd block
|
// the returned hash chain is ordered head->parent. In addition, every 3rd block
|
||||||
// contains a transaction and every 5th an uncle to allow testing correct block
|
// contains a transaction and every 5th an uncle to allow testing correct block
|
||||||
// reassembly.
|
// reassembly.
|
||||||
func makeChain(n int, seed byte, parent *types.Block) ([]common.Hash, map[common.Hash]*types.Block) {
|
func makeChain(n int, parent *types.Block) ([]common.Hash, map[common.Hash]*types.Block) {
|
||||||
blocks, _ := core.GenerateChain(params.TestChainConfig, parent, ethash.NewFaker(), testdb, n, testChainGen)
|
blocks, _ := core.GenerateChain(params.TestChainConfig, parent, ethash.NewFaker(), testdb, n, testChainGen)
|
||||||
hashes := make([]common.Hash, n+1)
|
hashes := make([]common.Hash, n+1)
|
||||||
hashes[len(hashes)-1] = parent.Hash()
|
hashes[len(hashes)-1] = parent.Hash()
|
||||||
|
Loading…
Reference in New Issue
Block a user