Skip to content

Commit

Permalink
wip: add last applied l1 block to chunk data
Browse files Browse the repository at this point in the history
  • Loading branch information
lastminutedev committed Nov 21, 2023
1 parent 49ecf53 commit 9037ce9
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
2 changes: 2 additions & 0 deletions common/types/message/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ type TaskMsg struct {
type ChunkTaskDetail struct {
BlockHashes []common.Hash `json:"block_hashes"`
PrevLastAppliedL1Block uint64 `json:"prev_last_applied_l1_block"`
LastAppliedL1Block uint64 `json:"last_applied_l1_block"`
L1BlockRangeHash common.Hash `json:"l1_block_range_hash"`
}

Expand Down Expand Up @@ -280,6 +281,7 @@ type ChunkProof struct {
type ChunkTrace struct {
BlockTraces []*types.BlockTrace `json:"block_traces"`
PrevLastAppliedL1Block uint64 `json:"prev_last_applied_l1_block"`
LastAppliedL1Block uint64 `json:"last_applied_l1_block"`
L1BlockRangeHash common.Hash `json:"l1_block_range_hash"`
}

Expand Down
3 changes: 2 additions & 1 deletion coordinator/internal/logic/provertask/chunk_prover_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ func (cp *ChunkProverTask) formatProverTask(ctx context.Context, task *orm.Prove
}
return 0
}(),
L1BlockRangeHash: common.HexToHash(chunk.L1BlockRangeHash),
LastAppliedL1Block: chunk.LastAppliedL1Block,
L1BlockRangeHash: common.HexToHash(chunk.L1BlockRangeHash),
}
taskDataBytes, err := json.Marshal(taskDetail)
if err != nil {
Expand Down
9 changes: 7 additions & 2 deletions prover/core/prover.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,15 +208,20 @@ func (p *ProverCore) proveBatch(chunkInfosByt []byte, chunkProofsByt []byte) ([]
return result.Message, nil
}

func (p *ProverCore) proveChunk(chunkTraceByt []byte, prevLastAppliedL1Block uint64, l1BlockRangeHash []byte) ([]byte, error) {
func (p *ProverCore) proveChunk(chunkTraceByt []byte, prevLastAppliedL1Block uint64, lastAppliedL1Block uint64, l1BlockRangeHash []byte) ([]byte, error) {
chunkTraceBytStr := C.CString(string(chunkTraceByt))
defer C.free(unsafe.Pointer(chunkTraceBytStr))

l1BlockRangeHashStr := C.CString(string(l1BlockRangeHash))
defer C.free(unsafe.Pointer(l1BlockRangeHashStr))

log.Info("Start to create chunk proof ...")
cProof := C.gen_chunk_proof(tracesStr, C.uint64_t(prevLastAppliedL1Block), l1BlockRangeHashStr)
cProof := C.gen_chunk_proof(
tracesStr,
C.uint64_t(prevLastAppliedL1Block),
C.uint64_t(lastAppliedL1Block),
l1BlockRangeHashStr,
)
defer C.free_c_chars(cProof)
log.Info("Finish creating chunk proof!")

Expand Down
1 change: 1 addition & 0 deletions prover/prover.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ func (r *Prover) proveChunk(task *store.ProvingTask) (*message.ChunkProof, error
chunkTrace := message.ChunkTrace{
BlockTraces: traces,
PrevLastAppliedL1Block: task.Task.ChunkTaskDetail.PrevLastAppliedL1Block,
LastAppliedL1Block: task.Task.ChunkTaskDetail.LastAppliedL1Block,
L1BlockRangeHash: task.Task.ChunkTaskDetail.L1BlockRangeHash,
}
return r.proverCore.ProveChunk(
Expand Down

0 comments on commit 9037ce9

Please sign in to comment.