11use eyre:: Result ;
22use sbv_core:: BlockWitness ;
3- use sbv_primitives:: B256 ;
3+ use sbv_primitives:: { types :: consensus :: BlockHeader , B256 } ;
44use scroll_zkvm_types:: {
5- chunk:: { execute, ChunkInfo , ChunkWitness , LegacyChunkWitness , SecretKey } ,
5+ chunk:: { execute, ChunkInfo , ChunkWitness , LegacyChunkWitness , ValidiumInputs } ,
66 task:: ProvingTask ,
77 utils:: { to_rkyv_bytes, RancorError } ,
88 version:: Version ,
@@ -14,7 +14,7 @@ use super::chunk_interpreter::*;
1414#[ derive( Debug , Clone , serde:: Serialize , serde:: Deserialize ) ]
1515pub struct ChunkTask {
1616 /// The version for the chunk, as per [`Version`].
17- pub version : Version ,
17+ pub version : u8 ,
1818 /// block hashes for a series of block
1919 pub block_hashes : Vec < B256 > ,
2020 /// The on-chain L1 msg queue hash before applying L1 msg txs from the chunk.
@@ -26,6 +26,7 @@ pub struct ChunkTask {
2626impl TryFromWithInterpreter < ChunkTask > for ChunkProvingTask {
2727 fn try_from_with_interpret (
2828 value : ChunkTask ,
29+ decryption_key : Option < & [ u8 ] > ,
2930 interpreter : impl ChunkInterpreter ,
3031 ) -> Result < Self > {
3132 let mut block_witnesses = Vec :: new ( ) ;
@@ -35,11 +36,27 @@ impl TryFromWithInterpreter<ChunkTask> for ChunkProvingTask {
3536 block_witnesses. push ( witness) ;
3637 }
3738
39+ let validium_txs = if Version :: from ( value. version ) . is_validium ( ) {
40+ let mut validium_txs = Vec :: new ( ) ;
41+ for block_number in block_witnesses. iter ( ) . map ( |w| w. header . number ( ) ) {
42+ validium_txs. push ( interpreter. try_fetch_l1_msgs ( block_number) ?) ;
43+ }
44+ validium_txs
45+ } else {
46+ vec ! [ ]
47+ } ;
48+
49+ let validium_inputs = decryption_key. map ( |secret_key| ValidiumInputs {
50+ validium_txs,
51+ secret_key : secret_key. into ( ) ,
52+ } ) ;
53+
3854 Ok ( Self {
3955 version : value. version ,
4056 block_witnesses,
4157 prev_msg_queue_hash : value. prev_msg_queue_hash ,
4258 fork_name : value. fork_name ,
59+ validium_inputs,
4360 } )
4461 }
4562}
@@ -61,6 +78,8 @@ pub struct ChunkProvingTask {
6178 pub prev_msg_queue_hash : B256 ,
6279 /// Fork name specify
6380 pub fork_name : String ,
81+ /// Optional inputs in case of domain=validium.
82+ pub validium_inputs : Option < ValidiumInputs > ,
6483}
6584
6685#[ derive( Clone , Debug ) ]
@@ -134,14 +153,15 @@ impl ChunkProvingTask {
134153
135154 fn build_guest_input ( & self ) -> ChunkWitness {
136155 let version = Version :: from ( self . version ) ;
156+
137157 if version. is_validium ( ) {
138- ChunkWitness :: new_validium (
158+ assert ! ( self . validium_inputs. is_some( ) ) ;
159+ ChunkWitness :: new (
139160 version. as_version_byte ( ) ,
140161 & self . block_witnesses ,
141162 self . prev_msg_queue_hash ,
142163 version. fork ,
143- vec ! [ ] , // TODO: validium txs
144- SecretKey :: try_from_bytes ( vec ! [ 0 ; 32 ] ) . expect ( "should be ok" ) , // TODO: secret key
164+ self . validium_inputs . clone ( ) ,
145165 )
146166 } else {
147167 ChunkWitness :: new_scroll (
0 commit comments