Skip to content
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
2 changes: 1 addition & 1 deletion Cargo.lock

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

Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ use crate::{

#[derive(Clone, Debug, PartialEq, Encode, Decode, TreeHash, Serialize, Deserialize)]
#[serde(bound(serialize = "", deserialize = ""))]
// REVIEW: Do we want to use primitive_types here?
pub struct ExecutionPayloadHeader<C: BYTES_PER_LOGS_BLOOM + MAX_EXTRA_DATA_BYTES> {
pub parent_hash: H256,
pub fee_recipient: Address,
Expand Down Expand Up @@ -128,7 +127,6 @@ impl<C: BYTES_PER_LOGS_BLOOM + MAX_EXTRA_DATA_BYTES>
.extra_data
.try_into()
.map_err(TryFromExecutionPayloadHeaderError::ExtraData)?,
// .into_iter().rev().collect::<Vec<_>>()
base_fee_per_gas: U256::from_little_endian(
&<[u8; 32]>::try_from(value.base_fee_per_gas)
.map_err(TryFromExecutionPayloadHeaderError::BaseFeePerGas)?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub struct LightClientUpdate<C: SYNC_COMMITTEE_SIZE + BYTES_PER_LOGS_BLOOM + MAX
pub attested_header: LightClientHeader<C>,
/// Next sync committee corresponding to `attested_header.state_root`
// TODO: Merge these fields into one
#[serde(default = "Option::default")]
#[serde(default)]
pub next_sync_committee: Option<SyncCommittee<C>>,
#[serde(default)]
pub next_sync_committee_branch: Option<NextSyncCommitteeBranch>,
Expand Down
6 changes: 3 additions & 3 deletions voyager/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ pub enum AnyLightClient {

/// The IBC interface on a [`Chain`] that knows how to connect to a counterparty.
pub trait LightClient: Send + Sync + Sized {
type UpdateClientMessage;

/// The chain that this light client is on.
type HostChain: Chain;

Expand All @@ -94,7 +92,7 @@ pub trait LightClient: Send + Sync + Sized {
fn update_client(
&self,
client_id: String,
_: Self::UpdateClientMessage,
header: HeaderOf<Self::CounterpartyChain>,
) -> impl Future<Output = (Height, UpdateClient)> + '_;

// TODO: Use state_proof instead
Expand All @@ -108,12 +106,14 @@ pub trait LightClient: Send + Sync + Sized {

pub type ClientStateOf<C> = <C as Chain>::SelfClientState;
pub type ConsensusStateOf<C> = <C as Chain>::SelfConsensusState;
pub type HeaderOf<C> = <C as Chain>::Header;

/// Represents a block chain. One [`Chain`] may have many related [`LightClient`]s for connecting to
/// various other [`Chain`]s, all sharing a common config.
pub trait Chain {
type SelfClientState: ClientState + Debug + Serialize;
type SelfConsensusState: Debug + Serialize;
type Header;

fn chain_id(&self) -> impl Future<Output = String> + '_;

Expand Down
10 changes: 5 additions & 5 deletions voyager/src/chain/cosmos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ use unionlabs::{
},
},
google::protobuf::{any::Any, duration::Duration, timestamp::Timestamp},
lightclients::{cometbls, ethereum, tendermint::fraction::Fraction, wasm},
lightclients::{cometbls, tendermint::fraction::Fraction, wasm},
},
tendermint::{
abci::{event::Event, event_attribute::EventAttribute},
Expand All @@ -73,7 +73,7 @@ use crate::{
ChannelEndPath, ClientConsensusStatePath, ClientStatePath, CommitmentPath,
ConnectionPath, IbcPath, StateProof,
},
Chain, ChainConnection, ClientStateOf, Connect, ConsensusStateOf, CreateClient,
Chain, ChainConnection, ClientStateOf, Connect, ConsensusStateOf, CreateClient, HeaderOf,
IbcStateRead, LightClient,
},
config::UnionChainConfig,
Expand Down Expand Up @@ -306,6 +306,8 @@ impl Chain for Union {
type SelfConsensusState =
Any<wasm::consensus_state::ConsensusState<cometbls::consensus_state::ConsensusState>>;

type Header = cometbls::header::Header;

fn chain_id(&self) -> impl Future<Output = String> + '_ {
async move { self.chain_id.clone() }
}
Expand Down Expand Up @@ -582,8 +584,6 @@ impl Chain for Union {
}

impl<C: ChainSpec> LightClient for Ethereum<C> {
type UpdateClientMessage = wasm::header::Header<ethereum::header::Header<C>>;

type HostChain = Union;

type CounterpartyChain = Evm<C>;
Expand All @@ -597,7 +597,7 @@ impl<C: ChainSpec> LightClient for Ethereum<C> {
fn update_client(
&self,
client_id: String,
msg: Self::UpdateClientMessage,
msg: HeaderOf<Self::CounterpartyChain>,
) -> impl Future<Output = (Height, UpdateClient)> + '_ {
self.send_msg_and_read_event(MsgUpdateClient {
client_id,
Expand Down
9 changes: 4 additions & 5 deletions voyager/src/chain/evm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ use unionlabs::{
},
google::protobuf::any::Any,
lightclients::{
cometbls,
ethereum::{
self,
account_update::AccountUpdate,
Expand All @@ -86,7 +85,7 @@ use crate::{
ChannelEndPath, ClientConsensusStatePath, ClientStatePath, CommitmentPath,
ConnectionPath, IbcPath,
},
Chain, ChainConnection, ClientStateOf, Connect, ConsensusStateOf, CreateClient,
Chain, ChainConnection, ClientStateOf, Connect, ConsensusStateOf, CreateClient, HeaderOf,
IbcStateRead, LightClient, StateProof,
},
config::EvmChainConfigFields,
Expand Down Expand Up @@ -386,6 +385,8 @@ impl<C: ChainSpec> Chain for Evm<C> {
type SelfConsensusState =
Any<wasm::consensus_state::ConsensusState<ethereum::consensus_state::ConsensusState>>;

type Header = wasm::header::Header<ethereum::header::Header<C>>;

fn chain_id(&self) -> impl Future<Output = String> + '_ {
// TODO: Cache this in `self`, it only needs to be fetched once
async move { self.provider.get_chainid().await.unwrap().to_string() }
Expand Down Expand Up @@ -652,8 +653,6 @@ impl<C: ChainSpec> CreateClient<Cometbls<C>> for Evm<C> {
}

impl<C: ChainSpec> LightClient for Cometbls<C> {
type UpdateClientMessage = cometbls::header::Header;

type HostChain = Evm<C>;

type CounterpartyChain = Union;
Expand All @@ -667,7 +666,7 @@ impl<C: ChainSpec> LightClient for Cometbls<C> {
fn update_client(
&self,
client_id: String,
msg: Self::UpdateClientMessage,
msg: HeaderOf<Self::CounterpartyChain>,
) -> impl Future<Output = (Height, UpdateClient)> + '_ {
async move {
let tx_rcp = self
Expand Down