Skip to content

Commit d319678

Browse files
committed
add the optional bundle info
1 parent 0364057 commit d319678

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

common/types/message/message.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ type BatchTaskDetail struct {
103103

104104
// BundleTaskDetail consists of all the information required to describe the task to generate a proof for a bundle of batches.
105105
type BundleTaskDetail struct {
106-
BatchProofs []BatchProof `json:"batch_proofs"`
106+
BatchProofs []BatchProof `json:"batch_proofs"`
107+
BundleInfo *OpenVMBundleInfo `json:"bundle_info,omitempty"`
107108
}
108109

109110
// ChunkInfo is for calculating pi_hash for chunk
@@ -384,7 +385,7 @@ type OpenVMBundleInfo struct {
384385
NumBatches uint32 `json:"num_batches"`
385386
PrevBatchHash common.Hash `json:"prev_batch_hash"`
386387
BatchHash common.Hash `json:"batch_hash"`
387-
MsgQueueHash common.Hash `json:"msg_queue_hash"`
388+
MsgQueueHash common.Hash `json:"msg_queue_hash,omitempty"`
388389
}
389390

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

coordinator/internal/logic/provertask/bundle_prover_task.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"github.com/gin-gonic/gin"
1010
"github.com/prometheus/client_golang/prometheus"
1111
"github.com/prometheus/client_golang/prometheus/promauto"
12+
"github.com/scroll-tech/go-ethereum/common"
1213
"github.com/scroll-tech/go-ethereum/log"
1314
"github.com/scroll-tech/go-ethereum/params"
1415
"gorm.io/gorm"
@@ -194,6 +195,11 @@ func (bp *BundleProverTask) formatProverTask(ctx context.Context, task *orm.Prov
194195
return nil, fmt.Errorf("failed to get batch proofs for bundle task id:%s, no batch found", task.TaskID)
195196
}
196197

198+
parentBatch, err := bp.batchOrm.GetBatchByHash(ctx, batches[0].ParentBatchHash)
199+
if err != nil {
200+
return nil, fmt.Errorf("failed to get parent batch for batch task id:%s err:%w", task.TaskID, err)
201+
}
202+
197203
var batchProofs []message.BatchProof
198204
for _, batch := range batches {
199205
proof := message.NewBatchProof(hardForkName)
@@ -207,6 +213,17 @@ func (bp *BundleProverTask) formatProverTask(ctx context.Context, task *orm.Prov
207213
BatchProofs: batchProofs,
208214
}
209215

216+
taskDetail.BundleInfo = &message.OpenVMBundleInfo{
217+
ChainID: bp.chainCfg.ChainID.Uint64(),
218+
PrevStateRoot: common.HexToHash(parentBatch.StateRoot),
219+
PostStateRoot: common.HexToHash(batches[len(batches)-1].StateRoot),
220+
WithdrawRoot: common.HexToHash(batches[len(batches)-1].WithdrawRoot),
221+
NumBatches: uint32(len(batches)),
222+
PrevBatchHash: common.HexToHash(batches[0].ParentBatchHash),
223+
BatchHash: common.HexToHash(batches[len(batches)-1].Hash),
224+
// MsgQueueHash is omittable here, because it is introduced in phase-2.
225+
}
226+
210227
batchProofsBytes, err := json.Marshal(taskDetail)
211228
if err != nil {
212229
return nil, fmt.Errorf("failed to marshal batch proofs, taskID:%s err:%w", task.TaskID, err)

0 commit comments

Comments
 (0)