Skip to content

Escrow Cancellation #3357

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 15 commits into
base: develop
Choose a base branch
from
Open

Escrow Cancellation #3357

wants to merge 15 commits into from

Conversation

flopez7
Copy link
Contributor

@flopez7 flopez7 commented May 20, 2025

Issue tracking

#3287

Context behind the change

  • Added fund reservation in escrow contract and CancellationRefund and CancellationRequested events to track cancellation process and refunds.
  • Updated Subgraph to handle new events from escrow contract
  • Updated SDKs to add the new var needed for fund reservation and some new methods for querying CancellationRefund and CancellationRequested events
  • Created new webhook from JL to RecO for escrow cancellation and updated cancellation logic. Now we have to check CancellationRefundEvents for getting the amount we have to refund to the user instead of receiving it directly from the SDK cancel method.
  • In RecO, added new fund reservation logic and new method for handling escrow cancellation by calling StoreResults and sending the results to RepO
  • Updated Rep Oracle logic to properly handle cancelled escrows, calculate payouts using reserved funds and send webhooks back to job launcher and exchange oracle.

How has this been tested?

Deployed locally and completed the fortune flow with some escrows. Tested normal and cancellation flow
Run unit tests

Release plan

Important: Check that there are no active escrows before deployment to avoid errors due to StoreResult contract change. Also we need to make sure CVAT and Audino are updated to use new contract version

  • Deploy smart contracts
  • Deploy the new SDK version
  • Deploy new Subgraphs

Potential risks; What to monitor; Reverse plan

Since the core has been updated, we have to check each step to make sure it works correctly.

@flopez7 flopez7 requested a review from portuu3 May 20, 2025 13:38
@flopez7 flopez7 self-assigned this May 20, 2025
Copy link

vercel bot commented May 20, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
faucet-frontend ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 28, 2025 10:10am
4 Skipped Deployments
Name Status Preview Comments Updated (UTC)
faucet-server ⬜️ Ignored (Inspect) Visit Preview May 28, 2025 10:10am
human-app ⬜️ Skipped (Inspect) May 28, 2025 10:10am
human-dashboard-frontend ⬜️ Skipped (Inspect) May 28, 2025 10:10am
staking-dashboard ⬜️ Skipped (Inspect) May 28, 2025 10:10am

@flopez7 flopez7 marked this pull request as draft May 20, 2025 13:38
Copy link
Collaborator

@portuu3 portuu3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For bulkPayout we should have the changes from https://github.com/humanprotocol/human-protocol/pull/3261/files. Merge it first

@portuu3
Copy link
Collaborator

portuu3 commented May 20, 2025

For bulkPayout we should have the changes from https://github.com/humanprotocol/human-protocol/pull/3261/files. Merge it first

* Fix possible no assignments error when there are

* Update readme

* Update cvat sdk versions

* Address api changes

* Improve performance of some cvat calls

* Improve description
* Draw roi point along with bbox in skeleton tasks

* Relax filtering for overlapping gt skeletons (#3358)
@flopez7 flopez7 force-pushed the feat/escrow-cancellation branch from 3f4dce8 to 941d544 Compare May 21, 2025 09:19
@vercel vercel bot temporarily deployed to Preview – staking-dashboard May 21, 2025 09:21 Inactive
@vercel vercel bot temporarily deployed to Preview – human-dashboard-frontend May 21, 2025 09:21 Inactive
@vercel vercel bot temporarily deployed to Preview – human-app May 21, 2025 09:21 Inactive
* fix payouts when fee calculation is truncated

* fix tests and use faker in the root of the repository

* document escrow contract and improve tests

* Delete unnecessary check for BULK_MAX_VALUE

* remove unused modifier

* Undo faker package changes for updating yarn

---------

Co-authored-by: Francisco López <francislopez977@gmail.com>
…avoid remaining funds and update tests for dynamic amounts
@vercel vercel bot temporarily deployed to Preview – staking-dashboard May 22, 2025 11:19 Inactive
@vercel vercel bot temporarily deployed to Preview – human-app May 22, 2025 11:19 Inactive
@vercel vercel bot temporarily deployed to Preview – human-dashboard-frontend May 22, 2025 11:19 Inactive
@vercel vercel bot temporarily deployed to Preview – human-dashboard-frontend May 22, 2025 11:56 Inactive
@vercel vercel bot temporarily deployed to Preview – staking-dashboard May 22, 2025 11:56 Inactive
@vercel vercel bot temporarily deployed to Preview – human-app May 22, 2025 11:56 Inactive
flopez7 and others added 2 commits May 28, 2025 11:36
- Updated subgraph package.json to include network-specific test command.
- Enhanced GraphQL schema with CancellationRefundEvent and CancellationRequested types.
- Implemented event handlers for CancellationRequested and CancellationRefund in EscrowTemplate.
- Modified EscrowStatistics to track toCancelStatusEventCount.
- Updated dayUpdates utility to initialize dailyToCancelStatusEventCount.
- Adjusted template.yaml to listen for CancellationRequested and CancellationRefund events.
- Expanded tests to cover new cancellation events and their effects on statistics.
- Created fixture functions for generating mock CancellationRequested and CancellationRefund events.
@vercel vercel bot temporarily deployed to Preview – human-dashboard-frontend May 28, 2025 10:08 Inactive
@vercel vercel bot temporarily deployed to Preview – human-app May 28, 2025 10:08 Inactive
@vercel vercel bot temporarily deployed to Preview – staking-dashboard May 28, 2025 10:08 Inactive
@flopez7 flopez7 requested a review from Dzeranov May 28, 2025 10:23
@flopez7 flopez7 marked this pull request as ready for review May 28, 2025 10:23
@flopez7 flopez7 changed the title Feat/escrow cancellation Escrow Cancellation May 28, 2025
@flopez7 flopez7 added documentation Improvements or additions to documentation Fortune Fortune app Contracts Core and removed On hold labels May 28, 2025
@@ -486,13 +489,17 @@ def get_w3_with_priv_key(priv_key: str):
raise EscrowClientError("Invalid empty hash")
if not validate_url(url):
raise EscrowClientError(f"Invalid URL: {url}")
if amount <= 0:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the contract actually allows amount 0

@@ -1,6 +1,8 @@
export enum EventType {
ESCROW_COMPLETED = 'escrow_completed',
ESCROW_CANCELED = 'escrow_canceled',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why escrow and job?

eventEntity.txHash = event.transaction.hash;
eventEntity.escrowAddress = event.address;
eventEntity.sender = event.transaction.from;
eventEntity.status = 'Cancelled';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check internal transaction


emit IntermediateStorage(_url, _hash);

if (status == EscrowStatuses.ToCancel) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cancel the escrow if fundsToReserve=0, unreservedFunds=0 and status is ToCancel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Contracts Core documentation Improvements or additions to documentation Fortune Fortune app
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants