feat: implement query methods for unreceived packets and acks #226
+43
−3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes: #219
Description
This PR introduces two new methods,
unreceived_packet_sequences
andunreceived_ack_sequences
to theIChannelQuery
interface. These methods filter pending packets based on a provided list of sequences.If an empty array of sequences is passed, the methods throw an error. This behavior differs from the typical implementation in Cosmos chains, where passing an empty array would return all unreceived packets. The decision to deviate from this convention is intentional. Otherwise it requires the Cairo contract to maintain and update a list of received commitment and acknowledgment keys (computed from paths using Poseidon hashing), where the size of list only can be up to the 255 elements. This also would necessitate to deal with deletion upon packet processing completion, adding significant on-chain costs. Thus, for each packet, this would involve:
For these, providing query endpoints that return comprehensive lists of packet commitments and acknowledgments isn't efficient as well. Similarly, for the send packet endpoint, our internal discussions concluded that maintaining such data on-chain would unnecessarily bloat Cairo storage. Plus, implementing a robust on-chain query language would also be burdensome.
Instead, Starknet nodes offer a
get_events
endpoint with adequate filtering options. Leveragingget_events
should be a more efficient for obtaining a list of packet commitments or acknowledgments when relayers need them.