Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/_shared-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
uses: golangci/golangci-lint-action@1e7e51e771db61008b38414a730f564565cf7c20 # v9.2.0
with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: v2.7.2
version: v2.11.3

# Optional: working directory, useful for monorepos
# working-directory: somedir
Expand Down
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ var rootCmd = &cobra.Command{
default:
logr.Fatalf("Invalid log format: %s", logFormat)
}

if verbose {
logr.SetLevel(logrus.DebugLevel)
}
Expand All @@ -49,7 +50,6 @@ var rootCmd = &cobra.Command{
if err := coord.Run(cmd.Context()); err != nil {
logr.Fatal(err)
}

},
}

Expand Down
1 change: 1 addition & 0 deletions cmd/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ var validateCmd = &cobra.Command{
Run: func(_ *cobra.Command, _ []string) {
// Set up minimal logging for error output
logrus.SetLevel(logrus.ErrorLevel)

if verbose {
logrus.SetLevel(logrus.DebugLevel)
}
Expand Down
10 changes: 5 additions & 5 deletions pkg/ai/system_prompt.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ func buildTaskDocumentation() string {
}

builder.WriteString("\n```\n\n")
builder.WriteString(fmt.Sprintf("Total: %d tasks available\n\n", len(allTaskNames)))
fmt.Fprintf(&builder, "Total: %d tasks available\n\n", len(allTaskNames))

// Define category order
categoryOrder := []string{"check", "generate", "get", "run", "validator", "utility", "other"}
Expand All @@ -358,11 +358,11 @@ func buildTaskDocumentation() string {
continue
}

builder.WriteString(fmt.Sprintf("### %s Tasks\n\n", titleCaser.String(category)))
fmt.Fprintf(&builder, "### %s Tasks\n\n", titleCaser.String(category))

for _, desc := range descs {
builder.WriteString(fmt.Sprintf("#### %s\n", desc.Name))
builder.WriteString(fmt.Sprintf("**Description:** %s\n\n", desc.Description))
fmt.Fprintf(&builder, "#### %s\n", desc.Name)
fmt.Fprintf(&builder, "**Description:** %s\n\n", desc.Description)

// Add config inputs (from JSON schema)
writeConfigInputs(&builder, desc.ConfigSchema)
Expand All @@ -372,7 +372,7 @@ func buildTaskDocumentation() string {
builder.WriteString("**Outputs:**\n")

for _, output := range desc.Outputs {
builder.WriteString(fmt.Sprintf("- `%s` (%s): %s\n", output.Name, output.Type, output.Description))
fmt.Fprintf(&builder, "- `%s` (%s): %s\n", output.Name, output.Type, output.Description)
}

builder.WriteString("\n")
Expand Down
4 changes: 2 additions & 2 deletions pkg/ai/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -453,9 +453,9 @@ func FormatValidationIssues(issues []ValidationIssue) string {
}

if issue.Path != "" {
sb.WriteString(fmt.Sprintf("%s [%s] %s\n", prefix, issue.Path, issue.Message))
fmt.Fprintf(&sb, "%s [%s] %s\n", prefix, issue.Path, issue.Message)
} else {
sb.WriteString(fmt.Sprintf("%s %s\n", prefix, issue.Message))
fmt.Fprintf(&sb, "%s %s\n", prefix, issue.Message)
}
}

Expand Down
6 changes: 3 additions & 3 deletions pkg/assertoor/coordinator.go
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ func (c *Coordinator) runEpochGC(ctx context.Context) {
if networkTime < 0 {
sleepTime = networkTime.Abs()
} else {
currentSlot := uint64(networkTime / specs.SecondsPerSlot) //nolint:gosec // no overflow possible
currentSlot := uint64(networkTime / specs.SecondsPerSlot) //nolint:gosec // G115: networkTime is checked non-negative above
currentEpoch := currentSlot / specs.SlotsPerEpoch
currentSlotIndex := currentSlot % specs.SlotsPerEpoch
nextGcSlot := uint64(0)
Expand All @@ -388,7 +388,7 @@ func (c *Coordinator) runEpochGC(ctx context.Context) {
case <-time.After(specs.SecondsPerSlot / 2):
}

nextEpochDuration := time.Until(genesis.GenesisTime.Add(time.Duration((currentEpoch+1)*specs.SlotsPerEpoch) * specs.SecondsPerSlot)) //nolint:gosec // no overflow possible
nextEpochDuration := time.Until(genesis.GenesisTime.Add(time.Duration((currentEpoch+1)*specs.SlotsPerEpoch) * specs.SecondsPerSlot)) //nolint:gosec // G115: epoch*slots product won't overflow

c.log.GetLogger().Infof("run GC (slot %v, %v sec before epoch %v)", currentSlot, nextEpochDuration.Seconds(), currentEpoch+1)
runtime.GC()
Expand All @@ -402,7 +402,7 @@ func (c *Coordinator) runEpochGC(ctx context.Context) {
}
}

nextRunTime := genesis.GenesisTime.Add(time.Duration(nextGcSlot) * specs.SecondsPerSlot) //nolint:gosec // no overflow possible
nextRunTime := genesis.GenesisTime.Add(time.Duration(nextGcSlot) * specs.SecondsPerSlot) //nolint:gosec // G115: slot number won't overflow int64
sleepTime = time.Until(nextRunTime)
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/clients/consensus/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func (block *Block) GetSeenBy() []*Client {
block.seenMutex.RLock()
defer block.seenMutex.RUnlock()

clients := []*Client{}
clients := make([]*Client, 0, len(block.seenMap))

for _, client := range block.seenMap {
clients = append(clients, client)
Expand Down
8 changes: 4 additions & 4 deletions pkg/clients/consensus/blockcache.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func (cache *BlockCache) SetMinFollowDistance(followDistance uint64) {
followDistance = 10000
}

followDistance32 := uint32(followDistance) //nolint:gosec // no overflow possible
followDistance32 := uint32(followDistance)

if followDistance32 > cache.followDistance {
cache.followDistance = followDistance32
Expand Down Expand Up @@ -281,7 +281,7 @@ func (cache *BlockCache) AddBlock(root phase0.Root, slot phase0.Slot) (*Block, b
}

if cache.maxSlotIdx < 0 || slot > phase0.Slot(cache.maxSlotIdx) {
cache.maxSlotIdx = int64(slot) //nolint:gosec // no overflow possible
cache.maxSlotIdx = int64(slot) //nolint:gosec // G115: slot values won't exceed int64 max
}

return cacheBlock, true
Expand Down Expand Up @@ -313,8 +313,8 @@ func (cache *BlockCache) GetCachedBlocks() []*Block {
cache.blockMutex.RLock()
defer cache.blockMutex.RUnlock()

blocks := []*Block{}
slots := []phase0.Slot{}
blocks := make([]*Block, 0, len(cache.blockSlotMap))
slots := make([]phase0.Slot, 0, len(cache.blockSlotMap))

for slot := range cache.blockSlotMap {
slots = append(slots, slot)
Expand Down
2 changes: 1 addition & 1 deletion pkg/clients/execution/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func (block *Block) GetSeenBy() []*Client {
block.seenMutex.RLock()
defer block.seenMutex.RUnlock()

clients := []*Client{}
clients := make([]*Client, 0, len(block.seenMap))
for _, client := range block.seenMap {
clients = append(clients, client)
}
Expand Down
8 changes: 4 additions & 4 deletions pkg/clients/execution/blockcache.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func (cache *BlockCache) SetMinFollowDistance(followDistance uint64) {
followDistance = 10000
}

followDistance32 := uint32(followDistance) //nolint:gosec // no overflow possible
followDistance32 := uint32(followDistance)

if followDistance32 > cache.followDistance {
cache.followDistance = followDistance32
Expand Down Expand Up @@ -148,7 +148,7 @@ func (cache *BlockCache) AddBlock(hash common.Hash, number uint64) (*Block, bool
}

if cache.maxSlotIdx < 0 || number > uint64(cache.maxSlotIdx) {
cache.maxSlotIdx = int64(number) //nolint:gosec // no overflow possible
cache.maxSlotIdx = int64(number) //nolint:gosec // G115: block numbers won't exceed int64 max
}

return cacheBlock, true
Expand All @@ -165,8 +165,8 @@ func (cache *BlockCache) GetCachedBlocks() []*Block {
cache.cacheMutex.RLock()
defer cache.cacheMutex.RUnlock()

blocks := []*Block{}
slots := []uint64{}
blocks := make([]*Block, 0, len(cache.numberMap))
slots := make([]uint64, 0, len(cache.numberMap))

for slot := range cache.numberMap {
slots = append(slots, slot)
Expand Down
4 changes: 2 additions & 2 deletions pkg/tasks/check_consensus_attestation_stats/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ func (t *Task) aggregateEpochVotes(ctx context.Context, epoch uint64) []*epochVo
}
}

votes := []*epochVotes{}
votes := make([]*epochVotes, 0, len(allHeads))
for root := range allHeads {
votes = append(votes, allVotes[root])
}
Expand All @@ -565,7 +565,7 @@ func (t *Task) aggregateAttestationVotes(votes *epochVotes, slot, committee uint

for bitIdx, attDuty := range voteValidators {
validatorIdx := attDuty.validator
if aggregationBits.BitAt(uint64(bitIdx) + aggregationBitsOffset) { //nolint:gosec // no overflow possible
if aggregationBits.BitAt(uint64(bitIdx) + aggregationBitsOffset) {
if votes.activityMap[validatorIdx] {
continue
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/tasks/check_consensus_block_proposals/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,9 @@ func (t *Task) Execute(ctx context.Context) error {
}

func (t *Task) setMatchingBlocksOutput(blocks []*consensus.Block) {
blockRoots := []string{}
blockHeaders := []any{}
blockBodies := []any{}
blockRoots := make([]string, 0, len(blocks))
blockHeaders := make([]any, 0, len(blocks))
blockBodies := make([]any, 0, len(blocks))

for _, block := range blocks {
blockRoots = append(blockRoots, block.Root.String())
Expand Down
2 changes: 1 addition & 1 deletion pkg/tasks/check_consensus_sync_status/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ func (t *Task) processClientCheck(client *clients.PoolClient, syncStatus *rpc.Sy
return false
}

if int64(syncStatus.HeadSlot) < int64(t.config.MinSlotHeight) { //nolint:gosec // no overflow possible
if int64(syncStatus.HeadSlot) < int64(t.config.MinSlotHeight) { //nolint:gosec // G115: slot values won't exceed int64 max
checkLogger.Debugf("check failed. check: MinSlotHeight, expected: >= %v, got: %v", t.config.MinSlotHeight, syncStatus.HeadSlot)
return false
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/tasks/check_eth_config/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ func (t *Task) Execute(ctx context.Context) error {

configIndex := 1
for config, clientNames := range configMap {
diffBuilder.WriteString(fmt.Sprintf("Config variant #%d (clients: %v):\n", configIndex, clientNames))
fmt.Fprintf(&diffBuilder, "Config variant #%d (clients: %v):\n", configIndex, clientNames)
diffBuilder.WriteString(config)
diffBuilder.WriteString("\n\n")

Expand Down
2 changes: 1 addition & 1 deletion pkg/tasks/check_execution_sync_status/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ func (t *Task) processClientCheck(client *clients.PoolClient, syncStatus *rpc.Sy
return false
}

if int64(currentBlock) < int64(t.config.MinBlockHeight) { //nolint:gosec // no overflow possible
if int64(currentBlock) < int64(t.config.MinBlockHeight) { //nolint:gosec // G115: block heights won't exceed int64 max
checkLogger.Debugf("check failed. check: MinBlockHeight, expected: >= %v, got: %v", t.config.MinBlockHeight, currentBlock)
return false
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/tasks/generate_attestations/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,10 +265,10 @@ func (t *Task) initValidatorKeys() error {

startIndex := uint64(0)
if t.config.StartIndex > 0 {
startIndex = uint64(t.config.StartIndex) //nolint:gosec // no overflow possible
startIndex = uint64(t.config.StartIndex)
}

endIndex := startIndex + uint64(t.config.IndexCount) //nolint:gosec // no overflow possible
endIndex := startIndex + uint64(t.config.IndexCount) //nolint:gosec // G115: config value is validated non-negative

for accountIdx := startIndex; accountIdx < endIndex; accountIdx++ {
validatorKeyPath := fmt.Sprintf("m/12381/3600/%d/0/0", accountIdx)
Expand Down Expand Up @@ -419,7 +419,7 @@ func (t *Task) findSlotDuties(slot uint64, duties []*v1.BeaconCommittee) []*vali
validatorIndex: valIdx,
committeeIndex: committee.Index,
committeeLength: uint64(len(committee.Validators)),
positionInCommittee: uint64(position), //nolint:gosec // position from range is always non-negative
positionInCommittee: uint64(position),
})
}
}
Expand Down
1 change: 0 additions & 1 deletion pkg/tasks/generate_blob_transactions/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,6 @@ func (t *Task) generateTransaction(ctx context.Context, transactionIdx uint64, c

if t.config.RandomTarget {
addrBytes := make([]byte, 20)
//nolint:errcheck // ignore
rand.Read(addrBytes)
toAddr = common.Address(addrBytes)
} else if t.config.TargetAddress != "" {
Expand Down
6 changes: 3 additions & 3 deletions pkg/tasks/generate_bls_changes/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,11 @@ func (t *Task) LoadConfig() error {

func (t *Task) Execute(ctx context.Context) error {
if t.config.StartIndex > 0 {
t.nextIndex = uint64(t.config.StartIndex) //nolint:gosec // no overflow possible
t.nextIndex = uint64(t.config.StartIndex)
}

if t.config.IndexCount > 0 {
t.lastIndex = t.nextIndex + uint64(t.config.IndexCount) //nolint:gosec // no overflow possible
t.lastIndex = t.nextIndex + uint64(t.config.IndexCount)
}

var subscription *consensus.Subscription[*consensus.Block]
Expand All @@ -141,7 +141,7 @@ func (t *Task) Execute(ctx context.Context) error {
if t.config.LimitTotal > 0 {
targetCount = t.config.LimitTotal
} else if t.lastIndex > 0 {
targetCount = int(t.lastIndex - t.nextIndex) //nolint:gosec // no overflow possible
targetCount = int(t.lastIndex - t.nextIndex) //nolint:gosec // G115: difference is bounded by config values
}

t.ctx.ReportProgress(0, "Starting BLS change generation")
Expand Down
6 changes: 3 additions & 3 deletions pkg/tasks/generate_consolidations/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,11 @@ func (t *Task) LoadConfig() error {
//nolint:gocyclo // no need to reduce complexity
func (t *Task) Execute(ctx context.Context) error {
if t.config.SourceStartIndex > 0 {
t.nextIndex = uint64(t.config.SourceStartIndex) //nolint:gosec // no overflow possible
t.nextIndex = uint64(t.config.SourceStartIndex)
}

if t.config.SourceIndexCount > 0 {
t.lastIndex = t.nextIndex + uint64(t.config.SourceIndexCount) //nolint:gosec // no overflow possible
t.lastIndex = t.nextIndex + uint64(t.config.SourceIndexCount)
}

var subscription *consensus.Subscription[*consensus.Block]
Expand Down Expand Up @@ -204,7 +204,7 @@ func (t *Task) Execute(ctx context.Context) error {
progress := float64(totalCount) / float64(t.config.LimitTotal) * 100
t.ctx.ReportProgress(progress, fmt.Sprintf("Generated %d/%d consolidations", totalCount, t.config.LimitTotal))
case t.lastIndex > 0:
indexTotal := t.lastIndex - uint64(t.config.SourceStartIndex) //nolint:gosec // no overflow possible
indexTotal := t.lastIndex - uint64(t.config.SourceStartIndex) //nolint:gosec // G115: config value is validated non-negative
progress := float64(totalCount) / float64(indexTotal) * 100
t.ctx.ReportProgress(progress, fmt.Sprintf("Generated %d/%d consolidations", totalCount, indexTotal))
default:
Expand Down
6 changes: 3 additions & 3 deletions pkg/tasks/generate_deposits/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,11 @@ func (t *Task) LoadConfig() error {
//nolint:gocyclo // ignore
func (t *Task) Execute(ctx context.Context) error {
if t.config.StartIndex > 0 {
t.nextIndex = uint64(t.config.StartIndex) //nolint:gosec // no overflow possible
t.nextIndex = uint64(t.config.StartIndex)
}

if t.config.IndexCount > 0 {
t.lastIndex = t.nextIndex + uint64(t.config.IndexCount) //nolint:gosec // no overflow possible
t.lastIndex = t.nextIndex + uint64(t.config.IndexCount)
}

var subscription *consensus.Subscription[*consensus.Block]
Expand All @@ -169,7 +169,7 @@ func (t *Task) Execute(ctx context.Context) error {
if t.config.LimitTotal > 0 {
targetCount = t.config.LimitTotal
} else if t.lastIndex > 0 {
targetCount = int(t.lastIndex - t.nextIndex) //nolint:gosec // no overflow possible
targetCount = int(t.lastIndex - t.nextIndex) //nolint:gosec // G115: difference is bounded by config values
}

t.ctx.ReportProgress(0, "Starting deposit generation")
Expand Down
1 change: 0 additions & 1 deletion pkg/tasks/generate_eoa_transactions/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,6 @@ func (t *Task) generateTransaction(ctx context.Context, transactionIdx uint64, c

if t.config.RandomTarget {
addrBytes := make([]byte, 20)
//nolint:errcheck // ignore
rand.Read(addrBytes)
addr = common.Address(addrBytes)
} else if t.config.TargetAddress != "" {
Expand Down
8 changes: 4 additions & 4 deletions pkg/tasks/generate_exits/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@ func (t *Task) LoadConfig() error {

func (t *Task) Execute(ctx context.Context) error {
if t.config.StartIndex > 0 {
t.nextIndex = uint64(t.config.StartIndex) //nolint:gosec // no overflow possible
t.nextIndex = uint64(t.config.StartIndex)
}

if t.config.IndexCount > 0 {
t.lastIndex = t.nextIndex + uint64(t.config.IndexCount) //nolint:gosec // no overflow possible
t.lastIndex = t.nextIndex + uint64(t.config.IndexCount)
}

var subscription *consensus.Subscription[*consensus.Block]
Expand All @@ -132,7 +132,7 @@ func (t *Task) Execute(ctx context.Context) error {
if t.config.LimitTotal > 0 {
targetCount = t.config.LimitTotal
} else if t.lastIndex > 0 {
targetCount = int(t.lastIndex - t.nextIndex) //nolint:gosec // no overflow possible
targetCount = int(t.lastIndex - t.nextIndex) //nolint:gosec // G115: difference is bounded by config values
}

t.ctx.ReportProgress(0, "Starting voluntary exit generation")
Expand Down Expand Up @@ -324,7 +324,7 @@ func (t *Task) generateVoluntaryExit(ctx context.Context, accountIdx uint64, for
}

if t.config.ExitEpoch >= 0 {
operation.Epoch = phase0.Epoch(t.config.ExitEpoch) //nolint:gosec // no overflow possible
operation.Epoch = phase0.Epoch(t.config.ExitEpoch)
} else {
currentSlot, _ := client.GetLastHead()
operation.Epoch = phase0.Epoch(currentSlot / phase0.Slot(specs.SlotsPerEpoch))
Expand Down
Loading
Loading