diff --git a/cmd/devnet/devnetutils/utils.go b/cmd/devnet/devnetutils/utils.go index 4b9e3fe6c97..42c079dffff 100644 --- a/cmd/devnet/devnetutils/utils.go +++ b/cmd/devnet/devnetutils/utils.go @@ -142,10 +142,10 @@ func GenerateTopic(signature string) []libcommon.Hash { } // RandomNumberInRange returns a random number between min and max NOT inclusive -func RandomNumberInRange(min, max uint64) (uint64, error) { - if max <= min { - return 0, fmt.Errorf("Invalid range: upper bound %d less or equal than lower bound %d", max, min) +func RandomNumberInRange(_min, _max uint64) (uint64, error) { + if _max <= _min { + return 0, fmt.Errorf("Invalid range: upper bound %d less or equal than lower bound %d", _max, _min) } - return uint64(RandomInt(int(max-min)) + int(min)), nil + return uint64(RandomInt(int(_max-_min)) + int(_min)), nil } diff --git a/consensus/ethash/consensus_test.go b/consensus/ethash/consensus_test.go index 7ac1e5d5dd0..4436a0bfa46 100644 --- a/consensus/ethash/consensus_test.go +++ b/consensus/ethash/consensus_test.go @@ -95,11 +95,11 @@ func TestCalcDifficulty(t *testing.T) { } } -func randSlice(min, max uint32) []byte { +func randSlice(_min, _max uint32) []byte { var b = make([]byte, 4) rand.Read(b) a := binary.LittleEndian.Uint32(b) - size := min + a%(max-min) + size := _min + a%(_max-_min) out := make([]byte, size) rand.Read(out) return out diff --git a/erigon-lib/chain/snapcfg/util.go b/erigon-lib/chain/snapcfg/util.go index 9d885527675..6a4c4099798 100644 --- a/erigon-lib/chain/snapcfg/util.go +++ b/erigon-lib/chain/snapcfg/util.go @@ -464,17 +464,17 @@ func MergeLimitFromCfg(cfg *Cfg, snapType snaptype.Enum, fromBlock uint64) uint6 } func MaxSeedableSegment(chain string, dir string) uint64 { - var max uint64 + var _max uint64 if list, err := snaptype.Segments(dir); err == nil { for _, info := range list { - if Seedable(chain, info) && info.Type.Enum() == snaptype.MinCoreEnum && info.To > max { - max = info.To + if Seedable(chain, info) && info.Type.Enum() == snaptype.MinCoreEnum && info.To > _max { + _max = info.To } } } - return max + return _max } var oldMergeSteps = append([]uint64{snaptype.Erigon2OldMergeLimit}, snaptype.MergeSteps...) diff --git a/erigon-lib/types/ssz/ssz.go b/erigon-lib/types/ssz/ssz.go index cc5d1ceace7..40d5ad3a19a 100644 --- a/erigon-lib/types/ssz/ssz.go +++ b/erigon-lib/types/ssz/ssz.go @@ -121,7 +121,7 @@ func DecodeDynamicList[T Unmarshaler](bytes []byte, start, end uint32, _max uint return objs, nil } -func DecodeStaticList[T Unmarshaler](bytes []byte, start, end, bytesPerElement uint32, max uint64, version int) ([]T, error) { +func DecodeStaticList[T Unmarshaler](bytes []byte, start, end, bytesPerElement uint32, _max uint64, version int) ([]T, error) { if start > end || len(bytes) < int(end) { return nil, ErrBadOffset } @@ -131,7 +131,7 @@ func DecodeStaticList[T Unmarshaler](bytes []byte, start, end, bytesPerElement u if uint32(len(buf))%bytesPerElement != 0 { return nil, ErrBufferNotRounded } - if elementsNum > max { + if elementsNum > _max { return nil, ErrTooBigList } objs := make([]T, elementsNum) @@ -144,7 +144,7 @@ func DecodeStaticList[T Unmarshaler](bytes []byte, start, end, bytesPerElement u return objs, nil } -func DecodeHashList(bytes []byte, start, end, max uint32) ([]common.Hash, error) { +func DecodeHashList(bytes []byte, start, end, _max uint32) ([]common.Hash, error) { if start > end || len(bytes) < int(end) { return nil, ErrBadOffset } @@ -154,7 +154,7 @@ func DecodeHashList(bytes []byte, start, end, max uint32) ([]common.Hash, error) if uint32(len(buf))%length.Hash != 0 { return nil, ErrBufferNotRounded } - if elementsNum > max { + if elementsNum > _max { return nil, ErrTooBigList } objs := make([]common.Hash, elementsNum) @@ -164,7 +164,7 @@ func DecodeHashList(bytes []byte, start, end, max uint32) ([]common.Hash, error) return objs, nil } -func DecodeNumbersList(bytes []byte, start, end uint32, max uint64) ([]uint64, error) { +func DecodeNumbersList(bytes []byte, start, end uint32, _max uint64) ([]uint64, error) { if start > end || len(bytes) < int(end) { return nil, ErrBadOffset } @@ -174,7 +174,7 @@ func DecodeNumbersList(bytes []byte, start, end uint32, max uint64) ([]uint64, e if uint64(len(buf))%length.BlockNum != 0 { return nil, ErrBufferNotRounded } - if elementsNum > max { + if elementsNum > _max { return nil, ErrTooBigList } objs := make([]uint64, elementsNum) @@ -195,12 +195,12 @@ func CalculateIndiciesLimit(maxCapacity, numItems, size uint64) uint64 { return numItems } -func DecodeString(bytes []byte, start, end, max uint64) ([]byte, error) { +func DecodeString(bytes []byte, start, end, _max uint64) ([]byte, error) { if start > end || len(bytes) < int(end) { return nil, ErrBadOffset } buf := bytes[start:end] - if uint64(len(buf)) > max { + if uint64(len(buf)) > _max { return nil, ErrTooBigList } return buf, nil diff --git a/eth/stagedsync/stage_snapshots.go b/eth/stagedsync/stage_snapshots.go index d4a12250055..269440a6a4b 100644 --- a/eth/stagedsync/stage_snapshots.go +++ b/eth/stagedsync/stage_snapshots.go @@ -758,22 +758,22 @@ func (u *snapshotUploader) init(ctx context.Context, logger log.Logger) { } func (u *snapshotUploader) maxUploadedHeader() uint64 { - var max uint64 + var _max uint64 if len(u.files) > 0 { for _, state := range u.files { if state.local && state.remote { if state.info != nil { if state.info.Type.Enum() == coresnaptype.Enums.Headers { - if state.info.To > max { - max = state.info.To + if state.info.To > _max { + _max = state.info.To } } } else { if info, _, ok := snaptype.ParseFileName(u.cfg.dirs.Snap, state.file); ok { if info.Type.Enum() == coresnaptype.Enums.Headers { - if info.To > max { - max = info.To + if info.To > _max { + _max = info.To } } state.info = &info @@ -783,7 +783,7 @@ func (u *snapshotUploader) maxUploadedHeader() uint64 { } } - return max + return _max } type dirEntry struct { diff --git a/tests/fuzzers/difficulty/difficulty-fuzz.go b/tests/fuzzers/difficulty/difficulty-fuzz.go index 360d8581bd6..887d1d4c5d5 100644 --- a/tests/fuzzers/difficulty/difficulty-fuzz.go +++ b/tests/fuzzers/difficulty/difficulty-fuzz.go @@ -57,15 +57,15 @@ func (f *fuzzer) readSlice(min, max int) []byte { return out } -func (f *fuzzer) readUint64(min, max uint64) uint64 { - if min == max { - return min +func (f *fuzzer) readUint64(_min, _max uint64) uint64 { + if _min == _max { + return _min } var a uint64 if err := binary.Read(f.input, binary.LittleEndian, &a); err != nil { f.exhausted = true } - a = min + a%(max-min) + a = _min + a%(_max-_min) return a } func (f *fuzzer) readBool() bool { diff --git a/turbo/snapshotsync/freezeblocks/bor_snapshots.go b/turbo/snapshotsync/freezeblocks/bor_snapshots.go index 744b6900d23..5b681954f2c 100644 --- a/turbo/snapshotsync/freezeblocks/bor_snapshots.go +++ b/turbo/snapshotsync/freezeblocks/bor_snapshots.go @@ -146,7 +146,7 @@ func (br *BlockRetire) retireBorBlocks(ctx context.Context, minBlockNum uint64, // this is one off code to fix an issue in 2.49.x->2.52.x which missed // removal of intermediate segments after a merge operation -func removeBorOverlaps(dir string, active []snaptype.FileInfo, max uint64) { +func removeBorOverlaps(dir string, active []snaptype.FileInfo, _max uint64) { list, err := snaptype.Segments(dir) if err != nil { @@ -165,12 +165,12 @@ func removeBorOverlaps(dir string, active []snaptype.FileInfo, max uint64) { // added overhead to make sure we don't delete in the // current 500k block segment - if max > 500_001 { - max -= 500_001 + if _max > 500_001 { + _max -= 500_001 } for _, f := range l { - if max < f.From { + if _max < f.From { continue } diff --git a/turbo/snapshotsync/snapshots.go b/turbo/snapshotsync/snapshots.go index 3fc4d054cc3..da86afbc070 100644 --- a/turbo/snapshotsync/snapshots.go +++ b/turbo/snapshotsync/snapshots.go @@ -838,7 +838,7 @@ func (s *RoSnapshots) dirtyIdxAvailability(segtype snaptype.Enum) uint64 { return 0 } - var max uint64 + var _max uint64 dirty.Walk(func(segments []*DirtySegment) bool { for _, seg := range segments { @@ -846,30 +846,30 @@ func (s *RoSnapshots) dirtyIdxAvailability(segtype snaptype.Enum) uint64 { break } - max = seg.to - 1 + _max = seg.to - 1 } return true }) - return max + return _max } func (s *RoSnapshots) visibleIdxAvailability(segtype snaptype.Enum) uint64 { tx := s.ViewType(segtype.Type()) defer tx.Close() - var max uint64 + var _max uint64 for _, seg := range tx.Segments { if !seg.IsIndexed() { break } - max = seg.to - 1 + _max = seg.to - 1 } - return max + return _max } func (s *RoSnapshots) Ls() {