Skip to content

Commit 46edd49

Browse files
schoppmpcopybara-github
authored andcommitted
Add range tracking to server accumulator
PiperOrigin-RevId: 853836142
1 parent 7eaf73a commit 46edd49

File tree

7 files changed

+640
-44
lines changed

7 files changed

+640
-44
lines changed

MODULE.bazel

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,5 +107,9 @@ crate.spec(
107107
package = "sha3",
108108
version = "0.10.8",
109109
)
110+
crate.spec(
111+
package = "rangemap",
112+
version = "1.7.1",
113+
)
110114
crate.from_specs()
111115
use_repo(crate, crate_index = "crates")

willow/proto/willow/server_accumulator.proto

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,22 @@ option java_outer_classname = "ServerAccumulatorProto";
2424

2525
message ServerAccumulatorState {
2626
ServerStateProto server_state = 1;
27-
VerifierStateProto verifier_state = 2;
2827
AggregationConfigProto aggregation_config = 3;
28+
// We have one verifier state per range of nonces processed by this
29+
// accumulator. States gat merged when adjacent ranges are processed.
30+
repeated VerifierStateProto verifier_states = 2;
31+
// The ranges of nonces processed by this accumulator. In the same order as
32+
// the corresponding verifier states.
33+
repeated NonceRange processed_nonce_ranges = 4;
2934
}
3035

31-
message ClientMessageList {
36+
message ClientMessageRange {
3237
repeated ClientMessage client_messages = 1;
38+
NonceRange nonce_range = 2;
39+
}
40+
41+
// A range of nonces. Used to group client messages by nonce.
42+
message NonceRange {
43+
bytes start = 1; // Inclusive.
44+
bytes end = 2; // Exclusive.
3345
}

willow/src/api/BUILD

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,17 @@ cc_test(
6969
name = "server_accumulator_test",
7070
srcs = ["server_accumulator_test.cc"],
7171
deps = [
72+
":client_cc",
7273
":server_accumulator",
7374
":server_accumulator_cxx", # fixdeps: keep
7475
"@googletest//:gtest_main",
7576
"@abseil-cpp//absl/status",
7677
"@abseil-cpp//absl/status:statusor",
78+
"//shell_wrapper:status_matchers",
7779
"//willow/proto/willow:aggregation_config_cc_proto",
7880
"//willow/proto/willow:server_accumulator_cc_proto",
81+
"//willow/src/input_encoding:codec",
82+
"//willow/src/testing_utils:shell_testing_decryptor_cc",
7983
],
8084
)
8185

@@ -94,6 +98,7 @@ rust_library(
9498
":aggregation_config",
9599
"@protobuf//rust:protobuf",
96100
"@cxx.rs//:cxx",
101+
"@crate_index//:rangemap",
97102
"//shell_wrapper:status",
98103
"//willow/proto/willow:aggregation_config_rust_proto",
99104
"//willow/proto/willow:server_accumulator_rust_proto",

willow/src/api/server_accumulator.cc

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,17 @@ WillowShellServerAccumulator::CreateFromSerializedState(
5959
}
6060

6161
absl::Status WillowShellServerAccumulator::ProcessClientMessages(
62-
willow::ClientMessageList client_messages) {
62+
willow::ClientMessageRange client_messages) {
63+
auto serialized_client_messages = client_messages.SerializeAsString();
6364
client_messages.Clear();
65+
return ProcessClientMessages(std::move(serialized_client_messages));
66+
}
67+
68+
absl::Status WillowShellServerAccumulator::ProcessClientMessages(
69+
std::string serialized_client_messages) {
6470
std::unique_ptr<std::string> status_message;
6571
int status_code = accumulator_->ProcessClientMessages(
66-
std::make_unique<std::string>(client_messages.SerializeAsString()),
72+
std::make_unique<std::string>(std::move(serialized_client_messages)),
6773
&status_message);
6874
if (status_code != 0) {
6975
return absl::Status(absl::StatusCode(status_code), *status_message);

willow/src/api/server_accumulator.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,12 @@ class WillowShellServerAccumulator {
4848

4949
// Processes a list of client messages. If an invalid message is encountered,
5050
// an error is logged and processing continues.
51-
absl::Status ProcessClientMessages(willow::ClientMessageList client_messages);
51+
absl::Status ProcessClientMessages(
52+
willow::ClientMessageRange client_messages);
53+
54+
// Processes a list of client messages, given as a serialized
55+
// ClientMessageList proto.
56+
absl::Status ProcessClientMessages(std::string serialized_client_messages);
5257

5358
// Merges the state of `other` into the current accumulator.
5459
absl::Status Merge(std::unique_ptr<WillowShellServerAccumulator> other);

0 commit comments

Comments
 (0)