From 97b7ad38a98b022d597939203143fe3557cbb4b8 Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Fri, 23 Jun 2023 17:09:03 -0700 Subject: [PATCH 1/3] Change [IU]256 arithmetic host functions to take *Val not *Object. --- soroban-env-common/env.json | 72 +++++++++--------- soroban-env-common/src/convert.rs | 48 ++++++++++-- soroban-env-common/src/env.rs | 6 +- soroban-env-common/src/meta.rs | 2 +- soroban-env-common/src/unimplemented_env.rs | 6 +- soroban-env-common/src/vmcaller_env.rs | 6 +- soroban-env-guest/src/guest.rs | 8 +- .../src/cost_runner/cost_types/num_ops.rs | 19 ++--- soroban-env-host/src/host.rs | 30 ++++---- soroban-env-host/src/host/num.rs | 57 +++++++------- soroban-env-host/src/test/num.rs | 76 +++++++++---------- soroban-env-host/src/vm/dispatch.rs | 4 +- 12 files changed, 180 insertions(+), 154 deletions(-) diff --git a/soroban-env-common/env.json b/soroban-env-common/env.json index 083a2622c..f8af5d745 100644 --- a/soroban-env-common/env.json +++ b/soroban-env-common/env.json @@ -453,14 +453,14 @@ "args": [ { "name": "lhs", - "type": "U256Object" + "type": "U256Val" }, { "name": "rhs", - "type": "U256Object" + "type": "U256Val" } ], - "return": "U256Object", + "return": "U256Val", "docs": "Performs checked integer addition. Computes `lhs + rhs`, returning `ScError` if overflow occurred. " }, { @@ -469,14 +469,14 @@ "args": [ { "name": "lhs", - "type": "U256Object" + "type": "U256Val" }, { "name": "rhs", - "type": "U256Object" + "type": "U256Val" } ], - "return": "U256Object", + "return": "U256Val", "docs": "Performs checked integer subtraction. Computes `lhs - rhs`, returning `ScError` if overflow occurred. " }, { @@ -485,14 +485,14 @@ "args": [ { "name": "lhs", - "type": "U256Object" + "type": "U256Val" }, { "name": "rhs", - "type": "U256Object" + "type": "U256Val" } ], - "return": "U256Object", + "return": "U256Val", "docs": "Performs checked integer multiplication. Computes `lhs * rhs`, returning `ScError` if overflow occurred. " }, { @@ -501,14 +501,14 @@ "args": [ { "name": "lhs", - "type": "U256Object" + "type": "U256Val" }, { "name": "rhs", - "type": "U256Object" + "type": "U256Val" } ], - "return": "U256Object", + "return": "U256Val", "docs": "Performs checked integer division. Computes `lhs / rhs`, returning `ScError` if `rhs == 0` or overflow occurred. " }, { @@ -517,14 +517,14 @@ "args": [ { "name": "lhs", - "type": "U256Object" + "type": "U256Val" }, { "name": "rhs", "type": "U32Val" } ], - "return": "U256Object", + "return": "U256Val", "docs": "Performs checked exponentiation. Computes `lhs.exp(rhs)`, returning `ScError` if overflow occurred. " }, { @@ -533,14 +533,14 @@ "args": [ { "name": "lhs", - "type": "U256Object" + "type": "U256Val" }, { "name": "rhs", "type": "U32Val" } ], - "return": "U256Object", + "return": "U256Val", "docs": "Performs checked shift left. Computes `lhs << rhs`, returning `ScError` if `rhs` is larger than or equal to the number of bits in `lhs`." }, { @@ -549,14 +549,14 @@ "args": [ { "name": "lhs", - "type": "U256Object" + "type": "U256Val" }, { "name": "rhs", "type": "U32Val" } ], - "return": "U256Object", + "return": "U256Val", "docs": "Performs checked shift right. Computes `lhs >> rhs`, returning `ScError` if `rhs` is larger than or equal to the number of bits in `lhs`." }, { @@ -565,14 +565,14 @@ "args": [ { "name": "lhs", - "type": "I256Object" + "type": "I256Val" }, { "name": "rhs", - "type": "I256Object" + "type": "I256Val" } ], - "return": "I256Object", + "return": "I256Val", "docs": "Performs checked integer addition. Computes `lhs + rhs`, returning `ScError` if overflow occurred. " }, { @@ -581,14 +581,14 @@ "args": [ { "name": "lhs", - "type": "I256Object" + "type": "I256Val" }, { "name": "rhs", - "type": "I256Object" + "type": "I256Val" } ], - "return": "I256Object", + "return": "I256Val", "docs": "Performs checked integer subtraction. Computes `lhs - rhs`, returning `ScError` if overflow occurred. " }, { @@ -597,14 +597,14 @@ "args": [ { "name": "lhs", - "type": "I256Object" + "type": "I256Val" }, { "name": "rhs", - "type": "I256Object" + "type": "I256Val" } ], - "return": "I256Object", + "return": "I256Val", "docs": "Performs checked integer multiplication. Computes `lhs * rhs`, returning `ScError` if overflow occurred. " }, { @@ -613,14 +613,14 @@ "args": [ { "name": "lhs", - "type": "I256Object" + "type": "I256Val" }, { "name": "rhs", - "type": "I256Object" + "type": "I256Val" } ], - "return": "I256Object", + "return": "I256Val", "docs": "Performs checked integer division. Computes `lhs / rhs`, returning `ScError` if `rhs == 0` or overflow occurred. " }, { @@ -629,14 +629,14 @@ "args": [ { "name": "lhs", - "type": "I256Object" + "type": "I256Val" }, { "name": "rhs", "type": "U32Val" } ], - "return": "I256Object", + "return": "I256Val", "docs": "Performs checked exponentiation. Computes `lhs.exp(rhs)`, returning `ScError` if overflow occurred. " }, { @@ -645,14 +645,14 @@ "args": [ { "name": "lhs", - "type": "I256Object" + "type": "I256Val" }, { "name": "rhs", "type": "U32Val" } ], - "return": "I256Object", + "return": "I256Val", "docs": "Performs checked shift left. Computes `lhs << rhs`, returning `ScError` if `rhs` is larger than or equal to the number of bits in `lhs`." }, { @@ -661,14 +661,14 @@ "args": [ { "name": "lhs", - "type": "I256Object" + "type": "I256Val" }, { "name": "rhs", "type": "U32Val" } ], - "return": "I256Object", + "return": "I256Val", "docs": "Performs checked shift right. Computes `lhs >> rhs`, returning `ScError` if `rhs` is larger than or equal to the number of bits in `lhs`." }, { diff --git a/soroban-env-common/src/convert.rs b/soroban-env-common/src/convert.rs index e1644526e..b4bf0170e 100644 --- a/soroban-env-common/src/convert.rs +++ b/soroban-env-common/src/convert.rs @@ -1,7 +1,8 @@ use crate::{ num::{i256_from_pieces, i256_into_pieces, u256_from_pieces, u256_into_pieces}, - ConversionError, DurationSmall, DurationVal, Env, I128Small, I256Small, I64Small, - TimepointSmall, TimepointVal, U128Small, U256Small, U64Small, U64Val, Val, I256, U256, + ConversionError, DurationSmall, DurationVal, Env, I128Small, I128Val, I256Small, I256Val, + I64Small, TimepointSmall, TimepointVal, U128Small, U128Val, U256Small, U256Val, U64Small, + U64Val, Val, I256, U256, }; use core::fmt::Debug; use stellar_xdr::int128_helpers; @@ -94,12 +95,7 @@ impl TryFromVal for Val { type Error = ConversionError; fn try_from_val(env: &E, v: &u64) -> Result { - let v = *v; - if let Ok(so) = U64Small::try_from(v) { - Ok(so.into()) - } else { - Ok(env.obj_from_u64(v).map_err(|_| ConversionError)?.to_val()) - } + Ok(U64Val::try_from_val(env, v)?.to_val()) } } @@ -209,9 +205,18 @@ impl TryFromVal for i128 { } } } + impl TryFromVal for Val { type Error = ConversionError; + fn try_from_val(env: &E, v: &i128) -> Result { + Ok(I128Val::try_from_val(env, v)?.to_val()) + } +} + +impl TryFromVal for I128Val { + type Error = ConversionError; + fn try_from_val(env: &E, v: &i128) -> Result { let v = *v; if let Ok(so) = I128Small::try_from(v) { @@ -242,9 +247,18 @@ impl TryFromVal for u128 { } } } + impl TryFromVal for Val { type Error = ConversionError; + fn try_from_val(env: &E, v: &u128) -> Result { + Ok(U128Val::try_from_val(env, v)?.to_val()) + } +} + +impl TryFromVal for U128Val { + type Error = ConversionError; + fn try_from_val(env: &E, v: &u128) -> Result { let v = *v; if let Ok(so) = U128Small::try_from(v) { @@ -276,9 +290,18 @@ impl TryFromVal for I256 { } } } + impl TryFromVal for Val { type Error = ConversionError; + fn try_from_val(env: &E, v: &I256) -> Result { + Ok(I256Val::try_from_val(env, v)?.to_val()) + } +} + +impl TryFromVal for I256Val { + type Error = ConversionError; + fn try_from_val(env: &E, v: &I256) -> Result { let v = *v; if let Ok(so) = I256Small::try_from(v) { @@ -311,9 +334,18 @@ impl TryFromVal for U256 { } } } + impl TryFromVal for Val { type Error = ConversionError; + fn try_from_val(env: &E, v: &U256) -> Result { + Ok(U256Val::try_from_val(env, v)?.to_val()) + } +} + +impl TryFromVal for U256Val { + type Error = ConversionError; + fn try_from_val(env: &E, v: &U256) -> Result { let v = *v; if let Ok(so) = U256Small::try_from(v) { diff --git a/soroban-env-common/src/env.rs b/soroban-env-common/src/env.rs index 596b599de..dff4a438a 100644 --- a/soroban-env-common/src/env.rs +++ b/soroban-env-common/src/env.rs @@ -2,9 +2,9 @@ use soroban_env_macros::generate_call_macro_with_all_host_functions; use super::Symbol; use super::{ - AddressObject, Bool, BytesObject, DurationObject, Error, I128Object, I256Object, I64Object, - MapObject, StorageType, StringObject, SymbolObject, TimepointObject, U128Object, U256Object, - U32Val, U64Object, U64Val, Val, VecObject, Void, + AddressObject, Bool, BytesObject, DurationObject, Error, I128Object, I256Object, I256Val, + I64Object, MapObject, StorageType, StringObject, SymbolObject, TimepointObject, U128Object, + U256Object, U256Val, U32Val, U64Object, U64Val, Val, VecObject, Void, }; use core::any; diff --git a/soroban-env-common/src/meta.rs b/soroban-env-common/src/meta.rs index f9ed1d461..5aa5d378e 100644 --- a/soroban-env-common/src/meta.rs +++ b/soroban-env-common/src/meta.rs @@ -42,7 +42,7 @@ pub const ENV_META_V0_SECTION_NAME: &str = "contractenvmetav0"; soroban_env_macros::generate_env_meta_consts!( ledger_protocol_version: 20, - pre_release_version: 49, + pre_release_version: 50, ); pub fn get_ledger_protocol_version(interface_version: u64) -> u32 { diff --git a/soroban-env-common/src/unimplemented_env.rs b/soroban-env-common/src/unimplemented_env.rs index 1e68fb9e8..a601a73ba 100644 --- a/soroban-env-common/src/unimplemented_env.rs +++ b/soroban-env-common/src/unimplemented_env.rs @@ -1,8 +1,8 @@ use super::{call_macro_with_all_host_functions, Env, EnvBase, Symbol}; use super::{ - AddressObject, Bool, BytesObject, DurationObject, Error, I128Object, I256Object, I64Object, - MapObject, StorageType, StringObject, SymbolObject, TimepointObject, U128Object, U256Object, - U32Val, U64Object, U64Val, Val, VecObject, Void, + AddressObject, Bool, BytesObject, DurationObject, Error, I128Object, I256Object, I256Val, + I64Object, MapObject, StorageType, StringObject, SymbolObject, TimepointObject, U128Object, + U256Object, U256Val, U32Val, U64Object, U64Val, Val, VecObject, Void, }; use core::{any, convert::Infallible}; diff --git a/soroban-env-common/src/vmcaller_env.rs b/soroban-env-common/src/vmcaller_env.rs index b812ccdc9..9fa4bcafd 100644 --- a/soroban-env-common/src/vmcaller_env.rs +++ b/soroban-env-common/src/vmcaller_env.rs @@ -2,9 +2,9 @@ use stellar_xdr::{ScErrorCode, ScErrorType}; use super::{ - AddressObject, Bool, BytesObject, DurationObject, Error, I128Object, I256Object, I64Object, - MapObject, StorageType, StringObject, SymbolObject, TimepointObject, U128Object, U256Object, - U32Val, U64Object, U64Val, Val, VecObject, Void, + AddressObject, Bool, BytesObject, DurationObject, Error, I128Object, I256Object, I256Val, + I64Object, MapObject, StorageType, StringObject, SymbolObject, TimepointObject, U128Object, + U256Object, U256Val, U32Val, U64Object, U64Val, Val, VecObject, Void, }; use crate::call_macro_with_all_host_functions; use crate::{EnvBase, Symbol}; diff --git a/soroban-env-guest/src/guest.rs b/soroban-env-guest/src/guest.rs index a095b7b00..b50dbc9de 100644 --- a/soroban-env-guest/src/guest.rs +++ b/soroban-env-guest/src/guest.rs @@ -6,9 +6,9 @@ use core::convert::Infallible; use soroban_env_common::call_macro_with_all_host_functions; use super::{ - AddressObject, Bool, BytesObject, DurationObject, Error, I128Object, I256Object, I64Object, - MapObject, StorageType, StringObject, SymbolObject, TimepointObject, U128Object, U256Object, - U32Val, U64Object, U64Val, Val, VecObject, Void, + AddressObject, Bool, BytesObject, DurationObject, Error, I128Object, I256Object, I256Val, + I64Object, MapObject, StorageType, StringObject, SymbolObject, TimepointObject, U128Object, + U256Object, U256Val, U32Val, U64Object, U64Val, Val, VecObject, Void, }; use super::{Env, EnvBase, Symbol}; #[cfg(target_family = "wasm")] @@ -438,7 +438,7 @@ macro_rules! generate_extern_modules { #[allow(unused_imports)] use crate::{Val,Object,Symbol,Error,MapObject,VecObject,BytesObject}; #[allow(unused_imports)] - use crate::{I128Object, I256Object, I64Object, I64Val, U128Object, U256Object, U32Val, U64Object, U64Val, StorageType, TimepointObject, DurationObject}; + use crate::{I128Object, I256Object, I256Val, I64Object, I64Val, U128Object, U256Object, U256Val, U32Val, U64Object, U64Val, StorageType, TimepointObject, DurationObject}; #[allow(unused_imports)] use crate::{Void,AddressObject,SymbolObject,StringObject,Bool}; #[link(wasm_import_module = $mod_str)] diff --git a/soroban-env-host/src/cost_runner/cost_types/num_ops.rs b/soroban-env-host/src/cost_runner/cost_types/num_ops.rs index 4be43eeb7..18583c851 100644 --- a/soroban-env-host/src/cost_runner/cost_types/num_ops.rs +++ b/soroban-env-host/src/cost_runner/cost_types/num_ops.rs @@ -1,6 +1,6 @@ use std::hint::black_box; -use crate::{cost_runner::CostRunner, xdr::ContractCostType, Env, I256Object, U32Val}; +use crate::{cost_runner::CostRunner, xdr::ContractCostType, Env, I256Val, U32Val}; macro_rules! impl_int256_cost_runner { ($runner:ident, $method:ident, $cost:ident, $sample_type: ty) => { @@ -11,7 +11,7 @@ macro_rules! impl_int256_cost_runner { type SampleType = $sample_type; - type RecycledType = Option; + type RecycledType = Option; fn run_iter( host: &crate::Host, @@ -33,13 +33,8 @@ macro_rules! impl_int256_cost_runner { } }; } -impl_int256_cost_runner!( - Int256AddSubRun, - i256_add, - Int256AddSub, - (I256Object, I256Object) -); -impl_int256_cost_runner!(Int256MulRun, i256_mul, Int256Mul, (I256Object, I256Object)); -impl_int256_cost_runner!(Int256DivRun, i256_div, Int256Div, (I256Object, I256Object)); -impl_int256_cost_runner!(Int256PowRun, i256_pow, Int256Pow, (I256Object, U32Val)); -impl_int256_cost_runner!(Int256ShiftRun, i256_shl, Int256Shift, (I256Object, U32Val)); +impl_int256_cost_runner!(Int256AddSubRun, i256_add, Int256AddSub, (I256Val, I256Val)); +impl_int256_cost_runner!(Int256MulRun, i256_mul, Int256Mul, (I256Val, I256Val)); +impl_int256_cost_runner!(Int256DivRun, i256_div, Int256Div, (I256Val, I256Val)); +impl_int256_cost_runner!(Int256PowRun, i256_pow, Int256Pow, (I256Val, U32Val)); +impl_int256_cost_runner!(Int256ShiftRun, i256_shl, Int256Shift, (I256Val, U32Val)); diff --git a/soroban-env-host/src/host.rs b/soroban-env-host/src/host.rs index 539769a49..67ff05ef2 100644 --- a/soroban-env-host/src/host.rs +++ b/soroban-env-host/src/host.rs @@ -1362,21 +1362,21 @@ impl VmCallerEnv for Host { }) } - impl_bignum_host_fns!(u256_add, checked_add, U256, Int256AddSub); - impl_bignum_host_fns!(u256_sub, checked_sub, U256, Int256AddSub); - impl_bignum_host_fns!(u256_mul, checked_mul, U256, Int256Mul); - impl_bignum_host_fns!(u256_div, checked_div, U256, Int256Div); - impl_bignum_host_fns_rhs_u32!(u256_pow, checked_pow, U256, Int256Pow); - impl_bignum_host_fns_rhs_u32!(u256_shl, checked_shl, U256, Int256Shift); - impl_bignum_host_fns_rhs_u32!(u256_shr, checked_shr, U256, Int256Shift); - - impl_bignum_host_fns!(i256_add, checked_add, I256, Int256AddSub); - impl_bignum_host_fns!(i256_sub, checked_sub, I256, Int256AddSub); - impl_bignum_host_fns!(i256_mul, checked_mul, I256, Int256Mul); - impl_bignum_host_fns!(i256_div, checked_div, I256, Int256Div); - impl_bignum_host_fns_rhs_u32!(i256_pow, checked_pow, I256, Int256Pow); - impl_bignum_host_fns_rhs_u32!(i256_shl, checked_shl, I256, Int256Shift); - impl_bignum_host_fns_rhs_u32!(i256_shr, checked_shr, I256, Int256Shift); + impl_bignum_host_fns!(u256_add, checked_add, U256, U256Val, Int256AddSub); + impl_bignum_host_fns!(u256_sub, checked_sub, U256, U256Val, Int256AddSub); + impl_bignum_host_fns!(u256_mul, checked_mul, U256, U256Val, Int256Mul); + impl_bignum_host_fns!(u256_div, checked_div, U256, U256Val, Int256Div); + impl_bignum_host_fns_rhs_u32!(u256_pow, checked_pow, U256, U256Val, Int256Pow); + impl_bignum_host_fns_rhs_u32!(u256_shl, checked_shl, U256, U256Val, Int256Shift); + impl_bignum_host_fns_rhs_u32!(u256_shr, checked_shr, U256, U256Val, Int256Shift); + + impl_bignum_host_fns!(i256_add, checked_add, I256, I256Val, Int256AddSub); + impl_bignum_host_fns!(i256_sub, checked_sub, I256, I256Val, Int256AddSub); + impl_bignum_host_fns!(i256_mul, checked_mul, I256, I256Val, Int256Mul); + impl_bignum_host_fns!(i256_div, checked_div, I256, I256Val, Int256Div); + impl_bignum_host_fns_rhs_u32!(i256_pow, checked_pow, I256, I256Val, Int256Pow); + impl_bignum_host_fns_rhs_u32!(i256_shl, checked_shl, I256, I256Val, Int256Shift); + impl_bignum_host_fns_rhs_u32!(i256_shr, checked_shr, I256, I256Val, Int256Shift); fn map_new(&self, _vmcaller: &mut VmCaller) -> Result { self.add_host_object(HostMap::new()) diff --git a/soroban-env-host/src/host/num.rs b/soroban-env-host/src/host/num.rs index 808f7dcfb..d483805d9 100644 --- a/soroban-env-host/src/host/num.rs +++ b/soroban-env-host/src/host/num.rs @@ -26,52 +26,51 @@ macro_rules! impl_wrapping_obj_to_num { #[macro_export] macro_rules! impl_bignum_host_fns { - ($host_fn: ident, $method: ident, $num: ty, $cost: ident) => { + ($host_fn: ident, $method: ident, $num: ty, $valty: ty, $cost: ident) => { fn $host_fn( &self, vmcaller: &mut VmCaller, - lhs_obj: <$num as HostObjectType>::Wrapper, - rhs_obj: <$num as HostObjectType>::Wrapper, - ) -> Result<<$num as HostObjectType>::Wrapper, Self::Error> { + lhs_val: $valty, + rhs_val: $valty, + ) -> Result<$valty, Self::Error> { + use soroban_env_common::TryIntoVal; self.charge_budget(ContractCostType::$cost, None)?; - let res = self.visit_obj(lhs_obj, move |lhs: &$num| { - self.visit_obj(rhs_obj, move |rhs: &$num| { - lhs.$method(*rhs).ok_or_else(|| { - self.err( - ScErrorType::Object, - ScErrorCode::ArithDomain, - "overflow has occured", - &[lhs_obj.to_val(), rhs_obj.to_val()], - ) - }) - }) + let lhs: $num = lhs_val.to_val().try_into_val(self)?; + let rhs: $num = rhs_val.to_val().try_into_val(self)?; + let res: $num = lhs.$method(rhs).ok_or_else(|| { + self.err( + ScErrorType::Object, + ScErrorCode::ArithDomain, + "overflow has occured", + &[lhs_val.to_val(), rhs_val.to_val()], + ) })?; - self.add_host_object(res) + Ok(res.try_into_val(self)?) } }; } #[macro_export] macro_rules! impl_bignum_host_fns_rhs_u32 { - ($host_fn: ident, $method: ident, $num: ty, $cost: ident) => { + ($host_fn: ident, $method: ident, $num: ty, $valty: ty, $cost: ident) => { fn $host_fn( &self, vmcaller: &mut VmCaller, - lhs_obj: <$num as HostObjectType>::Wrapper, + lhs_val: $valty, rhs_val: U32Val, - ) -> Result<<$num as HostObjectType>::Wrapper, Self::Error> { + ) -> Result<$valty, Self::Error> { + use soroban_env_common::TryIntoVal; self.charge_budget(ContractCostType::$cost, None)?; - let res = self.visit_obj(lhs_obj, move |lhs: &$num| { - lhs.$method(rhs_val.into()).ok_or_else(|| { - self.err( - ScErrorType::Object, - ScErrorCode::ArithDomain, - "overflow has occured", - &[lhs_obj.to_val(), rhs_val.to_val()], - ) - }) + let lhs: $num = lhs_val.to_val().try_into_val(self)?; + let res = lhs.$method(rhs_val.into()).ok_or_else(|| { + self.err( + ScErrorType::Object, + ScErrorCode::ArithDomain, + "overflow has occured", + &[lhs_val.to_val(), rhs_val.to_val()], + ) })?; - self.add_host_object(res) + Ok(res.try_into_val(self)?) } }; } diff --git a/soroban-env-host/src/test/num.rs b/soroban-env-host/src/test/num.rs index d3cf686fd..49804c35b 100644 --- a/soroban-env-host/src/test/num.rs +++ b/soroban-env-host/src/test/num.rs @@ -1,10 +1,10 @@ use soroban_env_common::{ num::*, xdr::{ScErrorCode, ScErrorType, ScVal}, - Compare, Env, EnvBase, Object, TryFromVal, TryIntoVal, I256, + Compare, Env, EnvBase, TryFromVal, TryIntoVal, I256, }; -use crate::{budget::AsBudget, host_object::HostObjectType, Host, HostError, Val}; +use crate::{budget::AsBudget, Host, HostError, Val}; use core::fmt::Debug; use std::cmp::Ordering; @@ -200,25 +200,30 @@ fn test_num_rawval_scval_roundtrip_ordering() { check_roundtrip_compare_ok::(&host, input_vec); } -fn check_num_arith_ok(host: &Host, lhs: T, rhs: T, f: F, expected: T) -> Result<(), HostError> +fn check_num_arith_ok( + host: &Host, + lhs: T, + rhs: T, + f: F, + expected: T, +) -> Result<(), HostError> where - T: HostObjectType, - F: FnOnce( - &Host, - ::Wrapper, - ::Wrapper, - ) -> Result<::Wrapper, HostError>, + V: TryFromVal + Into, + HostError: From<>::Error>, + F: FnOnce(&Host, V, V) -> Result, { - let res: Object = host.add_host_object(expected)?.into(); - let res_back: Object = f(host, host.add_host_object(lhs)?, host.add_host_object(rhs)?)?.into(); + let res: V = V::try_from_val(host, &expected)?; + let lhs: V = V::try_from_val(host, &lhs)?; + let rhs: V = V::try_from_val(host, &rhs)?; + let res_back: V = f(host, lhs, rhs)?; assert_eq!( - host.compare(res.as_val(), res_back.as_val()).unwrap(), + host.compare(&res.into(), &res_back.into()).unwrap(), Ordering::Equal ); Ok(()) } -fn check_num_arith_rhs_u32_ok( +fn check_num_arith_rhs_u32_ok( host: &Host, lhs: T, rhs: u32, @@ -226,52 +231,47 @@ fn check_num_arith_rhs_u32_ok( expected: T, ) -> Result<(), HostError> where - T: HostObjectType, - F: FnOnce( - &Host, - ::Wrapper, - U32Val, - ) -> Result<::Wrapper, HostError>, + V: TryFromVal + Into, + HostError: From<>::Error>, + F: FnOnce(&Host, V, U32Val) -> Result, { - let res: Object = host.add_host_object(expected)?.into(); - let res_back: Object = f(host, host.add_host_object(lhs)?, U32Val::from(rhs))?.into(); + let res: V = V::try_from_val(host, &expected)?; + let lhs: V = V::try_from_val(host, &lhs)?; + let res_back: V = f(host, lhs, U32Val::from(rhs))?; assert_eq!( - host.compare(res.as_val(), res_back.as_val()).unwrap(), + host.compare(&res.into(), &res_back.into()).unwrap(), Ordering::Equal ); Ok(()) } -fn check_num_arith_expect_err(host: &Host, lhs: T, rhs: T, f: F) -> Result<(), HostError> +fn check_num_arith_expect_err(host: &Host, lhs: T, rhs: T, f: F) -> Result<(), HostError> where - T: HostObjectType, - F: FnOnce( - &Host, - ::Wrapper, - ::Wrapper, - ) -> Result<::Wrapper, HostError>, + V: TryFromVal + Into, + HostError: From<>::Error>, + F: FnOnce(&Host, V, V) -> Result, { - let res_back = f(host, host.add_host_object(lhs)?, host.add_host_object(rhs)?); + let lhs: V = V::try_from_val(host, &lhs)?; + let rhs: V = V::try_from_val(host, &rhs)?; + let res_back: Result = f(host, lhs, rhs); let code = (ScErrorType::Object, ScErrorCode::ArithDomain); assert!(HostError::result_matches_err(res_back, code)); Ok(()) } -fn check_num_arith_rhs_u32_expect_err( +fn check_num_arith_rhs_u32_expect_err( host: &Host, lhs: T, rhs: u32, f: F, ) -> Result<(), HostError> where - T: HostObjectType, - F: FnOnce( - &Host, - ::Wrapper, - U32Val, - ) -> Result<::Wrapper, HostError>, + V: TryFromVal + Into, + HostError: From<>::Error>, + F: FnOnce(&Host, V, U32Val) -> Result, { - let res_back = f(host, host.add_host_object(lhs)?, U32Val::from(rhs)); + let lhs: V = V::try_from_val(host, &lhs)?; + let res_back: Result = f(host, lhs, U32Val::from(rhs)); let code = (ScErrorType::Object, ScErrorCode::ArithDomain); assert!(HostError::result_matches_err(res_back, code)); Ok(()) diff --git a/soroban-env-host/src/vm/dispatch.rs b/soroban-env-host/src/vm/dispatch.rs index 9d5b68214..505e97d67 100644 --- a/soroban-env-host/src/vm/dispatch.rs +++ b/soroban-env-host/src/vm/dispatch.rs @@ -1,9 +1,9 @@ use super::FuelRefillable; use crate::{xdr::ContractCostType, Host, HostError, VmCaller, VmCallerEnv}; use crate::{ - AddressObject, BytesObject, DurationObject, Error, I128Object, I256Object, I64Object, + AddressObject, BytesObject, DurationObject, Error, I128Object, I256Object, I256Val, I64Object, MapObject, StorageType, StringObject, Symbol, SymbolObject, TimepointObject, U128Object, - U256Object, U32Val, U64Object, Val, VecObject, + U256Object, U256Val, U32Val, U64Object, Val, VecObject, }; use soroban_env_common::{call_macro_with_all_host_functions, WasmiMarshal}; use wasmi::{ From d34eaf12d817f74d332e95e5d905674bcfa6d86d Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Fri, 23 Jun 2023 19:32:27 -0700 Subject: [PATCH 2/3] Add a bunch of convenience (const) constructors for small number variants. --- soroban-env-common/src/num.rs | 81 +++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) diff --git a/soroban-env-common/src/num.rs b/soroban-env-common/src/num.rs index a09585b57..230590efb 100644 --- a/soroban-env-common/src/num.rs +++ b/soroban-env-common/src/num.rs @@ -308,6 +308,87 @@ impl TryFrom<&I256Small> for ScVal { } } +// Some explicit convenience "small" constructors that take 32-bit inputs in +// order to remain infallible and are also `const fn`. + +impl I64Small { + pub const fn from_i32(small: i32) -> Self { + let extended = small as i64; + unsafe { I64Small::from_body(extended as u64) } + } +} + +impl I64Val { + pub const fn from_i32(small: i32) -> Self { + Self::from_small(I64Small::from_i32(small)) + } +} + +impl U64Small { + pub const fn from_u32(small: u32) -> Self { + let extended = small as u64; + unsafe { U64Small::from_body(extended) } + } +} + +impl U64Val { + pub const fn from_u32(small: u32) -> Self { + Self::from_small(U64Small::from_u32(small)) + } +} + +impl I128Small { + pub const fn from_i32(small: i32) -> Self { + let extended = small as i64; + unsafe { I128Small::from_body(extended as u64) } + } +} + +impl I128Val { + pub const fn from_i32(small: i32) -> Self { + Self::from_small(I128Small::from_i32(small)) + } +} + +impl U128Small { + pub const fn from_u32(small: u32) -> Self { + let extended = small as u64; + unsafe { U128Small::from_body(extended) } + } +} + +impl U128Val { + pub const fn from_u32(small: u32) -> Self { + Self::from_small(U128Small::from_u32(small)) + } +} + +impl I256Small { + pub const fn from_i32(small: i32) -> Self { + let extended = small as i64; + unsafe { I256Small::from_body(extended as u64) } + } +} + +impl I256Val { + pub const fn from_i32(small: i32) -> Self { + Self::from_small(I256Small::from_i32(small)) + } +} + +impl U256Small { + pub const fn from_u32(small: u32) -> Self { + let extended = small as u64; + unsafe { U256Small::from_body(extended) } + } +} + +impl U256Val { + pub const fn from_u32(small: u32) -> Self { + Self::from_small(U256Small::from_u32(small)) + } +} + pub const fn is_small_u64(u: u64) -> bool { u == ((u << TAG_BITS) >> TAG_BITS) } From 5af91b24c7d7d6284c7ff237bb88fc95a858ce75 Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Fri, 23 Jun 2023 23:33:48 -0700 Subject: [PATCH 3/3] regenerate wasms --- soroban-test-wasms/wasm-workspace/Cargo.lock | 38 ++++++++++-------- .../wasm-workspace/add_f32/src/lib.rs | 4 +- .../wasm-workspace/add_i32/src/lib.rs | 4 +- .../wasm-workspace/auth/src/lib.rs | 10 ++--- .../wasm-workspace/complex/src/lib.rs | 4 +- .../wasm-workspace/invoke_contract/src/lib.rs | 8 ++-- .../opt/auth_test_contract.wasm | Bin 5415 -> 5406 bytes .../wasm-workspace/opt/example_add_f32.wasm | Bin 1267 -> 1102 bytes .../wasm-workspace/opt/example_add_i32.wasm | Bin 1214 -> 1049 bytes .../wasm-workspace/opt/example_complex.wasm | Bin 1926 -> 1825 bytes .../opt/example_contract_data.wasm | Bin 3046 -> 4155 bytes .../opt/example_create_contract.wasm | Bin 587 -> 712 bytes .../wasm-workspace/opt/example_fannkuch.wasm | Bin 919 -> 1044 bytes .../wasm-workspace/opt/example_fib.wasm | Bin 235 -> 360 bytes .../wasm-workspace/opt/example_hostile.wasm | Bin 1031 -> 1156 bytes .../opt/example_invoke_contract.wasm | Bin 2185 -> 2000 bytes .../opt/example_linear_memory.wasm | Bin 729 -> 854 bytes .../opt/example_simple_account.wasm | Bin 1945 -> 2070 bytes .../opt/example_updateable_contract.wasm | Bin 481 -> 606 bytes .../wasm-workspace/opt/example_vec.wasm | Bin 454 -> 579 bytes 20 files changed, 37 insertions(+), 31 deletions(-) diff --git a/soroban-test-wasms/wasm-workspace/Cargo.lock b/soroban-test-wasms/wasm-workspace/Cargo.lock index 842cbfc93..f3d2de8d6 100644 --- a/soroban-test-wasms/wasm-workspace/Cargo.lock +++ b/soroban-test-wasms/wasm-workspace/Cargo.lock @@ -887,6 +887,15 @@ version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" +[[package]] +name = "rustc_version" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +dependencies = [ + "semver", +] + [[package]] name = "ryu" version = "1.0.13" @@ -907,6 +916,12 @@ dependencies = [ "zeroize", ] +[[package]] +name = "semver" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bebd363326d05ec3e2f532ab7660680f3b02130d780c299bca73469d521bc0ed" + [[package]] name = "serde" version = "1.0.164" @@ -1036,7 +1051,7 @@ dependencies = [ "soroban-env-macros", "soroban-wasmi", "static_assertions", - "stellar-xdr 0.0.16 (git+https://github.com/stellar/rs-stellar-xdr?rev=6750a11325a7c4eed1e79372d136106e5bfecaff)", + "stellar-xdr", ] [[package]] @@ -1081,7 +1096,7 @@ dependencies = [ "quote", "serde", "serde_json", - "stellar-xdr 0.0.16 (git+https://github.com/stellar/rs-stellar-xdr?rev=6750a11325a7c4eed1e79372d136106e5bfecaff)", + "stellar-xdr", "syn 2.0.18", "thiserror", ] @@ -1127,15 +1142,17 @@ dependencies = [ name = "soroban-sdk-macros" version = "0.8.4" dependencies = [ + "crate-git-revision", "darling", "itertools", "proc-macro2", "quote", + "rustc_version", "sha2 0.9.9", "soroban-env-common", "soroban-spec", "soroban-spec-rust", - "stellar-xdr 0.0.16 (git+https://github.com/stellar/rs-stellar-xdr?rev=518171b12025283cac1233c7de8e4c20088d95b5)", + "stellar-xdr", "syn 2.0.18", ] @@ -1144,7 +1161,7 @@ name = "soroban-spec" version = "0.8.4" dependencies = [ "base64 0.13.1", - "stellar-xdr 0.0.16 (git+https://github.com/stellar/rs-stellar-xdr?rev=518171b12025283cac1233c7de8e4c20088d95b5)", + "stellar-xdr", "thiserror", "wasmparser", ] @@ -1158,7 +1175,7 @@ dependencies = [ "quote", "sha2 0.9.9", "soroban-spec", - "stellar-xdr 0.0.16 (git+https://github.com/stellar/rs-stellar-xdr?rev=518171b12025283cac1233c7de8e4c20088d95b5)", + "stellar-xdr", "syn 2.0.18", "thiserror", ] @@ -1218,17 +1235,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "stellar-xdr" -version = "0.0.16" -source = "git+https://github.com/stellar/rs-stellar-xdr?rev=518171b12025283cac1233c7de8e4c20088d95b5#518171b12025283cac1233c7de8e4c20088d95b5" -dependencies = [ - "crate-git-revision", - "hex", - "serde", - "serde_with", -] - [[package]] name = "stellar-xdr" version = "0.0.16" diff --git a/soroban-test-wasms/wasm-workspace/add_f32/src/lib.rs b/soroban-test-wasms/wasm-workspace/add_f32/src/lib.rs index b37f673d7..d9bf693d3 100644 --- a/soroban-test-wasms/wasm-workspace/add_f32/src/lib.rs +++ b/soroban-test-wasms/wasm-workspace/add_f32/src/lib.rs @@ -1,5 +1,5 @@ #![no_std] -use soroban_sdk::{contract, contractimpl, Env, Symbol}; +use soroban_sdk::{contract, contractimpl, Env, symbol_short}; #[contract] pub struct Contract; @@ -7,7 +7,7 @@ pub struct Contract; #[contractimpl] impl Contract { pub fn add(env: Env, a: i32, b: i32) -> i32 { - env.events().publish((Symbol::short("add"),), (a, b)); + env.events().publish((symbol_short!("add"),), (a, b)); let a = a as f32; let b = b as f32; (a + b) as i32 diff --git a/soroban-test-wasms/wasm-workspace/add_i32/src/lib.rs b/soroban-test-wasms/wasm-workspace/add_i32/src/lib.rs index c54255ea3..7464789a7 100644 --- a/soroban-test-wasms/wasm-workspace/add_i32/src/lib.rs +++ b/soroban-test-wasms/wasm-workspace/add_i32/src/lib.rs @@ -1,5 +1,5 @@ #![no_std] -use soroban_sdk::{contract, contractimpl, Env, Symbol}; +use soroban_sdk::{contract, contractimpl, Env, symbol_short}; #[contract] pub struct Contract; @@ -7,7 +7,7 @@ pub struct Contract; #[contractimpl] impl Contract { pub fn add(env: Env, a: i32, b: i32) -> i32 { - env.events().publish((Symbol::short("add"),), (a, b)); + env.events().publish((symbol_short!("add"),), (a, b)); a + b } } diff --git a/soroban-test-wasms/wasm-workspace/auth/src/lib.rs b/soroban-test-wasms/wasm-workspace/auth/src/lib.rs index 5a6d0185f..5cb36e764 100644 --- a/soroban-test-wasms/wasm-workspace/auth/src/lib.rs +++ b/soroban-test-wasms/wasm-workspace/auth/src/lib.rs @@ -1,7 +1,7 @@ #![no_std] use soroban_sdk::{ auth::{ContractContext, InvokerContractAuthEntry, SubContractInvocation}, - contract, contractimpl, contracttype, vec, Address, Env, IntoVal, Symbol, Vec, + contract, contractimpl, contracttype, vec, Address, Env, IntoVal, symbol_short, Vec, }; #[contract] @@ -31,7 +31,7 @@ impl AuthContract { for child in tree.children.iter() { env.invoke_contract::<()>( &child.contract.clone(), - &Symbol::short("tree_fn"), + &symbol_short!("tree_fn"), (addresses.clone(), child).into_val(&env), ); } @@ -40,7 +40,7 @@ impl AuthContract { pub fn order_fn(env: Env, addr: Address, child_id: Address) { env.invoke_contract::<()>( &child_id, - &Symbol::short("do_auth"), + &symbol_short!("do_auth"), (&addr, 10_u32).into_val(&env), ); addr.require_auth(); @@ -61,7 +61,7 @@ impl AuthContract { let curr_address = env.current_contract_address(); env.invoke_contract::<()>( &tree.contract, - &Symbol::short("tree_fn"), + &symbol_short!("tree_fn"), (vec![&env, curr_address], tree.clone()).into_val(&env), ); } @@ -77,7 +77,7 @@ fn tree_to_invoker_contract_auth(env: &Env, tree: &TreeNode) -> InvokerContractA InvokerContractAuthEntry::Contract(SubContractInvocation { context: ContractContext { contract: tree.contract.clone(), - fn_name: Symbol::short("tree_fn"), + fn_name: symbol_short!("tree_fn"), args: vec![&env], }, sub_invocations, diff --git a/soroban-test-wasms/wasm-workspace/complex/src/lib.rs b/soroban-test-wasms/wasm-workspace/complex/src/lib.rs index e34c71a7c..83111853d 100644 --- a/soroban-test-wasms/wasm-workspace/complex/src/lib.rs +++ b/soroban-test-wasms/wasm-workspace/complex/src/lib.rs @@ -1,5 +1,5 @@ #![no_std] -use soroban_sdk::{contract, contractimpl, contracttype, Bytes, BytesN, Env, Symbol, Vec}; +use soroban_sdk::{contract, contractimpl, contracttype, Bytes, BytesN, Env, symbol_short, Vec}; // This is a "complex" contract that uses a nontrivial amount of the host // interface from the guest: UDTs (thus maps), vectors, byte arrays and linear @@ -32,7 +32,7 @@ impl Contract { seq: ledger.sequence(), time: ledger.timestamp(), }; - let data = Symbol::short("data"); + let data = symbol_short!("data"); let hash = e.crypto().sha256(&my_ledger.network_id.clone().into()); let mut buf: [u8; 32] = [0; 32]; hash.copy_into_slice(&mut buf); diff --git a/soroban-test-wasms/wasm-workspace/invoke_contract/src/lib.rs b/soroban-test-wasms/wasm-workspace/invoke_contract/src/lib.rs index 93338c30b..3a8e6a5c0 100644 --- a/soroban-test-wasms/wasm-workspace/invoke_contract/src/lib.rs +++ b/soroban-test-wasms/wasm-workspace/invoke_contract/src/lib.rs @@ -1,5 +1,5 @@ #![no_std] -use soroban_sdk::{contract, contractimpl, vec, Address, Env, IntoVal, Symbol}; +use soroban_sdk::{contract, contractimpl, vec, Address, Env, IntoVal, symbol_short}; #[contract] pub struct Contract; @@ -7,16 +7,16 @@ pub struct Contract; #[contractimpl] impl Contract { pub fn add(env: Env, a: i32, b: i32) -> i32 { - env.events().publish((Symbol::short("add"),), (a, b)); + env.events().publish((symbol_short!("add"),), (a, b)); a + b } pub fn add_with(env: Env, x: i32, y: i32, contract_id: Address) -> i32 { env.events() - .publish((Symbol::short("add_with"),), (x, y, contract_id.clone())); + .publish((symbol_short!("add_with"),), (x, y, contract_id.clone())); env.invoke_contract( &contract_id, - &Symbol::short("add"), + &symbol_short!("add"), vec![&env, x.into_val(&env), y.into_val(&env)], ) } diff --git a/soroban-test-wasms/wasm-workspace/opt/auth_test_contract.wasm b/soroban-test-wasms/wasm-workspace/opt/auth_test_contract.wasm index 56741df370a0ee4e7ca23ce2118d9f388bc953c1..3461a8551d8de42c8903a3f1b6491d890a6abde9 100644 GIT binary patch delta 2007 zcmZ8iU2GIp6uv(*v$Ng5+g6~hRA#rJT}bQnZ+D11>|Fsd{y>ZgCYsPK6w0iv(rySu z>7X>k2Qf4^Q4$03!33j$7knTw1~fkO!H4=_^i6zG{COZ6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sQs3*1?b-au7v#~&B= zdGDC4C;4)GyHLt4qGM)vdVO$TWC?*@ZDpVG#Cxc)iJR%Q$)b;BiA4rki4w4{0Rd1O z?Ji2Z0yWziYi7ZMp(Z(I3j%P-;8@5MJp=xjIkMF)8gG^>r{UE@(K_agX?U|aw&W;pPNheBY5!d8lVj_Ff zDs!{wv-tg?SE9eoBfE76?B;b|N2hu6bTZ9MGnvXXyz`Ag!`!^^!JXW}0x7{G{Q3h(+7iL3S&o-CGDtg!p(*cJF!rzHxfNzs zQh26T3?Q2McCOM=T#aYkwJ0LF%=vRECoy>y?o{C$E^)#5U=6&X=I_FE6*@dm33@); zp;!vL@4=#>E^PY#KSazvKK^gYaTt>>NZdI7~6n; z0Qyf;`@_xdDg5o(yT)m2xi{QBdvxwZ=gp;sX79vOr_0!Psk2-0uiM7yscRoTvQGa3 D)cS48 diff --git a/soroban-test-wasms/wasm-workspace/opt/example_add_f32.wasm b/soroban-test-wasms/wasm-workspace/opt/example_add_f32.wasm index c7ee86018a23b37fd89119b57a6397ab0983a37b..fb74a6b1bf84c6a6af474458f05edd57dba9997e 100644 GIT binary patch delta 532 zcmX9)-D=cO5I#9`&XV1;mWp01n+qpt!40%a_Qxa@l$;j9q9{IqVs@KqleR)OEEX?T zypW0@uDS3Ls(9BY@ChvVDn7tE*`15Sd^6vC=bQOg|6_iAXq?aY@AE4;|76MUlGkVR zU$HzHv zx|PyGAK>mYK_INU0hn}$r6lMmtFGdLxo)(veu<6CZ;skyj9tC7fzMEVuE5jhWJUdG z8cM&Xc&o^VD6a{tsrD9&#gi8nDpciA+*1vM5$88k1}{H~TeCiUw>ExrTIBJ#I7y0l z>XBX*GM`M7e3h^Dx!dR-i!t%~%T`DAjCt!P898+L~qK`$PRlGqOiqj0A; j+DZE3AohlRFZAPH=m*~6zzf49**-YRi!)YUh{yi{U(aR` delta 774 zcmY*X&1w`u5U#H3nVro{B*Gq+U6Go}f>}^m51ADO*`APK6wM1nF(kRnU<6r$mt=DY zA(D%6A3{BdkSB;QppPJ)d;lLnzn=AC!_ZY-Ki^m1)VJt&^W8&pcE0|Ae>KkEb{k(B z(wvyX^G`P>VUINA!$oonRVF=}8Qdct@kmB$ovhiBildxKMdKnmDXtt3B}yblw7E8K zlzD>hurPQyJ-Vdw7EuCK6^*_oUzuBg-iFwP`4 z*5Gq-{~+PoSUyNhZQMSH0qrREYq<%vI0Z%nlD)jV2*35Ycj;WowoNsD~#596xga74I z)^OS~%f?P0nbnD{2drT;KO#Vr*|12o8dOg9GbFWVu1fvD-h155x#enpy^K9g&4Mb! zylU6GDMM8m!$km80)MyFLJ<5t_M)rpcZB@Z>`YY`L_X0%gVau!I88$h`_dlD0P_sW zzW6m5m3|*Uxm{wElJ8AIICp&%zd*yHZYge5`4xg_3#OyZ3!S@opCv0q^!-IDSd8S% zI~&hHCHV+N-4V{47(BvRZNriKgVO-NI;PUqWCbrzpTp2(6AE0@#&l8g<(45NT~Zt~ my85%VvqRUfZok?azuwv&@9yot+#PT24`xAX;l499_Q_v|P=Qte diff --git a/soroban-test-wasms/wasm-workspace/opt/example_add_i32.wasm b/soroban-test-wasms/wasm-workspace/opt/example_add_i32.wasm index a6e1dceed32fb6c1f611063c320cc7f6c159b129..4448cf3df6931d48af0878b4f16699233e4354d2 100644 GIT binary patch literal 1049 zcmY*Y-A)rh6h3oirhkjLL^L48oGx6HMCwv-ce(2{F{s@60%hB-!qyhjHjTujC6O4e zjMu&Z@xpiT8GHm^M9=I3#%uK`KHw>5RiC|(4x;ReHqFUK?_0&&Tl2k^9?Z6_lld0YW)$P zTKWx%8)x)FHK~Xe(o8+Y5Y_tf>-&RH5-En$)wNd&u*QMNf^vXQNf|e-R=CISdvX)l zar+)}GjfU2Ey>&^!b}1ohu5kJj`d1a25~oIC0T_e?JRAeirGRKTm{)=Q0aiBNmEJ* z(;UjVw2BMDak4HC4Fu>isSJ?mNC&8F#4xWApk-P}DfdWIp>O2WW6+AlQh{WaKpP#d z1-NWjO$|3a9#KQ`3Vl!8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B7);(81Zdw*)?s2+s4=e z5qw4GKj5wix$Fj>xDWPJ`b%{yr%ze7>8N@BGsYXlKK88NxqkTKWPVy5&Zj5m$J2Rr qK5UY-3Hu8@y|&Juy__C?OByD=D`3~D3sVu+ZKoYc_RP>^FPRS1%y z>WHXrMuMpmES-=LX?Qq? zr80Dhul5SVwgDuCSq|`b18fsA;6xp8g&Q7u0YJGD{6q<3tXyz732XC;4 zN|U(If9A*4S_21j$lfH#rl5%fdJAMxKogD=*@t8;v9Uj*XsQq&O`Xdne1jv3OUP(Sntg`ye$T`e^H^gq8-Qr>VCxF>w$R_qheUr zb@4~v7Tcxjtb<;yji2x3Sv1a{#d);vqUF-E>3*Co_iOEz*J-(%dy^--`O||H10kAC zr#tDA)^l5at5@^dQFjzaeZM>Mx7wqvxHI-5x7Ts~e$@8+p8L4#`hFa5?o6`$0EtJX F#y^X)l2-r# delta 861 zcmXX^O=}cE5UuX&`PlR(nS+EFHK`dF+y$fYkjz1l?IFf5B*8-v1U2A6XD=eTCX++h zv!QR^JbB8=t4IWYfZz{M|AF8^!Gpe@?7&df)m^V%y{fk}F|jxKA{43!A11{*P0CDD2dlHZW-|24$S;8Y||wy1v)dt+Tqw3FMs>1_(CPPOPUuP=sh^};I3kdq$shl7gfs&R^$uD6N(e5YJS(bI% zH-XA156Cv$mi!P#4|oOn@Y0f>VgxJgOwfRK-$QcA{sP-Ry91~@V9W`1pw}&w3Y`eo z0SgV|kh9<77kAC5V1X)k&gBfXdACrZ$E?nwM_?kj4QwCjE`z7Z2W+u7amkK!eD&Hsr9{{dxEkhcH; diff --git a/soroban-test-wasms/wasm-workspace/opt/example_contract_data.wasm b/soroban-test-wasms/wasm-workspace/opt/example_contract_data.wasm index dd7ac6c7f03502a8712ec131345802b3d5dd6466..7ac865f47b190cea0393e435ad7a8b9b1d53e9bd 100644 GIT binary patch literal 4155 zcmdT{&2Aev5S}4-W!Wpqbe*=2ogYdukQitT$u=yd=s{W_33^Nq?NMIaYg@7;tCC{C z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ThP$pym=8 z|5vwZXm}#&g&_upLCS5Ya+}+q2*5qv3J=wg2MA4kP}? z$QC18j07eomTtc`_Vb-HB3(g?qRcgJs+pE*feF_?WQ~e29F}e@3)XWr+Frn!x#A2H zWW%s1oe4`OZq>s)L{at;UwUal`ElepL=eIpQw^v73-Ps@}d>? zL4Dukl`e!0;+ZV83w={yL#KkY$_q@yMiG(IBou)so1r%mTcL`*mQ3#RR$Efv#ALnOwMjgYsnv?F#b zENsNbhJ_HzCRP#~3xB~>+l9M0C-BIMnZrR7~F(9kV z#BVuBZghqdhcw?mA5l_F_zN>=PF_-PBz;)DIXQhgdjW$MIGN+}jiRW@FM6E{4ERD{ z!3R+Y6Q>E{!{BdfO`7?Wcs*A0!t$r(IWSk8ATam+g7QJR^;F=%F^s`r6rtX~gF$^l z`2vHXNOq&-I#$-TOOI_Wz}8VZo~mp zr#xHE73+6NEhb{gQ6p|8GPacxiHw+zXQpjEYgk%R*F?&Si>U GcJ>SFf@M?y delta 622 zcmXX@J#Q015S@>`f-i!`b5aZ)6?KB-0?rLZ1T^-gh$16| z1lo=&6;ucz(Sk?^6*P1ah@U`7$E@wu?c4cy`(|eE$I7$Sm+SX%x=&>Z`&2y-@qycR>>ziux9zA;J#{GK9eEz;Nm^}zKjF0v2N~aSEUr+P zVZg6Yq(FBQY}#GjdO)t#ctN|3?W zzmGnbuZc{F(@P-fxJ?~c7~BCG&_Kn}MME=iB+w^t&(0S)}%&r zW0J_~HasU7T delta 13 Ucmcb{c9V5OG83cWk)?EnA( diff --git a/soroban-test-wasms/wasm-workspace/opt/example_simple_account.wasm b/soroban-test-wasms/wasm-workspace/opt/example_simple_account.wasm index 66ef0783c431d35327c68ebca5193de1ce2ea143..d52661a4337e3c2ab24e910c1f0be084f2cd0bda 100644 GIT binary patch delta 140 zcmbQqKTTjm5L>+wLp5J=eqKpYVsc4tYDr?50RsfE78RGJ7D3p2hI-~kdIq|AnduoN zIh9Zq3=AAa#l