Repository navigation
feat(contracts): arbiter activation path for the dispute subsystem - #1934
Open
achiever2110 wants to merge 5 commits into
Open
achiever2110 wants to merge 5 commits into
achiever2110 wants to merge 5 commits into
Conversation
Every stream constructor wrote arbiter: None and nothing ever changed it, so request_dispute always failed with DisputeNotSupported: the escrow/dispute subsystem was unreachable from the public API, and its tests injected the field into storage to exercise it at all (LabsCrypt#1897). set_stream_arbiter lets the sender name (or replace, or detach) the arbiter on an active stream. Swapping the decider once a dispute is open would let the sender choose the verdict, so that is refused with a new ArbiterLocked error rather than ignored. The contract itself and the sender cannot be the arbiter, for the same reason. The change emits stream_arbiter_set, so 'the arbiter was always that address' is auditable. Three tests: the dispute path becomes reachable through the public API alone (request_dispute succeeds only after an arbiter is set), only the sender may set it, and it locks once a dispute is open.
…rbiter-activation-path # Conflicts: # contracts/stream_contract/src/test.rs
The merge appended the arbiter tests after a trailing newline; rustfmt flags the extra blank line at EOF and the Soroban Contracts CI job fails on it.
ArbiterLocked now occupies discriminant 50, so asserting try_from(50) is unknown contradicted the variant added by this PR and failed the contracts test suite.
This branch has not been deployed
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.
The dispute/escrow subsystem existed, was tested, and could not be reached.
Closes #1897
The problem
Every stream constructor writes
arbiter: None, and no entrypoint ever wrotestream.arbiter. Sorequest_disputealways failed withDisputeNotSupported,resolve_disputecould never run, and the only way toexercise the subsystem at all was for the tests to reach into storage and inject
the field — which the existing test does, with a comment saying it is standing in
for "the escrow deployment flow". There was no such flow.
The change
set_stream_arbiter(sender, stream_id, arbiter: Option<Address>):require_authplus an ownership check), because thearbiter is the party who decides a cancellation dispute.
ArbiterLockedoncedispute_status != None. A senderwho could swap the decider mid-dispute could simply pick someone who rules in
their favour, so this fails loudly instead of being ignored.
no-op respectively.
Nonedetaches the arbiter, which makes the stream non-disputable again.stream_arbiter_setwith the full record, so a later "the arbiter wasalways that address" is checkable against history.
ArbiterLockedis a new error code (49). The diagnostics round-trip test thatused 49 as its "unknown code" sentinel now uses 50.
On the yield half of the issue
The issue also mentions
yield_enabledand theYieldStrategytrait. I did notadd a toggle for it: nothing in the contract reads
yield_enabledand nothingimplements
YieldStrategy, so such an entrypoint would set a flag that changesno behaviour — exactly the kind of half-live surface the other issues in this
series are about. Dropping it from the public API is the honest option, and it is
already absent from it. When a strategy is implemented, the toggle should ship
with the code path that consumes it. Say the word and I will open a follow-up
that removes the dead trait and the storage field properly, with a migration.
Tests
cargo test -p stream_contract— 278 passed, 1 ignored (was 275 + 1).New:
request_disputefails before an arbiter is set and succeeds after — throughthe public API only, no storage injection
as arbiter
ArbiterLockedonce a dispute is openbash scripts/lint-rust.shpasses (pre-commit hook).