Skip to content

feat: continue implementing oprf-accountant v2#858

Open
fabian1409 wants to merge 3 commits into
mainfrom
fg/orpf-accountant-service-v2
Open

feat: continue implementing oprf-accountant v2#858
fabian1409 wants to merge 3 commits into
mainfrom
fg/orpf-accountant-service-v2

Conversation

@fabian1409

@fabian1409 fabian1409 commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator

Note

Medium Risk
Touches billing semantics, private-key signing, and a breaking DB shape; votes are not fully submitted on-chain yet, so behavior in production depends on finishing submission and aligning with the pending currentVoteEpoch contract API.

Overview
Adds a background OprfAccountantService that periodically calls BillingContract.currentVoteEpoch(), waits for the configured post-epoch offset, aggregates per-RP request counts from Postgres for the epoch’s [epochStart, epochEnd) span, and builds EIP-712–signed SignedVoteChunks for submitBillingVotes (on-chain submission is still commented out pending wallet/signer split and contract ABI).

Storage and ingestion: The rp_signatures migration is reshaped for v2—drops per-row epoch and the (rp_id, nonce, epoch) uniqueness rule, adds action and optional wip101_data, and makes signature nullable. Batch inserts persist the new fields; POST /req now returns 500 on DB errors. rp_counts_for_epoch_span supplies vote data with COUNT(DISTINCT nonce) per rp_id, ordered for the contract.

Wiring: Config gains billing contract address, RPC, wallet key, tick/vote timeouts, voting-window offset, and vote chunk size. Startup spawns the accountant loop alongside Axum and joins it on shutdown. Unit/integration tests cover vote-window logic, chunk signing, and aggregation edge cases. Cargo.lock picks up alloy/web3 and taceo-nodes-common test-deps (e.g. axum-test).

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

@fabian1409 fabian1409 requested review from a team, 0xThemis, dkales and philsippl as code owners July 10, 2026 13:12
@fabian1409 fabian1409 changed the title Fg/orpf accountant service v2 feat: continue implementing oprf-accountant Jul 10, 2026

@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 6 potential issues.

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 5d6ff03. Configure here.

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 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 Outdated
@fabian1409 fabian1409 force-pushed the fg/orpf-accountant-service-v2 branch from 5d6ff03 to 9c43150 Compare July 10, 2026 13:20
@socket-security

socket-security Bot commented Jul 10, 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

Comment thread services/oprf-accountant/src/postgres.rs Dismissed
Comment thread services/oprf-accountant/src/postgres.rs Dismissed
Comment thread services/oprf-accountant/src/postgres.rs Dismissed
Comment thread services/oprf-accountant/src/postgres.rs Fixed
Comment thread services/oprf-accountant/src/postgres.rs Dismissed
Comment thread services/oprf-accountant/src/postgres.rs Dismissed
Comment thread services/oprf-accountant/src/postgres.rs Dismissed
Comment thread services/oprf-accountant/src/postgres.rs Dismissed
Comment thread services/oprf-accountant/src/postgres.rs Dismissed
Comment thread services/oprf-accountant/src/postgres.rs Fixed
@fabian1409 fabian1409 marked this pull request as draft July 10, 2026 15:39
@fabian1409 fabian1409 changed the title feat: continue implementing oprf-accountant feat: continue implementing oprf-accountant v2 Jul 10, 2026
@fabian1409 fabian1409 force-pushed the fg/orpf-accountant-service-v2 branch from 9c43150 to 208794b Compare July 10, 2026 15:41
Comment thread services/oprf-accountant/src/postgres.rs Dismissed
Comment thread services/oprf-accountant/src/postgres.rs Dismissed
Comment thread services/oprf-accountant/src/postgres.rs Dismissed
… to assign epoch at vote time instead of when we get them
@fabian1409 fabian1409 force-pushed the fg/orpf-accountant-service-v2 branch from 208794b to 23df385 Compare July 13, 2026 06:26
@fabian1409 fabian1409 force-pushed the fg/orpf-accountant-service-v2 branch from 96f447c to 7e3f534 Compare July 13, 2026 09:27
@fabian1409 fabian1409 marked this pull request as ready for review July 13, 2026 09:36
Comment thread services/oprf-accountant/src/api.rs Outdated
Comment thread services/oprf-accountant/src/api.rs Outdated
Comment thread services/oprf-accountant/src/main.rs Outdated
#[instrument(level = "info", skip_all, name = "accountant_service::tick")]
pub(crate) async fn tick(&self) -> eyre::Result<()> {
if let MaybeVotes::Votes { epoch, counts } = self.maybe_get_votes().await? {
tokio::time::timeout(self.vote_timeout, self.vote_for_epoch(epoch, counts)).await??;

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.

nit: maybe add some .context() here to the three ?. Helps in case this actually happens

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