From 2754315e68bbe14d3d3f687e4d31ce4f68a421f1 Mon Sep 17 00:00:00 2001 From: Bjerg Date: Fri, 11 Nov 2022 07:46:09 +0100 Subject: [PATCH] chore: omner -> ommer (#192) * chore: omner -> ommer * chore: missmatch -> mismatch * chore: other typos --- bin/reth/src/test_eth_chain/models.rs | 2 +- crates/consensus/src/proofs.rs | 8 ++++---- crates/consensus/src/verification.rs | 23 ++++++++++++----------- crates/interfaces/src/consensus.rs | 8 ++++---- crates/primitives/src/block.rs | 2 +- 5 files changed, 22 insertions(+), 21 deletions(-) diff --git a/bin/reth/src/test_eth_chain/models.rs b/bin/reth/src/test_eth_chain/models.rs index d0bd2503e..2c3c38f96 100644 --- a/bin/reth/src/test_eth_chain/models.rs +++ b/bin/reth/src/test_eth_chain/models.rs @@ -81,7 +81,7 @@ pub struct Block { pub rlp: Bytes, /// Transactions pub transactions: Option>, - /// Uncle/Omner headers. + /// Uncle/ommer headers pub uncle_headers: Option>, } diff --git a/crates/consensus/src/proofs.rs b/crates/consensus/src/proofs.rs index 59a0f78f6..964cc8159 100644 --- a/crates/consensus/src/proofs.rs +++ b/crates/consensus/src/proofs.rs @@ -75,14 +75,14 @@ pub fn calculate_log_root<'a>(logs: impl IntoIterator) -> H256 { H256::from_slice(out.as_slice()) } -/// Calculate hash over omners/uncles headers -pub fn calculate_omners_root<'a>(_omners: impl IntoIterator) -> H256 { +/// Calculate hash for ommer/uncle headers +pub fn calculate_ommers_root<'a>(_ommers: impl IntoIterator) -> H256 { // RLP Encode let mut stream = RlpStream::new(); stream.begin_unbounded_list(); /* TODO - for omner in omners { - stream.append(omner) + for ommer in ommers { + stream.append(ommer) } */ stream.finalize_unbounded_list(); diff --git a/crates/consensus/src/verification.rs b/crates/consensus/src/verification.rs index f7bfdd7ed..27428f716 100644 --- a/crates/consensus/src/verification.rs +++ b/crates/consensus/src/verification.rs @@ -34,7 +34,7 @@ pub fn validate_header_standalone( Ok(()) } -/// Validate transactions standlone +/// Validate transactions standalone pub fn validate_transactions_standalone( transaction: &Transaction, config: &Config, @@ -62,13 +62,14 @@ pub fn validate_transactions_standalone( Ok(()) } -/// Validate transaction in regards to header -/// Only parametar from header that effects transaction is base_fee +/// Validate a transaction in regards to a block header. +/// +/// The only parameter from the header that affects the transaction is `base_fee`. pub fn validate_transaction_regarding_header( transaction: &Transaction, base_fee: Option, ) -> Result<(), Error> { - // check basefee and few checks that are related to that. + // check base fee and few checks that are related to that. // https://github.com/ethereum/EIPs/pull/3594 if let Some(base_fee_per_gas) = base_fee { if transaction.max_fee_per_gas() < base_fee_per_gas { @@ -116,11 +117,11 @@ pub fn validate_transaction_regarding_state( /// Validate block standalone pub fn validate_block_standalone(block: &BlockLocked) -> Result<(), Error> { - // check omners hash - let omners_hash = crate::proofs::calculate_omners_root(block.ommers.iter().map(|h| h.as_ref())); - if block.header.ommers_hash != omners_hash { - return Err(Error::BodyOmmnersHashDiff { - got: omners_hash, + // check ommers hash + let ommers_hash = crate::proofs::calculate_ommers_root(block.ommers.iter().map(|h| h.as_ref())); + if block.header.ommers_hash != ommers_hash { + return Err(Error::BodyOmmersHashDiff { + got: ommers_hash, expected: block.header.ommers_hash, }) } @@ -185,7 +186,7 @@ pub fn validate_header_regarding_parent( ) -> Result<(), Error> { // Parent number is consistent. if parent.number + 1 != child.number { - return Err(Error::ParentBlockNumberMissmatch { + return Err(Error::ParentBlockNumberMismatch { parent_block_number: parent.number, block_number: child.number, }) @@ -361,7 +362,7 @@ mod tests { transactions_root: hex!("56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421").into(), receipts_root: hex!("56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421").into(), logs_bloom: hex!("002400000000004000220000800002000000000000000000000000000000100000000000000000100000000000000021020000000800000006000000002100040000000c0004000000000008000008200000000000000000000000008000000001040000020000020000002000000800000002000020000000022010000000000000010002001000000000020200000000000001000200880000004000000900020000000000020000000040000000000000000000000000000080000000000001000002000000000000012000200020000000000000001000000000000020000010321400000000100000000000000000000000000000400000000000000000").into(), - difficulty: 0x00.into(), // total diffuculty: 0xc70d815d562d3cfa955).into(), + difficulty: 0x00.into(), // total difficulty: 0xc70d815d562d3cfa955).into(), number: 0xf21d20, gas_limit: 0x1c9c380, gas_used: 0x6e813, diff --git a/crates/interfaces/src/consensus.rs b/crates/interfaces/src/consensus.rs index c2ad8b183..ac82fce85 100644 --- a/crates/interfaces/src/consensus.rs +++ b/crates/interfaces/src/consensus.rs @@ -23,8 +23,8 @@ pub trait Consensus: Send + Sync { pub enum Error { #[error("Block used gas ({gas_used:?}) is greater then gas limit ({gas_limit:?})")] HeaderGasUsedExceedsGasLimit { gas_used: u64, gas_limit: u64 }, - #[error("Block ommner hash ({got:?}) is different then expected: ({expected:?})")] - BodyOmmnersHashDiff { got: H256, expected: H256 }, + #[error("Block ommer hash ({got:?}) is different then expected: ({expected:?})")] + BodyOmmersHashDiff { got: H256, expected: H256 }, #[error("Block transaction root ({got:?}) is different then expected: ({expected:?})")] BodyTransactionRootDiff { got: H256, expected: H256 }, #[error("Block receipts root ({got:?}) is different then expected: ({expected:?})")] @@ -33,8 +33,8 @@ pub enum Error { BlockKnown { hash: BlockHash, number: BlockNumber }, #[error("Block parent [hash:{hash:?}] is not known")] ParentUnknown { hash: BlockHash }, - #[error("Block number {block_number:?} is missmatch with parent block number {parent_block_number:?}")] - ParentBlockNumberMissmatch { parent_block_number: BlockNumber, block_number: BlockNumber }, + #[error("Block number {block_number:?} is mismatch with parent block number {parent_block_number:?}")] + ParentBlockNumberMismatch { parent_block_number: BlockNumber, block_number: BlockNumber }, #[error( "Block timestamp {timestamp:?} is in past in comparison with parent timestamp {parent_timestamp:?}" )] diff --git a/crates/primitives/src/block.rs b/crates/primitives/src/block.rs index 0b9ad1082..f826880fa 100644 --- a/crates/primitives/src/block.rs +++ b/crates/primitives/src/block.rs @@ -30,7 +30,7 @@ pub struct BlockLocked { pub body: Vec, /// Block receipts. pub receipts: Vec, - /// Omners/uncles header + /// Ommer/uncle headers pub ommers: Vec, }