Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
benluelo committed Sep 16, 2024
1 parent 4e696f4 commit 1919609
Show file tree
Hide file tree
Showing 11 changed files with 575 additions and 619 deletions.
1 change: 1 addition & 0 deletions lib/serde-utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,7 @@ pub mod hex_string_list {
}
}

// TODO: Check if human readable
pub mod string {
use alloc::string::String;
use core::{fmt::Display, str::FromStr};
Expand Down
33 changes: 26 additions & 7 deletions lib/voyager-message/src/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use macros::apply;
use queue_msg::{
call, conc, data, defer, noop, now, promise, queue_msg, seq, HandleCall, Op, QueueError,
};
use serde_json::Value;
use serde_json::{json, Value};
use serde_utils::Hex;
use tracing::{debug, info, info_span, instrument, trace, Instrument};
use unionlabs::{
Expand Down Expand Up @@ -744,12 +744,31 @@ impl<D: Member, C: Member, Cb: Member> HandleCall<VoyagerMessage<D, C, Cb>> for
counterparty_chain_id,
update_from,
update_to,
}) => ctx
.consensus_module(&chain_id)
.map_err(error_object_to_queue_error)?
.fetch_update_headers(update_from, update_to, counterparty_chain_id)
.await
.map_err(json_rpc_error_to_queue_error),
}) => {
info!(
%chain_id,
%counterparty_chain_id,
%update_from,
%update_to,
"fetching update headers",
);
if update_from >= update_to {
Err(QueueError::Fatal(
format!(
"update range is invalid ({update_to} >= {update_to}), \
chain_id: {chain_id}, counterparty_chain_id: \
{counterparty_chain_id}"
)
.into(),
))
} else {
ctx.consensus_module(&chain_id)
.map_err(error_object_to_queue_error)?
.fetch_update_headers(update_from, update_to, counterparty_chain_id)
.await
.map_err(json_rpc_error_to_queue_error)
}
}

Call::MakeMsgCreateClient(MakeMsgCreateClient {
chain_id,
Expand Down
2 changes: 1 addition & 1 deletion lib/voyager-message/src/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ pub trait ConsensusModule<D: Member, C: Member, Cb: Member> {
/// [`AggregateMsgUpdateClientsFromOrderedHeaders`] message, which will
/// be used to build the actual [`MsgUpdateClient`]s.
#[method(name = "fetchUpdateHeaders")]
fn fetch_update_headers(
async fn fetch_update_headers(
&self,
update_from: Height,
update_to: Height,
Expand Down
38 changes: 21 additions & 17 deletions lib/voyager-message/src/pass.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use queue_msg::{
optimize::{OptimizationResult, PurePass},
BoxDynError, Op,
};
use tracing::{error, info, trace, trace_span};
use tracing::{error, trace, trace_span};
use unionlabs::ErrorReporter;

use crate::VoyagerMessage;
Expand Down Expand Up @@ -87,7 +87,9 @@ impl PurePass<VoyagerMessage> for JaqInterestFilter {
));

let Some(result) = out.next() else {
panic!("filter didn't return any values");
error!("filter didn't return any values");

continue;
};

let result = match result {
Expand All @@ -99,22 +101,24 @@ impl PurePass<VoyagerMessage> for JaqInterestFilter {
}
};

assert!(out.next().is_none(), "filter returned too many items");

match result {
Val::Bool(true) => {
info!(%msg_json, "interest");

opt_res
.optimize_further
.push((vec![idx], msg, plugin_name.clone()));

continue 'outer;
}
Val::Bool(false) => {
trace!(%msg_json, "no interest");
if out.next().is_some() {
error!("filter returned multiple values, only a single boolean value is valid");
} else {
match result {
Val::Bool(true) => {
trace!(%msg_json, "interest");

opt_res
.optimize_further
.push((vec![idx], msg, plugin_name.clone()));

continue 'outer;
}
Val::Bool(false) => {
trace!(%msg_json, "no interest");
}
_ => error!("filter returned a non-boolean value: {result:?}"),
}
_ => error!("filter returned a non-boolean value: {result:?}"),
}
}

Expand Down
2 changes: 1 addition & 1 deletion voyager/modules/consensus/cometbls/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ impl ConsensusModuleServer<ModuleData, ModuleCall, ModuleCallback> for ModuleSer
}

#[instrument(skip_all, fields(chain_id = %self.ctx.chain_id))]
fn fetch_update_headers(
async fn fetch_update_headers(
&self,
update_from: Height,
update_to: Height,
Expand Down
Loading

0 comments on commit 1919609

Please sign in to comment.