Skip to content

Commit

Permalink
Linting.
Browse files Browse the repository at this point in the history
  • Loading branch information
mcdee committed Oct 1, 2024
1 parent 0276a72 commit 72a9390
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 16 deletions.
4 changes: 2 additions & 2 deletions cmd/block/analyze/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func (c *command) analyzeAttestations(ctx context.Context, block *spec.Versioned

// Count new votes.
analysis.PossibleVotes = int(attestation.AggregationBits.Len())
for j := uint64(0); j < attestation.AggregationBits.Len(); j++ {
for j := range attestation.AggregationBits.Len() {
if attestation.AggregationBits.BitAt(j) {
analysis.Votes++
if blockVotes[data.Slot][data.Index].BitAt(j) {
Expand Down Expand Up @@ -269,7 +269,7 @@ func (c *command) processParentBlock(_ context.Context, block *spec.VersionedSig
if !exists {
c.votes[data.Slot][data.Index] = bitfield.NewBitlist(attestation.AggregationBits.Len())
}
for j := uint64(0); j < attestation.AggregationBits.Len(); j++ {
for j := range attestation.AggregationBits.Len() {
if attestation.AggregationBits.BitAt(j) {
c.votes[data.Slot][data.Index].SetBitAt(j, true)
}
Expand Down
12 changes: 6 additions & 6 deletions cmd/block/info/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ func outputBlockSyncAggregate(ctx context.Context, eth2Client eth2client.Service
res.WriteString(fmt.Sprintf(" Error: failed to obtain sync committee: %v\n", err))
} else {
res.WriteString(" Contributing validators:")
for i := uint64(0); i < syncAggregate.SyncCommitteeBits.Len(); i++ {
for i := range syncAggregate.SyncCommitteeBits.Len() {
if syncAggregate.SyncCommitteeBits.BitAt(i) {
res.WriteString(fmt.Sprintf(" %d", syncCommitteeResponse.Data.Validators[i]))
}
Expand Down Expand Up @@ -791,7 +791,7 @@ func outputCapellaBlockExecutionPayload(_ context.Context,
res.WriteString(" Execution block number: ")
res.WriteString(fmt.Sprintf("%d\n", payload.BlockNumber))
baseFeePerGasBEBytes := make([]byte, len(payload.BaseFeePerGas))
for i := 0; i < 32; i++ {
for i := range 32 {
baseFeePerGasBEBytes[i] = payload.BaseFeePerGas[32-1-i]
}
baseFeePerGas := new(big.Int).SetBytes(baseFeePerGasBEBytes)
Expand Down Expand Up @@ -953,7 +953,7 @@ func outputBellatrixBlockExecutionPayload(_ context.Context,
res.WriteString(" Execution block number: ")
res.WriteString(fmt.Sprintf("%d\n", payload.BlockNumber))
baseFeePerGasBEBytes := make([]byte, len(payload.BaseFeePerGas))
for i := 0; i < 32; i++ {
for i := range 32 {
baseFeePerGasBEBytes[i] = payload.BaseFeePerGas[32-1-i]
}
baseFeePerGas := new(big.Int).SetBytes(baseFeePerGasBEBytes)
Expand Down Expand Up @@ -1016,7 +1016,7 @@ func bitlistToString(input bitfield.Bitlist) string {
bits := int(input.Len())

res := ""
for i := 0; i < bits; i++ {
for i := range bits {
if input.BitAt(uint64(i)) {
res = fmt.Sprintf("%s✓", res)
} else {
Expand All @@ -1033,7 +1033,7 @@ func bitvectorToString(input bitfield.Bitvector512) string {
bits := int(input.Len())

res := strings.Builder{}
for i := 0; i < bits; i++ {
for i := range bits {
if input.BitAt(uint64(i)) {
res.WriteString("✓")
} else {
Expand All @@ -1049,7 +1049,7 @@ func bitvectorToString(input bitfield.Bitvector512) string {
func attestingIndices(input bitfield.Bitlist, indices []phase0.ValidatorIndex) string {
bits := int(input.Len())
res := ""
for i := 0; i < bits; i++ {
for i := range bits {
if input.BitAt(uint64(i)) {
res = fmt.Sprintf("%s%d ", res, indices[i])
}
Expand Down
3 changes: 2 additions & 1 deletion cmd/block/info/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,8 @@ func headEventHandler(event *apiv1.Event) {
err = outputCapellaBlock(ctx, jsonOutput, sszOutput, block.Capella)
case spec.DataVersionDeneb:
var blobSidecars []*deneb.BlobSidecar
kzgCommitments, err := block.BlobKZGCommitments()
var kzgCommitments []deneb.KZGCommitment
kzgCommitments, err = block.BlobKZGCommitments()
if err != nil {
fmt.Fprintf(os.Stderr, "Failed to obtain KZG commitments: %v\n", err)
return
Expand Down
2 changes: 1 addition & 1 deletion cmd/chain/verify/signedcontributionandproof/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ func (c *command) confirmContributionSignature(ctx context.Context) error {

subCommittee := c.syncCommittee.ValidatorAggregates[c.item.Message.Contribution.SubcommitteeIndex]
includedIndices := make([]phase0.ValidatorIndex, 0, len(subCommittee))
for i := uint64(0); i < c.item.Message.Contribution.AggregationBits.Len(); i++ {
for i := range c.item.Message.Contribution.AggregationBits.Len() {
if c.item.Message.Contribution.AggregationBits.BitAt(i) {
includedIndices = append(includedIndices, subCommittee[int(i)])
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/epoch/summary/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ func (c *command) processSlots(ctx context.Context,
return nil, nil, nil, nil, nil, nil, nil, err
}

for i := uint64(0); i < attestation.AggregationBits.Len(); i++ {
for i := range attestation.AggregationBits.Len() {
if attestation.AggregationBits.BitAt(i) {
validatorIndex := committee[int(i)]
if len(c.validators) > 0 {
Expand Down Expand Up @@ -399,7 +399,7 @@ func (c *command) processSyncCommitteeDuties(ctx context.Context) error {
if err != nil {
return errors.Wrapf(err, "failed to obtain sync aggregate for slot %d", slot)
}
for i := uint64(0); i < aggregate.SyncCommitteeBits.Len(); i++ {
for i := range aggregate.SyncCommitteeBits.Len() {
validatorIndex := committee.Validators[int(i)]
if _, exists := c.validators[validatorIndex]; !exists {
// Not one of ours.
Expand Down
2 changes: 1 addition & 1 deletion cmd/validator/keycheck/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func checkMnemonic(ctx context.Context, debug bool, validatorWithdrawalCredentia
// Create seed from mnemonic and passphrase.
seed := bip39.NewSeed(mnemonic, mnemonicPassphrase)
// Check first 1024 indices.
for i := 0; i < 1024; i++ {
for i := range 1024 {
path := fmt.Sprintf("m/12381/3600/%d/0", i)
if debug {
fmt.Printf("Checking path %s\n", path)
Expand Down
6 changes: 3 additions & 3 deletions shamir/shamir.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ func (p *polynomial) evaluate(x uint8) uint8 {
func interpolatePolynomial(xSamples, ySamples []uint8, x uint8) uint8 {
limit := len(xSamples)
var result, basis uint8
for i := 0; i < limit; i++ {
for i := range limit {
basis = 1
for j := 0; j < limit; j++ {
for j := range limit {
if i == j {
continue
}
Expand Down Expand Up @@ -183,7 +183,7 @@ func Split(secret []byte, parts, threshold int) ([][]byte, error) {
// Generate a `parts` number of (x,y) pairs
// We cheat by encoding the x value once as the final index,
// so that it only needs to be stored once.
for i := 0; i < parts; i++ {
for i := range parts {
x := uint8(xCoordinates[i]) + 1
y := p.evaluate(x)
out[i][idx] = y
Expand Down

0 comments on commit 72a9390

Please sign in to comment.