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
1 change: 1 addition & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ func Run(ctx context.Context, conf Config) (err error) {
if err != nil {
return err
}

labels["cluster_peer"] = p2p.PeerName(peerID)

// Update cluster_peer label for Loki
Expand Down
13 changes: 13 additions & 0 deletions app/eth2wrap/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,23 +288,27 @@ func (c *DutiesCache) InvalidateCache(ctx context.Context, epoch eth2p0.Epoch) {
defer c.mu.Unlock()

invalidated := false

for e := range c.proposerDuties {
if e > epoch {
invalidated = true

delete(c.proposerDuties, e)
}
}

for e := range c.attesterDuties {
if e > epoch {
invalidated = true

delete(c.attesterDuties, e)
}
}

for e := range c.syncDuties {
if e > epoch {
invalidated = true

delete(c.syncDuties, e)
}
}
Expand Down Expand Up @@ -336,6 +340,7 @@ func (c *DutiesCache) ProposerDutiesCache(ctx context.Context, epoch eth2p0.Epoc
}

missedCacheCount.WithLabelValues("proposer_duties").Inc()

c.mu.Lock()
defer c.mu.Unlock()

Expand Down Expand Up @@ -385,6 +390,7 @@ func (c *DutiesCache) AttesterDutiesCache(ctx context.Context, epoch eth2p0.Epoc
}

missedCacheCount.WithLabelValues("attester_duties").Inc()

c.mu.Lock()
defer c.mu.Unlock()

Expand Down Expand Up @@ -422,6 +428,7 @@ func (c *DutiesCache) SyncCommDutiesCache(ctx context.Context, epoch eth2p0.Epoc
}

missedCacheCount.WithLabelValues("sync_committee_duties").Inc()

c.mu.Lock()
defer c.mu.Unlock()

Expand Down Expand Up @@ -467,10 +474,12 @@ func (c *DutiesCache) cachedProposerDuties(epoch eth2p0.Epoch, vidxs []eth2p0.Va
}

dutiesFiltered := []*eth2v1.ProposerDuty{}

for _, d := range duties {
if !slices.Contains(vidxs, d.ValidatorIndex) {
continue
}

dutiesFiltered = append(dutiesFiltered, d)
}

Expand All @@ -492,10 +501,12 @@ func (c *DutiesCache) cachedAttesterDuties(epoch eth2p0.Epoch, vidxs []eth2p0.Va
}

dutiesFiltered := []*eth2v1.AttesterDuty{}

for _, d := range duties {
if !slices.Contains(vidxs, d.ValidatorIndex) {
continue
}

dutiesFiltered = append(dutiesFiltered, d)
}

Expand All @@ -517,10 +528,12 @@ func (c *DutiesCache) cachedSyncDuties(epoch eth2p0.Epoch, vidxs []eth2p0.Valida
}

dutiesFiltered := []*eth2v1.SyncCommitteeDuty{}

for _, d := range duties {
if !slices.Contains(vidxs, d.ValidatorIndex) {
continue
}

dutiesFiltered = append(dutiesFiltered, d)
}

Expand Down
2 changes: 2 additions & 0 deletions app/monitoringapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,13 +284,15 @@ func beaconNodeVersionMetric(ctx context.Context, eth2Cl eth2wrap.Client, beacon
if err != nil {
log.Warn(ctx, "Failed to fetch beacon node version", err,
z.Str("beacon_node_address", addr))

continue
}

response, err := scopedClient.NodeIdentity(ctx, &eth2api.NodeIdentityOpts{})
if err != nil {
log.Warn(ctx, "Failed to fetch beacon node identity", err,
z.Str("beacon_node_address", addr))

continue
}

Expand Down
1 change: 1 addition & 0 deletions cmd/test_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ func TestBeaconBasicAuth(t *testing.T) {

// Create a test server that validates basic auth
authValidated := false

server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
// Check if Authorization header is present
auth := r.Header.Get("Authorization")
Expand Down
25 changes: 16 additions & 9 deletions core/consensus/qbft/qbft_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,22 @@ func testQBFTConsensus(t *testing.T, threshold, nodes int) {
lock, p2pkeys, _ := cluster.NewForT(t, 1, threshold, nodes, seed, random)

var (
peers []p2p.Peer
hosts []host.Host
hostsInfo []peer.AddrInfo
components []*qbft.Consensus
results = make(chan core.UnsignedDataSet, threshold)
runErrs = make(chan error, threshold)
sniffed = make(chan int, threshold)
ctx, cancel = context.WithCancel(context.Background())
peers []p2p.Peer
hosts []host.Host
hostsInfo []peer.AddrInfo
components []*qbft.Consensus
results = make(chan core.UnsignedDataSet, threshold)
runErrs = make(chan error, threshold)
sniffed = make(chan int, threshold)
deadlineChan = make(chan core.Duty)
ctx, cancel = context.WithCancel(context.Background())
)
defer cancel()

// Add a test timeout to fail fast instead of waiting for CI's 10-minute timeout
testCtx, testCancel := context.WithTimeout(ctx, 30*time.Second)
defer testCancel()

// Create hosts and enrs (only for threshold).
for i := range threshold {
addr := testutil.AvailableAddr(t)
Expand Down Expand Up @@ -127,7 +132,7 @@ func testQBFTConsensus(t *testing.T, threshold, nodes int) {

deadliner := coremocks.NewDeadliner(t)
deadliner.On("Add", mock.Anything).Return(true)
deadliner.On("C").Return(nil)
deadliner.On("C").Return((<-chan core.Duty)(deadlineChan))

// Create a mock beacon client for test
// Use zero genesis time so timer uses relative timing instead of absolute slot-based timing
Expand Down Expand Up @@ -165,6 +170,8 @@ func testQBFTConsensus(t *testing.T, threshold, nodes int) {

for {
select {
case <-testCtx.Done():
t.Fatal("test timed out waiting for consensus")
case err := <-runErrs:
testutil.RequireNoError(t, err)
case res := <-results:
Expand Down
1 change: 1 addition & 0 deletions core/consensus/timer/roundtimer.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ func (t *doubleEagerLinearRoundTimer) Timer(round int64) (<-chan time.Time, func
} else {
deadline = t.clock.Now().Add(timeout)
}

t.firstDeadlines[round] = deadline
}

Expand Down
1 change: 1 addition & 0 deletions core/tracker/tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ func countAttestations(duty core.Duty, events []event) int {

// Count fetcher events
count := 0

for _, e := range events {
if e.step == fetcher && e.pubkey != "" {
count++
Expand Down
4 changes: 4 additions & 0 deletions core/validatorapi/validatorapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -1123,10 +1123,12 @@ func (c Component) ProposerDuties(ctx context.Context, opts *eth2api.ProposerDut
// Replace root public keys with public shares.
// Duties are copied into new slice, as otherwise the cached duties would be modified.
dutiesShareKey := []*eth2v1.ProposerDuty{}

for _, d := range cachedResp {
if d == nil {
return nil, errors.New("nil proposer duty from cache")
}

duty := *d

pubshare, ok := c.getPubShareFunc(duty.PubKey)
Expand Down Expand Up @@ -1158,6 +1160,7 @@ func (c Component) AttesterDuties(ctx context.Context, opts *eth2api.AttesterDut
// Replace root public keys with public shares.
// Duties are copied into new slice, as otherwise the cached duties would be modified.
dutiesShareKey := []*eth2v1.AttesterDuty{}

for _, d := range cachedResp {
if d == nil {
return nil, errors.New("attester duty cannot be nil")
Expand Down Expand Up @@ -1187,6 +1190,7 @@ func (c Component) SyncCommitteeDuties(ctx context.Context, opts *eth2api.SyncCo
// Replace root public keys with public shares.
// Duties are copied into new slice, as otherwise the cached duties would be modified.
dutiesShareKey := []*eth2v1.SyncCommitteeDuty{}

for _, d := range cachedResp {
if d == nil {
return nil, errors.New("sync committee duty cannot be nil")
Expand Down
Loading