mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 19:09:54 +00:00
fix(validation-rpc): validate against parent, not latest (#14405)
This commit is contained in:
@ -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))
|
||||
|
||||
Reference in New Issue
Block a user