mirror of
https://github.com/scroll-tech/scroll.git
synced 2026-01-11 15:08:09 -05:00
Compare commits
45 Commits
v4.1.43
...
multi_veri
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
11cd211de4 | ||
|
|
0a3401772e | ||
|
|
141a05f2c6 | ||
|
|
69d2d2b7c2 | ||
|
|
5955329cff | ||
|
|
3292128919 | ||
|
|
497fd783a3 | ||
|
|
e86399b5d4 | ||
|
|
b1e3b28dc6 | ||
|
|
0a9641be70 | ||
|
|
e7d4b10451 | ||
|
|
e7f868b467 | ||
|
|
8dd288c22d | ||
|
|
4dce379232 | ||
|
|
4a3056667e | ||
|
|
d8019b2dfb | ||
|
|
cf2fdfda9f | ||
|
|
02e6f77221 | ||
|
|
3e3f39a3f2 | ||
|
|
00f906f612 | ||
|
|
7f86fe65da | ||
|
|
df3fac89ae | ||
|
|
0892f0f876 | ||
|
|
0b9d6d04fa | ||
|
|
0c12773b78 | ||
|
|
36a4964aa5 | ||
|
|
cd4158c80d | ||
|
|
3e01d3de83 | ||
|
|
5344a73c5b | ||
|
|
50829cae9c | ||
|
|
2044a052ec | ||
|
|
1e2ce2d655 | ||
|
|
66e802fb55 | ||
|
|
716d01fda5 | ||
|
|
399404172c | ||
|
|
364a8f8850 | ||
|
|
76ba845d0f | ||
|
|
f729b8e0ab | ||
|
|
e6b0c61878 | ||
|
|
a7a65b60e5 | ||
|
|
160287e6cc | ||
|
|
bdc1957f27 | ||
|
|
8ee49ed515 | ||
|
|
c90d1414d9 | ||
|
|
87b1a7a63e |
@@ -110,7 +110,7 @@ func action(ctx *cli.Context) error {
|
||||
|
||||
go utils.Loop(subCtx, 2*time.Second, l2relayer.ProcessPendingBatches)
|
||||
|
||||
go utils.Loop(subCtx, 60*time.Second, l2relayer.ProcessCommittedBatches)
|
||||
go utils.Loop(subCtx, 10*time.Second, l2relayer.ProcessCommittedBatches)
|
||||
|
||||
// Finish start all rollup relayer functions.
|
||||
log.Info("Start rollup-relayer successfully")
|
||||
|
||||
@@ -195,6 +195,13 @@ func (s *Sender) SendTransaction(ID string, target *common.Address, value *big.I
|
||||
tx *types.Transaction
|
||||
err error
|
||||
)
|
||||
|
||||
defer func() {
|
||||
if err != nil {
|
||||
s.pendingTxs.Remove(ID) // release the ID on failure
|
||||
}
|
||||
}()
|
||||
|
||||
if feeData, err = s.getFeeData(s.auth, target, value, data, minGasLimit); err != nil {
|
||||
return common.Hash{}, fmt.Errorf("failed to get fee data, err: %w", err)
|
||||
}
|
||||
|
||||
34
common/libzkp/impl/Cargo.lock
generated
34
common/libzkp/impl/Cargo.lock
generated
@@ -32,7 +32,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "aggregator"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.5.14rc1#ae23cd7af80f1ba9d0f0bb1a4367ffe626ade86e"
|
||||
source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.5.16#f1341e5bf2dc59ea10c19012257c7e386cfc195f"
|
||||
dependencies = [
|
||||
"ark-std",
|
||||
"env_logger 0.10.0",
|
||||
@@ -380,7 +380,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4114279215a005bc675e386011e594e1d9b800918cea18fcadadcce864a2046b"
|
||||
dependencies = [
|
||||
"borsh-derive",
|
||||
"hashbrown 0.12.3",
|
||||
"hashbrown 0.13.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -433,7 +433,7 @@ checksum = "a3e2c3daef883ecc1b5d58c15adae93470a91d425f3532ba1695849656af3fc1"
|
||||
[[package]]
|
||||
name = "bus-mapping"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.5.14rc1#ae23cd7af80f1ba9d0f0bb1a4367ffe626ade86e"
|
||||
source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.5.16#f1341e5bf2dc59ea10c19012257c7e386cfc195f"
|
||||
dependencies = [
|
||||
"eth-types",
|
||||
"ethers-core",
|
||||
@@ -1049,7 +1049,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "eth-types"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.5.14rc1#ae23cd7af80f1ba9d0f0bb1a4367ffe626ade86e"
|
||||
source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.5.16#f1341e5bf2dc59ea10c19012257c7e386cfc195f"
|
||||
dependencies = [
|
||||
"ethers-core",
|
||||
"ethers-signers",
|
||||
@@ -1226,7 +1226,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "external-tracer"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.5.14rc1#ae23cd7af80f1ba9d0f0bb1a4367ffe626ade86e"
|
||||
source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.5.16#f1341e5bf2dc59ea10c19012257c7e386cfc195f"
|
||||
dependencies = [
|
||||
"eth-types",
|
||||
"geth-utils",
|
||||
@@ -1439,7 +1439,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "gadgets"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.5.14rc1#ae23cd7af80f1ba9d0f0bb1a4367ffe626ade86e"
|
||||
source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.5.16#f1341e5bf2dc59ea10c19012257c7e386cfc195f"
|
||||
dependencies = [
|
||||
"digest 0.7.6",
|
||||
"eth-types",
|
||||
@@ -1479,7 +1479,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "geth-utils"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.5.14rc1#ae23cd7af80f1ba9d0f0bb1a4367ffe626ade86e"
|
||||
source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.5.16#f1341e5bf2dc59ea10c19012257c7e386cfc195f"
|
||||
dependencies = [
|
||||
"env_logger 0.9.3",
|
||||
"gobuild 0.1.0-alpha.2 (git+https://github.com/scroll-tech/gobuild.git)",
|
||||
@@ -1633,7 +1633,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "halo2-mpt-circuits"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/scroll-tech/mpt-circuit.git?branch=v0.5#1c11b6c9b1245073a76c3ce7100b6798060f7cb8"
|
||||
source = "git+https://github.com/scroll-tech/mpt-circuit.git?branch=v0.5#2163a9c436ed85363c954ecf7e6e1044a1b991dc"
|
||||
dependencies = [
|
||||
"ethers-core",
|
||||
"halo2_proofs",
|
||||
@@ -1655,7 +1655,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "halo2_proofs"
|
||||
version = "0.2.0"
|
||||
source = "git+https://github.com/scroll-tech/halo2.git?branch=develop#4d8a405a97ce445c88fc8ec40f9a2dd0a661c697"
|
||||
source = "git+https://github.com/scroll-tech/halo2.git?branch=develop#01f0b5260445a9190299af7b06b766c1e925fdaf"
|
||||
dependencies = [
|
||||
"ark-std",
|
||||
"blake2b_simd",
|
||||
@@ -2077,7 +2077,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "keccak256"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.5.14rc1#ae23cd7af80f1ba9d0f0bb1a4367ffe626ade86e"
|
||||
source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.5.16#f1341e5bf2dc59ea10c19012257c7e386cfc195f"
|
||||
dependencies = [
|
||||
"env_logger 0.9.3",
|
||||
"eth-types",
|
||||
@@ -2264,7 +2264,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "mock"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.5.14rc1#ae23cd7af80f1ba9d0f0bb1a4367ffe626ade86e"
|
||||
source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.5.16#f1341e5bf2dc59ea10c19012257c7e386cfc195f"
|
||||
dependencies = [
|
||||
"eth-types",
|
||||
"ethers-core",
|
||||
@@ -2279,7 +2279,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "mpt-zktrie"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.5.14rc1#ae23cd7af80f1ba9d0f0bb1a4367ffe626ade86e"
|
||||
source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.5.16#f1341e5bf2dc59ea10c19012257c7e386cfc195f"
|
||||
dependencies = [
|
||||
"bus-mapping",
|
||||
"eth-types",
|
||||
@@ -2755,7 +2755,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "prover"
|
||||
version = "0.4.0"
|
||||
source = "git+https://github.com/scroll-tech/scroll-prover?tag=v0.5.14#7653cd664105077ac1540ecfdb0602e3858f59a6"
|
||||
source = "git+https://github.com/scroll-tech/scroll-prover?tag=v0.5.16#bd901762c4744936586f4a30e27a4b65cea3bb71"
|
||||
dependencies = [
|
||||
"aggregator",
|
||||
"anyhow",
|
||||
@@ -3624,7 +3624,7 @@ checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9"
|
||||
[[package]]
|
||||
name = "snark-verifier"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/scroll-tech/snark-verifier?branch=develop#12c306ec57849921e690221b10b8a08189868d4a"
|
||||
source = "git+https://github.com/scroll-tech/snark-verifier?branch=develop#100127726ac210226ac1096767e0efc5230775e3"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"ethereum-types 0.14.1",
|
||||
@@ -3648,7 +3648,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "snark-verifier-sdk"
|
||||
version = "0.0.1"
|
||||
source = "git+https://github.com/scroll-tech/snark-verifier?branch=develop#12c306ec57849921e690221b10b8a08189868d4a"
|
||||
source = "git+https://github.com/scroll-tech/snark-verifier?branch=develop#100127726ac210226ac1096767e0efc5230775e3"
|
||||
dependencies = [
|
||||
"bincode",
|
||||
"env_logger 0.10.0",
|
||||
@@ -4040,7 +4040,7 @@ checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba"
|
||||
[[package]]
|
||||
name = "types"
|
||||
version = "0.4.0"
|
||||
source = "git+https://github.com/scroll-tech/scroll-prover?tag=v0.5.14#7653cd664105077ac1540ecfdb0602e3858f59a6"
|
||||
source = "git+https://github.com/scroll-tech/scroll-prover?tag=v0.5.16#bd901762c4744936586f4a30e27a4b65cea3bb71"
|
||||
dependencies = [
|
||||
"base64 0.13.1",
|
||||
"blake2",
|
||||
@@ -4491,7 +4491,7 @@ checksum = "2a0956f1ba7c7909bfb66c2e9e4124ab6f6482560f6628b5aaeba39207c9aad9"
|
||||
[[package]]
|
||||
name = "zkevm-circuits"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.5.14rc1#ae23cd7af80f1ba9d0f0bb1a4367ffe626ade86e"
|
||||
source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.5.16#f1341e5bf2dc59ea10c19012257c7e386cfc195f"
|
||||
dependencies = [
|
||||
"array-init",
|
||||
"bus-mapping",
|
||||
|
||||
4555
common/libzkp/impl/Cargo.lock.new
Normal file
4555
common/libzkp/impl/Cargo.lock.new
Normal file
File diff suppressed because it is too large
Load Diff
4555
common/libzkp/impl/Cargo.lock.old
Normal file
4555
common/libzkp/impl/Cargo.lock.old
Normal file
File diff suppressed because it is too large
Load Diff
@@ -20,8 +20,8 @@ maingate = { git = "https://github.com/scroll-tech/halo2wrong", branch = "halo2-
|
||||
halo2curves = { git = "https://github.com/scroll-tech/halo2curves.git", branch = "0.3.1-derive-serde" }
|
||||
|
||||
[dependencies]
|
||||
prover = { git = "https://github.com/scroll-tech/scroll-prover", tag = "v0.5.14" }
|
||||
types = { git = "https://github.com/scroll-tech/scroll-prover", tag = "v0.5.14" }
|
||||
prover = { git = "https://github.com/scroll-tech/scroll-prover", tag = "v0.5.16" }
|
||||
types = { git = "https://github.com/scroll-tech/scroll-prover", tag = "v0.5.16" }
|
||||
halo2_proofs = { git = "https://github.com/scroll-tech/halo2.git", branch = "develop" }
|
||||
|
||||
log = "0.4"
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
var tag = "v4.1.43"
|
||||
var tag = "v4.1.46"
|
||||
|
||||
var commit = func() string {
|
||||
if info, ok := debug.ReadBuildInfo(); ok {
|
||||
@@ -28,8 +28,15 @@ var commit = func() string {
|
||||
// The default `000000-000000` is set for integration test, and will be overwritten by coordinator's & prover's actual compilations (see their Makefiles).
|
||||
var ZkVersion = "000000-000000"
|
||||
|
||||
// Version denote the version of scroll protocol, including the l2geth, relayer, coordinator, prover, contracts and etc.
|
||||
var Version = fmt.Sprintf("%s-%s-%s", tag, commit, ZkVersion)
|
||||
// OldZkVersion is the last version of ZkVersion.
|
||||
var OldZkVersion = "000000-000000"
|
||||
|
||||
var (
|
||||
// Version denote the version of scroll protocol, including the l2geth, relayer, coordinator, prover, contracts and etc.
|
||||
Version = fmt.Sprintf("%s-%s-%s", tag, commit, ZkVersion)
|
||||
// OldVersion is the last version of Version.
|
||||
OldVersion = fmt.Sprintf("%s-%s-%s", tag, commit, OldZkVersion)
|
||||
)
|
||||
|
||||
// CheckScrollProverVersion check the "scroll-prover" version, if it's different from the local one, return false
|
||||
func CheckScrollProverVersion(proverVersion string) bool {
|
||||
@@ -44,5 +51,5 @@ func CheckScrollProverVersion(proverVersion string) bool {
|
||||
return false
|
||||
}
|
||||
// compare the `scroll_prover` version
|
||||
return remote[2] == local[2] || remote[2] == "0756ac6"
|
||||
return remote[2] == local[2]
|
||||
}
|
||||
|
||||
@@ -571,6 +571,10 @@ contract ScrollChain is OwnableUpgradeable, PausableUpgradeable, IScrollChain {
|
||||
_totalL1MessagesPoppedInBatch += 1;
|
||||
_totalL1MessagesPoppedOverall += 1;
|
||||
}
|
||||
|
||||
// check last L1 message is not skipped, _totalL1MessagesPoppedInBatch must > 0
|
||||
uint256 rem = (_totalL1MessagesPoppedInBatch - 1) & 0xff;
|
||||
require(((_bitmap >> rem) & 1) == 0, "cannot skip last L1 message");
|
||||
}
|
||||
|
||||
return _ptr;
|
||||
|
||||
@@ -52,6 +52,11 @@ contract ScrollChainTest is DSTestPlus {
|
||||
function testCommitBatch() public {
|
||||
bytes memory batchHeader0 = new bytes(89);
|
||||
|
||||
// import 10 L1 messages
|
||||
for (uint256 i = 0; i < 10; i++) {
|
||||
messageQueue.appendCrossDomainMessage(address(this), 1000000, new bytes(0));
|
||||
}
|
||||
|
||||
// import genesis batch first
|
||||
assembly {
|
||||
mstore(add(batchHeader0, add(0x20, 25)), 1)
|
||||
@@ -106,13 +111,24 @@ contract ScrollChainTest is DSTestPlus {
|
||||
hevm.expectRevert("invalid chunk length");
|
||||
rollup.commitBatch(0, batchHeader0, chunks, new bytes(0));
|
||||
|
||||
// num txs less than num L1 msgs, revert
|
||||
// cannot skip last L1 message, revert
|
||||
chunk0 = new bytes(1 + 60);
|
||||
bytes memory bitmap = new bytes(32);
|
||||
chunk0[0] = bytes1(uint8(1)); // one block in this chunk
|
||||
chunk0[58] = bytes1(uint8(1)); // numTransactions = 1
|
||||
chunk0[60] = bytes1(uint8(1)); // numL1Messages = 1
|
||||
bitmap[31] = bytes1(uint8(1));
|
||||
chunks[0] = chunk0;
|
||||
hevm.expectRevert("cannot skip last L1 message");
|
||||
rollup.commitBatch(0, batchHeader0, chunks, bitmap);
|
||||
|
||||
// num txs less than num L1 msgs, revert
|
||||
chunk0 = new bytes(1 + 60);
|
||||
bitmap = new bytes(32);
|
||||
chunk0[0] = bytes1(uint8(1)); // one block in this chunk
|
||||
chunk0[58] = bytes1(uint8(1)); // numTransactions = 1
|
||||
chunk0[60] = bytes1(uint8(3)); // numL1Messages = 3
|
||||
bitmap[31] = bytes1(uint8(7));
|
||||
bitmap[31] = bytes1(uint8(3));
|
||||
chunks[0] = chunk0;
|
||||
hevm.expectRevert("num txs less than num L1 msgs");
|
||||
rollup.commitBatch(0, batchHeader0, chunks, bitmap);
|
||||
@@ -328,8 +344,8 @@ contract ScrollChainTest is DSTestPlus {
|
||||
// 2ac1dad3f3696e5581dfc10f2c7a7a8fc5b344285f7d332c7895a8825fca609a
|
||||
// 2. chunk1 has three blocks
|
||||
// 2.1 block0 has 5 tx, 3 L1 messages, no skips
|
||||
// 2.2 block1 has 10 tx, 5 L1 messages, even is skipped.
|
||||
// 2.2 block1 has 300 tx, 256 L1 messages, odd position is skipped.
|
||||
// 2.2 block1 has 10 tx, 5 L1 messages, even is skipped, last is not skipped
|
||||
// 2.2 block1 has 300 tx, 256 L1 messages, odd position is skipped, last is not skipped
|
||||
// => payload for chunk1
|
||||
// 0000000000000000
|
||||
// 0000000000000000
|
||||
@@ -348,32 +364,32 @@ contract ScrollChainTest is DSTestPlus {
|
||||
// 012c
|
||||
// ... (some tx hashes)
|
||||
// => data hash for chunk2
|
||||
// 0520f1fbe159af97fdf1d6cfcfe7605f99f7bfe3ed876e87b64250b1810df00b
|
||||
// e1276f58354ab2372050bde30d8c970ccc3728c76e97f37deebeee83ecbf5705
|
||||
// => data hash for all chunks
|
||||
// f52343299f6379fd15b20b23d51fc61b9b357b124be112686626b6278bcffa83
|
||||
// 3c71d155351642d15f1542a1543ce423abeca1f8939100a0a34cdc3127b95f69
|
||||
// => payload for batch header
|
||||
// 00
|
||||
// 0000000000000002
|
||||
// 0000000000000108
|
||||
// 0000000000000109
|
||||
// f52343299f6379fd15b20b23d51fc61b9b357b124be112686626b6278bcffa83
|
||||
// 3c71d155351642d15f1542a1543ce423abeca1f8939100a0a34cdc3127b95f69
|
||||
// cef70bf80683c4d9b8b2813e90c314e8c56648e231300b8cfed9d666b0caf14e
|
||||
// aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa800000000000000000000000000000000000000000000000000000000000000aa
|
||||
// => hash for batch header
|
||||
// 2231cf185a5c07931584f970738b4cd2ae4fb39e2d90853b26746c7616ea71b9
|
||||
// 03a9cdcb9d582251acf60937db006ec99f3505fd4751b7c1f92c9a8ef413e873
|
||||
bytes memory batchHeader2 = new bytes(89 + 32 + 32);
|
||||
assembly {
|
||||
mstore(add(batchHeader2, 0x20), 0) // version
|
||||
mstore(add(batchHeader2, add(0x20, 1)), shl(192, 2)) // batchIndex = 2
|
||||
mstore(add(batchHeader2, add(0x20, 9)), shl(192, 264)) // l1MessagePopped = 264
|
||||
mstore(add(batchHeader2, add(0x20, 17)), shl(192, 265)) // totalL1MessagePopped = 265
|
||||
mstore(add(batchHeader2, add(0x20, 25)), 0xf52343299f6379fd15b20b23d51fc61b9b357b124be112686626b6278bcffa83) // dataHash
|
||||
mstore(add(batchHeader2, add(0x20, 25)), 0x3c71d155351642d15f1542a1543ce423abeca1f8939100a0a34cdc3127b95f69) // dataHash
|
||||
mstore(add(batchHeader2, add(0x20, 57)), batchHash1) // parentBatchHash
|
||||
mstore(
|
||||
add(batchHeader2, add(0x20, 89)),
|
||||
77194726158210796949047323339125271902179989777093709359638389338608753093288
|
||||
77194726158210796949047323339125271902179989777093709359638389338608753093160
|
||||
) // bitmap0
|
||||
mstore(add(batchHeader2, add(0x20, 121)), 170) // bitmap1
|
||||
mstore(add(batchHeader2, add(0x20, 121)), 42) // bitmap1
|
||||
}
|
||||
chunk0 = new bytes(1 + 60 + 3 * 5);
|
||||
assembly {
|
||||
@@ -408,17 +424,17 @@ contract ScrollChainTest is DSTestPlus {
|
||||
assembly {
|
||||
mstore(
|
||||
add(bitmap, add(0x20, 0)),
|
||||
77194726158210796949047323339125271902179989777093709359638389338608753093288
|
||||
77194726158210796949047323339125271902179989777093709359638389338608753093160
|
||||
) // bitmap0
|
||||
mstore(add(bitmap, add(0x20, 32)), 170) // bitmap1
|
||||
mstore(add(bitmap, add(0x20, 32)), 42) // bitmap1
|
||||
}
|
||||
|
||||
hevm.expectEmit(true, true, false, true);
|
||||
emit CommitBatch(2, bytes32(0x2231cf185a5c07931584f970738b4cd2ae4fb39e2d90853b26746c7616ea71b9));
|
||||
emit CommitBatch(2, bytes32(0x03a9cdcb9d582251acf60937db006ec99f3505fd4751b7c1f92c9a8ef413e873));
|
||||
rollup.commitBatch(0, batchHeader1, chunks, bitmap);
|
||||
assertBoolEq(rollup.isBatchFinalized(2), false);
|
||||
bytes32 batchHash2 = rollup.committedBatches(2);
|
||||
assertEq(batchHash2, bytes32(0x2231cf185a5c07931584f970738b4cd2ae4fb39e2d90853b26746c7616ea71b9));
|
||||
assertEq(batchHash2, bytes32(0x03a9cdcb9d582251acf60937db006ec99f3505fd4751b7c1f92c9a8ef413e873));
|
||||
|
||||
// verify committed batch correctly
|
||||
hevm.expectEmit(true, true, false, true);
|
||||
@@ -441,7 +457,7 @@ contract ScrollChainTest is DSTestPlus {
|
||||
}
|
||||
// 4 ~ 9, even is nonzero, odd is zero
|
||||
for (uint256 i = 4; i < 9; i++) {
|
||||
if (i % 2 == 1) {
|
||||
if (i % 2 == 1 || i == 8) {
|
||||
assertEq(messageQueue.getCrossDomainMessage(i), bytes32(0));
|
||||
} else {
|
||||
assertGt(uint256(messageQueue.getCrossDomainMessage(i)), 0);
|
||||
@@ -449,7 +465,7 @@ contract ScrollChainTest is DSTestPlus {
|
||||
}
|
||||
// 9 ~ 265, even is nonzero, odd is zero
|
||||
for (uint256 i = 9; i < 265; i++) {
|
||||
if (i % 2 == 1) {
|
||||
if (i % 2 == 1 || i == 264) {
|
||||
assertEq(messageQueue.getCrossDomainMessage(i), bytes32(0));
|
||||
} else {
|
||||
assertGt(uint256(messageQueue.getCrossDomainMessage(i)), 0);
|
||||
|
||||
@@ -5,28 +5,38 @@ IMAGE_VERSION=latest
|
||||
REPO_ROOT_DIR=./..
|
||||
|
||||
ifeq (4.3,$(firstword $(sort $(MAKE_VERSION) 4.3)))
|
||||
ZKEVM_VERSION=$(shell grep -m 1 "scroll-prover" ../common/libzkp/impl/Cargo.lock | cut -d "#" -f2 | cut -c-7)
|
||||
HALO2_VERSION=$(shell grep -m 1 "halo2.git" ../common/libzkp/impl/Cargo.lock | cut -d "#" -f2 | cut -c-7)
|
||||
ZKEVM_VERSION=$(shell grep -m 1 "scroll-prover" ../common/libzkp/impl/Cargo.lock.new | cut -d "#" -f2 | cut -c-7)
|
||||
HALO2_VERSION=$(shell grep -m 1 "halo2.git" ../common/libzkp/impl/Cargo.lock.new | cut -d "#" -f2 | cut -c-7)
|
||||
OLD_ZKEVM_VERSION=$(shell grep -m 1 "scroll-prover" ../common/libzkp/impl/Cargo.lock.old | cut -d "#" -f2 | cut -c-7)
|
||||
OLD_HALO2_VERSION=$(shell grep -m 1 "halo2.git" ../common/libzkp/impl/Cargo.lock.old | cut -d "#" -f2 | cut -c-7)
|
||||
else
|
||||
ZKEVM_VERSION=$(shell grep -m 1 "scroll-prover" ../common/libzkp/impl/Cargo.lock | cut -d "\#" -f2 | cut -c-7)
|
||||
HALO2_VERSION=$(shell grep -m 1 "halo2.git" ../common/libzkp/impl/Cargo.lock | cut -d "\#" -f2 | cut -c-7)
|
||||
ZKEVM_VERSION=$(shell grep -m 1 "scroll-prover" ../common/libzkp/impl/Cargo.lock.new | cut -d "\#" -f2 | cut -c-7)
|
||||
HALO2_VERSION=$(shell grep -m 1 "halo2.git" ../common/libzkp/impl/Cargo.lock.new | cut -d "\#" -f2 | cut -c-7)
|
||||
OLD_ZKEVM_VERSION=$(shell grep -m 1 "scroll-prover" ../common/libzkp/impl/Cargo.lock.old | cut -d "\#" -f2 | cut -c-7)
|
||||
OLD_HALO2_VERSION=$(shell grep -m 1 "halo2.git" ../common/libzkp/impl/Cargo.lock.old | cut -d "\#" -f2 | cut -c-7)
|
||||
endif
|
||||
|
||||
ZK_VERSION=${ZKEVM_VERSION}-${HALO2_VERSION}
|
||||
OLD_ZK_VERSION=${OLD_ZKEVM_VERSION}-${OLD_HALO2_VERSION}
|
||||
|
||||
pre-upgrade-zk:
|
||||
cd ../common/libzkp/impl && cp Cargo.lock.old Cargo.lock && cargo clean && cargo build --release && cp ./target/release/libzkp.so ../interface/liboldzkp.so
|
||||
cp -r ../common/libzkp/interface ./internal/logic/old_verifier/lib && rm ../common/libzkp/interface/liboldzkp.so
|
||||
find ../common | grep libzktrie.so | xargs -I{} cp {} ./internal/logic/old_verifier/lib/liboldzktrie.so
|
||||
|
||||
test:
|
||||
go test -v -race -coverprofile=coverage.txt -covermode=atomic -p 1 $(PWD)/...
|
||||
|
||||
libzkp:
|
||||
cd ../common/libzkp/impl && cargo clean && cargo build --release && cp ./target/release/libzkp.so ../interface/
|
||||
rm -rf ./internal/logic/verifier/lib && cp -r ../common/libzkp/interface ./internal/logic/verifier/lib
|
||||
libzkp: pre-upgrade-zk
|
||||
cd ../common/libzkp/impl && cp Cargo.lock.new Cargo.lock && cargo clean && cargo build --release && cp ./target/release/libzkp.so ../interface/
|
||||
cp -r ../common/libzkp/interface ./internal/logic/verifier/lib
|
||||
find ../common | grep libzktrie.so | xargs -I{} cp {} ./internal/logic/verifier/lib
|
||||
|
||||
coordinator: libzkp ## Builds the Coordinator instance.
|
||||
go build -ldflags "-X scroll-tech/common/version.ZkVersion=${ZK_VERSION}" -o $(PWD)/build/bin/coordinator ./cmd
|
||||
go build -ldflags "-X scroll-tech/common/version.ZkVersion=${ZK_VERSION} -X scroll-tech/common/version.OldZkVersion=${OLD_ZK_VERSION}" -o $(PWD)/build/bin/coordinator ./cmd
|
||||
|
||||
coordinator_skip_libzkp:
|
||||
go build -ldflags "-X scroll-tech/common/version.ZkVersion=${ZK_VERSION}" -o $(PWD)/build/bin/coordinator ./cmd
|
||||
go build -ldflags "-X scroll-tech/common/version.ZkVersion=${ZK_VERSION} -X scroll-tech/common/version.OldZkVersion=${OLD_ZK_VERSION}" -o $(PWD)/build/bin/coordinator ./cmd
|
||||
|
||||
mock_coordinator: ## Builds the mocked Coordinator instance.
|
||||
go build -tags="mock_prover mock_verifier" -o $(PWD)/build/bin/coordinator ./cmd
|
||||
|
||||
@@ -8,6 +8,11 @@
|
||||
"params_path": "",
|
||||
"assets_path": ""
|
||||
},
|
||||
"old_verifier": {
|
||||
"mock_mode": true,
|
||||
"params_path": "",
|
||||
"assets_path": ""
|
||||
},
|
||||
"max_verifier_workers": 4
|
||||
},
|
||||
"db": {
|
||||
|
||||
@@ -17,6 +17,8 @@ type ProverManager struct {
|
||||
SessionAttempts uint8 `json:"session_attempts"`
|
||||
// Zk verifier config.
|
||||
Verifier *VerifierConfig `json:"verifier"`
|
||||
// Old Zk version config
|
||||
OldVerifier *VerifierConfig `json:"old_verifier"`
|
||||
// Proof collection time (in seconds).
|
||||
CollectionTimeSec int `json:"collection_time_sec"`
|
||||
// Max number of workers in verifier worker pool
|
||||
|
||||
35
coordinator/internal/logic/old_verifier/mock.go
Normal file
35
coordinator/internal/logic/old_verifier/mock.go
Normal file
@@ -0,0 +1,35 @@
|
||||
//go:build mock_verifier
|
||||
|
||||
package old_verifier
|
||||
|
||||
import (
|
||||
"scroll-tech/common/types/message"
|
||||
|
||||
"scroll-tech/coordinator/internal/config"
|
||||
)
|
||||
|
||||
const InvalidTestProof = "this is a invalid proof"
|
||||
|
||||
// OldVerifier represents a mock halo2 verifier.
|
||||
type OldVerifier struct{}
|
||||
|
||||
// NewVerifier Sets up a mock verifier.
|
||||
func NewOldVerifier(_ *config.VerifierConfig) (*OldVerifier, error) {
|
||||
return &OldVerifier{}, nil
|
||||
}
|
||||
|
||||
// VerifyChunkProof return a mock verification result for a ChunkProof.
|
||||
func (v *OldVerifier) VerifyChunkProof(proof *message.ChunkProof) (bool, error) {
|
||||
if string(proof.Proof) == InvalidTestProof {
|
||||
return false, nil
|
||||
}
|
||||
return true, nil
|
||||
}
|
||||
|
||||
// VerifyBatchProof return a mock verification result for a BatchProof.
|
||||
func (v *OldVerifier) VerifyBatchProof(proof *message.BatchProof) (bool, error) {
|
||||
if string(proof.Proof) == InvalidTestProof {
|
||||
return false, nil
|
||||
}
|
||||
return true, nil
|
||||
}
|
||||
98
coordinator/internal/logic/old_verifier/old_verifier.go
Normal file
98
coordinator/internal/logic/old_verifier/old_verifier.go
Normal file
@@ -0,0 +1,98 @@
|
||||
//go:build !mock_verifier
|
||||
|
||||
package old_verifier
|
||||
|
||||
/*
|
||||
#cgo LDFLAGS: -loldzkp -lm -ldl -loldzktrie -L${SRCDIR}/lib/ -Wl,-rpath=${SRCDIR}/lib
|
||||
#cgo gpu LDFLAGS: -loldzkp -lm -ldl -lgmp -lstdc++ -lprocps -loldzktrie -L/usr/local/cuda/lib64/ -lcudart -L${SRCDIR}/lib/ -Wl,-rpath=${SRCDIR}/lib
|
||||
#include <stdlib.h>
|
||||
#include "./lib/libzkp.h"
|
||||
*/
|
||||
import "C" //nolint:typecheck
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"scroll-tech/common/types/message"
|
||||
"unsafe"
|
||||
|
||||
"scroll-tech/coordinator/internal/logic/verifier"
|
||||
|
||||
"github.com/scroll-tech/go-ethereum/log"
|
||||
|
||||
"scroll-tech/coordinator/internal/config"
|
||||
)
|
||||
|
||||
// OldVerifier represents a rust ffi to a halo2 verifier.
|
||||
type OldVerifier struct {
|
||||
cfg *config.VerifierConfig
|
||||
}
|
||||
|
||||
// NewOldVerifier Sets up a rust ffi to call verify.
|
||||
func NewOldVerifier(cfg *config.VerifierConfig) (*OldVerifier, error) {
|
||||
if cfg.MockMode {
|
||||
return &OldVerifier{cfg: cfg}, nil
|
||||
}
|
||||
paramsPathStr := C.CString(cfg.ParamsPath)
|
||||
assetsPathStr := C.CString(cfg.AssetsPath)
|
||||
defer func() {
|
||||
C.free(unsafe.Pointer(paramsPathStr))
|
||||
C.free(unsafe.Pointer(assetsPathStr))
|
||||
}()
|
||||
|
||||
log.Info("Init old verifier!")
|
||||
|
||||
C.init_batch_verifier(paramsPathStr, assetsPathStr)
|
||||
C.init_chunk_verifier(paramsPathStr, assetsPathStr)
|
||||
|
||||
return &OldVerifier{cfg: cfg}, nil
|
||||
}
|
||||
|
||||
// VerifyBatchProof Verify a ZkProof by marshaling it and sending it to the Halo2 OldVerifier.
|
||||
func (v *OldVerifier) VerifyBatchProof(proof *message.BatchProof) (bool, error) {
|
||||
if v.cfg.MockMode {
|
||||
log.Info("Mock mode, batch verifier disabled")
|
||||
if string(proof.Proof) == verifier.InvalidTestProof {
|
||||
return false, nil
|
||||
}
|
||||
return true, nil
|
||||
|
||||
}
|
||||
buf, err := json.Marshal(proof)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
proofStr := C.CString(string(buf))
|
||||
defer func() {
|
||||
C.free(unsafe.Pointer(proofStr))
|
||||
}()
|
||||
|
||||
log.Info("Start to verify batch proof ...")
|
||||
verified := C.verify_batch_proof(proofStr)
|
||||
return verified != 0, nil
|
||||
}
|
||||
|
||||
// VerifyChunkProof Verify a ZkProof by marshaling it and sending it to the Halo2 OldVerifier.
|
||||
func (v *OldVerifier) VerifyChunkProof(proof *message.ChunkProof) (bool, error) {
|
||||
if v.cfg.MockMode {
|
||||
log.Info("Mock mode, verifier disabled")
|
||||
if string(proof.Proof) == verifier.InvalidTestProof {
|
||||
return false, nil
|
||||
}
|
||||
return true, nil
|
||||
|
||||
}
|
||||
buf, err := json.Marshal(proof)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
proofStr := C.CString(string(buf))
|
||||
defer func() {
|
||||
C.free(unsafe.Pointer(proofStr))
|
||||
}()
|
||||
|
||||
log.Info("Start to verify chunk proof ...")
|
||||
verified := C.verify_chunk_proof(proofStr)
|
||||
return verified != 0, nil
|
||||
}
|
||||
@@ -5,8 +5,13 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"scroll-tech/common/version"
|
||||
"time"
|
||||
|
||||
"scroll-tech/coordinator/internal/logic/old_verifier"
|
||||
|
||||
jwt "github.com/appleboy/gin-jwt/v2"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/prometheus/client_golang/prometheus/promauto"
|
||||
@@ -27,6 +32,8 @@ var (
|
||||
ErrValidatorFailureProofMsgStatusNotOk = errors.New("validator failure proof msg status not ok")
|
||||
// ErrValidatorFailureProverTaskEmpty get none prover task
|
||||
ErrValidatorFailureProverTaskEmpty = errors.New("validator failure get none prover task for the proof")
|
||||
// ErrInvalidProverVersion means prover version is invalid.
|
||||
ErrInvalidProverVersion = errors.New("prover version invalid")
|
||||
// ErrValidatorFailureProverTaskCannotSubmitTwice prove task can not submit proof twice
|
||||
ErrValidatorFailureProverTaskCannotSubmitTwice = errors.New("validator failure prove task cannot submit proof twice")
|
||||
// ErrValidatorFailureProofTimeout the submit proof is timeout
|
||||
@@ -44,7 +51,8 @@ type ProofReceiverLogic struct {
|
||||
db *gorm.DB
|
||||
cfg *config.ProverManager
|
||||
|
||||
verifier *verifier.Verifier
|
||||
verifier *verifier.Verifier
|
||||
oldVerifier *old_verifier.OldVerifier
|
||||
|
||||
proofReceivedTotal prometheus.Counter
|
||||
proofSubmitFailure prometheus.Counter
|
||||
@@ -64,6 +72,10 @@ func NewSubmitProofReceiverLogic(cfg *config.ProverManager, db *gorm.DB, reg pro
|
||||
if err != nil {
|
||||
panic("proof receiver new verifier failure")
|
||||
}
|
||||
oldVf, err := old_verifier.NewOldVerifier(cfg.OldVerifier)
|
||||
if err != nil {
|
||||
panic("proof receiver new OldVerifier failure")
|
||||
}
|
||||
return &ProofReceiverLogic{
|
||||
chunkOrm: orm.NewChunk(db),
|
||||
batchOrm: orm.NewBatch(db),
|
||||
@@ -72,7 +84,8 @@ func NewSubmitProofReceiverLogic(cfg *config.ProverManager, db *gorm.DB, reg pro
|
||||
cfg: cfg,
|
||||
db: db,
|
||||
|
||||
verifier: vf,
|
||||
verifier: vf,
|
||||
oldVerifier: oldVf,
|
||||
|
||||
proofReceivedTotal: promauto.With(reg).NewCounter(prometheus.CounterOpts{
|
||||
Name: "coordinator_submit_proof_total",
|
||||
@@ -150,9 +163,9 @@ func (m *ProofReceiverLogic) HandleZkProof(ctx *gin.Context, proofMsg *message.P
|
||||
var success bool
|
||||
var verifyErr error
|
||||
if proofMsg.Type == message.ProofTypeChunk {
|
||||
success, verifyErr = m.verifier.VerifyChunkProof(proofMsg.ChunkProof)
|
||||
success, verifyErr = m.verifyChunkProof(ctx, proofMsg.ChunkProof)
|
||||
} else if proofMsg.Type == message.ProofTypeBatch {
|
||||
success, verifyErr = m.verifier.VerifyBatchProof(proofMsg.BatchProof)
|
||||
success, verifyErr = m.verifyBatchProof(ctx, proofMsg.BatchProof)
|
||||
}
|
||||
|
||||
if verifyErr != nil || !success {
|
||||
@@ -383,3 +396,27 @@ func (m *ProofReceiverLogic) updateProverTaskProof(ctx context.Context, pk strin
|
||||
}
|
||||
return m.proverTaskOrm.UpdateProverTaskProof(ctx, proofMsg.Type, proofMsg.ID, pk, proofBytes)
|
||||
}
|
||||
|
||||
func (m *ProofReceiverLogic) verifyChunkProof(c *gin.Context, proof *message.ChunkProof) (bool, error) {
|
||||
claims := jwt.ExtractClaims(c)
|
||||
proverVersion := claims[coordinatorType.ProverVersion]
|
||||
switch proverVersion.(string) {
|
||||
case version.Version:
|
||||
return m.verifier.VerifyChunkProof(proof)
|
||||
case version.OldVersion:
|
||||
return m.oldVerifier.VerifyChunkProof(proof)
|
||||
}
|
||||
return false, ErrInvalidProverVersion
|
||||
}
|
||||
|
||||
func (m *ProofReceiverLogic) verifyBatchProof(c *gin.Context, proof *message.BatchProof) (bool, error) {
|
||||
claims := jwt.ExtractClaims(c)
|
||||
proverVersion := claims[coordinatorType.ProverVersion]
|
||||
switch proverVersion.(string) {
|
||||
case version.Version:
|
||||
return m.verifier.VerifyBatchProof(proof)
|
||||
case version.OldVersion:
|
||||
return m.oldVerifier.VerifyBatchProof(proof)
|
||||
}
|
||||
return false, ErrInvalidProverVersion
|
||||
}
|
||||
|
||||
@@ -41,6 +41,8 @@ func NewVerifier(cfg *config.VerifierConfig) (*Verifier, error) {
|
||||
C.free(unsafe.Pointer(assetsPathStr))
|
||||
}()
|
||||
|
||||
log.Info("Init verifier!")
|
||||
|
||||
C.init_batch_verifier(paramsPathStr, assetsPathStr)
|
||||
C.init_chunk_verifier(paramsPathStr, assetsPathStr)
|
||||
|
||||
|
||||
@@ -109,7 +109,8 @@ func setupCoordinator(t *testing.T, proversPerSession uint8, coordinatorURL stri
|
||||
}
|
||||
|
||||
func setEnv(t *testing.T) {
|
||||
version.Version = "v1.2.3-aaa-bbb-ccc"
|
||||
version.Version = "v1.2.3-commit-prover-halo2"
|
||||
version.OldZkVersion = "prover_old"
|
||||
|
||||
base = docker.NewDockerApp()
|
||||
base.RunDBImage(t)
|
||||
|
||||
@@ -5,6 +5,7 @@ DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" > /dev/null 2>&1 && pwd)"
|
||||
PROJ_DIR=$DIR"/.."
|
||||
|
||||
mkdir -p $PROJ_DIR/assets/params
|
||||
wget https://circuit-release.s3.us-west-2.amazonaws.com/circuit-release/release-1220/test_seed -O $PROJ_DIR/assets/seed
|
||||
wget https://circuit-release.s3.us-west-2.amazonaws.com/circuit-release/params-0320/params20 -O $PROJ_DIR/assets/params/params20
|
||||
wget https://circuit-release.s3.us-west-2.amazonaws.com/circuit-release/params-0320/params26 -O $PROJ_DIR/assets/params/params26
|
||||
wget https://circuit-release.s3.us-west-2.amazonaws.com/setup/params19 -O $PROJ_DIR/assets/params/params19
|
||||
wget https://circuit-release.s3.us-west-2.amazonaws.com/setup/params20 -O $PROJ_DIR/assets/params/params20
|
||||
wget https://circuit-release.s3.us-west-2.amazonaws.com/setup/params24 -O $PROJ_DIR/assets/params/params24
|
||||
wget https://circuit-release.s3.us-west-2.amazonaws.com/setup/params25 -O $PROJ_DIR/assets/params/params25
|
||||
Reference in New Issue
Block a user