Skip to content

Commit d827c39

Browse files
authored
More error context for L1 operations (#874)
* More error context for L1 operations * fmt
1 parent 0ceb6ec commit d827c39

File tree

5 files changed

+84
-29
lines changed

5 files changed

+84
-29
lines changed

Cargo.lock

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ resolver = "2"
1313
default-members = ["node"]
1414

1515
[workspace.package]
16-
version = "1.33.6"
16+
version = "1.33.7"
1717
edition = "2024"
1818
repository = "https://github.com/NethermindEth/Catalyst"
1919
license = "MIT"

pacaya/src/l1/execution_layer.rs

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use alloy::{
1818
primitives::{Address, U256},
1919
providers::DynProvider,
2020
};
21-
use anyhow::{Error, anyhow};
21+
use anyhow::{Context, Error, anyhow};
2222
use common::{
2323
l1::{
2424
bindings::IERC20,
@@ -62,9 +62,12 @@ impl ELTrait for ExecutionLayer {
6262
.first()
6363
.ok_or_else(|| anyhow!("L1 RPC URL is required"))?,
6464
)
65-
.await?;
65+
.await
66+
.context("construct_alloy_provider")?;
6667
let common =
67-
ExecutionLayerCommon::new(provider.clone(), common_config.signer.get_address()).await?;
68+
ExecutionLayerCommon::new(provider.clone(), common_config.signer.get_address())
69+
.await
70+
.context("ExecutionLayerCommon::new")?;
6871

6972
let taiko_wrapper_contract = taiko_wrapper::TaikoWrapper::new(
7073
specific_config.contract_addresses.taiko_wrapper,
@@ -125,18 +128,21 @@ impl PreconferProvider for ExecutionLayer {
125128
self.common()
126129
.get_account_balance(self.common().preconfer_address())
127130
.await
131+
.context("get_preconfer_wallet_eth")
128132
}
129133

130134
async fn get_preconfer_nonce_pending(&self) -> Result<u64, Error> {
131135
self.common()
132136
.get_account_nonce(self.common().preconfer_address(), BlockNumberOrTag::Pending)
133137
.await
138+
.context("get_preconfer_nonce_pending")
134139
}
135140

136141
async fn get_preconfer_nonce_latest(&self) -> Result<u64, Error> {
137142
self.common()
138143
.get_account_nonce(self.common().preconfer_address(), BlockNumberOrTag::Latest)
139144
.await
145+
.context("get_preconfer_nonce_latest")
140146
}
141147

142148
fn get_preconfer_address(&self) -> Address {
@@ -238,9 +244,13 @@ impl ExecutionLayer {
238244
coinbase,
239245
forced_inclusion,
240246
)
241-
.await?;
247+
.await
248+
.context("build_propose_batch_tx")?;
242249

243-
let pending_nonce = self.get_preconfer_nonce_pending().await?;
250+
let pending_nonce = self
251+
.get_preconfer_nonce_pending()
252+
.await
253+
.context("get_preconfer_nonce_pending (send_batch_to_l1)")?;
244254
// Spawn a monitor for this transaction
245255
self.transaction_monitor
246256
.monitor_new_transaction(tx, pending_nonce)
@@ -255,7 +265,11 @@ impl ExecutionLayer {
255265
self.config.contract_addresses.taiko_inbox,
256266
&self.provider,
257267
);
258-
let pacaya_config = contract.pacayaConfig().call().await?;
268+
let pacaya_config = contract
269+
.pacayaConfig()
270+
.call()
271+
.await
272+
.context("ITaikoInbox::pacayaConfig")?;
259273

260274
info!(
261275
"Pacaya config: chainid {}, maxUnverifiedBatches {}, batchRingBufferSize {}, maxAnchorHeightOffset {}",
@@ -273,9 +287,18 @@ impl ExecutionLayer {
273287
self.config.contract_addresses.taiko_inbox,
274288
self.provider.clone(),
275289
);
276-
let num_batches = contract.getStats2().call().await?.numBatches;
290+
let num_batches = contract
291+
.getStats2()
292+
.call()
293+
.await
294+
.context("ITaikoInbox::getStats2")?
295+
.numBatches;
277296
// It is safe because num_batches initial value is 1
278-
let batch = contract.getBatch(num_batches - 1).call().await?;
297+
let batch = contract
298+
.getBatch(num_batches - 1)
299+
.call()
300+
.await
301+
.context("ITaikoInbox::getBatch")?;
279302

280303
Ok(batch.lastBlockId)
281304
}
@@ -401,7 +424,10 @@ impl ExecutionLayer {
401424
}
402425

403426
pub async fn is_transaction_in_progress(&self) -> Result<bool, Error> {
404-
self.transaction_monitor.is_transaction_in_progress().await
427+
self.transaction_monitor
428+
.is_transaction_in_progress()
429+
.await
430+
.context("is_transaction_in_progress")
405431
}
406432
}
407433

shasta/src/l1/execution_layer.rs

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use alloy::{
1010
rpc::client::BatchRequest,
1111
sol_types::SolCall,
1212
};
13-
use anyhow::{Error, anyhow};
13+
use anyhow::{Context, Error, anyhow};
1414
use common::{
1515
l1::{
1616
traits::{ELTrait, PreconferProvider},
@@ -61,9 +61,12 @@ impl ELTrait for ExecutionLayer {
6161
.first()
6262
.ok_or_else(|| anyhow!("L1 RPC URL is required"))?,
6363
)
64-
.await?;
64+
.await
65+
.context("construct_alloy_provider")?;
6566
let common =
66-
ExecutionLayerCommon::new(provider.clone(), common_config.signer.get_address()).await?;
67+
ExecutionLayerCommon::new(provider.clone(), common_config.signer.get_address())
68+
.await
69+
.context("ExecutionLayerCommon::new")?;
6770

6871
let transaction_monitor = TransactionMonitor::new(
6972
provider.clone(),
@@ -113,18 +116,21 @@ impl PreconferProvider for ExecutionLayer {
113116
self.common()
114117
.get_account_balance(self.common().preconfer_address())
115118
.await
119+
.context("get_preconfer_wallet_eth")
116120
}
117121

118122
async fn get_preconfer_nonce_pending(&self) -> Result<u64, Error> {
119123
self.common()
120124
.get_account_nonce(self.common().preconfer_address(), BlockNumberOrTag::Pending)
121125
.await
126+
.context("get_preconfer_nonce_pending")
122127
}
123128

124129
async fn get_preconfer_nonce_latest(&self) -> Result<u64, Error> {
125130
self.common()
126131
.get_account_nonce(self.common().preconfer_address(), BlockNumberOrTag::Latest)
127132
.await
133+
.context("get_preconfer_nonce_latest")
128134
}
129135

130136
fn get_preconfer_address(&self) -> Address {
@@ -193,9 +199,13 @@ impl ExecutionLayer {
193199
self.contract_addresses.shasta_inbox,
194200
num_forced_inclusion,
195201
)
196-
.await?;
202+
.await
203+
.context("build_propose_tx")?;
197204

198-
let pending_nonce = self.get_preconfer_nonce_pending().await?;
205+
let pending_nonce = self
206+
.get_preconfer_nonce_pending()
207+
.await
208+
.context("get_preconfer_nonce_pending (send_batch_to_l1)")?;
199209
// Spawn a monitor for this transaction
200210
self.transaction_monitor
201211
.monitor_new_transaction(tx, pending_nonce)
@@ -206,7 +216,10 @@ impl ExecutionLayer {
206216
}
207217

208218
pub async fn is_transaction_in_progress(&self) -> Result<bool, Error> {
209-
self.transaction_monitor.is_transaction_in_progress().await
219+
self.transaction_monitor
220+
.is_transaction_in_progress()
221+
.await
222+
.context("is_transaction_in_progress")
210223
}
211224

212225
pub async fn fetch_protocol_config(&self) -> Result<ProtocolConfig, Error> {
@@ -289,7 +302,12 @@ impl ExecutionLayer {
289302
}
290303

291304
pub async fn get_inbox_next_proposal_id(&self) -> Result<u64, Error> {
292-
let state = self.inbox_instance.getCoreState().call().await?;
305+
let state = self
306+
.inbox_instance
307+
.getCoreState()
308+
.call()
309+
.await
310+
.context("getCoreState (get_inbox_next_proposal_id)")?;
293311

294312
Ok(state.nextProposalId.to::<u64>())
295313
}

shasta/src/l1/proposal_tx_builder.rs

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use alloy::{
99
rpc::types::TransactionRequest,
1010
};
1111
use alloy_json_rpc::RpcError;
12-
use anyhow::Error;
12+
use anyhow::{Context, Error};
1313
use common::l1::{fees_per_gas::FeesPerGas, tools, transaction_error::TransactionError};
1414
use common::shared::l2_block_v2::L2BlockV2;
1515
use taiko_bindings::inbox::{IInbox::ProposeInput, Inbox, LibBlobs::BlobReference};
@@ -42,7 +42,8 @@ impl ProposalTxBuilder {
4242
) -> Result<TransactionRequest, Error> {
4343
let tx_blob = self
4444
.build_propose_blob(l2_blocks, from, to, num_forced_inclusion)
45-
.await?;
45+
.await
46+
.context("build_propose_blob")?;
4647
let tx_blob_gas = match self.provider.estimate_gas(tx_blob.clone()).await {
4748
Ok(gas) => gas,
4849
Err(e) => {
@@ -114,21 +115,31 @@ impl ProposalTxBuilder {
114115
.map_err(|e| Error::msg(format!("Can't encode and compress manifest: {e}")))?;
115116

116117
let sidecar_builder: SidecarBuilder<BlobCoder> = SidecarBuilder::from_slice(&manifest_data);
117-
let sidecar = sidecar_builder.build_7594()?;
118+
let sidecar = sidecar_builder
119+
.build_7594()
120+
.context("sidecar builder build_7594")?;
118121

119122
// Build the propose input.
120123
let input = ProposeInput {
121124
deadline: U48::ZERO,
122125
blobReference: BlobReference {
123126
blobStartIndex: 0,
124-
numBlobs: sidecar.blobs.len().try_into()?,
127+
numBlobs: sidecar
128+
.blobs
129+
.len()
130+
.try_into()
131+
.context("blobs len try_into")?,
125132
offset: U24::ZERO,
126133
},
127134
numForcedInclusions: num_forced_inclusion,
128135
};
129136

130137
let inbox = Inbox::new(to, self.provider.clone());
131-
let encoded_proposal_input = inbox.encodeProposeInput(input).call().await?;
138+
let encoded_proposal_input = inbox
139+
.encodeProposeInput(input)
140+
.call()
141+
.await
142+
.context("inbox encodeProposeInput")?;
132143

133144
let tx = TransactionRequest::default()
134145
.with_from(from)

0 commit comments

Comments
 (0)