From 525167af94ed53f4d9100eb8c97548247adea629 Mon Sep 17 00:00:00 2001 From: Potuz Date: Thu, 4 Jul 2024 09:16:11 -0300 Subject: [PATCH] Change gwei math to primitives package for ePBS state --- beacon-chain/core/helpers/BUILD.bazel | 1 + proto/engine/v1/engine.ssz.go | 2 +- proto/eth/v1/gateway.ssz.go | 2 +- proto/eth/v2/grpc.ssz.go | 2 +- proto/prysm/v1alpha1/generated.ssz.go | 131 +++++++++++++------------- testing/util/random/BUILD.bazel | 1 - 6 files changed, 69 insertions(+), 70 deletions(-) diff --git a/beacon-chain/core/helpers/BUILD.bazel b/beacon-chain/core/helpers/BUILD.bazel index 7150803b0654..4408d6ed88a6 100644 --- a/beacon-chain/core/helpers/BUILD.bazel +++ b/beacon-chain/core/helpers/BUILD.bazel @@ -81,6 +81,7 @@ go_test( "//container/slice:go_default_library", "//crypto/hash:go_default_library", "//encoding/bytesutil:go_default_library", + "//math:go_default_library", "//proto/prysm/v1alpha1:go_default_library", "//runtime/version:go_default_library", "//testing/assert:go_default_library", diff --git a/proto/engine/v1/engine.ssz.go b/proto/engine/v1/engine.ssz.go index d98e9f8acebe..f3f42e523534 100644 --- a/proto/engine/v1/engine.ssz.go +++ b/proto/engine/v1/engine.ssz.go @@ -1,5 +1,5 @@ // Code generated by fastssz. DO NOT EDIT. -// Hash: 3d8372b29262b45e4ea813e1758fbd2290450bac17685441c9306ff653bb991c +// Hash: bdbc74649983e9eaaf1bafa335c21274f9abb3cf75505019386aef56246b55f0 package enginev1 import ( diff --git a/proto/eth/v1/gateway.ssz.go b/proto/eth/v1/gateway.ssz.go index ceebc8d094b9..630663138b11 100644 --- a/proto/eth/v1/gateway.ssz.go +++ b/proto/eth/v1/gateway.ssz.go @@ -1,5 +1,5 @@ // Code generated by fastssz. DO NOT EDIT. -// Hash: d06a72227c2f5e350916cce3e89f4e855135a2a22f6ea263dedc68fa506c1ba7 +// Hash: dc11029a7f019f6c900b35f68bbe0a9ff6ca31ba1f7d8c18518cad810690300d package v1 import ( diff --git a/proto/eth/v2/grpc.ssz.go b/proto/eth/v2/grpc.ssz.go index af4fd70ce818..3ccde83580b6 100644 --- a/proto/eth/v2/grpc.ssz.go +++ b/proto/eth/v2/grpc.ssz.go @@ -1,5 +1,5 @@ // Code generated by fastssz. DO NOT EDIT. -// Hash: e1b3713d854395a4c86aa7a0bf0249d9f2764183a636fcc53badddeaf38990f2 +// Hash: 6f33097dd41d3dd49d35b7cfceef5a1afca20f05d65b18215748b459db16f99b package eth import ( diff --git a/proto/prysm/v1alpha1/generated.ssz.go b/proto/prysm/v1alpha1/generated.ssz.go index 5537f35e73b2..29781e6da263 100644 --- a/proto/prysm/v1alpha1/generated.ssz.go +++ b/proto/prysm/v1alpha1/generated.ssz.go @@ -1,11 +1,10 @@ // Code generated by fastssz. DO NOT EDIT. -// Hash: 050e86cc92690603d4c328eea81f5ca09012184e81dc5545c24c244096415333 +// Hash: 6032ce00da94bec6155432e7b3b1834f1559d4d51ee0e30104552bc89106e344 package eth import ( ssz "github.com/prysmaticlabs/fastssz" github_com_prysmaticlabs_prysm_v5_consensus_types_primitives "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives" - github_com_prysmaticlabs_prysm_v5_math "github.com/prysmaticlabs/prysm/v5/math" v1 "github.com/prysmaticlabs/prysm/v5/proto/engine/v1" ) @@ -20079,16 +20078,16 @@ func (b *BeaconStateEPBS) UnmarshalSSZ(buf []byte) error { b.DepositReceiptsStartIndex = ssz.UnmarshallUint64(buf[2736649:2736657]) // Field (28) 'DepositBalanceToConsume' - b.DepositBalanceToConsume = github_com_prysmaticlabs_prysm_v5_math.Gwei(ssz.UnmarshallUint64(buf[2736657:2736665])) + b.DepositBalanceToConsume = github_com_prysmaticlabs_prysm_v5_consensus_types_primitives.Gwei(ssz.UnmarshallUint64(buf[2736657:2736665])) // Field (29) 'ExitBalanceToConsume' - b.ExitBalanceToConsume = github_com_prysmaticlabs_prysm_v5_math.Gwei(ssz.UnmarshallUint64(buf[2736665:2736673])) + b.ExitBalanceToConsume = github_com_prysmaticlabs_prysm_v5_consensus_types_primitives.Gwei(ssz.UnmarshallUint64(buf[2736665:2736673])) // Field (30) 'EarliestExitEpoch' b.EarliestExitEpoch = github_com_prysmaticlabs_prysm_v5_consensus_types_primitives.Epoch(ssz.UnmarshallUint64(buf[2736673:2736681])) // Field (31) 'ConsolidationBalanceToConsume' - b.ConsolidationBalanceToConsume = github_com_prysmaticlabs_prysm_v5_math.Gwei(ssz.UnmarshallUint64(buf[2736681:2736689])) + b.ConsolidationBalanceToConsume = github_com_prysmaticlabs_prysm_v5_consensus_types_primitives.Gwei(ssz.UnmarshallUint64(buf[2736681:2736689])) // Field (32) 'EarliestConsolidationEpoch' b.EarliestConsolidationEpoch = github_com_prysmaticlabs_prysm_v5_consensus_types_primitives.Epoch(ssz.UnmarshallUint64(buf[2736689:2736697])) @@ -21102,77 +21101,77 @@ func (s *SignedBlindPayloadEnvelope) HashTreeRootWith(hh *ssz.Hasher) (err error } // MarshalSSZ ssz marshals the BlindPayloadEnvelope object -func (e *BlindPayloadEnvelope) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(e) +func (b *BlindPayloadEnvelope) MarshalSSZ() ([]byte, error) { + return ssz.MarshalSSZ(b) } // MarshalSSZTo ssz marshals the BlindPayloadEnvelope object to a target array -func (e *BlindPayloadEnvelope) MarshalSSZTo(buf []byte) (dst []byte, err error) { +func (b *BlindPayloadEnvelope) MarshalSSZTo(buf []byte) (dst []byte, err error) { dst = buf offset := int(221) // Field (0) 'PayloadRoot' - if size := len(e.PayloadRoot); size != 32 { + if size := len(b.PayloadRoot); size != 32 { err = ssz.ErrBytesLengthFn("--.PayloadRoot", size, 32) return } - dst = append(dst, e.PayloadRoot...) + dst = append(dst, b.PayloadRoot...) // Field (1) 'BuilderIndex' - dst = ssz.MarshalUint64(dst, uint64(e.BuilderIndex)) + dst = ssz.MarshalUint64(dst, uint64(b.BuilderIndex)) // Field (2) 'BeaconBlockRoot' - if size := len(e.BeaconBlockRoot); size != 32 { + if size := len(b.BeaconBlockRoot); size != 32 { err = ssz.ErrBytesLengthFn("--.BeaconBlockRoot", size, 32) return } - dst = append(dst, e.BeaconBlockRoot...) + dst = append(dst, b.BeaconBlockRoot...) // Offset (3) 'BlobKzgCommitments' dst = ssz.WriteOffset(dst, offset) - offset += len(e.BlobKzgCommitments) * 48 + offset += len(b.BlobKzgCommitments) * 48 // Field (4) 'InclusionListProposerIndex' - dst = ssz.MarshalUint64(dst, uint64(e.InclusionListProposerIndex)) + dst = ssz.MarshalUint64(dst, uint64(b.InclusionListProposerIndex)) // Field (5) 'InclusionListSlot' - dst = ssz.MarshalUint64(dst, uint64(e.InclusionListSlot)) + dst = ssz.MarshalUint64(dst, uint64(b.InclusionListSlot)) // Field (6) 'InclusionListSignature' - if size := len(e.InclusionListSignature); size != 96 { + if size := len(b.InclusionListSignature); size != 96 { err = ssz.ErrBytesLengthFn("--.InclusionListSignature", size, 96) return } - dst = append(dst, e.InclusionListSignature...) + dst = append(dst, b.InclusionListSignature...) // Field (7) 'PayloadWithheld' - dst = ssz.MarshalBool(dst, e.PayloadWithheld) + dst = ssz.MarshalBool(dst, b.PayloadWithheld) // Field (8) 'StateRoot' - if size := len(e.StateRoot); size != 32 { + if size := len(b.StateRoot); size != 32 { err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) return } - dst = append(dst, e.StateRoot...) + dst = append(dst, b.StateRoot...) // Field (3) 'BlobKzgCommitments' - if size := len(e.BlobKzgCommitments); size > 4096 { + if size := len(b.BlobKzgCommitments); size > 4096 { err = ssz.ErrListTooBigFn("--.BlobKzgCommitments", size, 4096) return } - for ii := 0; ii < len(e.BlobKzgCommitments); ii++ { - if size := len(e.BlobKzgCommitments[ii]); size != 48 { + for ii := 0; ii < len(b.BlobKzgCommitments); ii++ { + if size := len(b.BlobKzgCommitments[ii]); size != 48 { err = ssz.ErrBytesLengthFn("--.BlobKzgCommitments[ii]", size, 48) return } - dst = append(dst, e.BlobKzgCommitments[ii]...) + dst = append(dst, b.BlobKzgCommitments[ii]...) } return } // UnmarshalSSZ ssz unmarshals the BlindPayloadEnvelope object -func (e *BlindPayloadEnvelope) UnmarshalSSZ(buf []byte) error { +func (b *BlindPayloadEnvelope) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) if size < 221 { @@ -21183,19 +21182,19 @@ func (e *BlindPayloadEnvelope) UnmarshalSSZ(buf []byte) error { var o3 uint64 // Field (0) 'PayloadRoot' - if cap(e.PayloadRoot) == 0 { - e.PayloadRoot = make([]byte, 0, len(buf[0:32])) + if cap(b.PayloadRoot) == 0 { + b.PayloadRoot = make([]byte, 0, len(buf[0:32])) } - e.PayloadRoot = append(e.PayloadRoot, buf[0:32]...) + b.PayloadRoot = append(b.PayloadRoot, buf[0:32]...) // Field (1) 'BuilderIndex' - e.BuilderIndex = github_com_prysmaticlabs_prysm_v5_consensus_types_primitives.ValidatorIndex(ssz.UnmarshallUint64(buf[32:40])) + b.BuilderIndex = github_com_prysmaticlabs_prysm_v5_consensus_types_primitives.ValidatorIndex(ssz.UnmarshallUint64(buf[32:40])) // Field (2) 'BeaconBlockRoot' - if cap(e.BeaconBlockRoot) == 0 { - e.BeaconBlockRoot = make([]byte, 0, len(buf[40:72])) + if cap(b.BeaconBlockRoot) == 0 { + b.BeaconBlockRoot = make([]byte, 0, len(buf[40:72])) } - e.BeaconBlockRoot = append(e.BeaconBlockRoot, buf[40:72]...) + b.BeaconBlockRoot = append(b.BeaconBlockRoot, buf[40:72]...) // Offset (3) 'BlobKzgCommitments' if o3 = ssz.ReadOffset(buf[72:76]); o3 > size { @@ -21207,25 +21206,25 @@ func (e *BlindPayloadEnvelope) UnmarshalSSZ(buf []byte) error { } // Field (4) 'InclusionListProposerIndex' - e.InclusionListProposerIndex = github_com_prysmaticlabs_prysm_v5_consensus_types_primitives.ValidatorIndex(ssz.UnmarshallUint64(buf[76:84])) + b.InclusionListProposerIndex = github_com_prysmaticlabs_prysm_v5_consensus_types_primitives.ValidatorIndex(ssz.UnmarshallUint64(buf[76:84])) // Field (5) 'InclusionListSlot' - e.InclusionListSlot = github_com_prysmaticlabs_prysm_v5_consensus_types_primitives.Slot(ssz.UnmarshallUint64(buf[84:92])) + b.InclusionListSlot = github_com_prysmaticlabs_prysm_v5_consensus_types_primitives.Slot(ssz.UnmarshallUint64(buf[84:92])) // Field (6) 'InclusionListSignature' - if cap(e.InclusionListSignature) == 0 { - e.InclusionListSignature = make([]byte, 0, len(buf[92:188])) + if cap(b.InclusionListSignature) == 0 { + b.InclusionListSignature = make([]byte, 0, len(buf[92:188])) } - e.InclusionListSignature = append(e.InclusionListSignature, buf[92:188]...) + b.InclusionListSignature = append(b.InclusionListSignature, buf[92:188]...) // Field (7) 'PayloadWithheld' - e.PayloadWithheld = ssz.UnmarshalBool(buf[188:189]) + b.PayloadWithheld = ssz.UnmarshalBool(buf[188:189]) // Field (8) 'StateRoot' - if cap(e.StateRoot) == 0 { - e.StateRoot = make([]byte, 0, len(buf[189:221])) + if cap(b.StateRoot) == 0 { + b.StateRoot = make([]byte, 0, len(buf[189:221])) } - e.StateRoot = append(e.StateRoot, buf[189:221]...) + b.StateRoot = append(b.StateRoot, buf[189:221]...) // Field (3) 'BlobKzgCommitments' { @@ -21234,61 +21233,61 @@ func (e *BlindPayloadEnvelope) UnmarshalSSZ(buf []byte) error { if err != nil { return err } - e.BlobKzgCommitments = make([][]byte, num) + b.BlobKzgCommitments = make([][]byte, num) for ii := 0; ii < num; ii++ { - if cap(e.BlobKzgCommitments[ii]) == 0 { - e.BlobKzgCommitments[ii] = make([]byte, 0, len(buf[ii*48:(ii+1)*48])) + if cap(b.BlobKzgCommitments[ii]) == 0 { + b.BlobKzgCommitments[ii] = make([]byte, 0, len(buf[ii*48:(ii+1)*48])) } - e.BlobKzgCommitments[ii] = append(e.BlobKzgCommitments[ii], buf[ii*48:(ii+1)*48]...) + b.BlobKzgCommitments[ii] = append(b.BlobKzgCommitments[ii], buf[ii*48:(ii+1)*48]...) } } return err } // SizeSSZ returns the ssz encoded size in bytes for the BlindPayloadEnvelope object -func (e *BlindPayloadEnvelope) SizeSSZ() (size int) { +func (b *BlindPayloadEnvelope) SizeSSZ() (size int) { size = 221 // Field (3) 'BlobKzgCommitments' - size += len(e.BlobKzgCommitments) * 48 + size += len(b.BlobKzgCommitments) * 48 return } // HashTreeRoot ssz hashes the BlindPayloadEnvelope object -func (e *BlindPayloadEnvelope) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(e) +func (b *BlindPayloadEnvelope) HashTreeRoot() ([32]byte, error) { + return ssz.HashWithDefaultHasher(b) } // HashTreeRootWith ssz hashes the BlindPayloadEnvelope object with a hasher -func (e *BlindPayloadEnvelope) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (b *BlindPayloadEnvelope) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() // Field (0) 'PayloadRoot' - if size := len(e.PayloadRoot); size != 32 { + if size := len(b.PayloadRoot); size != 32 { err = ssz.ErrBytesLengthFn("--.PayloadRoot", size, 32) return } - hh.PutBytes(e.PayloadRoot) + hh.PutBytes(b.PayloadRoot) // Field (1) 'BuilderIndex' - hh.PutUint64(uint64(e.BuilderIndex)) + hh.PutUint64(uint64(b.BuilderIndex)) // Field (2) 'BeaconBlockRoot' - if size := len(e.BeaconBlockRoot); size != 32 { + if size := len(b.BeaconBlockRoot); size != 32 { err = ssz.ErrBytesLengthFn("--.BeaconBlockRoot", size, 32) return } - hh.PutBytes(e.BeaconBlockRoot) + hh.PutBytes(b.BeaconBlockRoot) // Field (3) 'BlobKzgCommitments' { - if size := len(e.BlobKzgCommitments); size > 4096 { + if size := len(b.BlobKzgCommitments); size > 4096 { err = ssz.ErrListTooBigFn("--.BlobKzgCommitments", size, 4096) return } subIndx := hh.Index() - for _, i := range e.BlobKzgCommitments { + for _, i := range b.BlobKzgCommitments { if len(i) != 48 { err = ssz.ErrBytesLength return @@ -21296,7 +21295,7 @@ func (e *BlindPayloadEnvelope) HashTreeRootWith(hh *ssz.Hasher) (err error) { hh.PutBytes(i) } - numItems := uint64(len(e.BlobKzgCommitments)) + numItems := uint64(len(b.BlobKzgCommitments)) if ssz.EnableVectorizedHTR { hh.MerkleizeWithMixinVectorizedHTR(subIndx, numItems, 4096) } else { @@ -21305,27 +21304,27 @@ func (e *BlindPayloadEnvelope) HashTreeRootWith(hh *ssz.Hasher) (err error) { } // Field (4) 'InclusionListProposerIndex' - hh.PutUint64(uint64(e.InclusionListProposerIndex)) + hh.PutUint64(uint64(b.InclusionListProposerIndex)) // Field (5) 'InclusionListSlot' - hh.PutUint64(uint64(e.InclusionListSlot)) + hh.PutUint64(uint64(b.InclusionListSlot)) // Field (6) 'InclusionListSignature' - if size := len(e.InclusionListSignature); size != 96 { + if size := len(b.InclusionListSignature); size != 96 { err = ssz.ErrBytesLengthFn("--.InclusionListSignature", size, 96) return } - hh.PutBytes(e.InclusionListSignature) + hh.PutBytes(b.InclusionListSignature) // Field (7) 'PayloadWithheld' - hh.PutBool(e.PayloadWithheld) + hh.PutBool(b.PayloadWithheld) // Field (8) 'StateRoot' - if size := len(e.StateRoot); size != 32 { + if size := len(b.StateRoot); size != 32 { err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) return } - hh.PutBytes(e.StateRoot) + hh.PutBytes(b.StateRoot) if ssz.EnableVectorizedHTR { hh.MerkleizeVectorizedHTR(indx) diff --git a/testing/util/random/BUILD.bazel b/testing/util/random/BUILD.bazel index 82bd74cdb074..3f7f483af3ad 100644 --- a/testing/util/random/BUILD.bazel +++ b/testing/util/random/BUILD.bazel @@ -9,7 +9,6 @@ go_library( "//config/fieldparams:go_default_library", "//config/params:go_default_library", "//consensus-types/primitives:go_default_library", - "//math:go_default_library", "//proto/engine/v1:go_default_library", "//proto/prysm/v1alpha1:go_default_library", "@com_github_prysmaticlabs_go_bitfield//:go_default_library",