fix: don't use rlp in the tree for slot values (#51)
* fix: don't use rlp in the tree for slot values * fix timeout after rebase
This commit is contained in:
@ -365,15 +365,15 @@ func (s *stateObject) updateTrie(db Database) Trie {
|
|||||||
}
|
}
|
||||||
s.db.StorageDeleted += 1
|
s.db.StorageDeleted += 1
|
||||||
} else {
|
} else {
|
||||||
|
if !tr.IsVerkle() {
|
||||||
// Encoding []byte cannot fail, ok to ignore the error.
|
// Encoding []byte cannot fail, ok to ignore the error.
|
||||||
v, _ = rlp.EncodeToBytes(common.TrimLeftZeroes(value[:]))
|
v, _ = rlp.EncodeToBytes(common.TrimLeftZeroes(value[:]))
|
||||||
|
|
||||||
if !tr.IsVerkle() {
|
|
||||||
s.setError(tr.TryUpdate(key[:], v))
|
s.setError(tr.TryUpdate(key[:], v))
|
||||||
} else {
|
} else {
|
||||||
k := trieUtils.GetTreeKeyStorageSlot(s.address[:], new(uint256.Int).SetBytes(key[:]))
|
k := trieUtils.GetTreeKeyStorageSlot(s.address[:], new(uint256.Int).SetBytes(key[:]))
|
||||||
// Update the trie, with v as a value
|
// Update the trie, with v as a value
|
||||||
s.setError(tr.TryUpdate(k, v))
|
s.setError(tr.TryUpdate(k, value[:]))
|
||||||
}
|
}
|
||||||
s.db.StorageUpdated += 1
|
s.db.StorageUpdated += 1
|
||||||
}
|
}
|
||||||
|
@ -191,6 +191,22 @@ func (b *testWorkerBackend) newRandomUncle() *types.Block {
|
|||||||
return blocks[0]
|
return blocks[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (b *testWorkerBackend) newRandomVerkleUncle() *types.Block {
|
||||||
|
var parent *types.Block
|
||||||
|
cur := b.chain.CurrentBlock()
|
||||||
|
if cur.NumberU64() == 0 {
|
||||||
|
parent = b.chain.Genesis()
|
||||||
|
} else {
|
||||||
|
parent = b.chain.GetBlockByHash(b.chain.CurrentBlock().ParentHash())
|
||||||
|
}
|
||||||
|
blocks, _ := core.GenerateVerkleChain(b.chain.Config(), parent, b.chain.Engine(), b.db, 1, func(i int, gen *core.BlockGen) {
|
||||||
|
var addr = make([]byte, common.AddressLength)
|
||||||
|
rand.Read(addr)
|
||||||
|
gen.SetCoinbase(common.BytesToAddress(addr))
|
||||||
|
})
|
||||||
|
return blocks[0]
|
||||||
|
}
|
||||||
|
|
||||||
func (b *testWorkerBackend) newRandomTx(creation bool) *types.Transaction {
|
func (b *testWorkerBackend) newRandomTx(creation bool) *types.Transaction {
|
||||||
var tx *types.Transaction
|
var tx *types.Transaction
|
||||||
gasPrice := big.NewInt(10 * params.InitialBaseFee)
|
gasPrice := big.NewInt(10 * params.InitialBaseFee)
|
||||||
@ -306,11 +322,10 @@ func TestGenerateBlocksAndImportVerkle(t *testing.T) {
|
|||||||
w.start()
|
w.start()
|
||||||
|
|
||||||
for i := 0; i < 5; i++ {
|
for i := 0; i < 5; i++ {
|
||||||
// TODO this causes a failure, but shouldn't. investigate.
|
b.txPool.AddLocal(b.newRandomTx(true))
|
||||||
//b.txPool.AddLocal(b.newRandomTx(true))
|
|
||||||
b.txPool.AddLocal(b.newRandomTx(false))
|
b.txPool.AddLocal(b.newRandomTx(false))
|
||||||
//w.postSideBlock(core.ChainSideEvent{Block: b.newRandomUncle()})
|
w.postSideBlock(core.ChainSideEvent{Block: b.newRandomVerkleUncle()})
|
||||||
//w.postSideBlock(core.ChainSideEvent{Block: b.newRandomUncle()})
|
w.postSideBlock(core.ChainSideEvent{Block: b.newRandomVerkleUncle()})
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case ev := <-sub.Chan():
|
case ev := <-sub.Chan():
|
||||||
|
Reference in New Issue
Block a user