-
Notifications
You must be signed in to change notification settings - Fork 136
Fix pointer address decoder to follow cardano ledger logic #740
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
lisicky
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/check
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes the pointer address decoder to follow Cardano ledger logic by implementing proper variable-length encoding/decoding and overflow normalization behavior. The changes ensure compatibility with the Haskell implementation by normalizing pointer values to (0,0,0) when any component exceeds its maximum allowed value.
- Implements new variable-length u64 decoder that matches Haskell's
decodeVariableLengthWord64function - Adds overflow normalization logic that resets pointers to (0,0,0) when values exceed u32::MAX, u16::MAX, or u16::MAX for slot, tx_index, and cert_index respectively
- Refactors Pointer struct into separate module with comprehensive test coverage
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| rust/src/protocol_types/pointer.rs | New module containing Pointer struct with Cardano-compliant variable-length encoding/decoding |
| rust/src/protocol_types/address.rs | Removes old Pointer implementation and variable-length nat functions, updates to use new Pointer module |
| rust/src/protocol_types/numeric/big_num.rs | Adds From implementation for BigNum |
| rust/src/protocol_types/mod.rs | Exports new pointer module |
| rust/src/tests/pointer.rs | Comprehensive test suite for pointer functionality |
| rust/src/tests/mod.rs | Adds pointer test module |
| rust/src/tests/address.rs | Updates test expectations for overflow normalization behavior |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
…enii/crazy-pointers
lisicky
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/check
No description provided.