chore: Rename BlockLocked to SealedBlock (#573)

* chore: Rename BlockLocked to SealedBlock

* chore: fmt

Co-authored-by: Genysys <112424909+samtvlabs@users.noreply.github.com>
Co-authored-by: Georgios Konstantopoulos <me@gakonst.com>
This commit is contained in:
Genysys
2022-12-22 16:45:36 +04:00
committed by GitHub
parent a85793cd9b
commit 0b1b5368e6
16 changed files with 50 additions and 50 deletions

View File

@ -8,7 +8,7 @@ use reth_db::{
}; };
use reth_executor::SpecUpgrades; use reth_executor::SpecUpgrades;
use reth_primitives::{ use reth_primitives::{
keccak256, Account as RethAccount, BigEndianHash, BlockLocked, SealedHeader, StorageEntry, H256, keccak256, Account as RethAccount, BigEndianHash, SealedBlock, SealedHeader, StorageEntry, H256,
}; };
use reth_rlp::Decodable; use reth_rlp::Decodable;
use reth_stages::{stages::execution::ExecutionStage, ExecInput, Stage, Transaction}; use reth_stages::{stages::execution::ExecutionStage, ExecInput, Stage, Transaction};
@ -102,11 +102,11 @@ pub async fn run_test(path: PathBuf) -> eyre::Result<()> {
// insert genesis // insert genesis
let header: SealedHeader = suite.genesis_block_header.into(); let header: SealedHeader = suite.genesis_block_header.into();
let genesis_block = BlockLocked { header, body: vec![], ommers: vec![] }; let genesis_block = SealedBlock { header, body: vec![], ommers: vec![] };
reth_provider::insert_canonical_block(&tx, &genesis_block, has_block_reward)?; reth_provider::insert_canonical_block(&tx, &genesis_block, has_block_reward)?;
suite.blocks.iter().try_for_each(|block| -> eyre::Result<()> { suite.blocks.iter().try_for_each(|block| -> eyre::Result<()> {
let decoded = BlockLocked::decode(&mut block.rlp.as_ref())?; let decoded = SealedBlock::decode(&mut block.rlp.as_ref())?;
reth_provider::insert_canonical_block(&tx, &decoded, has_block_reward)?; reth_provider::insert_canonical_block(&tx, &decoded, has_block_reward)?;
Ok(()) Ok(())
})?; })?;

View File

@ -43,9 +43,9 @@ The transactions root is a value that is calculated based on the transactions in
When the `BodyStage` is looking at the headers to determine which block to download, it will skip the blocks where the `header.ommers_hash` and the `header.transaction_root` are empty, denoting that the block is empty as well. When the `BodyStage` is looking at the headers to determine which block to download, it will skip the blocks where the `header.ommers_hash` and the `header.transaction_root` are empty, denoting that the block is empty as well.
Once the `BodyStage` determines which block bodies to fetch, a new `bodies_stream` is created which downloads all of the bodies from the `starting_block`, up until the `target_block` specified. Each time the `bodies_stream` yields a value, a `BlockLocked` is created using the block header, the ommers hash and the newly downloaded block body. Once the `BodyStage` determines which block bodies to fetch, a new `bodies_stream` is created which downloads all of the bodies from the `starting_block`, up until the `target_block` specified. Each time the `bodies_stream` yields a value, a `SealedBlock` is created using the block header, the ommers hash and the newly downloaded block body.
{{#template ../templates/source_and_github.md path_to_root=../../ path=crates/primitives/src/block.rs anchor=struct-BlockLocked}} {{#template ../templates/source_and_github.md path_to_root=../../ path=crates/primitives/src/block.rs anchor=struct-SealedBlock}}
The new block is then pre-validated, checking that the ommers hash and transactions root in the block header are the same in the block body. Following a successful pre-validation, the `BodyStage` loops through each transaction in the `block.body`, adding the transaction to the database. This process is repeated for every downloaded block body, with the `BodyStage` returning `Ok(ExecOutput { stage_progress: highest_block, reached_tip: true, done })` signaling it successfully completed. The new block is then pre-validated, checking that the ommers hash and transactions root in the block header are the same in the block body. Following a successful pre-validation, the `BodyStage` loops through each transaction in the `block.body`, adding the transaction to the database. This process is repeated for every downloaded block body, with the `BodyStage` returning `Ok(ExecOutput { stage_progress: highest_block, reached_tip: true, done })` signaling it successfully completed.

View File

@ -1,7 +1,7 @@
//! Consensus for ethereum network //! Consensus for ethereum network
use crate::{verification, Config}; use crate::{verification, Config};
use reth_interfaces::consensus::{Consensus, Error, ForkchoiceState}; use reth_interfaces::consensus::{Consensus, Error, ForkchoiceState};
use reth_primitives::{BlockLocked, BlockNumber, SealedHeader, H256}; use reth_primitives::{BlockNumber, SealedBlock, SealedHeader, H256};
use tokio::sync::{watch, watch::error::SendError}; use tokio::sync::{watch, watch::error::SendError};
/// Ethereum beacon consensus /// Ethereum beacon consensus
@ -54,7 +54,7 @@ impl Consensus for BeaconConsensus {
Ok(()) Ok(())
} }
fn pre_validate_block(&self, block: &BlockLocked) -> Result<(), Error> { fn pre_validate_block(&self, block: &SealedBlock) -> Result<(), Error> {
verification::validate_block_standalone(block) verification::validate_block_standalone(block)
} }

View File

@ -2,7 +2,7 @@
use crate::{config, Config}; use crate::{config, Config};
use reth_interfaces::{consensus::Error, Result as RethResult}; use reth_interfaces::{consensus::Error, Result as RethResult};
use reth_primitives::{ use reth_primitives::{
BlockLocked, BlockNumber, Header, SealedHeader, Transaction, TransactionSignedEcRecovered, BlockNumber, Header, SealedBlock, SealedHeader, Transaction, TransactionSignedEcRecovered,
TxEip1559, TxEip2930, TxLegacy, EMPTY_OMMER_ROOT, H256, U256, TxEip1559, TxEip2930, TxLegacy, EMPTY_OMMER_ROOT, H256, U256,
}; };
use reth_provider::{AccountProvider, HeaderProvider}; use reth_provider::{AccountProvider, HeaderProvider};
@ -182,7 +182,7 @@ pub fn validate_all_transaction_regarding_block_and_nonces<
/// - Compares the transactions root in the block header to the block body /// - Compares the transactions root in the block header to the block body
/// - Pre-execution transaction validation /// - Pre-execution transaction validation
/// - (Optionally) Compares the receipts root in the block header to the block body /// - (Optionally) Compares the receipts root in the block header to the block body
pub fn validate_block_standalone(block: &BlockLocked) -> Result<(), Error> { pub fn validate_block_standalone(block: &SealedBlock) -> Result<(), Error> {
// Check ommers hash // Check ommers hash
// TODO(onbjerg): This should probably be accessible directly on [Block] // TODO(onbjerg): This should probably be accessible directly on [Block]
let ommers_hash = let ommers_hash =
@ -313,7 +313,7 @@ pub fn validate_header_regarding_parent(
/// ///
/// Returns parent block header /// Returns parent block header
pub fn validate_block_regarding_chain<PROV: HeaderProvider>( pub fn validate_block_regarding_chain<PROV: HeaderProvider>(
block: &BlockLocked, block: &SealedBlock,
provider: &PROV, provider: &PROV,
) -> RethResult<SealedHeader> { ) -> RethResult<SealedHeader> {
let hash = block.header.hash(); let hash = block.header.hash();
@ -334,7 +334,7 @@ pub fn validate_block_regarding_chain<PROV: HeaderProvider>(
/// Full validation of block before execution. /// Full validation of block before execution.
pub fn full_validation<Provider: HeaderProvider + AccountProvider>( pub fn full_validation<Provider: HeaderProvider + AccountProvider>(
block: &BlockLocked, block: &SealedBlock,
provider: Provider, provider: Provider,
config: &Config, config: &Config,
) -> RethResult<()> { ) -> RethResult<()> {
@ -456,7 +456,7 @@ mod tests {
TransactionSignedEcRecovered::from_signed_transaction(tx, signer) TransactionSignedEcRecovered::from_signed_transaction(tx, signer)
} }
/// got test block /// got test block
fn mock_block() -> (BlockLocked, Header) { fn mock_block() -> (SealedBlock, Header) {
// https://etherscan.io/block/15867168 where transaction root and receipts root are cleared // https://etherscan.io/block/15867168 where transaction root and receipts root are cleared
// empty merkle tree: 0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421 // empty merkle tree: 0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421
@ -489,7 +489,7 @@ mod tests {
let ommers = Vec::new(); let ommers = Vec::new();
let body = Vec::new(); let body = Vec::new();
(BlockLocked { header: header.seal(), body, ommers }, parent) (SealedBlock { header: header.seal(), body, ommers }, parent)
} }
#[test] #[test]

View File

@ -418,7 +418,7 @@ mod tests {
transaction::DbTx, transaction::DbTx,
}; };
use reth_primitives::{ use reth_primitives::{
hex_literal::hex, keccak256, Account, Address, BlockLocked, Bytes, StorageKey, H160, H256, hex_literal::hex, keccak256, Account, Address, Bytes, SealedBlock, StorageKey, H160, H256,
U256, U256,
}; };
use reth_provider::{AccountProvider, StateProvider}; use reth_provider::{AccountProvider, StateProvider};
@ -484,7 +484,7 @@ mod tests {
// Got rlp block from: src/GeneralStateTestsFiller/stChainId/chainIdGasCostFiller.json // Got rlp block from: src/GeneralStateTestsFiller/stChainId/chainIdGasCostFiller.json
let mut block_rlp = hex!("f90262f901f9a075c371ba45999d87f4542326910a11af515897aebce5265d3f6acd1f1161f82fa01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347942adc25665018aa1fe0e6bc666dac8fc2697ff9baa098f2dcd87c8ae4083e7017a05456c14eea4b1db2032126e27b3b1563d57d7cc0a08151d548273f6683169524b66ca9fe338b9ce42bc3540046c828fd939ae23bcba03f4e5c2ec5b2170b711d97ee755c160457bb58d8daa338e835ec02ae6860bbabb901000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000083020000018502540be40082a8798203e800a00000000000000000000000000000000000000000000000000000000000000000880000000000000000f863f861800a8405f5e10094100000000000000000000000000000000000000080801ba07e09e26678ed4fac08a249ebe8ed680bf9051a5e14ad223e4b2b9d26e0208f37a05f6e3f188e3e6eab7d7d3b6568f5eac7d687b08d307d3154ccd8c87b4630509bc0").as_slice(); let mut block_rlp = hex!("f90262f901f9a075c371ba45999d87f4542326910a11af515897aebce5265d3f6acd1f1161f82fa01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347942adc25665018aa1fe0e6bc666dac8fc2697ff9baa098f2dcd87c8ae4083e7017a05456c14eea4b1db2032126e27b3b1563d57d7cc0a08151d548273f6683169524b66ca9fe338b9ce42bc3540046c828fd939ae23bcba03f4e5c2ec5b2170b711d97ee755c160457bb58d8daa338e835ec02ae6860bbabb901000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000083020000018502540be40082a8798203e800a00000000000000000000000000000000000000000000000000000000000000000880000000000000000f863f861800a8405f5e10094100000000000000000000000000000000000000080801ba07e09e26678ed4fac08a249ebe8ed680bf9051a5e14ad223e4b2b9d26e0208f37a05f6e3f188e3e6eab7d7d3b6568f5eac7d687b08d307d3154ccd8c87b4630509bc0").as_slice();
let block = BlockLocked::decode(&mut block_rlp).unwrap(); let block = SealedBlock::decode(&mut block_rlp).unwrap();
let mut db = StateProviderTest::default(); let mut db = StateProviderTest::default();

View File

@ -1,5 +1,5 @@
use async_trait::async_trait; use async_trait::async_trait;
use reth_primitives::{BlockHash, BlockLocked, BlockNumber, SealedHeader, H256}; use reth_primitives::{BlockHash, BlockNumber, SealedBlock, SealedHeader, H256};
use tokio::sync::watch::Receiver; use tokio::sync::watch::Receiver;
/// Re-export forkchoice state /// Re-export forkchoice state
@ -24,7 +24,7 @@ pub trait Consensus: Send + Sync {
/// 11.1 "Ommer Validation". /// 11.1 "Ommer Validation".
/// ///
/// **This should not be called for the genesis block**. /// **This should not be called for the genesis block**.
fn pre_validate_block(&self, block: &BlockLocked) -> Result<(), Error>; fn pre_validate_block(&self, block: &SealedBlock) -> Result<(), Error>;
/// After the Merge (aka Paris) block rewards became obsolete. /// After the Merge (aka Paris) block rewards became obsolete.
/// This flag is needed as reth change set is indexed of transaction granularity /// This flag is needed as reth change set is indexed of transaction granularity

View File

@ -1,11 +1,11 @@
use crate::p2p::downloader::{DownloadStream, Downloader}; use crate::p2p::downloader::{DownloadStream, Downloader};
use reth_primitives::{BlockLocked, SealedHeader}; use reth_primitives::{SealedBlock, SealedHeader};
/// The block response /// The block response
#[derive(PartialEq, Eq, Debug)] #[derive(PartialEq, Eq, Debug)]
pub enum BlockResponse { pub enum BlockResponse {
/// Full block response (with transactions or ommers) /// Full block response (with transactions or ommers)
Full(BlockLocked), Full(SealedBlock),
/// The empty block response /// The empty block response
Empty(SealedHeader), Empty(SealedHeader),
} }

View File

@ -1,6 +1,6 @@
use rand::{distributions::uniform::SampleRange, thread_rng, Rng}; use rand::{distributions::uniform::SampleRange, thread_rng, Rng};
use reth_primitives::{ use reth_primitives::{
proofs, Address, BlockLocked, Bytes, Header, SealedHeader, Signature, Transaction, proofs, Address, Bytes, Header, SealedBlock, SealedHeader, Signature, Transaction,
TransactionKind, TransactionSigned, TxLegacy, H256, U256, TransactionKind, TransactionSigned, TxLegacy, H256, U256,
}; };
use secp256k1::{KeyPair, Message as SecpMessage, Secp256k1, SecretKey}; use secp256k1::{KeyPair, Message as SecpMessage, Secp256k1, SecretKey};
@ -100,7 +100,7 @@ pub fn sign_message(secret: H256, message: H256) -> Result<Signature, secp256k1:
/// transactions in the block. /// transactions in the block.
/// ///
/// The ommer headers are not assumed to be valid. /// The ommer headers are not assumed to be valid.
pub fn random_block(number: u64, parent: Option<H256>, tx_count: Option<u8>) -> BlockLocked { pub fn random_block(number: u64, parent: Option<H256>, tx_count: Option<u8>) -> SealedBlock {
let mut rng = thread_rng(); let mut rng = thread_rng();
// Generate transactions // Generate transactions
@ -119,7 +119,7 @@ pub fn random_block(number: u64, parent: Option<H256>, tx_count: Option<u8>) ->
let transactions_root = proofs::calculate_transaction_root(transactions.iter()); let transactions_root = proofs::calculate_transaction_root(transactions.iter());
let ommers_hash = proofs::calculate_ommers_root(ommers.iter()); let ommers_hash = proofs::calculate_ommers_root(ommers.iter());
BlockLocked { SealedBlock {
header: Header { header: Header {
parent_hash: parent.unwrap_or_default(), parent_hash: parent.unwrap_or_default(),
number, number,
@ -145,14 +145,14 @@ pub fn random_block_range(
block_numbers: std::ops::Range<u64>, block_numbers: std::ops::Range<u64>,
head: H256, head: H256,
tx_count: std::ops::Range<u8>, tx_count: std::ops::Range<u8>,
) -> Vec<BlockLocked> { ) -> Vec<SealedBlock> {
let mut rng = rand::thread_rng(); let mut rng = rand::thread_rng();
let mut blocks = let mut blocks =
Vec::with_capacity(block_numbers.end.saturating_sub(block_numbers.start) as usize); Vec::with_capacity(block_numbers.end.saturating_sub(block_numbers.start) as usize);
for idx in block_numbers { for idx in block_numbers {
blocks.push(random_block( blocks.push(random_block(
idx, idx,
Some(blocks.last().map(|block: &BlockLocked| block.header.hash()).unwrap_or(head)), Some(blocks.last().map(|block: &SealedBlock| block.header.hash()).unwrap_or(head)),
Some(tx_count.clone().sample_single(&mut rng)), Some(tx_count.clone().sample_single(&mut rng)),
)); ));
} }

View File

@ -13,7 +13,7 @@ use crate::{
use futures::{Future, FutureExt, Stream}; use futures::{Future, FutureExt, Stream};
use reth_eth_wire::BlockHeaders; use reth_eth_wire::BlockHeaders;
use reth_primitives::{ use reth_primitives::{
BlockLocked, BlockNumber, Header, HeadersDirection, PeerId, SealedHeader, H256, BlockNumber, Header, HeadersDirection, PeerId, SealedBlock, SealedHeader, H256,
}; };
use reth_rpc_types::engine::ForkchoiceState; use reth_rpc_types::engine::ForkchoiceState;
use std::{ use std::{
@ -260,7 +260,7 @@ impl Consensus for TestConsensus {
} }
} }
fn pre_validate_block(&self, _block: &BlockLocked) -> Result<(), consensus::Error> { fn pre_validate_block(&self, _block: &SealedBlock) -> Result<(), consensus::Error> {
if self.fail_validation() { if self.fail_validation() {
Err(consensus::Error::BaseFeeMissing) Err(consensus::Error::BaseFeeMissing)
} else { } else {

View File

@ -11,7 +11,7 @@ use reth_interfaces::{
error::{DownloadError, DownloadResult, RequestError}, error::{DownloadError, DownloadResult, RequestError},
}, },
}; };
use reth_primitives::{BlockLocked, SealedHeader}; use reth_primitives::{SealedBlock, SealedHeader};
use std::{borrow::Borrow, sync::Arc}; use std::{borrow::Borrow, sync::Arc};
/// Downloads bodies in batches. /// Downloads bodies in batches.
@ -158,7 +158,7 @@ where
} }
}; };
let block = BlockLocked { let block = SealedBlock {
header: header.clone(), header: header.clone(),
body: body.transactions, body: body.transactions,
ommers: body.ommers.into_iter().map(|header| header.seal()).collect(), ommers: body.ommers.into_iter().map(|header| header.seal()).collect(),
@ -247,7 +247,7 @@ mod tests {
if header.is_empty() { if header.is_empty() {
BlockResponse::Empty(header) BlockResponse::Empty(header)
} else { } else {
BlockResponse::Full(BlockLocked { BlockResponse::Full(SealedBlock {
header, header,
body: body.transactions, body: body.transactions,
ommers: body.ommers.into_iter().map(|o| o.seal()).collect(), ommers: body.ommers.into_iter().map(|o| o.seal()).collect(),

View File

@ -22,9 +22,9 @@ impl Deref for Block {
} }
/// Sealed Ethereum full block. /// Sealed Ethereum full block.
// ANCHOR: struct-BlockLocked // ANCHOR: struct-SealedBlock
#[derive(Debug, Clone, PartialEq, Eq, Default, RlpEncodable, RlpDecodable)] #[derive(Debug, Clone, PartialEq, Eq, Default, RlpEncodable, RlpDecodable)]
pub struct BlockLocked { pub struct SealedBlock {
/// Locked block header. /// Locked block header.
pub header: SealedHeader, pub header: SealedHeader,
/// Transactions with signatures. /// Transactions with signatures.
@ -32,16 +32,16 @@ pub struct BlockLocked {
/// Ommer/uncle headers /// Ommer/uncle headers
pub ommers: Vec<SealedHeader>, pub ommers: Vec<SealedHeader>,
} }
// ANCHOR_END: struct-BlockLocked // ANCHOR_END: struct-SealedBlock
impl BlockLocked { impl SealedBlock {
/// Header hash. /// Header hash.
pub fn hash(&self) -> H256 { pub fn hash(&self) -> H256 {
self.header.hash() self.header.hash()
} }
} }
impl Deref for BlockLocked { impl Deref for SealedBlock {
type Target = Header; type Target = Header;
fn deref(&self) -> &Self::Target { fn deref(&self) -> &Self::Target {
self.header.as_ref() self.header.as_ref()

View File

@ -31,7 +31,7 @@ mod transaction;
pub mod proofs; pub mod proofs;
pub use account::Account; pub use account::Account;
pub use block::{Block, BlockHashOrNumber, BlockLocked}; pub use block::{Block, BlockHashOrNumber, SealedBlock};
pub use chain::Chain; pub use chain::Chain;
pub use constants::{EMPTY_OMMER_ROOT, KECCAK_EMPTY, MAINNET_GENESIS}; pub use constants::{EMPTY_OMMER_ROOT, KECCAK_EMPTY, MAINNET_GENESIS};
pub use ethbloom::Bloom; pub use ethbloom::Bloom;

View File

@ -557,14 +557,14 @@ mod tests {
TestConsensus, TestConsensus,
}, },
}; };
use reth_primitives::{BlockLocked, BlockNumber, SealedHeader, TxNumber, H256}; use reth_primitives::{BlockNumber, SealedBlock, SealedHeader, TxNumber, H256};
use std::{collections::HashMap, sync::Arc}; use std::{collections::HashMap, sync::Arc};
/// The block hash of the genesis block. /// The block hash of the genesis block.
pub(crate) const GENESIS_HASH: H256 = H256::zero(); pub(crate) const GENESIS_HASH: H256 = H256::zero();
/// A helper to create a collection of resulted-wrapped block bodies keyed by their hash. /// A helper to create a collection of resulted-wrapped block bodies keyed by their hash.
pub(crate) fn body_by_hash(block: &BlockLocked) -> (H256, DownloadResult<BlockBody>) { pub(crate) fn body_by_hash(block: &SealedBlock) -> (H256, DownloadResult<BlockBody>) {
( (
block.hash(), block.hash(),
Ok(BlockBody { Ok(BlockBody {
@ -624,7 +624,7 @@ mod tests {
#[async_trait::async_trait] #[async_trait::async_trait]
impl ExecuteStageTestRunner for BodyTestRunner { impl ExecuteStageTestRunner for BodyTestRunner {
type Seed = Vec<BlockLocked>; type Seed = Vec<SealedBlock>;
fn seed_execution(&mut self, input: ExecInput) -> Result<Self::Seed, TestRunnerError> { fn seed_execution(&mut self, input: ExecInput) -> Result<Self::Seed, TestRunnerError> {
let start = input.stage_progress.unwrap_or_default(); let start = input.stage_progress.unwrap_or_default();
@ -841,7 +841,7 @@ mod tests {
.get(&header.hash()) .get(&header.hash())
.expect("Stage tried downloading a block we do not have.") .expect("Stage tried downloading a block we do not have.")
.clone()?; .clone()?;
Ok(BlockResponse::Full(BlockLocked { Ok(BlockResponse::Full(SealedBlock {
header: header.clone(), header: header.clone(),
body: result.transactions, body: result.transactions,
ommers: result.ommers.into_iter().map(|header| header.seal()).collect(), ommers: result.ommers.into_iter().map(|header| header.seal()).collect(),

View File

@ -375,7 +375,7 @@ mod tests {
use super::*; use super::*;
use reth_db::mdbx::{test_utils::create_test_db, EnvKind, WriteMap}; use reth_db::mdbx::{test_utils::create_test_db, EnvKind, WriteMap};
use reth_primitives::{hex_literal::hex, keccak256, Account, BlockLocked, H160, U256}; use reth_primitives::{hex_literal::hex, keccak256, Account, SealedBlock, H160, U256};
use reth_provider::insert_canonical_block; use reth_provider::insert_canonical_block;
use reth_rlp::Decodable; use reth_rlp::Decodable;
@ -391,9 +391,9 @@ mod tests {
stage_progress: None, stage_progress: None,
}; };
let mut genesis_rlp = hex!("f901faf901f5a00000000000000000000000000000000000000000000000000000000000000000a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347942adc25665018aa1fe0e6bc666dac8fc2697ff9baa045571b40ae66ca7480791bbb2887286e4e4c4b1b298b191c889d6959023a32eda056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b901000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000083020000808502540be400808000a00000000000000000000000000000000000000000000000000000000000000000880000000000000000c0c0").as_slice(); let mut genesis_rlp = hex!("f901faf901f5a00000000000000000000000000000000000000000000000000000000000000000a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347942adc25665018aa1fe0e6bc666dac8fc2697ff9baa045571b40ae66ca7480791bbb2887286e4e4c4b1b298b191c889d6959023a32eda056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b901000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000083020000808502540be400808000a00000000000000000000000000000000000000000000000000000000000000000880000000000000000c0c0").as_slice();
let genesis = BlockLocked::decode(&mut genesis_rlp).unwrap(); let genesis = SealedBlock::decode(&mut genesis_rlp).unwrap();
let mut block_rlp = hex!("f90262f901f9a075c371ba45999d87f4542326910a11af515897aebce5265d3f6acd1f1161f82fa01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347942adc25665018aa1fe0e6bc666dac8fc2697ff9baa098f2dcd87c8ae4083e7017a05456c14eea4b1db2032126e27b3b1563d57d7cc0a08151d548273f6683169524b66ca9fe338b9ce42bc3540046c828fd939ae23bcba03f4e5c2ec5b2170b711d97ee755c160457bb58d8daa338e835ec02ae6860bbabb901000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000083020000018502540be40082a8798203e800a00000000000000000000000000000000000000000000000000000000000000000880000000000000000f863f861800a8405f5e10094100000000000000000000000000000000000000080801ba07e09e26678ed4fac08a249ebe8ed680bf9051a5e14ad223e4b2b9d26e0208f37a05f6e3f188e3e6eab7d7d3b6568f5eac7d687b08d307d3154ccd8c87b4630509bc0").as_slice(); let mut block_rlp = hex!("f90262f901f9a075c371ba45999d87f4542326910a11af515897aebce5265d3f6acd1f1161f82fa01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347942adc25665018aa1fe0e6bc666dac8fc2697ff9baa098f2dcd87c8ae4083e7017a05456c14eea4b1db2032126e27b3b1563d57d7cc0a08151d548273f6683169524b66ca9fe338b9ce42bc3540046c828fd939ae23bcba03f4e5c2ec5b2170b711d97ee755c160457bb58d8daa338e835ec02ae6860bbabb901000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000083020000018502540be40082a8798203e800a00000000000000000000000000000000000000000000000000000000000000000880000000000000000f863f861800a8405f5e10094100000000000000000000000000000000000000080801ba07e09e26678ed4fac08a249ebe8ed680bf9051a5e14ad223e4b2b9d26e0208f37a05f6e3f188e3e6eab7d7d3b6568f5eac7d687b08d307d3154ccd8c87b4630509bc0").as_slice();
let block = BlockLocked::decode(&mut block_rlp).unwrap(); let block = SealedBlock::decode(&mut block_rlp).unwrap();
insert_canonical_block(tx.deref_mut(), &genesis, true).unwrap(); insert_canonical_block(tx.deref_mut(), &genesis, true).unwrap();
insert_canonical_block(tx.deref_mut(), &block, true).unwrap(); insert_canonical_block(tx.deref_mut(), &block, true).unwrap();
tx.commit().unwrap(); tx.commit().unwrap();
@ -476,9 +476,9 @@ mod tests {
stage_progress: None, stage_progress: None,
}; };
let mut genesis_rlp = hex!("f901faf901f5a00000000000000000000000000000000000000000000000000000000000000000a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347942adc25665018aa1fe0e6bc666dac8fc2697ff9baa045571b40ae66ca7480791bbb2887286e4e4c4b1b298b191c889d6959023a32eda056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b901000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000083020000808502540be400808000a00000000000000000000000000000000000000000000000000000000000000000880000000000000000c0c0").as_slice(); let mut genesis_rlp = hex!("f901faf901f5a00000000000000000000000000000000000000000000000000000000000000000a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347942adc25665018aa1fe0e6bc666dac8fc2697ff9baa045571b40ae66ca7480791bbb2887286e4e4c4b1b298b191c889d6959023a32eda056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b901000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000083020000808502540be400808000a00000000000000000000000000000000000000000000000000000000000000000880000000000000000c0c0").as_slice();
let genesis = BlockLocked::decode(&mut genesis_rlp).unwrap(); let genesis = SealedBlock::decode(&mut genesis_rlp).unwrap();
let mut block_rlp = hex!("f90262f901f9a075c371ba45999d87f4542326910a11af515897aebce5265d3f6acd1f1161f82fa01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347942adc25665018aa1fe0e6bc666dac8fc2697ff9baa098f2dcd87c8ae4083e7017a05456c14eea4b1db2032126e27b3b1563d57d7cc0a08151d548273f6683169524b66ca9fe338b9ce42bc3540046c828fd939ae23bcba03f4e5c2ec5b2170b711d97ee755c160457bb58d8daa338e835ec02ae6860bbabb901000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000083020000018502540be40082a8798203e800a00000000000000000000000000000000000000000000000000000000000000000880000000000000000f863f861800a8405f5e10094100000000000000000000000000000000000000080801ba07e09e26678ed4fac08a249ebe8ed680bf9051a5e14ad223e4b2b9d26e0208f37a05f6e3f188e3e6eab7d7d3b6568f5eac7d687b08d307d3154ccd8c87b4630509bc0").as_slice(); let mut block_rlp = hex!("f90262f901f9a075c371ba45999d87f4542326910a11af515897aebce5265d3f6acd1f1161f82fa01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347942adc25665018aa1fe0e6bc666dac8fc2697ff9baa098f2dcd87c8ae4083e7017a05456c14eea4b1db2032126e27b3b1563d57d7cc0a08151d548273f6683169524b66ca9fe338b9ce42bc3540046c828fd939ae23bcba03f4e5c2ec5b2170b711d97ee755c160457bb58d8daa338e835ec02ae6860bbabb901000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000083020000018502540be40082a8798203e800a00000000000000000000000000000000000000000000000000000000000000000880000000000000000f863f861800a8405f5e10094100000000000000000000000000000000000000080801ba07e09e26678ed4fac08a249ebe8ed680bf9051a5e14ad223e4b2b9d26e0208f37a05f6e3f188e3e6eab7d7d3b6568f5eac7d687b08d307d3154ccd8c87b4630509bc0").as_slice();
let block = BlockLocked::decode(&mut block_rlp).unwrap(); let block = SealedBlock::decode(&mut block_rlp).unwrap();
insert_canonical_block(tx.deref_mut(), &genesis, true).unwrap(); insert_canonical_block(tx.deref_mut(), &genesis, true).unwrap();
insert_canonical_block(tx.deref_mut(), &block, true).unwrap(); insert_canonical_block(tx.deref_mut(), &block, true).unwrap();
tx.commit().unwrap(); tx.commit().unwrap();

View File

@ -133,7 +133,7 @@ mod tests {
use assert_matches::assert_matches; use assert_matches::assert_matches;
use reth_db::models::StoredBlockBody; use reth_db::models::StoredBlockBody;
use reth_interfaces::test_utils::generators::{random_block, random_block_range}; use reth_interfaces::test_utils::generators::{random_block, random_block_range};
use reth_primitives::{BlockLocked, BlockNumber, H256}; use reth_primitives::{BlockNumber, SealedBlock, H256};
use super::*; use super::*;
use crate::test_utils::{ use crate::test_utils::{
@ -159,7 +159,7 @@ mod tests {
let stage_progress = input.stage_progress.unwrap_or_default(); let stage_progress = input.stage_progress.unwrap_or_default();
// Insert blocks with a single transaction at block `stage_progress + 10` // Insert blocks with a single transaction at block `stage_progress + 10`
(stage_progress..input.previous_stage_progress() + 1) (stage_progress..input.previous_stage_progress() + 1)
.map(|number| -> Result<BlockLocked, TestRunnerError> { .map(|number| -> Result<SealedBlock, TestRunnerError> {
let tx_count = Some((number == stage_progress + 10) as u8); let tx_count = Some((number == stage_progress + 10) as u8);
let block = random_block(number, None, tx_count); let block = random_block(number, None, tx_count);
current_tx_id = runner.insert_block(current_tx_id, &block, false)?; current_tx_id = runner.insert_block(current_tx_id, &block, false)?;
@ -251,7 +251,7 @@ mod tests {
} }
impl ExecuteStageTestRunner for SenderRecoveryTestRunner { impl ExecuteStageTestRunner for SenderRecoveryTestRunner {
type Seed = Vec<BlockLocked>; type Seed = Vec<SealedBlock>;
fn seed_execution(&mut self, input: ExecInput) -> Result<Self::Seed, TestRunnerError> { fn seed_execution(&mut self, input: ExecInput) -> Result<Self::Seed, TestRunnerError> {
let stage_progress = input.stage_progress.unwrap_or_default(); let stage_progress = input.stage_progress.unwrap_or_default();
@ -332,7 +332,7 @@ mod tests {
fn insert_block( fn insert_block(
&self, &self,
tx_offset: u64, tx_offset: u64,
block: &BlockLocked, block: &SealedBlock,
insert_senders: bool, insert_senders: bool,
) -> Result<u64, TestRunnerError> { ) -> Result<u64, TestRunnerError> {
let mut current_tx_id = tx_offset; let mut current_tx_id = tx_offset;

View File

@ -7,7 +7,7 @@ use reth_db::{
use reth_interfaces::{provider::Error as ProviderError, Result}; use reth_interfaces::{provider::Error as ProviderError, Result};
use reth_primitives::{ use reth_primitives::{
rpc::{BlockId, BlockNumber}, rpc::{BlockId, BlockNumber},
Block, BlockHash, BlockHashOrNumber, BlockLocked, Header, H256, U256, Block, BlockHash, BlockHashOrNumber, Header, SealedBlock, H256, U256,
}; };
/// Client trait for fetching `Header` related data. /// Client trait for fetching `Header` related data.
@ -115,7 +115,7 @@ pub struct ChainInfo {
/// [tables::CumulativeTxCount] and [tables::BlockBodies] /// [tables::CumulativeTxCount] and [tables::BlockBodies]
pub fn insert_canonical_block<'a, TX: DbTxMut<'a> + DbTx<'a>>( pub fn insert_canonical_block<'a, TX: DbTxMut<'a> + DbTx<'a>>(
tx: &TX, tx: &TX,
block: &BlockLocked, block: &SealedBlock,
has_block_reward: bool, has_block_reward: bool,
) -> Result<()> { ) -> Result<()> {
let block_num_hash = BlockNumHash((block.number, block.hash())); let block_num_hash = BlockNumHash((block.number, block.hash()));