feat: implement stakeholder voting-to-suspend in MerchantRegistry (decentralized governance) - #564
Merged
Merged
Conversation
…ne-enforcement feat(dispute): auto-set computed_deadline and add merchant suspension governance
|
@Johnpii1 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.
close #438
Motivation
Ensure disputes have a usable computed deadline so escalation and deadline checks can run when operators do not set review_deadline (Issue #177).
Provide decentralized merchant suspension via stakeholder (arbitrator) proposals and voting to replace admin-only suspensions and support governance-driven enforcement (roadmap/Issue #438).
Description
Add dispute deadline constants and configuration: DEFAULT_DISPUTE_DEADLINE_THRESHOLD_AMOUNT, SMALL_DISPUTE_DEADLINE_SECS, and LARGE_DISPUTE_DEADLINE_SECS in fluxapay/src/lib.rs and a persistent DataKey::DisputeDeadlineThresholdAmount fallback.
Wire computed deadline into dispute creation by setting Dispute.computed_deadline_secs using computed_dispute_deadline_secs(env, amount) during create_dispute_inner.
Make maybe_escalate_dispute_due_to_deadline fall back to created_at + computed_deadline_secs when review_deadline is not set.
Add admin API set_dispute_threshold(env, admin, amount) and helpers get_dispute_deadline_threshold and computed_dispute_deadline_secs to allow configuring the small/large threshold at runtime.
Add merchant suspension governance to fluxapay/src/merchant_registry.rs: SuspensionProposal type, persistent proposal/vote counters/keys, propose_merchant_suspension (arbitrator-only), vote_suspension (arbitrator-only) with duplicate-vote rejection, expiration handling, auto-suspend execution when approval votes reach the configured threshold, and emitted events MERCHANT/SUSPENSION_PROPOSED, MERCHANT/SUSPENSION_VOTED, and MERCHANT/SUSPENDED.
Add set_suspension_threshold(env, admin, threshold) and grant_role passthrough and initialize AccessControl in MerchantRegistry::initialize so role-based governance can operate.
Testing
Ran cargo check -q; the build reported failures due to unrelated, pre-existing repository compile issues (e.g. overly long contract symbols/field names and some missing types), so compilation could not be validated in this run.
Ran cargo fmt --check; formatting check failed due to an existing parse error (unclosed delimiter) in fluxapay/src/dispute_test.rs, preventing a clean format pass.
No new unit test suite was executed as part of this rollout because the repo-level compile/format issues blocked running the standard test and build commands.