Skip to content

Commit

Permalink
feat(voyager)!: voyager v2
Browse files Browse the repository at this point in the history
wip

wip

wip

wip

wip

wip

wip

wip

wip

wip

wip

wip

wip

wip

wip

wip

wip

wip

wip

wip

wip

wip

wip

wip

wip

wip

wip

wip

wip

wip

wip

wip

wip

wip

wip

wip

wip

wip

wip

wip

wip

wip

wip

wip

wip

wip

wip

wip

wip

wip

wip

wip

wip

wip

wip

wip

wip

wip

wip

normalize comments

wip

wip: cleanup

wip

wip

wip

wip: newtype chain id

wip: cleanup

wip

wip: cleanup

wip: cleanup

wip

wip

cleanup after rebase

wip

wip

wip: update movement protos & fmt

wip

wip

wip: typetagged magic

take that, move

wip: fmt

wip: more betterer codegen

wip

wip

wip

wip

feat: package modules and allow plugin conf

wip

fix: modules and plugins

wip: dev

wip: voyager-modules

wip: fix enabled option

wip: log format

wip: fix

wip

wip

wip: ws or http idc

wip

wip: yeet

wip: time to test in prod

wip: slight cleanup

wip: fix voyager.nix

wip: less exploding in cosmos-sdk chian module

wip: extract reconnecting client to library

wip: pain

wip: ? is dangerous

wip: oops

wip

wip: oops again

wip: moar logs

wip: check if packet already sent

wip: don't drop updates if queue is empty

wip: clean up clean up

everybody everywhere

wip

wip: no more splodey

wip: add wait until connectec to cometbft-rpc

wip: cleanup

wip: don't cancel on drop

ask me how long i spent figuring this out

wip: fix panic

wip

wip
  • Loading branch information
benluelo committed Sep 16, 2024
1 parent be596ba commit 39a7fe2
Show file tree
Hide file tree
Showing 354 changed files with 36,388 additions and 27,782 deletions.
9,538 changes: 5,504 additions & 4,034 deletions Cargo.lock

Large diffs are not rendered by default.

121 changes: 74 additions & 47 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ members = [

"hubble",

"lib/aptos-rpc",
"lib/beacon-api",
"lib/block-message",
"lib/chain-utils",
"lib/cometbft-rpc",

"lib/chain-utils",
"lib/gnark-key-parser",
"lib/gnark-mimc",
"lib/ibc-vm-rs",
Expand All @@ -32,7 +33,6 @@ members = [
"lib/poseidon-rs",
"lib/queue-msg",
"lib/queue-msg-macro",
"lib/relay-message",
"lib/scroll-api",
"lib/scroll-codec",
"lib/scroll-rpc",
Expand All @@ -41,13 +41,12 @@ members = [
"lib/ssz/tests-generator",
"lib/ssz-derive",
"lib/unionlabs",
"lib/voyager-message",
"lib/zktrie-rs",

"lib/near/near-ibc",
"lib/near/near-light-client",
"lib/near/dummy-ibc-app",
"lib/near/near-ibc-tests",
# "lib/near/near-ibc-tests",

"lib/arbitrum-verifier",
"lib/cometbls-groth16-verifier",
Expand All @@ -68,14 +67,35 @@ members = [
"tools/devnet-utils",
"tools/parse-wasm-client-type",
"tools/tidy",
"tools/move-bindgen",
"lib/move-bindgen-derive",

"ucli",
"unionvisor",

"voyager",
"voyager/modules/chain/cosmos-sdk",
"voyager/modules/chain/ethereum",
"voyager/modules/chain/movement",

"voyager/modules/client/cometbls",
"voyager/modules/client/ethereum",

"voyager/modules/consensus/cometbls",
"voyager/modules/consensus/ethereum",

"voyager/modules/transaction/cosmos-sdk",
"voyager/modules/transaction/ethereum",
"voyager/modules/transaction/aptos",

"voyager/plugins/packet-filter",
"voyager/plugins/transaction-batch",

"drip",
"light-clients/movement/ics08-movement",
"lib/aptos-verifier",

"lib/reconnecting-jsonrpc-ws-client",
]

[workspace.package]
Expand All @@ -91,45 +111,45 @@ lto = "thin"
opt-level = 3

[workspace.dependencies]
aptos-verifier = { path = "lib/aptos-verifier", default-features = false }
arbitrum-verifier = { path = "lib/arbitrum-verifier", default-features = false }
beacon-api = { path = "lib/beacon-api", default-features = false }
block-message = { path = "lib/block-message", default-features = false }
chain-utils = { path = "lib/chain-utils", default-features = false }
cometbft-rpc = { path = "lib/cometbft-rpc", default-features = false }
cometbls-groth16-verifier = { path = "lib/cometbls-groth16-verifier", default-features = false }
contracts = { path = "generated/rust/contracts", default-features = false }
ethereum-light-client = { path = "light-clients/ethereum-light-client", default-features = false }
ethereum-verifier = { path = "lib/ethereum-verifier", default-features = false }
evm-in-cosmos-light-client = { path = "light-clients/evm-in-cosmos-light-client", default-features = false }
gnark-key-parser = { path = "lib/gnark-key-parser", default-features = false }
gnark-mimc = { path = "lib/gnark-mimc", default-features = false }
ibc-vm-rs = { path = "lib/ibc-vm-rs", default-features = false }
ics008-wasm-client = { path = "lib/ics-008-wasm-client", default-features = false }
ics23 = { path = "lib/ics23", default-features = false }
linea-verifier = { path = "lib/linea-verifier", default-features = false }
linea-zktrie = { path = "lib/linea-zktrie", default-features = false }
macros = { path = "lib/macros", default-features = false }
pg-queue = { path = "lib/pg-queue", default-features = false }
poseidon-rs = { path = "lib/poseidon-rs", default-features = false }
protos = { path = "generated/rust/protos", default-features = false }
queue-msg = { path = "lib/queue-msg", default-features = false }
queue-msg-macro = { path = "lib/queue-msg-macro", default-features = false }
relay-message = { path = "lib/relay-message", default-features = false }
scroll-api = { path = "lib/scroll-api", default-features = false }
scroll-codec = { path = "lib/scroll-codec", default-features = false }
scroll-rpc = { path = "lib/scroll-rpc", default-features = false }
scroll-verifier = { path = "lib/scroll-verifier", default-features = false }
serde-utils = { path = "lib/serde-utils", default-features = false }
ssz = { path = "lib/ssz", default-features = false }
ssz-derive = { path = "lib/ssz-derive", default-features = false }
tendermint-light-client = { path = "light-clients/tendermint-light-client", default-features = false }
tendermint-verifier = { path = "lib/tendermint-verifier", default-features = false }
token-factory-api = { path = "cosmwasm/token-factory-api", default-features = false }
ucs01-relay-api = { path = "cosmwasm/ucs01-relay-api", default-features = false }
unionlabs = { path = "lib/unionlabs", default-features = false }
voyager-message = { path = "lib/voyager-message", default-features = false }
zktrie = { path = "lib/zktrie-rs", default-features = false }
aptos-verifier = { path = "lib/aptos-verifier", default-features = false }
arbitrum-verifier = { path = "lib/arbitrum-verifier", default-features = false }
beacon-api = { path = "lib/beacon-api", default-features = false }
chain-utils = { path = "lib/chain-utils", default-features = false }
cometbft-rpc = { path = "lib/cometbft-rpc", default-features = false }
cometbls-groth16-verifier = { path = "lib/cometbls-groth16-verifier", default-features = false }
contracts = { path = "generated/rust/contracts", default-features = false }
ethereum-light-client = { path = "light-clients/ethereum-light-client", default-features = false }
ethereum-verifier = { path = "lib/ethereum-verifier", default-features = false }
gnark-key-parser = { path = "lib/gnark-key-parser", default-features = false }
gnark-mimc = { path = "lib/gnark-mimc", default-features = false }
ibc-vm-rs = { path = "lib/ibc-vm-rs", default-features = false }
ics008-wasm-client = { path = "lib/ics-008-wasm-client", default-features = false }
ics23 = { path = "lib/ics23", default-features = false }
linea-verifier = { path = "lib/linea-verifier", default-features = false }
linea-zktrie = { path = "lib/linea-zktrie", default-features = false }
macros = { path = "lib/macros", default-features = false }
move-bindgen = { path = "tools/move-bindgen", default-features = false }
move-bindgen-derive = { path = "lib/move-bindgen-derive", default-features = false }
pg-queue = { path = "lib/pg-queue", default-features = false }
poseidon-rs = { path = "lib/poseidon-rs", default-features = false }
protos = { path = "generated/rust/protos", default-features = false }
queue-msg = { path = "lib/queue-msg", default-features = false }
queue-msg-macro = { path = "lib/queue-msg-macro", default-features = false }
reconnecting-jsonrpc-ws-client = { path = "lib/reconnecting-jsonrpc-ws-client", default-features = false }
scroll-api = { path = "lib/scroll-api", default-features = false }
scroll-codec = { path = "lib/scroll-codec", default-features = false }
scroll-rpc = { path = "lib/scroll-rpc", default-features = false }
scroll-verifier = { path = "lib/scroll-verifier", default-features = false }
serde-utils = { path = "lib/serde-utils", default-features = false }
ssz = { path = "lib/ssz", default-features = false }
ssz-derive = { path = "lib/ssz-derive", default-features = false }
tendermint-light-client = { path = "light-clients/tendermint-light-client", default-features = false }
tendermint-verifier = { path = "lib/tendermint-verifier", default-features = false }
token-factory-api = { path = "cosmwasm/token-factory-api", default-features = false }
ucs01-relay-api = { path = "cosmwasm/ucs01-relay-api", default-features = false }
unionlabs = { path = "lib/unionlabs", default-features = false }
voyager-message = { path = "lib/voyager-message", default-features = false }
zktrie = { path = "lib/zktrie-rs", default-features = false }

# external dependencies
milagro_bls = { git = "https://github.com/Snowfork/milagro_bls", rev = "bc2b5b5e8d48b7e2e1bfaa56dc2d93e13cb32095", default-features = false }
Expand All @@ -143,9 +163,10 @@ ethers-contract-abigen = { git = "https://github.com/unionlabs/ethers-rs", branc
ethers-contract-derive = { git = "https://github.com/unionlabs/ethers-rs", branch = "ethers-core-wasm", default-features = false }
ethers-core = { git = "https://github.com/unionlabs/ethers-rs", branch = "ethers-core-wasm", default-features = false }

near-workspaces = { git = "https://github.com/unionlabs/near-workspaces-rs-union", branch = "near-ibc", default-features = false }

arbitrary = { version = "1.3.0", default-features = false }
# https://github.com/aptos-labs/aptos-core/pull/12636
aptos-crypto = { git = "https://github.com/unionlabs/aptos-core" }
aptos-rest-client = { git = "https://github.com/unionlabs/aptos-core" }
aptos-types = { git = "https://github.com/unionlabs/aptos-core" }
axum = { version = "0.6.20", default-features = false }
base64 = { version = "0.21", default-features = false }
bip32 = { version = "0.5.0", default-features = false }
Expand All @@ -171,7 +192,9 @@ futures = { version = "0.3.28", default-features = false }
go-parse-duration = { version = "0.1.1", default-features = false }
hex = { version = "0.4.3", default-features = false }
hex-literal = { version = "0.4.1", default-features = false }
jsonrpsee = { version = "0.24.2", default-features = false }
lazy_static = { version = "1.4.0", default-features = false }
move-core-types = { git = "https://github.com/unionlabs/aptos-core" }
near-contract-standards = { version = "5.1.0", default-features = false }
near-sdk = { version = "5.1.0", default-features = false }
near-sdk-contract-tools = { version = "3.0.2", default-features = false }
Expand Down Expand Up @@ -205,3 +228,7 @@ typenum = { version = "1.17.0", default-features = false }
[patch."crates-io"]
arbitrary = { git = "https://github.com/unionlabs/arbitrary" }
# parity-secp256k1 = { git = "https://github.com/paritytech/rust-secp256k1" }

# https://aptos.dev/en/build/sdks/rust-sdk
merlin = { git = "https://github.com/aptos-labs/merlin" }
x25519-dalek = { git = "https://github.com/aptos-labs/x25519-dalek", branch = "zeroize_v1" }
12 changes: 11 additions & 1 deletion cosmwasm/ucs01-relay-api/src/middleware.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,20 @@ mod tests {
#[test]
fn serde_parses_memo() {
// let memo = "\"balls\": \"string\"";
let memo = "{\"forward\": {\"receiver\": \"[eth_addr]\",\"port\": \"[union-eth port]\",\"channel\": \"[union-eth channel]\",\"timeout\": \"1000000\",\"retries\": 0}}";
let memo = r#"{"forward": {"receiver": "[eth_addr]","port": "[union-eth port]","channel": "[union-eth channel]","timeout": "1000000","retries": 0}}"#;

let parsed = serde_json_wasm::from_str::<Memo>(memo).expect("works");

dbg!(parsed);
}

#[test]
fn serde_parses_memo_without_port_as_none() {
// let memo = "\"balls\": \"string\"";
let memo = r#"{"forward":{"channel":"channel-201","receiver":"2C96e52fCE14BAa13868CA8182f8A7903e4e76E0"}}"#;

let parsed = serde_json_wasm::from_str::<Memo>(memo).expect("works");

assert_eq!(parsed, Memo::None {})
}
}
6 changes: 3 additions & 3 deletions cosmwasm/ucs01-relay/src/ibc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ use crate::{
state::{ChannelInfo, PfmRefundPacketKey, CHANNEL_INFO, IN_FLIGHT_PFM_PACKETS},
};

#[cfg(test)]
mod tests;

fn to_response<T>(
IbcReceiveResponse {
acknowledgement,
Expand Down Expand Up @@ -309,6 +312,3 @@ pub fn ibc_packet_timeout(
}),
}
}

#[cfg(test)]
mod tests;
1 change: 1 addition & 0 deletions cosmwasm/ucs01-relay/src/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1127,6 +1127,7 @@ impl<'a> TransferProtocol for Ucs01Protocol<'a> {
}

#[cfg(test)]
#[allow(deprecated)] // TODO: Remove useage of mock_info
mod tests {
use cosmwasm_std::{
testing::{message_info, mock_dependencies, mock_env},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ We recommend running Voyager on a machine co-located with your chain's RPC nodes
},
"voyager": {
"num_workers": 4,
"laddr": "0.0.0.0:65534",
"laddr": "0.0.0.0:7717",
"queue": {
"type": "pg-queue",
"database_url": "postgres://user:password@127.0.0.1:5432/default",
Expand Down
13 changes: 7 additions & 6 deletions evm/contracts/core/03-connection/IBCConnection.sol
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ library IBCConnectionLib {
error ErrNoCounterpartyVersion();
error ErrUnsupportedVersion();
error ErrVersionMustBeUnset();
error ErrInvalidProof();
error ErrInvalidConnectionProof();
error ErrInvalidClientStateProof();
error ErrInvalidConnectionState();

// yes, these are all defined as strings in the ibc spec
Expand Down Expand Up @@ -443,7 +444,7 @@ contract IBCConnection is IBCStore, IIBCConnectionHandshake {
expectedConnection
)
) {
revert IBCConnectionLib.ErrInvalidProof();
revert IBCConnectionLib.ErrInvalidConnectionProof();
}
if (
!verifyClientState(
Expand All @@ -454,7 +455,7 @@ contract IBCConnection is IBCStore, IIBCConnectionHandshake {
msg_.clientStateBytes
)
) {
revert IBCConnectionLib.ErrInvalidProof();
revert IBCConnectionLib.ErrInvalidClientStateProof();
}

updateConnectionCommitment(connectionId);
Expand Down Expand Up @@ -521,7 +522,7 @@ contract IBCConnection is IBCStore, IIBCConnectionHandshake {
expectedConnection
)
) {
revert IBCConnectionLib.ErrInvalidProof();
revert IBCConnectionLib.ErrInvalidConnectionProof();
}
if (
!verifyClientState(
Expand All @@ -532,7 +533,7 @@ contract IBCConnection is IBCStore, IIBCConnectionHandshake {
msg_.clientStateBytes
)
) {
revert IBCConnectionLib.ErrInvalidProof();
revert IBCConnectionLib.ErrInvalidClientStateProof();
}

connection.state = IbcCoreConnectionV1GlobalEnums.State.STATE_OPEN;
Expand Down Expand Up @@ -593,7 +594,7 @@ contract IBCConnection is IBCStore, IIBCConnectionHandshake {
expectedConnection
)
) {
revert IBCConnectionLib.ErrInvalidProof();
revert IBCConnectionLib.ErrInvalidClientStateProof();
}

connection.state = IbcCoreConnectionV1GlobalEnums.State.STATE_OPEN;
Expand Down
16 changes: 10 additions & 6 deletions evm/tests/src/25-handler/IBCConnectionHandler.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -226,13 +226,13 @@ contract IBCConnectionHandlerTests is TestPlus {

function preAckInvalidConnectionStateProof() public {
client.reset();
vm.expectRevert(IBCConnectionLib.ErrInvalidProof.selector);
vm.expectRevert(IBCConnectionLib.ErrInvalidConnectionProof.selector);
}

function preAckInvalidClientStateProof() public {
client.reset();
client.pushValidMembership(0);
vm.expectRevert(IBCConnectionLib.ErrInvalidProof.selector);
vm.expectRevert(IBCConnectionLib.ErrInvalidClientStateProof.selector);
}

function preTryValidProofs() public {
Expand All @@ -243,13 +243,13 @@ contract IBCConnectionHandlerTests is TestPlus {

function preTryInvalidConnectionStateProof() public {
client.reset();
vm.expectRevert(IBCConnectionLib.ErrInvalidProof.selector);
vm.expectRevert(IBCConnectionLib.ErrInvalidConnectionProof.selector);
}

function preTryInvalidClientStateProof() public {
client.reset();
client.pushValidMembership(0);
vm.expectRevert(IBCConnectionLib.ErrInvalidProof.selector);
vm.expectRevert(IBCConnectionLib.ErrInvalidClientStateProof.selector);
}

function preConfirmValidProofs() public {
Expand All @@ -258,7 +258,11 @@ contract IBCConnectionHandlerTests is TestPlus {
}

function preConfirmInvalidConnectionState() public {
vm.expectRevert(IBCConnectionLib.ErrInvalidProof.selector);
vm.expectRevert(IBCConnectionLib.ErrInvalidConnectionProof.selector);
}

function preConfirmInvalidClientState() public {
vm.expectRevert(IBCConnectionLib.ErrInvalidClientStateProof.selector);
}

function test_handshake_init_ack_ok(uint64 proofHeight) public {
Expand Down Expand Up @@ -597,7 +601,7 @@ contract IBCConnectionHandlerTests is TestPlus {

IBCMsgs.MsgConnectionOpenConfirm memory msg_confirm =
MsgMocks.connectionOpenConfirm(clientId, connId, proofHeight);
preConfirmInvalidConnectionState();
preConfirmInvalidClientState();
handler.connectionOpenConfirm(msg_confirm);
}

Expand Down
6 changes: 2 additions & 4 deletions generated/rust/contracts/Cargo.toml

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

Loading

0 comments on commit 39a7fe2

Please sign in to comment.