Skip to content

Commit 15c872d

Browse files
committed
+ update openvm
+ fmt + trivial updates Signed-off-by: noelwei <[email protected]>
1 parent c0f773c commit 15c872d

File tree

7 files changed

+68
-49
lines changed

7 files changed

+68
-49
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ version = "4.5.8"
2323
[workspace.dependencies]
2424
scroll-zkvm-prover-euclid = { git = "https://github.com/scroll-tech/zkvm-prover", package = "scroll-zkvm-prover"}
2525

26-
openvm = { git = "https://github.com/openvm-org/openvm.git", rev = "3c35e9f", default-features = false }
27-
openvm-custom-insn = { git = "https://github.com/openvm-org/openvm.git", rev = "3c35e9f", default-features = false }
28-
openvm-rv32im-guest = { git = "https://github.com/openvm-org/openvm.git", rev = "3c35e9f", default-features = false }
26+
openvm = { git = "https://github.com/openvm-org/openvm.git", rev = "a0ae88f", default-features = false }
27+
openvm-custom-insn = { git = "https://github.com/openvm-org/openvm.git", rev = "a0ae88f", default-features = false }
28+
openvm-rv32im-guest = { git = "https://github.com/openvm-org/openvm.git", rev = "a0ae88f", default-features = false }
2929

3030
sbv-core = { git = "https://github.com/scroll-tech/stateless-block-verifier", branch = "zkvm/euclid-upgrade", features = ["scroll"] }
3131
sbv-primitives = { git = "https://github.com/scroll-tech/stateless-block-verifier", branch = "zkvm/euclid-upgrade", features = ["scroll"] }

common/types-rs/circuit/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ pub mod io;
22
pub use io::read_witnesses;
33

44
use alloy_primitives::B256;
5-
use types_base::public_inputs::PublicInputs;
6-
use types_agg::{ProofCarryingWitness, ProgramCommitment, AggregationInput, verify_proof};
75
use itertools::Itertools;
6+
use types_agg::{AggregationInput, ProgramCommitment, ProofCarryingWitness, verify_proof};
7+
8+
pub use types_base::public_inputs::PublicInputs;
89

910
/// Reveal the public-input values as openvm public values.
1011
pub fn reveal_pi_hash(pi_hash: B256) {
@@ -38,7 +39,6 @@ pub trait Circuit {
3839
}
3940
}
4041

41-
4242
/// Circuit that additional aggregates proofs from other [`Circuits`][Circuit].
4343
pub trait AggCircuit: Circuit
4444
where
@@ -93,4 +93,4 @@ where
9393
);
9494
}
9595
}
96-
}
96+
}

common/types-rs/src/lib.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// re-export for a compatible interface with old circuit/types for prover
2+
3+
pub mod bundle {
4+
pub use types_base::public_inputs::bundle::{BundleInfo, BundleInfoV1, BundleInfoV2};
5+
pub use types_bundle::*;
6+
}
7+
8+
pub mod batch {
9+
pub use types_base::public_inputs::batch::{ArchivedBatchInfo, BatchInfo, VersionedBatchInfo};
10+
pub use types_batch::*;
11+
}
12+
13+
pub mod chunk {
14+
pub use types_base::public_inputs::chunk::{
15+
ArchivedChunkInfo, BlockContextV2, ChunkInfo, SIZE_BLOCK_CTX, VersionedChunkInfo,
16+
};
17+
pub use types_chunk::*;
18+
}
19+
20+
pub use types_agg;
21+
pub use types_base::{public_inputs, utils};

zkvm-prover/src/prover.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
use crate::zk_circuits_handler::{
2-
euclid::EuclidHandler, euclidV2::EuclidV2Handler, CircuitsHandler,
3-
RequestPreHandler,
4-
RpcConfig,
2+
euclid::EuclidHandler, euclidV2::EuclidV2Handler, CircuitsHandler, RequestPreHandler, RpcConfig,
53
};
64
use anyhow::{anyhow, Result};
75
use async_trait::async_trait;
@@ -153,7 +151,8 @@ impl LocalProver {
153151
handler: Arc<dyn CircuitsHandler>,
154152
) -> Result<ProveResponse> {
155153
if self.pre_handler.is_none() {
156-
self.pre_handler.replace(RequestPreHandler::create(&self.config.rpc_config)?);
154+
self.pre_handler
155+
.replace(RequestPreHandler::create(&self.config.rpc_config)?);
157156
}
158157

159158
self.next_task_id += 1;

zkvm-prover/src/types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use serde::{Deserialize, Deserializer, Serialize, Serializer};
21
use alloy::primitives::B256;
2+
use serde::{Deserialize, Deserializer, Serialize, Serializer};
33

44
#[derive(Serialize, Deserialize, Default)]
55
pub struct Task {

zkvm-prover/src/zk_circuits_handler.rs

Lines changed: 32 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,12 @@ pub trait CircuitsHandler: Sync + Send {
1313
async fn get_proof_data(&self, prove_request: ProveRequest) -> Result<String>;
1414
}
1515

16-
1716
use alloy::{
18-
providers::{ProviderBuilder, RootProvider, Provider},
17+
providers::{Provider, ProviderBuilder, RootProvider},
1918
rpc::client::ClientBuilder,
2019
transports::layers::RetryBackoffLayer,
2120
};
22-
use sbv_primitives::{ChainId, types::Network};
21+
use sbv_primitives::{types::Network, ChainId};
2322
use serde::{Deserialize, Serialize};
2423

2524
#[derive(Serialize, Deserialize, Clone)]
@@ -35,7 +34,6 @@ pub struct RpcConfig {
3534
pub cups: u64,
3635
}
3736

38-
3937
pub struct RequestPreHandler {
4038
provider: RootProvider<Network>,
4139
}
@@ -44,47 +42,40 @@ impl RequestPreHandler {
4442
pub fn create(config: &RpcConfig) -> Result<Self> {
4543
let rpc = url::Url::parse(&config.rpc_url)?;
4644
tracing::info!("Using RPC: {}", rpc);
47-
let retry_layer = RetryBackoffLayer::new(
48-
config.max_retry,
49-
config.backoff,
50-
config.cups,
51-
);
52-
let client = ClientBuilder::default()
53-
.layer(retry_layer)
54-
.http(rpc);
45+
let retry_layer = RetryBackoffLayer::new(config.max_retry, config.backoff, config.cups);
46+
let client = ClientBuilder::default().layer(retry_layer).http(rpc);
5547

5648
Ok(Self {
57-
provider: ProviderBuilder::<_, _, Network>::default().on_client(client)
49+
provider: ProviderBuilder::<_, _, Network>::default().on_client(client),
5850
})
59-
6051
}
6152

6253
async fn on_chunk_request(&self, input: String) -> Result<String> {
63-
use sbv_utils::{rpc::ProviderExt, witness::WitnessBuilder};
64-
use alloy::network::primitives::BlockTransactionsKind;
6554
use crate::types::ChunkTaskDetail;
55+
use alloy::network::primitives::BlockTransactionsKind;
56+
use sbv_utils::{rpc::ProviderExt, witness::WitnessBuilder};
6657
use scroll_zkvm_prover_euclid::task::chunk::ChunkProvingTask;
6758

68-
let chunk_task : ChunkTaskDetail = serde_json::from_str(&input)?;
59+
let chunk_task: ChunkTaskDetail = serde_json::from_str(&input)?;
6960

7061
let chain_id = self.provider.get_chain_id().await?;
7162

72-
// we need block number but only get hashes, which cause much extra cost for query the block number from hash
73-
// according to https://github.com/scroll-tech/scroll/blob/932be72b88ba2ebb6f9457e8480ee08d612d35a7/coordinator/internal/orm/l2_block.go#L53
63+
// we need block number but only get hashes, which cause much extra cost for query the block
64+
// number from hash according to https://github.com/scroll-tech/scroll/blob/932be72b88ba2ebb6f9457e8480ee08d612d35a7/coordinator/internal/orm/l2_block.go#L53
7465
// the hashes is ordered by ascending in block number so a heuristic way is applied
7566

7667
let mut block_witnesses = Vec::new();
7768

7869
for block_hash in chunk_task.block_hashes {
79-
// grep `dump_block_witness` in sbv here,
70+
// grep `dump_block_witness` in sbv here,
8071
// TODO: we do not need to do that
8172
// if we have block number or `dump_block_witness` support block hashes
82-
let block = self.provider.get_block_by_hash(
83-
block_hash,
84-
BlockTransactionsKind::Full,
85-
).await?
86-
.ok_or_else(|| anyhow::anyhow!("Block not found"))?;
87-
73+
let block = self
74+
.provider
75+
.get_block_by_hash(block_hash, BlockTransactionsKind::Full)
76+
.await?
77+
.ok_or_else(|| anyhow::anyhow!("Block not found"))?;
78+
8879
let number = block.header.number;
8980

9081
let builder = WitnessBuilder::new()
@@ -93,10 +84,20 @@ impl RequestPreHandler {
9384
.execution_witness(self.provider.debug_execution_witness(number.into()).await?);
9485

9586
let builder = builder
96-
.state_root(self.provider.scroll_disk_root(number.into()).await?.disk_root)
87+
.state_root(
88+
self.provider
89+
.scroll_disk_root(number.into())
90+
.await?
91+
.disk_root,
92+
)
9793
.unwrap()
98-
.prev_state_root(self.provider.scroll_disk_root((number - 1).into()).await?.disk_root);
99-
94+
.prev_state_root(
95+
self.provider
96+
.scroll_disk_root((number - 1).into())
97+
.await?
98+
.disk_root,
99+
);
100+
100101
block_witnesses.push(builder.build()?);
101102
}
102103

@@ -108,17 +109,15 @@ impl RequestPreHandler {
108109
//self.provider.dump_block_witness(number)
109110

110111
Ok(serde_json::to_string(&input_repack)?)
111-
112112
}
113113

114114
pub async fn on_request(&self, mut prove_request: ProveRequest) -> Result<ProveRequest> {
115-
116115
match prove_request.proof_type {
117116
ProofType::Chunk => {
118117
prove_request.input = self.on_chunk_request(prove_request.input).await?;
119118
}
120-
_ => ()
119+
_ => (),
121120
}
122121
Ok(prove_request)
123122
}
124-
}
123+
}

0 commit comments

Comments
 (0)