-
-
Notifications
You must be signed in to change notification settings - Fork 474
Cache and retransmit bls changes if submitted early #5031
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
Changes from 6 commits
a39a1dd
b438d81
97fb72f
6f65957
5cc993c
6e3bf0a
dd6d8f7
31b59b9
bc695e3
3c674ff
adb54fd
06e3bb3
1ea60b9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -104,7 +104,11 @@ export function getBeaconPoolApi({ | |
| try { | ||
| await validateBlsToExecutionChange(chain, blsToExecutionChange); | ||
| chain.opPool.insertBlsToExecutionChange(blsToExecutionChange); | ||
| await network.gossip.publishBlsToExecutionChange(blsToExecutionChange); | ||
| if (chain.clock.currentEpoch >= chain.config.CAPELLA_FORK_EPOCH) { | ||
| await network.gossip.publishBlsToExecutionChange(blsToExecutionChange); | ||
| } else { | ||
| await chain.cacheBlsToExecutionChanges(blsToExecutionChange); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is it necessary to explicitly call this? |
||
| } | ||
| } catch (e) { | ||
| errors.push(e as Error); | ||
| logger.error( | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -63,6 +63,7 @@ export class Network implements INetwork { | |
| private readonly signal: AbortSignal; | ||
|
|
||
| private subscribedForks = new Set<ForkName>(); | ||
| private cachedBlsChangesPromise: Promise<void> | null = null; | ||
|
|
||
| constructor(private readonly opts: INetworkOptions, modules: INetworkModules) { | ||
| const {config, libp2p, logger, metrics, chain, reqRespHandlers, gossipHandlers, signal} = modules; | ||
|
|
@@ -411,6 +412,17 @@ export class Network implements INetwork { | |
| } | ||
| } | ||
| } | ||
|
|
||
| // If we are subscribed and post capella fork epoch, try gossiping the cached bls changes | ||
| if ( | ||
| this.isSubscribedToGossipCoreTopics() && | ||
| epoch >= this.config.CAPELLA_FORK_EPOCH && | ||
| !this.cachedBlsChangesPromise | ||
| ) { | ||
| this.cachedBlsChangesPromise = this.gossipCachedBlsChanges().then(() => { | ||
| this.cachedBlsChangesPromise = null; | ||
| }); | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just move this code above under the |
||
| } catch (e) { | ||
| this.logger.error("Error on BeaconGossipHandler.onEpoch", {epoch}, e as Error); | ||
| } | ||
|
|
@@ -482,6 +494,24 @@ export class Network implements INetwork { | |
| return topics; | ||
| } | ||
|
|
||
| private async gossipCachedBlsChanges(): Promise<void> { | ||
| const gossipedKeys = []; | ||
| try { | ||
| this.logger.info("Re-gossiping the cached bls changes"); | ||
| for await (const {key, value} of this.chain.db.blsToExecutionChangeCache.entriesStream()) { | ||
| await this.gossip.publishBlsToExecutionChange(value); | ||
| gossipedKeys.push(key); | ||
| } | ||
| } catch (e) { | ||
| this.logger.error("Failed to gossip all cached bls changes", {}, e as Error); | ||
| } finally { | ||
| this.logger.info("Gossiped cached blsChanges", {size: gossipedKeys.length}); | ||
| await this.chain.db.blsToExecutionChangeCache.batchDelete(gossipedKeys).catch((e) => { | ||
| this.logger.error("Could not clear gossiped blsChanges from blsToExecutionChangeCache", {}, e as Error); | ||
| }); | ||
| } | ||
| } | ||
|
|
||
| private onLightClientFinalityUpdate = async (finalityUpdate: altair.LightClientFinalityUpdate): Promise<void> => { | ||
| if (this.hasAttachedSyncCommitteeMember()) { | ||
| try { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,6 +33,7 @@ export enum Bucket { | |
| phase0_proposerSlashing = 14, // ValidatorIndex -> ProposerSlashing | ||
| phase0_attesterSlashing = 15, // Root -> AttesterSlashing | ||
| capella_blsToExecutionChange = 16, // ValidatorIndex -> SignedBLSToExecutionChange | ||
| capella_blsToExecutionChangeCache = 17, // ValidatorIndex -> SignedBLSToExecutionChange | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You should be able to recycle the existing in-memory + DB pool. Why is this extra bucket required?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. umm i guess the current db pool before capella can be used as to recycle, i was going for caching any generic publishing errors but i guess its over kill
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the problem could be, once capella is hit, it would become unclear which ones are received from gossip and which ones have been submitted, as there is always a possibility of restarts while the gossip job is not complete, so would like to retain this as a separate repo
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we can clean it post capella
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It does not matter where an object is received. You persist to db changes that are still valid to be included in a block
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
That's a fair point. However, it's not a consensus issue to re-broadcast other validator messages. After thinking about it I'm not opposed to mark those objects in some way as "submitted pre-capella" |
||
| // validator | ||
| // validator = 16, // DEPRECATED on v0.11.0 | ||
| // lastProposedBlock = 17, // DEPRECATED on v0.11.0 | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.