Skip to content

Commit ffac7e1

Browse files
byteZorvinheemankvMohiiit
authored
L3 bugs (#851)
Co-authored-by: Heemank Verma <[email protected]> Co-authored-by: Mohit Dhattarwal <[email protected]>
1 parent cadb2ee commit ffac7e1

File tree

30 files changed

+193
-143
lines changed

30 files changed

+193
-143
lines changed

.github/workflows/task-lint-cargo.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,13 @@ jobs:
4545
echo "Running cargo clippy..."
4646
cargo clippy --workspace --no-deps -- -D warnings
4747
cargo clippy --workspace --tests --no-deps -- -D warnings
48+
49+
# TODO(mehul 14/11/2025, hotfix): This is a temporary fix to ensure that the madara is linted.
50+
# Madara does not belong to the toplevel workspace, so we need to lint it separately.
51+
# Remove this once we add madara back to toplevel workspace.
52+
53+
echo "Running cargo clippy for madara..."
54+
cd madara
55+
cargo clippy --workspace --no-deps -- -D warnings
56+
cargo clippy --workspace --tests --no-deps -- -D warnings
57+
cd ..

bootstrapper/src/configs/devnet.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"rollup_declare_v0_seq_url": "http://127.0.0.1:9943",
44
"eth_priv_key": "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80",
55
"config_hash_version": "StarknetOsConfig2",
6-
"l2_deployer_address": "0x055be462e718c4166d656d11f89e341115b8bc82389c3762a10eade04fcb225d",
76
"rollup_priv_key": "0x077e56c6dc32d40a67f6f7e6625c8dc5e570abe49c0a24e9202e4ae906abcc07",
87
"eth_chain_id": 31337,
98
"l1_deployer_address": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",

bootstrapper/src/setup_scripts/udc.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ impl<'a> UdcSetup<'a> {
3939
Vec::from([udc_class_hash, Felt::ZERO, Felt::ONE, Felt::ZERO]),
4040
None,
4141
)
42+
.l1_gas(0)
43+
.l1_data_gas(0)
44+
.l2_gas(0)
4245
.send()
4346
.await
4447
.unwrap();

madara/clippy.toml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
allow-print-in-tests = true
2+
allow-unwrap-in-tests = true
3+
4+
# Suppress large error type warnings - these are common with AWS SDK errors
5+
# and would require significant refactoring to fix properly
6+
too-large-for-stack = 1000
7+
8+
# Allow needless updates - sometimes used for clarity in struct initialization
9+
# Even when all fields are specified, ..Default::default() can make intent clearer
10+
11+
# Set a higher threshold for result-large-err to accommodate AWS SDK errors
12+
# which are inherently large due to comprehensive error handling
13+
type-complexity-threshold = 250

madara/crates/client/block_production/src/executor/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ pub enum ExecutorMessage {
4949
exec_ctx: BlockExecutionContext,
5050
},
5151
BatchExecuted(BatchExecutionResult),
52-
EndBlock(BlockExecutionSummary),
52+
EndBlock(Box<BlockExecutionSummary>),
5353
}
5454

5555
#[derive(Default, Debug)]

madara/crates/client/block_production/src/executor/thread.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ impl ExecutorThread {
433433
);
434434
let block_exec_summary = execution_state.executor.finalize()?;
435435

436-
if self.replies_sender.blocking_send(super::ExecutorMessage::EndBlock(block_exec_summary)).is_err() {
436+
if self.replies_sender.blocking_send(super::ExecutorMessage::EndBlock(Box::new(block_exec_summary))).is_err() {
437437
// Receiver closed
438438
break Ok(());
439439
}

madara/crates/client/block_production/src/util.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,9 @@ pub(crate) fn create_execution_context(
170170
previous_l2_gas_price: u128,
171171
previous_l2_gas_used: u128,
172172
) -> anyhow::Result<BlockExecutionContext> {
173-
174-
let (block_timestamp, gas_prices) = if let Some(custom_header) = backend.get_custom_header().filter(|h| h.block_n == block_n) {
173+
let (block_timestamp, gas_prices) = if let Some(custom_header) =
174+
backend.get_custom_header().filter(|h| h.block_n == block_n)
175+
{
175176
// Convert Unix timestamp (seconds since Jan 1, 1970) to SystemTime
176177
let block_timestamp = UNIX_EPOCH + Duration::from_secs(custom_header.timestamp);
177178
let gas_prices = custom_header.gas_prices;

madara/crates/client/db/src/lib.rs

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ use crate::storage::StoredChainInfo;
121121
use crate::sync_status::SyncStatusCell;
122122
use mp_block::commitments::BlockCommitments;
123123
use mp_block::commitments::CommitmentComputationContext;
124+
use mp_block::header::CustomHeader;
124125
use mp_block::BlockHeaderWithSignatures;
125126
use mp_block::FullBlockWithoutCommitments;
126127
use mp_block::TransactionWithReceipt;
@@ -133,7 +134,6 @@ use mp_transactions::L1HandlerTransactionWithFee;
133134
use prelude::*;
134135
use std::path::Path;
135136
use std::sync::{Arc, Mutex};
136-
use mp_block::header::CustomHeader;
137137
mod db_version;
138138
mod prelude;
139139
pub mod storage;
@@ -404,7 +404,6 @@ impl<D: MadaraStorage> MadaraBackend<D> {
404404
pub fn flush(&self) -> Result<()> {
405405
self.db.flush()
406406
}
407-
408407
}
409408

410409
impl MadaraBackend<RocksDBStorage> {
@@ -582,7 +581,9 @@ impl<D: MadaraStorage> MadaraBackendWriter<D> {
582581
.context("There is no current preconfirmed block")?
583582
.get_full_block_with_classes()?;
584583

585-
if let Some(state_diff) = state_diff {
584+
if let Some(mut state_diff) = state_diff {
585+
state_diff.old_declared_contracts =
586+
std::mem::replace(&mut block.state_diff.old_declared_contracts, state_diff.old_declared_contracts);
586587
block.state_diff = state_diff;
587588
}
588589

@@ -652,20 +653,13 @@ impl<D: MadaraStorage> MadaraBackendWriter<D> {
652653
block.header.clone().into_confirmed_header(parent_block_hash, commitments.clone(), global_state_root);
653654
let block_hash = header.compute_hash(self.inner.chain_config.chain_id.to_felt(), pre_v0_13_2_hash_override);
654655

655-
tracing::info!(
656-
"🙇 Block hash {:?} computed for #{}",
657-
block_hash,
658-
block.header.block_number
659-
);
656+
tracing::info!("🙇 Block hash {:?} computed for #{}", block_hash, block.header.block_number);
660657

661-
match self.inner.get_custom_header_with_clear(true) {
662-
Some(header) => {
663-
let is_valid = header.is_block_hash_as_expected(&block_hash);
664-
if !is_valid {
665-
tracing::warn!("Block hash not as expected for {}", block.header.block_number);
666-
}
658+
if let Some(header) = self.inner.get_custom_header_with_clear(true) {
659+
let is_valid = header.is_block_hash_as_expected(&block_hash);
660+
if !is_valid {
661+
tracing::warn!("Block hash not as expected for {}", block.header.block_number);
667662
}
668-
None => {}
669663
}
670664

671665
// Save the block.

madara/crates/client/db/src/rocksdb/l1_to_l2_messages.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,7 @@ impl RocksDBStorageInner {
7878

7979
pub(super) fn write_l1_handler_txn_hash_by_nonce(&self, core_contract_nonce: u64, txn_hash: &Felt) -> Result<()> {
8080
let on_l2_cf = self.get_column(L1_TO_L2_TXN_HASH_BY_NONCE);
81-
self.db.put_cf_opt(
82-
&on_l2_cf,
83-
core_contract_nonce.to_be_bytes(),
84-
txn_hash.to_bytes_be(),
85-
&self.writeopts,
86-
)?;
81+
self.db.put_cf_opt(&on_l2_cf, core_contract_nonce.to_be_bytes(), txn_hash.to_bytes_be(), &self.writeopts)?;
8782
Ok(())
8883
}
8984

madara/crates/client/db/src/rocksdb/meta.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,7 @@ impl RocksDBStorageInner {
6464
&self.writeopts,
6565
)?;
6666
} else {
67-
self.db.delete_cf_opt(
68-
&self.get_column(META_COLUMN),
69-
META_CONFIRMED_ON_L1_TIP_KEY,
70-
&self.writeopts,
71-
)?;
67+
self.db.delete_cf_opt(&self.get_column(META_COLUMN), META_CONFIRMED_ON_L1_TIP_KEY, &self.writeopts)?;
7268
}
7369
Ok(())
7470
}
@@ -231,11 +227,7 @@ impl RocksDBStorageInner {
231227
&self.writeopts,
232228
)?;
233229
} else {
234-
self.db.delete_cf_opt(
235-
&self.get_column(META_COLUMN),
236-
META_LATEST_APPLIED_TRIE_UPDATE,
237-
&self.writeopts,
238-
)?;
230+
self.db.delete_cf_opt(&self.get_column(META_COLUMN), META_LATEST_APPLIED_TRIE_UPDATE, &self.writeopts)?;
239231
}
240232
Ok(())
241233
}

0 commit comments

Comments
 (0)