Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(eth-sender): print better error message in case of missing blob prices #2927

Merged
merged 5 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
perekopskiy marked this conversation as resolved.
Show resolved Hide resolved
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.

Loading