Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,854 changes: 1,795 additions & 1,059 deletions Cargo.lock

Large diffs are not rendered by default.

44 changes: 23 additions & 21 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,23 @@ repository = "https://github.com/scroll-tech/scroll"
version = "4.5.8"

[workspace.dependencies]
scroll-zkvm-prover-euclid = { git = "https://github.com/scroll-tech/zkvm-prover", rev = "6078604", package = "scroll-zkvm-prover" }
scroll-zkvm-verifier-euclid = { git = "https://github.com/scroll-tech/zkvm-prover", rev = "6078604", package = "scroll-zkvm-verifier" }
scroll-zkvm-types = { git = "https://github.com/scroll-tech/zkvm-prover", rev = "6078604" }
scroll-zkvm-prover-euclid = { git = "https://github.com/scroll-tech/zkvm-prover", rev = "2962428", package = "scroll-zkvm-prover" }
scroll-zkvm-verifier-euclid = { git = "https://github.com/scroll-tech/zkvm-prover", rev = "2962428", package = "scroll-zkvm-verifier" }
scroll-zkvm-types = { git = "https://github.com/scroll-tech/zkvm-prover", rev = "2962428" }

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

metrics = "0.23.0"
metrics-util = "0.17"
metrics-tracing-context = "0.16.0"

anyhow = "1.0"
alloy = { version = "0.11", default-features = false }
alloy-primitives = { version = "0.8", default-features = false }
alloy = { version = "1", default-features = false }
alloy-primitives = { version = "1.2", default-features = false, features = ["tiny-keccak"] }
# also use this to trigger "serde" feature for primitives
alloy-serde = { version = "0.8", default-features = false }
alloy-serde = { version = "1", default-features = false }

rkyv = "0.8"
serde = { version = "1", default-features = false, features = ["derive"] }
serde_json = { version = "1.0" }
serde_derive = "1.0"
Expand All @@ -43,22 +42,25 @@ itertools = "0.14"
tiny-keccak = "2.0"
tracing = "0.1"
eyre = "0.6"
bincode_v1 = { version = "1.3", package = "bincode"}
snark-verifier-sdk = { version = "0.2.0", default-features = false, features = [
"loader_halo2",
"halo2-axiom",
"display",
] }
once_cell = "1.20"
base64 = "0.22"

#TODO: upgrade when Feynman
vm-zstd = { git = "https://github.com/scroll-tech/rust-zstd-decompressor.git", tag = "v0.1.1" }

[patch.crates-io]
alloy-primitives = { git = "https://github.com/scroll-tech/alloy-core", branch = "v0.8.18-euclid-upgrade" }
ruint = { git = "https://github.com/scroll-tech/uint.git", branch = "v1.12.3" }
tiny-keccak = { git = "https://github.com/scroll-tech/tiny-keccak", branch = "scroll-patch-v2.0.2-euclid-upgrade" }
revm = { git = "https://github.com/scroll-tech/revm", branch = "feat/reth-v74" }
revm-bytecode = { git = "https://github.com/scroll-tech/revm", branch = "feat/reth-v74" }
revm-context = { git = "https://github.com/scroll-tech/revm", branch = "feat/reth-v74" }
revm-context-interface = { git = "https://github.com/scroll-tech/revm", branch = "feat/reth-v74" }
revm-database = { git = "https://github.com/scroll-tech/revm", branch = "feat/reth-v74" }
revm-database-interface = { git = "https://github.com/scroll-tech/revm", branch = "feat/reth-v74" }
revm-handler = { git = "https://github.com/scroll-tech/revm", branch = "feat/reth-v74" }
revm-inspector = { git = "https://github.com/scroll-tech/revm", branch = "feat/reth-v74" }
revm-interpreter = { git = "https://github.com/scroll-tech/revm", branch = "feat/reth-v74" }
revm-precompile = { git = "https://github.com/scroll-tech/revm", branch = "feat/reth-v74" }
revm-primitives = { git = "https://github.com/scroll-tech/revm", branch = "feat/reth-v74" }
revm-state = { git = "https://github.com/scroll-tech/revm", branch = "feat/reth-v74" }

ruint = { git = "https://github.com/scroll-tech/uint.git", branch = "v1.15.0" }
alloy-primitives = { git = "https://github.com/scroll-tech/alloy-core", branch = "v1.2.0" }

[profile.maxperf]
inherits = "release"
Expand Down
17 changes: 4 additions & 13 deletions coordinator/cmd/tool/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func verify(cCtx *cli.Context) error {
proofType = cCtx.Args().Get(1)
proofPath = cCtx.Args().Get(2)
}
log.Info("verify proof in: ", proofPath, "type", proofType, "forkName", forkName)
log.Info("verify proof", "in", proofPath, "type", proofType, "forkName", forkName)

// Load the content of the proof file
data, err := os.ReadFile(filepath.Clean(proofPath))
Expand All @@ -53,7 +53,7 @@ func verify(cCtx *cli.Context) error {
return fmt.Errorf("no vk loaded for fork %s", forkName)
}
if len(proof.Vk) != 0 {
if bytes.Equal(proof.Vk, vk) {
if !bytes.Equal(proof.Vk, vk) {
return fmt.Errorf("unmatch vk with expected: expected %s, get %s",
base64.StdEncoding.EncodeToString(vk),
base64.StdEncoding.EncodeToString(proof.Vk),
Expand All @@ -74,7 +74,7 @@ func verify(cCtx *cli.Context) error {
return fmt.Errorf("no vk loaded for fork %s", forkName)
}
if len(proof.Vk) != 0 {
if bytes.Equal(proof.Vk, vk) {
if !bytes.Equal(proof.Vk, vk) {
return fmt.Errorf("unmatch vk with expected: expected %s, get %s",
base64.StdEncoding.EncodeToString(vk),
base64.StdEncoding.EncodeToString(proof.Vk),
Expand All @@ -94,16 +94,7 @@ func verify(cCtx *cli.Context) error {
if !ok {
return fmt.Errorf("no vk loaded for fork %s", forkName)
}
if len(proof.Vk) != 0 {
if bytes.Equal(proof.Vk, vk) {
return fmt.Errorf("unmatch vk with expected: expected %s, get %s",
base64.StdEncoding.EncodeToString(vk),
base64.StdEncoding.EncodeToString(proof.Vk),
)
}
} else {
proof.Vk = vk
}
proof.Vk = vk

ret, err = vf.VerifyBundleProof(proof, forkName)
default:
Expand Down
4 changes: 4 additions & 0 deletions coordinator/internal/logic/libzkp/lib.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ import (
"scroll-tech/common/types/message"
)

func init() {
C.init_tracing()
}

// Helper function to convert Go string to C string and handle cleanup
func goToCString(s string) *C.char {
return C.CString(s)
Expand Down
3 changes: 3 additions & 0 deletions coordinator/internal/logic/libzkp/libzkp.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

#include <stddef.h> // For size_t

// Init log tracing
void init_tracing();

// Initialize the verifier with configuration
void init_verifier(char* config);

Expand Down
2 changes: 1 addition & 1 deletion coordinator/internal/logic/provertask/batch_prover_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ func (bp *BatchProverTask) Assign(ctx *gin.Context, getTaskParameter *coordinato
taskMsg, metadata, err = bp.applyUniversal(taskMsg)
if err != nil {
bp.recoverActiveAttempts(ctx, batchTask)
log.Error("Generate universal prover task failure", "task_id", batchTask.Hash, "type", "batch")
log.Error("Generate universal prover task failure", "task_id", batchTask.Hash, "type", "batch", "err", err)
return nil, ErrCoordinatorInternalFailure
}
proverTask.Metadata = metadata
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ func (bp *BundleProverTask) Assign(ctx *gin.Context, getTaskParameter *coordinat
taskMsg, metadata, err = bp.applyUniversal(taskMsg)
if err != nil {
bp.recoverActiveAttempts(ctx, bundleTask)
log.Error("Generate universal prover task failure", "task_id", bundleTask.Hash, "type", "bundle")
log.Error("Generate universal prover task failure", "task_id", bundleTask.Hash, "type", "bundle", "err", err)
return nil, ErrCoordinatorInternalFailure
}
// bundle proof require snark
Expand Down
2 changes: 1 addition & 1 deletion coordinator/internal/logic/provertask/chunk_prover_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ func (cp *ChunkProverTask) Assign(ctx *gin.Context, getTaskParameter *coordinato
taskMsg, metadata, err = cp.applyUniversal(taskMsg)
if err != nil {
cp.recoverActiveAttempts(ctx, chunkTask)
log.Error("Generate universal prover task failure", "task_id", chunkTask.Hash, "type", "chunk")
log.Error("Generate universal prover task failure", "task_id", chunkTask.Hash, "type", "chunk", "err", err)
return nil, ErrCoordinatorInternalFailure
}
proverTask.Metadata = metadata
Expand Down
13 changes: 0 additions & 13 deletions coordinator/internal/logic/verifier/verifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,19 +117,6 @@ func (v *Verifier) VerifyBundleProof(proof *message.OpenVMBundleProof, forkName
return libzkp.VerifyBundleProof(string(buf), forkName), nil
}

// func (v *Verifier) ReadVK(filePat string) (string, error) {

// f, err := os.Open(filepath.Clean(filePat))
// if err != nil {
// return "", err
// }
// byt, err := io.ReadAll(f)
// if err != nil {
// return "", err
// }
// return base64.StdEncoding.EncodeToString(byt), nil
// }

func (v *Verifier) loadOpenVMVks(cfg config.AssetConfig) error {

vkFileName := cfg.Vkfile
Expand Down
2 changes: 1 addition & 1 deletion coordinator/internal/orm/prover_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ func (o *ProverTask) UpdateProverTaskProvingStatusAndFailureType(ctx context.Con
return nil
}

// UpdateProverTaskProvingStatusAndFailureType updates the proving_status of a specific ProverTask record.
// UpdateProverTaskAssignedTime updates the assigned_at time of a specific ProverTask record.
func (o *ProverTask) UpdateProverTaskAssignedTime(ctx context.Context, uuid uuid.UUID, t time.Time, dbTX ...*gorm.DB) error {
db := o.db
if len(dbTX) > 0 && dbTX[0] != nil {
Expand Down
6 changes: 3 additions & 3 deletions crates/l2geth/src/rpc_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ impl RpcClientCore {
let client = ClientBuilder::default().layer(retry_layer).http(rpc);

Ok(Self {
provider: ProviderBuilder::<_, _, Network>::default().on_client(client),
provider: ProviderBuilder::<_, _, Network>::default().connect_client(client),
rt,
})
}
Expand All @@ -100,13 +100,13 @@ impl ChunkInterpreter for RpcClient<'_> {
block_hash: sbv_primitives::B256,
prev_witness: Option<&sbv_primitives::types::BlockWitness>,
) -> Result<sbv_primitives::types::BlockWitness> {
use alloy::network::primitives::BlockTransactionsKind;
use sbv_utils::{rpc::ProviderExt, witness::WitnessBuilder};

let chain_id = provider.get_chain_id().await?;

let block = provider
.get_block_by_hash(block_hash, BlockTransactionsKind::Full)
.get_block_by_hash(block_hash)
.full()
.await?
.ok_or_else(|| eyre::eyre!("Block not found"))?;

Expand Down
3 changes: 2 additions & 1 deletion crates/libzkp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ edition.workspace = true
scroll-zkvm-types.workspace = true
scroll-zkvm-verifier-euclid.workspace = true

alloy-primitives.workspace = true #depress the effect of "native-keccak"
sbv-primitives.workspace = true
base64.workspace = true
serde.workspace = true
Expand All @@ -19,5 +20,5 @@ eyre.workspace = true
git-version = "0.3.5"
serde_stacker = "0.1"
regex = "1.11"
c-kzg = { version = "1.0", features = ["serde"] }
c-kzg = { version = "2.0", features = ["serde"] }

15 changes: 5 additions & 10 deletions crates/libzkp/src/proofs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,7 @@ impl<Metadata: ProofMetadata> PersistableProof for WrappedProof<Metadata> {
mod tests {
use base64::{prelude::BASE64_STANDARD, Engine};
use sbv_primitives::B256;
use scroll_zkvm_types::{
bundle::{BundleInfo, BundleInfoV1},
proof::EvmProof,
public_inputs::PublicInputs,
};
use scroll_zkvm_types::{bundle::BundleInfo, proof::EvmProof, public_inputs::ForkName};

use super::*;

Expand All @@ -245,7 +241,7 @@ mod tests {
fn test_dummy_proof() -> eyre::Result<()> {
// 1. Metadata
let metadata = {
let bundle_info: BundleInfoV1 = BundleInfo {
let bundle_info = BundleInfo {
chain_id: 12345,
num_batches: 12,
prev_state_root: B256::repeat_byte(1),
Expand All @@ -254,11 +250,10 @@ mod tests {
batch_hash: B256::repeat_byte(4),
withdraw_root: B256::repeat_byte(5),
msg_queue_hash: B256::repeat_byte(6),
}
.into();
let bundle_pi_hash = bundle_info.pi_hash();
};
let bundle_pi_hash = bundle_info.pi_hash(ForkName::EuclidV1);
BundleProofMetadata {
bundle_info: bundle_info.0,
bundle_info,
bundle_pi_hash,
}
};
Expand Down
10 changes: 6 additions & 4 deletions crates/libzkp/src/tasks/batch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use eyre::Result;
use sbv_primitives::{B256, U256};
use scroll_zkvm_types::{
batch::{
BatchHeader, BatchHeaderV6, BatchHeaderV7, BatchInfo, BatchWitness, EnvelopeV6, EnvelopeV7,
PointEvalWitness, ReferenceHeader, ToArchievedWitness, N_BLOB_BYTES,
BatchHeader, BatchHeaderV6, BatchHeaderV7, BatchInfo, BatchWitness, Envelope, EnvelopeV6,
EnvelopeV7, PointEvalWitness, ReferenceHeader, ToArchievedWitness, N_BLOB_BYTES,
},
public_inputs::ForkName,
task::ProvingTask,
Expand Down Expand Up @@ -117,7 +117,8 @@ impl BatchProvingTask {
"hardfork mismatch for da-codec@v6 header: found={fork_name:?}, expected={:?}",
ForkName::EuclidV1,
);
EnvelopeV6::from(self.blob_bytes.as_slice()).challenge_digest(versioned_hash)
EnvelopeV6::from_slice(self.blob_bytes.as_slice())
.challenge_digest(versioned_hash)
}
BatchHeaderV::V7(_) => {
match fork_name {
Expand All @@ -131,7 +132,8 @@ impl BatchProvingTask {
padded_blob_bytes.resize(N_BLOB_BYTES, 0);
padded_blob_bytes
};
EnvelopeV7::from(padded_blob_bytes.as_slice()).challenge_digest(versioned_hash)
EnvelopeV7::from_slice(padded_blob_bytes.as_slice())
.challenge_digest(versioned_hash)
}
};

Expand Down
12 changes: 5 additions & 7 deletions crates/libzkp/src/tasks/batch/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ pub mod point_eval {

/// Get the KZG commitment from an EIP-4844 blob.
pub fn blob_to_kzg_commitment(blob: &c_kzg::Blob) -> c_kzg::KzgCommitment {
c_kzg::KzgCommitment::blob_to_kzg_commitment(blob, c_kzg::ethereum_kzg_settings())
c_kzg::ethereum_kzg_settings(0)
.blob_to_kzg_commitment(blob)
.expect("blob to kzg commitment should succeed")
}

Expand All @@ -65,12 +66,9 @@ pub mod point_eval {
pub fn get_kzg_proof(blob: &c_kzg::Blob, challenge: H256) -> (c_kzg::KzgProof, U256) {
let challenge = get_x_from_challenge(challenge);

let (proof, y) = c_kzg::KzgProof::compute_kzg_proof(
blob,
&c_kzg::Bytes32::new(challenge.to_be_bytes()),
c_kzg::ethereum_kzg_settings(),
)
.expect("kzg proof should succeed");
let (proof, y) = c_kzg::ethereum_kzg_settings(0)
.compute_kzg_proof(blob, &c_kzg::Bytes32::new(challenge.to_be_bytes()))
.expect("kzg proof should succeed");

(proof, U256::from_be_slice(y.as_slice()))
}
Expand Down
4 changes: 2 additions & 2 deletions crates/libzkp/src/tasks/bundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use scroll_zkvm_types::{
bundle::{BundleInfo, BundleWitness, ToArchievedWitness},
public_inputs::ForkName,
task::ProvingTask,
utils::{to_rkyv_bytes, RancorError},
};

/// Message indicating a sanity check failure.
Expand Down Expand Up @@ -47,6 +46,7 @@ impl BundleProvingTask {
.iter()
.map(|wrapped_proof| wrapped_proof.metadata.batch_info.clone())
.collect(),
fork_name: self.fork_name.to_lowercase().as_str().into(),
}
}

Expand Down Expand Up @@ -83,7 +83,7 @@ impl TryFrom<BundleProvingTask> for ProvingTask {
.into_iter()
.map(|w_proof| w_proof.proof.into_root_proof().expect("expect root proof"))
.collect(),
serialized_witness: vec![to_rkyv_bytes::<RancorError>(&witness)?.to_vec()],
serialized_witness: vec![witness.rkyv_serialize(None)?.to_vec()],
vk: Vec::new(),
})
}
Expand Down
13 changes: 6 additions & 7 deletions crates/libzkp/src/tasks/chunk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use sbv_primitives::{types::BlockWitness, B256};
use scroll_zkvm_types::{
chunk::{execute, ChunkInfo, ChunkWitness, ToArchievedWitness},
task::ProvingTask,
utils::{to_rkyv_bytes, RancorError},
};

/// The type aligned with coordinator's defination
Expand Down Expand Up @@ -72,7 +71,7 @@ impl TryFrom<ChunkProvingTask> for ProvingTask {
identifier: value.identifier(),
fork_name: value.fork_name,
aggregated_proofs: Vec::new(),
serialized_witness: vec![to_rkyv_bytes::<RancorError>(&witness)?.to_vec()],
serialized_witness: vec![witness.rkyv_serialize(None)?.to_vec()],
vk: Vec::new(),
})
}
Expand Down Expand Up @@ -119,11 +118,11 @@ impl ChunkProvingTask {
}

fn build_guest_input(&self) -> ChunkWitness {
ChunkWitness {
blocks: self.block_witnesses.to_vec(),
prev_msg_queue_hash: self.prev_msg_queue_hash,
fork_name: self.fork_name.to_lowercase().as_str().into(),
}
ChunkWitness::new(
&self.block_witnesses,
self.prev_msg_queue_hash,
self.fork_name.to_lowercase().as_str().into(),
)
}

fn insert_state(&mut self, node: sbv_primitives::Bytes) {
Expand Down
1 change: 1 addition & 0 deletions crates/libzkp/src/tasks/chunk_task.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions crates/libzkp_c/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ crate-type = ["cdylib"]
[dependencies]
libzkp = { path = "../libzkp" }
l2geth = { path = "../l2geth"}
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
tracing.workspace = true
Loading
Loading