mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-25 14:16:44 +00:00
core: use new intermedate root
This commit is contained in:
parent
c89452c0e1
commit
145d88cbe4
3 changed files with 7 additions and 5 deletions
|
|
@ -128,7 +128,7 @@ func (v *BlockValidator) ValidateState(block, parent *types.Block, statedb *stat
|
|||
}
|
||||
// Validate the state root against the received state root and throw
|
||||
// an error if they don't match.
|
||||
if root := statedb.IntermediateRoot(); header.Root != root {
|
||||
if root := state.IntermediateRoot(statedb); header.Root != root {
|
||||
return fmt.Errorf("invalid merkle root: header=%x computed=%x", header.Root, root)
|
||||
}
|
||||
return nil
|
||||
|
|
|
|||
|
|
@ -225,7 +225,7 @@ func GenerateChain(config *ChainConfig, parent *types.Block, db ethdb.Database,
|
|||
return blocks, receipts
|
||||
}
|
||||
|
||||
func makeHeader(parent *types.Block, state *state.StateDB) *types.Header {
|
||||
func makeHeader(parent *types.Block, st *state.StateDB) *types.Header {
|
||||
var time *big.Int
|
||||
if parent.Time() == nil {
|
||||
time = big.NewInt(10)
|
||||
|
|
@ -233,7 +233,7 @@ func makeHeader(parent *types.Block, state *state.StateDB) *types.Header {
|
|||
time = new(big.Int).Add(parent.Time(), big.NewInt(10)) // block time is fixed at 10 seconds
|
||||
}
|
||||
return &types.Header{
|
||||
Root: state.IntermediateRoot(),
|
||||
Root: state.IntermediateRoot(st),
|
||||
ParentHash: parent.Hash(),
|
||||
Coinbase: parent.Coinbase(),
|
||||
Difficulty: CalcDifficulty(MakeChainConfig(), time.Uint64(), new(big.Int).Sub(time, big.NewInt(10)).Uint64(), parent.Number(), parent.Difficulty()),
|
||||
|
|
|
|||
|
|
@ -64,15 +64,17 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg
|
|||
header = block.Header()
|
||||
allLogs vm.Logs
|
||||
gp = new(GasPool).AddGas(block.GasLimit())
|
||||
forkState = state.Fork(statedb)
|
||||
)
|
||||
// Mutate the the block and state according to any hard-fork specs
|
||||
if p.config.DAOForkSupport && p.config.DAOForkBlock != nil && p.config.DAOForkBlock.Cmp(block.Number()) == 0 {
|
||||
ApplyDAOHardFork(statedb)
|
||||
}
|
||||
|
||||
forkState := state.Fork(statedb)
|
||||
// Iterate over and process the individual transactions
|
||||
for i, tx := range block.Transactions() {
|
||||
forkState.TransitionState(tx.Hash(), block.Hash(), i)
|
||||
|
||||
txPostState, receipt, logs, _, err := ApplyTransaction(p.config, p.bc, gp, forkState, header, tx, totalUsedGas, cfg)
|
||||
if err != nil {
|
||||
return nil, nil, totalUsedGas, err
|
||||
|
|
@ -82,7 +84,7 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg
|
|||
|
||||
forkState = state.Fork(txPostState)
|
||||
}
|
||||
AccumulateRewards(statedb, header, block.Uncles())
|
||||
AccumulateRewards(forkState, header, block.Uncles())
|
||||
|
||||
statedb.Set(state.Reduce(forkState))
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue