Skip to content

Commit 23df385

Browse files
committed
add accountant_service.rs that handles rp count submitting, update db to assign epoch at vote time instead of when we get them
1 parent 664429b commit 23df385

9 files changed

Lines changed: 1312 additions & 146 deletions

File tree

Cargo.lock

Lines changed: 285 additions & 103 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

services/oprf-accountant/Cargo.toml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,24 @@ repository.workspace = true
88
license.workspace = true
99

1010
[dependencies]
11-
alloy-primitives.workspace = true
11+
alloy = { workspace = true, features = ["full", "rpc", "rpc-client-ws"] }
1212
ark-babyjubjub = { workspace = true }
1313
ark-serde-compat = { workspace = true }
1414
ark-serialize = { workspace = true }
1515
axum = { workspace = true, features = ["json", "macros"] }
1616
backon = { workspace = true, features = ["std", "tokio-sleep"] }
1717
config.workspace = true
1818
eyre = { workspace = true }
19+
futures-util = { workspace = true }
1920
humantime-serde = { workspace = true }
2021
itertools.workspace = true
2122
metrics = { workspace = true }
2223
rustls = { workspace = true }
24+
secrecy = { workspace = true, features = ["serde"] }
2325
serde = { workspace = true, features = ["derive"] }
2426
serde_json = { workspace = true }
2527
sqlx = { workspace = true, features = ["postgres", "runtime-tokio-rustls"] }
26-
taceo-nodes-common = { workspace = true, features = ["api", "postgres"] }
28+
taceo-nodes-common = { workspace = true, features = ["api", "postgres", "web3"] }
2729
telemetry-batteries = { workspace = true }
2830
thiserror.workspace = true
2931
tokio = { workspace = true, features = [
@@ -34,9 +36,16 @@ tokio = { workspace = true, features = [
3436
"time",
3537
"tokio-macros",
3638
] }
39+
tokio-util = { workspace = true }
3740
tracing = { workspace = true, features = ["release_max_level_debug"] }
3841
uuid.workspace = true
3942
world-id-primitives = { workspace = true }
4043

44+
[dev-dependencies]
45+
taceo-nodes-common = { workspace = true, features = [
46+
"postgres",
47+
"test-utils",
48+
] }
49+
4150
[target.'cfg(not(target_env = "msvc"))'.dependencies]
4251
tikv-jemallocator = { workspace = true }
Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
-- Stores RP (relying party) signatures over proof requests so they can be verified later.
2-
create table if not exists rp_signatures (
2+
CREATE TABLE IF NOT EXISTS rp_signatures (
33
id BIGINT GENERATED ALWAYS AS identity PRIMARY KEY,
44
rp_id BIGINT NOT NULL,
5-
epoch BIGINT NOT NULL,
65
-- version is currently always 1
76
version SMALLINT NOT NULL DEFAULT 1,
87
nonce BYTEA NOT NULL,
98
-- Signed validity window (u64 unix seconds stored as bigint)
10-
signed_created_at BIGINT NOT NULL,
11-
signed_expires_at BIGINT NOT NULL,
9+
created_at BIGINT NOT NULL,
10+
expires_at BIGINT NOT NULL,
11+
-- The request's action field; part of the signed message for Uniqueness Proof requests.
12+
action BYTEA NOT NULL,
1213
-- RP ECDSA (secp256k1) signature over the message (alloy Signature, 65 bytes)
13-
signature BYTEA NOT NULL,
14+
signature BYTEA,
15+
-- Auxiliary data passed to a WIP101 signer contract's `verifyRpRequest`; only present
16+
-- (and only meaningful) when `signature` is NULL, i.e. the RP is WIP101-backed.
17+
wip101_data BYTEA,
1418
-- Record insertion timestamp (bookkeeping)
15-
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
16-
17-
-- A given nonce should be signed at most once per RP (replay protection)
18-
constraint uq_rp_signatures_rp_id_nonce unique (rp_id, nonce, epoch)
19+
recorded_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
1920
);

0 commit comments

Comments
 (0)