Skip to content

Commit

Permalink
nit
Browse files Browse the repository at this point in the history
  • Loading branch information
Wizdave97 committed Dec 26, 2023
1 parent 8b9bef8 commit 3de3a08
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 22 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions parachain/modules/consensus/polygon-pos/prover/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
name = "polygon-pos-prover"
version = "0.1.0"
edition = "2021"
authors = ["Polytope Labs"]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand Down
25 changes: 3 additions & 22 deletions parachain/modules/consensus/polygon-pos/prover/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ use anyhow::anyhow;
use ethers::{
prelude::{Provider, Ws},
providers::Middleware,
types::BlockId,
types::{Block, BlockId},
};
use polygon_pos_verifier::primitives::{parse_validators, CodecHeader, SPAN_LENGTH};
use primitive_types::H160;
use primitive_types::{H160, H256};
use std::{collections::BTreeSet, fmt::Debug, sync::Arc};

#[cfg(test)]
Expand All @@ -31,26 +31,7 @@ impl PolygonPosProver {
.get_block(block)
.await?
.ok_or_else(|| anyhow!("Header not found for {:?}", block))?;
let header = CodecHeader {
parent_hash: block.parent_hash,
uncle_hash: block.uncles_hash,
coinbase: block.author.unwrap_or_default(),
state_root: block.state_root,
transactions_root: block.transactions_root,
receipts_root: block.receipts_root,
logs_bloom: block.logs_bloom.unwrap_or_default(),
difficulty: block.difficulty,
number: block.number.unwrap_or_default().as_u64().into(),
gas_limit: block.gas_limit.low_u64(),
gas_used: block.gas_used.low_u64(),
timestamp: block.timestamp.low_u64(),
extra_data: block.extra_data.0.into(),
mix_hash: block.mix_hash.unwrap_or_default(),
nonce: block.nonce.unwrap_or_default(),
base_fee_per_gas: block.base_fee_per_gas,
withdrawals_hash: block.withdrawals_root,
excess_data_gas: block.excess_blob_gas,
};
let header: CodecHeader = block.into();

Ok(header)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ ethabi = { version = "18.0.0", features = ["rlp", "parity-codec"], default-featu
ismp = { path = "../../../ismp/core", default-features = false }
scale-info = { version = "2.1.1", default-features = false, features = ["derive"] }
sp-io = { version = "27.0.0", default-features = false }
ethers = { version = "2.0.8", default-features = false }

[features]
default = ["std"]
Expand Down
26 changes: 26 additions & 0 deletions parachain/modules/consensus/polygon-pos/verifier/src/primitives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use alloy_primitives::{Address, FixedBytes, B256};
use alloy_rlp_derive::{RlpDecodable, RlpEncodable};
use anyhow::anyhow;
use ethabi::ethereum_types::{Bloom, H160, H256, H64, U256};
use ethers::types::Block;
use ismp::util::Keccak256;

const EXTRA_VANITY_LENGTH: usize = 32;
Expand Down Expand Up @@ -54,6 +55,31 @@ pub struct CodecHeader {
pub excess_data_gas: Option<U256>,
}

impl From<Block<H256>> for CodecHeader {
fn from(block: Block<H256>) -> Self {
CodecHeader {
parent_hash: block.parent_hash,
uncle_hash: block.uncles_hash,
coinbase: block.author.unwrap_or_default(),
state_root: block.state_root,
transactions_root: block.transactions_root,
receipts_root: block.receipts_root,
logs_bloom: block.logs_bloom.unwrap_or_default(),
difficulty: block.difficulty,
number: block.number.unwrap_or_default().as_u64().into(),
gas_limit: block.gas_limit.low_u64(),
gas_used: block.gas_used.low_u64(),
timestamp: block.timestamp.low_u64(),
extra_data: block.extra_data.0.into(),
mix_hash: block.mix_hash.unwrap_or_default(),
nonce: block.nonce.unwrap_or_default(),
base_fee_per_gas: block.base_fee_per_gas,
withdrawals_hash: block.withdrawals_root,
excess_data_gas: block.excess_blob_gas,
}
}
}

impl From<&CodecHeader> for Header {
fn from(value: &CodecHeader) -> Self {
Header {
Expand Down

0 comments on commit 3de3a08

Please sign in to comment.