Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Commit

Permalink
fix(execution): forbid calling cairo0 contract with cairo1 only builtins
Browse files Browse the repository at this point in the history
  • Loading branch information
meship-starkware committed Jul 22, 2024
1 parent 08da831 commit b200027
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@ pub struct VmExecutionContext<'a> {
pub entry_point_pc: usize,
}

pub const CAIRO0_BUILTINS_NAMES: [BuiltinName; 6] = [
BuiltinName::range_check,
BuiltinName::pedersen,
BuiltinName::ecdsa,
BuiltinName::bitwise,
BuiltinName::ec_op,
BuiltinName::poseidon,
];

/// Executes a specific call to a contract entry point and returns its output.
pub fn execute_entry_point_call(
call: CallEntryPoint,
Expand Down Expand Up @@ -72,6 +81,12 @@ pub fn initialize_execution_context<'a>(
// Resolve initial PC from EP indicator.
let entry_point_pc = resolve_entry_point_pc(call, &contract_class)?;

for builtin_name in contract_class.program.iter_builtins() {
if !CAIRO0_BUILTINS_NAMES.contains(builtin_name) {
return Err(PreExecutionError::InvalidBuiltin(builtin_name.clone().to_string()));
}
}

// Instantiate Cairo runner.
let proof_mode = false;
let trace_enabled = false;
Expand Down

0 comments on commit b200027

Please sign in to comment.