mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 15:16:43 +00:00
cmd, core, eth: make IsPrague block based instead of block, time both
This commit is contained in:
parent
4a4ba278dc
commit
f090b34cd0
7 changed files with 26 additions and 18 deletions
|
|
@ -377,7 +377,7 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig,
|
|||
|
||||
// Gather the execution-layer triggered requests.
|
||||
var requests [][]byte
|
||||
if chainConfig.IsPrague(vmContext.BlockNumber, vmContext.Time) {
|
||||
if chainConfig.IsPrague(vmContext.BlockNumber) {
|
||||
// EIP-6110 deposits
|
||||
var allLogs []*types.Log
|
||||
for _, receipt := range receipts {
|
||||
|
|
|
|||
|
|
@ -360,7 +360,7 @@ func GenerateChain(config *params.ChainConfig, parent *types.Block, engine conse
|
|||
}
|
||||
|
||||
var requests [][]byte
|
||||
if config.IsPrague(b.header.Number, b.header.Time) {
|
||||
if config.IsPrague(b.header.Number) {
|
||||
// EIP-6110 deposits
|
||||
var blockLogs []*types.Log
|
||||
for _, r := range b.receipts {
|
||||
|
|
@ -478,7 +478,7 @@ func GenerateVerkleChain(config *params.ChainConfig, parent *types.Block, engine
|
|||
// preState := statedb.Copy()
|
||||
|
||||
// Pre-execution system calls.
|
||||
if config.IsPrague(b.header.Number, b.header.Time) {
|
||||
if config.IsPrague(b.header.Number) {
|
||||
// EIP-2935
|
||||
blockContext := NewEVMBlockContext(b.header, cm, &b.header.Coinbase)
|
||||
vmenv := vm.NewEVM(blockContext, vm.TxContext{}, statedb, cm.config, vm.Config{})
|
||||
|
|
|
|||
|
|
@ -511,7 +511,7 @@ func (g *Genesis) toBlockWithRoot(root common.Hash) *types.Block {
|
|||
head.BlobGasUsed = new(uint64)
|
||||
}
|
||||
}
|
||||
if conf.IsPrague(num, g.Timestamp) {
|
||||
if conf.IsPrague(num) {
|
||||
emptyRequests := [][]byte{{0x00}, {0x01}, {0x02}}
|
||||
rhash := types.CalcRequestsHash(emptyRequests)
|
||||
head.RequestsHash = &rhash
|
||||
|
|
|
|||
|
|
@ -300,6 +300,7 @@ func (p *ParallelStateProcessor) Process(block *types.Block, statedb *state.Stat
|
|||
metadata = true
|
||||
}
|
||||
|
||||
// TODO(manav): Use `p.chain` instead of `p.bc`
|
||||
blockContext := NewEVMBlockContext(header, p.bc, nil)
|
||||
context := NewEVMBlockContext(header, p.bc.hc, nil)
|
||||
vmenv := vm.NewEVM(context, vm.TxContext{}, statedb, p.config, cfg)
|
||||
|
|
@ -395,14 +396,23 @@ func (p *ParallelStateProcessor) Process(block *types.Block, statedb *state.Stat
|
|||
}
|
||||
|
||||
// Read requests if Prague is enabled.
|
||||
var requests types.Requests
|
||||
if p.config.IsPrague(block.Number()) && p.config.Bor == nil {
|
||||
requests, err = ParseDepositLogs(allLogs, p.config)
|
||||
var requests [][]byte
|
||||
if p.config.IsPrague(block.Number()) {
|
||||
// EIP-6110 deposits
|
||||
depositRequests, err := ParseDepositLogs(allLogs, p.config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
requests = append(requests, depositRequests)
|
||||
// EIP-7002 withdrawals
|
||||
withdrawalRequests := ProcessWithdrawalQueue(vmenv, tracingStateDB)
|
||||
requests = append(requests, withdrawalRequests)
|
||||
// EIP-7251 consolidations
|
||||
consolidationRequests := ProcessConsolidationQueue(vmenv, tracingStateDB)
|
||||
requests = append(requests, consolidationRequests)
|
||||
}
|
||||
|
||||
// TODO(manav): Use `p.chain` instead of `p.bc` param (check consensus interface)
|
||||
// Finalize the block, applying any consensus engine specific extras (e.g. block rewards)
|
||||
p.engine.Finalize(p.bc, header, statedb, block.Body())
|
||||
|
||||
|
|
|
|||
|
|
@ -38,16 +38,14 @@ import (
|
|||
// StateProcessor implements Processor.
|
||||
type StateProcessor struct {
|
||||
config *params.ChainConfig // Chain configuration options
|
||||
bc *BlockChain // Canonical header chain
|
||||
hc *HeaderChain
|
||||
chain *HeaderChain // Canonical header chain
|
||||
}
|
||||
|
||||
// NewStateProcessor initialises a new StateProcessor.
|
||||
func NewStateProcessor(config *params.ChainConfig, bc *BlockChain, hc *HeaderChain) *StateProcessor {
|
||||
func NewStateProcessor(config *params.ChainConfig, chain *HeaderChain) *StateProcessor {
|
||||
return &StateProcessor{
|
||||
config: config,
|
||||
bc: bc,
|
||||
hc: hc,
|
||||
chain: chain,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -90,7 +88,7 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg
|
|||
if beaconRoot := block.BeaconRoot(); beaconRoot != nil {
|
||||
ProcessBeaconBlockRoot(*beaconRoot, vmenv, tracingStateDB)
|
||||
}
|
||||
if p.config.IsPrague(block.Number(), block.Time()) {
|
||||
if p.config.IsPrague(block.Number()) {
|
||||
ProcessParentBlockHash(block.ParentHash(), vmenv, tracingStateDB)
|
||||
}
|
||||
|
||||
|
|
@ -120,7 +118,7 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg
|
|||
}
|
||||
// Read requests if Prague is enabled.
|
||||
var requests [][]byte
|
||||
if p.config.IsPrague(block.Number(), block.Time()) {
|
||||
if p.config.IsPrague(block.Number()) {
|
||||
// EIP-6110 deposits
|
||||
depositRequests, err := ParseDepositLogs(allLogs, p.config)
|
||||
if err != nil {
|
||||
|
|
@ -189,7 +187,6 @@ func ApplyTransactionWithEVM(msg *Message, config *params.ChainConfig, gp *GasPo
|
|||
statedb.AddBalance(result.BurntContractAddress, cmath.BigIntToUint256Int(result.FeeBurnt), tracing.BalanceChangeTransfer)
|
||||
}
|
||||
|
||||
// TODO(raneet10) Double check
|
||||
statedb.AddBalance(evm.Context.Coinbase, cmath.BigIntToUint256Int(result.FeeTipped), tracing.BalanceChangeTransfer)
|
||||
output1 := new(big.Int).SetBytes(result.SenderInitBalance.Bytes())
|
||||
output2 := new(big.Int).SetBytes(coinbaseBalance.Bytes())
|
||||
|
|
@ -366,7 +363,8 @@ func processRequestsSystemCall(vmenv *vm.EVM, statedb vm.StateDB, requestType by
|
|||
}
|
||||
vmenv.Reset(NewEVMTxContext(msg), statedb)
|
||||
statedb.AddAddressToAccessList(addr)
|
||||
ret, _, _ := vmenv.Call(vm.AccountRef(msg.From), *msg.To, msg.Data, 30_000_000, common.U2560)
|
||||
// Note(bor): It's okay to pass nil interrupt context as this is only for eth related things.
|
||||
ret, _, _ := vmenv.Call(vm.AccountRef(msg.From), *msg.To, msg.Data, 30_000_000, common.U2560, nil)
|
||||
statedb.Finalise(true)
|
||||
|
||||
// Create withdrawals requestsData with prefix 0x01
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ func ExecuteStateless(config *params.ChainConfig, block *types.Block, witness *s
|
|||
headerCache: lru.NewCache[common.Hash, *types.Header](256),
|
||||
engine: beacon.New(ethash.NewFaker()),
|
||||
}
|
||||
processor := NewStateProcessor(config, nil, headerChain)
|
||||
processor := NewStateProcessor(config, headerChain)
|
||||
validator := NewBlockValidator(config, nil) // No chain, we only validate the state, not the block
|
||||
|
||||
// Run the stateless blocks processing and self-validate certain fields
|
||||
|
|
|
|||
|
|
@ -812,7 +812,7 @@ func (api *API) traceBlock(ctx context.Context, block *types.Block, config *Trac
|
|||
vmenv := vm.NewEVM(blockCtx, vm.TxContext{}, statedb, api.backend.ChainConfig(), vm.Config{})
|
||||
core.ProcessBeaconBlockRoot(*beaconRoot, vmenv, statedb)
|
||||
}
|
||||
if api.backend.ChainConfig().IsPrague(block.Number(), block.Time()) {
|
||||
if api.backend.ChainConfig().IsPrague(block.Number()) {
|
||||
vmenv := vm.NewEVM(blockCtx, vm.TxContext{}, statedb, api.backend.ChainConfig(), vm.Config{})
|
||||
core.ProcessParentBlockHash(block.ParentHash(), vmenv, statedb)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue