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

penumbra-ibc: rename ibc relay actions #3284

Merged
merged 7 commits into from
Nov 13, 2023
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 crates/bin/pcli/src/command/view/tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ impl TxCmd {
penumbra_transaction::ActionView::ValidatorDefinition(_) => {
["Upload Validator Definition".to_string(), "".to_string()]
}
penumbra_transaction::ActionView::IbcAction(_) => {
penumbra_transaction::ActionView::IbcRelay(_) => {
["IBC Action".to_string(), "".to_string()]
}
penumbra_transaction::ActionView::ProposalSubmit(prop_submit) => [
Expand Down
6 changes: 3 additions & 3 deletions crates/bin/pclientd/tests/network_integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use penumbra_asset::{asset, Value, STAKING_TOKEN_ASSET_ID};
use penumbra_chain::test_keys;
use penumbra_custody::soft_kms;
use penumbra_proto::{
core::{component::fee::v1alpha1::Fee, component::ibc::v1alpha1::IbcAction},
core::{component::fee::v1alpha1::Fee, component::ibc::v1alpha1::IbcRelay},
custody::v1alpha1::{
custody_protocol_service_client::CustodyProtocolServiceClient, AuthorizeRequest,
},
Expand Down Expand Up @@ -109,7 +109,7 @@ async fn transaction_send_flow() -> anyhow::Result<()> {
use ibc_types::DomainType;
let msg_create_stargaze_client =
MsgCreateClient::decode(msg_create_client_stargaze_raw.as_slice()).unwrap();
let create_client_action: IbcAction = msg_create_stargaze_client.into();
let create_client_action: IbcRelay = msg_create_stargaze_client.into();

// 5.1. Generate a transaction plan sending funds to an address.
let plan = view_client
Expand All @@ -124,7 +124,7 @@ async fn transaction_send_flow() -> anyhow::Result<()> {
.into(),
),
}],
ibc_actions: vec![create_client_action],
ibc_relay_actions: vec![create_client_action],
..Default::default()
})
.await?
Expand Down
6 changes: 3 additions & 3 deletions crates/core/app/src/action_handler/actions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl ActionHandler for Action {
Action::ProposalDepositClaim(action) => action.check_stateless(()).await,
Action::Swap(action) => action.check_stateless(()).await,
Action::Output(action) => action.check_stateless(()).await,
Action::IbcAction(action) => {
Action::IbcRelay(action) => {
action
.clone()
.with_handler::<Ics20Transfer>()
Expand Down Expand Up @@ -71,7 +71,7 @@ impl ActionHandler for Action {
Action::SwapClaim(action) => action.check_stateful(state).await,
Action::Spend(action) => action.check_stateful(state).await,
Action::Output(action) => action.check_stateful(state).await,
Action::IbcAction(action) => {
Action::IbcRelay(action) => {
if !state.get_ibc_params().await?.ibc_enabled {
anyhow::bail!("transaction contains IBC actions, but IBC is not enabled");
}
Expand Down Expand Up @@ -108,7 +108,7 @@ impl ActionHandler for Action {
Action::SwapClaim(action) => action.execute(state).await,
Action::Spend(action) => action.execute(state).await,
Action::Output(action) => action.execute(state).await,
Action::IbcAction(action) => {
Action::IbcRelay(action) => {
action
.clone()
.with_handler::<Ics20Transfer>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use penumbra_storage::{StateRead, StateWrite};

use crate::{
component::{app_handler::AppHandler, MsgHandler as _},
IbcAction, IbcActionWithHandler,
IbcActionWithHandler, IbcRelay,
};

#[async_trait]
Expand All @@ -16,24 +16,24 @@ impl<H: AppHandler> ActionHandler for IbcActionWithHandler<H> {
async fn check_stateless(&self, _context: ()) -> Result<()> {
let action = self.action();
match action {
IbcAction::CreateClient(msg) => msg.check_stateless::<H>().await?,
IbcAction::UpdateClient(msg) => msg.check_stateless::<H>().await?,
IbcAction::UpgradeClient(msg) => msg.check_stateless::<H>().await?,
IbcAction::SubmitMisbehavior(msg) => msg.check_stateless::<H>().await?,
IbcAction::ConnectionOpenInit(msg) => msg.check_stateless::<H>().await?,
IbcAction::ConnectionOpenTry(msg) => msg.check_stateless::<H>().await?,
IbcAction::ConnectionOpenAck(msg) => msg.check_stateless::<H>().await?,
IbcAction::ConnectionOpenConfirm(msg) => msg.check_stateless::<H>().await?,
IbcAction::ChannelOpenInit(msg) => msg.check_stateless::<H>().await?,
IbcAction::ChannelOpenTry(msg) => msg.check_stateless::<H>().await?,
IbcAction::ChannelOpenAck(msg) => msg.check_stateless::<H>().await?,
IbcAction::ChannelOpenConfirm(msg) => msg.check_stateless::<H>().await?,
IbcAction::ChannelCloseInit(msg) => msg.check_stateless::<H>().await?,
IbcAction::ChannelCloseConfirm(msg) => msg.check_stateless::<H>().await?,
IbcAction::RecvPacket(msg) => msg.check_stateless::<H>().await?,
IbcAction::Acknowledgement(msg) => msg.check_stateless::<H>().await?,
IbcAction::Timeout(msg) => msg.check_stateless::<H>().await?,
IbcAction::Unknown(msg) => {
IbcRelay::CreateClient(msg) => msg.check_stateless::<H>().await?,
IbcRelay::UpdateClient(msg) => msg.check_stateless::<H>().await?,
IbcRelay::UpgradeClient(msg) => msg.check_stateless::<H>().await?,
IbcRelay::SubmitMisbehavior(msg) => msg.check_stateless::<H>().await?,
IbcRelay::ConnectionOpenInit(msg) => msg.check_stateless::<H>().await?,
IbcRelay::ConnectionOpenTry(msg) => msg.check_stateless::<H>().await?,
IbcRelay::ConnectionOpenAck(msg) => msg.check_stateless::<H>().await?,
IbcRelay::ConnectionOpenConfirm(msg) => msg.check_stateless::<H>().await?,
IbcRelay::ChannelOpenInit(msg) => msg.check_stateless::<H>().await?,
IbcRelay::ChannelOpenTry(msg) => msg.check_stateless::<H>().await?,
IbcRelay::ChannelOpenAck(msg) => msg.check_stateless::<H>().await?,
IbcRelay::ChannelOpenConfirm(msg) => msg.check_stateless::<H>().await?,
IbcRelay::ChannelCloseInit(msg) => msg.check_stateless::<H>().await?,
IbcRelay::ChannelCloseConfirm(msg) => msg.check_stateless::<H>().await?,
IbcRelay::RecvPacket(msg) => msg.check_stateless::<H>().await?,
IbcRelay::Acknowledgement(msg) => msg.check_stateless::<H>().await?,
IbcRelay::Timeout(msg) => msg.check_stateless::<H>().await?,
IbcRelay::Unknown(msg) => {
anyhow::bail!("unknown IBC message type: {}", msg.type_url)
}
}
Expand All @@ -49,75 +49,75 @@ impl<H: AppHandler> ActionHandler for IbcActionWithHandler<H> {
async fn execute<S: StateWrite>(&self, state: S) -> Result<()> {
let action = self.action();
match action {
IbcAction::CreateClient(msg) => msg
IbcRelay::CreateClient(msg) => msg
.try_execute::<S, H>(state)
.await
.context("failed to execute MsgCreateClient")?,
IbcAction::UpdateClient(msg) => msg
IbcRelay::UpdateClient(msg) => msg
.try_execute::<S, H>(state)
.await
.context("failed to execute MsgUpdateClient")?,
IbcAction::UpgradeClient(msg) => msg
IbcRelay::UpgradeClient(msg) => msg
.try_execute::<S, H>(state)
.await
.context("failed to execute MsgUpgradeClient")?,
IbcAction::SubmitMisbehavior(msg) => msg
IbcRelay::SubmitMisbehavior(msg) => msg
.try_execute::<S, H>(state)
.await
.context("failed to execute MsgSubmitMisbehaviour")?,
IbcAction::ConnectionOpenInit(msg) => msg
IbcRelay::ConnectionOpenInit(msg) => msg
.try_execute::<S, H>(state)
.await
.context("failed to execute MsgConnectionOpenInit")?,
IbcAction::ConnectionOpenTry(msg) => msg
IbcRelay::ConnectionOpenTry(msg) => msg
.try_execute::<S, H>(state)
.await
.context("failed to execute MsgConnectionOpenTry")?,
IbcAction::ConnectionOpenAck(msg) => msg
IbcRelay::ConnectionOpenAck(msg) => msg
.try_execute::<S, H>(state)
.await
.context("failed to execute MsgConnectionOpenAck")?,
IbcAction::ConnectionOpenConfirm(msg) => msg
IbcRelay::ConnectionOpenConfirm(msg) => msg
.try_execute::<S, H>(state)
.await
.context("failed to execute MsgConnectionOpenConfirm")?,
IbcAction::ChannelOpenInit(msg) => msg
IbcRelay::ChannelOpenInit(msg) => msg
.try_execute::<S, H>(state)
.await
.context("failed to execute MsgChannelOpenInit")?,
IbcAction::ChannelOpenTry(msg) => msg
IbcRelay::ChannelOpenTry(msg) => msg
.try_execute::<S, H>(state)
.await
.context("failed to execute MsgChannelOpenTry")?,
IbcAction::ChannelOpenAck(msg) => msg
IbcRelay::ChannelOpenAck(msg) => msg
.try_execute::<S, H>(state)
.await
.context("failed to execute MsgChannelOpenAck")?,
IbcAction::ChannelOpenConfirm(msg) => msg
IbcRelay::ChannelOpenConfirm(msg) => msg
.try_execute::<S, H>(state)
.await
.context("failed to execute MsgChannelOpenConfirm")?,
IbcAction::ChannelCloseInit(msg) => msg
IbcRelay::ChannelCloseInit(msg) => msg
.try_execute::<S, H>(state)
.await
.context("failed to execute MsgChannelCloseInit")?,
IbcAction::ChannelCloseConfirm(msg) => msg
IbcRelay::ChannelCloseConfirm(msg) => msg
.try_execute::<S, H>(state)
.await
.context("failed to execute MsgChannelCloseConfirm")?,
IbcAction::RecvPacket(msg) => msg
IbcRelay::RecvPacket(msg) => msg
.try_execute::<S, H>(state)
.await
.context("failed to execute MsgRecvPacket")?,
IbcAction::Acknowledgement(msg) => msg
IbcRelay::Acknowledgement(msg) => msg
.try_execute::<S, H>(state)
.await
.context("failed to execute MsgAcknowledgement")?,
IbcAction::Timeout(msg) => msg
IbcRelay::Timeout(msg) => msg
.try_execute::<S, H>(state)
.await
.context("failed to execute MsgTimeout")?,
IbcAction::Unknown(msg) => {
IbcRelay::Unknown(msg) => {
anyhow::bail!("unknown IBC message type: {}", msg.type_url)
}
}
Expand Down
8 changes: 4 additions & 4 deletions crates/core/component/ibc/src/component/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ mod tests {
use tendermint::Time;

use crate::component::ibc_action_with_handler::IbcActionWithHandler;
use crate::IbcAction;
use crate::IbcRelay;

use crate::component::app_handler::{AppHandler, AppHandlerCheck, AppHandlerExecute};
use ibc_types::core::channel::msgs::{
Expand Down Expand Up @@ -516,10 +516,10 @@ mod tests {
msg_update_stargaze_client.client_id = ClientId::from_str("07-tendermint-0").unwrap();

let create_client_action = IbcActionWithHandler::<MockAppHandler>::new(
IbcAction::CreateClient(msg_create_stargaze_client),
IbcRelay::CreateClient(msg_create_stargaze_client),
);
let update_client_action = IbcActionWithHandler::<MockAppHandler>::new(
IbcAction::UpdateClient(msg_update_stargaze_client),
IbcRelay::UpdateClient(msg_update_stargaze_client),
);

create_client_action.check_stateless(()).await?;
Expand All @@ -546,7 +546,7 @@ mod tests {
let mut second_update = MsgUpdateClient::decode(msg_update_second.as_slice()).unwrap();
second_update.client_id = ClientId::from_str("07-tendermint-0").unwrap();
let second_update_client_action =
IbcActionWithHandler::<MockAppHandler>::new(IbcAction::UpdateClient(second_update));
IbcActionWithHandler::<MockAppHandler>::new(IbcRelay::UpdateClient(second_update));

second_update_client_action.check_stateless(()).await?;
second_update_client_action
Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
use crate::component::app_handler::AppHandler;
use crate::IbcAction;
use crate::IbcRelay;
use std::marker::PhantomData;

pub struct IbcActionWithHandler<H>(IbcAction, PhantomData<H>);
pub struct IbcActionWithHandler<H>(IbcRelay, PhantomData<H>);

impl<H: AppHandler> IbcActionWithHandler<H> {
pub fn new(action: IbcAction) -> Self {
pub fn new(action: IbcRelay) -> Self {
Self(action, PhantomData)
}

pub fn action(&self) -> &IbcAction {
pub fn action(&self) -> &IbcRelay {
&self.0
}

pub fn into_inner(self) -> IbcAction {
pub fn into_inner(self) -> IbcRelay {
self.0
}
}

impl<H: AppHandler> From<IbcActionWithHandler<H>> for IbcAction {
impl<H: AppHandler> From<IbcActionWithHandler<H>> for IbcRelay {
fn from(value: IbcActionWithHandler<H>) -> Self {
value.0
}
}

impl IbcAction {
impl IbcRelay {
pub fn with_handler<H: AppHandler>(self) -> IbcActionWithHandler<H> {
IbcActionWithHandler::new(self)
}
Expand Down
Loading
Loading