Skip to content

Commit 07ebd01

Browse files
committed
feat: add more arguments to task and metadata
1 parent 342c015 commit 07ebd01

File tree

7 files changed

+47
-25
lines changed

7 files changed

+47
-25
lines changed

common/types/message/message.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ 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"`
@@ -90,6 +91,7 @@ func (e *Byte48) UnmarshalJSON(input []byte) error {
9091

9192
// BatchTaskDetail is a type containing BatchTask detail.
9293
type BatchTaskDetail struct {
94+
Version uint8 `json:"version"`
9395
// use one of the string of "euclidv1" / "euclidv2"
9496
ForkName string `json:"fork_name"`
9597
ChunkInfos []*ChunkInfo `json:"chunk_infos"`
@@ -103,6 +105,7 @@ type BatchTaskDetail struct {
103105

104106
// BundleTaskDetail consists of all the information required to describe the task to generate a proof for a bundle of batches.
105107
type BundleTaskDetail struct {
108+
Version uint8 `json:"version"`
106109
// use one of the string of "euclidv1" / "euclidv2"
107110
ForkName string `json:"fork_name"`
108111
BatchProofs []*OpenVMBatchProof `json:"batch_proofs"`
@@ -124,6 +127,9 @@ type ChunkInfo struct {
124127
TxDataLength uint64 `json:"tx_data_length"`
125128
InitialBlockNumber uint64 `json:"initial_block_number"`
126129
BlockCtxs []BlockContextV2 `json:"block_ctxs"`
130+
PrevBlockhash common.Hash `json:"prev_blockhash"`
131+
PostBlockhash common.Hash `json:"post_blockhash"`
132+
EncryptionKey []byte `json:"encryption_key"`
127133
}
128134

129135
// BlockContextV2 is the block context for euclid v2
@@ -186,6 +192,7 @@ type OpenVMBatchInfo struct {
186192
ChainID uint64 `json:"chain_id"`
187193
PrevMsgQueueHash common.Hash `json:"prev_msg_queue_hash"`
188194
PostMsgQueueHash common.Hash `json:"post_msg_queue_hash"`
195+
EncryptionKey []byte `json:"encryption_key"`
189196
}
190197

191198
// BatchProof includes the proof info that are required for batch verification and rollup.
@@ -246,6 +253,7 @@ type OpenVMBundleInfo struct {
246253
PrevBatchHash common.Hash `json:"prev_batch_hash"`
247254
BatchHash common.Hash `json:"batch_hash"`
248255
MsgQueueHash common.Hash `json:"msg_queue_hash"`
256+
EncryptionKey []byte `json:"encryption_key"`
249257
}
250258

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

coordinator/conf/config.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
{
1313
"assets_path": "assets",
1414
"fork_name": "euclidV2"
15-
},
15+
},
1616
{
1717
"assets_path": "assets",
1818
"fork_name": "feynman"
@@ -36,5 +36,8 @@
3636
"secret": "prover secret key",
3737
"challenge_expire_duration_sec": 3600,
3838
"login_expire_duration_sec": 3600
39+
},
40+
"sequencer": {
41+
"decryption_key": "sequencer decryption key"
3942
}
4043
}

coordinator/internal/config/config.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,18 @@ type Auth struct {
4747
LoginExpireDurationSec int `json:"login_expire_duration_sec"`
4848
}
4949

50+
// The sequencer controlled data
51+
type Sequencer struct {
52+
DecryptionKey string `json:"decryption_key"`
53+
}
54+
5055
// Config load configuration items.
5156
type Config struct {
5257
ProverManager *ProverManager `json:"prover_manager"`
5358
DB *database.Config `json:"db"`
5459
L2 *L2 `json:"l2"`
5560
Auth *Auth `json:"auth"`
61+
Sequencer *Sequencer `json:"sequencer"`
5662
}
5763

5864
// AssetConfig contain assets configurated for each fork, the defaul vkfile name is "OpenVmVk.json".

coordinator/internal/config/config_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@ func TestConfig(t *testing.T) {
4141
"secret": "prover secret key",
4242
"challenge_expire_duration_sec": 3600,
4343
"login_expire_duration_sec": 3600
44-
}
44+
},
45+
"sequencer": {
46+
"decryption_key": "sequencer decryption key"
47+
}
4548
}`
4649

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

crates/libzkp/src/tasks/batch.rs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ impl BatchHeaderV {
7373
#[derive(Clone, serde::Deserialize, serde::Serialize)]
7474
pub struct BatchProvingTask {
7575
/// The version of the chunks in the batch, as per [`Version`].
76-
pub version: Version,
76+
pub version: u8,
7777
/// Chunk proofs for the contiguous list of chunks within the batch.
7878
pub chunk_proofs: Vec<ChunkProof>,
7979
/// The [`BatchHeaderV6/V7`], as computed on-chain for this batch.
@@ -106,7 +106,7 @@ impl TryFrom<BatchProvingTask> for ProvingTask {
106106

107107
Ok(ProvingTask {
108108
identifier: value.batch_header.batch_hash().to_string(),
109-
fork_name: value.version.fork.to_string(),
109+
fork_name: value.fork_name,
110110
aggregated_proofs: value
111111
.chunk_proofs
112112
.into_iter()
@@ -120,7 +120,9 @@ impl TryFrom<BatchProvingTask> for ProvingTask {
120120

121121
impl BatchProvingTask {
122122
fn build_guest_input(&self) -> BatchWitness {
123-
let point_eval_witness = if !self.version.is_validium() {
123+
let version = Version::from(self.version);
124+
125+
let point_eval_witness = if !version.is_validium() {
124126
// sanity check: calculate point eval needed and compare with task input
125127
let (kzg_commitment, kzg_proof, challenge_digest) = {
126128
let blob = point_eval::to_blob(&self.blob_bytes);
@@ -129,10 +131,10 @@ impl BatchProvingTask {
129131
let challenge_digest = match &self.batch_header {
130132
BatchHeaderV::V6(_) => {
131133
assert_eq!(
132-
self.version.fork,
134+
version.fork,
133135
ForkName::EuclidV1,
134136
"hardfork mismatch for da-codec@v6 header: found={:?}, expected={:?}",
135-
self.version.fork,
137+
version.fork,
136138
ForkName::EuclidV1,
137139
);
138140
EnvelopeV6::from_slice(self.blob_bytes.as_slice())
@@ -145,7 +147,7 @@ impl BatchProvingTask {
145147
padded_blob_bytes
146148
};
147149

148-
match self.version.fork {
150+
match version.fork {
149151
ForkName::EuclidV2 => {
150152
<EnvelopeV7 as Envelope>::from_slice(padded_blob_bytes.as_slice())
151153
.challenge_digest(versioned_hash)
@@ -198,7 +200,7 @@ impl BatchProvingTask {
198200
None
199201
};
200202

201-
let reference_header = match (self.version.domain, self.version.stf_version) {
203+
let reference_header = match (version.domain, version.stf_version) {
202204
(Domain::Scroll, STFVersion::V6) => {
203205
ReferenceHeader::V6(*self.batch_header.must_v6_header())
204206
}
@@ -217,8 +219,8 @@ impl BatchProvingTask {
217219
};
218220

219221
BatchWitness {
220-
version: self.version.as_version_byte(),
221-
fork_name: self.version.fork,
222+
version: version.as_version_byte(),
223+
fork_name: version.fork,
222224
chunk_proofs: self.chunk_proofs.iter().map(|proof| proof.into()).collect(),
223225
chunk_infos: self
224226
.chunk_proofs
@@ -237,7 +239,7 @@ impl BatchProvingTask {
237239
// 2. validate every adjacent proof pair
238240
let witness = self.build_guest_input();
239241
let metadata = BatchInfo::from(&witness);
240-
super::check_aggregation_proofs(self.chunk_proofs.as_slice(), self.version)?;
242+
super::check_aggregation_proofs(self.chunk_proofs.as_slice(), Version::from(self.version))?;
241243

242244
Ok(metadata)
243245
}

crates/libzkp/src/tasks/bundle.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const BUNDLE_SANITY_MSG: &str = "bundle must have at least one batch";
1414
#[derive(Clone, serde::Deserialize, serde::Serialize)]
1515
pub struct BundleProvingTask {
1616
/// The version of batches in the bundle.
17-
pub version: Version,
17+
pub version: u8,
1818
/// The STARK proofs of each batch in the bundle.
1919
pub batch_proofs: Vec<BatchProof>,
2020
/// for sanity check
@@ -44,15 +44,16 @@ impl BundleProvingTask {
4444
}
4545

4646
fn build_guest_input(&self) -> BundleWitness {
47+
let version = Version::from(self.version);
4748
BundleWitness {
48-
version: self.version.as_version_byte(),
49+
version: version.as_version_byte(),
4950
batch_proofs: self.batch_proofs.iter().map(|proof| proof.into()).collect(),
5051
batch_infos: self
5152
.batch_proofs
5253
.iter()
5354
.map(|wrapped_proof| wrapped_proof.metadata.batch_info.clone())
5455
.collect(),
55-
fork_name: self.version.fork,
56+
fork_name: version.fork,
5657
}
5758
}
5859

@@ -62,7 +63,7 @@ impl BundleProvingTask {
6263
// 2. validate every adjacent proof pair
6364
let witness = self.build_guest_input();
6465
let metadata = BundleInfo::from(&witness);
65-
super::check_aggregation_proofs(self.batch_proofs.as_slice(), self.version)?;
66+
super::check_aggregation_proofs(self.batch_proofs.as_slice(), Version::from(self.version))?;
6667

6768
Ok(metadata)
6869
}

crates/libzkp/src/tasks/chunk.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ const CHUNK_SANITY_MSG: &str = "chunk must have at least one block";
5454
#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
5555
pub struct ChunkProvingTask {
5656
/// The version for the chunk, as per [Version][scroll_zkvm_types::version::Version].
57-
pub version: Version,
57+
pub version: u8,
5858
/// Witnesses for every block in the chunk.
5959
pub block_witnesses: Vec<BlockWitness>,
6060
/// The on-chain L1 msg queue hash before applying L1 msg txs from the chunk.
@@ -133,21 +133,22 @@ impl ChunkProvingTask {
133133
}
134134

135135
fn build_guest_input(&self) -> ChunkWitness {
136-
if self.version.is_validium() {
136+
let version = Version::from(self.version);
137+
if version.is_validium() {
137138
ChunkWitness::new_validium(
138-
self.version.as_version_byte(),
139+
version.as_version_byte(),
139140
&self.block_witnesses,
140141
self.prev_msg_queue_hash,
141-
self.version.fork,
142+
version.fork,
142143
vec![], // TODO: validium txs
143144
SecretKey::try_from_bytes(vec![0; 32]).expect("should be ok"), // TODO: secret key
144145
)
145146
} else {
146147
ChunkWitness::new_scroll(
147-
self.version.as_version_byte(),
148+
version.as_version_byte(),
148149
&self.block_witnesses,
149150
self.prev_msg_queue_hash,
150-
self.version.fork,
151+
version.fork,
151152
)
152153
}
153154
}
@@ -158,9 +159,7 @@ impl ChunkProvingTask {
158159

159160
pub fn precheck_and_build_metadata(&self) -> Result<ChunkInfo> {
160161
let witness = self.build_guest_input();
161-
162-
let ret = ChunkInfo::try_from(witness).map_err(|e| eyre::eyre!("{e}"))?;
163-
Ok(ret)
162+
Ok(ChunkInfo::try_from(witness).map_err(|e| eyre::eyre!("{e}"))?)
164163
}
165164

166165
/// this method check the validate of current task (there may be missing storage node)

0 commit comments

Comments
 (0)