1+ use crate :: ecdsa:: PySignature ;
12use crate :: ids:: PyIds ;
23use crate :: pycell;
34use crate :: scope_manager:: { PyEnterScope , PyExitScope } ;
@@ -23,7 +24,7 @@ use std::any::Any;
2324use std:: collections:: HashMap ;
2425use std:: { cell:: RefCell , rc:: Rc } ;
2526
26- const GLOBAL_NAMES : [ & str ; 17 ] = [
27+ const GLOBAL_NAMES : [ & str ; 18 ] = [
2728 "memory" ,
2829 "segments" ,
2930 "ap" ,
@@ -33,6 +34,7 @@ const GLOBAL_NAMES: [&str; 17] = [
3334 "vm_exit_scope" ,
3435 "to_felt_or_relocatable" ,
3536 "range_check_builtin" ,
37+ "ecdsa_builtin" ,
3638 "PRIME" ,
3739 "__doc__" ,
3840 "__annotations__" ,
@@ -76,8 +78,8 @@ impl PyVM {
7678 Python :: with_gil ( |py| -> Result < ( ) , VirtualMachineError > {
7779 let memory = PyMemory :: new ( self ) ;
7880 let segments = PySegmentManager :: new ( self , memory. clone ( ) ) ;
79- let ap = PyRelocatable :: from ( self . vm . borrow ( ) . get_ap ( ) ) ;
80- let fp = PyRelocatable :: from ( self . vm . borrow ( ) . get_fp ( ) ) ;
81+ let ap = PyRelocatable :: from ( ( * self . vm ) . borrow ( ) . get_ap ( ) ) ;
82+ let fp = PyRelocatable :: from ( ( * self . vm ) . borrow ( ) . get_fp ( ) ) ;
8183 let ids = PyIds :: new (
8284 self ,
8385 & hint_data. ids_data ,
@@ -88,8 +90,9 @@ impl PyVM {
8890 let enter_scope = pycell ! ( py, PyEnterScope :: new( ) ) ;
8991 let exit_scope = pycell ! ( py, PyExitScope :: new( ) ) ;
9092 let range_check_builtin =
91- PyRangeCheck :: from ( self . vm . borrow ( ) . get_range_check_builtin ( ) ) ;
92- let prime = self . vm . borrow ( ) . get_prime ( ) . clone ( ) ;
93+ PyRangeCheck :: from ( ( * self . vm ) . borrow ( ) . get_range_check_builtin ( ) ) ;
94+ let ecdsa_builtin = pycell ! ( py, PySignature :: new( ) ) ;
95+ let prime = ( * self . vm ) . borrow ( ) . get_prime ( ) . clone ( ) ;
9396 let to_felt_or_relocatable = ToFeltOrRelocatableFunc ;
9497
9598 // This line imports Python builtins. If not imported, this will run only with Python 3.10
@@ -126,6 +129,9 @@ impl PyVM {
126129 globals
127130 . set_item ( "range_check_builtin" , range_check_builtin)
128131 . map_err ( to_vm_error) ?;
132+ globals
133+ . set_item ( "ecdsa_builtin" , ecdsa_builtin)
134+ . map_err ( to_vm_error) ?;
129135 globals. set_item ( "PRIME" , prime) . map_err ( to_vm_error) ?;
130136 globals
131137 . set_item (
@@ -155,6 +161,11 @@ impl PyVM {
155161 py,
156162 ) ;
157163
164+ if self . vm . borrow_mut ( ) . get_signature_builtin ( ) . is_ok ( ) {
165+ ecdsa_builtin
166+ . borrow ( )
167+ . update_signature ( self . vm . borrow_mut ( ) . get_signature_builtin ( ) ?) ?;
168+ }
158169 enter_scope. borrow ( ) . update_scopes ( exec_scopes) ?;
159170 exit_scope. borrow ( ) . update_scopes ( exec_scopes)
160171 } ) ?;
@@ -171,7 +182,7 @@ impl PyVM {
171182 struct_types : Rc < HashMap < String , HashMap < String , Member > > > ,
172183 constants : & HashMap < String , BigInt > ,
173184 ) -> Result < ( ) , VirtualMachineError > {
174- let pc_offset = self . vm . borrow ( ) . get_pc ( ) . offset ;
185+ let pc_offset = ( * self . vm ) . borrow ( ) . get_pc ( ) . offset ;
175186
176187 if let Some ( hint_list) = hint_data_dictionary. get ( & pc_offset) {
177188 for hint_data in hint_list. iter ( ) {
0 commit comments