Skip to content

Commit

Permalink
fix CI
Browse files Browse the repository at this point in the history
  • Loading branch information
colinlyguo committed Oct 7, 2024
1 parent 1102e04 commit 79fdd37
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 15 deletions.
2 changes: 1 addition & 1 deletion rollup/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ require (
github.com/holiman/uint256 v1.2.4
github.com/mitchellh/mapstructure v1.5.0
github.com/prometheus/client_golang v1.16.0
github.com/scroll-tech/da-codec v0.1.1-0.20241007144555-0079225045cc
github.com/scroll-tech/da-codec v0.1.1-0.20241007172557-669b454fad33
github.com/scroll-tech/go-ethereum v1.10.14-0.20241004182217-88bdce77a6e7
github.com/smartystreets/goconvey v1.8.0
github.com/spf13/viper v1.19.0
Expand Down
4 changes: 2 additions & 2 deletions rollup/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,8 @@ github.com/sagikazarmark/locafero v0.4.0 h1:HApY1R9zGo4DBgr7dqsTH/JJxLTTsOt7u6ke
github.com/sagikazarmark/locafero v0.4.0/go.mod h1:Pe1W6UlPYUk/+wc/6KFhbORCfqzgYEpgQ3O5fPuL3H4=
github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6gto+ugjYE=
github.com/sagikazarmark/slog-shim v0.1.0/go.mod h1:SrcSrq8aKtyuqEI1uvTDTK1arOWRIczQRv+GVI1AkeQ=
github.com/scroll-tech/da-codec v0.1.1-0.20241007144555-0079225045cc h1:jBGGDSmpb1oxuWe4URwDN7cmHdEN5mvHFPijGudFCQs=
github.com/scroll-tech/da-codec v0.1.1-0.20241007144555-0079225045cc/go.mod h1:6jxEQvNc7GQKMSUi25PthAUY3WnZL8CN0yWivBgAXi0=
github.com/scroll-tech/da-codec v0.1.1-0.20241007172557-669b454fad33 h1:e7ZFclDH2hX9JE/+5I5MpXrVe4mB5a3EpDUtc2QI+I0=
github.com/scroll-tech/da-codec v0.1.1-0.20241007172557-669b454fad33/go.mod h1:6jxEQvNc7GQKMSUi25PthAUY3WnZL8CN0yWivBgAXi0=
github.com/scroll-tech/go-ethereum v1.10.14-0.20241004182217-88bdce77a6e7 h1:uj6kHOscSmho2oQsIFdTL5yWN/84mdd+LTQkdfBSH/s=
github.com/scroll-tech/go-ethereum v1.10.14-0.20241004182217-88bdce77a6e7/go.mod h1:DWGorBlnlr6aLwN9IX4LLuHcgbMeYUUEvLjn186CNAY=
github.com/scroll-tech/zktrie v0.8.4 h1:UagmnZ4Z3ITCk+aUq9NQZJNAwnWl4gSxsLb2Nl7IgRE=
Expand Down
29 changes: 18 additions & 11 deletions rollup/internal/controller/relayer/l2_relayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ func (r *Layer2Relayer) ProcessPendingBatches() {
codecVersion := encoding.CodecVersion(dbBatch.CodecVersion)
switch codecVersion {
case encoding.CodecV0, encoding.CodecV1, encoding.CodecV2:
calldata, err = r.constructCommitBatchPayloadCodecV0AndV1AndV2(dbBatch, dbParentBatch, dbChunks, chunks)
calldata, blob, err = r.constructCommitBatchPayloadCodecV0AndV1AndV2(dbBatch, dbParentBatch, dbChunks, chunks)
if err != nil {
log.Error("failed to construct commitBatch payload for V0/V1/V2", "codecVersion", codecVersion, "index", dbBatch.Index, "err", err)
return
Expand Down Expand Up @@ -638,7 +638,7 @@ func (r *Layer2Relayer) finalizeBatch(dbBatch *orm.Batch, withProof bool) error
return fmt.Errorf("failed to construct finalizeBatch payload codecv1, index: %v, err: %w", dbBatch.Index, err)
}
} else { // >= codecv3
log.Info("encoding is codecv3, using finalizeBundle instead", "index", dbBatch.Index)
log.Debug("encoding is codecv3, using finalizeBundle instead", "index", dbBatch.Index)
return nil
}

Expand Down Expand Up @@ -932,35 +932,42 @@ func (r *Layer2Relayer) handleL2RollupRelayerConfirmLoop(ctx context.Context) {
}
}

func (r *Layer2Relayer) constructCommitBatchPayloadCodecV0AndV1AndV2(dbBatch *orm.Batch, dbParentBatch *orm.Batch, dbChunks []*orm.Chunk, chunks []*encoding.Chunk) ([]byte, error) {
func (r *Layer2Relayer) constructCommitBatchPayloadCodecV0AndV1AndV2(dbBatch *orm.Batch, dbParentBatch *orm.Batch, dbChunks []*orm.Chunk, chunks []*encoding.Chunk) ([]byte, *kzg4844.Blob, error) {
codec, err := encoding.CodecFromVersion(encoding.CodecVersion(dbBatch.CodecVersion))
if err != nil {
return nil, fmt.Errorf("failed to get codec from version: %w", err)
return nil, nil, fmt.Errorf("failed to get codec from version: %w", err)
}

daBatch, err := codec.NewDABatchFromBytes(dbBatch.BatchHeader)
if err != nil {
return nil, fmt.Errorf("failed to create DA batch from bytes: %w", err)
batch := &encoding.Batch{
Index: dbBatch.Index,
TotalL1MessagePoppedBefore: dbChunks[0].TotalL1MessagesPoppedBefore,
ParentBatchHash: common.HexToHash(dbParentBatch.Hash),
Chunks: chunks,
}

daBatch, createErr := codec.NewDABatch(batch)
if createErr != nil {
return nil, nil, fmt.Errorf("failed to create DA batch: %w", createErr)
}

encodedChunks := make([][]byte, len(dbChunks))
for i, c := range dbChunks {
daChunk, createErr := codec.NewDAChunk(chunks[i], c.TotalL1MessagesPoppedBefore)
if createErr != nil {
return nil, fmt.Errorf("failed to create DA chunk: %w", createErr)
return nil, nil, fmt.Errorf("failed to create DA chunk: %w", createErr)
}
daChunkBytes, encodeErr := daChunk.Encode()
if encodeErr != nil {
return nil, fmt.Errorf("failed to encode DA chunk: %w", encodeErr)
return nil, nil, fmt.Errorf("failed to encode DA chunk: %w", encodeErr)
}
encodedChunks[i] = daChunkBytes
}

calldata, packErr := r.l1RollupABI.Pack("commitBatch", daBatch.Version(), dbParentBatch.BatchHeader, encodedChunks, daBatch.SkippedL1MessageBitmap())
if packErr != nil {
return nil, fmt.Errorf("failed to pack commitBatch: %w", packErr)
return nil, nil, fmt.Errorf("failed to pack commitBatch: %w", packErr)
}
return calldata, nil
return calldata, daBatch.Blob(), nil
}

func (r *Layer2Relayer) constructCommitBatchPayloadCodecV3AndV4(dbBatch *orm.Batch, dbParentBatch *orm.Batch, dbChunks []*orm.Chunk, chunks []*encoding.Chunk) ([]byte, *kzg4844.Blob, error) {
Expand Down
4 changes: 3 additions & 1 deletion rollup/tests/rollup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func testCommitAndFinalizeGenesisBatch(t *testing.T) {
}

func testCommitBatchAndFinalizeBatchOrBundleWithAllCodecVersions(t *testing.T) {
codecVersions := []encoding.CodecVersion{encoding.CodecV0, encoding.CodecV1, encoding.CodecV2, encoding.CodecV3}
codecVersions := []encoding.CodecVersion{encoding.CodecV0, encoding.CodecV1, encoding.CodecV2, encoding.CodecV3, encoding.CodecV4}
for _, codecVersion := range codecVersions {
db := setupDB(t)

Expand All @@ -66,6 +66,8 @@ func testCommitBatchAndFinalizeBatchOrBundleWithAllCodecVersions(t *testing.T) {
chainConfig = &params.ChainConfig{BernoulliBlock: big.NewInt(0)}
} else if codecVersion == encoding.CodecV2 {
chainConfig = &params.ChainConfig{BernoulliBlock: big.NewInt(0), CurieBlock: big.NewInt(0)}
} else if codecVersion == encoding.CodecV3 {
chainConfig = &params.ChainConfig{BernoulliBlock: big.NewInt(0), CurieBlock: big.NewInt(0), DarwinTime: new(uint64)}
} else {
chainConfig = &params.ChainConfig{BernoulliBlock: big.NewInt(0), CurieBlock: big.NewInt(0), DarwinTime: new(uint64)}
}
Expand Down

0 comments on commit 79fdd37

Please sign in to comment.