Skip to content

Commit a87da01

Browse files
authored
fix: submit channel refactors (#94)
# fix: submit channel refactors This PR includes several fixes and refactors to the channel submission logic. - Handle 403 errors with `Skip`s instead of erroring - Adds `retry_count` increments to some code paths that weren't previously ticking the count - Adds per-slot limiting to the block building loop so that the retry function doesn't simply get called again after 3 attempts - Explicitly logs the `call` results of the blob transaction to aid with debugging - Adds gas bumping logic to the submit task to facilitate transaction replacement Additionally, there are some configuration changes that needed to be made. - Additional broadcast hosts was just pointing back at the host RPC, which was adding noise to the logs and interfering with nonce debugging. This PR makes it optional and un-sets the duplicate host-rpc URL. - Slot offset and start timestamp were incorrectly configured and have been updated to their correct values Closes ENG-1079 See: [Builder Retry Logic](https://www.notion.so/init4tech/Builder-Retry-Logic-1f43e1cd45398092a1b3fb692dd37787?pvs=4)
1 parent 7e359c5 commit a87da01

File tree

5 files changed

+252
-91
lines changed

5 files changed

+252
-91
lines changed

Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ integration = []
2727
[dependencies]
2828
init4-bin-base = { version = "0.4.1", features = ["perms"] }
2929

30-
signet-constants = { git = "https://github.com/init4tech/signet-sdk", rev = "bd183b627dcb0eb682da801093b13f1f8311446b" }
31-
signet-sim = { git = "https://github.com/init4tech/signet-sdk", rev = "bd183b627dcb0eb682da801093b13f1f8311446b" }
32-
signet-tx-cache = { git = "https://github.com/init4tech/signet-sdk", rev = "bd183b627dcb0eb682da801093b13f1f8311446b" }
33-
signet-types = { git = "https://github.com/init4tech/signet-sdk", rev = "bd183b627dcb0eb682da801093b13f1f8311446b" }
34-
signet-zenith = { git = "https://github.com/init4tech/signet-sdk", rev = "bd183b627dcb0eb682da801093b13f1f8311446b" }
30+
signet-constants = { git = "https://github.com/init4tech/signet-sdk", rev = "ba5894f6fac35299d495ae115cd465a1f0791637" }
31+
signet-sim = { git = "https://github.com/init4tech/signet-sdk", rev = "ba5894f6fac35299d495ae115cd465a1f0791637" }
32+
signet-tx-cache = { git = "https://github.com/init4tech/signet-sdk", rev = "ba5894f6fac35299d495ae115cd465a1f0791637" }
33+
signet-types = { git = "https://github.com/init4tech/signet-sdk", rev = "ba5894f6fac35299d495ae115cd465a1f0791637" }
34+
signet-zenith = { git = "https://github.com/init4tech/signet-sdk", rev = "ba5894f6fac35299d495ae115cd465a1f0791637" }
3535

3636
trevm = { version = "0.23.4", features = ["concurrent-db", "test-utils"] }
3737

bin/submit_transaction.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use builder::config::HostProvider;
1111
use init4_bin_base::{
1212
deps::{
1313
metrics::{counter, histogram},
14-
tracing,
14+
tracing::{debug, error},
1515
},
1616
init4,
1717
utils::{from_env::FromEnv, signer::LocalOrAwsConfig},
@@ -52,16 +52,17 @@ async fn main() {
5252
let _guard = init4();
5353

5454
let config = Config::from_env().unwrap();
55-
tracing::trace!("connecting to provider");
55+
debug!(?config.recipient_address, "connecting to provider");
56+
5657
let provider = config.provider().await;
5758
let recipient_address = config.recipient_address;
5859
let sleep_time = config.sleep_time;
5960

6061
loop {
61-
tracing::debug!("attempting transaction");
62+
debug!(?recipient_address, "attempting transaction");
6263
send_transaction(&provider, recipient_address).await;
6364

64-
tracing::debug!(sleep_time, "sleeping");
65+
debug!(sleep_time, "sleeping");
6566
tokio::time::sleep(tokio::time::Duration::from_secs(sleep_time)).await;
6667
}
6768
}
@@ -78,18 +79,17 @@ async fn send_transaction(provider: &HostProvider, recipient_address: Address) {
7879
let dispatch_start_time: Instant = Instant::now();
7980

8081
// dispatch the transaction
81-
tracing::debug!("dispatching transaction");
8282
let result = provider.send_transaction(tx).await.unwrap();
8383

8484
// wait for the transaction to mine
8585
let receipt = match timeout(Duration::from_secs(240), result.get_receipt()).await {
8686
Ok(Ok(receipt)) => receipt,
8787
Ok(Err(e)) => {
88-
tracing::error!(error = ?e, "failed to get transaction receipt");
88+
error!(error = ?e, "failed to get transaction receipt");
8989
return;
9090
}
9191
Err(_) => {
92-
tracing::error!("timeout waiting for transaction receipt");
92+
error!("timeout waiting for transaction receipt");
9393
counter!("txn_submitter.tx_timeout").increment(1);
9494
return;
9595
}
@@ -99,6 +99,6 @@ async fn send_transaction(provider: &HostProvider, recipient_address: Address) {
9999

100100
// record metrics for how long it took to mine the transaction
101101
let mine_time = dispatch_start_time.elapsed().as_secs();
102-
tracing::debug!(success = receipt.status(), mine_time, hash, "transaction mined");
102+
debug!(success = receipt.status(), mine_time, hash, "transaction mined");
103103
histogram!("txn_submitter.tx_mine_time").record(mine_time as f64);
104104
}

src/config.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,9 @@ pub struct BuilderConfig {
7272
/// NOTE: should not include the host_rpc_url value
7373
#[from_env(
7474
var = "TX_BROADCAST_URLS",
75-
desc = "Additional RPC URLs to which to broadcast transactions",
76-
infallible
75+
desc = "Additional RPC URLs to which the builder broadcasts transactions",
76+
infallible,
77+
optional
7778
)]
7879
pub tx_broadcast_urls: Vec<Cow<'static, str>>,
7980
/// address of the Zenith contract on Host.

src/tasks/block/sim.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,10 @@ impl Simulator {
9494
self.config.rollup_block_gas_limit,
9595
);
9696

97-
let block = block_build.build().await;
98-
debug!(block = ?block, "finished block simulation");
97+
let built_block = block_build.build().await;
98+
debug!(block_number = ?built_block.block_number(), "finished building block");
9999

100-
Ok(block)
100+
Ok(built_block)
101101
}
102102

103103
/// Spawns the simulator task, which handles the setup and sets the deadline
@@ -155,8 +155,7 @@ impl Simulator {
155155

156156
// If no env, skip this run
157157
let Some(block_env) = self.block_env.borrow_and_update().clone() else { return };
158-
159-
debug!(block_env = ?block_env, "building on block");
158+
debug!(block_env = ?block_env, "building on block env");
160159

161160
match self.handle_build(constants, sim_cache, finish_by, block_env).await {
162161
Ok(block) => {

0 commit comments

Comments
 (0)