Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 18 additions & 18 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ signet-rpc = { version = "0.16.0-rc.7", path = "crates/rpc" }

init4-bin-base = { version = "0.18.0-rc.8", features = ["alloy"] }

signet-bundle = "0.16.0-rc.11"
signet-constants = "0.16.0-rc.11"
signet-evm = "0.16.0-rc.11"
signet-extract = "0.16.0-rc.11"
signet-test-utils = "0.16.0-rc.11"
signet-tx-cache = "0.16.0-rc.11"
signet-types = "0.16.0-rc.11"
signet-zenith = "0.16.0-rc.11"
signet-journal = "0.16.0-rc.11"
signet-bundle = "0.16.0-rc.14"
signet-constants = "0.16.0-rc.14"
signet-evm = "0.16.0-rc.14"
signet-extract = "0.16.0-rc.14"
signet-test-utils = "0.16.0-rc.14"
signet-tx-cache = "0.16.0-rc.14"
signet-types = "0.16.0-rc.14"
signet-zenith = "0.16.0-rc.14"
signet-journal = "0.16.0-rc.14"
signet-storage = "0.6.5"
signet-cold = "0.6.5"
signet-hot = "0.6.5"
Expand Down Expand Up @@ -114,14 +114,14 @@ url = "2.5.4"
tempfile = "3.17.0"

[patch.crates-io]
# signet-bundle = { path = "../sdk/crates/bundle"}
# signet-constants = { path = "../sdk/crates/constants"}
# signet-evm = { path = "../sdk/crates/evm"}
# signet-extract = { path = "../sdk/crates/extract"}
# signet-journal = { path = "../sdk/crates/journal"}
# signet-test-utils = { path = "../sdk/crates/test-utils"}
# signet-tx-cache = { path = "../sdk/crates/tx-cache"}
# signet-types = { path = "../sdk/crates/types"}
# signet-zenith = { path = "../sdk/crates/zenith"}
signet-bundle = { git = "https://github.com/init4tech/signet-sdk.git", branch = "feat/extractable-metadata"}
signet-constants = { git = "https://github.com/init4tech/signet-sdk.git", branch = "feat/extractable-metadata"}
signet-evm = { git = "https://github.com/init4tech/signet-sdk.git", branch = "feat/extractable-metadata"}
signet-extract = { git = "https://github.com/init4tech/signet-sdk.git", branch = "feat/extractable-metadata"}
signet-journal = { git = "https://github.com/init4tech/signet-sdk.git", branch = "feat/extractable-metadata"}
signet-test-utils = { git = "https://github.com/init4tech/signet-sdk.git", branch = "feat/extractable-metadata"}
signet-tx-cache = { git = "https://github.com/init4tech/signet-sdk.git", branch = "feat/extractable-metadata"}
signet-types = { git = "https://github.com/init4tech/signet-sdk.git", branch = "feat/extractable-metadata"}
signet-zenith = { git = "https://github.com/init4tech/signet-sdk.git", branch = "feat/extractable-metadata"}

# init4-bin-base = { path = "../shared" }
11 changes: 5 additions & 6 deletions crates/blobber/src/blobs/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ use alloy::eips::eip7691::MAX_BLOBS_PER_BLOCK_ELECTRA;
use alloy::eips::merge::EPOCH_SLOTS;
use alloy::primitives::{B256, Bytes, keccak256};
use core::fmt;
use reth::transaction_pool::TransactionPool;
use reth::{network::cache::LruMap, primitives::Receipt};
use reth::{network::cache::LruMap, transaction_pool::TransactionPool};
use signet_extract::ExtractedEvent;
use signet_zenith::Zenith::BlockSubmitted;
use signet_zenith::ZenithBlock;
Expand Down Expand Up @@ -75,10 +74,10 @@ impl<Coder> CacheHandle<Coder> {

/// Fetch the blobs using [`Self::fetch_blobs`] and decode them to get the
/// Zenith block data using the provided coder.
pub async fn fetch_and_decode(
pub async fn fetch_and_decode<R>(
&self,
slot: usize,
extract: &ExtractedEvent<'_, Receipt, BlockSubmitted>,
extract: &ExtractedEvent<'_, R, BlockSubmitted>,
) -> BlobberResult<Bytes>
where
Coder: SidecarCoder + Default,
Expand Down Expand Up @@ -116,11 +115,11 @@ impl<Coder> CacheHandle<Coder> {
/// decoded (e.g., due to a malformatted blob).
/// - `Err(FetchError)` if there was an unrecoverable error fetching the
/// blobs.
pub async fn signet_block(
pub async fn signet_block<R>(
&self,
host_block_number: u64,
slot: usize,
extract: &ExtractedEvent<'_, Receipt, BlockSubmitted>,
extract: &ExtractedEvent<'_, R, BlockSubmitted>,
) -> FetchResult<ZenithBlock>
where
Coder: SidecarCoder + Default,
Expand Down
2 changes: 1 addition & 1 deletion crates/blobber/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ mod error;
pub use error::{BlobberError, BlobberResult};

mod shim;
pub use shim::ExtractableChainShim;
pub use shim::{ExtractableChainShim, RecoveredBlockShim};

#[cfg(test)]
mod test {
Expand Down
14 changes: 8 additions & 6 deletions crates/blobber/src/shim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use alloy::consensus::Block;
use reth::providers::Chain;
use signet_extract::{Extractable, HasTxns};
use signet_extract::{BlockAndReceipts, Extractable, HasTxns};
use signet_types::primitives::TransactionSigned;

/// A type alias for Reth's recovered block with a signed transaction.
Expand Down Expand Up @@ -32,14 +32,16 @@ impl<'a> Extractable for ExtractableChainShim<'a> {
type Block = RecoveredBlockShim;
type Receipt = reth::primitives::Receipt;

fn blocks_and_receipts(&self) -> impl Iterator<Item = (&Self::Block, &Vec<Self::Receipt>)> {
fn blocks_and_receipts(
&self,
) -> impl Iterator<Item = BlockAndReceipts<'_, Self::Block, Self::Receipt>> {
self.chain.blocks_and_receipts().map(|(block, receipts)| {
// SAFETY: because the shim is repr(transparent), the memory layout
// of `RecoveredBlockShim` is the same as `RethRecovered`, so we
// can safely transmute the reference.
// SAFETY: `RecoveredBlockShim` is `#[repr(transparent)]` over a
// single `RethRecovered` field, guaranteeing identical memory
// layout. This makes the reference transmute sound.
let block =
unsafe { std::mem::transmute::<&'a RethRecovered, &RecoveredBlockShim>(block) };
(block, receipts)
BlockAndReceipts { block, receipts }
})
}
}
Expand Down
7 changes: 4 additions & 3 deletions crates/block-processor/src/alias.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
use alloy::primitives::{Address, map::HashSet};
use core::future::{self, Future};
use std::sync::{Arc, Mutex};

/// Simple trait to allow checking if an address should be aliased.
pub trait AliasOracle {
/// Returns true if the given address is an alias.
fn should_alias(&self, address: Address) -> eyre::Result<bool>;
fn should_alias(&self, address: Address) -> impl Future<Output = eyre::Result<bool>> + Send;
}

impl AliasOracle for HashSet<Address> {
fn should_alias(&self, address: Address) -> eyre::Result<bool> {
Ok(self.contains(&address))
fn should_alias(&self, address: Address) -> impl Future<Output = eyre::Result<bool>> + Send {
future::ready(Ok(self.contains(&address)))
}
}

Expand Down
14 changes: 7 additions & 7 deletions crates/block-processor/src/v1/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ use alloy::{
use core::fmt;
use eyre::{ContextCompat, WrapErr};
use init4_bin_base::utils::calc::SlotCalculator;
use signet_blobber::{CacheHandle, ExtractableChainShim};
use signet_blobber::CacheHandle;
use signet_constants::SignetSystemConstants;
use signet_evm::{BlockResult, EthereumHardfork, EvmNeedsCfg, SignetDriver};
use signet_extract::Extracts;
use signet_extract::{Extractable, Extracts};
use signet_hot::{
db::HotDbRead,
model::{HotKv, HotKvRead, RevmRead},
Expand Down Expand Up @@ -114,9 +114,9 @@ where
host_height = block_extracts.host_block.number(),
has_ru_block = block_extracts.submitted.is_some(),
))]
pub async fn process_block(
pub async fn process_block<C: Extractable>(
&self,
block_extracts: &Extracts<'_, ExtractableChainShim<'_>>,
block_extracts: &Extracts<'_, C>,
) -> eyre::Result<ExecutedBlock> {
metrics::record_extracts(block_extracts);
self.run_evm(block_extracts).await
Expand All @@ -142,9 +142,9 @@ where
/// Run the EVM for a single block extraction, returning the fully
/// assembled [`ExecutedBlock`].
#[instrument(skip_all)]
async fn run_evm(
async fn run_evm<C: Extractable>(
&self,
block_extracts: &Extracts<'_, ExtractableChainShim<'_>>,
block_extracts: &Extracts<'_, C>,
) -> eyre::Result<ExecutedBlock> {
let start_time = std::time::Instant::now();
let spec_id = self.hardforks.spec_id();
Expand Down Expand Up @@ -186,7 +186,7 @@ where
let mut to_alias: HashSet<Address> = Default::default();
for transact in block_extracts.transacts() {
let addr = transact.host_sender();
if !to_alias.contains(&addr) && oracle.should_alias(addr)? {
if !to_alias.contains(&addr) && oracle.should_alias(addr).await? {
to_alias.insert(addr);
}
}
Expand Down
18 changes: 14 additions & 4 deletions crates/node/src/alias.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
use alloy::{consensus::constants::KECCAK_EMPTY, primitives::Address};
use core::fmt;
use core::{
fmt,
future::{self, Future},
};
use eyre::OptionExt;
use reth::providers::{StateProviderBox, StateProviderFactory};
use signet_block_processor::{AliasOracle, AliasOracleFactory};
Expand All @@ -16,9 +19,9 @@ impl fmt::Debug for RethAliasOracle {
}
}

impl AliasOracle for RethAliasOracle {
fn should_alias(&self, address: Address) -> eyre::Result<bool> {
// No account at this address.
impl RethAliasOracle {
/// Synchronously check whether the given address should be aliased.
fn check_alias(&self, address: Address) -> eyre::Result<bool> {
let Some(acct) = self.0.basic_account(&address)? else { return Ok(false) };
// Get the bytecode hash for this account.
let bch = match acct.bytecode_hash {
Expand All @@ -41,6 +44,13 @@ impl AliasOracle for RethAliasOracle {
}
}

impl AliasOracle for RethAliasOracle {
fn should_alias(&self, address: Address) -> impl Future<Output = eyre::Result<bool>> + Send {
let result = self.check_alias(address);
future::ready(result)
}
}

/// An [`AliasOracleFactory`] backed by a `Box<dyn StateProviderFactory>`.
///
/// Creates [`RethAliasOracle`] instances from the latest host chain state.
Expand Down