Skip to content
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
3 changes: 1 addition & 2 deletions crates/blockifier/src/fee/receipt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,7 @@ impl TransactionReceipt {
tx_type: account_tx.tx_type(),
reverted_steps,
reverted_sierra_gas,
// TODO(AvivG): Get proof facts length from account_tx when it supports retrieving it.
proof_facts_length: 0,
proof_facts_length: account_tx.proof_facts_length(),
})
}
}
4 changes: 4 additions & 0 deletions crates/blockifier/src/transaction/account_transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,10 @@ impl AccountTransaction {
self.signature().0.len()
}

pub fn proof_facts_length(&self) -> usize {
if let Transaction::Invoke(tx) = &self.tx { tx.proof_facts_length() } else { 0 }
}

pub fn enforce_fee(&self) -> bool {
self.create_tx_info().enforce_fee()
}
Expand Down
30 changes: 28 additions & 2 deletions crates/blockifier/src/transaction/transactions_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,32 @@ fn test_invoke_tx(
) {
let block_context = &BlockContext::create_for_account_testing_with_kzg(use_kzg_da);
let versioned_constants = &block_context.versioned_constants;

// Adjust resource bounds for client-side proving transactions.
let resource_bounds = if proof_facts.is_empty() {
resource_bounds
} else {
match resource_bounds {
ValidResourceBounds::AllResources(all_bounds) => {
// For client-side proving transactions, reserve extra L2 gas for the fixed proof
// cost.
let proof_gas_cost: u64 =
versioned_constants.archival_data_gas_costs.gas_per_proof.to_integer();

ValidResourceBounds::AllResources(AllResourceBounds {
l2_gas: ResourceBounds {
max_amount: GasAmount(all_bounds.l2_gas.max_amount.0 + proof_gas_cost),
..all_bounds.l2_gas
},
..all_bounds
})
}
// Skip impossible combination: proof_facts only exist in V3 transactions,
// and V3 uses AllResourceBounds (L1Gas is legacy-only).
ValidResourceBounds::L1Gas(_) => return,
}
};

let account_contract = FeatureContract::AccountWithoutValidations(account_cairo_version);
let test_contract = FeatureContract::TestContract(CairoVersion::Cairo0);
let chain_info = &block_context.chain_info;
Expand All @@ -623,6 +649,7 @@ fn test_invoke_tx(
// transaction.
let calldata_length = invoke_tx.calldata_length();
let signature_length = invoke_tx.signature_length();
let proof_facts_length = invoke_tx.proof_facts_length();
let state_changes_for_fee = StateChangesCount {
n_storage_updates: 1,
n_modified_contracts: 1,
Expand All @@ -635,8 +662,7 @@ fn test_invoke_tx(
StateResources::new_for_testing(state_changes_for_fee, 0),
None,
ExecutionSummary::default(),
// TODO(AvivG): Test non-zero proof facts length after invoke_tx supports retrieving it.
0,
proof_facts_length,
);
let sender_address = invoke_tx.sender_address();

Expand Down
10 changes: 10 additions & 0 deletions crates/starknet_api/src/executable_transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,16 @@ impl InvokeTransaction {
let tx_hash = invoke_tx.calculate_transaction_hash(chain_id, &invoke_tx.version())?;
Ok(Self { tx: invoke_tx, tx_hash })
}

/// Returns the length of proof facts for client-side proving.
pub fn proof_facts_length(&self) -> usize {
match &self.tx {
crate::transaction::InvokeTransaction::V3(tx) => tx.proof_facts.0.len(),
// Client-side proving is only supported starting from V3.
crate::transaction::InvokeTransaction::V0(_)
| crate::transaction::InvokeTransaction::V1(_) => 0,
}
}
}

#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize, Hash)]
Expand Down
Loading