diff --git a/go-ethereum/common/hexutil/hexutil.go b/go-ethereum/common/hexutil/hexutil.go index 7a47c47f..30548355 100644 --- a/go-ethereum/common/hexutil/hexutil.go +++ b/go-ethereum/common/hexutil/hexutil.go @@ -34,11 +34,10 @@ import ( "encoding/hex" "fmt" "math/big" + "math/bits" "strconv" ) -const uintBits = 32 << (uint64(^uint(0)) >> 63) - // Errors var ( ErrEmptyString = &decError{"empty hex string"} @@ -48,7 +47,7 @@ var ( ErrEmptyNumber = &decError{"hex string \"0x\""} ErrLeadingZero = &decError{"hex number with leading zero digits"} ErrUint64Range = &decError{"hex number > 64 bits"} - ErrUintRange = &decError{fmt.Sprintf("hex number > %d bits", uintBits)} + ErrUintRange = &decError{fmt.Sprintf("hex number > %d bits", bits.UintSize)} ErrBig256Range = &decError{"hex number > 256 bits"} ) diff --git a/go-ethereum/common/hexutil/json_test.go b/go-ethereum/common/hexutil/json_test.go index 7cca3009..a0144384 100644 --- a/go-ethereum/common/hexutil/json_test.go +++ b/go-ethereum/common/hexutil/json_test.go @@ -22,6 +22,7 @@ import ( "encoding/json" "errors" "math/big" + "math/bits" "testing" "github.com/holiman/uint256" @@ -384,7 +385,7 @@ func TestUnmarshalUint(t *testing.T) { for _, test := range unmarshalUintTests { var v Uint err := json.Unmarshal([]byte(test.input), &v) - if uintBits == 32 && test.wantErr32bit != nil { + if bits.UintSize == 32 && test.wantErr32bit != nil { checkError(t, test.input, err, test.wantErr32bit) continue }