mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-28 07:36:44 +00:00
feat: add codecv3 for darwin batches (#866)
* feat: add codecv3 for darwin batches * fix lint issue * chore: auto version bump [bot] * update da-codec dependency --------- Co-authored-by: colin <102356659+colinlyguo@users.noreply.github.com> Co-authored-by: colinlyguo <colinlyguo@users.noreply.github.com> Co-authored-by: colinlyguo <colinlyguo@scroll.io>
This commit is contained in:
parent
9aee47255f
commit
15019efa6c
4 changed files with 32 additions and 6 deletions
2
go.mod
2
go.mod
|
|
@ -50,7 +50,7 @@ require (
|
|||
github.com/prometheus/tsdb v0.7.1
|
||||
github.com/rjeczalik/notify v0.9.1
|
||||
github.com/rs/cors v1.7.0
|
||||
github.com/scroll-tech/da-codec v0.0.0-20240605080813-32bfc9fccde7
|
||||
github.com/scroll-tech/da-codec v0.1.1-0.20240703091800-5b6cded48ab7
|
||||
github.com/scroll-tech/zktrie v0.8.4
|
||||
github.com/shirou/gopsutil v3.21.11+incompatible
|
||||
github.com/status-im/keycard-go v0.0.0-20190316090335-8537d3370df4
|
||||
|
|
|
|||
4
go.sum
4
go.sum
|
|
@ -392,8 +392,8 @@ github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncj
|
|||
github.com/rs/cors v1.7.0 h1:+88SsELBHx5r+hZ8TCkggzSstaWNbDvThkVK8H6f9ik=
|
||||
github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU=
|
||||
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
github.com/scroll-tech/da-codec v0.0.0-20240605080813-32bfc9fccde7 h1:CDrPMqifvAVyYqu0x1J5qickVV0b51tApPnOwDYLESI=
|
||||
github.com/scroll-tech/da-codec v0.0.0-20240605080813-32bfc9fccde7/go.mod h1:1wWYii0OPwd5kw+xrz0PFgS420xNadrNF1x/ELJT+TM=
|
||||
github.com/scroll-tech/da-codec v0.1.1-0.20240703091800-5b6cded48ab7 h1:UfiLBLCAMBk9bsTP3fc1fETpNVFSQapQVdLcZveyV0M=
|
||||
github.com/scroll-tech/da-codec v0.1.1-0.20240703091800-5b6cded48ab7/go.mod h1:D6XEESeNVJkQJlv3eK+FyR+ufPkgVQbJzERylQi53Bs=
|
||||
github.com/scroll-tech/zktrie v0.8.4 h1:UagmnZ4Z3ITCk+aUq9NQZJNAwnWl4gSxsLb2Nl7IgRE=
|
||||
github.com/scroll-tech/zktrie v0.8.4/go.mod h1:XvNo7vAk8yxNyTjBDj5WIiFzYW4bx/gJ78+NK6Zn6Uk=
|
||||
github.com/segmentio/kafka-go v0.1.0/go.mod h1:X6itGqS9L4jDletMsxZ7Dz+JFWxM6JHfPOCvTvk+EJo=
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import (
|
|||
const (
|
||||
VersionMajor = 5 // Major version component of the current release
|
||||
VersionMinor = 5 // Minor version component of the current release
|
||||
VersionPatch = 4 // Patch version component of the current release
|
||||
VersionPatch = 5 // Patch version component of the current release
|
||||
VersionMeta = "mainnet" // Version metadata to append to the version string
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import (
|
|||
"github.com/scroll-tech/da-codec/encoding/codecv0"
|
||||
"github.com/scroll-tech/da-codec/encoding/codecv1"
|
||||
"github.com/scroll-tech/da-codec/encoding/codecv2"
|
||||
"github.com/scroll-tech/da-codec/encoding/codecv3"
|
||||
|
||||
"github.com/scroll-tech/go-ethereum/accounts/abi"
|
||||
"github.com/scroll-tech/go-ethereum/common"
|
||||
|
|
@ -456,10 +457,16 @@ func validateBatch(event *L1FinalizeBatchEvent, parentBatchMeta *rawdb.Finalized
|
|||
return 0, nil, fmt.Errorf("failed to create codecv1 DA batch, batch index: %v, err: %w", event.BatchIndex.Uint64(), err)
|
||||
}
|
||||
localBatchHash = daBatch.Hash()
|
||||
} else { // codecv2: batches after Curie
|
||||
} else if !chainCfg.IsDarwin(startBlock.Header.Time) { // codecv2: batches after Curie and before Darwin
|
||||
daBatch, err := codecv2.NewDABatch(batch)
|
||||
if err != nil {
|
||||
return 0, nil, fmt.Errorf("failed to create codecv1 DA batch, batch index: %v, err: %w", event.BatchIndex.Uint64(), err)
|
||||
return 0, nil, fmt.Errorf("failed to create codecv2 DA batch, batch index: %v, err: %w", event.BatchIndex.Uint64(), err)
|
||||
}
|
||||
localBatchHash = daBatch.Hash()
|
||||
} else { // codecv3: batches after Darwin
|
||||
daBatch, err := codecv3.NewDABatch(batch)
|
||||
if err != nil {
|
||||
return 0, nil, fmt.Errorf("failed to create codecv3 DA batch, batch index: %v, err: %w", event.BatchIndex.Uint64(), err)
|
||||
}
|
||||
localBatchHash = daBatch.Hash()
|
||||
}
|
||||
|
|
@ -555,6 +562,25 @@ func decodeBlockRangesFromEncodedChunks(codecVersion encoding.CodecVersion, chun
|
|||
StartBlockNumber: daBlocks[0].BlockNumber,
|
||||
EndBlockNumber: daBlocks[len(daBlocks)-1].BlockNumber,
|
||||
})
|
||||
case encoding.CodecV3:
|
||||
if len(chunk) != 1+numBlocks*60 {
|
||||
return nil, fmt.Errorf("invalid chunk byte length, expected: %v, got: %v", 1+numBlocks*60, len(chunk))
|
||||
}
|
||||
daBlocks := make([]*codecv3.DABlock, numBlocks)
|
||||
for i := 0; i < numBlocks; i++ {
|
||||
startIdx := 1 + i*60 // add 1 to skip numBlocks byte
|
||||
endIdx := startIdx + 60
|
||||
daBlocks[i] = &codecv3.DABlock{}
|
||||
if err := daBlocks[i].Decode(chunk[startIdx:endIdx]); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
chunkBlockRanges = append(chunkBlockRanges, &rawdb.ChunkBlockRange{
|
||||
StartBlockNumber: daBlocks[0].BlockNumber,
|
||||
EndBlockNumber: daBlocks[len(daBlocks)-1].BlockNumber,
|
||||
})
|
||||
|
||||
default:
|
||||
return nil, fmt.Errorf("unexpected batch version %v", codecVersion)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue