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

LedgerTxn::getHeader is misused #4412

Open
marta-lokhova opened this issue Aug 2, 2024 · 0 comments
Open

LedgerTxn::getHeader is misused #4412

marta-lokhova opened this issue Aug 2, 2024 · 0 comments
Assignees
Labels

Comments

@marta-lokhova
Copy link
Contributor

it looks like getHeader isn't used correctly in the codebase. getHeader is a const getter, and is meant to be used when creating a LedgerTxn child. The problem is that when it comes to modifying the header at apply time, getHeader doesn't check any invariance, like whether there's an active writer already that may modify the header, a child exists (which invalidates the header), or if ledger header is already sealed (which suggests buggy usage). This creates an opportunity to load and use an invalid header. We should switch to using loadHeader instead, which enforces the invariants mentioned.

if (!isLive(ttlLtxe.current(), ltx.getHeader().ledgerSeq))

if (!isLive(ttlLtxe.current(), ltx.getHeader().ledgerSeq))

releaseAssert(protocolVersionStartsFrom(ltx.getHeader().ledgerVersion,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant