Skip to content

Commit 9400229

Browse files
committed
fix a few rebase issues
1 parent 41b5b85 commit 9400229

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

core/chain_makers.go

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ func GenerateChainWithGenesis(genesis *Genesis, engine consensus.Engine, n int,
365365
return db, blocks, receipts
366366
}
367367

368-
func GenerateVerkleChain(config *params.ChainConfig, parent *types.Block, engine consensus.Engine, db ethdb.Database, n int, gen func(int, *BlockGen)) ([]*types.Block, []types.Receipts, []*verkle.VerkleProof, []verkle.StateDiff) {
368+
func GenerateVerkleChain(config *params.ChainConfig, parent *types.Block, engine consensus.Engine, diskdb ethdb.Database, n int, gen func(int, *BlockGen)) ([]*types.Block, []types.Receipts, []*verkle.VerkleProof, []verkle.StateDiff) {
369369
if config == nil {
370370
config = params.TestChainConfig
371371
}
@@ -434,20 +434,16 @@ func GenerateVerkleChain(config *params.ChainConfig, parent *types.Block, engine
434434
return nil, nil
435435
}
436436
var snaps *snapshot.Tree
437-
triedb := state.NewDatabaseWithConfig(db, nil)
438-
triedb.StartVerkleTransition(common.Hash{}, common.Hash{}, config, config.PragueTime, common.Hash{})
439-
triedb.EndVerkleTransition()
440-
//statedb, err := state.New(parent.Root(), triedb, snaps)
441-
//if err != nil {
442-
// panic(fmt.Sprintf("could not find state for block %d: err=%v, parent root=%x", parent.NumberU64(), err, parent.Root()))
443-
//}
444-
statedb.Database().SaveTransitionState(parent.Root())
437+
db := state.NewDatabaseWithConfig(diskdb, nil)
438+
db.StartVerkleTransition(common.Hash{}, common.Hash{}, config, config.PragueTime, common.Hash{})
439+
db.EndVerkleTransition()
440+
db.SaveTransitionState(parent.Root())
445441
for i := 0; i < n; i++ {
446-
// XXX merge uncommment
447-
statedb, err := state.New(parent.Root(), triedb, snaps)
442+
statedb, err := state.New(parent.Root(), db, snaps)
448443
if err != nil {
449444
panic(fmt.Sprintf("could not find state for block %d: err=%v, parent root=%x", i, err, parent.Root()))
450445
}
446+
statedb.NewAccessWitness()
451447
block, receipt := genblock(i, parent, statedb)
452448
blocks[i] = block
453449
receipts[i] = receipt

core/state_processor.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import (
3131
"github.com/ethereum/go-ethereum/crypto"
3232
"github.com/ethereum/go-ethereum/log"
3333
"github.com/ethereum/go-ethereum/params"
34+
"github.com/ethereum/go-ethereum/trie/utils"
3435
)
3536

3637
// StateProcessor is a basic Processor, which takes care of transitioning
@@ -186,6 +187,14 @@ func ApplyTransaction(config *params.ChainConfig, bc ChainContext, author *commo
186187
return applyTransaction(msg, config, gp, statedb, header.Number, header.Hash(), tx, usedGas, vmenv)
187188
}
188189

190+
func InsertBlockHashHistoryAtEip2935Fork(statedb *state.StateDB, prevNumber uint64, prevHash common.Hash, chain consensus.ChainHeaderReader) {
191+
ancestor := chain.GetHeader(prevHash, prevNumber)
192+
for i := prevNumber; i > 0 && i >= prevNumber-256; i-- {
193+
ProcessParentBlockHash(statedb, i, ancestor.Hash())
194+
ancestor = chain.GetHeader(ancestor.ParentHash, ancestor.Number.Uint64()-1)
195+
}
196+
}
197+
189198
func ProcessParentBlockHash(statedb *state.StateDB, prevNumber uint64, prevHash common.Hash) {
190199
var key common.Hash
191200
binary.BigEndian.PutUint64(key[24:], prevNumber)

0 commit comments

Comments
 (0)