Skip to content

Pi/custom genesis#753

Open
Quantumplation wants to merge 2 commits intomainfrom
pi/custom-genesis
Open

Pi/custom genesis#753
Quantumplation wants to merge 2 commits intomainfrom
pi/custom-genesis

Conversation

@Quantumplation
Copy link
Collaborator

Description

Adds support for custom genesis files, in place of well known network names. Also fixes a bug that this uncovered.

Related Issue(s)

N/A

How was this tested?

Pointed Acropolis (technically scooper-v2) at a yaci-devkit private devnet and confirmed it was able to sync from origin to tip.

Checklist

  • My code builds and passes local tests
  • I added/updated tests for my changes, where applicable
  • I updated documentation (if applicable)
  • branch has ≤ 5 commits (honor system)
  • commit messages tell a coherent story
  • branch is up to date with main (rebased on main; fast-forward possible)
  • CI/CD passes on the merged-with-main result

Impact / Side effects

This will allow users using custom networks, like yaci-devkit to sync an acropolis node. It will allow users building custom tools like indexers to do the same.

Reviewer notes / Areas to focus

…y networks

Use Cow<'static, [u8]> to unify builtin (include_bytes!) and custom
(file-based) genesis data, allowing the bootstrapper to load Byron and
Shelley genesis files from disk for networks beyond mainnet/preview/sanchonet.
…alse rollback halt

When an IndexActor starts from a cursor at Point::Origin, its points
deque contains a single entry with slot 0 and no hash. If the first real
block also arrives at slot 0 (as on preview/sanchonet), the rollback
detection logic finds Origin via binary search, compares hashes
(None != Some(block_hash)), and interprets it as a conflicting block.
It then tries to roll back to index -1, which fails checked_sub(1) and
halts the actor.

We encountered this when adding custom genesis support, where networks
can boot directly into post-Byron eras with an initial block at slot 0.

Fix by replacing Origin with the actual first block's point at the top
of apply_txs, before the rollback logic runs. This is preferable to
making the rollback path Origin-aware (subtle, scattered checks) or
stripping Origin in the constructor (causes the empty-deque early return
to skip the first block, requiring a larger refactor).
Copy link
Collaborator

@whankinsiv whankinsiv left a comment

Choose a reason for hiding this comment

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

Thanks for adding this Pi!

// Origin is a virtual starting point (slot 0, no hash). Replace it with
// the actual first block we receive so that rollback detection doesn't
// confuse it with a different block at slot 0.
if self.points.len() == 1 && matches!(self.points.front(), Some(Point::Origin)) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice 👍🏻

Copy link
Collaborator

@golddydev golddydev left a comment

Choose a reason for hiding this comment

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

Thanks Pi. Good to know about Cow thing ❤️

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.

4 participants