Skip to content

feat: continue implementing oprf-accountant#849

Closed
fabian1409 wants to merge 5 commits into
mainfrom
fg/oprf-accountant-service
Closed

feat: continue implementing oprf-accountant#849
fabian1409 wants to merge 5 commits into
mainfrom
fg/oprf-accountant-service

Conversation

@fabian1409

@fabian1409 fabian1409 commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

Note

Medium Risk
Changes affect billing epoch assignment and vote timing against a live contract and wallet key, but votes are not yet submitted on-chain while the cursor can still advance after the stub vote path.

Overview
Adds an OprfAccountantService background worker that buckets incoming billable RP requests by epoch (from expires_at and on-chain timing eras), persists them in Postgres, and on each tick refreshes eras from the BillingContract, decides whether the last closed epoch’s voting window is open (including a configurable flush offset), aggregates per-RP counts, and advances an epoch_cursor so restarts do not re-vote the same epoch. On-chain submitBillingVotes / EIP-712 signing is still a TODO in vote_for_epoch.

The HTTP POST /req path now records batches through the accountant instead of writing Postgres directly. Config gains billing contract address, RPC, wallet key, tick interval, and voting-window offset; startup spawns the worker alongside Axum and adds bounded graceful shutdown. Migrations add epoch_cursor, store epoch on rp_signatures, and make signature optional. Tests cover era/epoch math, vote-window edge cases, and Postgres aggregation (including per-epoch nonce uniqueness).

Reviewed by Cursor Bugbot for commit de5c9fe. Bugbot is set up for automated code reviews on this repo. Configure here.

@socket-security

socket-security Bot commented Jul 9, 2026

Copy link
Copy Markdown

Warning

Review the following alerts detected in dependencies.

According to your organization's Security Policy, it is recommended to resolve "Warn" alerts. Learn more about Socket for GitHub.

Action Severity Alert  (click "▶" to expand/collapse)
Warn High
Obfuscated code: cargo tokio is 90.0% likely obfuscated

Confidence: 0.90

Location: Package overview

From: Cargo.lockcargo/tokio@1.50.0

ℹ Read more on: This package | This alert | What is obfuscated code?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Packages should not obfuscate their code. Consider not using packages with obfuscated code.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore cargo/tokio@1.50.0. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

View full report

@fabian1409
fabian1409 force-pushed the fg/oprf-accountant-service branch from 09d1437 to e1d94b5 Compare July 9, 2026 12:21
Comment thread services/oprf-accountant/src/accountant_service.rs
Comment thread services/oprf-accountant/src/accountant_service.rs Outdated
Comment thread services/oprf-accountant/src/accountant_service.rs Dismissed
Comment thread services/oprf-accountant/src/accountant_service.rs Dismissed
Comment thread services/oprf-accountant/src/accountant_service.rs Dismissed
Comment thread services/oprf-accountant/src/accountant_service.rs Dismissed
Comment thread services/oprf-accountant/src/accountant_service.rs Dismissed
Comment thread services/oprf-accountant/src/accountant_service.rs Dismissed
Comment thread services/oprf-accountant/src/accountant_service.rs Dismissed
Comment thread services/oprf-accountant/src/accountant_service.rs Dismissed
Comment thread services/oprf-accountant/src/accountant_service.rs Dismissed
Comment thread services/oprf-accountant/src/accountant_service.rs Dismissed
Comment thread services/oprf-accountant/migrations/20260703123015_init_db.up.sql Outdated
Comment thread services/oprf-accountant/src/accountant_service.rs Outdated
Comment thread services/oprf-accountant/src/accountant_service.rs Outdated
Comment thread services/oprf-accountant/src/accountant_service.rs
Comment thread services/oprf-accountant/src/accountant_service.rs
Comment thread services/oprf-accountant/src/lib.rs
Comment thread services/oprf-accountant/src/postgres.rs Outdated
Comment thread services/oprf-accountant/src/timing_watcher.rs Outdated
Comment thread services/oprf-accountant/src/timing_watcher.rs Outdated
Comment thread services/oprf-accountant/src/timing_watcher.rs Outdated
@fabian1409
fabian1409 force-pushed the fg/oprf-accountant-service branch from 37cf045 to 81bae2b Compare July 9, 2026 14:51
@fabian1409
fabian1409 force-pushed the fg/oprf-accountant-service branch from 81bae2b to 4023a29 Compare July 9, 2026 14:58
@fabian1409
fabian1409 marked this pull request as ready for review July 10, 2026 07:29
@fabian1409
fabian1409 requested review from a team, dkales and philsippl as code owners July 10, 2026 07:29

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit de5c9fe. Configure here.

tracing::info!(epoch, ?counts, "submitting billing vote for epoch");
self.vote_for_epoch(epoch, counts).await?;
tracing::info!(epoch, "successfully submitted billing vote for epoch");
self.db.set_epoch_cursor(epoch).await?;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Cursor advances without on-chain vote

High Severity

After each successful tick vote window, set_epoch_cursor runs even though vote_for_epoch only returns early for empty counts and otherwise hits a TODO without calling submitBillingVotes. The DB then records the epoch as processed while the chain never receives billing votes for non-empty aggregates.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit de5c9fe. Configure here.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

this will be added in a followup PR

@fabian1409

Copy link
Copy Markdown
Collaborator Author

replaced by #858

@fabian1409 fabian1409 closed this Jul 13, 2026
@fabian1409
fabian1409 deleted the fg/oprf-accountant-service branch July 13, 2026 12:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants