Skip to content

Commit cb1773c

Browse files
committed
eth/catalyst: forkcohoicev3 newpayloadv4
1 parent d7420ce commit cb1773c

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

eth/catalyst/api.go

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -245,8 +245,9 @@ func (api *ConsensusAPI) ForkchoiceUpdatedV3(update engine.ForkchoiceStateV1, pa
245245
if params.BeaconRoot == nil {
246246
return engine.STATUS_INVALID, engine.InvalidPayloadAttributes.With(errors.New("missing beacon root"))
247247
}
248-
if api.eth.BlockChain().Config().LatestFork(params.Timestamp) != forks.Cancun && api.eth.BlockChain().Config().LatestFork(params.Timestamp) != forks.Prague {
249-
return engine.STATUS_INVALID, engine.UnsupportedFork.With(errors.New("forkchoiceUpdatedV3 must only be called for cancun payloads"))
248+
latestFork := api.eth.BlockChain().Config().LatestFork(params.Timestamp)
249+
if latestFork != forks.Cancun && latestFork != forks.Prague && latestFork != forks.Osaka {
250+
return engine.STATUS_INVALID, engine.UnsupportedFork.With(errors.New("forkchoiceUpdatedV3 must only be called for cancun, prague and osaka payloads"))
250251
}
251252
}
252253
// TODO(matt): the spec requires that fcu is applied when called on a valid
@@ -303,8 +304,9 @@ func (api *ConsensusAPI) ForkchoiceUpdatedWithWitnessV3(update engine.Forkchoice
303304
if params.BeaconRoot == nil {
304305
return engine.STATUS_INVALID, engine.InvalidPayloadAttributes.With(errors.New("missing beacon root"))
305306
}
306-
if api.eth.BlockChain().Config().LatestFork(params.Timestamp) != forks.Cancun && api.eth.BlockChain().Config().LatestFork(params.Timestamp) != forks.Prague {
307-
return engine.STATUS_INVALID, engine.UnsupportedFork.With(errors.New("forkchoiceUpdatedV3 must only be called for cancun payloads"))
307+
latestFork := api.eth.BlockChain().Config().LatestFork(params.Timestamp)
308+
if latestFork != forks.Cancun && latestFork != forks.Prague && latestFork != forks.Osaka {
309+
return engine.STATUS_INVALID, engine.UnsupportedFork.With(errors.New("forkchoiceUpdatedV3 must only be called for cancun, prague and osaka payloads"))
308310
}
309311
}
310312
// TODO(matt): the spec requires that fcu is applied when called on a valid
@@ -666,8 +668,9 @@ func (api *ConsensusAPI) NewPayloadV4(params engine.ExecutableData, versionedHas
666668
return engine.PayloadStatusV1{Status: engine.INVALID}, engine.InvalidParams.With(errors.New("nil executionRequests post-prague"))
667669
}
668670

669-
if api.eth.BlockChain().Config().LatestFork(params.Timestamp) != forks.Prague {
670-
return engine.PayloadStatusV1{Status: engine.INVALID}, engine.UnsupportedFork.With(errors.New("newPayloadV4 must only be called for prague payloads"))
671+
latestFork := api.eth.BlockChain().Config().LatestFork(params.Timestamp)
672+
if latestFork != forks.Prague && latestFork != forks.Osaka {
673+
return engine.PayloadStatusV1{Status: engine.INVALID}, engine.UnsupportedFork.With(errors.New("newPayloadV4 must only be called for prague or osaka payloads"))
671674
}
672675
requests := convertRequests(executionRequests)
673676
if err := validateRequests(requests); err != nil {
@@ -788,8 +791,9 @@ func (api *ConsensusAPI) NewPayloadWithWitnessV4(params engine.ExecutableData, v
788791
return engine.PayloadStatusV1{Status: engine.INVALID}, engine.InvalidParams.With(errors.New("nil executionRequests post-prague"))
789792
}
790793

791-
if api.eth.BlockChain().Config().LatestFork(params.Timestamp) != forks.Prague {
792-
return engine.PayloadStatusV1{Status: engine.INVALID}, engine.UnsupportedFork.With(errors.New("newPayloadWithWitnessV4 must only be called for prague payloads"))
794+
latestFork := api.eth.BlockChain().Config().LatestFork(params.Timestamp)
795+
if latestFork != forks.Prague && latestFork != forks.Osaka {
796+
return engine.PayloadStatusV1{Status: engine.INVALID}, engine.UnsupportedFork.With(errors.New("newPayloadWithWitnessV4 must only be called for prague or osaka payloads"))
793797
}
794798
requests := convertRequests(executionRequests)
795799
if err := validateRequests(requests); err != nil {

0 commit comments

Comments
 (0)