Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: make mebibyte a constant #4225

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
4 changes: 2 additions & 2 deletions pkg/da/data_availability_header.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,8 @@ func EmptySquareShares() []share.Share {

// SquareSize is a copy of the function defined in the square package to avoid
// a circular dependency. TODO deduplicate
func SquareSize(len int) int {
return RoundUpPowerOfTwo(int(math.Ceil(math.Sqrt(float64(len)))))
func SquareSize(length int) int {
return RoundUpPowerOfTwo(int(math.Ceil(math.Sqrt(float64(length)))))
}

// RoundUpPowerOfTwo returns the next power of two greater than or equal to input.
Expand Down
4 changes: 2 additions & 2 deletions test/txsim/blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ type Range struct {
Max int
}

func NewRange(min, max int) Range {
return Range{Min: min, Max: max}
func NewRange(minimum, maximum int) Range {
return Range{Min: minimum, Max: maximum}
}

// Rand returns a random number between min (inclusive) and max (exclusive).
Expand Down
6 changes: 3 additions & 3 deletions x/blob/ante/max_total_blob_size_ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ func (d MaxTotalBlobSizeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simula
return next(ctx, tx, simulate)
}

max := d.maxTotalBlobSize(ctx)
maximum := d.maxTotalBlobSize(ctx)
for _, m := range tx.GetMsgs() {
if pfb, ok := m.(*blobtypes.MsgPayForBlobs); ok {
if total := getTotal(pfb.BlobSizes); total > max {
return ctx, errors.Wrapf(blobtypes.ErrTotalBlobSizeTooLarge, "total blob size %d exceeds max %d", total, max)
if total := getTotal(pfb.BlobSizes); total > maximum {
return ctx, errors.Wrapf(blobtypes.ErrTotalBlobSizeTooLarge, "total blob size %d exceeds max %d", total, maximum)
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions x/mint/types/minter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,14 @@ func TestCalculateBlockProvisionError(t *testing.T) {
}

func randomBlockInterval() time.Duration {
min := (14 * time.Second).Nanoseconds()
max := (16 * time.Second).Nanoseconds()
return time.Duration(randInRange(min, max))
minimum := (14 * time.Second).Nanoseconds()
maximum := (16 * time.Second).Nanoseconds()
return time.Duration(randInRange(minimum, maximum))
Comment on lines -159 to +161
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why were these also changed?

}

// randInRange returns a random number in the range (min, max) inclusive.
func randInRange(min int64, max int64) int64 {
return rand.Int63n(max-min) + min
func randInRange(minimum int64, maximum int64) int64 {
return rand.Int63n(maximum-minimum) + minimum
Comment on lines -165 to +166
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

}

func BenchmarkCalculateBlockProvision(b *testing.B) {
Expand Down
Loading