Skip to content

Commit bfaf3c5

Browse files
committed
trie: use trie.NewStackTrie instead of new(trie.Trie) (ethereum#22246)
1 parent 0766e0b commit bfaf3c5

File tree

13 files changed

+15
-15
lines changed

13 files changed

+15
-15
lines changed

consensus/XDPoS/engines/engine_v1/engine.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -850,7 +850,7 @@ func (x *XDPoS_v1) Finalize(chain consensus.ChainReader, header *types.Header, s
850850
header.UncleHash = types.CalcUncleHash(nil)
851851

852852
// Assemble and return the final block for sealing
853-
return types.NewBlock(header, txs, nil, receipts, new(trie.Trie)), nil
853+
return types.NewBlock(header, txs, nil, receipts, trie.NewStackTrie(nil)), nil
854854
}
855855

856856
// Authorize injects a private key into the consensus engine to mint new blocks

consensus/XDPoS/engines/engine_v2/engine.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ func (x *XDPoS_v2) Finalize(chain consensus.ChainReader, header *types.Header, s
415415
header.UncleHash = types.CalcUncleHash(nil)
416416

417417
// Assemble and return the final block for sealing
418-
return types.NewBlock(header, txs, nil, receipts, new(trie.Trie)), nil
418+
return types.NewBlock(header, txs, nil, receipts, trie.NewStackTrie(nil)), nil
419419
}
420420

421421
// Authorize injects a private key into the consensus engine to mint new blocks with.

consensus/clique/clique.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ func (c *Clique) Finalize(chain consensus.ChainReader, header *types.Header, sta
589589
header.UncleHash = types.CalcUncleHash(nil)
590590

591591
// Assemble and return the final block for sealing
592-
return types.NewBlock(header, txs, nil, receipts, new(trie.Trie)), nil
592+
return types.NewBlock(header, txs, nil, receipts, trie.NewStackTrie(nil)), nil
593593
}
594594

595595
// Authorize injects a private key into the consensus engine to mint new blocks

consensus/ethash/consensus.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ func (ethash *Ethash) Finalize(chain consensus.ChainReader, header *types.Header
524524
header.Root = state.IntermediateRoot(chain.Config().IsEIP158(header.Number))
525525

526526
// Header seems complete, assemble into a block and return
527-
return types.NewBlock(header, txs, uncles, receipts, new(trie.Trie)), nil
527+
return types.NewBlock(header, txs, uncles, receipts, trie.NewStackTrie(nil)), nil
528528
}
529529

530530
// Some weird constants to avoid constant memory allocs for them.

consensus/tests/engine_v1_tests/helper.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ func createBlockFromHeader(bc *core.BlockChain, customHeader *types.Header, txs
383383
}
384384

385385
header.GasUsed = *gasUsed
386-
block = types.NewBlock(&header, txs, nil, receipts, new(trie.Trie))
386+
block = types.NewBlock(&header, txs, nil, receipts, trie.NewStackTrie(nil))
387387
}
388388

389389
return block, nil

consensus/tests/engine_v2_tests/helper.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,7 @@ func createBlockFromHeader(bc *core.BlockChain, customHeader *types.Header, txs
695695
header.Coinbase = signerAddress
696696
sealHeader(bc, &header, signerAddress, signerFunction)
697697

698-
block = types.NewBlock(&header, txs, nil, receipts, new(trie.Trie))
698+
block = types.NewBlock(&header, txs, nil, receipts, trie.NewStackTrie(nil))
699699
}
700700

701701
return block, nil

core/blockchain_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -654,12 +654,12 @@ func TestFastVsFullChains(t *testing.T) {
654654
}
655655
if fblock, ablock := fast.GetBlockByHash(hash), archive.GetBlockByHash(hash); fblock.Hash() != ablock.Hash() {
656656
t.Errorf("block #%d [%x]: block mismatch: have %v, want %v", num, hash, fblock, ablock)
657-
} else if types.DeriveSha(fblock.Transactions(), new(trie.Trie)) != types.DeriveSha(ablock.Transactions(), new(trie.Trie)) {
657+
} else if types.DeriveSha(fblock.Transactions(), trie.NewStackTrie(nil)) != types.DeriveSha(ablock.Transactions(), trie.NewStackTrie(nil)) {
658658
t.Errorf("block #%d [%x]: transactions mismatch: have %v, want %v", num, hash, fblock.Transactions(), ablock.Transactions())
659659
} else if types.CalcUncleHash(fblock.Uncles()) != types.CalcUncleHash(ablock.Uncles()) {
660660
t.Errorf("block #%d [%x]: uncles mismatch: have %v, want %v", num, hash, fblock.Uncles(), ablock.Uncles())
661661
}
662-
if freceipts, areceipts := rawdb.ReadReceipts(fastDb, hash, *rawdb.ReadHeaderNumber(fastDb, hash), fast.Config()), rawdb.ReadReceipts(archiveDb, hash, *rawdb.ReadHeaderNumber(archiveDb, hash), fast.Config()); types.DeriveSha(freceipts, new(trie.Trie)) != types.DeriveSha(areceipts, new(trie.Trie)) {
662+
if freceipts, areceipts := rawdb.ReadReceipts(fastDb, hash, *rawdb.ReadHeaderNumber(fastDb, hash), fast.Config()), rawdb.ReadReceipts(archiveDb, hash, *rawdb.ReadHeaderNumber(archiveDb, hash), fast.Config()); types.DeriveSha(freceipts, trie.NewStackTrie(nil)) != types.DeriveSha(areceipts, trie.NewStackTrie(nil)) {
663663
t.Errorf("block #%d [%x]: receipts mismatch: have %v, want %v", num, hash, freceipts, areceipts)
664664
}
665665
}

core/genesis.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ func (g *Genesis) ToBlock(db ethdb.Database) *types.Block {
229229
statedb.Commit(false)
230230
statedb.Database().TrieDB().Commit(root, true)
231231

232-
return types.NewBlock(head, nil, nil, nil, new(trie.Trie))
232+
return types.NewBlock(head, nil, nil, nil, trie.NewStackTrie(nil))
233233
}
234234

235235
// Commit writes the block and state of a genesis specification to the database.

core/state_processor_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,5 +287,5 @@ func GenerateBadBlock(t *testing.T, parent *types.Block, engine consensus.Engine
287287
}
288288
header.Root = common.BytesToHash(hasher.Sum(nil))
289289
// Assemble and return the final block for sealing
290-
return types.NewBlock(header, txs, nil, receipts, new(trie.Trie))
290+
return types.NewBlock(header, txs, nil, receipts, trie.NewStackTrie(nil))
291291
}

core/txpool/txpool_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ func (bc *testBlockChain) CurrentBlock() *types.Block {
8383
return types.NewBlock(&types.Header{
8484
Root: types.EmptyRootHash,
8585
GasLimit: atomic.LoadUint64(&bc.gasLimit),
86-
}, nil, nil, nil, new(trie.Trie))
86+
}, nil, nil, nil, trie.NewStackTrie(nil))
8787
}
8888

8989
func (bc *testBlockChain) GetBlock(hash common.Hash, number uint64) *types.Block {

0 commit comments

Comments
 (0)