fix(settlement): validate governance fee config shape - #667
Open
Hikmaholadele wants to merge 4 commits into
Open
fix(settlement): validate governance fee config shape#667Hikmaholadele wants to merge 4 commits into
Hikmaholadele wants to merge 4 commits into
Conversation
Closes Betta-Pay#483 Safely validate the governance fee configuration before accessing its fields. Previously, `read_governance_fee_rule` and `validate_fee_against_governance` used `try_invoke_contract::<Option<GovFeeConfig>, SettlementError>`, which triggers host-side `map_unpack_to_slice` deserialisation. If the governance contract returns a struct with a different shape (e.g. 1 field instead of 2), the host panics with an opaque "escalating error to panic" rather than the typed `GovernanceCallFailed` error. The fix introduces `try_read_governance_fee_config`, which: 1. Receives a raw `Val` from `try_invoke_contract::<Val>` (no host-side deserialisation). 2. Validates the map structure: exactly 2 fields, both present, both `u32`. 3. Returns `Some(GovFeeConfig)` for valid configs, `None` for Void, or panics with `GovernanceCallFailed` for malformed shapes. Both `read_governance_fee_rule` and `validate_fee_against_governance` now route through this helper. Existing behavior for valid 2-field configurations and no-config (bootstrap fallback) is preserved. cargo test -p settlement_contract — 108 passed, 0 failed (governance error tests: 7 passed, including 3 new malformed-config regression tests).
|
@Hikmaholadele 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! 🚀 |
Remove the `try_update_governance` assertion from `real_auth_tests::fee_anchor_and_system_param_writes_require_real_authorization`. The `GovernanceContract` no longer has an `update_governance` method (it was replaced by `upgrade` and `transfer_admin`), so the generated client does not expose `try_update_governance`. This pre-existing stale reference caused a compilation failure on every workspace build. The remaining three assertions (`try_set_fee_config`, `try_upsert_anchor`, `try_update_system_param`) still verify that governance writes require real authorization. Closes Betta-Pay#483 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
Contributor
Author
|
Hi, this workflow is currently waiting for maintainer approval. Could you please approve it so the workflow can proceed? Thank you. |
Fix compilation errors caused by API changes merged from main: - Add missing deployer parameter to all init() calls in tests - Add executor parameter to execute() calls in timelock tests - Fix variable references (_admins -> admins) in schedule collision tests - Import GovernanceContract/GovernanceContractClient from governance_contract - Add missing Symbol/FromVal imports for test event assertions - Fix set_fee_config to use governance_contract::FeeConfig type - Remove unused imports and prefix unused variables with underscore - Use IntoVal for Symbol conversion in storage.rs - Replace assert_eq! with assert! for literal bool comparison - Apply cargo fmt formatting across workspace 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
Contributor
Author
|
This workflow is currently awaiting maintainer approval. Could you please approve it so the workflow can proceed? Thank you. |
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 #483
Summary
Safely validates the governance fee configuration before deserialization, preventing malformed configurations from causing opaque host/Wasm errors.
Tests: cargo test --workspace — all tests pass.
Closes #483