Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/cmd/dry_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func runDryRun(cmd *cobra.Command, args []string) error {
}

// Validate envelope is parseable
envBytes, err := base64.StdEncoding.DecodeString(envXdrB64)
envBytes, err := base64.StdEncoding.Strict().DecodeString(envXdrB64)
if err != nil {
return errors.WrapUnmarshalFailed(err, "envelope base64")
}
Expand Down
2 changes: 1 addition & 1 deletion simulator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ nursery = "warn"
# HostedContractEvent.failed_call field that this simulator relies on.
# We accept any release in the 21-25 range so the binary stays compatible
# with both mainnet protocol 21 and subsequent minor protocol bumps.
soroban-env-host = { version = ">=21.0, <26" } # Updated to latest version
soroban-env-host = { version = ">=21.0, <26", features = ["testutils"] } # Updated to latest version
base64 = "0.21"
clap = { version = "4.4", features = ["derive"] }
serde = { version = "1.0", features = ["derive"] }
Expand Down
24 changes: 24 additions & 0 deletions simulator/src/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,18 @@ impl SimHost {
host.set_diagnostic_level(DiagnosticLevel::Debug)
.expect("failed to set diagnostic level");

// Hook memory_limit into the Budget tracking mechanism via reset_limits()
if let Some(mem_limit) = memory_limit {
// Get the current CPU limit to preserve it
let cpu_limit = host.budget_cloned()
.get_cpu_insns_remaining()
.unwrap_or(100_000_000);
// Reset both CPU and memory limits to enforce memory_limit during execution
if let Err(e) = host.budget_ref().reset_limits(cpu_limit, mem_limit) {
eprintln!("Warning: Failed to set memory limit: {:?}", e);
}
}

Self {
inner: host,
ledger_snapshot: LedgerSnapshot::new(),
Expand All @@ -79,6 +91,18 @@ impl SimHost {
let host = Host::with_storage_and_budget(storage, budget);
host.set_diagnostic_level(DiagnosticLevel::Debug)?;

// Hook memory_limit into the Budget tracking mechanism via reset_limits()
if let Some(mem_limit) = memory_limit {
// Get the current CPU limit to preserve it
let cpu_limit = host.budget_cloned()
.get_cpu_insns_remaining()
.unwrap_or(100_000_000);
// Reset both CPU and memory limits to enforce memory_limit during execution
if let Err(e) = host.budget_ref().reset_limits(cpu_limit, mem_limit) {
eprintln!("Warning: Failed to set memory limit: {:?}", e);
}
}

Ok(Self {
inner: host,
ledger_snapshot: snapshot.clone(),
Expand Down
Loading