onflow / flow-go

A fast, secure, and developer-friendly blockchain built to support the next generation of games, apps, and the digital assets that power them.
GNU Affero General Public License v3.0
532 stars 176 forks source link

Networking layer's ProtocolStateIDCache accounts for ejection events #6123

Open AlexHentschel opened 3 months ago

AlexHentschel commented 3 months ago

Problem Definition

With the Dynamic Protocol state, we now have the ability to eject nodes at any block within the epoch. However, the networking layer is still oblivious about any potential ejections until the new epoch starts.

Proposed Solution

I would suggest adding a notification that is emitted by the protocol state and distributed via the events.Distributor. The ProtocolStateIDCache can listen to this event and update its internally-maintained notion of "latest authorized network participants" (for brevity, I will call this the latest identity table).

Details

while we are at it, I would really like to get the following TODO cleaned up: https://github.com/onflow/flow-go/blob/c54e15a6e3754bd6bc255bf115dcc0bcc6d06857/network/p2p/cache/protocol_state_provider.go#L69-L71 this violation of API conventions (potentially blocking the hotPath of consensus) is inherent to all notifications the ProtocolStateIDCache ingests. Note that the ProtocolStateIDCache only needs to be eventually consistent (👉 documentation). This allows a subtle but very compact implementation:

Current functional overlap with IdentityDeltas

There is overlap between the ProtocolStateIDCache and the IdentityDeltas. We should take this opportunity to consolidate them (remove one). Alternatively we would need to update both to support ejections.

Definition of Done

Verifying that an ejected node is no longer exposed through the ProtocolStateIDCache's methods GetFlowID, GetPeerID,ByPeerID,ByNodeIDorIdentitiesshould be sufficient. I think we have an integration test that verifies that connections from nodes that aren't exposed by theProtocolStateIDCache` are dropped/refused.

github-actions[bot] commented 6 days ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.