From b200027b4dba83c290445ed689a7b6b80aa5c141 Mon Sep 17 00:00:00 2001 From: meship-starkware Date: Mon, 22 Jul 2024 14:19:42 +0300 Subject: [PATCH] fix(execution): forbid calling cairo0 contract with cairo1 only builtins --- .../execution/deprecated_entry_point_execution.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/crates/blockifier/src/execution/deprecated_entry_point_execution.rs b/crates/blockifier/src/execution/deprecated_entry_point_execution.rs index 4f84b19d03..619fe16539 100644 --- a/crates/blockifier/src/execution/deprecated_entry_point_execution.rs +++ b/crates/blockifier/src/execution/deprecated_entry_point_execution.rs @@ -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, @@ -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;