diff --git a/soroban-env-host/src/test/budget_metering.rs b/soroban-env-host/src/test/budget_metering.rs index 396d1f4f5..ac623a982 100644 --- a/soroban-env-host/src/test/budget_metering.rs +++ b/soroban-env-host/src/test/budget_metering.rs @@ -383,7 +383,8 @@ fn total_amount_charged_from_random_inputs() -> Result<(), HostError> { } let actual = format!("{:?}", host.as_budget()); - expect![[r#" + #[cfg(not(feature = "next"))] + let expected = expect![[r#" ===================================================================================================================================================================== Cpu limit: 100000000; used: 13060190 Mem limit: 41943040; used: 273960 @@ -419,8 +420,68 @@ fn total_amount_charged_from_random_inputs() -> Result<(), HostError> { Shadow mem limit: 41943040; used: 273960 ===================================================================================================================================================================== - "#]] - .assert_eq(&actual); + "#]]; + #[cfg(feature = "next")] + let expected = expect![ + r#" + ===================================================================================================================================================================== + Cpu limit: 100000000; used: 13060190 + Mem limit: 41943040; used: 273960 + ===================================================================================================================================================================== + CostType iterations input cpu_insns mem_bytes const_term_cpu lin_term_cpu const_term_mem lin_term_mem + WasmInsnExec 246 None 984 0 4 0 0 0 + MemAlloc 1 Some(152) 453 168 434 16 16 128 + MemCpy 1 Some(65) 50 0 42 16 0 0 + MemCmp 1 Some(74) 53 0 44 16 0 0 + DispatchHostFunction 176 None 54560 0 310 0 0 0 + VisitObject 97 None 5917 0 61 0 0 0 + ValSer 1 Some(49) 241 389 230 29 242 384 + ValDeser 1 Some(103) 62271 309 59052 4001 0 384 + ComputeSha256Hash 1 Some(193) 14310 0 3738 7012 0 0 + ComputeEd25519PubKey 226 None 9097178 0 40253 0 0 0 + VerifyEd25519Sig 1 Some(227) 384738 0 377524 4068 0 0 + VmInstantiation 1 Some(147) 503770 135880 451626 45405 130065 5064 + VmCachedInstantiation 1 Some(147) 503770 135880 451626 45405 130065 5064 + InvokeVmFunction 47 None 91556 658 1948 0 14 0 + ComputeKeccak256Hash 1 Some(1) 3812 0 3766 5969 0 0 + ComputeEcdsaSecp256k1Sig 1 None 710 0 710 0 0 0 + RecoverEcdsaSecp256k1Key 1 None 2315295 181 2315295 0 181 0 + Int256AddSub 1 None 4404 99 4404 0 99 0 + Int256Mul 1 None 4947 99 4947 0 99 0 + Int256Div 1 None 4911 99 4911 0 99 0 + Int256Pow 1 None 4286 99 4286 0 99 0 + Int256Shift 1 None 913 99 913 0 99 0 + ChaCha20DrawBytes 1 Some(1) 1061 0 1058 501 0 0 + ParseWasmInstructions 0 Some(0) 0 0 72736 25420 17564 6457 + ParseWasmFunctions 0 Some(0) 0 0 0 536688 0 47464 + ParseWasmGlobals 0 Some(0) 0 0 0 176902 0 13420 + ParseWasmTableEntries 0 Some(0) 0 0 0 29639 0 6285 + ParseWasmTypes 0 Some(0) 0 0 0 1048891 0 64670 + ParseWasmDataSegments 0 Some(0) 0 0 0 236970 0 29074 + ParseWasmElemSegments 0 Some(0) 0 0 0 317249 0 48095 + ParseWasmImports 0 Some(0) 0 0 0 694667 0 102890 + ParseWasmExports 0 Some(0) 0 0 0 427037 0 36394 + ParseWasmDataSegmentBytes0 Some(0) 0 0 66075 28 17580 257 + InstantiateWasmInstructions0 None 0 0 25059 0 70192 0 + InstantiateWasmFunctions 0 Some(0) 0 0 0 7503 0 14613 + InstantiateWasmGlobals 0 Some(0) 0 0 0 10761 0 6833 + InstantiateWasmTableEntries0 Some(0) 0 0 0 3211 0 1025 + InstantiateWasmTypes 0 None 0 0 0 0 0 0 + InstantiateWasmDataSegments0 Some(0) 0 0 0 16370 0 129632 + InstantiateWasmElemSegments0 Some(0) 0 0 0 28309 0 13665 + InstantiateWasmImports 0 Some(0) 0 0 0 683461 0 77273 + InstantiateWasmExports 0 Some(0) 0 0 0 297065 0 9176 + InstantiateWasmDataSegmentBytes0 Some(0) 0 0 25191 14 69256 126 + ===================================================================================================================================================================== + Internal details (diagnostics info, does not affect fees) + Total # times meter was called: 23 + Shadow cpu limit: 100000000; used: 13060190 + Shadow mem limit: 41943040; used: 273960 + ===================================================================================================================================================================== + + "# + ]; + expected.assert_eq(&actual); assert_eq!( host.as_budget().get_cpu_insns_consumed()?, diff --git a/soroban-env-host/src/test/bytes.rs b/soroban-env-host/src/test/bytes.rs index 5f7d1a51c..855b840c9 100644 --- a/soroban-env-host/src/test/bytes.rs +++ b/soroban-env-host/src/test/bytes.rs @@ -490,8 +490,12 @@ fn instantiate_oversized_bytes_from_linear_memory() -> Result<(), HostError> { U32Val::from(100).to_val().get_payload() ); - // constructing a big map will cause budget limit exceeded error - let wasm_long = wasm::wasm_module_with_large_bytes_from_linear_memory(480000, 7); + // constructing a big bytes will cause budget limit exceeded error + #[cfg(not(feature = "next"))] + const TOO_BIG: u32 = 480000; + #[cfg(feature = "next")] + const TOO_BIG: u32 = 8_000_000; + let wasm_long = wasm::wasm_module_with_large_bytes_from_linear_memory(TOO_BIG, 7); host.budget_ref().reset_unlimited()?; let contract_id_obj2 = host.register_test_contract_wasm(&wasm_long.as_slice()); host.budget_ref().reset_default()?; diff --git a/soroban-env-host/src/test/hostile.rs b/soroban-env-host/src/test/hostile.rs index e6873adf1..e0c1417a7 100644 --- a/soroban-env-host/src/test/hostile.rs +++ b/soroban-env-host/src/test/hostile.rs @@ -527,6 +527,61 @@ fn excessive_logging() -> Result<(), HostError> { host.enable_debug()?; let contract_id_obj = host.register_test_contract_wasm(wasm.as_slice()); + #[cfg(feature = "next")] + let expected_budget = expect![[r#" + ======================================================= + Cpu limit: 2000000; used: 284819 + Mem limit: 500000; used: 252830 + ======================================================= + CostType cpu_insns mem_bytes + WasmInsnExec 300 0 + MemAlloc 15750 67248 + MemCpy 2345 0 + MemCmp 696 0 + DispatchHostFunction 310 0 + VisitObject 244 0 + ValSer 0 0 + ValDeser 0 0 + ComputeSha256Hash 3738 0 + ComputeEd25519PubKey 0 0 + VerifyEd25519Sig 0 0 + VmInstantiation 0 0 + VmCachedInstantiation 0 0 + InvokeVmFunction 1948 14 + ComputeKeccak256Hash 0 0 + ComputeEcdsaSecp256k1Sig 0 0 + RecoverEcdsaSecp256k1Key 0 0 + Int256AddSub 0 0 + Int256Mul 0 0 + Int256Div 0 0 + Int256Pow 0 0 + Int256Shift 0 0 + ChaCha20DrawBytes 0 0 + ParseWasmInstructions 74324 17967 + ParseWasmFunctions 4192 370 + ParseWasmGlobals 1382 104 + ParseWasmTableEntries 29639 6285 + ParseWasmTypes 8194 505 + ParseWasmDataSegments 0 0 + ParseWasmElemSegments 0 0 + ParseWasmImports 5427 803 + ParseWasmExports 6672 568 + ParseWasmDataSegmentBytes66075 17580 + InstantiateWasmInstructions25059 70192 + InstantiateWasmFunctions 58 114 + InstantiateWasmGlobals 84 53 + InstantiateWasmTableEntries3211 1025 + InstantiateWasmTypes 0 0 + InstantiateWasmDataSegments0 0 + InstantiateWasmElemSegments0 0 + InstantiateWasmImports 5339 603 + InstantiateWasmExports 4641 143 + InstantiateWasmDataSegmentBytes25191 69256 + ======================================================= + + "#]]; + + #[cfg(not(feature = "next"))] let expected_budget = expect![[r#" ======================================================= Cpu limit: 2000000; used: 522315 diff --git a/soroban-env-host/src/test/invocation.rs b/soroban-env-host/src/test/invocation.rs index dd418a11d..fe58cc5c1 100644 --- a/soroban-env-host/src/test/invocation.rs +++ b/soroban-env-host/src/test/invocation.rs @@ -67,9 +67,9 @@ fn invoke_alloc() -> Result<(), HostError> { // pages or about 1.3 MiB, plus the initial 17 pages (1.1MiB) plus some more // slop from general host machinery allocations, plus allocating a VM once // during upload and once during execution we get around 2.5MiB. Call - // is "less than 4MiB". + // is "less than 5MiB". assert!(used_bytes > (128 * 4096)); - assert!(used_bytes < 0x40_0000); + assert!(used_bytes < 0x50_0000); Ok(()) } diff --git a/soroban-env-host/src/test/map.rs b/soroban-env-host/src/test/map.rs index 0c6558ee2..4e2bb7e57 100644 --- a/soroban-env-host/src/test/map.rs +++ b/soroban-env-host/src/test/map.rs @@ -484,8 +484,12 @@ fn instantiate_oversized_map_from_linear_memory() -> Result<(), HostError> { ); // constructing a big map will cause budget limit exceeded error + #[cfg(not(feature = "next"))] + const TOO_BIG: u32 = 20_000; + #[cfg(feature = "next")] + const TOO_BIG: u32 = 1_000_000; let wasm_long = - wasm::wasm_module_with_large_map_from_linear_memory(20000, U32Val::from(7).to_val()); + wasm::wasm_module_with_large_map_from_linear_memory(TOO_BIG, U32Val::from(7).to_val()); host.budget_ref().reset_unlimited()?; let contract_id_obj2 = host.register_test_contract_wasm(&wasm_long.as_slice()); host.budget_ref().reset_default()?; diff --git a/soroban-env-host/src/test/vec.rs b/soroban-env-host/src/test/vec.rs index 637f44dec..6481aaca3 100644 --- a/soroban-env-host/src/test/vec.rs +++ b/soroban-env-host/src/test/vec.rs @@ -453,8 +453,12 @@ fn instantiate_oversized_vec_from_linear_memory() -> Result<(), HostError> { ); // constructing a big map will cause budget limit exceeded error + #[cfg(not(feature = "next"))] + const TOO_BIG: u32 = 60_000; + #[cfg(feature = "next")] + const TOO_BIG: u32 = 1_000_000; let wasm_long = - wasm::wasm_module_with_large_vector_from_linear_memory(60000, U32Val::from(7).to_val()); + wasm::wasm_module_with_large_vector_from_linear_memory(TOO_BIG, U32Val::from(7).to_val()); host.budget_ref().reset_unlimited()?; let contract_id_obj2 = host.register_test_contract_wasm(&wasm_long.as_slice()); host.budget_ref().reset_default()?;