From 09786257424a51da94cb6a13427160dfbc839b98 Mon Sep 17 00:00:00 2001 From: jsvisa Date: Fri, 26 Sep 2025 11:44:26 +0800 Subject: [PATCH 1/3] eth/catalyst: check getPayloadV4/5 based on Osaka --- eth/catalyst/api.go | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/eth/catalyst/api.go b/eth/catalyst/api.go index b37c26149f6..88de8a29eca 100644 --- a/eth/catalyst/api.go +++ b/eth/catalyst/api.go @@ -446,7 +446,16 @@ func (api *ConsensusAPI) GetPayloadV4(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 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")) + } + return data, nil } // GetPayloadV5 returns a cached payload by id. This endpoint should only @@ -458,7 +467,16 @@ func (api *ConsensusAPI) GetPayloadV5(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 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 data, nil } func (api *ConsensusAPI) getPayload(payloadID engine.PayloadID, full bool) (*engine.ExecutionPayloadEnvelope, error) { From 6d9d1f5c0d57fd8acff3b54c323babecccfaa3cd Mon Sep 17 00:00:00 2001 From: jsvisa Date: Fri, 26 Sep 2025 12:27:36 +0800 Subject: [PATCH 2/3] 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 88de8a29eca..afb42f862b5 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 } From bafa700f350ce7dc7fb4d534571a2b2dd379941a Mon Sep 17 00:00:00 2001 From: jsvisa Date: Fri, 26 Sep 2025 13:00:17 +0800 Subject: [PATCH 3/3] check fork --- eth/catalyst/api.go | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/eth/catalyst/api.go b/eth/catalyst/api.go index afb42f862b5..ebf4dc7f9dc 100644 --- a/eth/catalyst/api.go +++ b/eth/catalyst/api.go @@ -413,10 +413,6 @@ 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 } @@ -436,9 +432,9 @@ func (api *ConsensusAPI) GetPayloadV2(payloadID engine.PayloadID) (*engine.Execu 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")) + // Check if the payload timestamp falls within the Shanghai fork timeframe + if data.ExecutionPayload != nil && !api.checkFork(data.ExecutionPayload.Timestamp, forks.Shanghai) { + return nil, engine.UnsupportedFork } return data, nil } @@ -453,9 +449,9 @@ func (api *ConsensusAPI) GetPayloadV3(payloadID engine.PayloadID) (*engine.Execu 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")) + // Check if the payload timestamp falls within the Cancun fork timeframe + if data.ExecutionPayload != nil && !api.checkFork(data.ExecutionPayload.Timestamp, forks.Cancun) { + return nil, engine.UnsupportedFork } return data, nil } @@ -470,9 +466,9 @@ 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")) + // Check if the payload timestamp falls within the Prague fork timeframe + if data.ExecutionPayload != nil && !api.checkFork(data.ExecutionPayload.Timestamp, forks.Prague) { + return nil, engine.UnsupportedFork } return data, nil } @@ -490,9 +486,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 + // Check if the payload timestamp falls within the time frame of the Osaka fork or later if data.ExecutionPayload != nil && api.config().LatestFork(data.ExecutionPayload.Timestamp) < forks.Osaka { - return nil, engine.UnsupportedFork.With(errors.New("engine_getPayloadV5 is not available before Osaka fork")) + return nil, engine.UnsupportedFork } return data, nil }