-
Notifications
You must be signed in to change notification settings - Fork 9
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
fix: attribute decoding in cometbft v0.38 #96
Conversation
Caution Review failedThe pull request is closed. WalkthroughThe changes in the Changes
Sequence Diagram(s)sequenceDiagram
participant A as Transaction
participant B as Message State
participant C as Message Parser
A->>B: txToMessageState()
B->>B: Check if attr.Key is "message"
B->>B: Assign attr.Value to decodedValue
B->>C: Process decodedValue
C->>C: Decode message
C->>C: Hash and parse into Message object
C-->>B: Return Message object
B-->>A: Return MessageState
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (2)
noble/message_state.go (2)
30-31
: Remove unnecessary string conversionThe removal of base64 decoding is correct for cometbft v0.38 compatibility. However, there's an unnecessary string conversion that can be simplified.
- decodedKey := attr.Key - if string(decodedKey) == "message" { + if attr.Key == "message" {🧰 Tools
🪛 GitHub Check: golangci-lint
[failure] 31-31:
unnecessary conversion (unconvert)🪛 golangci-lint
31-31: unnecessary conversion
(unconvert)
32-32
: LGTM! Consider enhancing the documentationThe direct assignment of
attr.Value
is correct for cometbft v0.38. The subsequent double decoding is properly maintained.Consider expanding the comment to explain why the initial base64 decoding was removed:
- // Because we are using cometBFT v0.38, we need to decode the value twice. + // In cometBFT v0.38, attributes are no longer base64 encoded, but the message itself + // still requires double decoding due to the protocol specification.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
noble/message_state.go
(1 hunks)
🧰 Additional context used
🪛 GitHub Check: golangci-lint
noble/message_state.go
[failure] 31-31:
unnecessary conversion (unconvert)
🪛 golangci-lint
noble/message_state.go
31-31: unnecessary conversion
(unconvert)
🔇 Additional comments (1)
noble/message_state.go (1)
30-32
: Verify consistent attribute handling across the codebase
Let's ensure this change is consistently applied across all CCTP message handling code.
✅ Verification successful
Let me gather more context about the message handling implementation to ensure we have a complete picture.
Let me try one more search to specifically look for message handling patterns in the codebase.
Base64 decoding change is correctly isolated and safe
The code analysis shows that:
- The base64 decoding is only used in this specific message handling block in
noble/message_state.go
- There are no other instances of attribute handling that expect base64 encoded values
- The base64 decoding is specifically tied to CometBFT v0.38 compatibility as noted in the code comment
The change is properly contained and doesn't require updates in other parts of the codebase.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for other potential attribute handling code that might need similar updates
rg -l "circle\.cctp.*MessageSent" | xargs rg "attr\.(Key|Value)"
# Search for related tests that might need updating
rg -l "TestMessage.*State" | xargs rg "base64"
Length of output: 778
Script:
#!/bin/bash
# Search for message attribute handling patterns
rg -A 5 "type.*Message.*Event"
# Look for any other attribute decoding patterns
rg -A 3 "attr\.(Key|Value)"
# Check test files for message attribute handling
fd "test.*\.go$" --exec rg -l "Message.*Event"
Length of output: 565
Script:
#!/bin/bash
# Search for message handling patterns using ast-grep
ast-grep --pattern 'if $_ == "message" {
$$$
}'
# Look for any message event handling
rg -B 2 -A 5 "MessageSent.*Event"
# Check for attribute handling in tests
rg -A 5 "func.*Test.*Message"
Length of output: 5209
🧰 Tools
🪛 GitHub Check: golangci-lint
[failure] 31-31:
unnecessary conversion (unconvert)
🪛 golangci-lint
31-31: unnecessary conversion
(unconvert)
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.
Nice catch ser, thank you 🫡
Summary by CodeRabbit
Bug Fixes
Refactor
Documentation