From 21abd64daf9751e833818089a2d7c9200f612eb4 Mon Sep 17 00:00:00 2001 From: Edgar Luque Date: Tue, 20 Aug 2024 10:03:57 +0200 Subject: [PATCH] temp --- src/starknet/tx_v2_info.rs | 8 +++---- src/vm/enum.rs | 2 ++ src/vm/starknet.rs | 46 ++++++++++++++++++++++++++++---------- 3 files changed, 40 insertions(+), 16 deletions(-) diff --git a/src/starknet/tx_v2_info.rs b/src/starknet/tx_v2_info.rs index 0495a30..4086365 100644 --- a/src/starknet/tx_v2_info.rs +++ b/src/starknet/tx_v2_info.rs @@ -38,19 +38,19 @@ impl TxV2Info { Value::Felt(self.transaction_hash), Value::Felt(self.chain_id), Value::Felt(self.nonce), - Value::Array { + Value::Struct(vec![Value::Array { ty: resource_bounds_ty, data: self .resource_bounds .into_iter() .map(ResourceBounds::into_value) .collect(), - }, + }]), Value::U128(self.tip), - Value::Array { + Value::Struct(vec![Value::Array { ty: felt252_ty.clone(), data: self.paymaster_data.into_iter().map(Value::Felt).collect(), - }, + }]), Value::U32(self.nonce_data_availability_mode), Value::U32(self.fee_data_availability_mode), Value::Array { diff --git a/src/vm/enum.rs b/src/vm/enum.rs index a76e51b..63fcecb 100644 --- a/src/vm/enum.rs +++ b/src/vm/enum.rs @@ -38,6 +38,8 @@ pub fn eval_init( }; assert_eq!(info.n_variants, variants.len()); assert!(info.index < info.n_variants); + dbg!(&value); + dbg!(&variants[info.index]); assert!(value.is(registry, &variants[info.index])); EvalAction::NormalBranch( diff --git a/src/vm/starknet.rs b/src/vm/starknet.rs index 2b1febe..3770532 100644 --- a/src/vm/starknet.rs +++ b/src/vm/starknet.rs @@ -496,27 +496,49 @@ fn eval_get_execution_info_v2( let result = syscall_handler.get_execution_info_v2(&mut gas); - let out_ty = registry + let mut out_ty = registry .get_type(&info.branch_signatures()[0].vars[2].ty) .unwrap(); + let mut out_ty_id = &info.branch_signatures()[0].vars[2].ty; - let out_ty = if let CoreTypeConcrete::Struct(inner) = out_ty { - let out_ty = registry.get_type(&inner.members[1]).unwrap(); + if let CoreTypeConcrete::Box(inner) = out_ty { + out_ty_id = &inner.ty; + out_ty = registry.get_type(&inner.ty).unwrap(); + }; - if let CoreTypeConcrete::Struct(inner) = out_ty { - // should be resourcebound ty - inner.members[7].clone() - } else { - panic!() - } - } else { - panic!() + if let CoreTypeConcrete::Struct(inner) = out_ty { + out_ty_id = &inner.members[1]; + out_ty = registry.get_type(&inner.members[1]).unwrap(); + }; + + if let CoreTypeConcrete::Box(inner) = out_ty { + out_ty_id = &inner.ty; + out_ty = registry.get_type(&inner.ty).unwrap(); + }; + + if let CoreTypeConcrete::Struct(inner) = out_ty { + out_ty_id = &inner.members[7]; + out_ty = registry.get_type(&inner.members[7]).unwrap(); + }; + + if let CoreTypeConcrete::Struct(inner) = out_ty { + out_ty_id = &inner.members[0]; + out_ty = registry.get_type(&inner.members[0]).unwrap(); + }; + if let CoreTypeConcrete::Snapshot(inner) = out_ty { + out_ty_id = &inner.ty; + out_ty = registry.get_type(&inner.ty).unwrap(); + }; + if let CoreTypeConcrete::Array(inner) = out_ty { + out_ty_id = &inner.ty; + out_ty = registry.get_type(&inner.ty).unwrap(); }; + dbg!(&out_ty_id); match result { Ok(res) => EvalAction::NormalBranch( 0, - smallvec![Value::U128(gas), system, res.into_value(felt_ty, out_ty)], + smallvec![Value::U128(gas), system, res.into_value(felt_ty, out_ty_id.clone())], ), Err(e) => EvalAction::NormalBranch( 1,