Add dry-run execution simulation for governance proposals (#917) - #935
Merged
Conversation
…#917) Summary ------- Add a simulation interface that runs proposal logic without mutating state, so maintainers can validate proposal effects before executing on-chain. Changes ------- 1. proposals.rs - Define SimulationEffect and SimulationResult structs (contract types) that describe every storage mutation a proposal would cause. - Add simulate_proposal_action(env, proposal) — iterates over all ProposalType variants, reads current storage values, and records the proposed changes in a SimulationResult without writing anything. - Add simulate_proposal(env, proposal_id) — convenience wrapper that fetches the proposal by ID and delegates to simulate_proposal_action. 2. lib.rs - Import simulate_proposal, SimulationEffect, SimulationResult from the proposals module. - Publicly export SimulationEffect, SimulationResult. - Add simulate_proposal as a public contract function that calls through to proposals::simulate_proposal. - Register est_simulation test module. 3. test_simulation.rs (new) - simulate_signal_proposal_returns_effects_without_mutating — verifies simulation returns effects and does not change proposal status. - simulate_parameter_change_proposal_reports_current_and_proposed — checks that current/proposed values are surfaced for param changes. - simulate_treasury_spend_insufficient_balance_reports_failure — confirms simulation reports failure when treasury balance is too low. - simulate_nonexistent_proposal_returns_error — validates that ProposalNotFound is returned for invalid IDs. - simulate_feature_toggle_reports_effect — checks feature toggle effects contain the correct key. - simulation_is_read_only_no_storage_writes — runs simulation twice and confirms identical results + unchanged state. Design notes ------------ - The simulation is **read-only** — no storage writes are performed. Only env.storage().instance().get() is called; no .set() or .remove(). - No authentication required — safe to call via simulateTransaction RPC. - Simulation failure (e.g. insufficient treasury) is returned as a SimulationResult with success: false rather than a contract error, so the caller always receives structured diagnostic information.
|
@Kenisank Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #917
Summary
Add a simulation interface that runs proposal logic without mutating state, so maintainers can validate proposal effects before executing on-chain.
Changes
proposals.rs
lib.rs
test_simulation.rs (new)
Design notes
Summary
Test plan
Security review checklist
Required for any change touching
contracts/(or shared crates consumed bycontracts, e.g.
contracts/common). Not required for docs-only, CI-only, ornon-contract tooling changes — if this PR doesn't touch contract code, check
the box below and move on.
contracts/or contract-consumed shared crates,or it does, and
docs/security/release_security_checklist.mdwas reviewed against this change (Logic, Access control, Upgrades,
Arithmetic categories as applicable).
The automated portion of the release gate runs in
security-release-gate.yml(fmt/clippy/tests/deployment-manifest/error-code checks). This checkbox
covers the human-judgement half that automation can't verify.
WASM ABI diff
CI posts a WASM ABI Export Diff Report as a PR comment. Check it for:
.breaking.txtfile is removed in the follow-up PR.Related issue