Skip to content

Commit

Permalink
cherry pick: non-zero default period (#14206) + head report chain_id …
Browse files Browse the repository at this point in the history
  • Loading branch information
bukata-sa authored Aug 26, 2024
1 parent d56db81 commit 74a6b00
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 28 deletions.
5 changes: 5 additions & 0 deletions .changeset/eight-bees-speak.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": patch
---

#bugfix head reporter non-zero reporting period
5 changes: 5 additions & 0 deletions .changeset/swift-pumas-taste.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": patch
---

#internal add head report chain_id
11 changes: 6 additions & 5 deletions core/services/headreporter/head_reporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,12 @@ type (

func NewHeadReporterService(ds sqlutil.DataSource, lggr logger.Logger, reporters ...HeadReporter) *HeadReporterService {
return &HeadReporterService{
ds: ds,
lggr: lggr.Named("HeadReporter"),
newHeads: mailbox.NewSingle[*evmtypes.Head](),
chStop: make(chan struct{}),
reporters: reporters,
ds: ds,
lggr: lggr.Named("HeadReporter"),
newHeads: mailbox.NewSingle[*evmtypes.Head](),
chStop: make(chan struct{}),
reporters: reporters,
reportPeriod: 15 * time.Second,
}
}

Expand Down
6 changes: 6 additions & 0 deletions core/services/headreporter/head_reporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"testing"
"time"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"

Expand Down Expand Up @@ -42,4 +43,9 @@ func Test_HeadReporterService(t *testing.T) {

require.Eventually(t, func() bool { return reportCalls.Load() == 2 }, 5*time.Second, 100*time.Millisecond)
})

t.Run("has default report period", func(t *testing.T) {
service := NewHeadReporterService(pgtest.NewSqlxDB(t), logger.TestLogger(t), NewMockHeadReporter(t))
assert.Equal(t, service.reportPeriod, 15*time.Second)
})
}
1 change: 1 addition & 0 deletions core/services/headreporter/telemetry_reporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ func (t *telemetryReporter) ReportNewHead(ctx context.Context, head *evmtypes.He
}
}
request := &telem.HeadReportRequest{
ChainID: head.EVMChainID.String(),
Latest: &telem.Block{
Timestamp: uint64(head.Timestamp.UTC().Unix()),
Number: uint64(head.Number),
Expand Down
2 changes: 2 additions & 0 deletions core/services/headreporter/telemetry_reporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ func Test_TelemetryReporter_NewHead(t *testing.T) {
},
}
requestBytes, err := proto.Marshal(&telem.HeadReportRequest{
ChainID: "100",
Latest: &telem.Block{
Timestamp: uint64(head.Timestamp.UTC().Unix()),
Number: 42,
Expand Down Expand Up @@ -70,6 +71,7 @@ func Test_TelemetryReporter_NewHeadMissingFinalized(t *testing.T) {
IsFinalized: false,
}
requestBytes, err := proto.Marshal(&telem.HeadReportRequest{
ChainID: "100",
Latest: &telem.Block{
Timestamp: uint64(head.Timestamp.UTC().Unix()),
Number: 42,
Expand Down
47 changes: 24 additions & 23 deletions core/services/synchronization/telem/telem_head_report.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 74a6b00

Please sign in to comment.