diff --git a/soroban-env-host/src/e2e_invoke.rs b/soroban-env-host/src/e2e_invoke.rs index 1faaea183..c5ef2c83b 100644 --- a/soroban-env-host/src/e2e_invoke.rs +++ b/soroban-env-host/src/e2e_invoke.rs @@ -179,9 +179,10 @@ pub fn extract_rent_changes(ledger_changes: &Vec) -> Vec= expiration_change.new_expiration_ledger + && entry_change.old_entry_size_bytes >= encoded_new_value.len() as u32 { return None; } diff --git a/soroban-env-host/src/test/invocation.rs b/soroban-env-host/src/test/invocation.rs index 448ec2215..1dcaccb4e 100644 --- a/soroban-env-host/src/test/invocation.rs +++ b/soroban-env-host/src/test/invocation.rs @@ -2,14 +2,18 @@ use std::rc::Rc; use expect_test::expect; use soroban_env_common::{ - xdr::{self, ScErrorCode}, - Env, EnvBase, TryFromVal, Val, + xdr::{ + self, ContractDataDurability, LedgerKey, LedgerKeyContractData, ScErrorCode, ScSymbol, + ScVal, + }, + Env, EnvBase, TryFromVal, U64Small, Val, }; use crate::{ - events::HostEvent, xdr::ScErrorType, ContractFunctionSet, Error, Host, HostError, Symbol, Tag, + budget::AsBudget, events::HostEvent, xdr::ScErrorType, ContractFunctionSet, Error, Host, + HostError, Symbol, Tag, }; -use soroban_test_wasms::{ADD_I32, ALLOC, ERR, INVOKE_CONTRACT, VEC}; +use soroban_test_wasms::{ADD_I32, ALLOC, CONTRACT_STORAGE, ERR, INVOKE_CONTRACT, VEC}; #[test] fn invoke_single_contract_function() -> Result<(), HostError> { @@ -273,3 +277,35 @@ fn wasm_invoke_return_err_variants() -> Result<(), HostError> { } Ok(()) } + +#[test] +fn invoke_single_contract_function2() -> Result<(), HostError> { + let host = Host::test_host_with_recording_footprint(); + let contract_id_obj = host.register_test_contract_wasm(CONTRACT_STORAGE); + // put_persistent + let func = host.symbol_new_from_slice("put_persistent")?; + let key = Symbol::try_from_small_str("a")?; + let mut args = host.vec_new()?; + args = host.vec_push_back(args, key.into())?; + args = host.vec_push_back(args, U64Small::try_from(1u64).unwrap().into())?; + let _res = host.call(contract_id_obj, func.into(), args)?; + + // increase_entry_size + let func = host.symbol_new_from_slice("increase_entry_size")?; + let mut args = host.vec_new()?; + args = host.vec_push_back(args, key.into())?; + let _res = host.call(contract_id_obj, func.into(), args)?; + + // let v = host.get_contract_data(key.into(), soroban_env_common::StorageType::Persistent)?; + // println!("{:?}", v); + + let k = Rc::new(LedgerKey::ContractData(LedgerKeyContractData { + key: ScVal::Symbol(ScSymbol::try_from("a").unwrap()), + durability: ContractDataDurability::Persistent, + contract: xdr::ScAddress::Contract(host.contract_id_from_address(contract_id_obj)?), + })); + let v = host.with_mut_storage(|s| s.get(&k, host.as_budget()))?; + println!("{:?}", v); + + Ok(()) +} diff --git a/soroban-test-wasms/wasm-workspace/contract_data/src/lib.rs b/soroban-test-wasms/wasm-workspace/contract_data/src/lib.rs index f59decaa8..6d7b650dd 100644 --- a/soroban-test-wasms/wasm-workspace/contract_data/src/lib.rs +++ b/soroban-test-wasms/wasm-workspace/contract_data/src/lib.rs @@ -22,8 +22,15 @@ impl Contract { e.storage().persistent().get(&key).unwrap() } - pub fn bump_persistent(e: Env, key: Symbol, low_expiration_watermark: u32, high_expiration_watermark: u32) { - e.storage().persistent().bump(&key, low_expiration_watermark, high_expiration_watermark) + pub fn bump_persistent( + e: Env, + key: Symbol, + low_expiration_watermark: u32, + high_expiration_watermark: u32, + ) { + e.storage() + .persistent() + .bump(&key, low_expiration_watermark, high_expiration_watermark) } pub fn put_temporary(e: Env, key: Symbol, val: u64) { @@ -42,8 +49,15 @@ impl Contract { e.storage().temporary().get(&key).unwrap() } - pub fn bump_temporary(e: Env, key: Symbol, low_expiration_watermark: u32, high_expiration_watermark: u32) { - e.storage().temporary().bump(&key, low_expiration_watermark, high_expiration_watermark) + pub fn bump_temporary( + e: Env, + key: Symbol, + low_expiration_watermark: u32, + high_expiration_watermark: u32, + ) { + e.storage() + .temporary() + .bump(&key, low_expiration_watermark, high_expiration_watermark) } pub fn put_instance(e: Env, key: Symbol, val: u64) { @@ -63,6 +77,13 @@ impl Contract { } pub fn bump_instance(e: Env, low_expiration_watermark: u32, high_expiration_watermark: u32) { - e.storage().instance().bump(low_expiration_watermark, high_expiration_watermark) + e.storage() + .instance() + .bump(low_expiration_watermark, high_expiration_watermark) + } + + pub fn increase_entry_size(e: Env, key: Symbol) { + let u: u64 = e.storage().persistent().get(&key).unwrap(); + e.storage().persistent().set(&key, &u128::from(u)) } } 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 84ebca5f9..fa084050b 100644 Binary files a/soroban-test-wasms/wasm-workspace/opt/auth_test_contract.wasm and b/soroban-test-wasms/wasm-workspace/opt/auth_test_contract.wasm differ 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 6a8c47b14..4dd82484f 100644 Binary files a/soroban-test-wasms/wasm-workspace/opt/example_add_f32.wasm and b/soroban-test-wasms/wasm-workspace/opt/example_add_f32.wasm differ 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 0859a11eb..da7f7e1fb 100644 Binary files a/soroban-test-wasms/wasm-workspace/opt/example_add_i32.wasm and b/soroban-test-wasms/wasm-workspace/opt/example_add_i32.wasm differ diff --git a/soroban-test-wasms/wasm-workspace/opt/example_alloc.wasm b/soroban-test-wasms/wasm-workspace/opt/example_alloc.wasm index dc84a6733..3beb6bf9a 100644 Binary files a/soroban-test-wasms/wasm-workspace/opt/example_alloc.wasm and b/soroban-test-wasms/wasm-workspace/opt/example_alloc.wasm differ diff --git a/soroban-test-wasms/wasm-workspace/opt/example_complex.wasm b/soroban-test-wasms/wasm-workspace/opt/example_complex.wasm index 791ad4aac..7f2042d5b 100644 Binary files a/soroban-test-wasms/wasm-workspace/opt/example_complex.wasm and b/soroban-test-wasms/wasm-workspace/opt/example_complex.wasm differ 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 670597357..06680a486 100644 Binary files a/soroban-test-wasms/wasm-workspace/opt/example_contract_data.wasm and b/soroban-test-wasms/wasm-workspace/opt/example_contract_data.wasm differ diff --git a/soroban-test-wasms/wasm-workspace/opt/example_create_contract.wasm b/soroban-test-wasms/wasm-workspace/opt/example_create_contract.wasm index 95ae6d50f..4af2b4c32 100644 Binary files a/soroban-test-wasms/wasm-workspace/opt/example_create_contract.wasm and b/soroban-test-wasms/wasm-workspace/opt/example_create_contract.wasm differ diff --git a/soroban-test-wasms/wasm-workspace/opt/example_err.wasm b/soroban-test-wasms/wasm-workspace/opt/example_err.wasm index e625632e7..c85247e46 100644 Binary files a/soroban-test-wasms/wasm-workspace/opt/example_err.wasm and b/soroban-test-wasms/wasm-workspace/opt/example_err.wasm differ diff --git a/soroban-test-wasms/wasm-workspace/opt/example_fannkuch.wasm b/soroban-test-wasms/wasm-workspace/opt/example_fannkuch.wasm index 535ab0d1a..e0486487b 100644 Binary files a/soroban-test-wasms/wasm-workspace/opt/example_fannkuch.wasm and b/soroban-test-wasms/wasm-workspace/opt/example_fannkuch.wasm differ diff --git a/soroban-test-wasms/wasm-workspace/opt/example_fib.wasm b/soroban-test-wasms/wasm-workspace/opt/example_fib.wasm index d68e40516..57014cd46 100644 Binary files a/soroban-test-wasms/wasm-workspace/opt/example_fib.wasm and b/soroban-test-wasms/wasm-workspace/opt/example_fib.wasm differ diff --git a/soroban-test-wasms/wasm-workspace/opt/example_hostile.wasm b/soroban-test-wasms/wasm-workspace/opt/example_hostile.wasm index 8b3c2ce81..277e05af8 100644 Binary files a/soroban-test-wasms/wasm-workspace/opt/example_hostile.wasm and b/soroban-test-wasms/wasm-workspace/opt/example_hostile.wasm differ diff --git a/soroban-test-wasms/wasm-workspace/opt/example_invoke_contract.wasm b/soroban-test-wasms/wasm-workspace/opt/example_invoke_contract.wasm index 81c118016..15b3eb9ac 100644 Binary files a/soroban-test-wasms/wasm-workspace/opt/example_invoke_contract.wasm and b/soroban-test-wasms/wasm-workspace/opt/example_invoke_contract.wasm differ diff --git a/soroban-test-wasms/wasm-workspace/opt/example_linear_memory.wasm b/soroban-test-wasms/wasm-workspace/opt/example_linear_memory.wasm index 3e9759a07..5c8496191 100644 Binary files a/soroban-test-wasms/wasm-workspace/opt/example_linear_memory.wasm and b/soroban-test-wasms/wasm-workspace/opt/example_linear_memory.wasm differ 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 752f8798f..211f4ee3b 100644 Binary files a/soroban-test-wasms/wasm-workspace/opt/example_simple_account.wasm and b/soroban-test-wasms/wasm-workspace/opt/example_simple_account.wasm differ diff --git a/soroban-test-wasms/wasm-workspace/opt/example_updateable_contract.wasm b/soroban-test-wasms/wasm-workspace/opt/example_updateable_contract.wasm index 7a3c7985f..1c1fb9fab 100644 Binary files a/soroban-test-wasms/wasm-workspace/opt/example_updateable_contract.wasm and b/soroban-test-wasms/wasm-workspace/opt/example_updateable_contract.wasm differ diff --git a/soroban-test-wasms/wasm-workspace/opt/example_vec.wasm b/soroban-test-wasms/wasm-workspace/opt/example_vec.wasm index 39e57fe32..20a948b18 100644 Binary files a/soroban-test-wasms/wasm-workspace/opt/example_vec.wasm and b/soroban-test-wasms/wasm-workspace/opt/example_vec.wasm differ diff --git a/soroban-test-wasms/wasm-workspace/opt/soroban_write_upgrade_bytes_contract.wasm b/soroban-test-wasms/wasm-workspace/opt/soroban_write_upgrade_bytes_contract.wasm index f46f8b7a3..870caa766 100644 Binary files a/soroban-test-wasms/wasm-workspace/opt/soroban_write_upgrade_bytes_contract.wasm and b/soroban-test-wasms/wasm-workspace/opt/soroban_write_upgrade_bytes_contract.wasm differ diff --git a/soroban-test-wasms/wasm-workspace/opt/test_delegated_account.wasm b/soroban-test-wasms/wasm-workspace/opt/test_delegated_account.wasm index c2c3aab58..725df682a 100644 Binary files a/soroban-test-wasms/wasm-workspace/opt/test_delegated_account.wasm and b/soroban-test-wasms/wasm-workspace/opt/test_delegated_account.wasm differ