harden: add instruction data length assertions to critical encoders#197
harden: add instruction data length assertions to critical encoders#1970x-SquidSol wants to merge 1 commit intodcccrypto:mainfrom
Conversation
Added post-encode length assertions to 5 safety-critical encoder functions following the encodeInitMarket pattern (line 260): - encodeTradeCpi: 21 bytes (user funds) - encodeTradeCpiV2: 22 bytes (user funds) - encodeTradeNoCpi: 21 bytes (user funds) - encodeExecuteAdl: 3 bytes (auto-deleveraging) - encodeUpdateConfig: 145 bytes (14 fields, highest layout-error risk) Each assertion catches field addition/removal bugs that would silently produce wrong-length instruction data, causing the on-chain decoder to misparse fields or panic. The enc* helpers always produce fixed-size output, so the assertions can never false-positive on valid inputs. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Warning Rate limit exceeded
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 38 minutes and 10 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the 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. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Summary
encodeInitMarkethad a post-encode length assertion (352 bytes). All other encoders returnedconcatBytes(...)with no size verification.concatByteswithout updating the layout could silently produce wrong-length instruction data, causing the on-chain decoder to misparse or panic.encodeTradeCpiencodeTradeCpiV2encodeTradeNoCpiencodeExecuteAdlencodeUpdateConfigenc*helpers return fixed-size arrays — assertions can never false-positive on valid inputsencodeInitMarketpattern already established at line 260Test plan
🤖 Generated with Claude Code