diff --git a/cmd/block/analyze/process.go b/cmd/block/analyze/process.go index 40b2877..66b3ef2 100644 --- a/cmd/block/analyze/process.go +++ b/cmd/block/analyze/process.go @@ -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) { @@ -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) } diff --git a/cmd/block/info/output.go b/cmd/block/info/output.go index 8dc6953..dd3a50f 100644 --- a/cmd/block/info/output.go +++ b/cmd/block/info/output.go @@ -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])) } @@ -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) @@ -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) @@ -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 { @@ -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 { @@ -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]) } diff --git a/cmd/block/info/process.go b/cmd/block/info/process.go index 329d13d..6daf472 100644 --- a/cmd/block/info/process.go +++ b/cmd/block/info/process.go @@ -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 diff --git a/cmd/chain/verify/signedcontributionandproof/process.go b/cmd/chain/verify/signedcontributionandproof/process.go index caedf38..5c5271b 100644 --- a/cmd/chain/verify/signedcontributionandproof/process.go +++ b/cmd/chain/verify/signedcontributionandproof/process.go @@ -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)]) } diff --git a/cmd/epoch/summary/process.go b/cmd/epoch/summary/process.go index bd3530f..93759f1 100644 --- a/cmd/epoch/summary/process.go +++ b/cmd/epoch/summary/process.go @@ -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 { @@ -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. diff --git a/cmd/validator/keycheck/process.go b/cmd/validator/keycheck/process.go index 0488c2c..014bff5 100644 --- a/cmd/validator/keycheck/process.go +++ b/cmd/validator/keycheck/process.go @@ -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) diff --git a/shamir/shamir.go b/shamir/shamir.go index 82a88b3..85cd45f 100644 --- a/shamir/shamir.go +++ b/shamir/shamir.go @@ -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 } @@ -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