Skip to content

Commit 4994adf

Browse files
authored
Unionlabs split tendermint (#3128)
- split tendermint light client types into their own crate - split berachain light client types into their own crate (i would do this in a separate PR but the berachain light client depends on the tendermint types, if this wasn't also split out it would result in a circular dependency)
2 parents 42027a6 + ce9ec46 commit 4994adf

File tree

49 files changed

+857
-776
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+857
-776
lines changed

Cargo.lock

+33
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+7-2
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ members = [
5959
"light-clients/arbitrum-light-client",
6060

6161
"light-clients/berachain-light-client",
62+
"light-clients/berachain-light-client/types",
6263

6364
"light-clients/cometbls-light-client",
6465
"light-clients/cometbls-light-client/types",
@@ -70,6 +71,7 @@ members = [
7071
"light-clients/scroll-light-client",
7172

7273
"light-clients/tendermint-light-client",
74+
"light-clients/tendermint-light-client/types",
7375

7476
"light-clients/linea-light-client",
7577

@@ -163,8 +165,11 @@ scroll-codec = { path = "lib/scroll-codec", default-features = false }
163165
scroll-rpc = { path = "lib/scroll-rpc", default-features = false }
164166
scroll-verifier = { path = "lib/scroll-verifier", default-features = false }
165167

166-
tendermint-light-client = { path = "light-clients/tendermint-light-client", default-features = false }
167-
tendermint-verifier = { path = "lib/tendermint-verifier", default-features = false }
168+
berachain-light-client-types = { path = "light-clients/berachain-light-client/types", default-features = false }
169+
170+
tendermint-light-client = { path = "light-clients/tendermint-light-client", default-features = false }
171+
tendermint-light-client-types = { path = "light-clients/tendermint-light-client/types", default-features = false }
172+
tendermint-verifier = { path = "lib/tendermint-verifier", default-features = false }
168173

169174
linea-verifier = { path = "lib/linea-verifier", default-features = false }
170175
linea-zktrie = { path = "lib/linea-zktrie", default-features = false }

hubble/Cargo.toml

+46-44
Original file line numberDiff line numberDiff line change
@@ -18,50 +18,52 @@ name = "hubble"
1818
path = "src/main.rs"
1919

2020
[dependencies]
21-
alloy = { workspace = true, features = ["eips", "rpc", "rpc-types", "serde", "transports", "transport-http", "providers", "reqwest"] }
22-
aptos-crypto = { workspace = true }
23-
aptos-move-ibc = { workspace = true }
24-
aptos-rest-client = { workspace = true }
25-
aptos-types = { workspace = true }
26-
async-trait = "0.1.82"
27-
axum = { workspace = true, features = ["macros", "tokio"] }
28-
backon = "0.4.4"
29-
base64 = { workspace = true }
30-
chain-utils = { workspace = true }
31-
chrono = { workspace = true, features = ["clock"] }
32-
clap = { workspace = true, features = ["derive", "env", "error-context"] }
33-
color-eyre = { workspace = true, features = ["default"] }
34-
cometbft-rpc = { workspace = true }
35-
cometbls-light-client-types = { workspace = true, features = ["proto", "ethabi"] }
36-
const-hex = "1.12.0"
37-
contracts = { workspace = true }
38-
futures = { workspace = true, features = ["async-await"] }
39-
hex = { workspace = true }
40-
itertools = "0.13.0"
41-
lazy_static = { workspace = true }
42-
num-traits = "0.2.19"
43-
prometheus = { version = "0.13.3", features = ["process"] }
44-
prost = { workspace = true }
45-
protos = { workspace = true, features = ["client"] }
46-
regex = "1.10.5"
47-
reqwest = { workspace = true, features = ["json", "blocking"] }
48-
scroll-api = { workspace = true }
49-
serde = { workspace = true, features = ["derive"] }
50-
serde-aux = "4.5.0"
51-
serde_json = { workspace = true }
52-
sqlx = { workspace = true, features = ["postgres", "runtime-tokio", "tls-rustls", "time", "macros", "json", "bigdecimal"] }
53-
tendermint = { workspace = true, features = ["std"] }
54-
tendermint-rpc = { workspace = true, features = ["http-client", "tokio"] }
55-
thiserror = { workspace = true }
56-
time = { workspace = true, features = ["serde"] }
57-
tokio = { workspace = true, features = ["full"] }
58-
tonic = { workspace = true, features = ["transport", "tls", "tls-roots", "tls-webpki-roots"] }
59-
tracing = { workspace = true }
60-
tracing-error = { version = "0.2.0" }
61-
tracing-subscriber = { workspace = true, features = ["env-filter", "json", "tracing-log"] }
62-
unionlabs = { workspace = true, features = ["ethabi"] }
63-
url = { version = "2.4.1", features = ["serde"] }
64-
valuable = { version = "0.1.0", features = ["derive"] }
21+
alloy = { workspace = true, features = ["eips", "rpc", "rpc-types", "serde", "transports", "transport-http", "providers", "reqwest"] }
22+
aptos-crypto = { workspace = true }
23+
aptos-move-ibc = { workspace = true }
24+
aptos-rest-client = { workspace = true }
25+
aptos-types = { workspace = true }
26+
async-trait = "0.1.82"
27+
axum = { workspace = true, features = ["macros", "tokio"] }
28+
backon = "0.4.4"
29+
base64 = { workspace = true }
30+
berachain-light-client-types = { workspace = true, features = ["proto"] }
31+
chain-utils = { workspace = true }
32+
chrono = { workspace = true, features = ["clock"] }
33+
clap = { workspace = true, features = ["derive", "env", "error-context"] }
34+
color-eyre = { workspace = true, features = ["default"] }
35+
cometbft-rpc = { workspace = true }
36+
cometbls-light-client-types = { workspace = true, features = ["proto", "ethabi"] }
37+
const-hex = "1.12.0"
38+
contracts = { workspace = true }
39+
futures = { workspace = true, features = ["async-await"] }
40+
hex = { workspace = true }
41+
itertools = "0.13.0"
42+
lazy_static = { workspace = true }
43+
num-traits = "0.2.19"
44+
prometheus = { version = "0.13.3", features = ["process"] }
45+
prost = { workspace = true }
46+
protos = { workspace = true, features = ["client"] }
47+
regex = "1.10.5"
48+
reqwest = { workspace = true, features = ["json", "blocking"] }
49+
scroll-api = { workspace = true }
50+
serde = { workspace = true, features = ["derive"] }
51+
serde-aux = "4.5.0"
52+
serde_json = { workspace = true }
53+
sqlx = { workspace = true, features = ["postgres", "runtime-tokio", "tls-rustls", "time", "macros", "json", "bigdecimal"] }
54+
tendermint = { workspace = true, features = ["std"] }
55+
tendermint-light-client-types = { workspace = true, features = ["proto"] }
56+
tendermint-rpc = { workspace = true, features = ["http-client", "tokio"] }
57+
thiserror = { workspace = true }
58+
time = { workspace = true, features = ["serde"] }
59+
tokio = { workspace = true, features = ["full"] }
60+
tonic = { workspace = true, features = ["transport", "tls", "tls-roots", "tls-webpki-roots"] }
61+
tracing = { workspace = true }
62+
tracing-error = { version = "0.2.0" }
63+
tracing-subscriber = { workspace = true, features = ["env-filter", "json", "tracing-log"] }
64+
unionlabs = { workspace = true, features = ["ethabi"] }
65+
url = { version = "2.4.1", features = ["serde"] }
66+
valuable = { version = "0.1.0", features = ["derive"] }
6567

6668
[target.'cfg(not(target_env = "msvc"))'.dependencies]
6769
tikv-jemallocator = "0.5"

hubble/src/indexer/tm/create_client_tracker.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ pub fn schedule_create_client_checker(
100100
cs.chain_id.as_str().to_owned()
101101
}
102102
WasmClientType::Tendermint => {
103-
let cs = match unionlabs::ibc::lightclients::tendermint::client_state::ClientState::decode_as::<Proto>(&cs.data) {
103+
let cs = match tendermint_light_client_types::client_state::ClientState::decode_as::<Proto>(&cs.data) {
104104
Ok(cs) => cs,
105105
Err(err) => {
106106
warn!("error while decoding client {client_id}: {:?}. Most likely due to a client state upgrade. This can then be safely ignored", err);
@@ -134,7 +134,7 @@ pub fn schedule_create_client_checker(
134134
}
135135
WasmClientType::Linea => todo!("We still need to add linea"),
136136
WasmClientType::Berachain => {
137-
let cs = match unionlabs::ibc::lightclients::berachain::client_state::ClientState::decode_as::<Proto>(&cs.data) {
137+
let cs = match berachain_light_client_types::client_state::ClientState::decode_as::<Proto>(&cs.data) {
138138
Ok(cs) => cs,
139139
// We changed the format of berachain client states, but union-testnet-8 still contains an old configuration which we need to ignore.
140140
Err(err) => {

lib/chain-utils/Cargo.toml

+29-27
Original file line numberDiff line numberDiff line change
@@ -14,33 +14,35 @@ protos = { workspace = true, features = ["default", "client"] }
1414
serde-utils = { workspace = true }
1515
unionlabs = { workspace = true, features = ["default"] }
1616

17-
bip32 = { workspace = true, features = ["secp256k1"] }
18-
chrono = { workspace = true, features = ["alloc"] }
19-
cometbft-rpc = { workspace = true }
20-
crossbeam-queue = { workspace = true, features = ["std"] }
21-
dashmap = { workspace = true }
22-
enumorph = { workspace = true }
23-
ethers = { workspace = true, features = ["rustls", "ws"] }
24-
frame-support-procedural = { workspace = true }
25-
futures = { workspace = true }
26-
hex = { workspace = true }
27-
ics23 = { workspace = true }
28-
num-rational = "0.4.2"
29-
num_enum = "0.7.0"
30-
prost = { workspace = true }
31-
rand = "0.8.5"
32-
reqwest = { workspace = true }
33-
scroll-api = { workspace = true }
34-
scroll-rpc = { workspace = true }
35-
serde = { workspace = true, features = ["derive"] }
36-
serde_json = { workspace = true }
37-
sha2 = { workspace = true }
38-
tendermint-rpc = { workspace = true, features = ["http-client", "websocket-client", "default"] }
39-
thiserror = { workspace = true }
40-
tokio = { workspace = true }
41-
tonic = { workspace = true, features = ["transport", "tls", "tls-roots", "tls-webpki-roots"] }
42-
tracing = { workspace = true }
43-
typenum = { workspace = true, features = ["const-generics", "no_std"] }
17+
berachain-light-client-types.workspace = true
18+
bip32 = { workspace = true, features = ["secp256k1"] }
19+
chrono = { workspace = true, features = ["alloc"] }
20+
cometbft-rpc = { workspace = true }
21+
crossbeam-queue = { workspace = true, features = ["std"] }
22+
dashmap = { workspace = true }
23+
enumorph = { workspace = true }
24+
ethers = { workspace = true, features = ["rustls", "ws"] }
25+
frame-support-procedural = { workspace = true }
26+
futures = { workspace = true }
27+
hex = { workspace = true }
28+
ics23 = { workspace = true }
29+
num-rational = "0.4.2"
30+
num_enum = "0.7.0"
31+
prost = { workspace = true }
32+
rand = "0.8.5"
33+
reqwest = { workspace = true }
34+
scroll-api = { workspace = true }
35+
scroll-rpc = { workspace = true }
36+
serde = { workspace = true, features = ["derive"] }
37+
serde_json = { workspace = true }
38+
sha2 = { workspace = true }
39+
tendermint-light-client-types.workspace = true
40+
tendermint-rpc = { workspace = true, features = ["http-client", "websocket-client", "default"] }
41+
thiserror = { workspace = true }
42+
tokio = { workspace = true }
43+
tonic = { workspace = true, features = ["transport", "tls", "tls-roots", "tls-webpki-roots"] }
44+
tracing = { workspace = true }
45+
typenum = { workspace = true, features = ["const-generics", "no_std"] }
4446

4547
[features]
4648

lib/chain-utils/src/berachain.rs

+9-14
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@ use std::{
33
sync::Arc,
44
};
55

6+
use berachain_light_client_types::{ClientState, ConsensusState};
67
use cometbft_rpc::types::AbciQueryResponse;
78
use contracts::ibc_handler::IBCHandler;
89
use ethers::providers::{Middleware, Provider, ProviderError, Ws, WsClientError};
910
use ics23::ibc_api::SDK_SPECS;
1011
use serde::{Deserialize, Serialize};
12+
use tendermint_light_client_types::Fraction;
1113
use unionlabs::{
1214
berachain::{
1315
BerachainChainSpec, LATEST_BEACON_BLOCK_HEADER_PREFIX,
@@ -19,13 +21,9 @@ use unionlabs::{
1921
hash::H160,
2022
ibc::{
2123
core::client::height::Height,
22-
lightclients::{
23-
berachain,
24-
ethereum::{
25-
beacon_block_header::BeaconBlockHeader,
26-
execution_payload_header::ExecutionPayloadHeader, storage_proof::StorageProof,
27-
},
28-
tendermint::fraction::Fraction,
24+
lightclients::ethereum::{
25+
beacon_block_header::BeaconBlockHeader,
26+
execution_payload_header::ExecutionPayloadHeader, storage_proof::StorageProof,
2927
},
3028
},
3129
option_unwrap, result_unwrap,
@@ -135,7 +133,7 @@ impl Berachain {
135133
.unwrap())
136134
}
137135

138-
async fn self_client_state(&self, height: Height) -> berachain::client_state::ClientState {
136+
async fn self_client_state(&self, height: Height) -> ClientState {
139137
let commit = self
140138
.tm_client
141139
.commit(Some(height.revision_height.try_into().unwrap()))
@@ -148,7 +146,7 @@ impl Berachain {
148146
// 1/4 eth mainnet's ~28hrs
149147
const UNBONDING_PERIOD: i64 = 60 * 60 * 7;
150148

151-
berachain::client_state::ClientState {
149+
ClientState {
152150
consensus_chain_id: self.consensus_chain_id.clone(),
153151
execution_chain_id: self.execution_chain_id,
154152
// https://github.com/cometbft/cometbft/blob/da0e55604b075bac9e1d5866cb2e62eaae386dd9/light/verifier.go#L16
@@ -172,10 +170,7 @@ impl Berachain {
172170
}
173171
}
174172

175-
async fn self_consensus_state(
176-
&self,
177-
height: Height,
178-
) -> berachain::consensus_state::ConsensusState {
173+
async fn self_consensus_state(&self, height: Height) -> ConsensusState {
179174
let execution_header = self
180175
.execution_header_at_beacon_slot(height.revision_height)
181176
.await;
@@ -186,7 +181,7 @@ impl Berachain {
186181
.await
187182
.unwrap();
188183

189-
berachain::consensus_state::ConsensusState {
184+
ConsensusState {
190185
eth_timestamp: execution_header.timestamp,
191186
comet_timestamp: commit.signed_header.header.time,
192187
eth_storage_root: self

0 commit comments

Comments
 (0)