pectra HFs: supported EIPs: 2537, 2935, 7623, 7702; disabled EIPs: 7549 7840, 7691, 6110, 7002, 7251, 7685

This commit is contained in:
Pratik Patil 2025-05-16 09:43:31 +05:30
parent 46119804a5
commit 5a4c85922d
No known key found for this signature in database
GPG key ID: AFDCA496554874B3
12 changed files with 24 additions and 18 deletions

View file

@ -362,6 +362,7 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig,
statedb.AddBalance(w.Address, uint256.MustFromBig(amount), tracing.BalanceIncreaseWithdrawal) statedb.AddBalance(w.Address, uint256.MustFromBig(amount), tracing.BalanceIncreaseWithdrawal)
} }
// Polygon/bor: EIP-6110, EIP-7002, and EIP-7251 are not supported
// Gather the execution-layer triggered requests. // Gather the execution-layer triggered requests.
var requests [][]byte var requests [][]byte
if chainConfig.IsPrague(vmContext.BlockNumber) && chainConfig.Bor == nil { if chainConfig.IsPrague(vmContext.BlockNumber) && chainConfig.Bor == nil {

View file

@ -163,6 +163,7 @@ func Transaction(ctx *cli.Context) error {
continue continue
} }
// For Prague txs, validate the floor data gas. // For Prague txs, validate the floor data gas.
// EIP-7623
if rules.IsPrague { if rules.IsPrague {
floorDataGas, err := core.FloorDataGas(tx.Data()) floorDataGas, err := core.FloorDataGas(tx.Data())
if err != nil { if err != nil {

View file

@ -324,7 +324,8 @@ func (b *BlockGen) collectRequests(readonly bool) (requests [][]byte) {
statedb = statedb.Copy() statedb = statedb.Copy()
} }
if b.cm.config.IsPrague(b.header.Number) { // Polygon/bor: EIP-6110, EIP-7002, and EIP-7251 are not supported
if b.cm.config.IsPrague(b.header.Number) && b.cm.config.Bor == nil {
requests = [][]byte{} requests = [][]byte{}
// EIP-6110 deposits // EIP-6110 deposits
var blockLogs []*types.Log var blockLogs []*types.Log

View file

@ -539,6 +539,8 @@ func (g *Genesis) toBlockWithRoot(root common.Hash) *types.Block {
head.BlobGasUsed = new(uint64) head.BlobGasUsed = new(uint64)
} }
} }
// Polygon/bor: EIP-7685 not supported
if conf.IsPrague(num) && conf.Bor == nil { if conf.IsPrague(num) && conf.Bor == nil {
head.RequestsHash = &types.EmptyRequestsHash head.RequestsHash = &types.EmptyRequestsHash
} }

View file

@ -309,6 +309,7 @@ func (p *ParallelStateProcessor) Process(block *types.Block, statedb *state.Stat
ProcessBeaconBlockRoot(*beaconRoot, vmenv) ProcessBeaconBlockRoot(*beaconRoot, vmenv)
} }
if p.config.IsPrague(block.Number()) { if p.config.IsPrague(block.Number()) {
// EIP-2935
ProcessParentBlockHash(block.ParentHash(), vmenv) ProcessParentBlockHash(block.ParentHash(), vmenv)
} }
// Iterate over and process the individual transactions // Iterate over and process the individual transactions
@ -398,21 +399,8 @@ func (p *ParallelStateProcessor) Process(block *types.Block, statedb *state.Stat
return nil, err return nil, err
} }
// Read requests if Prague is enabled and bor consensus is not active. // Polygon/bor: EIP-6110, EIP-7002, and EIP-7251 are not supported
var requests [][]byte var requests [][]byte
if p.config.IsPrague(block.Number()) && p.config.Bor == nil {
// EIP-6110 deposits
err := ParseDepositLogs(&requests, allLogs, p.config)
if err != nil {
return nil, err
}
// EIP-7002 withdrawals
ProcessWithdrawalQueue(&requests, vmenv)
// EIP-7251 consolidations
ProcessConsolidationQueue(&requests, vmenv)
}
// 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())

View file

@ -90,6 +90,7 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg
ProcessBeaconBlockRoot(*beaconRoot, evm) ProcessBeaconBlockRoot(*beaconRoot, evm)
} }
if (p.config.IsPrague(block.Number()) || p.config.IsVerkle(block.Number())) && p.config.Bor == nil { if (p.config.IsPrague(block.Number()) || p.config.IsVerkle(block.Number())) && p.config.Bor == nil {
// EIP-2935
ProcessParentBlockHash(block.ParentHash(), evm) ProcessParentBlockHash(block.ParentHash(), evm)
} }
@ -117,6 +118,8 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg
receipts = append(receipts, receipt) receipts = append(receipts, receipt)
allLogs = append(allLogs, receipt.Logs...) allLogs = append(allLogs, receipt.Logs...)
} }
// Polygon/bor: EIP-6110, EIP-7002, and EIP-7251 are not supported
// Read requests if Prague is enabled. // Read requests if Prague is enabled.
var requests [][]byte var requests [][]byte
if p.config.IsPrague(block.Number()) && p.config.Bor == nil { if p.config.IsPrague(block.Number()) && p.config.Bor == nil {

View file

@ -122,7 +122,8 @@ func ValidateTransaction(tx *types.Transaction, head *types.Header, signer types
return fmt.Errorf("%w: gas %v, minimum needed %v", core.ErrIntrinsicGas, tx.Gas(), intrGas) return fmt.Errorf("%w: gas %v, minimum needed %v", core.ErrIntrinsicGas, tx.Gas(), intrGas)
} }
// Ensure the transaction can cover floor data gas. // Ensure the transaction can cover floor data gas.
if opts.Config.IsPrague(head.Number) { // EIP-7623
if opts.Config.IsPrague(head.Number) && opts.Config.Bor != nil {
floorDataGas, err := core.FloorDataGas(tx.Data()) floorDataGas, err := core.FloorDataGas(tx.Data())
if err != nil { if err != nil {
return err return err

View file

@ -587,6 +587,7 @@ func (evm *EVM) Create2(caller common.Address, code []byte, gas uint64, endowmen
// Prague, it can also resolve code pointed to by a delegation designator. // Prague, it can also resolve code pointed to by a delegation designator.
func (evm *EVM) resolveCode(addr common.Address) []byte { func (evm *EVM) resolveCode(addr common.Address) []byte {
code := evm.StateDB.GetCode(addr) code := evm.StateDB.GetCode(addr)
// EIP-7702
if !evm.chainRules.IsPrague { if !evm.chainRules.IsPrague {
return code return code
} }
@ -602,6 +603,7 @@ func (evm *EVM) resolveCode(addr common.Address) []byte {
// delegation designator. Although this is not accessible in the EVM it is used // delegation designator. Although this is not accessible in the EVM it is used
// internally to associate jumpdest analysis to code. // internally to associate jumpdest analysis to code.
func (evm *EVM) resolveCodeHash(addr common.Address) common.Hash { func (evm *EVM) resolveCodeHash(addr common.Address) common.Hash {
// EIP-7702
if evm.chainRules.IsPrague { if evm.chainRules.IsPrague {
code := evm.StateDB.GetCode(addr) code := evm.StateDB.GetCode(addr)
if target, ok := types.ParseDelegation(code); ok { if target, ok := types.ParseDelegation(code); ok {

View file

@ -252,7 +252,7 @@ func (eth *Ethereum) stateAtTransaction(ctx context.Context, block *types.Block,
core.ProcessBeaconBlockRoot(*beaconRoot, evm) core.ProcessBeaconBlockRoot(*beaconRoot, evm)
} }
// If prague hardfork, insert parent block hash in the state as per EIP-2935. // If prague hardfork, insert parent block hash in the state as per EIP-2935.
if eth.blockchain.Config().IsPrague(block.Number()) { if eth.blockchain.Config().IsPrague(block.Number()) && eth.blockchain.Config().Bor != nil {
core.ProcessParentBlockHash(block.ParentHash(), evm) core.ProcessParentBlockHash(block.ParentHash(), evm)
} }
if txIndex == 0 && len(block.Transactions()) == 0 { if txIndex == 0 && len(block.Transactions()) == 0 {

View file

@ -484,6 +484,7 @@ func (api *API) traceChain(start, end *types.Block, config *TraceConfig, closed
core.ProcessBeaconBlockRoot(*beaconRoot, evm) core.ProcessBeaconBlockRoot(*beaconRoot, evm)
} }
// Insert parent hash in history contract. // Insert parent hash in history contract.
// EIP-2935
if api.backend.ChainConfig().IsPrague(next.Number()) { if api.backend.ChainConfig().IsPrague(next.Number()) {
core.ProcessParentBlockHash(next.ParentHash(), evm) core.ProcessParentBlockHash(next.ParentHash(), evm)
} }

View file

@ -251,6 +251,7 @@ func (sim *simulator) processBlock(ctx context.Context, block *simBlock, header,
evm.SetPrecompiles(precompiles) evm.SetPrecompiles(precompiles)
} }
if sim.chainConfig.IsPrague(header.Number) || sim.chainConfig.IsVerkle(header.Number) { if sim.chainConfig.IsPrague(header.Number) || sim.chainConfig.IsVerkle(header.Number) {
// EIP-2935
core.ProcessParentBlockHash(header.ParentHash, evm) core.ProcessParentBlockHash(header.ParentHash, evm)
} }
if header.ParentBeaconRoot != nil { if header.ParentBeaconRoot != nil {
@ -309,9 +310,11 @@ func (sim *simulator) processBlock(ctx context.Context, block *simBlock, header,
if sim.chainConfig.IsCancun(header.Number) { if sim.chainConfig.IsCancun(header.Number) {
header.BlobGasUsed = &blobGasUsed header.BlobGasUsed = &blobGasUsed
} }
// Polygon/bor: EIP-6110, EIP-7002, and EIP-7251 are not supported
var requests [][]byte var requests [][]byte
// Process EIP-7685 requests // Process EIP-7685 requests
if sim.chainConfig.IsPrague(header.Number) { if sim.chainConfig.IsPrague(header.Number) && sim.chainConfig.Bor == nil {
requests = [][]byte{} requests = [][]byte{}
// EIP-6110 // EIP-6110
if err := core.ParseDepositLogs(&requests, allLogs, sim.chainConfig); err != nil { if err := core.ParseDepositLogs(&requests, allLogs, sim.chainConfig); err != nil {

View file

@ -1312,6 +1312,7 @@ func (w *worker) prepareWork(genParams *generateParams, witness bool) (*environm
core.ProcessBeaconBlockRoot(*header.ParentBeaconRoot, vmenv) core.ProcessBeaconBlockRoot(*header.ParentBeaconRoot, vmenv)
} }
if w.chainConfig.IsPrague(header.Number) { if w.chainConfig.IsPrague(header.Number) {
// EIP-2935
context := core.NewEVMBlockContext(header, w.chain, nil) context := core.NewEVMBlockContext(header, w.chain, nil)
vmenv := vm.NewEVM(context, env.state, w.chainConfig, vm.Config{}) vmenv := vm.NewEVM(context, env.state, w.chainConfig, vm.Config{})
core.ProcessParentBlockHash(header.ParentHash, vmenv) core.ProcessParentBlockHash(header.ParentHash, vmenv)
@ -1429,6 +1430,8 @@ func (w *worker) generateWork(params *generateParams, witness bool) *newPayloadR
for _, r := range work.receipts { for _, r := range work.receipts {
allLogs = append(allLogs, r.Logs...) allLogs = append(allLogs, r.Logs...)
} }
// Polygon/bor: EIP-6110, EIP-7002, and EIP-7251 are not supported
// Collect consensus-layer requests if Prague is enabled and bor consensus is not active. // Collect consensus-layer requests if Prague is enabled and bor consensus is not active.
var requests [][]byte var requests [][]byte
if w.chainConfig.IsPrague(work.header.Number) && w.chainConfig.Bor == nil { if w.chainConfig.IsPrague(work.header.Number) && w.chainConfig.Bor == nil {