Skip to content

Commit

Permalink
fix: errors after removing unused protos
Browse files Browse the repository at this point in the history
  • Loading branch information
benluelo committed Jan 8, 2025
1 parent c2c22d1 commit d425e28
Show file tree
Hide file tree
Showing 8 changed files with 6 additions and 184 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

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

1 change: 0 additions & 1 deletion generated/rust/protos/Cargo.toml

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

2 changes: 0 additions & 2 deletions lib/berachain-light-client-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ alloy = { workspace = true, features = ["sol-types"], opti
beacon-api-types = { workspace = true }
bincode = { workspace = true, features = ["alloc", "derive"], optional = true }
ethereum-light-client-types = { workspace = true }
protos = { workspace = true, optional = true, features = ["union+ibc+lightclients+berachain+v1"] }
serde = { workspace = true, optional = true, features = ["derive"] }
unionlabs = { workspace = true }

Expand All @@ -22,5 +21,4 @@ bincode = [
"beacon-api-types/bincode",
]
ethabi = ["unionlabs/ethabi", "dep:alloy"]
proto = ["dep:protos"]
serde = ["beacon-api-types/serde", "ethereum-light-client-types/serde", "dep:serde"]
46 changes: 2 additions & 44 deletions lib/unionlabs/src/aptos/signature.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
use macros::model;
use unionlabs_primitives::{FixedBytesError, H768};
use unionlabs_primitives::H768;

#[model(proto(
raw(protos::union::ibc::lightclients::movement::v1::AggregateSignature),
into,
from
))]
#[model]
#[cfg_attr(feature = "bincode", derive(bincode::Encode, bincode::Decode))]
pub struct AggregateSignature {
pub validator_bitmask: ValidatorBitmask,
Expand All @@ -17,41 +13,3 @@ pub struct AggregateSignature {
pub struct ValidatorBitmask {
pub inner: Vec<u8>,
}

impl From<AggregateSignature>
for protos::union::ibc::lightclients::movement::v1::AggregateSignature
{
fn from(value: AggregateSignature) -> Self {
Self {
validator_bitmask: value.validator_bitmask.inner,
sig: value.sig.map(Into::into).unwrap_or_default(),
}
}
}

#[derive(Debug, Clone, PartialEq, thiserror::Error)]
pub enum TryFromAggregateSignatureError {
#[error("invalid sig")]
Sig(#[from] FixedBytesError),
}

impl TryFrom<protos::union::ibc::lightclients::movement::v1::AggregateSignature>
for AggregateSignature
{
type Error = TryFromAggregateSignatureError;

fn try_from(
value: protos::union::ibc::lightclients::movement::v1::AggregateSignature,
) -> Result<Self, Self::Error> {
Ok(Self {
validator_bitmask: ValidatorBitmask {
inner: value.validator_bitmask,
},
sig: if value.sig.is_empty() {
None
} else {
Some(value.sig.try_into()?)
},
})
}
}
132 changes: 2 additions & 130 deletions lib/unionlabs/src/linea/proof.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
use macros::model;
use serde::{Deserialize, Serialize};

use crate::errors::{required, MissingField};

#[derive(Debug, PartialEq, Clone, thiserror::Error)]
pub enum TryFromMerkleProofError {
#[error(transparent)]
MissingField(#[from] MissingField),
}

#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct MerklePath {
Expand All @@ -18,32 +10,7 @@ pub struct MerklePath {
pub proof_related_nodes: Vec<Vec<u8>>,
}

impl From<MerklePath> for protos::union::ibc::lightclients::linea::v1::MerklePath {
fn from(value: MerklePath) -> Self {
Self {
value: value.value,
proof_related_nodes: value.proof_related_nodes,
}
}
}

impl From<protos::union::ibc::lightclients::linea::v1::MerklePath> for MerklePath {
fn from(value: protos::union::ibc::lightclients::linea::v1::MerklePath) -> Self {
Self {
value: value.value,
proof_related_nodes: value.proof_related_nodes,
}
}
}

#[model(
proto(
raw(protos::union::ibc::lightclients::linea::v1::InclusionProof),
into,
from
),
no_serde
)]
#[model(no_serde)]
#[derive(Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct InclusionProof {
Expand All @@ -53,38 +20,7 @@ pub struct InclusionProof {
pub proof: MerklePath,
}

impl From<InclusionProof> for protos::union::ibc::lightclients::linea::v1::InclusionProof {
fn from(value: InclusionProof) -> Self {
Self {
key: value.key,
leaf_index: value.leaf_index,
merkle_path: Some(value.proof.into()),
}
}
}

impl TryFrom<protos::union::ibc::lightclients::linea::v1::InclusionProof> for InclusionProof {
type Error = TryFromMerkleProofError;

fn try_from(
value: protos::union::ibc::lightclients::linea::v1::InclusionProof,
) -> Result<Self, Self::Error> {
Ok(Self {
key: value.key,
leaf_index: value.leaf_index,
proof: required!(value.merkle_path)?.into(),
})
}
}

#[model(
proto(
raw(protos::union::ibc::lightclients::linea::v1::NonInclusionProof),
into,
from
),
no_serde
)]
#[model(no_serde)]
#[derive(Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct NonInclusionProof {
Expand All @@ -96,77 +32,13 @@ pub struct NonInclusionProof {
pub right_proof: MerklePath,
}

impl From<NonInclusionProof> for protos::union::ibc::lightclients::linea::v1::NonInclusionProof {
fn from(value: NonInclusionProof) -> Self {
Self {
key: value.key,
left_leaf_index: value.left_leaf_index,
left_proof: Some(value.left_proof.into()),
right_leaf_index: value.right_leaf_index,
right_proof: Some(value.right_proof.into()),
}
}
}

impl TryFrom<protos::union::ibc::lightclients::linea::v1::NonInclusionProof> for NonInclusionProof {
type Error = TryFromMerkleProofError;

fn try_from(
value: protos::union::ibc::lightclients::linea::v1::NonInclusionProof,
) -> Result<Self, Self::Error> {
Ok(Self {
key: value.key,
left_leaf_index: value.left_leaf_index,
left_proof: required!(value.left_proof)?.into(),
right_leaf_index: value.right_leaf_index,
right_proof: required!(value.right_proof)?.into(),
})
}
}

#[derive(Clone, PartialEq, Debug, Serialize, Deserialize)]
#[serde(untagged)]
pub enum MerkleProof {
Inclusion(InclusionProof),
NonInclusion(NonInclusionProof),
}

impl From<MerkleProof> for protos::union::ibc::lightclients::linea::v1::MerkleProof {
fn from(value: MerkleProof) -> Self {
Self {
proof: Some(match value {
MerkleProof::Inclusion(inclusion) => {
protos::union::ibc::lightclients::linea::v1::merkle_proof::Proof::Inclusion(
inclusion.into(),
)
}
MerkleProof::NonInclusion(noninclusion) => {
protos::union::ibc::lightclients::linea::v1::merkle_proof::Proof::Noninclusion(
noninclusion.into(),
)
}
}),
}
}
}

impl TryFrom<protos::union::ibc::lightclients::linea::v1::MerkleProof> for MerkleProof {
type Error = TryFromMerkleProofError;

fn try_from(
value: protos::union::ibc::lightclients::linea::v1::MerkleProof,
) -> Result<Self, Self::Error> {
Ok(match required!(value.proof)? {
protos::union::ibc::lightclients::linea::v1::merkle_proof::Proof::Inclusion(
inclusion,
) => MerkleProof::Inclusion(inclusion.try_into()?),
protos::union::ibc::lightclients::linea::v1::merkle_proof::Proof::Noninclusion(
noninclusion,
) => MerkleProof::NonInclusion(noninclusion.try_into()?),
})
}
}

#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct GetProof {
Expand Down
4 changes: 0 additions & 4 deletions tools/rust-proto.nix
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,6 @@ _: {
"prost/std"
"serde/std"
];
eth-abi = [
"ethers"
"std"
];
client = [ "tonic" ];
json-schema = [ "schemars" ];
# nix attrsets don't preserve order, use this to replace with the insertion point (see command below)
Expand Down
2 changes: 1 addition & 1 deletion voyager/modules/consensus/berachain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ 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"] }
berachain-light-client-types = { workspace = true, features = ["serde"] }
cometbft-rpc = { workspace = true }
dashmap = { workspace = true }
enumorph = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion voyager/plugins/client-update/berachain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ 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"] }
berachain-light-client-types = { workspace = true, features = ["serde"] }
cometbft-rpc = { workspace = true }
cometbft-types.workspace = true
dashmap = { workspace = true }
Expand Down

0 comments on commit d425e28

Please sign in to comment.