Skip to content

Commit

Permalink
fix(eth-sender): print better error message in case of missing blob p…
Browse files Browse the repository at this point in the history
…rices (matter-labs#2927)

Signed-off-by: tomg10 <lemures64@gmail.com>
Co-authored-by: perekopskiy <mikeson.dp@gmail.com>
  • Loading branch information
tomg10 and perekopskiy authored Sep 19, 2024
1 parent 2cec83f commit 38fc824
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 9 deletions.
14 changes: 13 additions & 1 deletion core/node/eth_sender/src/eth_fees_oracle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,24 @@ pub(crate) struct GasAdjusterFeesOracle {
}

impl GasAdjusterFeesOracle {
fn assert_fee_is_not_zero(&self, value: u64, fee_type: &'static str) {
if value == 0 {
panic!(
"L1 RPC incorrectly reported {fee_type} prices, either it doesn't return them at \
all or returns 0's, eth-sender cannot continue without proper {fee_type} prices!"
);
}
}
fn calculate_fees_with_blob_sidecar(
&self,
previous_sent_tx: &Option<TxHistory>,
) -> Result<EthFees, EthSenderError> {
let base_fee_per_gas = self.gas_adjuster.get_blob_tx_base_fee();
self.assert_fee_is_not_zero(base_fee_per_gas, "base");
let priority_fee_per_gas = self.gas_adjuster.get_blob_tx_priority_fee();
let blob_base_fee_per_gas = Some(self.gas_adjuster.get_blob_tx_blob_base_fee());
let blob_base_fee_per_gas = self.gas_adjuster.get_blob_tx_blob_base_fee();
self.assert_fee_is_not_zero(blob_base_fee_per_gas, "blob");
let blob_base_fee_per_gas = Some(blob_base_fee_per_gas);

if let Some(previous_sent_tx) = previous_sent_tx {
// for blob transactions on re-sending need to double all gas prices
Expand Down Expand Up @@ -72,6 +83,7 @@ impl GasAdjusterFeesOracle {
time_in_mempool: u32,
) -> Result<EthFees, EthSenderError> {
let mut base_fee_per_gas = self.gas_adjuster.get_base_fee(time_in_mempool);
self.assert_fee_is_not_zero(base_fee_per_gas, "base");
if let Some(previous_sent_tx) = previous_sent_tx {
self.verify_base_fee_not_too_low_on_resend(
previous_sent_tx.id,
Expand Down
14 changes: 7 additions & 7 deletions core/node/eth_sender/src/tester.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,16 +153,16 @@ impl EthSenderTester {
.into_iter()
.map(|base_fee_per_gas| BaseFees {
base_fee_per_gas,
base_fee_per_blob_gas: 0.into(),
base_fee_per_blob_gas: 1.into(),
l2_pubdata_price: 0.into(),
})
.collect();

let gateway = MockSettlementLayer::builder()
.with_fee_history(
std::iter::repeat_with(|| BaseFees {
base_fee_per_gas: 0,
base_fee_per_blob_gas: 0.into(),
base_fee_per_gas: 1,
base_fee_per_blob_gas: 1.into(),
l2_pubdata_price: 0.into(),
})
.take(Self::WAIT_CONFIRMATIONS as usize)
Expand All @@ -181,8 +181,8 @@ impl EthSenderTester {
let l2_gateway: MockSettlementLayer = MockSettlementLayer::builder()
.with_fee_history(
std::iter::repeat_with(|| BaseFees {
base_fee_per_gas: 0,
base_fee_per_blob_gas: 0.into(),
base_fee_per_gas: 1,
base_fee_per_blob_gas: 1.into(),
l2_pubdata_price: 0.into(),
})
.take(Self::WAIT_CONFIRMATIONS as usize)
Expand All @@ -201,8 +201,8 @@ impl EthSenderTester {
let gateway_blobs = MockSettlementLayer::builder()
.with_fee_history(
std::iter::repeat_with(|| BaseFees {
base_fee_per_gas: 0,
base_fee_per_blob_gas: 0.into(),
base_fee_per_gas: 1,
base_fee_per_blob_gas: 1.into(),
l2_pubdata_price: 0.into(),
})
.take(Self::WAIT_CONFIRMATIONS as usize)
Expand Down
2 changes: 1 addition & 1 deletion core/node/fee_model/src/l1_gas_price/gas_adjuster/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ async fn kept_updated_l2(commitment_mode: L1BatchCommitmentMode) {
.zip(TEST_PUBDATA_PRICES)
.map(|(block, pubdata)| BaseFees {
base_fee_per_gas: block,
base_fee_per_blob_gas: 0.into(),
base_fee_per_blob_gas: 1.into(),
l2_pubdata_price: pubdata.into(),
})
.collect();
Expand Down
2 changes: 2 additions & 0 deletions zk_toolbox/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 38fc824

Please sign in to comment.