Skip to content

Commit

Permalink
partial review response and move mock grpc file to test crate
Browse files Browse the repository at this point in the history
  • Loading branch information
Lilyjjo committed Oct 9, 2024
1 parent e6e52b9 commit 62e65b3
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 223 deletions.
2 changes: 1 addition & 1 deletion crates/astria-composer/local.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ NO_COLOR=
ASTRIA_COMPOSER_API_LISTEN_ADDR="0.0.0.0:0"

# Address of the RPC server for the sequencer chain
ASTRIA_COMPOSER_SEQUENCER_HTTP_URL="http://127.0.0.1:26657"
ASTRIA_COMPOSER_COMETBFT_URL="http://127.0.0.1:26657"

# Address of the RPC server for the sequencer chain
ASTRIA_COMPOSER_SEQUENCER_GRPC_URL="http://127.0.0.1:8080"
Expand Down
2 changes: 1 addition & 1 deletion crates/astria-composer/src/composer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ impl Composer {
let shutdown_token = CancellationToken::new();

let (executor, executor_handle) = executor::Builder {
sequencer_http_url: cfg.sequencer_http_url.clone(),
cometbft_url: cfg.cometbft_url.clone(),
sequencer_grpc_url: cfg.sequencer_grpc_url.clone(),
sequencer_chain_id: cfg.sequencer_chain_id.clone(),
private_key_file: cfg.private_key_file.clone(),
Expand Down
2 changes: 1 addition & 1 deletion crates/astria-composer/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub struct Config {
pub api_listen_addr: SocketAddr,

/// Address of the RPC server for the sequencer chain
pub sequencer_http_url: String,
pub cometbft_url: String,

/// Address of the GRPC server for the sequencer chain
pub sequencer_grpc_url: String,
Expand Down
8 changes: 4 additions & 4 deletions crates/astria-composer/src/executor/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use crate::{
};

pub(crate) struct Builder {
pub(crate) sequencer_http_url: String,
pub(crate) cometbft_url: String,
pub(crate) sequencer_grpc_url: String,
pub(crate) sequencer_chain_id: String,
pub(crate) private_key_file: String,
Expand All @@ -41,7 +41,7 @@ pub(crate) struct Builder {
impl Builder {
pub(crate) fn build(self) -> eyre::Result<(super::Executor, executor::Handle)> {
let Self {
sequencer_http_url,
cometbft_url,
sequencer_grpc_url,
sequencer_chain_id,
private_key_file,
Expand All @@ -52,7 +52,7 @@ impl Builder {
shutdown_token,
metrics,
} = self;
let sequencer_http_client = sequencer_client::HttpClient::new(sequencer_http_url.as_str())
let cometbft_client = sequencer_client::HttpClient::new(cometbft_url.as_str())
.wrap_err("failed constructing sequencer http client")?;

let sequencer_grpc_client = connect_sequencer_grpc(sequencer_grpc_url.as_str())
Expand All @@ -79,7 +79,7 @@ impl Builder {
super::Executor {
status,
serialized_rollup_transactions: serialized_rollup_transaction_rx,
sequencer_http_client,
cometbft_client,
sequencer_grpc_client,
sequencer_chain_id,
sequencer_key,
Expand Down
20 changes: 9 additions & 11 deletions crates/astria-composer/src/executor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ pub(super) struct Executor {
serialized_rollup_transactions: mpsc::Receiver<Sequence>,
// The client for submitting wrapped and signed pending eth transactions to the astria
// sequencer via the cometbft client.
sequencer_http_client: sequencer_client::HttpClient,
cometbft_client: sequencer_client::HttpClient,
// The grpc client for grabbing the latest nonce from.
sequencer_grpc_client: sequencer_service_client::SequencerServiceClient<Channel>,
// The chain id used for submission of transactions to the sequencer.
Expand Down Expand Up @@ -207,7 +207,7 @@ impl Executor {
metrics: &'static Metrics,
) -> Fuse<Instrumented<SubmitFut>> {
SubmitFut {
sequencer_http_client: self.sequencer_http_client.clone(),
cometbft_client: self.cometbft_client.clone(),
sequencer_grpc_client: self.sequencer_grpc_client.clone(),
address: self.address,
nonce,
Expand Down Expand Up @@ -394,7 +394,7 @@ impl Executor {
},
);
let client_genesis: tendermint::Genesis =
tryhard::retry_fn(|| self.sequencer_http_client.genesis())
tryhard::retry_fn(|| self.cometbft_client.genesis())
.with_config(retry_config)
.await?;
Ok(client_genesis.chain_id)
Expand Down Expand Up @@ -521,7 +521,7 @@ async fn get_pending_nonce(
})
.with_config(retry_config)
.await
.wrap_err("failed getting pending nonce from sequencing after 1024 attempts");
.wrap_err("failed getting pending nonce from sequencer after 1024 attempts");

metrics.record_nonce_fetch_latency(start.elapsed());

Expand All @@ -538,7 +538,7 @@ async fn get_pending_nonce(
err,
)]
async fn submit_tx(
sequencer_http_client: sequencer_client::HttpClient,
cometbft_client: sequencer_client::HttpClient,
tx: SignedTransaction,
metrics: &Metrics,
) -> eyre::Result<tx_sync::Response> {
Expand Down Expand Up @@ -573,7 +573,7 @@ async fn submit_tx(
},
);
let res = tryhard::retry_fn(|| {
let client = sequencer_http_client.clone();
let client = cometbft_client.clone();
let tx = tx.clone();
let span = info_span!(parent: span.clone(), "attempt send");
async move { client.submit_transaction_sync(tx).await }.instrument(span)
Expand Down Expand Up @@ -658,7 +658,7 @@ pin_project! {
/// If the sequencer returned a non-zero abci code (albeit not `INVALID_NONCE`), this future will return with
/// that nonce it used to submit the non-zero abci code request.
struct SubmitFut {
sequencer_http_client: sequencer_client::HttpClient,
cometbft_client: sequencer_client::HttpClient,
sequencer_grpc_client: SequencerServiceClient<tonic::transport::Channel>,
address: Address,
chain_id: String,
Expand Down Expand Up @@ -710,8 +710,7 @@ impl Future for SubmitFut {
"submitting transaction to sequencer",
);
SubmitState::WaitingForSend {
fut: submit_tx(this.sequencer_http_client.clone(), tx, self.metrics)
.boxed(),
fut: submit_tx(this.cometbft_client.clone(), tx, self.metrics).boxed(),
}
}

Expand Down Expand Up @@ -784,8 +783,7 @@ impl Future for SubmitFut {
"resubmitting transaction to sequencer with new nonce",
);
SubmitState::WaitingForSend {
fut: submit_tx(this.sequencer_http_client.clone(), tx, self.metrics)
.boxed(),
fut: submit_tx(this.cometbft_client.clone(), tx, self.metrics).boxed(),
}
}
Err(error) => {
Expand Down
Loading

0 comments on commit 62e65b3

Please sign in to comment.