Skip to content

Commit

Permalink
zkvm: Protobuf based client/server IPC (risc0#814)
Browse files Browse the repository at this point in the history
This introduces an API based on `protobuf` messages passed over a TCP
connection. The server is launched by the client as a sub-process. The
child process intended to be `r0vm` or other compatible binary that
executes for the duration of a request and then terminates. In this
scenario, the client is the one that binds to the TCP socket on port 0
to allocate a port. This port is passed to `r0vm --port <PORT>` and the
'server' then connects back to the listener. This ensures that ports are
unique for each caller in a race-free manner.

In this PR, the client/server messages are defined, while the core data
types (receipts, segments, etc) are specified as bytes. This means
there's an inner encoding that should be largely opaque to clients.
There are instances where clients will want to deserialize these bytes
(like a `Receipt`). Currently this uses `bincode` but the intention is
to move to `protobuf` to allow for a better versioning story. Versioning
will be fleshed out in a future PR.

Therefore there will be two levels of protobufs, one for the API, and
another for the core data types. This design follows best practices:
https://protobuf.dev/programming-guides/api/#use-different-messages

TODO:
* more tests especially around I/O
* pluggable implementation for lift & join
  • Loading branch information
flaub authored Sep 5, 2023
1 parent 71fb936 commit 8e6a783
Show file tree
Hide file tree
Showing 25 changed files with 2,155 additions and 282 deletions.
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@
"risc0/zkvm/methods/guest/Cargo.toml",
"risc0/zkvm/methods/std/Cargo.toml"
]
}
}
104 changes: 103 additions & 1 deletion bonsai/examples/governance/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

127 changes: 127 additions & 0 deletions examples/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions risc0/cargo-risczero/src/commands/build_guest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,16 +212,16 @@ mod test {
fn test_reproducible_methods_guest() {
let tester = Tester::new("risc0/zkvm/methods/guest/Cargo.toml");
tester.compare_image_id(
"risc0_zkvm_methods_guest/hello_commit",
"eb12f9b97d8759327f651afeb09ae9a5713e7dbc428284d453b8cf56e8dadd5a",
"risc0_zkvm_methods_guest/multi_test",
"851ad4ed2ade10e8f330737e36107f338f276e7036f992dd9da5010ff7fb6fea",
);
tester.compare_image_id(
"risc0_zkvm_methods_guest/multi_test",
"44750696d3d67caaaf9b1ca9441d1ffe5d5b9370d6945ce56b1972c10e42da59",
"risc0_zkvm_methods_guest/hello_commit",
"46c239f8f36b1e6dd239c0586b662fc1ea71cd593fe43a57903b974a69694b22",
);
tester.compare_image_id(
"risc0_zkvm_methods_guest/slice_io",
"3f2ad1a2d500ab4ab927eebe241d872d3f598065b8987b182410cf01f350f74c",
"78d183c563f1ef6dc230c2dc504e29238ad284b175a5d1f6389b0e2649e0bd7b",
);
}
}
Loading

0 comments on commit 8e6a783

Please sign in to comment.