Skip to content

Commit df70b82

Browse files
authored
feat!: aggregate v2 receipts into v2 rav (#274)
* refactor!: add v2 proto refactor!: move grpc structs to v1 refactor: create shared uint128 proto Signed-off-by: Gustavo Inacio <[email protected]> * chore: add justfile Signed-off-by: Gustavo Inacio <[email protected]> * feat: add tap v2 aggregator Signed-off-by: Gustavo Inacio <[email protected]> * test: add test to verify if both are working Signed-off-by: Gustavo Inacio <[email protected]> --------- Signed-off-by: Gustavo Inacio <[email protected]>
1 parent dbae001 commit df70b82

File tree

13 files changed

+1305
-470
lines changed

13 files changed

+1305
-470
lines changed

justfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
fmt:
2+
cargo +nightly fmt
3+
4+
clippy:
5+
cargo +nightly clippy --all-targets --all-features
6+
7+
build:
8+
cargo build
9+
10+
test:
11+
cargo nextest run

tap_aggregator/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ tokio.workspace = true
3939
tonic = { version = "0.12.3", features = ["transport", "zstd"] }
4040
tower = { version = "0.5.2", features = ["util", "steer"] }
4141
tracing-subscriber = "0.3.17"
42-
tap_graph = { version = "0.2.0", path = "../tap_graph" }
42+
tap_graph = { version = "0.2.0", path = "../tap_graph", features = ["v2"] }
4343

4444
[build-dependencies]
4545
tonic-build = "0.12.3"

tap_aggregator/build.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
66
let out_dir = std::env::var("OUT_DIR").expect("OUT_DIR not set by Cargo");
77
println!("OUT_DIR: {}", out_dir); // This should print the output directory
88

9-
tonic_build::compile_protos("./proto/tap_aggregator.proto")?;
9+
tonic_build::configure().compile_protos(
10+
&[
11+
"proto/uint128.proto",
12+
"proto/tap_aggregator.proto",
13+
"proto/v2.proto",
14+
],
15+
&["proto"],
16+
)?;
17+
1018
Ok(())
1119
}

tap_aggregator/proto/tap_aggregator.proto

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44
syntax = "proto3";
55
package tap_aggregator.v1;
66

7+
import "uint128.proto";
8+
79
message Receipt {
810
bytes allocation_id = 1;
911
uint64 timestamp_ns = 2;
1012
uint64 nonce = 3;
11-
Uint128 value = 4;
13+
grpc.uint128.Uint128 value = 4;
1214
}
1315

1416
message SignedReceipt {
@@ -19,7 +21,7 @@ message SignedReceipt {
1921
message ReceiptAggregateVoucher {
2022
bytes allocation_id = 1;
2123
uint64 timestamp_ns = 2;
22-
Uint128 value_aggregate = 3;
24+
grpc.uint128.Uint128 value_aggregate = 3;
2325
}
2426

2527
message SignedRav {
@@ -39,10 +41,3 @@ message RavResponse {
3941
service TapAggregator {
4042
rpc AggregateReceipts(RavRequest) returns (RavResponse);
4143
}
42-
43-
message Uint128 {
44-
// Highest 64 bits of a 128 bit number.
45-
uint64 high = 1;
46-
// Lowest 64 bits of a 128 bit number.
47-
uint64 low = 2;
48-
}

tap_aggregator/proto/uint128.proto

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Copyright 2023-, Semiotic AI, Inc.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
syntax = "proto3";
5+
package grpc.uint128;
6+
7+
message Uint128 {
8+
// Highest 64 bits of a 128 bit number.
9+
uint64 high = 1;
10+
// Lowest 64 bits of a 128 bit number.
11+
uint64 low = 2;
12+
}

tap_aggregator/proto/v2.proto

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// Copyright 2023-, Semiotic AI, Inc.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
syntax = "proto3";
5+
package tap_aggregator.v2;
6+
7+
import "uint128.proto";
8+
9+
message Receipt {
10+
bytes allocation_id = 1;
11+
bytes payer = 2;
12+
bytes data_service = 3;
13+
bytes service_provider = 4;
14+
uint64 timestamp_ns = 5;
15+
uint64 nonce = 6;
16+
grpc.uint128.Uint128 value = 7;
17+
}
18+
19+
message SignedReceipt {
20+
Receipt message = 1;
21+
bytes signature = 2;
22+
}
23+
24+
message ReceiptAggregateVoucher {
25+
bytes allocation_id = 1;
26+
bytes payer = 2;
27+
bytes data_service = 3;
28+
bytes service_provider = 4;
29+
uint64 timestamp_ns = 5;
30+
grpc.uint128.Uint128 value_aggregate = 6;
31+
bytes metadata = 7;
32+
}
33+
34+
message SignedRav {
35+
ReceiptAggregateVoucher message = 1;
36+
bytes signature = 2;
37+
}
38+
39+
message RavRequest {
40+
repeated SignedReceipt receipts = 1;
41+
optional SignedRav previous_rav = 2;
42+
}
43+
44+
message RavResponse {
45+
SignedRav rav = 1;
46+
}
47+
48+
service TapAggregator {
49+
rpc AggregateReceipts(RavRequest) returns (RavResponse);
50+
}
51+

0 commit comments

Comments
 (0)