-
Notifications
You must be signed in to change notification settings - Fork 237
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
Problem: packet_sequence is not indexed in relayer event #1318
Conversation
WalkthroughThe recent updates enhance the blockchain's event handling and transaction search capabilities, particularly focusing on the IBC (Inter-Blockchain Communication) protocol and smart contract ABI (Application Binary Interface) management. Improvements include the addition of a Changes
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 as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
Signed-off-by: mmsqe <[email protected]>
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.
Review Status
Actionable comments generated: 1
Configuration used: CodeRabbit UI
Files selected for processing (13)
- CHANGELOG.md (1 hunks)
- integration_tests/cosmoscli.py (1 hunks)
- integration_tests/ibc_utils.py (1 hunks)
- integration_tests/test_ibc_rly.py (8 hunks)
- integration_tests/utils.py (1 hunks)
- x/cronos/events/bindings/cosmos/lib/cosmos_types.abigen.go (2 hunks)
- x/cronos/events/bindings/cosmos/precompile/bank/i_bank_module.abigen.go (2 hunks)
- x/cronos/events/bindings/cosmos/precompile/ica/i_ica_module.abigen.go (2 hunks)
- x/cronos/events/bindings/cosmos/precompile/icacallback/i_ica_callback.abigen.go (2 hunks)
- x/cronos/events/bindings/cosmos/precompile/relayer/i_relayer_functions.abigen.go (2 hunks)
- x/cronos/events/bindings/cosmos/precompile/relayer/i_relayer_module.abigen.go (16 hunks)
- x/cronos/events/bindings/src/Relayer.sol (1 hunks)
- x/cronos/events/events.go (1 hunks)
Additional comments: 30
x/cronos/events/bindings/src/Relayer.sol (4)
- 12-20: The addition of indexed parameters to the
RecvPacket
event enhances the ability to filter and search for events based onpacketSequence
,packetSrcPort
, andpacketSrcChannel
. This is a positive change for data querying capabilities. However, ensure that the size of the indexed parameters, especially if they are strings, does not lead to increased gas costs or exceed block gas limits when emitting these events.- 22-27: The
WriteAcknowledgement
event has been updated similarly toRecvPacket
with indexed parameters for better searchability. This change follows the same positive pattern as theRecvPacket
event. Again, be mindful of potential gas cost implications due to the use of strings as indexed parameters.- 31-36: The
AcknowledgePacket
event now includesconnectionId
as a parameter, replacingpacketConnection
andpacketChannelOrdering
from the previous version. This simplification could improve the event's usability, assumingconnectionId
provides sufficient context for event consumers. Ensure that all event consumers are updated to accommodate this change.- 39-44: The
TimeoutPacket
event has been updated in a manner consistent with theAcknowledgePacket
event, including the same set of indexed parameters. This consistency across event definitions is good for maintainability and understanding of the code. As with other events, consider the implications of using strings as indexed parameters.x/cronos/events/events.go (1)
- 20-35: The updates to the
RelayerValueDecoders
map include new attribute keys and their corresponding decoder functions. This is a necessary change to support the new event attributes introduced by the PR. Ensure that all new attribute keys are correctly mapped to their decoders and that these decoders are implemented correctly to handle the data types of the attributes.x/cronos/events/bindings/cosmos/precompile/icacallback/i_ica_callback.abigen.go (2)
- 29-29: The addition of
_ = abi.ConvertType
is a good practice to suppress unused import errors and indicates that type conversion functionality from theabi
package might be used elsewhere in the generated code. This is a standard pattern in Go for generated code.- 138-142: Changing the ABI retrieval method to use
ICACallbackMetaData.GetAbi()
instead of parsing JSON directly is a cleaner and more maintainable approach. This change ensures that the ABI is retrieved in a consistent manner, leveraging the metadata structure. Ensure that theGetAbi()
method correctly handles any potential errors and returns the expected ABI object.x/cronos/events/bindings/cosmos/lib/cosmos_types.abigen.go (2)
- 29-29: The inclusion of
_ = abi.ConvertType
in the variable declarations section is appropriate for suppressing unused import errors in generated Go code. This indicates the potential use of type conversion features provided by theabi
package.- 166-170: Switching to
CosmosTypesMetaData.GetAbi()
for ABI retrieval instead of parsing JSON directly is a positive change, aligning with best practices for handling contract ABIs in Go. This method provides a more structured and error-handling capable approach to ABI retrieval. Verify that theGetAbi()
method is implemented correctly and handles errors as expected.integration_tests/test_ibc_rly.py (6)
- 38-39: The introduction of
method_name_map
andmethod_with_seq
variables is a good practice for managing method names and identifying those that require sequence numbers. This approach improves code readability and maintainability.- 112-119: The
recv_packet
function now includes aseq
parameter and additional packet information. It's crucial to ensure that thepacketSequence
is correctly formatted and that all packet-related parameters are accurately represented.Please verify the correctness of the
packetSequence
formatting and the inclusion of all necessary packet information.
- 124-131: Similar to the
recv_packet
function, theacknowledge_packet
function has been updated to include aseq
parameter. Ensure that the sequence number is correctly handled and that the function aligns with the expected behavior for acknowledging packets.Confirm that the sequence number handling in the
acknowledge_packet
function is accurate and meets the requirements for packet acknowledgment.
- 141-148: The
write_ack
function's modifications to include aseq
parameter and additional packet information should be carefully reviewed to ensure that acknowledgments are correctly processed and that the packet data is accurately represented.Double-check the
write_ack
function's handling of the sequence number and packet data to ensure correctness and alignment with expected behavior.
- 175-189: The
get_send_packet_seq
function's addition is a significant enhancement for retrieving the sequence number of sent packets. It's important to validate the logic for extracting the sequence number from transaction events and ensure that it functions correctly in all scenarios.Please validate the logic and functionality of the
get_send_packet_seq
function to ensure it accurately retrieves the sequence number from sent packet events.
- 192-201: The
filter_logs_since
function's update to include aseq
parameter for filtering logs by sequence number is a valuable addition. Ensure that the filtering logic is correctly implemented and that it effectively narrows down the logs based on the provided sequence number.Confirm the effectiveness and correctness of the log filtering logic in the
filter_logs_since
function, especially in relation to sequence number handling.x/cronos/events/bindings/cosmos/precompile/bank/i_bank_module.abigen.go (2)
- 29-29: The addition of the
abi.ConvertType
import suggests that type conversion functionality is being utilized in the module. Ensure that this import is necessary and correctly used wherever type conversions are required.Please verify the usage of
abi.ConvertType
to ensure it's necessary and correctly applied in the context of this module.
- 138-142: The modification in the ABI retrieval method from
abi.JSON
toBankModuleMetaData.GetAbi()
is a positive change towards a more structured approach in handling contract ABIs. This change should improve the maintainability and readability of the code by leveraging the contract metadata.x/cronos/events/bindings/cosmos/precompile/ica/i_ica_module.abigen.go (2)
- 29-29: The addition of
abi.ConvertType
in the imports is appropriate given its usage in theQueryAccount
method to convert the output type. This ensures type safety and clarity in the contract method bindings.- 138-142: The modification in the
bindICAModule
function to useICAModuleMetaData.GetAbi()
instead of directly parsing the ABI string is a significant improvement. This change leverages theGetAbi
method, which likely provides a more structured and error-handled way to retrieve the ABI, enhancing maintainability and reducing the risk of runtime errors due to incorrect ABI parsing.integration_tests/utils.py (1)
- 690-702: The addition of the
by_name
parameter to theget_method_map
function introduces a useful feature that allows users to map method names to keys instead of the default behavior of mapping keys to signatures. This change enhances the flexibility and usability of the function, especially in scenarios where method names are more intuitive or easier to work with than signatures.However, it's important to ensure that:
- The documentation is updated to reflect this new feature and its usage.
- Any potential impact on existing tests or utilities that rely on the default behavior is carefully considered and addressed.
Overall, the implementation appears to be correct and logically sound. Great job on improving the functionality of this utility function!
integration_tests/ibc_utils.py (1)
- 430-430: The modification to the
check_balance_change
function to return a tuple containing bothamount
andpacket_seq
is a logical enhancement. This change allows for more detailed assertions in tests, particularly those involving IBC transfers where both the amount transferred and the packet sequence are relevant.However, it's crucial to ensure that all calls to
check_balance_change
throughout the integration tests have been updated to handle the new tuple return type. Failing to update these calls could lead to runtime errors or incorrect test assertions.CHANGELOG.md (1)
- 7-7: The addition of the
packet_sequence
index in the relayer event is correctly documented in the CHANGELOG under the "Improvements" section for the UNRELEASED version. This follows the standard format and provides a clear link to the pull request for more details.integration_tests/cosmoscli.py (1)
- 225-234: The addition of the
order
parameter to thetx_search_rpc
method enhances the method's functionality by allowing users to specify the order of transaction search results. This change is correctly implemented and follows good coding practices. However, it's important to ensure that theorder
parameter values are validated against expected values (e.g., "asc" or "desc") to prevent potential errors or misuse of the API.Additionally, consider adding documentation for the
order
parameter to describe its purpose, expected values, and impact on the method's behavior. This will improve the maintainability and usability of the method for future developers and users.x/cronos/events/bindings/cosmos/precompile/relayer/i_relayer_functions.abigen.go (1)
- 138-142: The modification to use
RelayerFunctionsMetaData.GetAbi()
for ABI retrieval instead of parsing it from a hardcoded string is a significant improvement in terms of maintainability and error reduction. This change abstracts the ABI retrieval process, making the code cleaner and more robust. It's crucial to ensure that theGetAbi()
method is correctly implemented and reliably returns the correct ABI. The introduction of error handling for the ABI retrieval process is also a positive change, enhancing the robustness of the contract binding.x/cronos/events/bindings/cosmos/precompile/relayer/i_relayer_module.abigen.go (6)
- 47-47: The ABI string has been updated to include new parameters (
packetSequence
,packetSrcPort
,packetSrcChannel
,packetDstPort
,packetDstChannel
, andconnectionId
) in various event definitions. This change aligns with the PR's objective to enhance event handling capabilities by indexingpacket_sequence
and including additional packet information.- 265-271: The
RelayerModuleAcknowledgePacket
struct has been updated to include new fields corresponding to the added event parameters. This update is necessary for correctly parsing and handlingAcknowledgePacket
events. Ensure that the types of the new fields (PacketSequence
,PacketSrcPort
,PacketSrcChannel
ascommon.Hash
andPacketDstPort
,PacketDstChannel
,ConnectionId
asstring
) are appropriate for the data they are intended to hold.- 1766-1773: The
RelayerModuleRecvPacket
struct has been updated to include new fields corresponding to the added event parameters, as well as aPacketDataHex
field of typeIRelayerModulePacketData
. This update is crucial for correctly parsing and handlingRecvPacket
events. It's important to verify that thePacketDataHex
field is correctly handled in the parsing logic to ensure the structured data is accurately represented.- 2086-2092: The
RelayerModuleTimeoutPacket
struct has been updated similarly to include new fields for the added event parameters. This change ensures thatTimeoutPacket
events can be correctly parsed and handled. The consistency in struct updates across different event types helps maintain the clarity and usability of the contract bindings.- 2405-2410: The
RelayerModuleWriteAcknowledgement
struct update includes new fields for the added event parameters, ensuring thatWriteAcknowledgement
events are correctly parsed and handled. This update is aligned with the changes in other event-related structs, maintaining consistency across the contract bindings.- 151-155: The method
bindRelayerModule
now usesRelayerModuleMetaData.GetAbi()
to retrieve the ABI for the contract. This change from directly using a hardcoded ABI string to using a metadata-based approach enhances maintainability and reduces the risk of ABI mismatches.
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #1318 +/- ##
===========================================
+ Coverage 15.98% 36.31% +20.33%
===========================================
Files 80 118 +38
Lines 6201 10774 +4573
===========================================
+ Hits 991 3913 +2922
- Misses 5130 6481 +1351
- Partials 80 380 +300
|
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.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Files selected for processing (1)
- versiondb/client/verify.go (1 hunks)
Files skipped from review due to trivial changes (1)
- versiondb/client/verify.go
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.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Files ignored due to path filters (3)
go.mod
is excluded by:!**/*.mod
go.sum
is excluded by:!**/*.sum
gomod2nix.toml
is excluded by:!**/*.toml
Files selected for processing (1)
- CHANGELOG.md (1 hunks)
Files skipped from review as they are similar to previous changes (1)
- CHANGELOG.md
08da9cc
👮🏻👮🏻👮🏻 !!!! REFERENCE THE PROBLEM YOUR ARE SOLVING IN THE PR TITLE AND DESCRIBE YOUR SOLUTION HERE !!!! DO NOT FORGET !!!! 👮🏻👮🏻👮🏻
PR Checklist:
make
)make test
)go fmt
)golangci-lint run
)go list -json -m all | nancy sleuth
)Thank you for your code, it's appreciated! :)
Summary by CodeRabbit