From 341a2f1ea3f3e34785c2f4f185c1af08b89bc63e Mon Sep 17 00:00:00 2001 From: terence tsao Date: Thu, 4 Nov 2021 11:48:09 -0700 Subject: [PATCH] Use ` math.MaxUint64` (#9857) Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com> --- beacon-chain/rpc/prysm/v1alpha1/debug/block.go | 3 ++- config/params/mainnet_config.go | 4 ++-- config/params/minimal_config.go | 4 ++-- time/slots/slottime_test.go | 4 ++-- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/beacon-chain/rpc/prysm/v1alpha1/debug/block.go b/beacon-chain/rpc/prysm/v1alpha1/debug/block.go index f65c46270..504e6dc1c 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/debug/block.go +++ b/beacon-chain/rpc/prysm/v1alpha1/debug/block.go @@ -3,6 +3,7 @@ package debug import ( "context" "fmt" + "math" types "github.com/prysmaticlabs/eth2-types" "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" @@ -61,7 +62,7 @@ func (ds *Server) GetInclusionSlot(ctx context.Context, req *pbrpc.InclusionSlot return nil, status.Errorf(codes.Internal, "Could not retrieve blocks: %v", err) } - inclusionSlot := types.Slot(1<<64 - 1) + inclusionSlot := types.Slot(math.MaxUint64) targetStates := make(map[[32]byte]state.ReadOnlyBeaconState) for _, blk := range blks { for _, a := range blk.Block().Body().Attestations() { diff --git a/config/params/mainnet_config.go b/config/params/mainnet_config.go index 48ae71f8a..8ab5a4575 100644 --- a/config/params/mainnet_config.go +++ b/config/params/mainnet_config.go @@ -65,8 +65,8 @@ var mainnetNetworkConfig = &NetworkConfig{ var mainnetBeaconConfig = &BeaconChainConfig{ // Constants (Non-configurable) - FarFutureEpoch: 1<<64 - 1, - FarFutureSlot: 1<<64 - 1, + FarFutureEpoch: math.MaxUint64, + FarFutureSlot: math.MaxUint64, BaseRewardsPerEpoch: 4, DepositContractTreeDepth: 32, GenesisDelay: 604800, // 1 week. diff --git a/config/params/minimal_config.go b/config/params/minimal_config.go index 23102ab6c..46d10ddb8 100644 --- a/config/params/minimal_config.go +++ b/config/params/minimal_config.go @@ -82,8 +82,8 @@ func MinimalSpecConfig() *BeaconChainConfig { minimalConfig.GenesisForkVersion = []byte{0, 0, 0, 1} minimalConfig.DepositContractTreeDepth = 32 - minimalConfig.FarFutureEpoch = 1<<64 - 1 - minimalConfig.FarFutureSlot = 1<<64 - 1 + minimalConfig.FarFutureEpoch = math.MaxUint64 + minimalConfig.FarFutureSlot = math.MaxUint64 // New Altair params minimalConfig.AltairForkVersion = []byte{1, 0, 0, 1} // Highest byte set to 0x01 to avoid collisions with mainnet versioning diff --git a/time/slots/slottime_test.go b/time/slots/slottime_test.go index 303431970..2b516bcbe 100644 --- a/time/slots/slottime_test.go +++ b/time/slots/slottime_test.go @@ -416,8 +416,8 @@ func TestPrevSlot(t *testing.T) { }, { name: "max", - slot: 1<<64 - 1, - want: 1<<64 - 1 - 1, + slot: math.MaxUint64, + want: math.MaxUint64 - 1, }, } for _, tt := range tests {