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

feat: voyager berachain #3387

Merged
merged 4 commits into from
Dec 31, 2024
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
60 changes: 60 additions & 0 deletions Cargo.lock

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

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,13 @@ members = [
"voyager/modules/client-bootstrap/movement",
"voyager/modules/client-bootstrap/tendermint",

"voyager/modules/consensus/berachain",
"voyager/modules/consensus/cometbls",
"voyager/modules/consensus/ethereum",
"voyager/modules/consensus/movement",
"voyager/modules/consensus/tendermint",

"voyager/plugins/client-update/berachain",
"voyager/plugins/client-update/cometbls",
"voyager/plugins/client-update/ethereum",
"voyager/plugins/client-update/movement",
Expand Down Expand Up @@ -254,6 +256,8 @@ voyager-core = { path = "lib/voyager-core", default-features = false }
voyager-message = { path = "lib/voyager-message", default-features = false }
voyager-vm = { path = "lib/voyager-vm", default-features = false }

voyager-consensus-module-tendermint = { path = "voyager/modules/consensus/tendermint", default-features = false }

# external dependencies
milagro_bls = { git = "https://github.com/Snowfork/milagro_bls", rev = "bc2b5b5e8d48b7e2e1bfaa56dc2d93e13cb32095", default-features = false }
tendermint-rpc = { git = "https://github.com/unionlabs/tendermint-rs", branch = "v0.39.1-bn254", default-features = false }
Expand Down
15 changes: 13 additions & 2 deletions cosmwasm/union-ibc/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# Handler

- `union-ibc`: [union17e93ukhcyesrvu72cgfvamdhyracghrx4f7ww89rqjg944ntdegscxepme](https://explorer.testnet-9.union.build/union/cosmwasm/0/transactions?contract=union17e93ukhcyesrvu72cgfvamdhyracghrx4f7ww89rqjg944ntdegscxepme)
- `etheruem-light-client`: [union198amaja0zfw53czzfph55xlhwf736qkrcvppx6y3a5rkqmxaj9fshqmczk](https://explorer.testnet-9.union.build/union/cosmwasm/0/transactions?contract=union198amaja0zfw53czzfph55xlhwf736qkrcvppx6y3a5rkqmxaj9fshqmczk)
- `union-ibc-ucs00-pingpong`: [union1aj2z8mf6ppg4pjsj787t69phxy3mx8p7ce8ncem05lls5j29haxsumypzd](https://explorer.testnet-9.union.build/union/cosmwasm/0/transactions?contract=union194e3rchcaqyynwcj6qr6647ge7lheymrgkhq9tdknw35050ufhuqzqz2he)

# Light Clients

- `ethereum-light-client`: [union198amaja0zfw53czzfph55xlhwf736qkrcvppx6y3a5rkqmxaj9fshqmczk](https://explorer.testnet-9.union.build/union/cosmwasm/0/transactions?contract=union198amaja0zfw53czzfph55xlhwf736qkrcvppx6y3a5rkqmxaj9fshqmczk)
- `tendermint-light-client`: [union17ymdtz48qey0lpha8erch8hghj37ag4dn0qqyyrtseymvgw6lfnqa962sy](https://explorer.testnet-9.union.build/union/cosmwasm/0/transactions?contract=union17ymdtz48qey0lpha8erch8hghj37ag4dn0qqyyrtseymvgw6lfnqa962sy)
- `berachain-light-client`: [union1au6fkkfcgqc6vn8dz9tq2a6ma0vzwn2zfwwgpm7awpaeekw346uqjedtky](https://explorer.testnet-9.union.build/union/cosmwasm/0/transactions?contract=union1au6fkkfcgqc6vn8dz9tq2a6ma0vzwn2zfwwgpm7awpaeekw346uqjedtky)

# Protocols

- `union-ibc-ucs00-pingpong`: [union194e3rchcaqyynwcj6qr6647ge7lheymrgkhq9tdknw35050ufhuqzqz2he](https://explorer.testnet-9.union.build/union/cosmwasm/0/transactions?contract=union194e3rchcaqyynwcj6qr6647ge7lheymrgkhq9tdknw35050ufhuqzqz2he)
union1au6fkkfcgqc6vn8dz9tq2a6ma0vzwn2zfwwgpm7awpaeekw346uqjedtky
6 changes: 6 additions & 0 deletions lib/cometbft-rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,12 @@ impl Client {
.await
}

pub async fn block_by_hash(&self, hash: H256) -> Result<BlockResponse, JsonRpcError> {
self.inner
.request("block_by_hash", (hash.to_string(),))
.await
}

pub async fn blockchain(
&self,
min_height: NonZeroU64,
Expand Down
2 changes: 1 addition & 1 deletion lib/voyager-message/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ thiserror = { workspace = true }
tokio = { workspace = true, features = ["time", "process", "fs"] }
tokio-util = "0.7.11"
tracing = { workspace = true }
tracing-subscriber = { workspace = true, features = ["json"] }
tracing-subscriber = { workspace = true, features = ["json", "env-filter"] }
unionlabs = { workspace = true, features = ["ethabi"] }
voyager-core = { workspace = true, features = ["schemars"] }
voyager-vm = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion voyager/modules/client/tendermint/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jsonrpsee = { workspace = true, features = ["macros", "serve
macros = { workspace = true }
serde = { workspace = true, features = ["derive"] }
serde_json = { workspace = true }
tendermint-light-client-types = { workspace = true, features = ["proto"] }
tendermint-light-client-types = { workspace = true, features = ["proto", "serde", "ethabi"] }
tokio = { workspace = true }
tracing = { workspace = true }
unionlabs = { workspace = true }
Expand Down
26 changes: 25 additions & 1 deletion voyager/modules/client/tendermint/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use tracing::{debug, instrument};
use unionlabs::{
self,
bytes::Bytes,
encoding::{DecodeAs, EncodeAs, Proto},
encoding::{Bincode, DecodeAs, EncodeAs, EthAbi, Proto},
google::protobuf::any::Any,
ErrorReporter,
};
Expand All @@ -35,6 +35,7 @@ async fn main() {
#[serde(try_from = "String", into = "String")]
pub enum SupportedIbcInterface {
IbcGoV8Native,
IbcCosmwasm,
}

impl TryFrom<String> for SupportedIbcInterface {
Expand All @@ -44,6 +45,7 @@ impl TryFrom<String> for SupportedIbcInterface {
fn try_from(value: String) -> Result<Self, Self::Error> {
match &*value {
IbcInterface::IBC_GO_V8_NATIVE => Ok(SupportedIbcInterface::IbcGoV8Native),
IbcInterface::IBC_COSMWASM => Ok(SupportedIbcInterface::IbcCosmwasm),
_ => Err(format!("unsupported IBC interface: `{value}`")),
}
}
Expand All @@ -53,6 +55,7 @@ impl SupportedIbcInterface {
fn as_str(&self) -> &'static str {
match self {
SupportedIbcInterface::IbcGoV8Native => IbcInterface::IBC_GO_V8_NATIVE,
SupportedIbcInterface::IbcCosmwasm => IbcInterface::IBC_COSMWASM,
}
}
}
Expand Down Expand Up @@ -99,6 +102,15 @@ impl Module {
})
.map(|any| any.0)
}
SupportedIbcInterface::IbcCosmwasm => {
ConsensusState::decode_as::<EthAbi>(consensus_state).map_err(|err| {
ErrorObject::owned(
FATAL_JSONRPC_ERROR_CODE,
format!("unable to decode consensus state: {}", ErrorReporter(err)),
None::<()>,
)
})
}
}
}

Expand All @@ -115,6 +127,14 @@ impl Module {
})
.map(|any| any.0)
}
SupportedIbcInterface::IbcCosmwasm => ClientState::decode_as::<Bincode>(client_state)
.map_err(|err| {
ErrorObject::owned(
FATAL_JSONRPC_ERROR_CODE,
format!("unable to decode client state: {}", ErrorReporter(err)),
None::<()>,
)
}),
}
}
}
Expand Down Expand Up @@ -190,6 +210,7 @@ impl ClientModuleServer for Module {
})
.map(|cs| match self.ibc_interface {
SupportedIbcInterface::IbcGoV8Native => Any(cs).encode_as::<Proto>().into(),
SupportedIbcInterface::IbcCosmwasm => cs.encode_as::<Bincode>().into(),
})
}

Expand All @@ -212,6 +233,7 @@ impl ClientModuleServer for Module {
})
.map(|cs| match self.ibc_interface {
SupportedIbcInterface::IbcGoV8Native => Any(cs).encode_as::<Proto>().into(),
SupportedIbcInterface::IbcCosmwasm => cs.encode_as::<EthAbi>().into(),
})
}

Expand Down Expand Up @@ -247,6 +269,7 @@ impl ClientModuleServer for Module {
})
.map(|header| match self.ibc_interface {
SupportedIbcInterface::IbcGoV8Native => Any(header).encode_as::<Proto>().into(),
SupportedIbcInterface::IbcCosmwasm => header.encode_as::<Bincode>().into(),
})
}

Expand All @@ -264,6 +287,7 @@ impl ClientModuleServer for Module {
})
.map(|cs| match self.ibc_interface {
SupportedIbcInterface::IbcGoV8Native => cs.encode_as::<Proto>().into(),
SupportedIbcInterface::IbcCosmwasm => cs.encode_as::<Bincode>().into(),
})
}
}
29 changes: 29 additions & 0 deletions voyager/modules/consensus/berachain/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[package]
edition = "2021"
name = "voyager-consensus-module-berachain"
version = "0.1.0"

[dependencies]
alloy = { workspace = true, features = ["rpc", "rpc-types", "transports", "transport-http", "transport-ws", "reqwest", "provider-ws"] }
beacon-api-types = { workspace = true, features = ["serde", "ssz"] }
berachain-light-client-types = { workspace = true, features = ["proto", "serde"] }
cometbft-rpc = { workspace = true }
dashmap = { workspace = true }
enumorph = { workspace = true }
futures = { workspace = true }
ics23 = { workspace = true }
jsonrpsee = { workspace = true, features = ["macros", "server", "tracing"] }
macros = { workspace = true }
num-bigint = { workspace = true }
prost = { workspace = true }
protos = { workspace = true }
serde = { workspace = true, features = ["derive"] }
serde_json = { workspace = true }
tendermint-light-client-types = { workspace = true, features = ["proto", "serde"] }
thiserror = { workspace = true }
tokio = { workspace = true }
tracing = { workspace = true }
tracing-subscriber = { workspace = true }
unionlabs = { workspace = true }
voyager-message = { workspace = true }
voyager-vm = { workspace = true }
Loading
Loading