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

dynamic sync committee subscriptions #3308

Merged
merged 7 commits into from
Jan 24, 2022
Merged

dynamic sync committee subscriptions #3308

merged 7 commits into from
Jan 24, 2022

Conversation

tersec
Copy link
Contributor

@tersec tersec commented Jan 21, 2022

No description provided.

@github-actions
Copy link

github-actions bot commented Jan 21, 2022

Unit Test Results

     12 files  ±0     790 suites  ±0   39m 54s ⏱️ - 1m 11s
1 615 tests +1  1 567 ✔️ +1    48 💤 ±0  0 ±0 
9 509 runs  +4  9 405 ✔️ +4  104 💤 ±0  0 ±0 

Results for commit b0a2d23. ± Comparison against base commit 61342c2.

♻️ This comment has been updated with latest results.

beacon_chain/nimbus_beacon_node.nim Outdated Show resolved Hide resolved
beacon_chain/spec/network.nim Outdated Show resolved Hide resolved
beacon_chain/nimbus_beacon_node.nim Outdated Show resolved Hide resolved
beacon_chain/nimbus_beacon_node.nim Outdated Show resolved Hide resolved
epochToSyncPeriod = nearSyncCommitteePeriod(epoch)

if epochToSyncPeriod.isNone or
forkVersionAtEpoch(node.dag.cfg, epoch + 1) ==
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't the check here use epoch + epochToSyncPeriod.get? Otherwise, if we are in the epochs just before the Altair branch and epochToSyncPeriod was set to 3 for example, we would still not not subscribe (because epoch + 1 is still not an Altair epoch).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

node.network.subscribe(getSyncCommitteeTopic(
forkDigests[gossipFork], subcommitteeIdx), basicParams)

node.network.updateSyncnetsMetadata(nextSyncCommitteeSubnets)
Copy link
Contributor

Choose a reason for hiding this comment

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

We didn't necessarily connect to all of the nextSyncCommitteeSubnets here though, so this update seems incorrect (due to the randomness in isEpochLeadTime).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

beacon_chain/spec/network.nim Outdated Show resolved Hide resolved
@arnetheduck
Copy link
Member

This code needs to be restructured and moved to ActionTracker where it should work similar to attestation duties - this is necessary to support duties coming from the REST API which otherwise will be broken by this approach - so far, the rest api discards sync duties knowing that all subnets are subscribed regardless:

return RestApiResponse.jsonMsgResponse(SyncCommitteeSubscriptionSuccess)

this is a blocker, or we break 3rd-party vc:s

@tersec
Copy link
Contributor Author

tersec commented Jan 22, 2022

This code needs to be restructured and moved to ActionTracker where it should work similar to attestation duties - this is necessary to support duties coming from the REST API which otherwise will be broken by this approach - so far, the rest api discards sync duties knowing that all subnets are subscribed regardless:

return RestApiResponse.jsonMsgResponse(SyncCommitteeSubscriptionSuccess)

this is a blocker, or we break 3rd-party vc:s

It handles VCs fine:

node.syncCommitteeMsgPool.syncCommitteeSubscriptions[validator_pubkey] =
item.until_epoch

func hasSyncPubKey(node: BeaconNode, epoch: Epoch): auto =
return func(pubkey: ValidatorPubKey): bool =
node.syncCommitteeMsgPool.syncCommitteeSubscriptions.getOrDefault(
pubkey, GENESIS_EPOCH) >= epoch or
pubkey in node.attachedValidators.validators

@arnetheduck
Copy link
Member

hm, is subscribeAllSubnets handled here? I imagine that we should also add subscribeAllSyncnets, subscribeAllAttnets and change the subscribeAllSubnets to enable both

@tersec
Copy link
Contributor Author

tersec commented Jan 24, 2022

hm, is subscribeAllSubnets handled here? I imagine that we should also add subscribeAllSyncnets, subscribeAllAttnets and change the subscribeAllSubnets to enable both

9983903

This sets enabling --subscribe-all-subnets to override the other two, which allows for an overall more reasonable tradeoff.

Having subscribe-or-not all ${FOO} subnets be different than a third, use-default state creates an actually-ternary setting which would have unintuitive behavior.

As long as one treats not specifying the options at all the same as explicitly specifying their default options, then the only other vaguely reasonable approach here (sync/attnets options override all-subnet options) means that one'd have to specify both sync/attnet and subnet to get anything. These options/switches exist in software, and could be documented, but present complexity up front without increasing expressiveness.

Furthermore, this version allows for backwards compatibility -- anyone already specifying --subscribe-all-subnets gets the status quo behavior of that option.

So, this seems like the least worst version. Alternatively, one could just not allow separately setting sync/attnets, but there are use cases where they're differently appropriate; e.g., a boot node should specify both, while someone mostly looking to boost attestation-based profit slightly might only be interested in the attnets one.

Some software uses a syntax closer to --select-suboptions:a,b where something like --select-subnets:all, --select-subnets:optionA, and --select-subnets:optionB or similar is used. This shows the relationship more implicitly, but also creates an entirely separate parsing sublanguage (which Nimbus already has in some cases) for probably not much gain.

proc trackSyncCommitteeTopics*(node: BeaconNode) =
# TODO
discard
proc trackCurrentSyncCommitteeTopics(node: BeaconNode, slot: Slot) {.async.} =
Copy link
Member

Choose a reason for hiding this comment

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

why async?

Copy link
Contributor Author

Choose a reason for hiding this comment

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


node.network.updateSyncnetsMetadata(currentSyncCommitteeSubnets)

proc trackNextSyncCommitteeTopics(node: BeaconNode, slot: Slot) {.async.} =
Copy link
Member

Choose a reason for hiding this comment

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

likewise

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tersec tersec merged commit 00a3474 into unstable Jan 24, 2022
@tersec tersec deleted the vfK branch January 24, 2022 20:41
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.

3 participants