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

Support for big ledger peer snapshot in the topology file #5787

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

crocodile-dentist
Copy link
Contributor

Description

This change introduces support for big ledger peers in the node. A new optional entry in network topology JSON parser is added that is intended to point to a path containing a serialized snapshot of big ledger peers taken from some slot a priori. When present, this file is decoded at node startup, or when a SIGHUP is triggered, and made available to the diffusion layer via reading from a TVar.

Checklist

  • Commit sequence broadly makes sense and commits have useful messages
  • New tests are added if needed and existing tests are updated. These may include:
    • golden tests
    • property tests
    • roundtrip tests
    • integration tests
      See Runnings tests for more details
  • Any changes are noted in the CHANGELOG.md for affected package
  • The version bounds in .cabal files are updated
  • CI passes. See note on CI. The following CI checks are required:
    • Code is linted with hlint. See .github/workflows/check-hlint.yml to get the hlint version
    • Code is formatted with stylish-haskell. See .github/workflows/stylish-haskell.yml to get the stylish-haskell version
    • Code builds on Linux, MacOS and Windows for ghc-8.10.7 and ghc-9.2.7
  • Self-reviewed the diff

Note on CI

If your PR is from a fork, the necessary CI jobs won't trigger automatically for security reasons.
You will need to get someone with write privileges. Please contact IOG node developers to do this
for you.

@crocodile-dentist crocodile-dentist self-assigned this Apr 17, 2024
@crocodile-dentist crocodile-dentist requested a review from a team as a code owner April 17, 2024 21:11
@crocodile-dentist crocodile-dentist force-pushed the mwojtowicz/genesis-ledger-peer-snapshot branch from b281d8f to 7a66082 Compare April 18, 2024 06:18
Comment on lines 796 to 797
(\io_m_lps -> do
m_lps <- io_m_lps
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not camelcase?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I though io_m_lps was a little clearer than ioMLps, or do you have something else in mind?

Copy link
Contributor

@carbolymer carbolymer Apr 18, 2024

Choose a reason for hiding this comment

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

Having to prefix the variables with the types is usually a sign that you're working against the language. Here it is because you're trying to shoehorn your function into MaybeT which doesn't work here very well and forces you to work with variables with type IO (Maybe a) outside of MaybeT. Why not write this function like this:

updateLedgerPeerSnapshot :: Tracer IO (StartupTrace blk)
                         -> STM IO (Maybe PeerSnapshotFile)
                         -> (Maybe LedgerPeerSnapshot -> STM IO ())
                         -> IO (Maybe LedgerPeerSnapshot)
updateLedgerPeerSnapshot startupTracer readLedgerPeerPath writeVar = do
  mPeerSnapshotFile <- atomically readLedgerPeerPath
  mLedgerPeerSnapshot <- forM mPeerSnapshotFile $ \f -> do
    lps@(LedgerPeerSnapshot (wOrigin, _)) <- readPeerSnapshotFile f
    lps <$ traceWith startupTracer (LedgerPeerSnapshotLoaded wOrigin)
  atomically . writeVar $ mLedgerPeerSnapshot
  pure mLedgerPeerSnapshot

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, that's most intuitive.

@crocodile-dentist
Copy link
Contributor Author

crocodile-dentist commented Apr 18, 2024

Maybe I don't have to bump the protocol version at all in this patch based on review comment in related PR on consensus side

@crocodile-dentist crocodile-dentist marked this pull request as draft April 18, 2024 16:12
@crocodile-dentist crocodile-dentist force-pushed the mwojtowicz/genesis-ledger-peer-snapshot branch from 7a66082 to c10e12e Compare April 22, 2024 10:10
Copy link

github-actions bot commented Jun 7, 2024

This PR is stale because it has been open 45 days with no activity.

@github-actions github-actions bot added the Stale label Jun 7, 2024
@github-actions github-actions bot removed the Stale label Jun 18, 2024
@crocodile-dentist crocodile-dentist force-pushed the mwojtowicz/genesis-ledger-peer-snapshot branch from c10e12e to 6b9616c Compare August 8, 2024 13:10
@crocodile-dentist crocodile-dentist force-pushed the mwojtowicz/genesis-ledger-peer-snapshot branch from 6b9616c to 70b3121 Compare September 30, 2024 12:26
@coot coot changed the title Support for big ledger peer snapshot Support for big ledger peer snapshot in the topology file Nov 8, 2024
This change introduces support for big ledger peers in the node.
A new optional entry in network topology JSON parser is added that is intended
to point to a path containing a serialized snapshot of big ledger peers
taken from some slot a priori. When present, this file is decoded
at node startup, or when a SIGHUP is triggered, and made available
to the diffusion layer via reading from a TVar.
The ConsensusMode configuration option determines whether support for
Genesis syncing is enabled. If this flag is GenesisMode, alternate
targets for active peers (non- big ledger) and all big ledger targets
is used by the peer selection and churn governors in the diffusion
layer. These targets are in effect when ledger state is deemed
`TooOld` by consensus layer. The large active big ledger peer targets
crucially depend on chain skipping to maintain performance
requirements. Otherwise, in PraosMode, the legacy algorithm with
a single set of targets is employed.
Missing updating Node Configuration parser to read genesis targets and
ledger snapshot.
@crocodile-dentist crocodile-dentist force-pushed the mwojtowicz/genesis-ledger-peer-snapshot branch from c427e76 to 982cd1d Compare November 13, 2024 14:36
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.

2 participants