Repository navigation
Drop checks-effects-interactions: re-entry cannot happen on Solana - #244
Merged
Merged
Conversation
added 2 commits
October 4, 2026 16:54
The book taught checks-effects-interactions as protection against a token hook or an upgraded callee re-entering a program mid-transfer. Solana's runtime rejects that call with ReentrancyNotAllowed, and a failed call undoes the whole transaction, so the order in which a handler writes its own state and calls other programs opens no attack. The Adversary chapter now states the runtime rule. The order book, fundraiser, managed fund, betting market, options and perpetual futures chapters describe what their handlers do without the label, and the glossary entry is gone. Follows quicknode/solana-program-examples#189, which removes the same claim from the programs' comments. Claude-Session: https://claude.ai/code/session_014pXG1pw56BE99p4A8qmrQk
The order book settlement figure said the ordering means "a re-entrant caller finds nothing left", and the betting claim figure labelled its first step "effects before interactions". Neither applies on Solana. The settlement caption now says what the handler does; the claim figure drops the label. Claude-Session: https://claude.ai/code/session_014pXG1pw56BE99p4A8qmrQk
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The book taught checks-effects-interactions as protection against a token hook, or an upgraded callee, re-entering a program mid-transfer and double-withdrawing. On Solana that call can't happen.
solana-program-runtimereturnsInstructionError::ReentrancyNotAllowedwhen a program already on the call stack is invoked by anything other than itself. A failed call also undoes the whole transaction. So the order in which a handler writes its own state and calls other programs doesn't open an attack.This follows quicknode/solana-program-examples#189, which removes the same claim from the companion programs' comments and READMEs.
After this merges, the book's prose, glossary and figures no longer mention checks-effects-interactions. The only remaining mentions are the example sentences in the comment on the lint rule in
scripts/lint-manuscript.mjs, which quote the old wording to show what the rule rejects.Changes
settle_funds()paragraph says what the handler does: it zeroes the counters and pays out the snapshot, so a user who callssettle_funds()again is paid nothing, and a failed transfer undoes the zeroing. The summary bullet says the same.test_double_claim_fails).order-book-settle.svg, the caption "checks-effects-interactions, so a re-entrant caller finds nothing left" → "the handler zeroes the counters and pays out what they held, so a user who settles again is paid nothing". Inbetting-alice-claim.svg, removed the "effects before interactions" label and "first" from "1. index entry removed first".Checks
npm run lint,node scripts/check-figure-geometry.mjsandnpm run build-pdfpass. Both changed figures were rendered and checked by eye.This branch was reset to
mainafter #243 merged. A commit had been pushed to it after that merge, and it now sits on top ofmainhere.🤖 Generated with Claude Code
https://claude.ai/code/session_014pXG1pw56BE99p4A8qmrQk