@@ -808,9 +808,20 @@ func (r *Layer2Relayer) finalizeBundle(bundle *orm.Bundle, withProof bool) error
808808 }
809809 }
810810
811- calldata , err := r .constructFinalizeBundlePayloadCodecV4 (dbBatch , aggProof )
812- if err != nil {
813- return fmt .Errorf ("failed to construct finalizeBundle payload codecv3, index: %v, err: %w" , dbBatch .Index , err )
811+ var calldata []byte
812+ switch encoding .CodecVersion (bundle .CodecVersion ) {
813+ case encoding .CodecV4 , encoding .CodecV5 , encoding .CodecV6 :
814+ calldata , err = r .constructFinalizeBundlePayloadCodecV4 (dbBatch , aggProof )
815+ if err != nil {
816+ return fmt .Errorf ("failed to construct finalizeBundle payload codecv4, bundle index: %v, last batch index: %v, err: %w" , bundle .Index , dbBatch .Index , err )
817+ }
818+ case encoding .CodecV7 :
819+ calldata , err = r .constructFinalizeBundlePayloadCodecV7 (dbBatch , aggProof )
820+ if err != nil {
821+ return fmt .Errorf ("failed to construct finalizeBundle payload codecv7, bundle index: %v, last batch index: %v, err: %w" , bundle .Index , dbBatch .Index , err )
822+ }
823+ default :
824+ return fmt .Errorf ("unsupported codec version in finalizeBundle, bundle index: %v, version: %d" , bundle .Index , bundle .CodecVersion )
814825 }
815826
816827 txHash , err := r .finalizeSender .SendTransaction ("finalizeBundle-" + bundle .Hash , & r .cfg .RollupContractAddress , calldata , nil , 0 )
@@ -1174,6 +1185,37 @@ func (r *Layer2Relayer) constructFinalizeBundlePayloadCodecV4(dbBatch *orm.Batch
11741185 return calldata , nil
11751186}
11761187
1188+ func (r * Layer2Relayer ) constructFinalizeBundlePayloadCodecV7 (dbBatch * orm.Batch , aggProof * message.BundleProof ) ([]byte , error ) {
1189+ // TODO: update this once the contract interface is finalized
1190+ if aggProof != nil { // finalizeBundle with proof.
1191+ calldata , packErr := r .l1RollupABI .Pack (
1192+ "finalizeBundleWithProof" ,
1193+ dbBatch .BatchHeader ,
1194+ dbBatch .LastL1MessageQueueHash ,
1195+ common .HexToHash (dbBatch .StateRoot ),
1196+ common .HexToHash (dbBatch .WithdrawRoot ),
1197+ aggProof .Proof ,
1198+ )
1199+ if packErr != nil {
1200+ return nil , fmt .Errorf ("failed to pack finalizeBundleWithProof: %w" , packErr )
1201+ }
1202+ return calldata , nil
1203+ }
1204+
1205+ // finalizeBundle without proof.
1206+ calldata , packErr := r .l1RollupABI .Pack (
1207+ "finalizeBundle" ,
1208+ dbBatch .BatchHeader ,
1209+ dbBatch .LastL1MessageQueueHash ,
1210+ common .HexToHash (dbBatch .StateRoot ),
1211+ common .HexToHash (dbBatch .WithdrawRoot ),
1212+ )
1213+ if packErr != nil {
1214+ return nil , fmt .Errorf ("failed to pack finalizeBundle: %w" , packErr )
1215+ }
1216+ return calldata , nil
1217+ }
1218+
11771219// StopSenders stops the senders of the rollup-relayer to prevent querying the removed pending_transaction table in unit tests.
11781220// for unit test
11791221func (r * Layer2Relayer ) StopSenders () {
0 commit comments