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/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@v8
with:
version: v2.4.0
version: v2.5.0
2 changes: 1 addition & 1 deletion .pre-commit/run_linter.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

VERSION="v2.4.0"
VERSION="v2.5.0"

if ! command -v golangci-lint &>/dev/null; then
echo "golangci-lint could not be found"
Expand Down
2 changes: 2 additions & 0 deletions app/eth2wrap/eth2wrap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ func TestMulti(t *testing.T) {
name: "cl1 error, cl2 ok",
handle: func(cl1, cl2 chan *eth2v1.PeerCount, _ context.CancelFunc) {
close(cl1)

cl2 <- &eth2v1.PeerCount{Connected: 99}
},
expRes: &eth2api.Response[*eth2v1.PeerCount]{Data: &eth2v1.PeerCount{Connected: 99}},
Expand All @@ -90,6 +91,7 @@ func TestMulti(t *testing.T) {
cl2 <- &eth2v1.PeerCount{Connected: 99}

time.Sleep(time.Millisecond)

cl1 <- &eth2v1.PeerCount{Connected: 98} // This might flap?
},
expRes: &eth2api.Response[*eth2v1.PeerCount]{Data: &eth2v1.PeerCount{Connected: 99}},
Expand Down
2 changes: 1 addition & 1 deletion app/eth2wrap/valcache.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (c *ValidatorCache) cached() (CompleteValidators, bool) {
return c.complete, c.complete != nil
}

// Get returns the cached active validators, cached complete Validators response, or fetches them if not available populating the cache.
// GetByHead returns the cached active validators, cached complete Validators response, or fetches them if not available populating the cache.
func (c *ValidatorCache) GetByHead(ctx context.Context) (ActiveValidators, CompleteValidators, error) {
completeCached, completeOk := c.cached()
activeCached, activeOk := c.activeCached()
Expand Down
2 changes: 2 additions & 0 deletions app/forkjoin/forkjoin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,11 @@ func TestForkJoin(t *testing.T) {
if i == 0 {
return 0, testErr
}

if i > n/2 {
require.Fail(t, "not failed fast")
}

<-ctx.Done() // This will hang if not failing fast

return 0, ctx.Err()
Expand Down
4 changes: 1 addition & 3 deletions app/health/checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,7 @@ func newQueryFunc(metrics [][]*pb.MetricFamily) func(string, labelSelector, seri

for _, fams := range metrics {
for _, fam := range fams {
if fam.GetName() != name {
continue
} else if len(fam.GetMetric()) == 0 {
if fam.GetName() != name || len(fam.GetMetric()) == 0 {
continue
}

Expand Down
2 changes: 2 additions & 0 deletions app/obolapi/api_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ func TestHttpPost(t *testing.T) {

data, err := io.ReadAll(r.Body)
require.NoError(t, err)

defer r.Body.Close()

require.JSONEq(t, string(data), `{"test_body_key": "test_body_value"}`)

w.WriteHeader(http.StatusOK)
Expand Down
9 changes: 6 additions & 3 deletions app/retry/retry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ func TestRetryer(t *testing.T) {
if attempt == 0 {
return context.Canceled
}
return nil //nolint:nlreturn

return nil
},
ExpectBackoffs: 1,
},
Expand All @@ -51,7 +52,8 @@ func TestRetryer(t *testing.T) {
if attempt < 5 {
return context.Canceled
}
return nil //nolint:nlreturn

return nil
},
ExpectBackoffs: 5,
},
Expand All @@ -61,7 +63,8 @@ func TestRetryer(t *testing.T) {
if attempt == 0 {
return context.Canceled
}
return nil //nolint:nlreturn

return nil
},
TimeoutCount: 1,
ExpectBackoffs: 1,
Expand Down
1 change: 1 addition & 0 deletions cmd/createdkg.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ func isMainOrGnosis(network string) bool {
func generateLaunchpadLink(configHash []byte, network string) string {
var networkLink string

//nolint:revive // `case "mainnet"` and `default` having same result is not an issue, it improves readability.
switch network {
case "mainnet":
networkLink = ""
Expand Down
1 change: 1 addition & 0 deletions cmd/createdkg_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ func TestDKGCLI(t *testing.T) {
},
cleanup: func(t *testing.T) {
t.Helper()

err := os.RemoveAll(".charon")
require.NoError(t, err)
},
Expand Down
1 change: 1 addition & 0 deletions cmd/dkg.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ this command at the same time.`,
if err := log.InitLogger(config.Log); err != nil {
return err
}

libp2plog.SetPrimaryCore(log.LoggerCore()) // Set libp2p logger to use charon logger

printLicense(cmd.Context())
Expand Down
1 change: 1 addition & 0 deletions cmd/exit_broadcast.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ func newBcastFullExitCmd(runFunc func(context.Context, exitConfig) error) *cobra
if err := log.InitLogger(config.Log); err != nil {
return err
}

libp2plog.SetPrimaryCore(log.LoggerCore()) // Set libp2p logger to use charon logger

printFlags(cmd.Context(), cmd.Flags())
Expand Down
1 change: 1 addition & 0 deletions cmd/exit_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func newDeleteExitCmd(runFunc func(context.Context, exitConfig) error) *cobra.Co
if err := log.InitLogger(config.Log); err != nil {
return err
}

libp2plog.SetPrimaryCore(log.LoggerCore()) // Set libp2p logger to use charon logger

printFlags(cmd.Context(), cmd.Flags())
Expand Down
1 change: 1 addition & 0 deletions cmd/exit_fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ func newFetchExitCmd(runFunc func(context.Context, exitConfig) error) *cobra.Com
if err := log.InitLogger(config.Log); err != nil {
return err
}

libp2plog.SetPrimaryCore(log.LoggerCore()) // Set libp2p logger to use charon logger

printFlags(cmd.Context(), cmd.Flags())
Expand Down
1 change: 1 addition & 0 deletions cmd/exit_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ func newListActiveValidatorsCmd(runFunc func(context.Context, exitConfig) error)
if err := log.InitLogger(config.Log); err != nil {
return err
}

libp2plog.SetPrimaryCore(log.LoggerCore()) // Set libp2p logger to use charon logger

printFlags(cmd.Context(), cmd.Flags())
Expand Down
1 change: 1 addition & 0 deletions cmd/exit_sign.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ func newSignPartialExitCmd(runFunc func(context.Context, exitConfig) error) *cob
if err := log.InitLogger(config.Log); err != nil {
return err
}

libp2plog.SetPrimaryCore(log.LoggerCore()) // Set libp2p logger to use charon logger

printFlags(cmd.Context(), cmd.Flags())
Expand Down
1 change: 1 addition & 0 deletions cmd/relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ func newRelayCmd(runFunc func(context.Context, relay.Config) error) *cobra.Comma
if err := log.InitLogger(config.LogConfig); err != nil {
return err
}

libp2plog.SetPrimaryCore(log.LoggerCore()) // Set libp2p logger to use charon logger

printLicense(cmd.Context())
Expand Down
1 change: 1 addition & 0 deletions cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ func newRunCmd(runFunc func(context.Context, app.Config) error, unsafe bool) *co
if err := log.InitLogger(conf.Log); err != nil {
return err
}

libp2plog.SetPrimaryCore(log.LoggerCore()) // Set libp2p logger to use charon logger

printLicense(cmd.Context())
Expand Down
1 change: 1 addition & 0 deletions cmd/testbeacon_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ func TestBeaconTest(t *testing.T) {
expectedErr: "",
cleanup: func(t *testing.T, p string) {
t.Helper()

err := os.Remove(p)
require.NoError(t, err)
},
Expand Down
1 change: 1 addition & 0 deletions cmd/testinfra_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ func TestInfraTest(t *testing.T) {
expectedErr: "",
cleanup: func(t *testing.T, p string) {
t.Helper()

err := os.Remove(p)
require.NoError(t, err)
},
Expand Down
1 change: 1 addition & 0 deletions cmd/testmev_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ func TestMEVTest(t *testing.T) {
expectedErr: "",
cleanup: func(t *testing.T, p string) {
t.Helper()

err := os.Remove(p)
require.NoError(t, err)
},
Expand Down
1 change: 1 addition & 0 deletions cmd/testpeers_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ func TestPeersTest(t *testing.T) {
expectedErr: "",
cleanup: func(t *testing.T, p string) {
t.Helper()

err := os.Remove(p)
require.NoError(t, err)
},
Expand Down
1 change: 1 addition & 0 deletions cmd/testvalidator_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ func TestValidatorTest(t *testing.T) {
expectedErr: "",
cleanup: func(t *testing.T, p string) {
t.Helper()

err := os.Remove(p)
require.NoError(t, err)
},
Expand Down
1 change: 1 addition & 0 deletions core/bcast/bcast.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ func (b Broadcaster) Broadcast(ctx context.Context, duty core.Duty, set core.Sig
}
}()

//nolint:revive // `case core.DutyRandao` and `case core.DutyPrepareAggregator` having same result is not an issue, it improves readability.
switch duty.Type {
case core.DutyAttester:
atts, err := setToAttestations(set)
Expand Down
1 change: 1 addition & 0 deletions core/consensus/qbft/qbft.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ func newDefinition(nodes int, subs func() []subscriber, roundTimer timer.RoundTi
for _, step := range steps {
fields = append(fields, z.Str(step.Type.String(), fmtStepPeers(step)))
}

if uponRule == qbft.UponRoundTimeout {
fields = append(fields, z.Str("timeout_reason", timeoutReason(steps, round, quorum)))
}
Expand Down
2 changes: 2 additions & 0 deletions core/consensus/qbft/strategysim_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -509,9 +509,11 @@ func newSimDefinition(nodes int, roundTimer timer.RoundTimer,
for _, step := range steps {
fields = append(fields, z.Str(step.Type.String(), fmtStepPeers(step)))
}

if uponRule == qbft.UponRoundTimeout {
fields = append(fields, z.Str("timeout_reason", timeoutReason(steps, round, quorum)))
}

log.Debug(ctx, "QBFT round changed", fields...)
},
// LogUponRule logs upon rules at debug level.
Expand Down
2 changes: 1 addition & 1 deletion core/consensus/timer/roundtimer.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func NewIncreasingRoundTimerWithDuty(duty core.Duty) RoundTimer {
}
}

// NewIncreasingRoundTimerWithDuty returns a new eager double linear round timer type for a specific duty and custom clock.
// NewIncreasingRoundTimerWithDutyAndClock returns a new eager double linear round timer type for a specific duty and custom clock.
func NewIncreasingRoundTimerWithDutyAndClock(duty core.Duty, clock clockwork.Clock) RoundTimer {
return &increasingRoundTimer{
clock: clock,
Expand Down
7 changes: 7 additions & 0 deletions core/parsigex/memory.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,27 +39,34 @@ func NewMemExFunc(expectedPeers int) func() core.ParSigEx {
getSubs: func() []sub {
// Wait for all expected peers to be registered.
t0 := time.Now()

for {
mu.Lock()

if len(subs) == expectedPeers {
mu.Unlock()
break
}

mu.Unlock()

if time.Since(t0) > 10*time.Second {
panic("timeout waiting for all peers to register")
}

time.Sleep(time.Millisecond)
}

mu.Lock()
defer mu.Unlock()

var others []sub // Get other peer's subscriptions.

for index, s := range subs {
if index == i {
continue
}

others = append(others, s...)
}

Expand Down
1 change: 1 addition & 0 deletions core/qbft/qbft.go
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,7 @@ func nextMinRound[I any, V comparable](d Definition[I, V], frc []Msg[I, V], roun

// isJustified returns true if message is justified or if it does not need justification.
func isJustified[I any, V comparable](d Definition[I, V], instance I, msg Msg[I, V]) bool {
//nolint:revive // `case MsgPrepare` and `case MsgCommit` having same result is not an issue, it improves readability.
switch msg.Type() {
case MsgPrePrepare:
return isJustifiedPrePrepare(d, instance, msg)
Expand Down
5 changes: 5 additions & 0 deletions core/qbft/qbft_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ func testQBFT(t *testing.T, test test) {
},
LogUponRule: func(_ context.Context, instance int64, process, round int64, msg Msg[int64, int64], rule UponRule) {
t.Logf("%s %d => %v@%d -> %v@%d ~= %v", clock.NowStr(), msg.Source(), msg.Type(), msg.Round(), process, round, rule)

if round > maxRound {
cancel()
}
Expand All @@ -327,6 +328,7 @@ func testQBFT(t *testing.T, test test) {
if test.Fuzz {
return // Ignore unjust messages when fuzzing.
}

t.Logf("Unjust: %#v", msg)
cancel()
},
Expand All @@ -344,14 +346,17 @@ func testQBFT(t *testing.T, test test) {
if round > maxRound {
return errors.New("max round reach")
}

if typ == MsgCommit && int(round) <= test.CommitsAfter {
t.Logf("%s %v dropping early commit for round %d", clock.NowStr(), source, round)
return nil
}

t.Logf("%s %v => %v@%d", clock.NowStr(), source, typ, round)

msg := newMsg(typ, instance, source, round, value, pr, pv, justify)
receive <- msg // Always send to self first (no jitter, no drops).

bcast(t, broadcast, msg, test.BCastJitterMS, clock)

return nil
Expand Down
2 changes: 1 addition & 1 deletion core/ssz.go
Original file line number Diff line number Diff line change
Expand Up @@ -846,7 +846,7 @@ func VersionedBlindedSSZValueForT(t *testing.T, value any, version eth2util.Data
return resp
}

// VersionedBlindedSSZValueForT exposes the value method of a type for testing purposes.
// VersionedSSZValueForT exposes the value method of a type for testing purposes.
func VersionedSSZValueForT(t *testing.T, value any, version eth2util.DataVersion) sszType {
t.Helper()

Expand Down
6 changes: 6 additions & 0 deletions core/tracker/inclusion_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,10 @@ func TestDuplicateAttData(t *testing.T) {
attestationsFunc: func(attData *eth2p0.AttestationData, aggBits1 bitfield.Bitlist, aggBits2 bitfield.Bitlist, aggBits3 bitfield.Bitlist) []*eth2spec.VersionedAttestation {
zeroComm := bitfield.NewBitvector64()
zeroComm.SetBitAt(0, true)

oneComm := bitfield.NewBitvector64()
oneComm.SetBitAt(1, true)

twoComm := bitfield.NewBitvector64()
twoComm.SetBitAt(2, true)

Expand All @@ -146,8 +148,10 @@ func TestDuplicateAttData(t *testing.T) {
zeroTwoComm := bitfield.NewBitvector64()
zeroTwoComm.SetBitAt(0, true)
zeroTwoComm.SetBitAt(2, true)

oneComm := bitfield.NewBitvector64()
oneComm.SetBitAt(1, true)

complexAttestationAggBits := slices.Concat(aggBits1, aggBits2)

return []*eth2spec.VersionedAttestation{
Expand All @@ -169,8 +173,10 @@ func TestDuplicateAttData(t *testing.T) {
attestationsFunc: func(attData *eth2p0.AttestationData, aggBits1 bitfield.Bitlist, aggBits2 bitfield.Bitlist, aggBits3 bitfield.Bitlist) []*eth2spec.VersionedAttestation {
zeroComm := bitfield.NewBitvector64()
zeroComm.SetBitAt(0, true)

oneComm := bitfield.NewBitvector64()
oneComm.SetBitAt(1, true)

twoComm := bitfield.NewBitvector64()
twoComm.SetBitAt(2, true)

Expand Down
2 changes: 2 additions & 0 deletions core/validatorapi/router_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ func TestRawRouter(t *testing.T) {
ProxyHandler: func(w http.ResponseWriter, r *http.Request) {
b, err := httputil.DumpRequest(r, false)
require.NoError(t, err)

_, _ = w.Write(b)
},
}
Expand Down Expand Up @@ -936,6 +937,7 @@ func TestRouter(t *testing.T) {
handler := testHandler{
ValidatorsFunc: func(ctx context.Context, opts *eth2api.ValidatorsOpts) (*eth2api.Response[map[eth2p0.ValidatorIndex]*eth2v1.Validator], error) {
res := make(map[eth2p0.ValidatorIndex]*eth2v1.Validator)

for _, pubkey := range opts.PubKeys {
idx++
res[idx] = &eth2v1.Validator{
Expand Down
Loading
Loading