diff --git a/Cargo.toml b/Cargo.toml index e4e8899..b9231f6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,11 +22,21 @@ name = "transaction-submitter" path = "bin/submit_transaction.rs" [dependencies] -init4-bin-base = "0.1.0" - -zenith-types = "0.13" - -alloy = { version = "0.7.3", features = ["full", "json-rpc", "signer-aws", "rpc-types-mev", "rlp"] } +init4-bin-base = { git = "https://github.com/init4tech/bin-base.git" } + +signet-bundle = { git = "https://github.com/init4tech/signet-sdk", branch = "main" } +signet-types = { git = "https://github.com/init4tech/signet-sdk", branch = "main" } +signet-zenith = { git = "https://github.com/init4tech/signet-sdk", branch = "main" } + +alloy = { version = "0.12.6", features = [ + "full", + "json-rpc", + "signer-aws", + "rpc-types-mev", + "rlp", + "node-bindings", + "serde", +] } aws-config = "1.1.7" aws-sdk-kms = "1.15.0" diff --git a/bin/submit_transaction.rs b/bin/submit_transaction.rs index 3955a49..addb205 100644 --- a/bin/submit_transaction.rs +++ b/bin/submit_transaction.rs @@ -82,9 +82,8 @@ async fn connect_from_config() -> (Provider, Address, u64) { let signer = AwsSigner::new(client, kms_key_id.to_string(), Some(chain_id)).await.unwrap(); let provider = ProviderBuilder::new() - .with_recommended_fillers() .wallet(EthereumWallet::from(signer)) - .on_builtin(&rpc_url) + .connect(&rpc_url) .await .unwrap(); diff --git a/src/config.rs b/src/config.rs index 1e8a6fa..705a567 100644 --- a/src/config.rs +++ b/src/config.rs @@ -9,10 +9,9 @@ use alloy::{ WalletFiller, }, }, - transports::BoxTransport, }; +use signet_zenith::Zenith; use std::{borrow::Cow, env, num, str::FromStr}; -use zenith_types::Zenith; // Keys for .env variables that need to be set to configure the builder. const HOST_CHAIN_ID: &str = "HOST_CHAIN_ID"; @@ -125,7 +124,7 @@ impl ConfigError { } } -/// Provider type used to read & write. +/// Type alias for the provider used in the builder. pub type Provider = FillProvider< JoinFill< JoinFill< @@ -134,26 +133,22 @@ pub type Provider = FillProvider< >, WalletFiller, >, - RootProvider, - BoxTransport, + RootProvider, Ethereum, >; -/// Provider type used to read-only. +/// Type alias for the provider used in the builder, without a wallet. pub type WalletlessProvider = FillProvider< JoinFill< Identity, JoinFill>>, >, - RootProvider, - BoxTransport, + RootProvider, Ethereum, >; -/// A Zenith contract instance, using some provider `P` (defaults to -/// [`Provider`]). -pub type ZenithInstance

= - Zenith::ZenithInstance; +/// A [`Zenith`] contract instance using [`Provider`] as the provider. +pub type ZenithInstance

= Zenith::ZenithInstance<(), P, alloy::network::Ethereum>; impl BuilderConfig { /// Load the builder configuration from environment variables. @@ -210,32 +205,36 @@ impl BuilderConfig { /// Connect to the Rollup rpc provider. pub async fn connect_ru_provider(&self) -> Result { - ProviderBuilder::new() - .with_recommended_fillers() - .on_builtin(&self.ru_rpc_url) + let provider = ProviderBuilder::new() + .connect(&self.ru_rpc_url) .await - .map_err(Into::into) + .map_err(ConfigError::Provider)?; + + Ok(provider) } /// Connect to the Host rpc provider. pub async fn connect_host_provider(&self) -> Result { let builder_signer = self.connect_builder_signer().await?; - ProviderBuilder::new() - .with_recommended_fillers() + let provider = ProviderBuilder::new() .wallet(EthereumWallet::from(builder_signer)) - .on_builtin(&self.host_rpc_url) + .connect(&self.host_rpc_url) .await - .map_err(Into::into) + .map_err(ConfigError::Provider)?; + + Ok(provider) } /// Connect additional broadcast providers. pub async fn connect_additional_broadcast( &self, - ) -> Result>, ConfigError> { - let mut providers = Vec::with_capacity(self.tx_broadcast_urls.len()); + ) -> Result, ConfigError> { + let mut providers: Vec = + Vec::with_capacity(self.tx_broadcast_urls.len()); for url in self.tx_broadcast_urls.iter() { let provider = - ProviderBuilder::new().on_builtin(url).await.map_err(Into::::into)?; + ProviderBuilder::new().connect(url).await.map_err(ConfigError::Provider)?; + providers.push(provider); } Ok(providers) @@ -278,5 +277,6 @@ pub fn load_url(key: &str) -> Result, ConfigError> { /// Load an address from an environment variable. pub fn load_address(key: &str) -> Result { let address = load_string(key)?; - Address::from_str(&address).map_err(Into::into) + Address::from_str(&address) + .map_err(|_| ConfigError::Var(format!("Invalid address format for {}", key))) } diff --git a/src/lib.rs b/src/lib.rs index 5d4e743..10eefeb 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -27,4 +27,5 @@ pub mod tasks; /// Utilities. pub mod utils; +// Anonymous import suppresses warnings about unused imports. use openssl as _; diff --git a/src/tasks/block.rs b/src/tasks/block.rs index e750696..a0c9c87 100644 --- a/src/tasks/block.rs +++ b/src/tasks/block.rs @@ -3,17 +3,18 @@ use super::oauth::Authenticator; use super::tx_poller::TxPoller; use crate::config::{BuilderConfig, WalletlessProvider}; use alloy::{ - consensus::{SidecarBuilder, SidecarCoder, TxEnvelope}, + consensus::{SidecarBuilder, SidecarCoder, transaction::TxEnvelope}, eips::eip2718::Decodable2718, primitives::{B256, Bytes, keccak256}, providers::Provider as _, rlp::Buf, }; +use signet_bundle::SignetEthBundle; +use signet_zenith::{Alloy2718Coder, encode_txns}; use std::time::{SystemTime, UNIX_EPOCH}; use std::{sync::OnceLock, time::Duration}; use tokio::{sync::mpsc, task::JoinHandle}; use tracing::{Instrument, debug, error, info, trace}; -use zenith_types::{Alloy2718Coder, ZenithEthBundle, encode_txns}; /// Ethereum's slot time in seconds. pub const ETHEREUM_SLOT_TIME: u64 = 12; @@ -183,7 +184,7 @@ impl BlockBuilder { } /// Simulates a Zenith bundle against the rollup state - async fn simulate_bundle(&mut self, bundle: &ZenithEthBundle) -> eyre::Result<()> { + async fn simulate_bundle(&mut self, bundle: &SignetEthBundle) -> eyre::Result<()> { // TODO: Simulate bundles with the Simulation Engine // [ENG-672](https://linear.app/initiates/issue/ENG-672/add-support-for-bundles) debug!(hash = ?bundle.bundle.bundle_hash(), block_number = ?bundle.block_number(), "bundle simulations is not implemented yet - skipping simulation"); @@ -269,7 +270,7 @@ mod tests { rpc::types::{TransactionRequest, mev::EthSendBundle}, signers::local::PrivateKeySigner, }; - use zenith_types::ZenithEthBundle; + use signet_bundle::SignetEthBundle; /// Create a mock bundle for testing with a single transaction async fn create_mock_bundle(wallet: &EthereumWallet) -> Bundle { @@ -294,7 +295,7 @@ mod tests { replacement_uuid: Some("replacement_uuid".to_owned()), }; - let zenith_bundle = ZenithEthBundle { bundle: eth_bundle, host_fills: None }; + let zenith_bundle = SignetEthBundle { bundle: eth_bundle, host_fills: None }; Bundle { id: "mock_bundle".to_owned(), bundle: zenith_bundle } } diff --git a/src/tasks/bundler.rs b/src/tasks/bundler.rs index acc3cae..d3ec34e 100644 --- a/src/tasks/bundler.rs +++ b/src/tasks/bundler.rs @@ -8,15 +8,14 @@ use tokio::sync::mpsc::{UnboundedReceiver, UnboundedSender, unbounded_channel}; use tokio::task::JoinHandle; use tokio::time; use tracing::{Instrument, debug, trace}; -use zenith_types::ZenithEthBundle; - +use signet_bundle::SignetEthBundle; /// Holds a bundle from the cache with a unique ID and a Zenith bundle. #[derive(Debug, Clone, Serialize, Deserialize)] pub struct Bundle { /// Cache identifier for the bundle pub id: String, /// The Zenith bundle for this bundle - pub bundle: ZenithEthBundle, + pub bundle: SignetEthBundle, } /// Response from the tx-pool containing a list of bundles. diff --git a/src/tasks/submit.rs b/src/tasks/submit.rs index 0f1b0bf..558167f 100644 --- a/src/tasks/submit.rs +++ b/src/tasks/submit.rs @@ -18,14 +18,14 @@ use alloy::{ use eyre::{bail, eyre}; use init4_bin_base::deps::metrics::{counter, histogram}; use oauth2::TokenResponse; +use signet_types::{SignRequest, SignResponse}; +use signet_zenith::{ + BundleHelper::{self, BlockHeader, FillPermit2, submitCall}, + Zenith::IncorrectHostBlock, +}; use std::time::Instant; use tokio::{sync::mpsc, task::JoinHandle}; use tracing::{debug, error, instrument, trace}; -use zenith_types::{ - BundleHelper::{self, FillPermit2}, - SignRequest, SignResponse, - Zenith::IncorrectHostBlock, -}; macro_rules! spawn_provider_send { ($provider:expr, $tx:expr) => { @@ -127,7 +127,7 @@ impl SubmitTask { s: FixedBytes<32>, in_progress: &InProgressBlock, ) -> eyre::Result { - let data = zenith_types::BundleHelper::submitCall { fills, header, v, r, s }.abi_encode(); + let data = submitCall { fills, header, v, r, s }.abi_encode(); let sidecar = in_progress.encode_blob::().build()?; Ok(TransactionRequest::default() @@ -151,7 +151,7 @@ impl SubmitTask { ) -> eyre::Result { let (v, r, s) = extract_signature_components(&resp.sig); - let header = zenith_types::BundleHelper::BlockHeader { + let header = BlockHeader { hostBlockNumber: resp.req.host_block_number, rollupChainId: U256::from(self.config.ru_chain_id), gasLimit: resp.req.gas_limit, @@ -167,7 +167,7 @@ impl SubmitTask { .with_gas_limit(1_000_000); if let Err(TransportError::ErrorResp(e)) = - self.host_provider.call(&tx).block(BlockNumberOrTag::Pending.into()).await + self.host_provider.call(tx.clone()).block(BlockNumberOrTag::Pending.into()).await { error!( code = e.code,