Repository navigation
Conversation
calldata.encode silently accepted: 1. Unsafe integer numbers (outside Number.isSafeInteger range) — BigInt(data) encoded the already-rounded Number 2. Strings with unpaired UTF-16 surrogates — TextEncoder replaced them with U+FFFD, causing decode(encode(value)) !== value and map key collisions Now rejects both with clear error messages, matching the GenVM Python reference encoder behavior. Closes genlayerlabs#229
calldata.decode was more permissive than the GenVM reference decoder: 1. readULeb128 accepted overlong/non-canonical encodings 2. readULeb128 read past end of input as undefined 3. Map decoding did not enforce canonical key order or reject duplicates 4. Strings and map keys used non-fatal TextDecoder for invalid UTF-8 Now rejects all of these at the point they are encountered. Closes genlayerlabs#227
|
This PR targeted I retargeted it to |
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches
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
Fixes #227:
calldata.decodewas more permissive than the GenVM reference decoder in several wire-level cases:readULeb128accepted overlong/non-canonical encodings such as[0x80, 0x00]readULeb128read past the end of input asundefinedTextDecoder, so malformed UTF-8 was accepted with replacement charactersChanges
src/abi/calldata/decoder.ts: reject overlong ULEB128 encodingssrc/abi/calldata/decoder.ts: fail immediately on unexpected end-of-inputsrc/abi/calldata/decoder.ts: enforce strictly increasing map key ordersrc/abi/calldata/decoder.ts: use fatalTextDecoderfor UTF-8 validationsrc/abi/calldata/decoder.ts: add bounds checking for strings and map keystests/calldata-decoder.test.tsTesting
npx vitest run— clean🤖 Generated with Claude Code
Summary by CodeRabbit
bigintfor integers outside the safe-integer range.