From 45ec2c32724cbb6119117f0b3b133267ac1d3b6f Mon Sep 17 00:00:00 2001 From: benluelo Date: Thu, 23 Jan 2025 08:30:42 +0000 Subject: [PATCH 1/5] feat(voyager): retryable errors are only a warning also Captures -> use --- lib/voyager-vm/src/engine.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/lib/voyager-vm/src/engine.rs b/lib/voyager-vm/src/engine.rs index f6f2f2da4f..d42efb5b24 100644 --- a/lib/voyager-vm/src/engine.rs +++ b/lib/voyager-vm/src/engine.rs @@ -2,10 +2,10 @@ use std::{future::Future, time::Duration}; use futures::{stream, FutureExt, Stream, StreamExt}; use tokio::time::sleep; -use tracing::error; +use tracing::{error, warn}; use unionlabs::ErrorReporter; -use crate::{defer, now, seq, BoxDynError, Captures, Context, Queue, QueueError, QueueMessage}; +use crate::{defer, now, seq, BoxDynError, Context, Queue, QueueError, QueueMessage}; pub struct Engine<'a, T: QueueMessage, Q: Queue> { store: &'a T::Context, @@ -22,7 +22,7 @@ impl<'a, T: QueueMessage, Q: Queue> Engine<'a, T, Q> { } } - pub fn run(self) -> impl Stream> + Send + Captures<'a> { + pub fn run(self) -> impl Stream> + Send + use<'a, T, Q> { futures::stream::try_unfold(self, |this| async move { sleep(Duration::from_millis(10)).await; let res = this.step().await; @@ -33,10 +33,8 @@ impl<'a, T: QueueMessage, Q: Queue> Engine<'a, T, Q> { pub(crate) fn step<'b>( &'b self, - ) -> impl Future>, BoxDynError>> - + Captures<'a> - + Captures<'b> - + Send { + ) -> impl Future>, BoxDynError>> + use<'a, 'b, T, Q> + Send + { // yield back to the runtime and throttle a bit, prevents 100% cpu usage while still allowing for a fast spin-loop sleep(Duration::from_millis(10)).then(|()| { self.queue @@ -53,7 +51,7 @@ impl<'a, T: QueueMessage, Q: Queue> Engine<'a, T, Q> { Err(QueueError::Retry(retry)) => { // TODO: Add some backoff logic here based on `full_err`? let full_err = ErrorReporter(&*retry); - error!(error = %full_err, "retryable error"); + warn!(error = %full_err, "retryable error"); (None, Ok(vec![seq([defer(now() + 3), op])])) } }) From d226a20985b22ba76ef6f415ac9781f526cb4833 Mon Sep 17 00:00:00 2001 From: benluelo Date: Fri, 24 Jan 2025 10:54:08 +0000 Subject: [PATCH 2/5] chore(voyager): go to therapy panic less --- lib/voyager-message/src/rpc/server.rs | 9 ++++++--- voyager/modules/consensus/ethereum/src/main.rs | 18 ++++++++++++++---- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/lib/voyager-message/src/rpc/server.rs b/lib/voyager-message/src/rpc/server.rs index d661392fcf..3752a93783 100644 --- a/lib/voyager-message/src/rpc/server.rs +++ b/lib/voyager-message/src/rpc/server.rs @@ -1,8 +1,11 @@ +#![warn(clippy::unwrap_used)] + use std::{ fmt::Debug, sync::{Arc, OnceLock}, }; +use anyhow::anyhow; use jsonrpsee::{ core::{async_trait, RpcResult}, types::{ErrorObject, ErrorObjectOwned}, @@ -19,7 +22,7 @@ use voyager_vm::ItemId; use crate::{ context::{LoadedModulesInfo, Modules, WithId}, core::{ChainId, ClientInfo, ClientStateMeta, ClientType, IbcInterface, QueryHeight}, - into_value, + into_value, json_rpc_error_to_queue_error, module::{ ClientBootstrapModuleClient, ClientModuleClient, ConsensusModuleClient, RawProofModuleClient, RawStateModuleClient, @@ -250,9 +253,9 @@ impl Server { .ibc_spec_handlers .handlers .get(ibc_spec_id) - .unwrap() + .ok_or_else(|| fatal_error(&*anyhow!("ibc spec {ibc_spec_id} is not supported in this build of voyager")))? .client_state_path)(client_id.clone()) - .unwrap(), + .map_err(|err| fatal_error(&*err))?, ) .await .map_err(json_rpc_error_to_error_object)?; diff --git a/voyager/modules/consensus/ethereum/src/main.rs b/voyager/modules/consensus/ethereum/src/main.rs index 874b05e2a3..d6b6e421f5 100644 --- a/voyager/modules/consensus/ethereum/src/main.rs +++ b/voyager/modules/consensus/ethereum/src/main.rs @@ -1,3 +1,5 @@ +#![warn(clippy::unwrap_used)] + use alloy::{ eips::BlockNumberOrTag, providers::{Provider, ProviderBuilder, RootProvider}, @@ -108,7 +110,11 @@ impl ConsensusModule for Module { let beacon_api_client = BeaconApiClient::new(config.beacon_rpc_url).await?; - let spec = beacon_api_client.spec().await.unwrap().data; + let spec = beacon_api_client + .spec() + .await + .map_err(|err| ErrorObject::owned(-1, ErrorReporter(err).to_string(), None::<()>))? + .data; if spec.preset_base != config.chain_spec { return Err(format!( @@ -139,7 +145,11 @@ impl ConsensusModuleServer for Module { .map(|response| Height::new(response.data.finalized_header.execution.block_number)) .map_err(|err| ErrorObject::owned(-1, ErrorReporter(err).to_string(), None::<()>)) } else { - Ok(Height::new(self.provider.get_block_number().await.unwrap())) + self.provider + .get_block_number() + .await + .map(Height::new) + .map_err(|err| ErrorObject::owned(-1, ErrorReporter(err).to_string(), None::<()>)) } } @@ -166,8 +176,8 @@ impl ConsensusModuleServer for Module { BlockTransactionsKind::Hashes, ) .await - .unwrap() - .unwrap() + .map_err(|err| ErrorObject::owned(-1, ErrorReporter(err).to_string(), None::<()>))? + .ok_or_else(|| ErrorObject::owned(-1, "latest block not found", None::<()>))? .header .timestamp }; From 145ed299a11ed9f46e8d2f0e098b82a5f013c3e8 Mon Sep 17 00:00:00 2001 From: benluelo Date: Sun, 26 Jan 2025 16:40:05 +0000 Subject: [PATCH 3/5] fix(voyager): properly parse packet_recv messages --- .../event-source/cosmos-sdk/src/ibc_events.rs | 12 +++++++----- voyager/plugins/event-source/cosmos-sdk/src/main.rs | 5 +---- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/voyager/plugins/event-source/cosmos-sdk/src/ibc_events.rs b/voyager/plugins/event-source/cosmos-sdk/src/ibc_events.rs index dc3a30c679..2087770ea3 100644 --- a/voyager/plugins/event-source/cosmos-sdk/src/ibc_events.rs +++ b/voyager/plugins/event-source/cosmos-sdk/src/ibc_events.rs @@ -1,5 +1,6 @@ use std::num::NonZeroU64; +use ibc_union_spec::types::Packet; use serde::{Deserialize, Serialize}; use unionlabs::{ bech32::Bech32, @@ -302,27 +303,28 @@ pub enum IbcEvent { #[serde(rename = "wasm-packet_send")] WasmPacketSend { #[serde(with = "stringified_json")] - packet: ibc_solidity::Packet, + packet: Packet, }, #[serde(rename = "wasm-packet_recv")] WasmPacketRecv { #[serde(with = "stringified_json")] - packet: ibc_solidity::Packet, - relayer_msg: Bytes, + packet: Packet, + maker: Bech32, + maker_msg: Bytes, }, #[serde(rename = "wasm-packet_ack")] WasmPacketAck { #[serde(with = "stringified_json")] - packet: ibc_solidity::Packet, + packet: Packet, acknowledgement: Bytes, }, #[serde(rename = "wasm-write_ack")] WasmWriteAck { #[serde(with = "stringified_json")] - packet: ibc_solidity::Packet, + packet: Packet, acknowledgement: Bytes, }, } diff --git a/voyager/plugins/event-source/cosmos-sdk/src/main.rs b/voyager/plugins/event-source/cosmos-sdk/src/main.rs index a2d75a68ff..d40e19d733 100644 --- a/voyager/plugins/event-source/cosmos-sdk/src/main.rs +++ b/voyager/plugins/event-source/cosmos-sdk/src/main.rs @@ -1659,10 +1659,7 @@ impl Module { event: into_value::(event), })) } - IbcEvent::WasmPacketRecv { - packet, - relayer_msg, - } => { + IbcEvent::WasmPacketRecv { packet, maker_msg } => { let destination_channel = voyager_client .query_ibc_state( self.chain_id.clone(), From 4aa583b8fe79eb4393785042ee2074bc0022a7e1 Mon Sep 17 00:00:00 2001 From: benluelo Date: Mon, 27 Jan 2025 09:00:12 +0000 Subject: [PATCH 4/5] fix(voyager): fix recv packet event sourcing on cosmos --- lib/ibc-solidity/src/lib.rs | 2 +- lib/ibc-union-spec/src/event.rs | 2 +- lib/ibc-union-spec/src/lib.rs | 2 +- lib/voyager-message/src/rpc/server.rs | 4 ++-- .../plugins/event-source/cosmos-sdk/src/main.rs | 16 +++++++++------- .../plugins/event-source/ethereum/src/main.rs | 2 +- .../plugins/event-source/movement/src/main.rs | 2 +- 7 files changed, 16 insertions(+), 14 deletions(-) diff --git a/lib/ibc-solidity/src/lib.rs b/lib/ibc-solidity/src/lib.rs index ed15ef01ca..4ae68a1372 100644 --- a/lib/ibc-solidity/src/lib.rs +++ b/lib/ibc-solidity/src/lib.rs @@ -283,7 +283,7 @@ maybe_sol_attr! { feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(deny_unknown_fields) )] - event PacketRecv(Packet packet, address relayer, bytes relayer_msg); + event PacketRecv(Packet packet, address relayer, bytes maker_msg); #[cfg_attr( feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(deny_unknown_fields) diff --git a/lib/ibc-union-spec/src/event.rs b/lib/ibc-union-spec/src/event.rs index 8defe44dd2..856dedf74f 100644 --- a/lib/ibc-union-spec/src/event.rs +++ b/lib/ibc-union-spec/src/event.rs @@ -273,7 +273,7 @@ pub struct PacketRecv { pub packet: PacketMetadata, - pub relayer_msg: Bytes, + pub maker_msg: Bytes, } #[derive(Debug, Clone, PartialEq, Eq)] diff --git a/lib/ibc-union-spec/src/lib.rs b/lib/ibc-union-spec/src/lib.rs index f474155290..9b17c521ff 100644 --- a/lib/ibc-union-spec/src/lib.rs +++ b/lib/ibc-union-spec/src/lib.rs @@ -185,7 +185,7 @@ pub fn log_event(e: &FullEvent, chain_id: &voyager_core::ChainId) { event, %chain_id, data.packet_data = %e.packet_data, - data.relayer_msg = %e.relayer_msg, + data.maker_msg = %e.maker_msg, data.packet.source_channel.channel_id = %e.packet.source_channel.channel_id, data.packet.source_channel.version = %e.packet.source_channel.version, diff --git a/lib/voyager-message/src/rpc/server.rs b/lib/voyager-message/src/rpc/server.rs index 3752a93783..fd5e6f7df5 100644 --- a/lib/voyager-message/src/rpc/server.rs +++ b/lib/voyager-message/src/rpc/server.rs @@ -1,4 +1,4 @@ -#![warn(clippy::unwrap_used)] +// #![warn(clippy::unwrap_used)] use std::{ fmt::Debug, @@ -22,7 +22,7 @@ use voyager_vm::ItemId; use crate::{ context::{LoadedModulesInfo, Modules, WithId}, core::{ChainId, ClientInfo, ClientStateMeta, ClientType, IbcInterface, QueryHeight}, - into_value, json_rpc_error_to_queue_error, + into_value, module::{ ClientBootstrapModuleClient, ClientModuleClient, ConsensusModuleClient, RawProofModuleClient, RawStateModuleClient, diff --git a/voyager/plugins/event-source/cosmos-sdk/src/main.rs b/voyager/plugins/event-source/cosmos-sdk/src/main.rs index d40e19d733..bbe3dabe17 100644 --- a/voyager/plugins/event-source/cosmos-sdk/src/main.rs +++ b/voyager/plugins/event-source/cosmos-sdk/src/main.rs @@ -1622,7 +1622,7 @@ impl Module { .await?; let event = ibc_union_spec::event::PacketAck { - packet_data: packet.data.into(), + packet_data: packet.data, packet: ibc_union_spec::event::PacketMetadata { source_channel: ibc_union_spec::event::ChannelMetadata { channel_id: packet.source_channel_id, @@ -1659,7 +1659,11 @@ impl Module { event: into_value::(event), })) } - IbcEvent::WasmPacketRecv { packet, maker_msg } => { + IbcEvent::WasmPacketRecv { + packet, + maker, + maker_msg, + } => { let destination_channel = voyager_client .query_ibc_state( self.chain_id.clone(), @@ -1712,7 +1716,7 @@ impl Module { .unwrap(); let event = ibc_union_spec::event::PacketRecv { - packet_data: packet.data.into(), + packet_data: packet.data, packet: ibc_union_spec::event::PacketMetadata { source_channel: ibc_union_spec::event::ChannelMetadata { channel_id: packet.source_channel_id, @@ -1725,7 +1729,6 @@ impl Module { destination_channel: ibc_union_spec::event::ChannelMetadata { channel_id: packet.destination_channel_id, version: destination_channel.version.clone(), - connection: ibc_union_spec::event::ConnectionMetadata { client_id: destination_connection.client_id, connection_id: destination_channel.connection_id, @@ -1734,7 +1737,7 @@ impl Module { timeout_height: packet.timeout_height, timeout_timestamp: packet.timeout_timestamp, }, - relayer_msg: relayer_msg.into_encoding(), + maker_msg: maker_msg.into_encoding(), } .into(); @@ -1806,7 +1809,7 @@ impl Module { .unwrap(); let event = ibc_union_spec::event::WriteAck { - packet_data: packet.data.into(), + packet_data: packet.data, packet: ibc_union_spec::event::PacketMetadata { source_channel: ibc_union_spec::event::ChannelMetadata { channel_id: packet.source_channel_id, @@ -1819,7 +1822,6 @@ impl Module { destination_channel: ibc_union_spec::event::ChannelMetadata { channel_id: packet.destination_channel_id, version: destination_channel.version.clone(), - connection: ibc_union_spec::event::ConnectionMetadata { client_id: destination_connection.client_id, connection_id: destination_channel.connection_id, diff --git a/voyager/plugins/event-source/ethereum/src/main.rs b/voyager/plugins/event-source/ethereum/src/main.rs index e9883f4e70..218dd902c9 100644 --- a/voyager/plugins/event-source/ethereum/src/main.rs +++ b/voyager/plugins/event-source/ethereum/src/main.rs @@ -877,7 +877,7 @@ impl PluginServer for Module { timeout_height: event.packet.timeout_height, timeout_timestamp: event.packet.timeout_timestamp, }, - relayer_msg: event.relayer_msg.into(), + maker_msg: event.maker_msg.into(), } .into(); diff --git a/voyager/plugins/event-source/movement/src/main.rs b/voyager/plugins/event-source/movement/src/main.rs index 40af6e056f..2c94fdc32d 100644 --- a/voyager/plugins/event-source/movement/src/main.rs +++ b/voyager/plugins/event-source/movement/src/main.rs @@ -662,7 +662,7 @@ impl PluginServer for Module { timeout_height: event.packet.timeout_height, timeout_timestamp: event.packet.timeout_timestamp, }, - relayer_msg: Default::default(), + maker_msg: Default::default(), } .into(), client_id, From 32f4d1756c72902731753a2d1197c68328a630ec Mon Sep 17 00:00:00 2001 From: benluelo Date: Mon, 27 Jan 2025 10:04:46 +0000 Subject: [PATCH 5/5] chore(voyager): cleanup and logging fixes --- lib/ibc-union-spec/src/lib.rs | 48 +++++++++---------- .../event-source/cosmos-sdk/src/main.rs | 32 ++++++++++--- 2 files changed, 49 insertions(+), 31 deletions(-) diff --git a/lib/ibc-union-spec/src/lib.rs b/lib/ibc-union-spec/src/lib.rs index 9b17c521ff..f37985a71d 100644 --- a/lib/ibc-union-spec/src/lib.rs +++ b/lib/ibc-union-spec/src/lib.rs @@ -169,13 +169,13 @@ pub fn log_event(e: &FullEvent, chain_id: &voyager_core::ChainId) { data.packet.source_channel.channel_id = %e.packet.source_channel.channel_id, data.packet.source_channel.version = %e.packet.source_channel.version, - data.packet.source_channel = %e.packet.source_channel.connection.client_id, - data.packet.source_channel = %e.packet.source_channel.connection.connection_id, + data.packet.source_channel.connection.client_id = %e.packet.source_channel.connection.client_id, + data.packet.source_channel.connection.connection_id = %e.packet.source_channel.connection.connection_id, data.packet.destination_channel.channel_id = %e.packet.destination_channel.channel_id, data.packet.destination_channel.version = %e.packet.destination_channel.version, - data.packet.destination_channel = %e.packet.destination_channel.connection.client_id, - data.packet.destination_channel = %e.packet.destination_channel.connection.connection_id, + data.packet.destination_channel.connection.client_id = %e.packet.destination_channel.connection.client_id, + data.packet.destination_channel.connection.connection_id = %e.packet.destination_channel.connection.connection_id, data.packet.timeout_height = %e.packet.timeout_height, data.packet.timeout_timestamp = %e.packet.timeout_timestamp, @@ -189,13 +189,13 @@ pub fn log_event(e: &FullEvent, chain_id: &voyager_core::ChainId) { data.packet.source_channel.channel_id = %e.packet.source_channel.channel_id, data.packet.source_channel.version = %e.packet.source_channel.version, - data.packet.source_channel = %e.packet.source_channel.connection.client_id, - data.packet.source_channel = %e.packet.source_channel.connection.connection_id, + data.packet.source_channel.connection.client_id = %e.packet.source_channel.connection.client_id, + data.packet.source_channel.connection.connection_id = %e.packet.source_channel.connection.connection_id, data.packet.destination_channel.channel_id = %e.packet.destination_channel.channel_id, data.packet.destination_channel.version = %e.packet.destination_channel.version, - data.packet.destination_channel = %e.packet.destination_channel.connection.client_id, - data.packet.destination_channel = %e.packet.destination_channel.connection.connection_id, + data.packet.destination_channel.connection.client_id = %e.packet.destination_channel.connection.client_id, + data.packet.destination_channel.connection.connection_id = %e.packet.destination_channel.connection.connection_id, data.packet.timeout_height = %e.packet.timeout_height, data.packet.timeout_timestamp = %e.packet.timeout_timestamp, @@ -209,13 +209,13 @@ pub fn log_event(e: &FullEvent, chain_id: &voyager_core::ChainId) { data.packet.source_channel.channel_id = %e.packet.source_channel.channel_id, data.packet.source_channel.version = %e.packet.source_channel.version, - data.packet.source_channel = %e.packet.source_channel.connection.client_id, - data.packet.source_channel = %e.packet.source_channel.connection.connection_id, + data.packet.source_channel.connection.client_id = %e.packet.source_channel.connection.client_id, + data.packet.source_channel.connection.connection_id = %e.packet.source_channel.connection.connection_id, data.packet.destination_channel.channel_id = %e.packet.destination_channel.channel_id, data.packet.destination_channel.version = %e.packet.destination_channel.version, - data.packet.destination_channel = %e.packet.destination_channel.connection.client_id, - data.packet.destination_channel = %e.packet.destination_channel.connection.connection_id, + data.packet.destination_channel.connection.client_id = %e.packet.destination_channel.connection.client_id, + data.packet.destination_channel.connection.connection_id = %e.packet.destination_channel.connection.connection_id, data.packet.timeout_height = %e.packet.timeout_height, data.packet.timeout_timestamp = %e.packet.timeout_timestamp, @@ -229,13 +229,13 @@ pub fn log_event(e: &FullEvent, chain_id: &voyager_core::ChainId) { data.packet.source_channel.channel_id = %e.packet.source_channel.channel_id, data.packet.source_channel.version = %e.packet.source_channel.version, - data.packet.source_channel = %e.packet.source_channel.connection.client_id, - data.packet.source_channel = %e.packet.source_channel.connection.connection_id, + data.packet.source_channel.connection.client_id = %e.packet.source_channel.connection.client_id, + data.packet.source_channel.connection.connection_id = %e.packet.source_channel.connection.connection_id, data.packet.destination_channel.channel_id = %e.packet.destination_channel.channel_id, data.packet.destination_channel.version = %e.packet.destination_channel.version, - data.packet.destination_channel = %e.packet.destination_channel.connection.client_id, - data.packet.destination_channel = %e.packet.destination_channel.connection.connection_id, + data.packet.destination_channel.connection.client_id = %e.packet.destination_channel.connection.client_id, + data.packet.destination_channel.connection.connection_id = %e.packet.destination_channel.connection.connection_id, data.packet.timeout_height = %e.packet.timeout_height, data.packet.timeout_timestamp = %e.packet.timeout_timestamp, @@ -249,13 +249,13 @@ pub fn log_event(e: &FullEvent, chain_id: &voyager_core::ChainId) { data.packet.source_channel.channel_id = %e.packet.source_channel.channel_id, data.packet.source_channel.version = %e.packet.source_channel.version, - data.packet.source_channel = %e.packet.source_channel.connection.client_id, - data.packet.source_channel = %e.packet.source_channel.connection.connection_id, + data.packet.source_channel.connection.client_id = %e.packet.source_channel.connection.client_id, + data.packet.source_channel.connection.connection_id = %e.packet.source_channel.connection.connection_id, data.packet.destination_channel.channel_id = %e.packet.destination_channel.channel_id, data.packet.destination_channel.version = %e.packet.destination_channel.version, - data.packet.destination_channel = %e.packet.destination_channel.connection.client_id, - data.packet.destination_channel = %e.packet.destination_channel.connection.connection_id, + data.packet.destination_channel.connection.client_id = %e.packet.destination_channel.connection.client_id, + data.packet.destination_channel.connection.connection_id = %e.packet.destination_channel.connection.connection_id, data.packet.timeout_height = %e.packet.timeout_height, data.packet.timeout_timestamp = %e.packet.timeout_timestamp, @@ -268,13 +268,13 @@ pub fn log_event(e: &FullEvent, chain_id: &voyager_core::ChainId) { data.packet.source_channel.channel_id = %e.packet.source_channel.channel_id, data.packet.source_channel.version = %e.packet.source_channel.version, - data.packet.source_channel = %e.packet.source_channel.connection.client_id, - data.packet.source_channel = %e.packet.source_channel.connection.connection_id, + data.packet.source_channel.connection.client_id = %e.packet.source_channel.connection.client_id, + data.packet.source_channel.connection.connection_id = %e.packet.source_channel.connection.connection_id, data.packet.destination_channel.channel_id = %e.packet.destination_channel.channel_id, data.packet.destination_channel.version = %e.packet.destination_channel.version, - data.packet.destination_channel = %e.packet.destination_channel.connection.client_id, - data.packet.destination_channel = %e.packet.destination_channel.connection.connection_id, + data.packet.destination_channel.connection.client_id = %e.packet.destination_channel.connection.client_id, + data.packet.destination_channel.connection.connection_id = %e.packet.destination_channel.connection.connection_id, data.packet.timeout_height = %e.packet.timeout_height, data.packet.timeout_timestamp = %e.packet.timeout_timestamp, diff --git a/voyager/plugins/event-source/cosmos-sdk/src/main.rs b/voyager/plugins/event-source/cosmos-sdk/src/main.rs index bbe3dabe17..b80fc1b608 100644 --- a/voyager/plugins/event-source/cosmos-sdk/src/main.rs +++ b/voyager/plugins/event-source/cosmos-sdk/src/main.rs @@ -39,8 +39,7 @@ use voyager_message::{ into_value, module::{PluginInfo, PluginServer}, rpc::missing_state, - DefaultCmd, ExtensionsExt, Plugin, PluginMessage, VoyagerClient, VoyagerMessage, - FATAL_JSONRPC_ERROR_CODE, + ExtensionsExt, Plugin, PluginMessage, VoyagerClient, VoyagerMessage, FATAL_JSONRPC_ERROR_CODE, }; use voyager_vm::{call, conc, data, pass::PassResult, seq, BoxDynError, Op}; @@ -95,12 +94,18 @@ fn default_chunk_block_fetch_size() -> u64 { 10 } +#[derive(clap::Subcommand)] +pub enum Cmd { + /// Return an op to fetch the events from a single block from the chain. + FetchSingleBlock { height: Height }, +} + impl Plugin for Module { type Call = ModuleCall; type Callback = ModuleCallback; type Config = Config; - type Cmd = DefaultCmd; + type Cmd = Cmd; async fn new(config: Self::Config) -> Result { let tm_client = cometbft_rpc::Client::new(config.rpc_url).await?; @@ -142,8 +147,21 @@ impl Plugin for Module { } } - async fn cmd(_config: Self::Config, cmd: Self::Cmd) { - match cmd {} + async fn cmd(config: Self::Config, cmd: Self::Cmd) { + match cmd { + Cmd::FetchSingleBlock { height } => { + print!( + "{}", + into_value(call::(PluginMessage::new( + plugin_name(&config.chain_id), + ModuleCall::from(FetchTransactions { + height, + page: const { option_unwrap!(NonZeroU32::new(1)) } + }) + ))) + ) + } + } } } @@ -1545,7 +1563,7 @@ impl Module { .await?; let event = ibc_union_spec::event::PacketSend { - packet_data: packet.data.into(), + packet_data: packet.data, packet: ibc_union_spec::event::PacketMetadata { source_channel: ibc_union_spec::event::ChannelMetadata { channel_id: packet.source_channel_id, @@ -1661,7 +1679,7 @@ impl Module { } IbcEvent::WasmPacketRecv { packet, - maker, + maker: _, maker_msg, } => { let destination_channel = voyager_client