@@ -33,7 +33,7 @@ import (
33
33
"github.com/ethereum/go-ethereum/log"
34
34
"github.com/ethereum/go-ethereum/miner"
35
35
"github.com/ethereum/go-ethereum/node"
36
- "github.com/ethereum/go-ethereum/params"
36
+ "github.com/ethereum/go-ethereum/params/forks "
37
37
"github.com/ethereum/go-ethereum/rpc"
38
38
)
39
39
@@ -192,7 +192,7 @@ func (api *ConsensusAPI) ForkchoiceUpdatedV2(update engine.ForkchoiceStateV1, pa
192
192
if params .BeaconRoot != nil {
193
193
return engine .STATUS_INVALID , engine .InvalidParams .With (errors .New ("unexpected beacon root" ))
194
194
}
195
- if ! latestActive ( api .eth .BlockChain ().Config (), "shanghai" , params .Timestamp ) {
195
+ if api .eth .BlockChain ().Config (). LatestFork ( params .Timestamp ) != forks . Shanghai {
196
196
return engine .STATUS_INVALID , engine .UnsupportedFork .With (errors .New ("forkchoiceUpdatedV2 must only be called for shanghai payloads" ))
197
197
}
198
198
}
@@ -208,8 +208,8 @@ func (api *ConsensusAPI) ForkchoiceUpdatedV3(update engine.ForkchoiceStateV1, pa
208
208
if params .BeaconRoot == nil {
209
209
return engine .STATUS_INVALID , engine .InvalidParams .With (errors .New ("missing beacon root" ))
210
210
}
211
- if ! latestActive ( api .eth .BlockChain ().Config (), "cancun" , params .Timestamp ) {
212
- return engine .STATUS_INVALID , engine .UnsupportedFork .With (errors .New ("forkchoiceUpdatedV3 must only be called for shanghai payloads" ))
211
+ if api .eth .BlockChain ().Config (). LatestFork ( params .Timestamp ) != forks . Cancun {
212
+ return engine .STATUS_INVALID , engine .UnsupportedFork .With (errors .New ("forkchoiceUpdatedV3 must only be called for cancun payloads" ))
213
213
}
214
214
}
215
215
return api .forkchoiceUpdated (update , params )
@@ -445,7 +445,7 @@ func (api *ConsensusAPI) NewPayloadV1(params engine.ExecutableData) (engine.Payl
445
445
446
446
// NewPayloadV2 creates an Eth1 block, inserts it in the chain, and returns the status of the chain.
447
447
func (api * ConsensusAPI ) NewPayloadV2 (params engine.ExecutableData ) (engine.PayloadStatusV1 , error ) {
448
- if latestActive ( api .eth .BlockChain ().Config (), "shanghai" , params .Timestamp ) {
448
+ if api .eth .BlockChain ().Config (). LatestFork ( params .Timestamp ) == forks . Shanghai {
449
449
if params .Withdrawals == nil {
450
450
return engine.PayloadStatusV1 {Status : engine .INVALID }, engine .InvalidParams .With (errors .New ("nil withdrawals post-shanghai" ))
451
451
}
@@ -482,33 +482,12 @@ func (api *ConsensusAPI) NewPayloadV3(params engine.ExecutableData, versionedHas
482
482
return engine.PayloadStatusV1 {Status : engine .INVALID }, engine .InvalidParams .With (errors .New ("nil parentBeaconBlockRoot post-cancun" ))
483
483
}
484
484
485
- if ! latestActive ( api .eth .BlockChain ().Config (), "cancun" , params .Timestamp ) {
485
+ if api .eth .BlockChain ().Config (). LatestFork ( params .Timestamp ) != forks . Cancun {
486
486
return engine.PayloadStatusV1 {Status : engine .INVALID }, engine .UnsupportedFork .With (errors .New ("newPayloadV3 must only be called for cancun payloads" ))
487
487
}
488
488
return api .newPayload (params , versionedHashes , beaconRoot )
489
489
}
490
490
491
- // latestActive returns true only if fork is the latest latestActive fork. It returns false otherwise.
492
- func latestActive (config * params.ChainConfig , fork string , time uint64 ) bool {
493
- switch fork {
494
- case "shanghai" :
495
- if ! config .IsShanghai (config .LondonBlock , time ) {
496
- return false
497
- }
498
- if config .IsCancun (config .LondonBlock , time ) {
499
- return false
500
- }
501
- case "cancun" :
502
- if ! config .IsCancun (config .LondonBlock , time ) {
503
- return false
504
- }
505
- if config .IsPrague (config .LondonBlock , time ) {
506
- return false
507
- }
508
- }
509
- return true
510
- }
511
-
512
491
func (api * ConsensusAPI ) newPayload (params engine.ExecutableData , versionedHashes []common.Hash , beaconRoot * common.Hash ) (engine.PayloadStatusV1 , error ) {
513
492
// The locking here is, strictly, not required. Without these locks, this can happen:
514
493
//
0 commit comments