Skip to content

Commit

Permalink
more skeleton defs
Browse files Browse the repository at this point in the history
  • Loading branch information
TalDerei committed Apr 17, 2024
1 parent d1e2090 commit 77a6a97
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 22 deletions.
16 changes: 9 additions & 7 deletions crates/core/app/src/action_handler/actions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,9 @@ impl AppActionHandler for Action {

async fn check_stateless(&self, context: TransactionContext) -> Result<()> {
match self {
// These actions require a context
Action::SwapClaim(action) => action.check_stateless(context).await,
Action::Spend(action) => action.check_stateless(context).await,
Action::DelegatorVote(action) => action.check_stateless(context).await,
// These actions don't require a context
Action::Delegate(action) => action.check_stateless(()).await,
Action::Undelegate(action) => action.check_stateless(()).await,
Action::UndelegateClaim(action) => action.check_stateless(()).await,
Expand All @@ -50,6 +48,9 @@ impl AppActionHandler for Action {
Action::CommunityPoolSpend(action) => action.check_stateless(()).await,
Action::CommunityPoolOutput(action) => action.check_stateless(()).await,
Action::CommunityPoolDeposit(action) => action.check_stateless(()).await,
Action::ActionDutchAuctionSchedule(_) => todo!(),
Action::ActionDutchAuctionEnd(_) => todo!(),
Action::ActionDutchAuctionWithdraw(_) => todo!(),
}
}

Expand All @@ -72,21 +73,16 @@ impl AppActionHandler for Action {
Action::Spend(action) => action.check_historical(state).await,
Action::Output(action) => action.check_historical(state).await,
Action::IbcRelay(action) => {
// SAFETY: this is safe to check in parallel because IBC enablement cannot
// change during transaction execution.
if !state.get_ibc_params().await?.ibc_enabled {
anyhow::bail!("transaction contains IBC actions, but IBC is not enabled");
}

action
.clone()
.with_handler::<Ics20Transfer, PenumbraHost>()
.check_stateful(state)
.await
}
Action::Ics20Withdrawal(action) => {
// SAFETY: this is safe to check in parallel because IBC enablement cannot
// change during transaction execution.
if !state
.get_ibc_params()
.await?
Expand All @@ -99,6 +95,9 @@ impl AppActionHandler for Action {
Action::CommunityPoolSpend(action) => action.check_historical(state).await,
Action::CommunityPoolOutput(action) => action.check_historical(state).await,
Action::CommunityPoolDeposit(action) => action.check_historical(state).await,
Action::ActionDutchAuctionSchedule(_) => todo!(),
Action::ActionDutchAuctionEnd(_) => todo!(),
Action::ActionDutchAuctionWithdraw(_) => todo!(),
}
}

Expand Down Expand Up @@ -131,6 +130,9 @@ impl AppActionHandler for Action {
Action::CommunityPoolSpend(action) => action.check_and_execute(state).await,
Action::CommunityPoolOutput(action) => action.check_and_execute(state).await,
Action::CommunityPoolDeposit(action) => action.check_and_execute(state).await,
Action::ActionDutchAuctionSchedule(_) => todo!(),
Action::ActionDutchAuctionEnd(_) => todo!(),
Action::ActionDutchAuctionWithdraw(_) => todo!(),
}
}
}
21 changes: 6 additions & 15 deletions crates/core/app/src/action_handler/actions/submit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,21 +99,12 @@ impl AppActionHandler for ProposalSubmit {
match action {
Spend(_) | Output(_) | Swap(_) | SwapClaim(_) | DelegatorVote(_)
| UndelegateClaim(_) => {
// These actions all require proving, so they are banned from Community Pool spend
// proposals to prevent DoS attacks.
anyhow::bail!(
"invalid action in Community Pool spend proposal (would require proving)"
)
anyhow::bail!("invalid action in Community Pool spend proposal (would require proving)")
}
Delegate(_) | Undelegate(_) => {
// Delegation and undelegation is disallowed due to Undelegateclaim requiring proving.
anyhow::bail!(
"invalid action in Community Pool spend proposal (can't claim outputs of undelegation)"
)
anyhow::bail!("invalid action in Community Pool spend proposal (can't claim outputs of undelegation)")
}
ProposalSubmit(_) | ProposalWithdraw(_) | ProposalDepositClaim(_) => {
// These actions manipulate proposals, so they are banned from Community Pool spend
// actions because they could cause recursion.
anyhow::bail!("invalid action in Community Pool spend proposal (not allowed to manipulate proposals from within proposals)")
}
ValidatorDefinition(_)
Expand All @@ -125,10 +116,10 @@ impl AppActionHandler for ProposalSubmit {
| CommunityPoolSpend(_)
| CommunityPoolOutput(_)
| Ics20Withdrawal(_)
| CommunityPoolDeposit(_) => {
// These actions are all valid for Community Pool spend proposals, because they
// don't require proving, so they don't represent a DoS vector.
}
| CommunityPoolDeposit(_) => {}
ActionDutchAuctionSchedule(_) => todo!(),
ActionDutchAuctionEnd(_) => todo!(),
ActionDutchAuctionWithdraw(_) => todo!(),
}
}
}
Expand Down

0 comments on commit 77a6a97

Please sign in to comment.