From 3d1883d03f5c759c46ac4b333b7a23fe850f62e8 Mon Sep 17 00:00:00 2001 From: Niclas Blomberg Date: Tue, 11 Feb 2025 15:04:29 +0100 Subject: [PATCH] fix(validation-rpc): validate against parent, not latest (#14405) --- crates/rpc/rpc/src/validation.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/crates/rpc/rpc/src/validation.rs b/crates/rpc/rpc/src/validation.rs index b92e1972c..cd512b488 100644 --- a/crates/rpc/rpc/src/validation.rs +++ b/crates/rpc/rpc/src/validation.rs @@ -141,18 +141,18 @@ where let parent_header = self .provider - .header(&block.parent_hash())? + .sealed_header_by_hash(block.parent_hash())? .ok_or_else(|| ValidationApiError::MissingParentBlock)?; if latest_header.number().saturating_sub(parent_header.number()) > self.validation_window { return Err(ValidationApiError::BlockTooOld) } - self.consensus.validate_header_against_parent(block.sealed_header(), &latest_header)?; - self.validate_gas_limit(registered_gas_limit, &latest_header, block.sealed_header())?; - let latest_header_hash = latest_header.hash(); - let state_provider = self.provider.state_by_block_hash(latest_header_hash)?; + self.consensus.validate_header_against_parent(block.sealed_header(), &parent_header)?; + self.validate_gas_limit(registered_gas_limit, &parent_header, block.sealed_header())?; + let parent_header_hash = parent_header.hash(); + let state_provider = self.provider.state_by_block_hash(parent_header_hash)?; - let mut request_cache = self.cached_reads(latest_header_hash).await; + let mut request_cache = self.cached_reads(parent_header_hash).await; let cached_db = request_cache.as_db_mut(StateProviderDatabase::new(&state_provider)); let executor = self.executor_provider.executor(cached_db); @@ -169,7 +169,7 @@ where })?; // update the cached reads - self.update_cached_reads(latest_header_hash, request_cache).await; + self.update_cached_reads(parent_header_hash, request_cache).await; if let Some(account) = accessed_blacklisted { return Err(ValidationApiError::Blacklist(account))