From 6d9d1f5c0d57fd8acff3b54c323babecccfaa3cd Mon Sep 17 00:00:00 2001 From: jsvisa Date: Fri, 26 Sep 2025 12:27:36 +0800 Subject: [PATCH] check for v1..3 --- eth/catalyst/api.go | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/eth/catalyst/api.go b/eth/catalyst/api.go index 88de8a29ec..afb42f862b 100644 --- a/eth/catalyst/api.go +++ b/eth/catalyst/api.go @@ -413,6 +413,10 @@ func (api *ConsensusAPI) GetPayloadV1(payloadID engine.PayloadID) (*engine.Execu if err != nil { return nil, err } + // Check if the payload timestamp is greater or equal to Shanghai activation timestamp + if data.ExecutionPayload != nil && api.config().LatestFork(data.ExecutionPayload.Timestamp) >= forks.Shanghai { + return nil, engine.UnsupportedFork.With(errors.New("engine_getPayloadV1 is not available after Shanghai fork")) + } return data.ExecutionPayload, nil } @@ -428,7 +432,15 @@ func (api *ConsensusAPI) GetPayloadV2(payloadID engine.PayloadID) (*engine.Execu if !payloadID.Is(engine.PayloadV1, engine.PayloadV2) { return nil, engine.UnsupportedFork } - return api.getPayload(payloadID, false) + data, err := api.getPayload(payloadID, false) + if err != nil { + return nil, err + } + // Check if the payload timestamp is greater or equal to Cancun activation timestamp + if data.ExecutionPayload != nil && api.config().LatestFork(data.ExecutionPayload.Timestamp) >= forks.Cancun { + return nil, engine.UnsupportedFork.With(errors.New("engine_getPayloadV2 is not available after Cancun fork")) + } + return data, nil } // GetPayloadV3 returns a cached payload by id. This endpoint should only @@ -437,7 +449,15 @@ func (api *ConsensusAPI) GetPayloadV3(payloadID engine.PayloadID) (*engine.Execu if !payloadID.Is(engine.PayloadV3) { return nil, engine.UnsupportedFork } - return api.getPayload(payloadID, false) + data, err := api.getPayload(payloadID, false) + if err != nil { + return nil, err + } + // Check if the payload timestamp is greater or equal to Prague activation timestamp + if data.ExecutionPayload != nil && api.config().LatestFork(data.ExecutionPayload.Timestamp) >= forks.Prague { + return nil, engine.UnsupportedFork.With(errors.New("engine_getPayloadV3 is not available after Prague fork")) + } + return data, nil } // GetPayloadV4 returns a cached payload by id. This endpoint should only @@ -450,7 +470,6 @@ func (api *ConsensusAPI) GetPayloadV4(payloadID engine.PayloadID) (*engine.Execu if err != nil { return nil, err } - // Check if the payload timestamp is greater or equal to Osaka activation timestamp if data.ExecutionPayload != nil && api.config().LatestFork(data.ExecutionPayload.Timestamp) >= forks.Osaka { return nil, engine.UnsupportedFork.With(errors.New("engine_getPayloadV4 is not available after Osaka fork")) @@ -471,10 +490,9 @@ func (api *ConsensusAPI) GetPayloadV5(payloadID engine.PayloadID) (*engine.Execu if err != nil { return nil, err } - // Check if the payload timestamp falls within the time frame of the Osaka fork if data.ExecutionPayload != nil && api.config().LatestFork(data.ExecutionPayload.Timestamp) < forks.Osaka { - return nil, engine.UnsupportedFork.With(errors.New("engine_getPayloadV5 is not available after Osaka fork")) + return nil, engine.UnsupportedFork.With(errors.New("engine_getPayloadV5 is not available before Osaka fork")) } return data, nil }