Skip to content

Commit

Permalink
feat(voyager): extract block fetching to a plugin
Browse files Browse the repository at this point in the history
yolo

wip

wip

wip

wip
  • Loading branch information
benluelo committed Sep 30, 2024
1 parent 4e9bf95 commit adf9310
Show file tree
Hide file tree
Showing 89 changed files with 7,232 additions and 5,170 deletions.
202 changes: 200 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ members = [
"unionvisor",

"voyager",

"voyager/modules/chain/cosmos-sdk",
"voyager/modules/chain/ethereum",
"voyager/modules/chain/movement",
Expand All @@ -90,6 +91,15 @@ members = [
"voyager/modules/consensus/movement",
"voyager/modules/consensus/tendermint",

"voyager/plugins/client-update/cometbls",
"voyager/plugins/client-update/ethereum",
"voyager/plugins/client-update/movement",
"voyager/plugins/client-update/tendermint",

"voyager/plugins/event-source/cosmos-sdk",
"voyager/plugins/event-source/ethereum",
"voyager/plugins/event-source/movement",

"voyager/plugins/transaction/cosmos-sdk",
"voyager/plugins/transaction/ethereum",
"voyager/plugins/transaction/aptos",
Expand Down
1 change: 1 addition & 0 deletions generated/rust/aptos-move-ibc/src/app.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions generated/rust/aptos-move-ibc/src/lib.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions lib/beacon-api/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,18 @@ pub enum BlockId {
Hash(H256),
}

impl From<u64> for BlockId {
fn from(slot: u64) -> Self {
BlockId::Slot(slot)
}
}

impl From<H256> for BlockId {
fn from(root: H256) -> Self {
BlockId::Hash(root)
}
}

impl Display for BlockId {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Expand Down
4 changes: 1 addition & 3 deletions lib/cometbls-groth16-verifier/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,9 +336,7 @@ mod tests {

#[test]
fn test_decode() {
let zkp = ZKP::try_from(hex!("1c9bc15a0c4541aff1d12780d6cf4ae2bdc6e3afafceae9d4fa36209fa323b68002e9c77c223d830e5df6a80cdd683f0986353933ee3179970fccc5d893219d30726f3b8c0dbe630b815b01b5557228a0dfeb0e0435bb0d15d1ccff7f6133fc110937d9fceee2f9052468c198fafeca89d524142a0efa9dc4df445853ce617302059018fef03dc34456ad201d2a5420a7d1c8fac57cb48cbe6709ac4da27d1eb250f73eab007d26cbff41ceb4564ab1cdfa83e9ee88be4f816dc841bbf2e90c80186ad9437fce7655c71b54addae1ccea429da3edba3232d073cb7e89ff2d27218556f1af0c446962ace932f637279dd0ad3ef1501fb6da39d5f68282f54bcf6094999672f3d8cbbf0409aef1048175ffff50b03a5154016d307a2ef425ffee509cd447b22ce6331c7a3473b2c6da1f9d550e8c3ab19bde65e699e07f4f2886c03ec4ff2faa0e342de7ac5daf32025acd6070c19ed8b007c121db0d955472c7d2e38d5a943d15bc902613029e4baa8c26034ff280e3a4d5468fcd6745afe53b5").as_slice()).unwrap();

// dbg!(zkp);
ZKP::try_from(hex!("1c9bc15a0c4541aff1d12780d6cf4ae2bdc6e3afafceae9d4fa36209fa323b68002e9c77c223d830e5df6a80cdd683f0986353933ee3179970fccc5d893219d30726f3b8c0dbe630b815b01b5557228a0dfeb0e0435bb0d15d1ccff7f6133fc110937d9fceee2f9052468c198fafeca89d524142a0efa9dc4df445853ce617302059018fef03dc34456ad201d2a5420a7d1c8fac57cb48cbe6709ac4da27d1eb250f73eab007d26cbff41ceb4564ab1cdfa83e9ee88be4f816dc841bbf2e90c80186ad9437fce7655c71b54addae1ccea429da3edba3232d073cb7e89ff2d27218556f1af0c446962ace932f637279dd0ad3ef1501fb6da39d5f68282f54bcf6094999672f3d8cbbf0409aef1048175ffff50b03a5154016d307a2ef425ffee509cd447b22ce6331c7a3473b2c6da1f9d550e8c3ab19bde65e699e07f4f2886c03ec4ff2faa0e342de7ac5daf32025acd6070c19ed8b007c121db0d955472c7d2e38d5a943d15bc902613029e4baa8c26034ff280e3a4d5468fcd6745afe53b5").as_slice()).unwrap();
}

#[test]
Expand Down
28 changes: 13 additions & 15 deletions lib/queue-msg/benches/normalize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use criterion::{black_box, criterion_group, criterion_main, Criterion};
use queue_msg::{call, conc, data, noop, normalize::normalize, promise, seq, Op};
use unionlabs::ibc::core::client::height::Height;
use voyager_message::{
call::FetchBlock, callback::AggregateFetchBlockRange, core::ChainId, data::LatestHeight,
VoyagerMessage,
call::FetchBlocks, callback::AggregateMsgUpdateClientsFromOrderedHeaders, core::ChainId,
data::LatestHeight, VoyagerMessage,
};

fn bench_normalize(c: &mut Criterion) {
Expand All @@ -26,9 +26,9 @@ fn mk_msg() -> Op<VoyagerMessage> {
revision_height: 1,
},
}),
call(FetchBlock {
call(FetchBlocks {
chain_id: ChainId::new("chain"),
height: Height {
start_height: Height {
revision_number: 1,
revision_height: 1,
},
Expand All @@ -42,21 +42,19 @@ fn mk_msg() -> Op<VoyagerMessage> {
revision_height: 1,
},
}),
call(FetchBlock {
call(FetchBlocks {
chain_id: ChainId::new("chain"),
height: Height {
start_height: Height {
revision_number: 1,
revision_height: 1,
},
}),
]),
],
[],
AggregateFetchBlockRange {
from_height: Height {
revision_number: 1,
revision_height: 1,
},
AggregateMsgUpdateClientsFromOrderedHeaders {
chain_id: ChainId::new("chain"),
counterparty_client_id: "counterparty_chain".parse().unwrap(),
},
),
seq([
Expand All @@ -67,9 +65,9 @@ fn mk_msg() -> Op<VoyagerMessage> {
revision_height: 1,
},
}),
call(FetchBlock {
call(FetchBlocks {
chain_id: ChainId::new("chain"),
height: Height {
start_height: Height {
revision_number: 1,
revision_height: 1,
},
Expand All @@ -83,9 +81,9 @@ fn mk_msg() -> Op<VoyagerMessage> {
revision_height: 1,
},
}),
call(FetchBlock {
call(FetchBlocks {
chain_id: ChainId::new("chain"),
height: Height {
start_height: Height {
revision_number: 1,
revision_height: 1,
},
Expand Down
9 changes: 9 additions & 0 deletions lib/queue-msg/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,15 @@ mod tests {
assert_eq!(normalize(vec![msg.clone()]), vec![(vec![0], msg)]);
}

#[test]
fn conc_seq_call_call_call() {
let msg = conc::<UnitMessage>([seq([call(()), call(())]), call(())]);
assert_eq!(
normalize(vec![msg.clone()]),
vec![(vec![0], seq([call(()), call(())])), (vec![0], call(()))]
);
}

#[test]
fn extract_data_simple() {
let msg = seq::<UnitMessage>([
Expand Down
8 changes: 7 additions & 1 deletion lib/queue-msg/src/normalize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ pub fn normalize<T: QueueMessage>(ops: Vec<Op<T>>) -> Vec<(Vec<usize>, Op<T>)> {

ops.into_iter()
.enumerate()
.flat_map(|(i, op)| go(op).into_iter().map(move |op| (vec![i], op)))
.flat_map(|(i, op)| {
// flatten conc to multiple messages
go(op).into_iter().flat_map(move |op| match op {
Op::Conc(ops) => ops.into_iter().map(move |op| (vec![i], op)).collect(),
op => vec![(vec![i], op)],
})
})
.collect()
}
Loading

0 comments on commit adf9310

Please sign in to comment.