Skip to content

Commit

Permalink
Merge branch 'main' into fix-clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
antiyro authored Oct 14, 2024
2 parents 46b362a + be95a6d commit 58893ec
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Next release

- fix(clippy): disallow printlns in workspace
- fix(db): storing a block needs to clear the current pending block
- fix(sync): Fixed pipeline stalling on machines with few cpu cores
- fix(rpc): handle batched requests in middleware
- chore: padded devnet address display with 64 chars
Expand Down
3 changes: 3 additions & 0 deletions crates/client/db/src/storage_updates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ impl MadaraBackend {
let block_n = block.info.block_n();
let state_diff_cpy = state_diff.clone();

// Clear in every case, even when storing a pending block
self.clear_pending_block()?;

let task_block_db = || match block.info {
MadaraMaybePendingBlockInfo::Pending(info) => {
self.block_db_store_pending(&MadaraPendingBlock { info, inner: block.inner }, &state_diff_cpy)
Expand Down
7 changes: 7 additions & 0 deletions crates/client/mempool/src/block_production.rs
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,13 @@ impl<Mempool: MempoolProvider> BlockProductionTask<Mempool> {
instant = interval_block_time.tick() => {
if let Err(err) = self.on_block_time().await {
log::error!("Block production task has errored: {err:#}");
// Clear pending block. The reason we do this is because if the error happened because the closed
// block is invalid or has not been saved properly, we want to avoid redoing the same error in the next
// block. So we drop all the transactions in the pending block just in case.
// If the problem happened after the block was closed and saved to the db, this will do nothing.
if let Err(err) = self.backend.clear_pending_block() {
log::error!("Error while clearing the pending block in recovery of block production error: {err:#}");
}
}
// ensure the pending block tick and block time match up
interval_pending_block_update.reset_at(instant + interval_pending_block_update.period());
Expand Down
6 changes: 5 additions & 1 deletion crates/client/mempool/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use mp_block::BlockId;
use mp_block::BlockTag;
use mp_block::MadaraPendingBlockInfo;
use mp_class::ConvertedClass;
use mp_convert::ToFelt;
use mp_transactions::broadcasted_to_blockifier;
use mp_transactions::BroadcastedToBlockifierError;
use starknet_api::core::{ContractAddress, Nonce};
Expand Down Expand Up @@ -125,12 +126,15 @@ impl Mempool {
None
};

log::debug!("Mempool verify tx_hash={:#x}", tx_hash(&tx).to_felt());

// Perform validations
let exec_context = ExecutionContext::new_in_block(Arc::clone(&self.backend), &pending_block_info)?;
let mut validator = exec_context.tx_validator();
let _ = validator.perform_validations(clone_account_tx(&tx), deploy_account_tx_hash.is_some());
validator.perform_validations(clone_account_tx(&tx), deploy_account_tx_hash.is_some())?;

if !is_only_query(&tx) {
log::debug!("Adding to mempool tx_hash={:#x}", tx_hash(&tx).to_felt());
// Finally, add it to the nonce chain for the account nonce
let force = false;
self.inner
Expand Down

0 comments on commit 58893ec

Please sign in to comment.