mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 18:32:23 +00:00
Fix block num
This commit is contained in:
parent
dddd593c77
commit
3d12e68d24
4 changed files with 12 additions and 7 deletions
|
|
@ -202,7 +202,7 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig,
|
||||||
prevHash = pre.Env.BlockHashes[math.HexOrDecimal64(prevNumber)]
|
prevHash = pre.Env.BlockHashes[math.HexOrDecimal64(prevNumber)]
|
||||||
evm = vm.NewEVM(vmContext, vm.TxContext{}, statedb, chainConfig, vmConfig)
|
evm = vm.NewEVM(vmContext, vm.TxContext{}, statedb, chainConfig, vmConfig)
|
||||||
)
|
)
|
||||||
core.ProcessParentBlockHash(statedb, evm, prevHash, prevNumber)
|
core.ProcessParentBlockHash(statedb, evm, prevHash)
|
||||||
}
|
}
|
||||||
for i := 0; txIt.Next(); i++ {
|
for i := 0; txIt.Next(); i++ {
|
||||||
tx, err := txIt.Tx()
|
tx, err := txIt.Tx()
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,7 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg
|
||||||
}
|
}
|
||||||
if p.config.IsPrague(block.Number(), block.Time()) {
|
if p.config.IsPrague(block.Number(), block.Time()) {
|
||||||
// This should not underflow as genesis block is not processed.
|
// This should not underflow as genesis block is not processed.
|
||||||
ProcessParentBlockHash(statedb, vmenv, block.ParentHash(), block.NumberU64()-1)
|
ProcessParentBlockHash(statedb, vmenv, block.ParentHash())
|
||||||
}
|
}
|
||||||
// Iterate over and process the individual transactions
|
// Iterate over and process the individual transactions
|
||||||
for i, tx := range block.Transactions() {
|
for i, tx := range block.Transactions() {
|
||||||
|
|
|
||||||
|
|
@ -549,11 +549,11 @@ func TestProcessParentBlockHash(t *testing.T) {
|
||||||
|
|
||||||
vmContext := NewEVMBlockContext(header, nil, &coinbase)
|
vmContext := NewEVMBlockContext(header, nil, &coinbase)
|
||||||
evm := vm.NewEVM(vmContext, vm.TxContext{}, statedb, chainConfig, vm.Config{})
|
evm := vm.NewEVM(vmContext, vm.TxContext{}, statedb, chainConfig, vm.Config{})
|
||||||
ProcessParentBlockHash(statedb, evm, header.ParentHash, parent.Number.Uint64())
|
ProcessParentBlockHash(statedb, evm, header.ParentHash)
|
||||||
|
|
||||||
vmContext = NewEVMBlockContext(parent, nil, &coinbase)
|
vmContext = NewEVMBlockContext(parent, nil, &coinbase)
|
||||||
evm = vm.NewEVM(vmContext, vm.TxContext{}, statedb, chainConfig, vm.Config{})
|
evm = vm.NewEVM(vmContext, vm.TxContext{}, statedb, chainConfig, vm.Config{})
|
||||||
ProcessParentBlockHash(statedb, evm, parent.ParentHash, genesis.Number.Uint64())
|
ProcessParentBlockHash(statedb, evm, parent.ParentHash)
|
||||||
|
|
||||||
// make sure that the state is correct
|
// make sure that the state is correct
|
||||||
if have := getParentBlockHash(statedb, 1); have != hashA {
|
if have := getParentBlockHash(statedb, 1); have != hashA {
|
||||||
|
|
|
||||||
|
|
@ -195,13 +195,18 @@ func (miner *Miner) prepareWork(genParams *generateParams) (*environment, error)
|
||||||
log.Error("Failed to create sealing context", "err", err)
|
log.Error("Failed to create sealing context", "err", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
var (
|
||||||
|
context vm.BlockContext
|
||||||
|
vmenv *vm.EVM
|
||||||
|
)
|
||||||
if header.ParentBeaconRoot != nil {
|
if header.ParentBeaconRoot != nil {
|
||||||
context := core.NewEVMBlockContext(header, miner.chain, nil)
|
context = core.NewEVMBlockContext(header, miner.chain, nil)
|
||||||
vmenv := vm.NewEVM(context, vm.TxContext{}, env.state, miner.chainConfig, vm.Config{})
|
vmenv = vm.NewEVM(context, vm.TxContext{}, env.state, miner.chainConfig, vm.Config{})
|
||||||
core.ProcessBeaconBlockRoot(*header.ParentBeaconRoot, vmenv, env.state)
|
core.ProcessBeaconBlockRoot(*header.ParentBeaconRoot, vmenv, env.state)
|
||||||
}
|
}
|
||||||
if miner.chainConfig.IsPrague(header.Number, header.Time) {
|
if miner.chainConfig.IsPrague(header.Number, header.Time) {
|
||||||
core.ProcessParentBlockHash(env.state, header.ParentHash, header.Number.Uint64()-1)
|
// Prague is enabled after Cancun so vmenv should be initalized.
|
||||||
|
core.ProcessParentBlockHash(env.state, vmenv, header.ParentHash)
|
||||||
}
|
}
|
||||||
return env, nil
|
return env, nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue