Skip to content

Commit

Permalink
fix: require fisherman deposit for conflicting query disputes (TRST-M07)
Browse files Browse the repository at this point in the history
Signed-off-by: Tomás Migone <[email protected]>
  • Loading branch information
tmigone committed Nov 29, 2024
1 parent 0c0d090 commit 8f1af3e
Show file tree
Hide file tree
Showing 2 changed files with 184 additions and 55 deletions.
25 changes: 21 additions & 4 deletions packages/subgraph-service/contracts/DisputeManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,14 @@ contract DisputeManager is
* @notice Create query disputes for two conflicting attestations.
* A conflicting attestation is a proof presented by two different indexers
* where for the same request on a subgraph the response is different.
* For this type of dispute the fisherman is not required to present a deposit
* as one of the attestation is considered to be right.
* For this type of dispute it's safe to assume one of the attestations is incorrect
* so the fisherman's deposit would not be necesarry, however to prevent spam attacks
* we still require it.
* Two linked disputes will be created and if the arbitrator resolve one, the other
* one will be automatically resolved.
* Requirements:
* - fisherman must have previously approved this contract to pull `disputeDeposit` amount
* of tokens from their balance.
* @param attestationData1 First attestation data submitted
* @param attestationData2 Second attestation data submitted
* @return DisputeId1, DisputeId2
Expand Down Expand Up @@ -205,10 +209,23 @@ contract DisputeManager is
)
);

// Get funds from fisherman
_pullFishermanDeposit();

// Create the disputes
// The deposit is zero for conflicting attestations
bytes32 dId1 = _createQueryDisputeWithAttestation(fisherman, 0, attestation1, attestationData1);
bytes32 dId2 = _createQueryDisputeWithAttestation(fisherman, 0, attestation2, attestationData2);
bytes32 dId1 = _createQueryDisputeWithAttestation(
fisherman,
disputeDeposit / 2,
attestation1,
attestationData1
);
bytes32 dId2 = _createQueryDisputeWithAttestation(
fisherman,
disputeDeposit / 2,
attestation2,
attestationData2
);

// Store the linked disputes to be resolved
disputes[dId1].relatedDisputeId = dId2;
Expand Down
Loading

0 comments on commit 8f1af3e

Please sign in to comment.