-
Notifications
You must be signed in to change notification settings - Fork 3.9k
fix(gno): support inter-realm cross-calls in voyager tx and state plugins #5478
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
Open
aronpark1007
wants to merge
7
commits into
unionlabs:main
Choose a base branch
from
onbloc:fix/gno-voyager-inter-realm-cross-call
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+360
−301
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
1fef6b2
fix(gno): switch tx plugin datagram templates to realm-aware msg cons…
aronpark1007 d3a9327
fix(gno): handle typed return format in parse_gno_string_object
aronpark1007 9f109db
fix(gno): parse chunked packet_data and acknowledgement event attrs
aronpark1007 aa20456
fix(gno): switch tx plugin msg constructors to types package and wire…
aronpark1007 e929522
fix(gno): parse chunked maker_msg event attrs
aronpark1007 c4141ef
fix(voyager/state-gno): find PacketSend event by type in query_packet…
aronpark1007 75feaf2
fix(gno): parse and construct batch_send and packet_ack events
aronpark1007 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -68,11 +68,21 @@ pub enum IbcEvent { | |
| }, | ||
|
|
||
| // TODO | ||
| BatchSend {}, | ||
| BatchSend { | ||
| packet_hash: H256, | ||
| batch_hash: H256, | ||
| channel_id: ChannelId, | ||
| }, | ||
|
|
||
| PacketRecv { | ||
| packet_hash: H256, | ||
| packet_data: Bytes, | ||
| destination_channel_id: ChannelId, | ||
| maker_msg: Bytes, | ||
| }, | ||
|
|
||
| // TODO | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can remove todo |
||
| PacketAck { | ||
| packet_hash: H256, | ||
| source_channel_id: ChannelId, | ||
| source_connection_id: ConnectionId, | ||
| source_connection_client_id: ClientId, | ||
|
|
@@ -81,12 +91,10 @@ pub enum IbcEvent { | |
| destination_connection_id: ConnectionId, | ||
| destination_connection_client_id: ClientId, | ||
| timeout_timestamp: Timestamp, | ||
| maker_msg: Bytes, | ||
| acknowledgement: Bytes, | ||
| maker: String, | ||
| }, | ||
|
|
||
| // TODO | ||
| PacketAck {}, | ||
|
|
||
| WriteAck { | ||
| packet_hash: H256, | ||
| packet_data: Bytes, | ||
|
|
@@ -141,6 +149,35 @@ impl IbcEvent { | |
| .map_err(RpcError::fatal(format!("error parsing value for key {ty}"))) | ||
| } | ||
|
|
||
| fn chunked_attr(attrs: &[gno_rpc::types::EventAttribute], ty: &str) -> RpcResult<Bytes> { | ||
| // If no _size field is present, the value was emitted as a single plain attribute. | ||
| let Some(hex_str_len) = attr::<usize>(attrs, &format!("{ty}_size")).ok() else { | ||
| return attr(attrs, ty); | ||
| }; | ||
|
|
||
| // Collect raw chunk strings. gno splits the full "0x<hex>" string into | ||
| // 4096-char slices, so only chunk[0] carries the "0x" prefix; subsequent | ||
| // chunks are bare hex continuations. | ||
| let combined: String = (0..) | ||
| .map_while(|i| { | ||
| attrs | ||
| .iter() | ||
| .find_map(|a| (a.key == format!("{ty}[{i}]")).then(|| a.value.clone())) | ||
| }) | ||
| .collect(); | ||
|
|
||
| if combined.len() != hex_str_len { | ||
| return Err(RpcError::fatal_from_message(format!( | ||
| "key {ty} incomplete: got {} hex chars, expected {hex_str_len}", | ||
| combined.len(), | ||
| ))); | ||
| } | ||
|
|
||
| combined | ||
| .parse::<Bytes>() | ||
| .map_err(RpcError::fatal(format!("error parsing hex for key {ty}"))) | ||
| } | ||
|
|
||
| let attrs = gno_event | ||
| .attrs | ||
| .ok_or_else(|| RpcError::fatal_from_message("no attributes on event"))?; | ||
|
|
@@ -204,35 +241,42 @@ impl IbcEvent { | |
| "ChannelOpenConfirm" => IbcEvent::ChannelOpenConfirm(parse_channel_event(attrs)?), | ||
| "PacketRecv" => IbcEvent::PacketRecv { | ||
| packet_hash: attr(&attrs, "packet_hash")?, | ||
| packet_data: attr(&attrs, "packet_data")?, | ||
| destination_channel_id: attr(&attrs, "destination_channel_id")?, | ||
| maker_msg: chunked_attr(&attrs, "maker_msg")?, | ||
| }, | ||
| "PacketSend" => IbcEvent::PacketSend { | ||
| packet_hash: attr(&attrs, "packet_hash")?, | ||
| packet_data: chunked_attr(&attrs, "packet_data")?, | ||
| source_channel_id: attr(&attrs, "source_channel_id")?, | ||
| source_channel_version: attr(&attrs, "source_channel_version")?, | ||
| source_connection_id: attr(&attrs, "source_connection_id")?, | ||
| source_connection_client_id: attr(&attrs, "source_connection_client_id")?, | ||
| destination_channel_id: attr(&attrs, "destination_channel_id")?, | ||
| destination_channel_version: attr(&attrs, "destination_channel_version")?, | ||
| destination_connection_id: attr(&attrs, "destination_connection_id")?, | ||
| destination_connection_client_id: attr(&attrs, "destination_connection_client_id")?, | ||
| timeout_timestamp: attr(&attrs, "timeout_timestamp")?, | ||
| maker_msg: attr(&attrs, "maker_msg")?, | ||
| }, | ||
| "PacketSend" => IbcEvent::PacketSend { | ||
| "BatchSend" => IbcEvent::BatchSend { | ||
| packet_hash: attr(&attrs, "packet_hash")?, | ||
| batch_hash: attr(&attrs, "batch_hash")?, | ||
| channel_id: attr(&attrs, "channel_id")?, | ||
| }, | ||
| "PacketAck" => IbcEvent::PacketAck { | ||
| packet_hash: attr(&attrs, "packet_hash")?, | ||
| packet_data: attr(&attrs, "packet_data")?, | ||
| source_channel_id: attr(&attrs, "source_channel_id")?, | ||
| source_channel_version: attr(&attrs, "source_channel_version")?, | ||
| source_connection_id: attr(&attrs, "source_connection_id")?, | ||
| source_connection_client_id: attr(&attrs, "source_connection_client_id")?, | ||
| destination_channel_id: attr(&attrs, "destination_channel_id")?, | ||
| destination_channel_version: attr(&attrs, "destination_channel_version")?, | ||
| destination_connection_id: attr(&attrs, "destination_connection_id")?, | ||
| destination_connection_client_id: attr(&attrs, "destination_connection_client_id")?, | ||
| timeout_timestamp: attr(&attrs, "timeout_timestamp")?, | ||
| acknowledgement: chunked_attr(&attrs, "acknowledgement")?, | ||
| maker: attr(&attrs, "maker")?, | ||
| }, | ||
| // TODO | ||
| "BatchSend" => IbcEvent::BatchSend {}, | ||
| "PacketAck" => IbcEvent::PacketAck {}, | ||
| "WriteAck" => IbcEvent::WriteAck { | ||
| packet_hash: attr(&attrs, "packet_hash")?, | ||
| packet_data: attr(&attrs, "packet_data")?, | ||
| packet_data: chunked_attr(&attrs, "packet_data")?, | ||
| source_channel_id: attr(&attrs, "source_channel_id")?, | ||
| source_connection_id: attr(&attrs, "source_connection_id")?, | ||
| source_connection_client_id: attr(&attrs, "source_connection_client_id")?, | ||
|
|
@@ -241,7 +285,7 @@ impl IbcEvent { | |
| destination_connection_id: attr(&attrs, "destination_connection_id")?, | ||
| destination_connection_client_id: attr(&attrs, "destination_connection_client_id")?, | ||
| timeout_timestamp: attr(&attrs, "timeout_timestamp")?, | ||
| acknowledgement: attr(&attrs, "acknowledgement")?, | ||
| acknowledgement: chunked_attr(&attrs, "acknowledgement")?, | ||
| }, | ||
| event => { | ||
| warn!("unknown event: {event}"); | ||
|
|
||
Oops, something went wrong.
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.
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.
do we need to support both?