Skip to content

Commit

Permalink
rename daBatchV2 to daBatchV3
Browse files Browse the repository at this point in the history
  • Loading branch information
colinlyguo committed Oct 16, 2024
1 parent 3e092dd commit 0158201
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion encoding/codecv3.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ func (d *DACodecV3) EstimateBatchL1CommitGas(b *Batch) (uint64, error) {
return totalL1CommitGas, nil
}

// JSONFromBytes converts the bytes to a daBatchV2 and then marshals it to JSON.
// JSONFromBytes converts the bytes to a daBatchV3 and then marshals it to JSON.
func (d *DACodecV3) JSONFromBytes(data []byte) ([]byte, error) {
batch, err := d.NewDABatchFromBytes(data)
if err != nil {
Expand Down
38 changes: 19 additions & 19 deletions encoding/codecv3_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
"github.com/scroll-tech/go-ethereum/crypto/kzg4844"
)

// daBatchV2 contains metadata about a batch of DAChunks.
type daBatchV2 struct {
// daBatchV3 contains metadata about a batch of DAChunks.
type daBatchV3 struct {
daBatchV0

blobVersionedHash common.Hash
Expand All @@ -24,11 +24,11 @@ type daBatchV2 struct {
blobBytes []byte
}

// newDABatchV2 is a constructor for daBatchV2 that calls blobDataProofForPICircuit internally.
// newDABatchV2 is a constructor for daBatchV3 that calls blobDataProofForPICircuit internally.
func newDABatchV2(version uint8, batchIndex, l1MessagePopped, totalL1MessagePopped, lastBlockTimestamp uint64,
dataHash, parentBatchHash, blobVersionedHash common.Hash, skippedL1MessageBitmap []byte, blob *kzg4844.Blob,
z *kzg4844.Point, blobBytes []byte) (*daBatchV2, error) {
daBatch := &daBatchV2{
z *kzg4844.Point, blobBytes []byte) (*daBatchV3, error) {
daBatch := &daBatchV3{
daBatchV0: daBatchV0{
version: version,
batchIndex: batchIndex,
Expand All @@ -55,11 +55,11 @@ func newDABatchV2(version uint8, batchIndex, l1MessagePopped, totalL1MessagePopp
return daBatch, nil
}

// newDABatchV2WithProof is a constructor for daBatchV2 that allows directly passing blobDataProof.
// newDABatchV2WithProof is a constructor for daBatchV3 that allows directly passing blobDataProof.
func newDABatchV2WithProof(version uint8, batchIndex, l1MessagePopped, totalL1MessagePopped, lastBlockTimestamp uint64,
dataHash, parentBatchHash, blobVersionedHash common.Hash, skippedL1MessageBitmap []byte,
blob *kzg4844.Blob, z *kzg4844.Point, blobBytes []byte, blobDataProof [2]common.Hash) *daBatchV2 {
return &daBatchV2{
blob *kzg4844.Blob, z *kzg4844.Point, blobBytes []byte, blobDataProof [2]common.Hash) *daBatchV3 {
return &daBatchV3{
daBatchV0: daBatchV0{
version: version,
batchIndex: batchIndex,
Expand All @@ -79,7 +79,7 @@ func newDABatchV2WithProof(version uint8, batchIndex, l1MessagePopped, totalL1Me
}

// Encode serializes the DABatch into bytes.
func (b *daBatchV2) Encode() []byte {
func (b *daBatchV3) Encode() []byte {
batchBytes := make([]byte, 193)
batchBytes[0] = b.version
binary.BigEndian.PutUint64(batchBytes[1:9], b.batchIndex)
Expand All @@ -95,13 +95,13 @@ func (b *daBatchV2) Encode() []byte {
}

// Hash computes the hash of the serialized DABatch.
func (b *daBatchV2) Hash() common.Hash {
func (b *daBatchV3) Hash() common.Hash {
bytes := b.Encode()
return crypto.Keccak256Hash(bytes)
}

// blobDataProofForPICircuit computes the abi-encoded blob verification data.
func (b *daBatchV2) blobDataProofForPICircuit() ([2]common.Hash, error) {
func (b *daBatchV3) blobDataProofForPICircuit() ([2]common.Hash, error) {
if b.blob == nil {
return [2]common.Hash{}, errors.New("called blobDataProofForPICircuit with empty blob")
}
Expand All @@ -126,7 +126,7 @@ func (b *daBatchV2) blobDataProofForPICircuit() ([2]common.Hash, error) {
}

// BlobDataProofForPointEvaluation computes the abi-encoded blob verification data.
func (b *daBatchV2) BlobDataProofForPointEvaluation() ([]byte, error) {
func (b *daBatchV3) BlobDataProofForPointEvaluation() ([]byte, error) {
if b.blob == nil {
return nil, errors.New("called BlobDataProofForPointEvaluation with empty blob")
}
Expand All @@ -148,18 +148,18 @@ func (b *daBatchV2) BlobDataProofForPointEvaluation() ([]byte, error) {
}

// Blob returns the blob of the batch.
func (b *daBatchV2) Blob() *kzg4844.Blob {
func (b *daBatchV3) Blob() *kzg4844.Blob {
return b.blob
}

// BlobBytes returns the blob bytes of the batch.
func (b *daBatchV2) BlobBytes() []byte {
func (b *daBatchV3) BlobBytes() []byte {
return b.blobBytes
}

// MarshalJSON implements the custom JSON serialization for daBatchV2.
// MarshalJSON implements the custom JSON serialization for daBatchV3.
// This method is designed to provide prover with batch info in snake_case format.
func (b *daBatchV2) MarshalJSON() ([]byte, error) {
func (b *daBatchV3) MarshalJSON() ([]byte, error) {
type daBatchV2JSON struct {
Version uint8 `json:"version"`
BatchIndex uint64 `json:"batch_index"`
Expand Down Expand Up @@ -193,16 +193,16 @@ func (b *daBatchV2) MarshalJSON() ([]byte, error) {
}

// Version returns the version of the DABatch.
func (b *daBatchV2) Version() uint8 {
func (b *daBatchV3) Version() uint8 {
return b.version
}

// SkippedL1MessageBitmap returns the skipped L1 message bitmap of the DABatch.
func (b *daBatchV2) SkippedL1MessageBitmap() []byte {
func (b *daBatchV3) SkippedL1MessageBitmap() []byte {
return b.skippedL1MessageBitmap
}

// DataHash returns the data hash of the DABatch.
func (b *daBatchV2) DataHash() common.Hash {
func (b *daBatchV3) DataHash() common.Hash {
return b.dataHash
}

0 comments on commit 0158201

Please sign in to comment.