diff --git a/crates/astria-auctioneer/src/auction/builder.rs b/crates/astria-auctioneer/src/auction/builder.rs index 6b9abc86cd..700d55b5d3 100644 --- a/crates/astria-auctioneer/src/auction/builder.rs +++ b/crates/astria-auctioneer/src/auction/builder.rs @@ -1,7 +1,9 @@ use std::time::Duration; -use astria_core::generated::bundle::v1alpha1::GetBundleStreamResponse; -use astria_eyre::eyre; +use astria_core::primitive::v1::{ + asset, + RollupId, +}; use tokio::sync::{ mpsc, oneshot, @@ -12,6 +14,7 @@ use super::{ Auction, Handle, Id, + SequencerKey, }; use crate::Metrics; @@ -28,6 +31,12 @@ pub(crate) struct Builder { pub(crate) latency_margin: Duration, /// The ID of the auction to be run pub(crate) auction_id: Id, + /// The key used to sign sequencer transactions + pub(crate) sequencer_key: SequencerKey, + /// The denomination of the fee asset used in the sequencer transactions + pub(crate) fee_asset_denomination: asset::Denom, + /// The rollup ID used for `RollupDataSubmission` with the auction result + pub(crate) rollup_id: RollupId, } impl Builder { @@ -39,6 +48,9 @@ impl Builder { sequencer_abci_endpoint, latency_margin, auction_id, + fee_asset_denomination, + rollup_id, + sequencer_key, } = self; let (executed_block_tx, executed_block_rx) = oneshot::channel(); @@ -58,6 +70,9 @@ impl Builder { new_bundles_rx, auction_id, latency_margin, + sequencer_key, + fee_asset_denomination, + rollup_id, }; ( diff --git a/crates/astria-auctioneer/src/auction/manager.rs b/crates/astria-auctioneer/src/auction/manager.rs index 469c9280dc..c34d549b22 100644 --- a/crates/astria-auctioneer/src/auction/manager.rs +++ b/crates/astria-auctioneer/src/auction/manager.rs @@ -1,6 +1,12 @@ use std::collections::HashMap; -use astria_core::generated::bundle::v1alpha1::Bundle; +use astria_core::{ + generated::bundle::v1alpha1::Bundle, + primitive::v1::{ + asset, + RollupId, + }, +}; use astria_eyre::eyre::{ self, OptionExt as _, @@ -15,28 +21,45 @@ use tracing::instrument; use super::{ Handle, Id, + SequencerKey, }; use crate::flatten_result; pub(crate) struct Builder { pub(crate) metrics: &'static crate::Metrics, pub(crate) shutdown_token: CancellationToken, + + /// The gRPC endpoint for the sequencer service used by auctions. pub(crate) sequencer_grpc_endpoint: String, + /// The ABCI endpoint for the sequencer service used by auctions. pub(crate) sequencer_abci_endpoint: String, + /// The amount of time to run the auction timer for. pub(crate) latency_margin: std::time::Duration, + /// The private key used to sign sequencer transactions. + pub(crate) sequencer_key: SequencerKey, + /// The denomination of the fee asset used in the sequencer transactions + pub(crate) fee_asset_denomination: asset::Denom, + /// The chain ID for sequencer transactions + pub(crate) sequencer_chain_id: String, + /// The rollup ID for the `RollupDataSubmission`s with auction results + pub(crate) rollup_id: RollupId, } impl Builder { - pub(crate) fn build(self) -> Manager { + pub(crate) fn build(self) -> eyre::Result { let Self { metrics, shutdown_token, sequencer_grpc_endpoint, sequencer_abci_endpoint, latency_margin, + fee_asset_denomination, + rollup_id, + sequencer_key, + sequencer_chain_id, } = self; - Manager { + Ok(Manager { metrics, shutdown_token, sequencer_grpc_endpoint, @@ -44,7 +67,11 @@ impl Builder { latency_margin, running_auctions: JoinMap::new(), auction_handles: HashMap::new(), - } + sequencer_key, + fee_asset_denomination, + sequencer_chain_id, + rollup_id, + }) } } @@ -57,6 +84,10 @@ pub(crate) struct Manager { running_auctions: JoinMap>, auction_handles: HashMap, // TODO: hold the bundle stream here? + sequencer_key: SequencerKey, + fee_asset_denomination: asset::Denom, + sequencer_chain_id: String, + rollup_id: RollupId, } impl Manager { @@ -69,6 +100,9 @@ impl Manager { sequencer_abci_endpoint: self.sequencer_abci_endpoint.clone(), latency_margin: self.latency_margin, auction_id, + sequencer_key: self.sequencer_key.clone(), + fee_asset_denomination: self.fee_asset_denomination.clone(), + rollup_id: self.rollup_id, } .build(); @@ -104,7 +138,7 @@ impl Manager { .wrap_err("failed to start processing bids") } - pub(crate) fn try_send_bundle(&mut self, _bundle: Bundle) -> eyre::Result<()> { + pub(crate) fn try_send_bundle(&mut self, _auction_id: Id, _bundle: Bundle) -> eyre::Result<()> { unimplemented!() // try to get the handle for the appropriate auction // try send into that auction diff --git a/crates/astria-auctioneer/src/auction/mod.rs b/crates/astria-auctioneer/src/auction/mod.rs index 2174954ccd..3d625ce865 100644 --- a/crates/astria-auctioneer/src/auction/mod.rs +++ b/crates/astria-auctioneer/src/auction/mod.rs @@ -124,7 +124,7 @@ struct Auction { /// The key used to sign transactions on the sequencer sequencer_key: SequencerKey, /// Fee asset for submitting transactions - fee_asset: asset::Denom, + fee_asset_denomination: asset::Denom, /// Rollup ID to submit the auction result to rollup_id: RollupId, } @@ -201,7 +201,7 @@ impl Auction { let transaction_body = auction_result .wrap_err("")? .ok_or_eyre("auction ended with no winning bid")? - .into_transaction_body(nonce, self.rollup_id, self.fee_asset.clone()); + .into_transaction_body(nonce, self.rollup_id, self.fee_asset_denomination.clone()); let transaction = transaction_body.sign(self.sequencer_key.signing_key()); diff --git a/crates/astria-auctioneer/src/auctioneer/inner.rs b/crates/astria-auctioneer/src/auctioneer/inner.rs index f370b4b743..de2e081016 100644 --- a/crates/astria-auctioneer/src/auctioneer/inner.rs +++ b/crates/astria-auctioneer/src/auctioneer/inner.rs @@ -51,6 +51,10 @@ impl Auctioneer { latency_margin_ms, rollup_grpc_endpoint, rollup_id, + sequencer_chain_id, + sequencer_private_key_path, + sequencer_address_prefix, + fee_asset_denomination, .. } = cfg; @@ -64,6 +68,10 @@ impl Auctioneer { rollup_id, rollup_grpc_endpoint, latency_margin: Duration::from_millis(latency_margin_ms), + sequencer_private_key_path, + sequencer_address_prefix, + fee_asset_denomination, + sequencer_chain_id, } .build() .wrap_err("failed to initialize the optimistic executor")?; diff --git a/crates/astria-auctioneer/src/config.rs b/crates/astria-auctioneer/src/config.rs index ffc6da1ba7..7ef5c971f7 100644 --- a/crates/astria-auctioneer/src/config.rs +++ b/crates/astria-auctioneer/src/config.rs @@ -20,10 +20,10 @@ pub struct Config { /// The file path for the private key used to sign sequencer transactions with the auction /// results pub sequencer_private_key_path: String, - // The fee asset denomination to use for the sequnecer transactions. - pub fee_asset_denomination: asset::Denom, // The address prefix to use when constructing sequencer addresses using the signing key. pub sequencer_address_prefix: String, + // The fee asset denomination to use for the sequnecer transactions. + pub fee_asset_denomination: asset::Denom, /// The endpoint for the rollup gRPC service used for the optimistic execution and bundle /// streams pub rollup_grpc_endpoint: String, diff --git a/crates/astria-auctioneer/src/optimistic_executor/builder.rs b/crates/astria-auctioneer/src/optimistic_executor/builder.rs index 844b592fc3..c4b5aff321 100644 --- a/crates/astria-auctioneer/src/optimistic_executor/builder.rs +++ b/crates/astria-auctioneer/src/optimistic_executor/builder.rs @@ -1,11 +1,21 @@ use std::time::Duration; -use astria_core::primitive::v1::RollupId; -use astria_eyre::eyre; +use astria_core::primitive::v1::{ + asset, + RollupId, +}; +use astria_eyre::{ + eyre, + eyre::WrapErr as _, +}; use tokio_util::sync::CancellationToken; +use tracing::info; use super::Startup; -use crate::Metrics; +use crate::{ + sequencer_key::SequencerKey, + Metrics, +}; pub(crate) struct Builder { pub(crate) metrics: &'static Metrics, @@ -14,6 +24,15 @@ pub(crate) struct Builder { pub(crate) sequencer_grpc_endpoint: String, /// The endpoint for the sequencer ABCI service used to submit the auction winner transaction pub(crate) sequencer_abci_endpoint: String, + /// The file path for the private key used to sign sequencer transactions with the auction + /// results + pub(crate) sequencer_private_key_path: String, + /// The prefix for the address used to sign sequencer transactions + pub(crate) sequencer_address_prefix: String, + /// The denomination of the fee asset used in the sequencer transactions + pub(crate) fee_asset_denomination: asset::Denom, + /// The chain ID for sequencer transactions + pub(crate) sequencer_chain_id: String, /// The rollup ID for the filtered optimistic block stream pub(crate) rollup_id: String, /// The endpoint for the rollup's optimistic execution gRPC service @@ -32,8 +51,19 @@ impl Builder { rollup_id, rollup_grpc_endpoint, latency_margin, + sequencer_private_key_path, + sequencer_address_prefix, + fee_asset_denomination, + sequencer_chain_id, } = self; + let sequencer_key = SequencerKey::builder() + .path(sequencer_private_key_path) + .prefix(sequencer_address_prefix) + .try_build() + .wrap_err("failed to load sequencer private key")?; + info!(address = %sequencer_key.address(), "loaded sequencer signer"); + let rollup_id = RollupId::from_unhashed_bytes(&rollup_id); Ok(Startup { @@ -44,6 +74,9 @@ impl Builder { rollup_id, rollup_grpc_endpoint, latency_margin, + sequencer_key, + fee_asset_denomination, + sequencer_chain_id, }) } } diff --git a/crates/astria-auctioneer/src/optimistic_executor/mod.rs b/crates/astria-auctioneer/src/optimistic_executor/mod.rs index 7392e0039b..c32abdcde9 100644 --- a/crates/astria-auctioneer/src/optimistic_executor/mod.rs +++ b/crates/astria-auctioneer/src/optimistic_executor/mod.rs @@ -2,7 +2,10 @@ mod builder; use std::time::Duration; -use astria_core::primitive::v1::RollupId; +use astria_core::primitive::v1::{ + asset, + RollupId, +}; use astria_eyre::eyre::{ self, OptionExt, @@ -28,6 +31,7 @@ use crate::{ optimistic_stream::OptimisticBlockStream, }, sequencer_grpc_client::SequencerGrpcClient, + sequencer_key::SequencerKey, }; pub(crate) struct Startup { @@ -36,6 +40,9 @@ pub(crate) struct Startup { shutdown_token: CancellationToken, sequencer_grpc_endpoint: String, sequencer_abci_endpoint: String, + sequencer_key: SequencerKey, + fee_asset_denomination: asset::Denom, + sequencer_chain_id: String, rollup_id: RollupId, rollup_grpc_endpoint: String, latency_margin: Duration, @@ -51,6 +58,9 @@ impl Startup { rollup_id, rollup_grpc_endpoint, latency_margin, + sequencer_key, + fee_asset_denomination, + sequencer_chain_id, } = self; let sequencer_client = SequencerGrpcClient::new(&sequencer_grpc_endpoint) @@ -73,14 +83,20 @@ impl Startup { // let bundle_stream = BundleServiceClient::new(bundle_service_grpc_url) // .wrap_err("failed to initialize bundle service grpc client")?; + // TODO: should i construct this in `Auctioneer::new()` instead of here? let auctions = auction::manager::Builder { metrics, shutdown_token: shutdown_token.clone(), sequencer_grpc_endpoint, sequencer_abci_endpoint, latency_margin, + sequencer_key, + fee_asset_denomination: fee_asset_denomination.clone(), + sequencer_chain_id, + rollup_id, } - .build(); + .build() + .wrap_err("failed to initialize auction manager")?; let optimistic_block = optimistic_blocks .next() diff --git a/crates/astria-auctioneer/src/sequencer_key.rs b/crates/astria-auctioneer/src/sequencer_key.rs index d5a0c8be23..463f77fc27 100644 --- a/crates/astria-auctioneer/src/sequencer_key.rs +++ b/crates/astria-auctioneer/src/sequencer_key.rs @@ -17,6 +17,7 @@ use astria_eyre::eyre::{ Context, }; +#[derive(Clone)] pub(crate) struct SequencerKey { address: Address, signing_key: SigningKey,