Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(blockifier): compute valid retdata directly #2113

Merged
merged 1 commit into from
Nov 18, 2024
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
2 changes: 1 addition & 1 deletion crates/blockifier/src/transaction/account_transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -939,7 +939,7 @@ impl ValidatableTransaction for AccountTransaction {
if is_cairo1(&contract_class) {
// The account contract class is a Cairo 1.0 contract; the `validate` entry point should
// return `VALID`.
let expected_retdata = retdata![Felt::from_hex(constants::VALIDATE_RETDATA)?];
let expected_retdata = retdata![*constants::VALIDATE_RETDATA];

if validate_call_info.execution.failed {
return Err(TransactionExecutionError::PanicInValidate {
Expand Down
4 changes: 2 additions & 2 deletions crates/blockifier/src/transaction/transactions_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,9 @@ fn expected_validate_call_info(
) -> Option<CallInfo> {
let retdata = match cairo_version {
CairoVersion::Cairo0 => Retdata::default(),
CairoVersion::Cairo1 => retdata!(felt!(constants::VALIDATE_RETDATA)),
CairoVersion::Cairo1 => retdata!(*constants::VALIDATE_RETDATA),
#[cfg(feature = "cairo_native")]
CairoVersion::Native => retdata!(felt!(constants::VALIDATE_RETDATA)),
CairoVersion::Native => retdata!(*constants::VALIDATE_RETDATA),
};
// Extra range check in regular (invoke) validate call, due to passing the calldata as an array.
let n_range_checks = match cairo_version {
Expand Down
9 changes: 8 additions & 1 deletion crates/starknet_api/src/transaction/constants.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
use std::sync::LazyLock;

use starknet_types_core::felt::Felt;

use crate::core::ascii_as_felt;

pub const EXECUTE_ENTRY_POINT_NAME: &str = "__execute__";
pub const TRANSFER_ENTRY_POINT_NAME: &str = "transfer";
pub const VALIDATE_ENTRY_POINT_NAME: &str = "__validate__";
Expand All @@ -12,4 +18,5 @@ pub const FELT_FALSE: u64 = 0;
pub const FELT_TRUE: u64 = 1;

// Expected return value of a `validate` entry point: `VALID`.
pub const VALIDATE_RETDATA: &str = "0x56414c4944";
pub static VALIDATE_RETDATA: LazyLock<Felt> =
LazyLock::new(|| ascii_as_felt("VALID").expect("Failed to parse ASCII"));
Loading