mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 23:26:44 +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.
|
// Gather the execution-layer triggered requests.
|
||||||
var requests [][]byte
|
var requests [][]byte
|
||||||
if chainConfig.IsPrague(vmContext.BlockNumber, vmContext.Time) {
|
if chainConfig.IsPrague(vmContext.BlockNumber) {
|
||||||
// EIP-6110 deposits
|
// EIP-6110 deposits
|
||||||
var allLogs []*types.Log
|
var allLogs []*types.Log
|
||||||
for _, receipt := range receipts {
|
for _, receipt := range receipts {
|
||||||
|
|
|
||||||
|
|
@ -360,7 +360,7 @@ func GenerateChain(config *params.ChainConfig, parent *types.Block, engine conse
|
||||||
}
|
}
|
||||||
|
|
||||||
var requests [][]byte
|
var requests [][]byte
|
||||||
if config.IsPrague(b.header.Number, b.header.Time) {
|
if config.IsPrague(b.header.Number) {
|
||||||
// EIP-6110 deposits
|
// EIP-6110 deposits
|
||||||
var blockLogs []*types.Log
|
var blockLogs []*types.Log
|
||||||
for _, r := range b.receipts {
|
for _, r := range b.receipts {
|
||||||
|
|
@ -478,7 +478,7 @@ func GenerateVerkleChain(config *params.ChainConfig, parent *types.Block, engine
|
||||||
// preState := statedb.Copy()
|
// preState := statedb.Copy()
|
||||||
|
|
||||||
// Pre-execution system calls.
|
// Pre-execution system calls.
|
||||||
if config.IsPrague(b.header.Number, b.header.Time) {
|
if config.IsPrague(b.header.Number) {
|
||||||
// EIP-2935
|
// EIP-2935
|
||||||
blockContext := NewEVMBlockContext(b.header, cm, &b.header.Coinbase)
|
blockContext := NewEVMBlockContext(b.header, cm, &b.header.Coinbase)
|
||||||
vmenv := vm.NewEVM(blockContext, vm.TxContext{}, statedb, cm.config, vm.Config{})
|
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)
|
head.BlobGasUsed = new(uint64)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if conf.IsPrague(num, g.Timestamp) {
|
if conf.IsPrague(num) {
|
||||||
emptyRequests := [][]byte{{0x00}, {0x01}, {0x02}}
|
emptyRequests := [][]byte{{0x00}, {0x01}, {0x02}}
|
||||||
rhash := types.CalcRequestsHash(emptyRequests)
|
rhash := types.CalcRequestsHash(emptyRequests)
|
||||||
head.RequestsHash = &rhash
|
head.RequestsHash = &rhash
|
||||||
|
|
|
||||||
|
|
@ -300,6 +300,7 @@ func (p *ParallelStateProcessor) Process(block *types.Block, statedb *state.Stat
|
||||||
metadata = true
|
metadata = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO(manav): Use `p.chain` instead of `p.bc`
|
||||||
blockContext := NewEVMBlockContext(header, p.bc, nil)
|
blockContext := NewEVMBlockContext(header, p.bc, nil)
|
||||||
context := NewEVMBlockContext(header, p.bc.hc, nil)
|
context := NewEVMBlockContext(header, p.bc.hc, nil)
|
||||||
vmenv := vm.NewEVM(context, vm.TxContext{}, statedb, p.config, cfg)
|
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.
|
// Read requests if Prague is enabled.
|
||||||
var requests types.Requests
|
var requests [][]byte
|
||||||
if p.config.IsPrague(block.Number()) && p.config.Bor == nil {
|
if p.config.IsPrague(block.Number()) {
|
||||||
requests, err = ParseDepositLogs(allLogs, p.config)
|
// EIP-6110 deposits
|
||||||
|
depositRequests, err := ParseDepositLogs(allLogs, p.config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
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)
|
// Finalize the block, applying any consensus engine specific extras (e.g. block rewards)
|
||||||
p.engine.Finalize(p.bc, header, statedb, block.Body())
|
p.engine.Finalize(p.bc, header, statedb, block.Body())
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,16 +38,14 @@ import (
|
||||||
// StateProcessor implements Processor.
|
// StateProcessor implements Processor.
|
||||||
type StateProcessor struct {
|
type StateProcessor struct {
|
||||||
config *params.ChainConfig // Chain configuration options
|
config *params.ChainConfig // Chain configuration options
|
||||||
bc *BlockChain // Canonical header chain
|
chain *HeaderChain // Canonical header chain
|
||||||
hc *HeaderChain
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewStateProcessor initialises a new StateProcessor.
|
// 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{
|
return &StateProcessor{
|
||||||
config: config,
|
config: config,
|
||||||
bc: bc,
|
chain: chain,
|
||||||
hc: hc,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -90,7 +88,7 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg
|
||||||
if beaconRoot := block.BeaconRoot(); beaconRoot != nil {
|
if beaconRoot := block.BeaconRoot(); beaconRoot != nil {
|
||||||
ProcessBeaconBlockRoot(*beaconRoot, vmenv, tracingStateDB)
|
ProcessBeaconBlockRoot(*beaconRoot, vmenv, tracingStateDB)
|
||||||
}
|
}
|
||||||
if p.config.IsPrague(block.Number(), block.Time()) {
|
if p.config.IsPrague(block.Number()) {
|
||||||
ProcessParentBlockHash(block.ParentHash(), vmenv, tracingStateDB)
|
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.
|
// Read requests if Prague is enabled.
|
||||||
var requests [][]byte
|
var requests [][]byte
|
||||||
if p.config.IsPrague(block.Number(), block.Time()) {
|
if p.config.IsPrague(block.Number()) {
|
||||||
// EIP-6110 deposits
|
// EIP-6110 deposits
|
||||||
depositRequests, err := ParseDepositLogs(allLogs, p.config)
|
depositRequests, err := ParseDepositLogs(allLogs, p.config)
|
||||||
if err != nil {
|
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)
|
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)
|
statedb.AddBalance(evm.Context.Coinbase, cmath.BigIntToUint256Int(result.FeeTipped), tracing.BalanceChangeTransfer)
|
||||||
output1 := new(big.Int).SetBytes(result.SenderInitBalance.Bytes())
|
output1 := new(big.Int).SetBytes(result.SenderInitBalance.Bytes())
|
||||||
output2 := new(big.Int).SetBytes(coinbaseBalance.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)
|
vmenv.Reset(NewEVMTxContext(msg), statedb)
|
||||||
statedb.AddAddressToAccessList(addr)
|
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)
|
statedb.Finalise(true)
|
||||||
|
|
||||||
// Create withdrawals requestsData with prefix 0x01
|
// 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),
|
headerCache: lru.NewCache[common.Hash, *types.Header](256),
|
||||||
engine: beacon.New(ethash.NewFaker()),
|
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
|
validator := NewBlockValidator(config, nil) // No chain, we only validate the state, not the block
|
||||||
|
|
||||||
// Run the stateless blocks processing and self-validate certain fields
|
// 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{})
|
vmenv := vm.NewEVM(blockCtx, vm.TxContext{}, statedb, api.backend.ChainConfig(), vm.Config{})
|
||||||
core.ProcessBeaconBlockRoot(*beaconRoot, vmenv, statedb)
|
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{})
|
vmenv := vm.NewEVM(blockCtx, vm.TxContext{}, statedb, api.backend.ChainConfig(), vm.Config{})
|
||||||
core.ProcessParentBlockHash(block.ParentHash(), vmenv, statedb)
|
core.ProcessParentBlockHash(block.ParentHash(), vmenv, statedb)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue