Skip to content

Say plainly that deepening the critbit tree only adds a minor cost - #171

Merged
mikemaccana merged 2 commits into
mainfrom
claude/peaceful-tesla-k0gp10
Sep 23, 2026
Merged

mikemaccana merged 2 commits into
mainfrom
claude/peaceful-tesla-k0gp10

Conversation

@mikemaccana

@mikemaccana mikemaccana commented Sep 23, 2026 •

Copy link
Copy Markdown
Collaborator

Deepening the order book's tree is cheap for everyone else. An attacker can place asks at doubling prices to make one path 64 levels deep, but no deeper. At that depth, each insert, fill, or cancel costs under 15,000 extra compute units, out of a default budget of 200,000 per instruction. The attack makes some transactions slightly more expensive. It can't make them fail.

The paragraph now says exactly that, in 46 words instead of 147:

A critbit tree does not balance itself, so an attacker can place asks at 2, 4, 8, and so on to deepen the tree. That only adds a minor cost: 64 levels at most, and under 15,000 extra compute units per instruction, out of a default budget of 200,000.

The two companion tests that measure it join the chapter's test list: doubling_prices_build_the_deepest_path_prices_allow and deepest_path_adds_little_compute_to_insert_fill_and_cancel.

Merge after quicknode/solana-program-examples#164, which adds those tests.

npm run lint, node scripts/check-figure-geometry.mjs, and npm run build-pdf all pass.

🤖 Generated with Claude Code

https://claude.ai/code/session_01RQ5RZgoQjVK36qSjqUSq6X

The paragraph said a doubling-price attacker grows a path by a level per
order, which reads as unbounded. The key sets the ceiling: prices fill its
top 64 bits, so they can add at most 64 levels, and at that depth an insert,
fill, or cancel costs under 15,000 extra compute units. The two companion
tests that prove it join the chapter's test list.

Claude-Session: https://claude.ai/code/session_01RQ5RZgoQjVK36qSjqUSq6X
@mikemaccana
mikemaccana force-pushed the claude/peaceful-tesla-k0gp10 branch from 8c10530 to 2306654 Compare September 23, 2026 03:07
@mikemaccana mikemaccana changed the title Clarify critbit tree depth bounds and add worst-case tests Give the critbit depth its real bound, in fewer words Sep 23, 2026
@mikemaccana mikemaccana changed the title Give the critbit depth its real bound, in fewer words Say plainly that deepening the critbit tree only adds a minor cost Sep 23, 2026
@mikemaccana
mikemaccana merged commit 254e494 into main Sep 23, 2026
1 check passed
@mikemaccana
mikemaccana deleted the claude/peaceful-tesla-k0gp10 branch October 13, 2026 00:23
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.

1 participant