Skip to content
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

Voyager patches #3644

Merged
merged 5 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/ibc-solidity/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion lib/ibc-union-spec/src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ pub struct PacketRecv {

pub packet: PacketMetadata,

pub relayer_msg: Bytes,
pub maker_msg: Bytes,
}

#[derive(Debug, Clone, PartialEq, Eq)]
Expand Down
50 changes: 25 additions & 25 deletions lib/ibc-union-spec/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -185,17 +185,17 @@ 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,
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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down
7 changes: 5 additions & 2 deletions lib/voyager-message/src/rpc/server.rs
Original file line number Diff line number Diff line change
@@ -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},
Expand Down Expand Up @@ -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)?;
Expand Down
14 changes: 6 additions & 8 deletions lib/voyager-vm/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<T>> {
store: &'a T::Context,
Expand All @@ -22,7 +22,7 @@ impl<'a, T: QueueMessage, Q: Queue<T>> Engine<'a, T, Q> {
}
}

pub fn run(self) -> impl Stream<Item = Result<T::Data, BoxDynError>> + Send + Captures<'a> {
pub fn run(self) -> impl Stream<Item = Result<T::Data, BoxDynError>> + Send + use<'a, T, Q> {
futures::stream::try_unfold(self, |this| async move {
sleep(Duration::from_millis(10)).await;
let res = this.step().await;
Expand All @@ -33,10 +33,8 @@ impl<'a, T: QueueMessage, Q: Queue<T>> Engine<'a, T, Q> {

pub(crate) fn step<'b>(
&'b self,
) -> impl Future<Output = Result<Option<Option<T::Data>>, BoxDynError>>
+ Captures<'a>
+ Captures<'b>
+ Send {
) -> impl Future<Output = Result<Option<Option<T::Data>>, 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
Expand All @@ -53,7 +51,7 @@ impl<'a, T: QueueMessage, Q: Queue<T>> 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])]))
}
})
Expand Down
18 changes: 14 additions & 4 deletions voyager/modules/consensus/ethereum/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![warn(clippy::unwrap_used)]

use alloy::{
eips::BlockNumberOrTag,
providers::{Provider, ProviderBuilder, RootProvider},
Expand Down Expand Up @@ -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!(
Expand Down Expand Up @@ -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::<()>))
}
}

Expand All @@ -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
};
Expand Down
12 changes: 7 additions & 5 deletions voyager/plugins/event-source/cosmos-sdk/src/ibc_events.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::num::NonZeroU64;

use ibc_union_spec::types::Packet;
use serde::{Deserialize, Serialize};
use unionlabs::{
bech32::Bech32,
Expand Down Expand Up @@ -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<HexUnprefixed>,
packet: Packet,
maker: Bech32<Bytes>,
maker_msg: Bytes<HexUnprefixed>,
},

#[serde(rename = "wasm-packet_ack")]
WasmPacketAck {
#[serde(with = "stringified_json")]
packet: ibc_solidity::Packet,
packet: Packet,
acknowledgement: Bytes<HexUnprefixed>,
},

#[serde(rename = "wasm-write_ack")]
WasmWriteAck {
#[serde(with = "stringified_json")]
packet: ibc_solidity::Packet,
packet: Packet,
acknowledgement: Bytes<HexUnprefixed>,
},
}
Expand Down
Loading
Loading