pub fn revert_block_by_number(&self, val: u64) -> u64 {
        let mut inner = self.inner.write().unwrap();
        let pending_block_number = inner.pending_block_number;
        let final_block_number = inner.final_block_number;
        let allowed_blocks_to_revert = pending_block_number - final_block_number;
        if allowed_blocks_to_revert < val {
            panic!(
                "Cannot revert block number by {val}, only {allowed_blocks_to_revert} blocks left"
            );
        };

        let desired_pending_block_number = pending_block_number - val;
        inner.pending_block_number = desired_pending_block_number;
        inner.safe_block_number =
            std::cmp::min(inner.safe_block_number, desired_pending_block_number);
        inner
            .nonces
            .retain(|&block_number, _| block_number <= desired_pending_block_number);

        let current_nonce = inner.nonces.values().max().cloned().unwrap_or_default();

        inner.current_nonce = current_nonce;

        let txs: Vec<_> = inner
            .sent_txs
            .iter()
            .filter_map(|(hash, (_, block_number))| {
                if *block_number >= desired_pending_block_number {
                    Some(*hash)
                } else {
                    None
                }
            })
            .collect();

        for tx_hash in txs.iter() {
            inner.executed_txs.remove(tx_hash);
            inner.sent_txs.remove(tx_hash);
        }

        desired_pending_block_number
    }
Revert the block. It will set proper block numbers and
remove all executed transactions in reverted blocks.
core/lib/eth_client/src/clients/mock.rs