Skip to content

Update cvat payout calculator for the new manifest#3981

Open
portuu3 wants to merge 1 commit into
developfrom
cvat-new-manifest
Open

Update cvat payout calculator for the new manifest#3981
portuu3 wants to merge 1 commit into
developfrom
cvat-new-manifest

Conversation

@portuu3

@portuu3 portuu3 commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator

Issue tracking

NA

Context behind the change

Update cvat payout calculator for the new manifest

How has this been tested?

Tested using unit tests
Pending to test with CVAT oracles on testnet when ready

Release plan

NA

Potential risks; What to monitor; Rollback plan

NA

@portuu3
portuu3 requested a review from Dzeranov July 23, 2026 07:59
@portuu3 portuu3 self-assigned this Jul 23, 2026
@vercel

vercel Bot commented Jul 23, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

5 Skipped Deployments
Project Deployment Actions Updated (UTC)
faucet-frontend Ignored Ignored Jul 23, 2026 8:00am
faucet-server Ignored Ignored Jul 23, 2026 8:00am
human-app Skipped Skipped Jul 23, 2026 8:00am
human-dashboard-frontend Skipped Skipped Jul 23, 2026 8:00am
staking-dashboard Skipped Skipped Jul 23, 2026 8:00am

Request Review

@dnechay dnechay moved this to In Review in Core tech - 2026 (H1) Jul 23, 2026

@dnechay dnechay left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Lgtm overall, some cleanup comments


for (const jobFinalResult of matchedJobResults) {
// TODO: enable annotation quality validation when ready
if (

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Already filtered above, so probably we can remove this check on jobFilanResult

Comment on lines +63 to 69
afterEach(() => {
jest.resetAllMocks();
mockedEscrowClient.build.mockResolvedValue({
getIntermediateResultsUrl: mockedGetIntermediateResultsUrl,
getReservedFunds: mockedGetReservedFunds,
} as unknown as EscrowClient);
});

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

No need in this block

Suggested change
afterEach(() => {
jest.resetAllMocks();
mockedEscrowClient.build.mockResolvedValue({
getIntermediateResultsUrl: mockedGetIntermediateResultsUrl,
getReservedFunds: mockedGetReservedFunds,
} as unknown as EscrowClient);
});

const tokenDecimals = BigInt(6);
const jobCount = jobsPerAnnotator * annotators.length;
const payoutPerJob = BigInt(faker.number.int({ min: 1000, max: 100000 }));
const reservedFunds = payoutPerJob * BigInt(jobCount);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
const reservedFunds = payoutPerJob * BigInt(jobCount);
mockedGetReservedFunds.mockResolvedValueOnce(payoutPerJob * BigInt(jobCount));

const mockedGetReservedFunds = jest
.fn()
.mockImplementation(async () =>
BigInt(faker.number.int({ min: 1000, max: 100000 })),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Let's not mock default with some random number, because it can confuse in case of incorrect/failing test suite, it's better to mimic real behavior (i.e. funds not reserved) which returns 0n

Suggested change
BigInt(faker.number.int({ min: 1000, max: 100000 })),
0n,

Comment on lines +142 to 149
mockedGetReservedFunds.mockResolvedValueOnce(reservedFunds);
const manifest = generateCvatManifest();
const payouts = await calculator.calculate({
chainId,
escrowAddress,
manifest,
manifest: manifest,
finalResultsUrl: faker.internet.url(),
});

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
mockedGetReservedFunds.mockResolvedValueOnce(reservedFunds);
const manifest = generateCvatManifest();
const payouts = await calculator.calculate({
chainId,
escrowAddress,
manifest,
manifest: manifest,
finalResultsUrl: faker.internet.url(),
});
const payouts = await calculator.calculate({
chainId,
escrowAddress,
manifest: generateCvatManifest(),
finalResultsUrl: faker.internet.url(),
});

results: [
{
id: faker.number.int(),
job_id: faker.number.int(),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Even though we use faker there, there is a very little chance that faker.number.int() will generate final_result_id = result.id, so for the purpose of this test let's make sure somehow that those ids are 100% different

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Review

Development

Successfully merging this pull request may close these issues.

2 participants