mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
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:
@ -8,7 +8,7 @@ use reth_db::{
|
||||
};
|
||||
use reth_executor::SpecUpgrades;
|
||||
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_stages::{stages::execution::ExecutionStage, ExecInput, Stage, Transaction};
|
||||
@ -102,11 +102,11 @@ pub async fn run_test(path: PathBuf) -> eyre::Result<()> {
|
||||
|
||||
// insert genesis
|
||||
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)?;
|
||||
|
||||
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)?;
|
||||
Ok(())
|
||||
})?;
|
||||
|
||||
@ -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.
|
||||
|
||||
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.
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
//! Consensus for ethereum network
|
||||
use crate::{verification, Config};
|
||||
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};
|
||||
|
||||
/// Ethereum beacon consensus
|
||||
@ -54,7 +54,7 @@ impl Consensus for BeaconConsensus {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn pre_validate_block(&self, block: &BlockLocked) -> Result<(), Error> {
|
||||
fn pre_validate_block(&self, block: &SealedBlock) -> Result<(), Error> {
|
||||
verification::validate_block_standalone(block)
|
||||
}
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
use crate::{config, Config};
|
||||
use reth_interfaces::{consensus::Error, Result as RethResult};
|
||||
use reth_primitives::{
|
||||
BlockLocked, BlockNumber, Header, SealedHeader, Transaction, TransactionSignedEcRecovered,
|
||||
BlockNumber, Header, SealedBlock, SealedHeader, Transaction, TransactionSignedEcRecovered,
|
||||
TxEip1559, TxEip2930, TxLegacy, EMPTY_OMMER_ROOT, H256, U256,
|
||||
};
|
||||
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
|
||||
/// - Pre-execution transaction validation
|
||||
/// - (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
|
||||
// TODO(onbjerg): This should probably be accessible directly on [Block]
|
||||
let ommers_hash =
|
||||
@ -313,7 +313,7 @@ pub fn validate_header_regarding_parent(
|
||||
///
|
||||
/// Returns parent block header
|
||||
pub fn validate_block_regarding_chain<PROV: HeaderProvider>(
|
||||
block: &BlockLocked,
|
||||
block: &SealedBlock,
|
||||
provider: &PROV,
|
||||
) -> RethResult<SealedHeader> {
|
||||
let hash = block.header.hash();
|
||||
@ -334,7 +334,7 @@ pub fn validate_block_regarding_chain<PROV: HeaderProvider>(
|
||||
|
||||
/// Full validation of block before execution.
|
||||
pub fn full_validation<Provider: HeaderProvider + AccountProvider>(
|
||||
block: &BlockLocked,
|
||||
block: &SealedBlock,
|
||||
provider: Provider,
|
||||
config: &Config,
|
||||
) -> RethResult<()> {
|
||||
@ -456,7 +456,7 @@ mod tests {
|
||||
TransactionSignedEcRecovered::from_signed_transaction(tx, signer)
|
||||
}
|
||||
/// 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
|
||||
// empty merkle tree: 0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421
|
||||
|
||||
@ -489,7 +489,7 @@ mod tests {
|
||||
let ommers = Vec::new();
|
||||
let body = Vec::new();
|
||||
|
||||
(BlockLocked { header: header.seal(), body, ommers }, parent)
|
||||
(SealedBlock { header: header.seal(), body, ommers }, parent)
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@ -418,7 +418,7 @@ mod tests {
|
||||
transaction::DbTx,
|
||||
};
|
||||
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,
|
||||
};
|
||||
use reth_provider::{AccountProvider, StateProvider};
|
||||
@ -484,7 +484,7 @@ mod tests {
|
||||
// Got rlp block from: src/GeneralStateTestsFiller/stChainId/chainIdGasCostFiller.json
|
||||
|
||||
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();
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
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;
|
||||
|
||||
/// Re-export forkchoice state
|
||||
@ -24,7 +24,7 @@ pub trait Consensus: Send + Sync {
|
||||
/// 11.1 "Ommer Validation".
|
||||
///
|
||||
/// **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.
|
||||
/// This flag is needed as reth change set is indexed of transaction granularity
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
use crate::p2p::downloader::{DownloadStream, Downloader};
|
||||
use reth_primitives::{BlockLocked, SealedHeader};
|
||||
use reth_primitives::{SealedBlock, SealedHeader};
|
||||
|
||||
/// The block response
|
||||
#[derive(PartialEq, Eq, Debug)]
|
||||
pub enum BlockResponse {
|
||||
/// Full block response (with transactions or ommers)
|
||||
Full(BlockLocked),
|
||||
Full(SealedBlock),
|
||||
/// The empty block response
|
||||
Empty(SealedHeader),
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
use rand::{distributions::uniform::SampleRange, thread_rng, Rng};
|
||||
use reth_primitives::{
|
||||
proofs, Address, BlockLocked, Bytes, Header, SealedHeader, Signature, Transaction,
|
||||
proofs, Address, Bytes, Header, SealedBlock, SealedHeader, Signature, Transaction,
|
||||
TransactionKind, TransactionSigned, TxLegacy, H256, U256,
|
||||
};
|
||||
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.
|
||||
///
|
||||
/// 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();
|
||||
|
||||
// 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 ommers_hash = proofs::calculate_ommers_root(ommers.iter());
|
||||
|
||||
BlockLocked {
|
||||
SealedBlock {
|
||||
header: Header {
|
||||
parent_hash: parent.unwrap_or_default(),
|
||||
number,
|
||||
@ -145,14 +145,14 @@ pub fn random_block_range(
|
||||
block_numbers: std::ops::Range<u64>,
|
||||
head: H256,
|
||||
tx_count: std::ops::Range<u8>,
|
||||
) -> Vec<BlockLocked> {
|
||||
) -> Vec<SealedBlock> {
|
||||
let mut rng = rand::thread_rng();
|
||||
let mut blocks =
|
||||
Vec::with_capacity(block_numbers.end.saturating_sub(block_numbers.start) as usize);
|
||||
for idx in block_numbers {
|
||||
blocks.push(random_block(
|
||||
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)),
|
||||
));
|
||||
}
|
||||
|
||||
@ -13,7 +13,7 @@ use crate::{
|
||||
use futures::{Future, FutureExt, Stream};
|
||||
use reth_eth_wire::BlockHeaders;
|
||||
use reth_primitives::{
|
||||
BlockLocked, BlockNumber, Header, HeadersDirection, PeerId, SealedHeader, H256,
|
||||
BlockNumber, Header, HeadersDirection, PeerId, SealedBlock, SealedHeader, H256,
|
||||
};
|
||||
use reth_rpc_types::engine::ForkchoiceState;
|
||||
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() {
|
||||
Err(consensus::Error::BaseFeeMissing)
|
||||
} else {
|
||||
|
||||
@ -11,7 +11,7 @@ use reth_interfaces::{
|
||||
error::{DownloadError, DownloadResult, RequestError},
|
||||
},
|
||||
};
|
||||
use reth_primitives::{BlockLocked, SealedHeader};
|
||||
use reth_primitives::{SealedBlock, SealedHeader};
|
||||
use std::{borrow::Borrow, sync::Arc};
|
||||
|
||||
/// Downloads bodies in batches.
|
||||
@ -158,7 +158,7 @@ where
|
||||
}
|
||||
};
|
||||
|
||||
let block = BlockLocked {
|
||||
let block = SealedBlock {
|
||||
header: header.clone(),
|
||||
body: body.transactions,
|
||||
ommers: body.ommers.into_iter().map(|header| header.seal()).collect(),
|
||||
@ -247,7 +247,7 @@ mod tests {
|
||||
if header.is_empty() {
|
||||
BlockResponse::Empty(header)
|
||||
} else {
|
||||
BlockResponse::Full(BlockLocked {
|
||||
BlockResponse::Full(SealedBlock {
|
||||
header,
|
||||
body: body.transactions,
|
||||
ommers: body.ommers.into_iter().map(|o| o.seal()).collect(),
|
||||
|
||||
@ -22,9 +22,9 @@ impl Deref for Block {
|
||||
}
|
||||
|
||||
/// Sealed Ethereum full block.
|
||||
// ANCHOR: struct-BlockLocked
|
||||
// ANCHOR: struct-SealedBlock
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Default, RlpEncodable, RlpDecodable)]
|
||||
pub struct BlockLocked {
|
||||
pub struct SealedBlock {
|
||||
/// Locked block header.
|
||||
pub header: SealedHeader,
|
||||
/// Transactions with signatures.
|
||||
@ -32,16 +32,16 @@ pub struct BlockLocked {
|
||||
/// Ommer/uncle headers
|
||||
pub ommers: Vec<SealedHeader>,
|
||||
}
|
||||
// ANCHOR_END: struct-BlockLocked
|
||||
// ANCHOR_END: struct-SealedBlock
|
||||
|
||||
impl BlockLocked {
|
||||
impl SealedBlock {
|
||||
/// Header hash.
|
||||
pub fn hash(&self) -> H256 {
|
||||
self.header.hash()
|
||||
}
|
||||
}
|
||||
|
||||
impl Deref for BlockLocked {
|
||||
impl Deref for SealedBlock {
|
||||
type Target = Header;
|
||||
fn deref(&self) -> &Self::Target {
|
||||
self.header.as_ref()
|
||||
|
||||
@ -31,7 +31,7 @@ mod transaction;
|
||||
pub mod proofs;
|
||||
|
||||
pub use account::Account;
|
||||
pub use block::{Block, BlockHashOrNumber, BlockLocked};
|
||||
pub use block::{Block, BlockHashOrNumber, SealedBlock};
|
||||
pub use chain::Chain;
|
||||
pub use constants::{EMPTY_OMMER_ROOT, KECCAK_EMPTY, MAINNET_GENESIS};
|
||||
pub use ethbloom::Bloom;
|
||||
|
||||
@ -557,14 +557,14 @@ mod tests {
|
||||
TestConsensus,
|
||||
},
|
||||
};
|
||||
use reth_primitives::{BlockLocked, BlockNumber, SealedHeader, TxNumber, H256};
|
||||
use reth_primitives::{BlockNumber, SealedBlock, SealedHeader, TxNumber, H256};
|
||||
use std::{collections::HashMap, sync::Arc};
|
||||
|
||||
/// The block hash of the genesis block.
|
||||
pub(crate) const GENESIS_HASH: H256 = H256::zero();
|
||||
|
||||
/// 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(),
|
||||
Ok(BlockBody {
|
||||
@ -624,7 +624,7 @@ mod tests {
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl ExecuteStageTestRunner for BodyTestRunner {
|
||||
type Seed = Vec<BlockLocked>;
|
||||
type Seed = Vec<SealedBlock>;
|
||||
|
||||
fn seed_execution(&mut self, input: ExecInput) -> Result<Self::Seed, TestRunnerError> {
|
||||
let start = input.stage_progress.unwrap_or_default();
|
||||
@ -841,7 +841,7 @@ mod tests {
|
||||
.get(&header.hash())
|
||||
.expect("Stage tried downloading a block we do not have.")
|
||||
.clone()?;
|
||||
Ok(BlockResponse::Full(BlockLocked {
|
||||
Ok(BlockResponse::Full(SealedBlock {
|
||||
header: header.clone(),
|
||||
body: result.transactions,
|
||||
ommers: result.ommers.into_iter().map(|header| header.seal()).collect(),
|
||||
|
||||
@ -375,7 +375,7 @@ mod tests {
|
||||
|
||||
use super::*;
|
||||
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_rlp::Decodable;
|
||||
|
||||
@ -391,9 +391,9 @@ mod tests {
|
||||
stage_progress: None,
|
||||
};
|
||||
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 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(), &block, true).unwrap();
|
||||
tx.commit().unwrap();
|
||||
@ -476,9 +476,9 @@ mod tests {
|
||||
stage_progress: None,
|
||||
};
|
||||
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 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(), &block, true).unwrap();
|
||||
tx.commit().unwrap();
|
||||
|
||||
@ -133,7 +133,7 @@ mod tests {
|
||||
use assert_matches::assert_matches;
|
||||
use reth_db::models::StoredBlockBody;
|
||||
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 crate::test_utils::{
|
||||
@ -159,7 +159,7 @@ mod tests {
|
||||
let stage_progress = input.stage_progress.unwrap_or_default();
|
||||
// Insert blocks with a single transaction at block `stage_progress + 10`
|
||||
(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 block = random_block(number, None, tx_count);
|
||||
current_tx_id = runner.insert_block(current_tx_id, &block, false)?;
|
||||
@ -251,7 +251,7 @@ mod tests {
|
||||
}
|
||||
|
||||
impl ExecuteStageTestRunner for SenderRecoveryTestRunner {
|
||||
type Seed = Vec<BlockLocked>;
|
||||
type Seed = Vec<SealedBlock>;
|
||||
|
||||
fn seed_execution(&mut self, input: ExecInput) -> Result<Self::Seed, TestRunnerError> {
|
||||
let stage_progress = input.stage_progress.unwrap_or_default();
|
||||
@ -332,7 +332,7 @@ mod tests {
|
||||
fn insert_block(
|
||||
&self,
|
||||
tx_offset: u64,
|
||||
block: &BlockLocked,
|
||||
block: &SealedBlock,
|
||||
insert_senders: bool,
|
||||
) -> Result<u64, TestRunnerError> {
|
||||
let mut current_tx_id = tx_offset;
|
||||
|
||||
@ -7,7 +7,7 @@ use reth_db::{
|
||||
use reth_interfaces::{provider::Error as ProviderError, Result};
|
||||
use reth_primitives::{
|
||||
rpc::{BlockId, BlockNumber},
|
||||
Block, BlockHash, BlockHashOrNumber, BlockLocked, Header, H256, U256,
|
||||
Block, BlockHash, BlockHashOrNumber, Header, SealedBlock, H256, U256,
|
||||
};
|
||||
|
||||
/// Client trait for fetching `Header` related data.
|
||||
@ -115,7 +115,7 @@ pub struct ChainInfo {
|
||||
/// [tables::CumulativeTxCount] and [tables::BlockBodies]
|
||||
pub fn insert_canonical_block<'a, TX: DbTxMut<'a> + DbTx<'a>>(
|
||||
tx: &TX,
|
||||
block: &BlockLocked,
|
||||
block: &SealedBlock,
|
||||
has_block_reward: bool,
|
||||
) -> Result<()> {
|
||||
let block_num_hash = BlockNumHash((block.number, block.hash()));
|
||||
|
||||
Reference in New Issue
Block a user