Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CCIP-2611] Report new heads to atlas' OTI #13647

Merged
merged 22 commits into from
Aug 15, 2024
Merged

Conversation

bukata-sa
Copy link
Contributor

@bukata-sa bukata-sa commented Jun 21, 2024

CCIP-2611
Report new heads to atlas' OTI to track NOPs health (block delay)

Requires Dependencies

Add wsRPC endoint in Atlas's OTI: https://github.com/smartcontractkit/atlas/pull/6394/files

Resolves Dependencies

None

Comment on lines 36 to 51
request := &telem.HeadReportRequest{
ChainId: head.EVMChainID.String(),
Timestamp: uint64(head.Timestamp.UTC().Unix()),
BlockNumber: uint64(head.Number),
BlockHash: head.Hash.Hex(),
Finalized: head.IsFinalized,
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need this to be something like:

type Block struct {
  Timestamp uint64
  Number    uint64
  Hash      string
}
type HeadReportRequest {
  ChainId   uint64
  Latest    Block
  Finalized Block
}

Use head.LatestFinalizedHead() to fetch finalized for a given latest head.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i.e. we want block info for both latest and finalized (at that latest point in time)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

)

func NewTelemetryReporter(chainContainer legacyevm.LegacyChainContainer, lggr logger.Logger, monitoringEndpointGen telemetry.MonitoringEndpointGenerator) *telemetryReporter {
endpoints := make(map[*big.Int]commontypes.MonitoringEndpoint)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A pointer is not a good key for a map, as any new pointer (even with same value) will have a different place in memory; if it is chainID, it's safe to use uint64

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

func NewTelemetryReporter(chainContainer legacyevm.LegacyChainContainer, lggr logger.Logger, monitoringEndpointGen telemetry.MonitoringEndpointGenerator) *telemetryReporter {
endpoints := make(map[*big.Int]commontypes.MonitoringEndpoint)
for _, chain := range chainContainer.Slice() {
endpoints[chain.ID()] = monitoringEndpointGen.GenMonitoringEndpoint("EVM", chain.ID().String(), "", synchronization.HeadReport)
Copy link
Collaborator

@andrevmatos andrevmatos Jun 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would we also need some form of check if telemetry is enabled in cfg? What do we see in the plugins? I assume this would fail if not, even though prometheus metrics are

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@bukata-sa bukata-sa changed the title feat(oti-head-report): Report new heads to atlas' OTI [CCIP-2610] Report new heads to atlas' OTI Jun 24, 2024
@bukata-sa bukata-sa marked this pull request as ready for review June 24, 2024 12:53
@bukata-sa bukata-sa requested a review from a team as a code owner June 24, 2024 12:53
@bukata-sa bukata-sa requested a review from a team as a code owner June 25, 2024 13:23
@bukata-sa bukata-sa changed the title [CCIP-2610] Report new heads to atlas' OTI [CCIP-2611] Report new heads to atlas' OTI Jun 25, 2024
@@ -30,6 +30,7 @@ func TestTOMLGeneralConfig_Defaults(t *testing.T) {
assert.False(t, config.StarkNetEnabled())
assert.Equal(t, false, config.JobPipeline().ExternalInitiatorsEnabled())
assert.Equal(t, 15*time.Minute, config.WebServer().SessionTimeout().Duration())
assert.Equal(t, false, config.HeadReport().TelemetryEnabled())
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@smartcontractkit/foundations do you think this should default to true? Or maybe a HeadReport.TelemetryDisabled config instead? I see this being enabled for every (prod) node by default

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the default should be true, as it requires less configuration to get this feature up and running

defer hrd.wgDone.Done()
ctx, cancel := hrd.chStop.NewCtx()
defer cancel()
after := time.After(hrd.reportPeriod)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a heads-up: this is fixing a bug that was present in the original code, where periodically reported Prom metrics were inadvertently being set only if it went through (default=) 30s without a new head being detected;

Since the metrics being set periodically are different than the ones on new heads, this means those could go a long time (or even forever) without being updated.

Taking after out of the for loop ensures these are set unconditionally every reportPeriod, as expected

@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Aug 13, 2024
@bukata-sa bukata-sa added this pull request to the merge queue Aug 13, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Aug 13, 2024
@bukata-sa bukata-sa added this pull request to the merge queue Aug 13, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Aug 13, 2024
@bukata-sa bukata-sa added this pull request to the merge queue Aug 13, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Aug 13, 2024
@bukata-sa bukata-sa added this pull request to the merge queue Aug 13, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Aug 13, 2024
@bukata-sa bukata-sa added this pull request to the merge queue Aug 13, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Aug 13, 2024
@bukata-sa bukata-sa added this pull request to the merge queue Aug 15, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Aug 15, 2024
@bukata-sa bukata-sa added this pull request to the merge queue Aug 15, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Aug 15, 2024
@bukata-sa bukata-sa added this pull request to the merge queue Aug 15, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Aug 15, 2024
@bukata-sa bukata-sa added this pull request to the merge queue Aug 15, 2024
Merged via the queue into develop with commit a41b353 Aug 15, 2024
139 of 140 checks passed
@bukata-sa bukata-sa deleted the feature/oti-head-report branch August 15, 2024 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants