Skip to content

beacon: pass context to methods #2188

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

Merged
merged 10 commits into from
May 15, 2025
Merged

beacon: pass context to methods #2188

merged 10 commits into from
May 15, 2025

Conversation

nkryuchkov
Copy link
Contributor

@nkryuchkov nkryuchkov commented Apr 29, 2025

Closes #2161

Part of PRs that will replace #1308

Currently, the beacon methods aren't cancellable because they use the common beacon client context, which matches the ssv-node lifetime

Copy link

codecov bot commented Apr 30, 2025

Codecov Report

Attention: Patch coverage is 25.23364% with 80 lines in your changes missing coverage. Please review.

Project coverage is 49.6%. Comparing base (a82d983) to head (c03e506).
Report is 1 commits behind head on stage.

Files with missing lines Patch % Lines
beacon/goclient/sync_committee_contribution.go 0.0% 12 Missing ⚠️
beacon/goclient/aggregator.go 0.0% 10 Missing ⚠️
beacon/goclient/proposer.go 9.0% 10 Missing ⚠️
beacon/goclient/sync_committee.go 0.0% 9 Missing ⚠️
operator/node.go 0.0% 8 Missing ⚠️
beacon/goclient/attest.go 53.3% 7 Missing ⚠️
beacon/goclient/committee_subscribe.go 0.0% 6 Missing ⚠️
beacon/goclient/signing.go 0.0% 4 Missing ⚠️
operator/validator/controller.go 0.0% 4 Missing ⚠️
cli/operator/node.go 0.0% 3 Missing ⚠️
... and 4 more

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

# Conflicts:
#	beacon/goclient/signing.go
Copy link
Contributor

@iurii-ssv iurii-ssv left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -105,6 +105,8 @@ func New(logger *zap.Logger, opts Options, slotTickerProvider slotticker.Provide

// Start starts to stream duties and run IBFT instances
func (n *Node) Start(logger *zap.Logger) error {
ctx := n.context // TODO: pass it to Start
Copy link
Contributor

Choose a reason for hiding this comment

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

what about this todo ? I think it's better to create issue in GH rather then write TODO

@MatusKysel MatusKysel requested a review from Copilot May 5, 2025 10:51
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR updates the beacon client to pass context parameters explicitly to all methods instead of relying on an internal context. The key changes include updating function signatures across multiple files, removing the Context field from the Options struct, and adjusting tests accordingly.

Reviewed Changes

Copilot reviewed 45 out of 45 changed files in this pull request and generated no comments.

Show a summary per file
File Description
beacon/goclient/voluntary_exit.go Updated SubmitVoluntaryExit to take a context parameter.
beacon/goclient/validatorliveness.go Context is now passed to recordRequestDuration.
beacon/goclient/validator.go Function signatures updated to include context parameter in various methods.
beacon/goclient/sync_committee_contribution.go Updated functions to require context parameter.
beacon/goclient/sync_committee.go Updated signature for GetSyncMessageBlockRoot and SubmitSyncMessages.
beacon/goclient/spec_test.go, signing_test.go Updated tests to pass context appropriately.
beacon/goclient/signing.go Updated DomainData to accept context.
beacon/goclient/proposer.go Updated functions to include context in their calls.
beacon/goclient/options.go Removed the Context field from Options.
beacon/goclient/goclient.go Removed internal client context and updated New to accept context.
Other test and helper files Adjusted new client invocations to pass context.
Comments suppressed due to low confidence (1)

beacon/goclient/options.go:10

  • The Context field was removed from the Options struct; please update the documentation and code comments to reflect that the New function now expects a context as its first argument.
Context                     context.Context

Copy link
Contributor

@oleg-ssvlabs oleg-ssvlabs left a comment

Choose a reason for hiding this comment

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

great job!
Left few minor comments related to the usage of t.Context() in tests. I believe it's optional to fix them, hence approving PR.

@@ -49,7 +120,17 @@ type signer interface {

// BeaconNode interface for all beacon duty calls
type BeaconNode interface {
specssv.BeaconNode // spec beacon interface
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it OK not to use spec definitions?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

IMO, yes. We decided to diverge from spec where we need it to keep spec looking like spec without any overhead

Copy link
Contributor

@y0sher y0sher left a comment

Choose a reason for hiding this comment

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

gj

@nkryuchkov nkryuchkov marked this pull request as draft May 13, 2025 17:15
@nkryuchkov nkryuchkov marked this pull request as ready for review May 13, 2025 20:14
Copy link
Contributor

@iurii-ssv iurii-ssv left a comment

Choose a reason for hiding this comment

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

Nice!

@y0sher y0sher merged commit 55d09f7 into stage May 15, 2025
6 of 7 checks passed
@y0sher y0sher deleted the beacon-pass-context branch May 15, 2025 10:28
nkryuchkov added a commit that referenced this pull request Jun 4, 2025
* beacon: pass context to methods

* fix context.Background leftovers

* fix fee recipient tests

* use t.Context instead of context.Background in tests

* beacon: delete unused returned errors

* Revert "beacon: delete unused returned errors"

This reverts commit 8915277.

* beacon: delete unused returned errors

* spec alignment

---------

Co-authored-by: y0sher <lyosher@gmail.com>
nkryuchkov added a commit that referenced this pull request Jun 4, 2025
* beacon: pass context to methods

* fix context.Background leftovers

* fix fee recipient tests

* use t.Context instead of context.Background in tests

* beacon: delete unused returned errors

* Revert "beacon: delete unused returned errors"

This reverts commit 8915277.

* beacon: delete unused returned errors

* spec alignment

---------

Co-authored-by: y0sher <lyosher@gmail.com>
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.

Delete Context from beacon client Options
5 participants