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

Bootstrap Peers Implementation #4555

Merged
merged 11 commits into from
Jan 29, 2024
Merged

Bootstrap Peers Implementation #4555

merged 11 commits into from
Jan 29, 2024

Conversation

bolt12
Copy link
Contributor

@bolt12 bolt12 commented May 12, 2023

Description

This PR implements the Bootstrap Peers IER by changing the LedgerConsensusInterface API and creating mechanisms in the networking outbound governor to promptly react to ledger state changes.

@bolt12 bolt12 requested a review from dnadales June 1, 2023 09:32
@coot coot added networking outbound-governor Issues / PRs related to outbound-governor labels Jun 15, 2023
@bolt12 bolt12 mentioned this pull request Jul 4, 2023
6 tasks
@coot
Copy link
Contributor

coot commented Jul 7, 2023

@bolt12 I think we can merge it as soon as consensus team agrees on the interface. The question I have iis if we will use the same implementation as for bootstrap peers or not (IntersectMBO/ouroboros-consensus#200).

@bolt12
Copy link
Contributor Author

bolt12 commented Jul 7, 2023

I think it might make sense to repurpose this PR to include bootstrap peers as well.

@bolt12
Copy link
Contributor Author

bolt12 commented Jul 7, 2023

Also see my comment here: IntersectMBO/ouroboros-consensus#200

@bolt12 bolt12 changed the title Added new UseLedgerCloseToTip flag value Adds new UseRecentLedger flag value Jul 27, 2023
@bolt12 bolt12 requested a review from coot January 25, 2024 11:12
`LedgerConsensusInterface` now has to fill 3 STM actions:

- `lpGetLatestSlot :: STM m SlotNo`
- `lpGetLedgerStateJudgment :: STM m LedgerStateJudgement`
- `lpGetLedgerPeers :: STM m [(PoolStake, NonEmpty RelayAccessPoint)]`

This allows to create a new interface function similar to the old one:

`getLedgerPeersFromSlotNo :: MonadSTM m => LedgerPeersConsensusInterface m -> SlotNo -> STM m LedgerPeers`

That abides buy the following invariants:

* 'BeforeSlot' is returned iff the latest slot is before the 'slotNo'
* 'LedgerPeers lsj peers' is returned iff the latest slot is after the 'slotNo';

Adds a test that checks this invariants
This is fruit of the following discussion: #4658

Renamed `UseLedgerAfter` to `AfterSlot`

Move `UseLedgerPeers` and `AfterSlot` to *-api
Adds `readLedgerStateJudgement` to `PeerSelectionActions`
Adds `currentLedgerStateJudgement` to `PeerSelectionState`

Adjusts `PeerSelectionActions` `requestPublicRootPeers` function to
provide either only ledger peers or bootstrap peers according to the
current ledger state. The same for `requestBigLedgerPeers`.

Adds LedgerStateJudgement to tests

Moves BigLedgerPeers to PublicRootPeers

Refactor `PeerSelectionActions` `requestPublicRootPeers` function
1. **ledgerStateJudgement**:
   - Triggered by `LedgerPeersConsensusInterface` API's STM action.
   - If ledger state shifts to 'TooOld', the governor:
     - Sets all targets to 0.
     - Ignores other monitoring jobs, preventing new peer learning or
       alterations to the peer sets.
     - The intent is to ensure complete state purge, transitioning the
       governor to a secure fallback state.

2. **waitForOnlyBootstrapPeers**:
   - Activates once the governor is in a clean state.
   - Resets targets to original values, allowing normal operations.
   - An invariant is introduced: the governor only knows about trustable
     (bootstrap) peers.
   - Protective measures added in the code to maintain this invariant.
     This safeguard is essential only during the fallback state.

When the ledger state transitions to 'YoungEnough', the governor will
accept non-trustable peers into its known set.
Reduce memory and time efficiency of test
Copy link
Contributor

@coot coot left a comment

Choose a reason for hiding this comment

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

Thanks @bolt12 for the good work.

@bolt12 bolt12 added this pull request to the merge queue Jan 29, 2024
Merged via the queue into master with commit 55c5e35 Jan 29, 2024
10 checks passed
@bolt12 bolt12 deleted the bolt12/4530 branch January 29, 2024 12:59
github-merge-queue bot pushed a commit to IntersectMBO/ouroboros-consensus that referenced this pull request Feb 22, 2024
The Genesis SoW will deliver a proper GSM. In the interim, this PR
defines a GSM that is suitable for use with the bootstrap-peers
intermediate solution (see
IntersectMBO/ouroboros-network#4555).

The relevant high-level specification is rendered here
https://ouroboros-consensus.cardano.intersectmbo.org/docs/for-developers/BootstrapPeersIER
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bootstrap Issues / PRs related to bootstrap peers outbound-governor Issues / PRs related to outbound-governor
Projects
Status: Done
4 participants