Skip to content

Commit 411c5dc

Browse files
authored
switch journal bytes to be serialized more compact (#16)
* switch journal bytes to be serialized more compact * sort deps
1 parent 0c705b5 commit 411c5dc

File tree

8 files changed

+17
-11
lines changed

8 files changed

+17
-11
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

batch-guest/guest/Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

batch-guest/guest/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ light-client-guest = { path = "../../light-client-guest" }
1111
blobstream0-primitives = { path = "../../primitives" }
1212
alloy-sol-types = "0.7"
1313
alloy-primitives = "0.7"
14+
serde_bytes = "0.11"
1415

1516
[patch.crates-io]
1617
sha2 = { git = "https://github.com/risc0/RustCrypto-hashes", tag = "sha2-v0.10.8-risczero.0" }

batch-guest/guest/src/main.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,16 @@
1414

1515
use alloy_primitives::U256;
1616
use alloy_sol_types::SolValue;
17-
use light_client_guest::TM_LIGHT_CLIENT_ID;
1817
use blobstream0_primitives::{
1918
IBlobstream::{DataRootTuple, RangeCommitment},
2019
LightClientCommit, MerkleTree,
2120
};
21+
use light_client_guest::TM_LIGHT_CLIENT_ID;
2222
use risc0_zkvm::{guest::env, serde::from_slice};
23+
use serde_bytes::ByteBuf;
2324

24-
// TODO by default this will serialize poorly, optimize
25-
type JournalBytes = Vec<u8>;
25+
/// Alias to represent the bytes from the journals being recursively proven.
26+
type JournalBytes = ByteBuf;
2627

2728
fn main() {
2829
// Input the vector of proofs to batch.

contracts/artifacts/Blobstream0.json

Lines changed: 6 additions & 6 deletions
Large diffs are not rendered by default.

contracts/src/ImageID.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@
1919
pragma solidity ^0.8.20;
2020

2121
library ImageID {
22-
bytes32 public constant BATCH_GUEST_ID = bytes32(0xf75fe9a787f9010e6a60a35271fbf7901d0afd27faff3c3dfe708582afae9af2);
22+
bytes32 public constant BATCH_GUEST_ID = bytes32(0x54c5a4b5dcef9cc6febc08d59d9892b0b36be5fd15ef365c7a9c126a8864e494);
2323
}

core/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ ciborium = { workspace = true }
1313
light-client-guest = { path = "../light-client-guest" }
1414
risc0-ethereum-contracts = { git = "https://github.com/risc0/risc0-ethereum", tag = "v1.0.0" }
1515
risc0-zkvm = { version = "=1.0.1" }
16+
serde_bytes = "0.11"
1617
tendermint = { workspace = true }
1718
tendermint-light-client-verifier = { workspace = true }
1819
tendermint-rpc = { workspace = true, features = ["http-client"] }

core/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ use risc0_ethereum_contracts::groth16;
2424
use risc0_zkvm::{
2525
default_prover, is_dev_mode, sha::Digestible, ExecutorEnv, Prover, ProverOpts, Receipt,
2626
};
27+
use serde_bytes::ByteBuf;
2728
use std::ops::Range;
2829
use tendermint::{block::Height, node::Id, validator::Set};
2930
use tendermint_light_client_verifier::types::LightBlock;
@@ -124,7 +125,7 @@ pub async fn prove_block_range(client: &HttpClient, range: Range<u64>) -> anyhow
124125
light_block,
125126
} = prove_block(prover.as_ref(), client, &previous_block, height).await?;
126127

127-
batch_receipts.push(receipt.journal.bytes.clone());
128+
batch_receipts.push(ByteBuf::from(receipt.journal.bytes.clone()));
128129
batch_env_builder.add_assumption(receipt);
129130
previous_block = light_block;
130131
}

0 commit comments

Comments
 (0)