mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore: omner -> ommer (#192)
* chore: omner -> ommer * chore: missmatch -> mismatch * chore: other typos
This commit is contained in:
@ -81,7 +81,7 @@ pub struct Block {
|
||||
pub rlp: Bytes,
|
||||
/// Transactions
|
||||
pub transactions: Option<Vec<Transaction>>,
|
||||
/// Uncle/Omner headers.
|
||||
/// Uncle/ommer headers
|
||||
pub uncle_headers: Option<Vec<Header>>,
|
||||
}
|
||||
|
||||
|
||||
@ -75,14 +75,14 @@ pub fn calculate_log_root<'a>(logs: impl IntoIterator<Item = &'a Log>) -> H256 {
|
||||
H256::from_slice(out.as_slice())
|
||||
}
|
||||
|
||||
/// Calculate hash over omners/uncles headers
|
||||
pub fn calculate_omners_root<'a>(_omners: impl IntoIterator<Item = &'a Header>) -> H256 {
|
||||
/// Calculate hash for ommer/uncle headers
|
||||
pub fn calculate_ommers_root<'a>(_ommers: impl IntoIterator<Item = &'a Header>) -> 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();
|
||||
|
||||
@ -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<u64>,
|
||||
) -> 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<AP: AccountProvider>(
|
||||
|
||||
/// 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,
|
||||
|
||||
@ -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:?}"
|
||||
)]
|
||||
|
||||
@ -30,7 +30,7 @@ pub struct BlockLocked {
|
||||
pub body: Vec<TransactionSigned>,
|
||||
/// Block receipts.
|
||||
pub receipts: Vec<Receipt>,
|
||||
/// Omners/uncles header
|
||||
/// Ommer/uncle headers
|
||||
pub ommers: Vec<SealedHeader>,
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user