From 13380af31830b6b8ef0eb320e019523d5f9fcd91 Mon Sep 17 00:00:00 2001 From: Arijit Das Date: Sat, 10 Jul 2021 01:22:02 +0530 Subject: [PATCH] fix(dot/types): fix max value for digest (#1687) Co-authored-by: noot <36753753+noot@users.noreply.github.com> --- dot/digest/digest.go | 3 ++- go.sum | 1 - lib/grandpa/grandpa.go | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dot/digest/digest.go b/dot/digest/digest.go index f48c2d9c5a..a511e0160e 100644 --- a/dot/digest/digest.go +++ b/dot/digest/digest.go @@ -19,6 +19,7 @@ package digest import ( "context" "errors" + "math" "math/big" "github.com/ChainSafe/gossamer/dot/types" @@ -28,7 +29,7 @@ import ( log "github.com/ChainSafe/log15" ) -var maxUint64 = uint64(2^64) - 1 +var maxUint64 = uint64(math.MaxUint64) var ( _ services.Service = &Handler{} diff --git a/go.sum b/go.sum index dc3f2bccbb..69581e72c2 100644 --- a/go.sum +++ b/go.sum @@ -273,7 +273,6 @@ github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfb github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= -github.com/golang/mock v1.4.4 h1:l75CXGRSwbaYNpl/Z2X1XIIAMSCquvXgpVZDhwEIJsc= github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.0/go.mod h1:Qd/q+1AKNOZr9uGQzbzCmRO6sUih6GTPZv6a1/R87v0= diff --git a/lib/grandpa/grandpa.go b/lib/grandpa/grandpa.go index e4d996738e..6d7078f69f 100644 --- a/lib/grandpa/grandpa.go +++ b/lib/grandpa/grandpa.go @@ -710,11 +710,11 @@ func (s *Service) determinePreVote() (*Vote, error) { nextChange := s.digestHandler.NextGrandpaAuthorityChange() if uint64(vote.number) > nextChange { - header, err := s.blockState.GetHeaderByNumber(big.NewInt(int64(nextChange))) + headerNum := new(big.Int).SetUint64(nextChange) + header, err := s.blockState.GetHeaderByNumber(headerNum) if err != nil { return nil, err } - vote = NewVoteFromHeader(header) }