-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: info endpoint in evm prover (#140)
- Loading branch information
1 parent
434c625
commit 0070f43
Showing
8 changed files
with
228 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
[package] | ||
name = "evm-prover" | ||
version = "0.1.0" | ||
edition = { workspace = true } | ||
|
||
[dependencies] | ||
tonic.workspace = true | ||
prost.workspace = true | ||
tokio = { workspace = true, features = ["full"] } | ||
futures = "0.3" | ||
tonic-reflection.workspace = true | ||
tendermint-rpc = { workspace = true, features = ["http-client"] } | ||
ibc-client-tendermint-types.workspace = true | ||
reqwest.workspace = true | ||
alloy = { workspace = true, features = ["providers"] } | ||
alloy-provider = { workspace = true } | ||
ibc-eureka-solidity-types.workspace = true | ||
sp1-sdk = { workspace = true, features = ["network"] } | ||
sp1-ics07-tendermint-prover.workspace = true | ||
sp1-ics07-tendermint-utils.workspace = true | ||
ibc-core-commitment-types = { workspace = true } | ||
ibc-proto = { workspace = true } | ||
dotenv = "0.15.0" | ||
anyhow = "1.0.94" | ||
bincode = "1.3.3" | ||
serde = "1.0.217" | ||
prost-types = "0.13.4" | ||
|
||
[build-dependencies] | ||
tonic-build.workspace = true | ||
sp1-helper = "4.0.1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# EVM Prover | ||
|
||
The EVM Prover is a gRPC service that generates zero-knowledge proofs for EVM state transitions. It is designed to work with IBC (Inter-Blockchain Communication) and specifically implements proofs compatible with the ICS-07 Tendermint client specification. | ||
|
||
## Usage | ||
|
||
> [!WARNING] | ||
> This gRPC service is still under development and may not lack some features or not work as described. | ||
Before running this program, please follow the steps outlined in this [README.md](https://github.com/celestiaorg/celestia-zkevm-ibc-demo/blob/main/README.md). | ||
|
||
To then run the server (on port `:50052`): | ||
|
||
```shell | ||
cargo run | ||
``` | ||
|
||
The only endpoint currently working is: | ||
|
||
```shell | ||
grpcurl -plaintext localhost:50052 celestia.prover.v1.Prover/Info | ||
``` | ||
|
||
## Protobuf | ||
|
||
gRPC depends on proto defined types. These are stored in `proto/prover/v1` from the root directory. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
use sp1_helper::build_program_with_args; | ||
|
||
fn main() -> Result<(), Box<dyn std::error::Error>> { | ||
tonic_build::configure() | ||
.build_server(true) | ||
.file_descriptor_set_path("proto_descriptor.bin") | ||
.compile_protos( | ||
&[ | ||
"../../proto/prover/v1/prover.proto", | ||
"../../proto/ibc/lightclients/groth16/v1/groth16.proto", | ||
], | ||
&["../../proto"], | ||
)?; | ||
build_program_with_args("../blevm/blevm-mock", Default::default()); | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
use sp1_sdk::HashableKey; | ||
use std::env; | ||
use std::fs; | ||
use tonic::{transport::Server, Request, Response, Status}; | ||
|
||
// Import the generated proto rust code | ||
pub mod prover { | ||
tonic::include_proto!("celestia.prover.v1"); | ||
tonic::include_proto!("celestia.ibc.lightclients.groth16.v1"); | ||
} | ||
|
||
use prover::prover_server::{Prover, ProverServer}; | ||
use prover::{ | ||
InfoRequest, InfoResponse, ProveStateMembershipRequest, ProveStateMembershipResponse, | ||
ProveStateTransitionRequest, ProveStateTransitionResponse, | ||
}; | ||
use sp1_sdk::{include_elf, ProverClient, SP1ProvingKey}; | ||
|
||
// The ELF file for the Succinct RISC-V zkVM. | ||
const BLEVM_ELF: &[u8] = include_elf!("blevm-mock"); | ||
pub struct ProverService { | ||
sp1_proving_key: SP1ProvingKey, | ||
} | ||
|
||
impl ProverService { | ||
async fn new() -> Result<Self, Box<dyn std::error::Error>> { | ||
let sp1_prover = ProverClient::from_env(); | ||
let (pk, _) = sp1_prover.setup(&BLEVM_ELF); | ||
|
||
Ok(ProverService { | ||
sp1_proving_key: pk, | ||
}) | ||
} | ||
} | ||
|
||
#[tonic::async_trait] | ||
impl Prover for ProverService { | ||
async fn info(&self, _request: Request<InfoRequest>) -> Result<Response<InfoResponse>, Status> { | ||
let state_transition_verifier_key = self.sp1_proving_key.vk.bytes32(); | ||
// Empty string membership verifier key because currently membership proofs are not supported | ||
let state_membership_verifier_key = String::new(); | ||
let response = InfoResponse { | ||
state_membership_verifier_key, | ||
state_transition_verifier_key, | ||
}; | ||
|
||
Ok(Response::new(response)) | ||
} | ||
|
||
async fn prove_state_transition( | ||
&self, | ||
_request: Request<ProveStateTransitionRequest>, | ||
) -> Result<Response<ProveStateTransitionResponse>, Status> { | ||
Err(Status::unimplemented( | ||
"State transition proofs not yet implemented", | ||
)) | ||
} | ||
|
||
async fn prove_state_membership( | ||
&self, | ||
_request: Request<ProveStateMembershipRequest>, | ||
) -> Result<Response<ProveStateMembershipResponse>, Status> { | ||
Err(Status::unimplemented( | ||
"Membership proofs not yet implemented", | ||
)) | ||
} | ||
} | ||
|
||
#[tokio::main] | ||
async fn main() -> Result<(), Box<dyn std::error::Error>> { | ||
dotenv::dotenv().ok(); | ||
|
||
let addr = "[::1]:50052".parse()?; | ||
let prover = ProverService::new().await?; | ||
|
||
println!("BLEVM Prover Server listening on {}", addr); | ||
|
||
// Load the file descriptor set | ||
let file_descriptor_set = fs::read("proto_descriptor.bin")?; | ||
|
||
Server::builder() | ||
.add_service(ProverServer::new(prover)) | ||
.add_service( | ||
tonic_reflection::server::Builder::configure() | ||
.register_encoded_file_descriptor_set(&file_descriptor_set) | ||
.build_v1() | ||
.unwrap(), | ||
) | ||
.serve(addr) | ||
.await?; | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters