-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: hollow aggregated proofs #149
Draft
ninabarbakadze
wants to merge
9
commits into
main
Choose a base branch
from
nina/hollow-aggreagted-proofs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
8b77d7c
feat: hollow aggregate proof
ninabarbakadze 7e80b3f
feat: add logic for hollow aggregated proof
ninabarbakadze 4a65616
chore: builds
ninabarbakadze 5bec0ba
chore: read verification keys
ninabarbakadze 7bd2ad8
Merge remote-tracking branch 'origin' into nina/hollow-aggreagted-proofs
ninabarbakadze 707643c
chore: remove unused imports
ninabarbakadze d2035b6
fix: rename cargo toml
ninabarbakadze 7f9ea80
Rename cargo.toml to Cargo.toml
ninabarbakadze 28341a1
chore: revert ibc eureka bump
ninabarbakadze File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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,21 @@ | ||
[package] | ||
version = "0.1.0" | ||
name = "blevm-aggregator-mock" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
blevm-common = { path = "../common" } | ||
hex-literal = "0.4.1" | ||
alloy-sol-types = { workspace = true } | ||
sp1-zkvm = { workspace = true, features = ["verify"] } | ||
rsp-client-executor = {workspace=true} | ||
celestia-types = {workspace=true} | ||
nmt-rs = "*" | ||
reth-primitives = {workspace=true} | ||
tendermint = {workspace=true} | ||
tendermint-proto = {workspace=true} | ||
bincode = {workspace=true} | ||
hex = "0.4.3" | ||
sha2 = "0.10.8" | ||
serde = { version = "1.0", default-features = false, features = ["derive", "std"] } | ||
serde_cbor = "0.11.2" |
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,66 @@ | ||
use serde::{de::DeserializeOwned, Deserialize, Serialize}; | ||
|
||
/// A buffer of serializable/deserializable objects. | ||
#[derive(Debug, Clone, Serialize, Deserialize)] | ||
pub struct Buffer { | ||
pub data: Vec<u8>, | ||
#[serde(skip)] | ||
pub ptr: usize, | ||
} | ||
|
||
impl Buffer { | ||
pub fn new() -> Self { | ||
Self { | ||
data: Vec::new(), | ||
ptr: 0, | ||
} | ||
} | ||
|
||
pub fn from(data: &[u8]) -> Self { | ||
Self { | ||
data: data.to_vec(), | ||
ptr: 0, | ||
} | ||
} | ||
|
||
#[allow(dead_code)] | ||
/// Set the position ptr to the beginning of the buffer. | ||
pub fn head(&mut self) { | ||
self.ptr = 0; | ||
} | ||
|
||
/// Read the serializable object from the buffer. | ||
pub fn read<T: Serialize + DeserializeOwned>(&mut self) -> T { | ||
let result: T = | ||
bincode::deserialize(&self.data[self.ptr..]).expect("failed to deserialize"); | ||
let nb_bytes = bincode::serialized_size(&result).expect("failed to get serialized size"); | ||
self.ptr += nb_bytes as usize; | ||
result | ||
} | ||
|
||
#[allow(dead_code)] | ||
pub fn read_slice(&mut self, slice: &mut [u8]) { | ||
slice.copy_from_slice(&self.data[self.ptr..self.ptr + slice.len()]); | ||
self.ptr += slice.len(); | ||
} | ||
|
||
#[allow(dead_code)] | ||
/// Write the serializable object from the buffer. | ||
pub fn write<T: Serialize>(&mut self, data: &T) { | ||
let mut tmp = Vec::new(); | ||
bincode::serialize_into(&mut tmp, data).expect("serialization failed"); | ||
self.data.extend(tmp); | ||
} | ||
|
||
#[allow(dead_code)] | ||
/// Write the slice of bytes to the buffer. | ||
pub fn write_slice(&mut self, slice: &[u8]) { | ||
self.data.extend_from_slice(slice); | ||
} | ||
} | ||
|
||
impl Default for Buffer { | ||
fn default() -> Self { | ||
Self::new() | ||
} | ||
} |
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,49 @@ | ||
#![no_main] | ||
sp1_zkvm::entrypoint!(main); | ||
|
||
mod buffer; | ||
use blevm_common::{BlevmAggOutput, BlevmOutput}; | ||
use buffer::Buffer; | ||
|
||
pub fn main() { | ||
// Read the number of proofs | ||
let n: usize = sp1_zkvm::io::read(); | ||
|
||
if n < 2 { | ||
panic!("must provide at least 2 proofs"); | ||
} | ||
|
||
// Read all verification keys first | ||
let mut verification_keys: Vec<[u32; 8]> = Vec::with_capacity(n); | ||
for _ in 0..n { | ||
verification_keys.push(sp1_zkvm::io::read()); | ||
} | ||
|
||
// Read all public values | ||
let mut public_values: Vec<Vec<u8>> = Vec::with_capacity(n); | ||
for _ in 0..n { | ||
public_values.push(sp1_zkvm::io::read()); | ||
} | ||
|
||
// Parse all outputs and collect Celestia header hashes | ||
let mut outputs: Vec<BlevmOutput> = Vec::with_capacity(n); | ||
let mut celestia_header_hashes: Vec<[u8; 32]> = Vec::with_capacity(n); | ||
for values in &public_values { | ||
let mut buffer = Buffer::from(values); | ||
let output: BlevmOutput = buffer.read(); | ||
celestia_header_hashes.push(output.celestia_header_hash); | ||
outputs.push(output); | ||
} | ||
|
||
// Create aggregate output using first and last blocks | ||
let agg_output = BlevmAggOutput { | ||
newest_header_hash: outputs[n - 1].header_hash, | ||
oldest_header_hash: outputs[0].header_hash, | ||
celestia_header_hashes, | ||
newest_state_root: outputs[n - 1].state_root, | ||
newest_height: outputs[n - 1].height, | ||
}; | ||
|
||
// Commit the aggregate output | ||
sp1_zkvm::io::commit(&agg_output); | ||
} |
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 |
---|---|---|
|
@@ -5,10 +5,6 @@ | |
sp1_zkvm::entrypoint!(main); | ||
|
||
use blevm_common::BlevmOutput; | ||
use celestia_types::nmt::Namespace; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was seeing warnings for unused imports |
||
use celestia_types::nmt::NamespaceProof; | ||
use nmt_rs::{simple_merkle::proof::Proof, NamespacedHash, TmSha2Hasher}; | ||
use rsp_client_executor::io::ClientExecutorInput; | ||
|
||
pub fn main() { | ||
// This is a mock proof so it hard-codes all the output values. Note: these values were sourced | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, minor update to the inputs, we should have verification keys here as well:
celestia-zkevm-ibc-demo/provers/blevm/blevm-aggregator/src/main.rs
Line 21 in a284b1f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no worries! I'll wait for your PR to merge and then I can replicate it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be addressed! :)