Compare commits

..

11 Commits

Author SHA1 Message Date
lightsing
8a05300ab3 apply review from coderabbitai 2025-11-27 12:48:41 +08:00
lightsing
5d378a015d apply review from coderabbitai 2025-11-27 12:43:49 +08:00
lightsing
88066d72e8 apply review 2025-11-27 12:40:36 +08:00
lightsing
226d32f9bf fix: build on macos 2025-11-27 11:49:24 +08:00
georgehao
2ecc42e2f5 Return when total < request page (#1766) 2025-11-25 23:36:40 +08:00
georgehao
de72e2dccb remove unused check (#1765) 2025-11-25 22:12:16 +08:00
georgehao
edb51236e2 bump version (#1763) 2025-11-25 21:00:57 +08:00
georgehao
15a23478d1 fix bridge history GetL2UnclaimedWithdrawalsByAddress (#1760)
Co-authored-by: Péter Garamvölgyi <peter@scroll.io>
2025-11-25 20:59:31 +08:00
Morty
9100a0bd4a fix: ci lint (#1762) 2025-11-25 17:45:05 +08:00
Morty
0ede0cd41f feat(blob-uploader): upload blob once proposed (#1759)
Co-authored-by: yiweichi <yiweichi@users.noreply.github.com>
2025-11-25 14:07:08 +08:00
Ho
9dceae1ca2 [Feat] Galileo forking (#1753)
Co-authored-by: Rohit Narurkar <rohit.narurkar@proton.me>
2025-11-24 17:37:04 +08:00
23 changed files with 89 additions and 70 deletions

14
Cargo.lock generated
View File

@@ -8779,7 +8779,7 @@ dependencies = [
[[package]]
name = "scroll-zkvm-prover"
version = "0.7.0"
source = "git+https://github.com/scroll-tech/zkvm-prover?tag=v0.7.0-rc.5#4d9af18e540af069cb2de1c73bf4751ff03c35fc"
source = "git+https://github.com/scroll-tech/zkvm-prover?tag=v0.7.0#56c951893bac4754a170dd95fa186d21aa34e2bf"
dependencies = [
"base64 0.22.1",
"bincode 1.3.3",
@@ -8806,7 +8806,7 @@ dependencies = [
[[package]]
name = "scroll-zkvm-types"
version = "0.7.0"
source = "git+https://github.com/scroll-tech/zkvm-prover?tag=v0.7.0-rc.5#4d9af18e540af069cb2de1c73bf4751ff03c35fc"
source = "git+https://github.com/scroll-tech/zkvm-prover?tag=v0.7.0#56c951893bac4754a170dd95fa186d21aa34e2bf"
dependencies = [
"alloy-primitives",
"base64 0.22.1",
@@ -8830,7 +8830,7 @@ dependencies = [
[[package]]
name = "scroll-zkvm-types-base"
version = "0.7.0"
source = "git+https://github.com/scroll-tech/zkvm-prover?tag=v0.7.0-rc.5#4d9af18e540af069cb2de1c73bf4751ff03c35fc"
source = "git+https://github.com/scroll-tech/zkvm-prover?tag=v0.7.0#56c951893bac4754a170dd95fa186d21aa34e2bf"
dependencies = [
"alloy-primitives",
"alloy-serde 1.0.41",
@@ -8843,7 +8843,7 @@ dependencies = [
[[package]]
name = "scroll-zkvm-types-batch"
version = "0.7.0"
source = "git+https://github.com/scroll-tech/zkvm-prover?tag=v0.7.0-rc.5#4d9af18e540af069cb2de1c73bf4751ff03c35fc"
source = "git+https://github.com/scroll-tech/zkvm-prover?tag=v0.7.0#56c951893bac4754a170dd95fa186d21aa34e2bf"
dependencies = [
"alloy-primitives",
"c-kzg",
@@ -8865,7 +8865,7 @@ dependencies = [
[[package]]
name = "scroll-zkvm-types-bundle"
version = "0.7.0"
source = "git+https://github.com/scroll-tech/zkvm-prover?tag=v0.7.0-rc.5#4d9af18e540af069cb2de1c73bf4751ff03c35fc"
source = "git+https://github.com/scroll-tech/zkvm-prover?tag=v0.7.0#56c951893bac4754a170dd95fa186d21aa34e2bf"
dependencies = [
"rkyv",
"scroll-zkvm-types-base",
@@ -8875,7 +8875,7 @@ dependencies = [
[[package]]
name = "scroll-zkvm-types-chunk"
version = "0.7.0"
source = "git+https://github.com/scroll-tech/zkvm-prover?tag=v0.7.0-rc.5#4d9af18e540af069cb2de1c73bf4751ff03c35fc"
source = "git+https://github.com/scroll-tech/zkvm-prover?tag=v0.7.0#56c951893bac4754a170dd95fa186d21aa34e2bf"
dependencies = [
"alloy-consensus",
"alloy-primitives",
@@ -8900,7 +8900,7 @@ dependencies = [
[[package]]
name = "scroll-zkvm-verifier"
version = "0.7.0"
source = "git+https://github.com/scroll-tech/zkvm-prover?tag=v0.7.0-rc.5#4d9af18e540af069cb2de1c73bf4751ff03c35fc"
source = "git+https://github.com/scroll-tech/zkvm-prover?tag=v0.7.0#56c951893bac4754a170dd95fa186d21aa34e2bf"
dependencies = [
"bincode 1.3.3",
"eyre",

View File

@@ -17,9 +17,9 @@ repository = "https://github.com/scroll-tech/scroll"
version = "4.7.1"
[workspace.dependencies]
scroll-zkvm-prover = { git = "https://github.com/scroll-tech/zkvm-prover", tag = "v0.7.0-rc.5" }
scroll-zkvm-verifier = { git = "https://github.com/scroll-tech/zkvm-prover", tag = "v0.7.0-rc.5" }
scroll-zkvm-types = { git = "https://github.com/scroll-tech/zkvm-prover", tag = "v0.7.0-rc.5" }
scroll-zkvm-prover = { git = "https://github.com/scroll-tech/zkvm-prover", tag = "v0.7.0" }
scroll-zkvm-verifier = { git = "https://github.com/scroll-tech/zkvm-prover", tag = "v0.7.0" }
scroll-zkvm-types = { git = "https://github.com/scroll-tech/zkvm-prover", tag = "v0.7.0" }
sbv-primitives = { git = "https://github.com/scroll-tech/stateless-block-verifier", tag = "scroll-v91", features = ["scroll", "rkyv"] }
sbv-utils = { git = "https://github.com/scroll-tech/stateless-block-verifier", tag = "scroll-v91" }

View File

@@ -361,7 +361,6 @@ func getTxHistoryInfoFromBridgeBatchDepositMessage(message *orm.BridgeBatchDepos
func (h *HistoryLogic) getCachedTxsInfo(ctx context.Context, cacheKey string, pageNum, pageSize uint64) ([]*types.TxHistoryInfo, uint64, bool, error) {
start := int64((pageNum - 1) * pageSize)
end := start + int64(pageSize) - 1
total, err := h.redis.ZCard(ctx, cacheKey).Result()
if err != nil {
log.Error("failed to get zcard result", "error", err)
@@ -372,6 +371,10 @@ func (h *HistoryLogic) getCachedTxsInfo(ctx context.Context, cacheKey string, pa
return nil, 0, false, nil
}
if start >= total {
return nil, 0, false, nil
}
values, err := h.redis.ZRevRange(ctx, cacheKey, start, end).Result()
if err != nil {
log.Error("failed to get zrange result", "error", err)
@@ -450,5 +453,6 @@ func (h *HistoryLogic) processAndCacheTxHistoryInfo(ctx context.Context, cacheKe
log.Error("cache miss after write, expect hit", "cached key", cacheKey, "page", page, "page size", pageSize, "error", err)
return nil, 0, err
}
return pagedTxs, total, nil
}

View File

@@ -157,7 +157,7 @@ func (c *CrossMessage) GetL2UnclaimedWithdrawalsByAddress(ctx context.Context, s
db = db.Where("tx_status in (?)", []types.TxStatusType{types.TxStatusTypeSent, types.TxStatusTypeFailedRelayed, types.TxStatusTypeRelayTxReverted})
db = db.Where("sender = ?", sender)
db = db.Order("block_timestamp desc")
db = db.Limit(500)
db = db.Limit(10000)
if err := db.Find(&messages).Error; err != nil {
return nil, fmt.Errorf("failed to get L2 claimable withdrawal messages by sender address, sender: %v, error: %w", sender, err)
}

16
build/common.mk Normal file
View File

@@ -0,0 +1,16 @@
UNAME_S := $(shell uname -s)
IS_DARWIN := $(findstring Darwin,$(UNAME_S))
SHLIB_EXT := so
ifeq ($(UNAME_S),Darwin)
SHLIB_EXT := dylib
endif
LIB_ZKP_NAME := libzkp.$(SHLIB_EXT)
define macos_codesign
@if [ -n "$(IS_DARWIN)" ]; then \
codesign --force --sign - '$(1)'; \
codesign --verify --deep --verbose '$(1)'; \
fi
endef

View File

@@ -5,7 +5,7 @@ import (
"runtime/debug"
)
var tag = "v4.7.1"
var tag = "v4.7.5"
var commit = func() string {
if info, ok := debug.ReadBuildInfo(); ok {

View File

@@ -1,4 +1,5 @@
/build/bin
.idea
internal/logic/verifier/lib
internal/libzkp/lib/libzkp.so
libzkp.so
libzkp.dylib

View File

@@ -1,8 +1,10 @@
include ../build/common.mk
.PHONY: lint docker clean coordinator coordinator_skip_libzkp mock_coordinator libzkp
IMAGE_VERSION=latest
REPO_ROOT_DIR=./..
LIBZKP_PATH=./internal/logic/libzkp/lib/libzkp.so
LIBZKP_PATH=./internal/logic/libzkp/lib/$(LIB_ZKP_NAME)
ifeq (4.3,$(firstword $(sort $(MAKE_VERSION) 4.3)))
ZKVM_VERSION=$(shell grep -m 1 "zkvm-prover?" ../Cargo.lock | cut -d "#" -f2 | cut -c-7)
@@ -27,6 +29,7 @@ libzkp: clean_libzkp $(LIBZKP_PATH)
coordinator_api: $(LIBZKP_PATH) ## Builds the Coordinator api instance.
go build -ldflags "-X scroll-tech/common/version.ZkVersion=${ZK_VERSION}" -o $(PWD)/build/bin/coordinator_api ./cmd/api
$(call macos_codesign,$(PWD)/build/bin/coordinator_api)
coordinator_cron:
go build -ldflags "-X scroll-tech/common/version.ZkVersion=${ZK_VERSION}" -o $(PWD)/build/bin/coordinator_cron ./cmd/cron

View File

@@ -10,6 +10,8 @@ See [monorepo prerequisites](../README.md#prerequisites).
## Build
Using Go version 1.22
```bash
make clean
make coordinator_api

View File

@@ -1,16 +1,20 @@
.PHONY: help fmt clippy test test-ci test-all
include ../../../../build/common.mk
.PHONY: help fmt clippy test test-ci test-all clean build
all: build
build:
@cargo build --release -p libzkp-c
@mkdir -p lib
@cp -f ../../../../target/release/libzkp.so lib/
@cp -f ../../../../target/release/$(LIB_ZKP_NAME) lib/
fmt:
@cargo fmt --all -- --check
clean:
@cargo clean --release -p libzkp -p libzkp-c -p l2geth
@rm -f lib/libzkp.so
@rm -f lib/$(LIB_ZKP_NAME)
clippy:
@cargo check --release --all-features

View File

@@ -1,7 +1,8 @@
package libzkp
/*
#cgo LDFLAGS: -lzkp -lm -ldl -L${SRCDIR}/lib -Wl,-rpath=${SRCDIR}/lib
#cgo linux LDFLAGS: -lzkp -lm -ldl -L${SRCDIR}/lib -Wl,-rpath=${SRCDIR}/lib
#cgo darwin LDFLAGS: -lzkp -lm -ldl -L${SRCDIR}/lib -Wl,-rpath,${SRCDIR}/lib
#cgo gpu LDFLAGS: -lzkp -lm -ldl -lgmp -lstdc++ -lprocps -L/usr/local/cuda/lib64/ -lcudart -L${SRCDIR}/lib/ -Wl,-rpath=${SRCDIR}/lib
#include <stdlib.h>
#include "libzkp.h"

View File

@@ -56,8 +56,6 @@ char* gen_wrapped_proof(char* proof_json, char* metadata, char* vk, size_t vk_le
// Release memory allocated for a string returned by gen_wrapped_proof
void release_string(char* string_ptr);
void set_dynamic_feature(const char* feats);
// Universal task compatibility fix function
char* univ_task_compatibility_fix(char* task_json);

View File

@@ -328,7 +328,6 @@ func (bp *BatchProverTask) getBatchTaskDetail(dbBatch *orm.Batch, chunkProofs []
if decodeErr != nil {
return nil, fmt.Errorf("failed to decode batch header version %d: %w", dbBatch.CodecVersion, decodeErr)
}
log.Info("Decode batchheader bytes to canonical header", "version", batchHeader.Version())
taskDetail.BatchHeader = batchHeader
taskDetail.ChallengeDigest = common.HexToHash(dbBatch.ChallengeDigest)

View File

@@ -3,6 +3,9 @@ name = "libzkp"
version.workspace = true
edition.workspace = true
[lib]
crate-type = ["rlib", "cdylib"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
scroll-zkvm-types = { workspace = true, features = ["scroll"] }

View File

@@ -1,6 +1,6 @@
pub mod proofs;
pub mod tasks;
pub use tasks::ProvintTaskExt;
pub use tasks::ProvingTaskExt;
pub mod verifier;
use verifier::HardForkName;
pub use verifier::{TaskType, VerifierConfig};
@@ -20,7 +20,7 @@ pub(crate) fn witness_use_legacy_mode(fork_name: &str) -> eyre::Result<bool> {
.map(|cfg| cfg.legacy_witness_encoding)
.ok_or_else(|| {
eyre::eyre!(
"can not found features setting for unrecognized fork {}",
"can not find features setting for unrecognized fork {}",
fork_name
)
})
@@ -55,10 +55,6 @@ impl FeatureOptions {
}
}
pub fn set_dynamic_feature(_: &str) {
tracing::error!("call deprecated method");
}
/// Turn the coordinator's chunk task into a json string for formal chunk proving
/// task (with full witnesses)
pub fn checkout_chunk_task(
@@ -196,7 +192,7 @@ pub fn gen_universal_task(
u_task.vk = Vec::from(expected_vk);
let fork_name = u_task.fork_name.clone();
let mut u_task_ext = ProvintTaskExt::new(u_task);
let mut u_task_ext = ProvingTaskExt::new(u_task);
// set additional settings from global features
if let Some(cfg) = ADDITIONAL_FEATURES

View File

@@ -36,20 +36,20 @@ fn check_aggregation_proofs<Metadata: MultiVersionPublicInputs>(
}
#[derive(serde::Deserialize, serde::Serialize)]
pub struct ProvintTaskExt {
pub struct ProvingTaskExt {
#[serde(flatten)]
task: ProvingTask,
#[serde(default)]
pub use_openvm_13: bool,
}
impl From<ProvintTaskExt> for ProvingTask {
fn from(wrap_t: ProvintTaskExt) -> Self {
impl From<ProvingTaskExt> for ProvingTask {
fn from(wrap_t: ProvingTaskExt) -> Self {
wrap_t.task
}
}
impl ProvintTaskExt {
impl ProvingTaskExt {
pub fn new(task: ProvingTask) -> Self {
Self {
task,

View File

@@ -27,11 +27,11 @@ pub struct BatchHeaderValidiumWithHash {
}
/// Parse header types passed from golang side and adapt to the
/// defination in zkvm-prover's types
/// definition in zkvm-prover's types
/// We distinguish the header type in golang side according to the codec
/// version, i.e. v6 - v9 (current), and validium
/// And adapt it to different header version used in zkvm-prover's witness
/// defination, i.e. v6- v8 (current), and validium
/// version, i.e. v7 - v9 (current), and validium
/// And adapt it to the corresponding header version used in zkvm-prover's witness
/// definition, i.e. v7- v8 (current), and validium
#[derive(Clone, serde::Deserialize, serde::Serialize)]
#[serde(untagged)]
#[allow(non_camel_case_types)]

View File

@@ -275,10 +275,3 @@ pub unsafe extern "C" fn release_string(ptr: *mut c_char) {
let _ = CString::from_raw(ptr);
}
}
/// # Safety
#[no_mangle]
pub unsafe extern "C" fn set_dynamic_feature(feats: *const c_char) {
let feats_str = c_char_to_str(feats);
libzkp::set_dynamic_feature(feats_str);
}

View File

@@ -12,6 +12,7 @@ use scroll_proving_sdk::{
ProvingService,
},
};
use scroll_zkvm_types::ProvingTask;
use serde::{Deserialize, Serialize};
use std::{
collections::HashMap,
@@ -272,7 +273,9 @@ impl LocalProver {
let duration = SystemTime::now().duration_since(UNIX_EPOCH).unwrap();
let created_at = duration.as_secs() as f64 + duration.subsec_nanos() as f64 * 1e-9;
let (prover_task, task_cfg) = UniversalHandler::get_task_from_input(&req.input)?;
let prover_task = UniversalHandler::get_task_from_input(&req.input)?;
let is_openvm_13 = prover_task.use_openvm_13;
let prover_task: ProvingTask = prover_task.into();
let vk = hex::encode(&prover_task.vk);
let handler = if let Some(handler) = self.handlers.get(&vk) {
handler.clone()
@@ -298,8 +301,10 @@ impl LocalProver {
.location_data
.get_asset(&vk, &url_base, &base_config.workspace_path)
.await?;
let circuits_handler =
Arc::new(Mutex::new(UniversalHandler::new(&asset_path, &task_cfg)?));
let circuits_handler = Arc::new(Mutex::new(UniversalHandler::new(
&asset_path,
is_openvm_13,
)?));
self.handlers.insert(vk, circuits_handler.clone());
circuits_handler
};

View File

@@ -3,7 +3,7 @@ use std::path::Path;
use super::CircuitsHandler;
use async_trait::async_trait;
use eyre::Result;
use libzkp::ProvintTaskExt;
use libzkp::ProvingTaskExt;
use scroll_zkvm_prover::{Prover, ProverConfig};
use scroll_zkvm_types::ProvingTask;
use tokio::sync::Mutex;
@@ -11,26 +11,20 @@ pub struct UniversalHandler {
prover: Prover,
}
// additional config dispatched with proving task
#[derive(Debug, Default)]
pub(crate) struct TaskConfig {
pub is_openvm_v13: bool,
}
/// Safe for current usage as `CircuitsHandler` trait (protected inside of Mutex and NEVER extract
/// the instance out by `into_inner`)
unsafe impl Send for UniversalHandler {}
impl UniversalHandler {
pub fn new(workspace_path: impl AsRef<Path>, cfg: &TaskConfig) -> Result<Self> {
pub fn new(workspace_path: impl AsRef<Path>, is_openvm_v13: bool) -> Result<Self> {
let path_app_exe = workspace_path.as_ref().join("app.vmexe");
let path_app_config = workspace_path.as_ref().join("openvm.toml");
let segment_len = Some((1 << 22) - 100);
let segment_len = Some((1 << 21) - 100);
let config = ProverConfig {
path_app_config,
path_app_exe,
segment_len,
is_openvm_v13: cfg.is_openvm_v13,
is_openvm_v13,
};
let prover = Prover::setup(config, None)?;
@@ -43,13 +37,8 @@ impl UniversalHandler {
&mut self.prover
}
pub fn get_task_from_input(input: &str) -> Result<(ProvingTask, TaskConfig)> {
let task_ext: ProvintTaskExt = serde_json::from_str(input)?;
let cfg = TaskConfig {
is_openvm_v13: task_ext.use_openvm_13,
};
Ok((task_ext.into(), cfg))
pub fn get_task_from_input(input: &str) -> Result<ProvingTaskExt> {
Ok(serde_json::from_str(input)?)
}
}

View File

@@ -242,10 +242,12 @@ func (b *BlobUploader) GetFirstUnuploadedBatchByPlatform(ctx context.Context, st
break
}
if len(batch.CommitTxHash) == 0 {
log.Debug("got batch not committed for blob uploading", "batch_index", batchIndex, "platform", platform.String())
return nil, nil
}
// disable this check to upload blobs before it's committed. This is to
// alleviate the case nodes try to fetch the blob from s3 before its uploaded.
// if len(batch.CommitTxHash) == 0 {
// log.Debug("got batch not committed for blob uploading", "batch_index", batchIndex, "platform", platform.String())
// return nil, nil
// }
return batch, nil
}

View File

@@ -1,3 +1,5 @@
include ../../build/common.mk
.PHONY: clean setup_db test_tool all check_vars
include conf/.make.env
@@ -52,6 +54,7 @@ reset_db:
test_tool:
go build -o $(PWD)/build/bin/e2e_tool ../../rollup/tests/integration_tool
$(call macos_codesign,$(PWD)/build/bin/e2e_tool)
build/bin/e2e_tool: test_tool
@@ -71,4 +74,4 @@ reimport_data: reset_db import_data
coordinator_setup:
SCROLL_FORK_NAME=${SCROLL_FORK_NAME} $(MAKE) -C ../../coordinator localsetup
cp -f conf/genesis.json ../../coordinator/build/bin/conf
cp -f conf/genesis.json ../../coordinator/build/bin/conf

View File

@@ -35,6 +35,6 @@
"login_expire_duration_sec": 3600
},
"sequencer": {
"decryption_key": "ad25ba5de9f03fd9e3c81a1ad731c5c7e94ae2641f75ed7d3275312053b40f75"
"decryption_key": "<decryption key>"
}
}