Skip to content

Commit 6bee330

Browse files
lispcnoel2004roynalnarutoThegaram
authored
feat: the CLOAK privacy solution (#1737)
Co-authored-by: Ho <fan@scroll.io> Co-authored-by: Rohit Narurkar <rohit.narurkar@proton.me> Co-authored-by: Péter Garamvölgyi <peter@scroll.io>
1 parent 1985e54 commit 6bee330

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+1683
-409
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,12 @@ edition = "2021"
1414
homepage = "https://scroll.io"
1515
readme = "README.md"
1616
repository = "https://github.com/scroll-tech/scroll"
17-
version = "4.5.47"
17+
version = "4.6.3"
1818

1919
[workspace.dependencies]
20-
# include compatiblity fixing from "fix/coordinator"
21-
scroll-zkvm-prover = { git = "https://github.com/scroll-tech/zkvm-prover", rev = "a71dd2b" }
22-
scroll-zkvm-verifier = { git = "https://github.com/scroll-tech/zkvm-prover", rev = "a71dd2b" }
23-
scroll-zkvm-types = { git = "https://github.com/scroll-tech/zkvm-prover", rev = "a71dd2b" }
20+
scroll-zkvm-prover = { git = "https://github.com/scroll-tech/zkvm-prover", rev = "360f364" }
21+
scroll-zkvm-verifier = { git = "https://github.com/scroll-tech/zkvm-prover", rev = "360f364" }
22+
scroll-zkvm-types = { git = "https://github.com/scroll-tech/zkvm-prover", rev = "360f364" }
2423

2524
sbv-primitives = { git = "https://github.com/scroll-tech/stateless-block-verifier", branch = "master", features = ["scroll", "rkyv"] }
2625
sbv-utils = { git = "https://github.com/scroll-tech/stateless-block-verifier", branch = "master" }

common/testcontainers/testcontainers.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"time"
1111

1212
"github.com/scroll-tech/go-ethereum/ethclient"
13+
"github.com/scroll-tech/go-ethereum/rpc"
1314
"github.com/testcontainers/testcontainers-go"
1415
"github.com/testcontainers/testcontainers-go/modules/compose"
1516
"github.com/testcontainers/testcontainers-go/modules/postgres"
@@ -220,11 +221,21 @@ func (t *TestcontainerApps) GetGormDBClient() (*gorm.DB, error) {
220221

221222
// GetL2GethClient returns a ethclient by dialing running L2Geth
222223
func (t *TestcontainerApps) GetL2GethClient() (*ethclient.Client, error) {
224+
225+
rpcCli, err := t.GetL2Client()
226+
if err != nil {
227+
return nil, err
228+
}
229+
return ethclient.NewClient(rpcCli), nil
230+
}
231+
232+
// GetL2GethClient returns a rpc client by dialing running L2Geth
233+
func (t *TestcontainerApps) GetL2Client() (*rpc.Client, error) {
223234
endpoint, err := t.GetL2GethEndPoint()
224235
if err != nil {
225236
return nil, err
226237
}
227-
client, err := ethclient.Dial(endpoint)
238+
client, err := rpc.Dial(endpoint)
228239
if err != nil {
229240
return nil, err
230241
}

common/types/message/message.go

Lines changed: 38 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,12 @@ const (
3939

4040
// ChunkTaskDetail is a type containing ChunkTask detail for chunk task.
4141
type ChunkTaskDetail struct {
42+
Version uint8 `json:"version"`
4243
// use one of the string of "euclidv1" / "euclidv2"
4344
ForkName string `json:"fork_name"`
4445
BlockHashes []common.Hash `json:"block_hashes"`
4546
PrevMsgQueueHash common.Hash `json:"prev_msg_queue_hash"`
47+
PostMsgQueueHash common.Hash `json:"post_msg_queue_hash"`
4648
}
4749

4850
// it is a hex encoded big with fixed length on 48 bytes
@@ -90,40 +92,59 @@ func (e *Byte48) UnmarshalJSON(input []byte) error {
9092

9193
// BatchTaskDetail is a type containing BatchTask detail.
9294
type BatchTaskDetail struct {
95+
Version uint8 `json:"version"`
9396
// use one of the string of "euclidv1" / "euclidv2"
94-
ForkName string `json:"fork_name"`
95-
ChunkInfos []*ChunkInfo `json:"chunk_infos"`
96-
ChunkProofs []*OpenVMChunkProof `json:"chunk_proofs"`
97-
BatchHeader interface{} `json:"batch_header"`
98-
BlobBytes []byte `json:"blob_bytes"`
99-
KzgProof Byte48 `json:"kzg_proof,omitempty"`
100-
KzgCommitment Byte48 `json:"kzg_commitment,omitempty"`
101-
ChallengeDigest common.Hash `json:"challenge_digest,omitempty"`
97+
ForkName string `json:"fork_name"`
98+
ChunkProofs []*OpenVMChunkProof `json:"chunk_proofs"`
99+
BatchHeader interface{} `json:"batch_header"`
100+
BlobBytes []byte `json:"blob_bytes"`
101+
KzgProof *Byte48 `json:"kzg_proof,omitempty"`
102+
KzgCommitment *Byte48 `json:"kzg_commitment,omitempty"`
103+
// ChallengeDigest should be a common.Hash type if it is not nil
104+
ChallengeDigest interface{} `json:"challenge_digest,omitempty"`
102105
}
103106

104107
// BundleTaskDetail consists of all the information required to describe the task to generate a proof for a bundle of batches.
105108
type BundleTaskDetail struct {
109+
Version uint8 `json:"version"`
106110
// use one of the string of "euclidv1" / "euclidv2"
107111
ForkName string `json:"fork_name"`
108112
BatchProofs []*OpenVMBatchProof `json:"batch_proofs"`
109113
BundleInfo *OpenVMBundleInfo `json:"bundle_info,omitempty"`
110114
}
111115

116+
type RawBytes []byte
117+
118+
func (r RawBytes) MarshalJSON() ([]byte, error) {
119+
if r == nil {
120+
return []byte("null"), nil
121+
}
122+
// Marshal the []byte as a JSON array of numbers
123+
rn := make([]uint16, len(r))
124+
for i := range r {
125+
rn[i] = uint16(r[i])
126+
}
127+
return json.Marshal(rn)
128+
}
129+
112130
// ChunkInfo is for calculating pi_hash for chunk
113131
type ChunkInfo struct {
114-
ChainID uint64 `json:"chain_id"`
115-
PrevStateRoot common.Hash `json:"prev_state_root"`
116-
PostStateRoot common.Hash `json:"post_state_root"`
117-
WithdrawRoot common.Hash `json:"withdraw_root"`
118-
DataHash common.Hash `json:"data_hash"`
119-
IsPadding bool `json:"is_padding"`
120-
TxBytes []byte `json:"tx_bytes"`
132+
ChainID uint64 `json:"chain_id"`
133+
PrevStateRoot common.Hash `json:"prev_state_root"`
134+
PostStateRoot common.Hash `json:"post_state_root"`
135+
WithdrawRoot common.Hash `json:"withdraw_root"`
136+
DataHash common.Hash `json:"data_hash"`
137+
IsPadding bool `json:"is_padding"`
138+
// TxBytes []byte `json:"tx_bytes"`
121139
TxBytesHash common.Hash `json:"tx_data_digest"`
122140
PrevMsgQueueHash common.Hash `json:"prev_msg_queue_hash"`
123141
PostMsgQueueHash common.Hash `json:"post_msg_queue_hash"`
124142
TxDataLength uint64 `json:"tx_data_length"`
125143
InitialBlockNumber uint64 `json:"initial_block_number"`
126144
BlockCtxs []BlockContextV2 `json:"block_ctxs"`
145+
PrevBlockhash common.Hash `json:"prev_blockhash"`
146+
PostBlockhash common.Hash `json:"post_blockhash"`
147+
EncryptionKey RawBytes `json:"encryption_key"`
127148
}
128149

129150
// BlockContextV2 is the block context for euclid v2
@@ -186,6 +207,7 @@ type OpenVMBatchInfo struct {
186207
ChainID uint64 `json:"chain_id"`
187208
PrevMsgQueueHash common.Hash `json:"prev_msg_queue_hash"`
188209
PostMsgQueueHash common.Hash `json:"post_msg_queue_hash"`
210+
EncryptionKey RawBytes `json:"encryption_key"`
189211
}
190212

191213
// BatchProof includes the proof info that are required for batch verification and rollup.
@@ -246,6 +268,7 @@ type OpenVMBundleInfo struct {
246268
PrevBatchHash common.Hash `json:"prev_batch_hash"`
247269
BatchHash common.Hash `json:"batch_hash"`
248270
MsgQueueHash common.Hash `json:"msg_queue_hash"`
271+
EncryptionKey RawBytes `json:"encryption_key"`
249272
}
250273

251274
// OpenVMBundleProof includes the proof info that are required for verification of a bundle of batch proofs.

common/version/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"runtime/debug"
66
)
77

8-
var tag = "v4.6.1"
8+
var tag = "v4.6.3"
99

1010
var commit = func() string {
1111
if info, ok := debug.ReadBuildInfo(); ok {

coordinator/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ coordinator_tool:
3737
localsetup: coordinator_api ## Local setup: build coordinator_api, copy config, and setup releases
3838
mkdir -p build/bin/conf
3939
@echo "Copying configuration files..."
40-
cp -r $(PWD)/conf/config.json $(PWD)/build/bin/conf/config.template.json
40+
cp -fL $(CURDIR)/conf/config.json $(CURDIR)/build/bin/conf/config.template.json
4141
@echo "Setting up releases..."
42-
cd $(PWD)/build && bash setup_releases.sh
42+
cd $(CURDIR)/build && bash setup_releases.sh
4343

4444

4545
#coordinator_api_skip_libzkp:

coordinator/cmd/tool/verify.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func verify(cCtx *cli.Context) error {
3636
return fmt.Errorf("error reading file: %w", err)
3737
}
3838

39-
vf, err := verifier.NewVerifier(cfg.ProverManager.Verifier)
39+
vf, err := verifier.NewVerifier(cfg.ProverManager.Verifier, cfg.L2.ValidiumMode)
4040
if err != nil {
4141
return err
4242
}

coordinator/internal/config/config.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,9 @@ type L2Endpoint struct {
3636
// L2 loads l2geth configuration items.
3737
type L2 struct {
3838
// l2geth chain_id.
39-
ChainID uint64 `json:"chain_id"`
40-
Endpoint *L2Endpoint `json:"l2geth"`
39+
ChainID uint64 `json:"chain_id"`
40+
Endpoint *L2Endpoint `json:"l2geth"`
41+
ValidiumMode bool `json:"validium_mode"`
4142
}
4243

4344
// Auth provides the auth coordinator
@@ -47,17 +48,24 @@ type Auth struct {
4748
LoginExpireDurationSec int `json:"login_expire_duration_sec"`
4849
}
4950

51+
// The sequencer controlled data
52+
type Sequencer struct {
53+
DecryptionKey string `json:"decryption_key"`
54+
}
55+
5056
// Config load configuration items.
5157
type Config struct {
5258
ProverManager *ProverManager `json:"prover_manager"`
5359
DB *database.Config `json:"db"`
5460
L2 *L2 `json:"l2"`
5561
Auth *Auth `json:"auth"`
62+
Sequencer *Sequencer `json:"sequencer"`
5663
}
5764

5865
// AssetConfig contain assets configurated for each fork, the defaul vkfile name is "OpenVmVk.json".
5966
type AssetConfig struct {
6067
AssetsPath string `json:"assets_path"`
68+
Version uint8 `json:"version,omitempty"`
6169
ForkName string `json:"fork_name"`
6270
Vkfile string `json:"vk_file,omitempty"`
6371
MinProverVersion string `json:"min_prover_version,omitempty"`

coordinator/internal/config/config_test.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,17 @@ func TestConfig(t *testing.T) {
3535
"maxIdleNum": 20
3636
},
3737
"l2": {
38-
"chain_id": 111
38+
"chain_id": 111,
39+
"validium_mode": false
3940
},
4041
"auth": {
4142
"secret": "prover secret key",
4243
"challenge_expire_duration_sec": 3600,
4344
"login_expire_duration_sec": 3600
44-
}
45+
},
46+
"sequencer": {
47+
"decryption_key": "sequencer decryption key"
48+
}
4549
}`
4650

4751
t.Run("Success Case", func(t *testing.T) {

coordinator/internal/controller/api/controller.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ var (
2424

2525
// InitController inits Controller with database
2626
func InitController(cfg *config.Config, chainCfg *params.ChainConfig, db *gorm.DB, reg prometheus.Registerer) {
27-
vf, err := verifier.NewVerifier(cfg.ProverManager.Verifier)
27+
validiumMode := cfg.L2.ValidiumMode
28+
29+
vf, err := verifier.NewVerifier(cfg.ProverManager.Verifier, validiumMode)
2830
if err != nil {
2931
panic("proof receiver new verifier failure")
3032
}

0 commit comments

Comments
 (0)