55 "encoding/binary"
66 "fmt"
77 "math/big"
8+ "slices"
89
910 "github.com/klauspost/compress/zstd"
1011
@@ -245,6 +246,15 @@ func (c *Chunk) CrcMax() (uint64, error) {
245246 // Map sub-circuit name to row count
246247 crc := make (map [string ]uint64 )
247248
249+ // if no blocks have row consumption, this is an euclid chunk
250+ isEuclidChunk := slices .IndexFunc (c .Blocks , func (block * Block ) bool {
251+ return block .RowConsumption != nil
252+ }) == - 1
253+
254+ if isEuclidChunk {
255+ return 0 , nil
256+ }
257+
248258 // Iterate over blocks, accumulate row consumption
249259 for _ , block := range c .Blocks {
250260 if block .RowConsumption == nil {
@@ -652,8 +662,10 @@ func GetHardforkName(config *params.ChainConfig, blockHeight, blockTimestamp uin
652662 return "curie"
653663 } else if ! config .IsDarwinV2 (blockTimestamp ) {
654664 return "darwin"
655- } else {
665+ } else if ! config . IsEuclid ( blockTimestamp ) {
656666 return "darwinV2"
667+ } else {
668+ return "euclid"
657669 }
658670}
659671
@@ -668,8 +680,11 @@ func GetCodecVersion(config *params.ChainConfig, blockHeight, blockTimestamp uin
668680 return CodecV2
669681 } else if ! config .IsDarwinV2 (blockTimestamp ) {
670682 return CodecV3
671- } else {
683+ } else if ! config . IsEuclid ( blockTimestamp ) {
672684 return CodecV4
685+ } else {
686+ // V5 is skipped, because it is only used for the special Euclid transition batch that we handle explicitly
687+ return CodecV6
673688 }
674689}
675690
@@ -698,7 +713,7 @@ func GetChunkEnableCompression(codecVersion CodecVersion, chunk *Chunk) (bool, e
698713 return false , nil
699714 case CodecV2 , CodecV3 :
700715 return true , nil
701- case CodecV4 :
716+ case CodecV4 , CodecV5 , CodecV6 :
702717 return CheckChunkCompressedDataCompatibility (chunk , codecVersion )
703718 default :
704719 return false , fmt .Errorf ("unsupported codec version: %v" , codecVersion )
@@ -712,7 +727,7 @@ func GetBatchEnableCompression(codecVersion CodecVersion, batch *Batch) (bool, e
712727 return false , nil
713728 case CodecV2 , CodecV3 :
714729 return true , nil
715- case CodecV4 :
730+ case CodecV4 , CodecV5 , CodecV6 :
716731 return CheckBatchCompressedDataCompatibility (batch , codecVersion )
717732 default :
718733 return false , fmt .Errorf ("unsupported codec version: %v" , codecVersion )
0 commit comments