Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ members = ["crates/*"]
resolver = "2"

[workspace.package]
version = "0.8.4"
edition = "2021"
rust-version = "1.82"
version = "0.8.2"
edition = "2024"
rust-version = "1.88"
authors = ["init4"]
license = "MIT OR Apache-2.0"
homepage = "https://github.com/init4tech/signet-sdk"
Expand Down
12 changes: 6 additions & 6 deletions crates/blobber/src/block_data.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use crate::{
error::UnrecoverableBlobError, shim::ExtractableChainShim, BlockExtractionError,
BlockExtractorBuilder, ExtractionResult,
BlockExtractionError, BlockExtractorBuilder, ExtractionResult, error::UnrecoverableBlobError,
shim::ExtractableChainShim,
};
use alloy::{
consensus::{Blob, SidecarCoder, SimpleCoder},
eips::eip7594::BlobTransactionSidecarVariant,
primitives::{keccak256, TxHash, B256},
primitives::{B256, TxHash, keccak256},
};
use init4_bin_base::utils::calc::SlotCalculator;
use reth::{
Expand Down Expand Up @@ -334,15 +334,15 @@ mod tests {
BlobTransactionSidecar, SidecarBuilder, SignableTransaction, TxEip2930, TxEnvelope,
},
eips::Encodable2718,
primitives::{bytes, Address, TxKind, U256},
primitives::{Address, TxKind, U256, bytes},
rlp::encode,
signers::{local::PrivateKeySigner, SignerSync},
signers::{SignerSync, local::PrivateKeySigner},
};
use foundry_blob_explorers::TransactionDetails;
use reth::primitives::{Transaction, TransactionSigned};
use reth_transaction_pool::{
test_utils::{testing_pool, MockTransaction},
PoolTransaction, TransactionOrigin,
test_utils::{MockTransaction, testing_pool},
};
use signet_types::constants::SignetSystemConstants;

Expand Down
8 changes: 4 additions & 4 deletions crates/db/src/provider.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use crate::{
DataCompat, DbZenithHeader, RuChain, ZenithHeaders,
tables::{DbSignetEvent, JournalHashes, SignetEvents},
traits::RuWriter,
DataCompat, DbZenithHeader, RuChain, ZenithHeaders,
};
use alloy::{
consensus::{BlockHeader, TxReceipt},
primitives::{map::HashSet, Address, BlockNumber, B256, U256},
primitives::{Address, B256, BlockNumber, U256, map::HashSet},
};
use reth::{
primitives::{Account, StaticFileSegment},
Expand All @@ -17,13 +17,13 @@ use reth::{
},
};
use reth_db::{
PlainAccountState,
cursor::{DbCursorRO, DbCursorRW},
models::{BlockNumberAddress, StoredBlockBodyIndices},
tables,
transaction::{DbTx, DbTxMut},
PlainAccountState,
};
use reth_prune_types::{PruneMode, MINIMUM_PRUNING_DISTANCE};
use reth_prune_types::{MINIMUM_PRUNING_DISTANCE, PruneMode};
use signet_evm::BlockResult;
use signet_node_types::{NodeTypesDbTrait, SignetNodeTypes};
use signet_types::primitives::RecoveredBlock;
Expand Down
5 changes: 3 additions & 2 deletions crates/db/src/tables.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
use alloy::{
primitives::{bytes::BufMut, Address, BlockNumber, Bytes, B256, U256},
primitives::{Address, B256, BlockNumber, Bytes, U256, bytes::BufMut},
rlp::Buf,
};
use reth_db::{
DatabaseError,
table::{Compress, Decompress, DupSort, Table},
tables, DatabaseError,
tables,
};
use signet_zenith::{
Passage::{Enter, EnterToken},
Expand Down
2 changes: 1 addition & 1 deletion crates/db/src/traits.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::{DbExtractionResults, DbSignetEvent, RuChain};
use alloy::primitives::{Address, BlockNumber, B256, U256};
use alloy::primitives::{Address, B256, BlockNumber, U256};
use itertools::Itertools;
use reth::{
primitives::Account,
Expand Down
6 changes: 3 additions & 3 deletions crates/rpc/examples/filler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ use alloy::{
network::{Ethereum, EthereumWallet, TransactionBuilder},
primitives::Bytes,
providers::{
Identity, Provider as _, RootProvider, SendableTx,
fillers::{
BlobGasFiller, ChainIdFiller, FillProvider, GasFiller, JoinFill, NonceFiller,
WalletFiller,
},
Identity, Provider as _, RootProvider, SendableTx,
},
rpc::types::{mev::EthSendBundle, TransactionRequest},
rpc::types::{TransactionRequest, mev::EthSendBundle},
signers::Signer,
};
use eyre::{eyre, Error};
use eyre::{Error, eyre};
use signet_bundle::SignetEthBundle;
use signet_constants::SignetConstants;
use signet_tx_cache::{client::TxCache, types::TxCacheSendBundleResponse};
Expand Down
4 changes: 2 additions & 2 deletions crates/rpc/examples/order.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use alloy::{
consensus::constants::GWEI_TO_WEI,
primitives::{uint, U256},
primitives::{U256, uint},
signers::Signer,
};
use chrono::Utc;
use eyre::Error;
use signet_constants::{SignetConstants, NATIVE_TOKEN_ADDRESS};
use signet_constants::{NATIVE_TOKEN_ADDRESS, SignetConstants};
use signet_tx_cache::client::TxCache;
use signet_types::UnsignedOrder;
use signet_zenith::RollupOrders::{Input, Order, Output};
Expand Down
2 changes: 1 addition & 1 deletion crates/rpc/src/config.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use ajj::{pubsub::ServerShutdown, Router};
use ajj::{Router, pubsub::ServerShutdown};
use reth::{args::RpcServerArgs, tasks::TaskExecutor};
use std::net::SocketAddr;
use tokio::task::JoinHandle;
Expand Down
36 changes: 24 additions & 12 deletions crates/rpc/src/ctx.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use crate::{
Pnt,
eth::EthError,
interest::{ActiveFilter, FilterManager, FilterOutput, SubscriptionManager},
receipts::build_signet_receipt,
util::BlockRangeInclusiveIter,
Pnt,
};
use alloy::{
consensus::{BlockHeader, Header, Signed, Transaction, TxEnvelope},
Expand All @@ -16,21 +16,21 @@ use reth::{
core::primitives::SignerRecoverable,
primitives::{Block, EthPrimitives, Receipt, Recovered, RecoveredBlock, TransactionSigned},
providers::{
providers::{BlockchainProvider, ProviderNodeTypes},
BlockHashReader, BlockIdReader, BlockNumReader, CanonStateSubscriptions, HeaderProvider,
ProviderBlock, ProviderError, ProviderReceipt, ReceiptProvider, StateProviderFactory,
TransactionsProvider,
providers::{BlockchainProvider, ProviderNodeTypes},
},
revm::{database::StateProviderDatabase, primitives::hardfork::SpecId},
rpc::{
eth::{filter::EthFilterError, helpers::types::EthRpcConverter},
server_types::eth::{
EthApiError, EthConfig, EthStateCache, FeeHistoryCache, FeeHistoryEntry,
GasPriceOracle,
fee_history::{
calculate_reward_percentiles_for_block, fee_history_cache_new_blocks_task,
},
logs_utils::{self, append_matching_block_logs, ProviderOrBlock},
EthApiError, EthConfig, EthStateCache, FeeHistoryCache, FeeHistoryEntry,
GasPriceOracle,
logs_utils::{self, ProviderOrBlock, append_matching_block_logs},
},
types::{FilterBlockOption, FilteredParams},
},
Expand All @@ -41,12 +41,12 @@ use reth_node_api::{BlockBody, FullNodeComponents};
use reth_rpc_eth_api::{RpcBlock, RpcConvert, RpcReceipt, RpcTransaction};
use signet_evm::EvmNeedsTx;
use signet_tx_cache::client::TxCache;
use signet_types::{constants::SignetSystemConstants, MagicSig};
use signet_types::{MagicSig, constants::SignetSystemConstants};
use std::{marker::PhantomData, sync::Arc};
use tracing::{instrument, trace, Level};
use tracing::{Level, instrument, trace};
use trevm::{
revm::{context::CfgEnv, database::StateBuilder},
Cfg,
revm::{context::CfgEnv, database::StateBuilder},
};

/// Type alias for EVMs using a [`StateProviderBox`] as the `DB` type for
Expand Down Expand Up @@ -312,6 +312,20 @@ where
Ok(builder.build())
}

/// Get the [`Header`] for a given block.
pub async fn raw_header(
&self,
t: impl Into<BlockId>,
) -> Result<Option<(B256, Header)>, EthApiError> {
let Some(hash) = self.provider.block_hash_for_id(t.into())? else {
return Ok(None);
};

let header = self.cache.get_header(hash).await.map_err(EthApiError::from)?;

Ok(Some((hash, header)))
}

/// Get the block for a given block, returning the block hash and
/// the block itself.
pub async fn raw_block(
Expand Down Expand Up @@ -513,20 +527,18 @@ where
build_signet_receipt(tx, meta, receipt, all_receipts.to_vec()).map(Some)
}

/// Create the [`Block`] object for a specific [`BlockId`].
/// Create the [`Header`] object for a specific [`BlockId`].
pub async fn block_cfg(&self, mut block_id: BlockId) -> Result<Header, EthApiError> {
// If the block is pending, we'll load the latest and
let pending = block_id.is_pending();
if pending {
block_id = BlockId::latest();
}

let Some((_, block)) = self.raw_block(block_id).await? else {
let Some((_, mut header)) = self.raw_header(block_id).await? else {
return Err(EthApiError::HeaderNotFound(block_id));
};

let mut header = block.clone_header();

// Modify the header for pending blocks, to simulate the next block.
if pending {
header.parent_hash = header.hash_slow();
Expand Down
22 changes: 11 additions & 11 deletions crates/rpc/src/eth/endpoints.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
use crate::{
Pnt,
ctx::RpcCtx,
eth::{CallErrorData, EthError},
interest::{FilterOutput, InterestKind},
receipts::build_signet_receipt,
util::{await_jh_option, await_jh_option_response, response_tri},
Pnt,
};
use ajj::{HandlerCtx, ResponsePayload};
use alloy::{
consensus::{BlockHeader, TxEnvelope},
eips::{
eip2718::{Decodable2718, Encodable2718},
BlockId, BlockNumberOrTag,
eip2718::{Decodable2718, Encodable2718},
},
network::Ethereum,
primitives::{Address, B256, U256, U64},
primitives::{Address, B256, U64, U256},
rpc::types::{
pubsub::SubscriptionKind, state::StateOverride, BlockOverrides, Filter, TransactionRequest,
BlockOverrides, Filter, TransactionRequest, pubsub::SubscriptionKind, state::StateOverride,
},
};
use reth::{
Expand All @@ -29,7 +29,7 @@ use reth_rpc_eth_api::{RpcBlock, RpcHeader, RpcReceipt, RpcTransaction};
use serde::Deserialize;
use signet_evm::EvmErrored;
use std::borrow::Cow;
use tracing::{debug, trace_span, Instrument};
use tracing::{Instrument, debug, trace_span};
use trevm::revm::context::result::ExecutionResult;

/// Args for `eth_estimateGas` and `eth_call`.
Expand Down Expand Up @@ -405,7 +405,7 @@ where
/// - If the gas is below `MIN_TRANSACTION_GAS`, set it to `None`
/// - If the gas is above the `rpc_gas_cap`, set it to the `rpc_gas_cap`
/// - Otherwise, do nothing
fn normalize_gas_stateless(request: &mut TransactionRequest, max_gas: u64) {
const fn normalize_gas_stateless(request: &mut TransactionRequest, max_gas: u64) {
match request.gas {
Some(..trevm::MIN_TRANSACTION_GAS) => request.gas = None,
Some(val) if val > max_gas => request.gas = Some(max_gas),
Expand Down Expand Up @@ -443,7 +443,7 @@ where
return ResponsePayload::internal_error_with_message_and_obj(
"error while loading block cfg".into(),
e.to_string().into(),
)
);
}
};

Expand Down Expand Up @@ -550,7 +550,7 @@ where
return ResponsePayload::internal_error_with_message_and_obj(
"error while loading block cfg".into(),
e.to_string().into(),
)
);
}
};

Expand Down Expand Up @@ -599,13 +599,13 @@ where
Signet: Pnt,
{
let task = async move {
let (block, suggested) = tokio::try_join!(
ctx.signet().raw_block(BlockId::latest()),
let (header, suggested) = tokio::try_join!(
ctx.signet().raw_header(BlockId::latest()),
ctx.signet().gas_oracle().suggest_tip_cap(),
)
.map_err(|e| e.to_string())?;

let base_fee = block.and_then(|b| b.1.header().base_fee_per_gas()).unwrap_or_default();
let base_fee = header.and_then(|h| h.1.base_fee_per_gas()).unwrap_or_default();
Ok(suggested + U256::from(base_fee))
};

Expand Down
2 changes: 1 addition & 1 deletion crates/rpc/src/eth/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pub use error::EthError;
mod helpers;
pub use helpers::CallErrorData;

use crate::{ctx::RpcCtx, Pnt};
use crate::{Pnt, ctx::RpcCtx};
use alloy::{eips::BlockNumberOrTag, primitives::B256};
use reth_node_api::FullNodeComponents;

Expand Down
34 changes: 14 additions & 20 deletions crates/rpc/src/interest/filters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ use alloy::{
primitives::{B256, U64},
rpc::types::{Filter, Log},
};
use dashmap::{mapref::one::RefMut, DashMap};
use dashmap::{DashMap, mapref::one::RefMut};
use std::{
collections::VecDeque,
sync::{
atomic::{AtomicU64, Ordering},
Arc, Weak,
atomic::{AtomicU64, Ordering},
},
time::{Duration, Instant},
};
Expand Down Expand Up @@ -71,9 +71,9 @@ impl FilterOutput {
pub fn extend(&mut self, other: Self) {
match (self, other) {
// If we're a log, we can extend with other logs
(Self::Log(ref mut logs), Self::Log(other_logs)) => logs.extend(other_logs),
(Self::Log(logs), Self::Log(other_logs)) => logs.extend(other_logs),
// If we're a block, we can extend with other blocks
(Self::Block(ref mut blocks), Self::Block(other_blocks)) => blocks.extend(other_blocks),
(Self::Block(blocks), Self::Block(other_blocks)) => blocks.extend(other_blocks),
// Extending with empty is a noop
(_, Self::Empty(_)) => (),
// If we're empty, just take the other value
Expand Down Expand Up @@ -108,22 +108,14 @@ impl From<Vec<Log>> for FilterOutput {
impl FromIterator<Log> for FilterOutput {
fn from_iter<T: IntoIterator<Item = Log>>(iter: T) -> Self {
let inner: VecDeque<_> = iter.into_iter().collect();
if inner.is_empty() {
Self::empty()
} else {
Self::Log(inner)
}
if inner.is_empty() { Self::empty() } else { Self::Log(inner) }
}
}

impl FromIterator<B256> for FilterOutput {
fn from_iter<T: IntoIterator<Item = B256>>(iter: T) -> Self {
let inner: VecDeque<_> = iter.into_iter().collect();
if inner.is_empty() {
Self::empty()
} else {
Self::Block(inner)
}
if inner.is_empty() { Self::empty() } else { Self::Block(inner) }
}
}

Expand Down Expand Up @@ -294,12 +286,14 @@ impl FilterCleanTask {
/// [`DashMap::retain`]'s deadlock condition is not met. See [`DashMap`]
/// documentation for more information.
fn spawn(self) {
std::thread::spawn(move || loop {
std::thread::sleep(self.sleep);
trace!("cleaning stale filters");
match self.manager.upgrade() {
Some(manager) => manager.clean_stale(self.age_limit),
None => break,
std::thread::spawn(move || {
loop {
std::thread::sleep(self.sleep);
trace!("cleaning stale filters");
match self.manager.upgrade() {
Some(manager) => manager.clean_stale(self.age_limit),
None => break,
}
}
});
}
Expand Down
Loading
Loading