Skip to content

Commit 0d964cd

Browse files
lightsinglispc
andauthored
chore: upgrade revm, reth and sbv (#217)
* wip * add compact * set latest version * fix * fmt * update commitments --------- Co-authored-by: Zhuo Zhang <[email protected]>
1 parent 4510258 commit 0d964cd

File tree

9 files changed

+128
-66
lines changed

9 files changed

+128
-66
lines changed

Cargo.lock

Lines changed: 48 additions & 48 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#![cfg_attr(rustfmt, rustfmt_skip)]
22
//! Generated by crates/build-guest. DO NOT EDIT!
33
4-
pub const COMMIT: [u32; 8] = [1202988051, 1148264508, 1543561268, 1765749557, 1182656731, 396804521, 834486540, 1245597015];
4+
pub const COMMIT: [u32; 8] = [1649793006, 453918448, 700472053, 1708688727, 1956651385, 1452705656, 611459631, 1820274171];
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#![cfg_attr(rustfmt, rustfmt_skip)]
22
//! Generated by crates/build-guest. DO NOT EDIT!
33
4-
pub const COMMIT: [u32; 8] = [373288848, 1343506321, 1914796275, 1793072527, 65733832, 1916923301, 963694893, 639345462];
4+
pub const COMMIT: [u32; 8] = [2012351307, 1390891344, 349217220, 1980321794, 92671869, 1673212720, 1290433404, 1552447571];
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#![cfg_attr(rustfmt, rustfmt_skip)]
22
//! Generated by crates/build-guest. DO NOT EDIT!
33
4-
pub const COMMIT: [u32; 8] = [1957156571, 872843267, 744762733, 1147670747, 1109472993, 163434507, 1792562840, 1106326803];
4+
pub const COMMIT: [u32; 8] = [534218310, 1811212981, 1016259372, 652600422, 1802874675, 1341042917, 594473376, 479497145];

crates/integration/src/testers/chunk.rs

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
1+
use crate::{
2+
PartialProvingTask, ProverTester, guest_version, prove_verify, testdata_fork_directory,
3+
tester_execute, testers::PATH_TESTDATA, testing_hardfork, testing_version,
4+
utils::metadata_from_chunk_witnesses,
5+
};
6+
use openvm_sdk::StdIn;
17
use rayon::iter::{IntoParallelIterator, ParallelIterator};
28
use sbv_core::BlockWitness;
39
use sbv_primitives::{B256, types::consensus::TxL1Message};
410
use scroll_zkvm_prover::utils::vm::ExecutionResult;
511
use scroll_zkvm_prover::{Prover, utils::read_json};
12+
use scroll_zkvm_types::chunk::ChunkWitnessUpgradeCompact;
613
use scroll_zkvm_types::{
714
chunk::{ChunkInfo, ChunkWitness, LegacyChunkWitness, SecretKey},
815
proof::ProofEnum,
@@ -13,12 +20,6 @@ use std::{
1320
path::{Path, PathBuf},
1421
};
1522

16-
use crate::{
17-
PartialProvingTask, ProverTester, prove_verify, testdata_fork_directory, tester_execute,
18-
testers::PATH_TESTDATA, testing_hardfork, testing_version,
19-
utils::metadata_from_chunk_witnesses,
20-
};
21-
2223
/// Load a file <block_n>.json in the <PATH_BLOCK_WITNESS> directory.
2324
pub fn read_block_witness_from_testdata(block_n: usize) -> eyre::Result<BlockWitness> {
2425
read_block_witness(
@@ -67,6 +68,28 @@ impl PartialProvingTask for ChunkWitness {
6768
Ok(bytes.to_vec())
6869
}
6970

71+
fn write_guest_input(&self, stdin: &mut StdIn) -> eyre::Result<()>
72+
where
73+
Self: Sized,
74+
{
75+
let bytes: Vec<u8> = match guest_version().as_str() {
76+
"0.5.2" => self.legacy_rkyv_archive()?,
77+
"0.6.0-rc.6" => {
78+
let config = bincode::config::standard();
79+
bincode::serde::encode_to_vec(
80+
ChunkWitnessUpgradeCompact::from(self.clone()),
81+
config,
82+
)?
83+
}
84+
_ => {
85+
let config = bincode::config::standard();
86+
bincode::serde::encode_to_vec(self, config)?
87+
}
88+
};
89+
stdin.write_bytes(&bytes);
90+
Ok(())
91+
}
92+
7093
fn fork_name(&self) -> ForkName {
7194
ForkName::from(self.fork_name.as_str())
7295
}

crates/types/chunk/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ serde_json.workspace = true
3434

3535
[features]
3636
default = []
37-
host = ["scroll-compress-ratio", "alloy-primitives/tiny-keccak"]
37+
host = ["scroll-compress-info", "alloy-primitives/tiny-keccak"]
3838
scroll = [
3939
"sbv-core/scroll",
4040
"sbv-primitives/scroll-evm-types",
4141
"sbv-primitives/scroll-hardforks",
4242
"sbv-primitives/scroll-revm-types",
4343
"sbv-primitives/scroll-reth-evm-types"
4444
]
45-
scroll-compress-ratio = ["sbv-core/scroll-compress-ratio"]
45+
scroll-compress-info = ["sbv-core/scroll-compress-info"]

crates/types/chunk/src/scroll.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ mod execute;
55
pub use execute::execute;
66

77
mod witness;
8-
pub use witness::{ChunkWitness, LegacyChunkWitness, ValidiumInputs};
8+
pub use witness::{ChunkWitness, ChunkWitnessUpgradeCompact, LegacyChunkWitness, ValidiumInputs};

crates/types/chunk/src/scroll/execute.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ pub fn execute(witness: ChunkWitness) -> Result<ChunkInfo, String> {
4242
post_state_root,
4343
withdraw_root,
4444
..
45-
} = verifier::run(&witness.blocks, chain_spec, witness.compression_ratios)
45+
} = verifier::run(&witness.blocks, chain_spec, witness.compression_infos)
4646
.map_err(|e| format!("verify error: {e}"))?;
4747

4848
let blocks = manually_drop_on_zkvm!(blocks);

crates/types/chunk/src/scroll/witness.rs

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub struct ChunkWitness {
1919
/// The code version specify the chain spec
2020
pub fork_name: ForkName,
2121
/// The compression ratios for each block in the chunk.
22-
pub compression_ratios: Vec<Vec<U256>>,
22+
pub compression_infos: Vec<Vec<(U256, usize)>>,
2323
/// Validium encrypted txs and secret key if this is a validium chain.
2424
pub validium: Option<ValidiumInputs>,
2525
}
@@ -33,6 +33,23 @@ pub struct ValidiumInputs {
3333
pub secret_key: Box<[u8]>,
3434
}
3535

36+
/// The witness type accepted by last version chunk-circuit.
37+
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
38+
pub struct ChunkWitnessUpgradeCompact {
39+
/// Version byte as per [version][types_base::version].
40+
pub version: u8,
41+
/// The block witness for each block in the chunk.
42+
pub blocks: Vec<BlockWitness>,
43+
/// The on-chain rolling L1 message queue hash before enqueueing any L1 msg tx from the chunk.
44+
pub prev_msg_queue_hash: B256,
45+
/// The code version specify the chain spec
46+
pub fork_name: ForkName,
47+
/// The compression ratios for each block in the chunk.
48+
pub compression_ratios: Vec<Vec<U256>>,
49+
/// Validium encrypted txs and secret key if this is a validium chain.
50+
pub validium: Option<ValidiumInputs>,
51+
}
52+
3653
/// The witness type accepted by the chunk-circuit.
3754
#[derive(
3855
Clone,
@@ -129,17 +146,18 @@ impl ChunkWitness {
129146
.collect(),
130147
})
131148
.collect();
132-
let compression_ratios = blocks
149+
150+
let compression_infos = blocks
133151
.iter()
134-
.map(|block| block.compression_ratios())
152+
.map(|block| block.compression_infos())
135153
.collect();
136154

137155
Self {
138156
version,
139157
blocks,
140158
prev_msg_queue_hash,
141159
fork_name,
142-
compression_ratios,
160+
compression_infos,
143161
validium,
144162
}
145163
}
@@ -183,8 +201,29 @@ impl From<ChunkWitness> for LegacyChunkWitness {
183201
.collect(),
184202
prev_msg_queue_hash: value.prev_msg_queue_hash,
185203
fork_name: value.fork_name,
186-
compression_ratios: value.compression_ratios,
204+
compression_ratios: value
205+
.compression_infos
206+
.iter()
207+
.map(|compression_infos| compression_infos.iter().map(|v| v.0).collect())
208+
.collect(),
187209
state_commit_mode: StateCommitMode::Auto,
188210
}
189211
}
190212
}
213+
214+
impl From<ChunkWitness> for ChunkWitnessUpgradeCompact {
215+
fn from(value: ChunkWitness) -> Self {
216+
ChunkWitnessUpgradeCompact {
217+
version: value.version,
218+
blocks: value.blocks,
219+
prev_msg_queue_hash: value.prev_msg_queue_hash,
220+
fork_name: value.fork_name,
221+
compression_ratios: value
222+
.compression_infos
223+
.iter()
224+
.map(|compression_infos| compression_infos.iter().map(|v| v.0).collect())
225+
.collect(),
226+
validium: value.validium,
227+
}
228+
}
229+
}

0 commit comments

Comments
 (0)