Skip to content
Open
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
47 changes: 38 additions & 9 deletions crates/central_systest_blobs/src/cende_blob_regression_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,11 @@ static NON_TRIVIAL_RESOURCE_BOUNDS: LazyLock<AllResourceBounds> =
},
});

type TxPair = (ExecutableAccountTx, InternalConsensusTransaction);
struct TxData {
executable: ExecutableAccountTx,
internal: InternalConsensusTransaction,
should_revert: bool,
}

/// ID of the current blobs file.
fn current_generation() -> usize {
Expand Down Expand Up @@ -249,7 +253,7 @@ struct BlobFactory {
blocks: Vec<BlockData>,

// Transactions for the next block.
next_txs: Vec<TxPair>,
next_txs: Vec<TxData>,

// Context.
nonce_manager: NonceManager,
Expand Down Expand Up @@ -310,11 +314,18 @@ impl BlobFactory {
.unwrap();
let mut transactions_with_receipts = Vec::new();
// Consume the transactions list (next block starts empty).
for (executable, internal) in std::mem::take(&mut self.next_txs).into_iter() {
for TxData { executable, internal, should_revert } in
std::mem::take(&mut self.next_txs).into_iter()
{
let (execution_info, _state_changes) = executor
.execute(&BlockifierTx::new_for_sequencing(ExecutableTx::Account(executable)))
.unwrap();
assert!(!execution_info.is_reverted(), "Got a reverted tx: {execution_info:?}");
assert_eq!(
execution_info.is_reverted(),
should_revert,
"Execution result does not match expected (should_revert={should_revert}): \
{execution_info:?}"
);

transactions_with_receipts
.push(InternalTransactionWithReceipt { transaction: internal, execution_info });
Expand Down Expand Up @@ -511,7 +522,11 @@ impl BlobFactory {
.returning(move |_| Ok(Some(contract.get_class())));

// Return the transactions.
self.next_txs.push((executable.into(), internal_tx));
self.next_txs.push(TxData {
executable: executable.into(),
internal: internal_tx,
should_revert: false,
});
}

fn make_free_deploy_account_tx(&mut self, account: FeatureContract) -> ContractAddress {
Expand Down Expand Up @@ -563,7 +578,11 @@ impl BlobFactory {
tx: without_hash,
tx_hash,
});
self.next_txs.push((executable.into(), internal));
self.next_txs.push(TxData {
executable: executable.into(),
internal,
should_revert: false,
});
contract_address
}

Expand All @@ -573,6 +592,7 @@ impl BlobFactory {
function_name: &str,
calldata: &[Felt],
with_fee_charge: bool,
should_revert: bool,
) {
let nonce = self.nonce_manager.next(*OPERATOR_ADDRESS);
let resource_bounds = if with_fee_charge {
Expand Down Expand Up @@ -608,7 +628,7 @@ impl BlobFactory {
tx: without_hash,
tx_hash,
});
self.next_txs.push((executable.into(), internal));
self.next_txs.push(TxData { executable: executable.into(), internal, should_revert });
}

fn make_operator_deploy_tx(
Expand Down Expand Up @@ -637,6 +657,7 @@ impl BlobFactory {
"deploy_contract",
&calldata,
with_fee_charge,
false, // should not revert
);
contract_address
}
Expand Down Expand Up @@ -664,15 +685,17 @@ impl BlobFactory {
/// no commitment is computed.
fn make_preconfirmed_block_from_remaining_txs(
block_context: BlockContext,
txs: Vec<TxPair>,
txs: Vec<TxData>,
mut state: DictStateReader,
) -> CendeWritePreconfirmedBlock {
let block_info = block_context.block_info().clone();
let mut transactions = vec![];
let mut transaction_receipts = vec![];
let mut transaction_state_diffs = vec![];

for (tx_index, (executable, internal)) in txs.into_iter().enumerate() {
for (tx_index, TxData { executable, internal, should_revert }) in
txs.into_iter().enumerate()
{
let tx_hash = match &internal {
InternalConsensusTransaction::RpcTransaction(tx) => tx.tx_hash,
InternalConsensusTransaction::L1Handler(_) => {
Expand All @@ -684,6 +707,12 @@ impl BlobFactory {
let execution_info = BlockifierAccountTx::new_for_sequencing(executable)
.execute(&mut tx_state, &block_context)
.unwrap();
assert_eq!(
execution_info.is_reverted(),
should_revert,
"Execution result does not match expected (should_revert={should_revert}): \
{execution_info:?}"
);

let state_changes = tx_state.to_state_diff().unwrap();

Expand Down
Loading