Skip to content

fix(discovery): use layout-descriptor offsets for all V1-family engine parsing#185

Open
0x-SquidSol wants to merge 1 commit intodcccrypto:mainfrom
0x-SquidSol:fix/parseEngineLight-layout-driven-v2
Open

fix(discovery): use layout-descriptor offsets for all V1-family engine parsing#185
0x-SquidSol wants to merge 1 commit intodcccrypto:mainfrom
0x-SquidSol:fix/parseEngineLight-layout-driven-v2

Conversation

@0x-SquidSol
Copy link
Copy Markdown
Contributor

Summary

  • parseEngineLight's layout-driven branch was gated on V_ADL-specific constants (engineOff===624 && accountSize===312)
  • V12.1 SBF (engineOff=616, accountSize=280), V12.1 HOST, V_SETDEXPOOL, V1M2, V1, V1D, V1M all fell through to the V1 hardcoded fallback with wrong offsets (24-byte shift from markPrice onward, and completely wrong for non-V1 layouts)
  • This is the same fix as merged PR fix(discovery): use layout-descriptor offsets for all V1-family engines #151 but with critical additions: >= 0 guards on 10 engine fields that V12.1 SBF sets to -1 (fundingIndex, lastFundingSlot, totalOi, insurance isolation, LP aggregates, lifetime force closes)
  • Without these guards, widening the branch to layout !== null would crash on V12.1 SBF slabs (reading at base + (-1))
  • The V1 hardcoded fallback (which also had a systematic 24-byte offset error) is removed as dead code
  • Forward-compatible: any new layout version only needs a buildLayout*() helper — no new branch in parseEngineLight

Test plan

  • Discovery tests pass (60/60)
  • No new test failures (16 pre-existing failures from HOST bitmapOff + ADL mock issues are separate)
  • Verify V12.1 SBF slabs produce correct engine state via discoverMarkets
  • Verify V_ADL, V1, V1D slabs still parse correctly (regression)

🤖 Generated with Claude Code

…e parsing

parseEngineLight's layout-driven branch was gated on V_ADL-specific
constants (engineOff===624 && accountSize===312). V12.1 SBF/HOST,
V_SETDEXPOOL, V1M2, V1, V1D, and V1M all fell through to the V1
hardcoded fallback which had wrong offsets (24-byte shift from
markPrice onward, and completely wrong for non-V1 layouts).

Widened guard to layout !== null (V0/V2 return early before this
point). Added >= 0 guards on all 10 engine fields that V12.1 SBF
sets to -1 (fundingIndex, lastFundingSlot, totalOi, insurance
isolation, LP aggregates, etc.). This makes the branch safe for
ANY layout descriptor, including future versions.

The V1 hardcoded fallback is replaced with a defensive throw for
the unreachable null-layout case.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 13, 2026

Warning

Rate limit exceeded

@0x-SquidSol has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 51 minutes and 28 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 51 minutes and 28 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ffb2a5db-1485-43a8-b8c8-75ff69cc1bd5

📥 Commits

Reviewing files that changed from the base of the PR and between 2f80d79 and d322864.

📒 Files selected for processing (1)
  • src/solana/discovery.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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