55 "encoding/binary"
66 "fmt"
77 "math/big"
8+ "slices"
89
910 "github.com/klauspost/compress/zstd"
1011
@@ -226,6 +227,15 @@ func (c *Chunk) CrcMax() (uint64, error) {
226227 // Map sub-circuit name to row count
227228 crc := make (map [string ]uint64 )
228229
230+ // if no blocks have row consumption, this is an euclid chunk
231+ isEuclidChunk := slices .IndexFunc (c .Blocks , func (block * Block ) bool {
232+ return block .RowConsumption != nil
233+ }) == - 1
234+
235+ if isEuclidChunk {
236+ return 0 , nil
237+ }
238+
229239 // Iterate over blocks, accumulate row consumption
230240 for _ , block := range c .Blocks {
231241 if block .RowConsumption == nil {
@@ -633,8 +643,10 @@ func GetHardforkName(config *params.ChainConfig, blockHeight, blockTimestamp uin
633643 return "curie"
634644 } else if ! config .IsDarwinV2 (blockTimestamp ) {
635645 return "darwin"
636- } else {
646+ } else if ! config . IsEuclid ( blockTimestamp ) {
637647 return "darwinV2"
648+ } else {
649+ return "euclid"
638650 }
639651}
640652
@@ -649,8 +661,11 @@ func GetCodecVersion(config *params.ChainConfig, blockHeight, blockTimestamp uin
649661 return CodecV2
650662 } else if ! config .IsDarwinV2 (blockTimestamp ) {
651663 return CodecV3
652- } else {
664+ } else if ! config . IsEuclid ( blockTimestamp ) {
653665 return CodecV4
666+ } else {
667+ // V5 is skipped, because it is only used for the special Euclid transition batch that we handle explicitly
668+ return CodecV6
654669 }
655670}
656671
@@ -679,7 +694,7 @@ func GetChunkEnableCompression(codecVersion CodecVersion, chunk *Chunk) (bool, e
679694 return false , nil
680695 case CodecV2 , CodecV3 :
681696 return true , nil
682- case CodecV4 :
697+ case CodecV4 , CodecV5 , CodecV6 :
683698 return CheckChunkCompressedDataCompatibility (chunk , codecVersion )
684699 default :
685700 return false , fmt .Errorf ("unsupported codec version: %v" , codecVersion )
@@ -693,7 +708,7 @@ func GetBatchEnableCompression(codecVersion CodecVersion, batch *Batch) (bool, e
693708 return false , nil
694709 case CodecV2 , CodecV3 :
695710 return true , nil
696- case CodecV4 :
711+ case CodecV4 , CodecV5 , CodecV6 :
697712 return CheckBatchCompressedDataCompatibility (batch , codecVersion )
698713 default :
699714 return false , fmt .Errorf ("unsupported codec version: %v" , codecVersion )
0 commit comments