MCPcopy Create free account
hub / github.com/base/base / validate_payload_attributes_against_header

Method validate_payload_attributes_against_header

crates/execution/node/src/engine.rs:224–255  ·  view source on GitHub ↗
(
        &self,
        attributes: &Types::PayloadAttributes,
        header: &<Self::Block as Block>::Header,
    )

Source from the content-addressed store, hash-verified

222 }
223
224 fn validate_payload_attributes_against_header(
225 &self,
226 attributes: &Types::PayloadAttributes,
227 header: &<Self::Block as Block>::Header,
228 ) -> Result<(), InvalidPayloadAttributesError> {
229 let timestamp = attributes.timestamp();
230 if !self.chain_spec().is_denim_active_at_timestamp(timestamp) {
231 return (timestamp > header.timestamp())
232 .then_some(())
233 .ok_or(InvalidPayloadAttributesError::InvalidTimestamp);
234 }
235
236 let invalid_metadata = |error: BaseTimeMetadataError| {
237 InvalidPayloadAttributesError::InvalidParams(Box::new(error))
238 };
239 let transaction = attributes
240 .sequencer_transactions()
241 .get(1)
242 .ok_or_else(|| invalid_metadata(BaseTimeMetadataError::Missing))?;
243 let deposit = transaction
244 .value()
245 .as_deposit()
246 .ok_or_else(|| invalid_metadata(BaseTimeMetadataError::NotDeposit))?;
247 BaseTimeUpdateTx::validate_deposit(deposit, header.number() + 1)
248 .map_err(invalid_metadata)?;
249
250 // The parent header does not contain its millisecond component, so only whole-second
251 // ordering can be checked here.
252 (timestamp >= header.timestamp())
253 .then_some(())
254 .ok_or(InvalidPayloadAttributesError::InvalidTimestamp)
255 }
256}
257
258impl<Types, Tx, ChainSpec> EngineApiValidator<Types> for BaseEngineValidator<Tx, ChainSpec>

Callers

nothing calls this directly

Calls 9

newFunction · 0.50
timestampMethod · 0.45
chain_specMethod · 0.45
getMethod · 0.45
as_depositMethod · 0.45
valueMethod · 0.45
numberMethod · 0.45

Tested by

no test coverage detected