diff --git a/crates/astria-core/src/generated/astria.protocol.transaction.v1.rs b/crates/astria-core/src/generated/astria.protocol.transaction.v1.rs index 562cec1545..c135968881 100644 --- a/crates/astria-core/src/generated/astria.protocol.transaction.v1.rs +++ b/crates/astria-core/src/generated/astria.protocol.transaction.v1.rs @@ -30,7 +30,7 @@ pub mod action { BridgeTransfer(super::BridgeTransfer), /// IBC user actions are defined on 21-30 #[prost(message, tag = "21")] - Ibc(::penumbra_sdk_proto::core::component::ibc::v1::IbcRelay), + Ibc(::penumbra_proto::core::component::ibc::v1::IbcRelay), #[prost(message, tag = "22")] Ics20Withdrawal(super::Ics20Withdrawal), #[prost(message, tag = "23")] diff --git a/crates/astria-core/src/generated/astria.protocol.transaction.v1alpha1.rs b/crates/astria-core/src/generated/astria.protocol.transaction.v1alpha1.rs index 74e9ac1759..a310970f2b 100644 --- a/crates/astria-core/src/generated/astria.protocol.transaction.v1alpha1.rs +++ b/crates/astria-core/src/generated/astria.protocol.transaction.v1alpha1.rs @@ -28,7 +28,7 @@ pub mod action { BridgeSudoChange(super::BridgeSudoChange), /// IBC user actions are defined on 21-30 #[prost(message, tag = "21")] - Ibc(::penumbra_sdk_proto::core::component::ibc::v1::IbcRelay), + Ibc(::penumbra_proto::core::component::ibc::v1::IbcRelay), #[prost(message, tag = "22")] Ics20Withdrawal(super::Ics20Withdrawal), /// POA sudo actions are defined on 50-60 diff --git a/crates/astria-sequencer/src/fees/action.rs b/crates/astria-sequencer/src/fees/action.rs deleted file mode 100644 index 6fa01af48e..0000000000 --- a/crates/astria-sequencer/src/fees/action.rs +++ /dev/null @@ -1,238 +0,0 @@ -use astria_core::protocol::transaction::v1::action::{ - FeeAssetChange, - FeeChange, -}; -use astria_eyre::eyre::{ - self, - ensure, - WrapErr as _, -}; -use cnidarium::StateWrite; -use futures::StreamExt; -use tokio::pin; - -use crate::{ - app::ActionHandler, - authority::StateReadExt as _, - fees::{ - StateReadExt as _, - StateWriteExt as _, - }, - transaction::StateReadExt as _, -}; - -#[async_trait::async_trait] -impl ActionHandler for FeeChange { - async fn check_stateless(&self) -> eyre::Result<()> { - Ok(()) - } - - /// check that the signer of the transaction is the current sudo address, - /// as only that address can change the fee - async fn check_and_execute(&self, mut state: S) -> eyre::Result<()> { - let from = state - .get_transaction_context() - .expect("transaction source must be present in state when executing an action") - .address_bytes(); - // ensure signer is the valid `sudo` key in state - let sudo_address = state - .get_sudo_address() - .await - .wrap_err("failed to get sudo address from state")?; - ensure!(sudo_address == from, "signer is not the sudo key"); - - match self { - Self::Transfer(fees) => state - .put_transfer_fees(*fees) - .wrap_err("failed to put transfer fees"), - Self::RollupDataSubmission(fees) => state - .put_rollup_data_submission_fees(*fees) - .wrap_err("failed to put sequence fees"), - Self::Ics20Withdrawal(fees) => state - .put_ics20_withdrawal_fees(*fees) - .wrap_err("failed to put ics20 withdrawal fees"), - Self::InitBridgeAccount(fees) => state - .put_init_bridge_account_fees(*fees) - .wrap_err("failed to put init bridge account fees"), - Self::BridgeLock(fees) => state - .put_bridge_lock_fees(*fees) - .wrap_err("failed to put bridge lock fees"), - Self::BridgeUnlock(fees) => state - .put_bridge_unlock_fees(*fees) - .wrap_err("failed to put bridge unlock fees"), - Self::BridgeSudoChange(fees) => state - .put_bridge_sudo_change_fees(*fees) - .wrap_err("failed to put bridge sudo change fees"), - Self::IbcRelay(fees) => state - .put_ibc_relay_fees(*fees) - .wrap_err("failed to put ibc relay fees"), - Self::ValidatorUpdate(fees) => state - .put_validator_update_fees(*fees) - .wrap_err("failed to put validator update fees"), - Self::FeeAssetChange(fees) => state - .put_fee_asset_change_fees(*fees) - .wrap_err("failed to put fee asset change fees"), - Self::FeeChange(fees) => state - .put_fee_change_fees(*fees) - .wrap_err("failed to put fee change fees"), - Self::IbcRelayerChange(fees) => state - .put_ibc_relayer_change_fees(*fees) - .wrap_err("failed to put ibc relayer change fees"), - Self::SudoAddressChange(fees) => state - .put_sudo_address_change_fees(*fees) - .wrap_err("failed to put sudo address change fees"), - Self::IbcSudoChange(fees) => state - .put_ibc_sudo_change_fees(*fees) - .wrap_err("failed to put ibc sudo change fees"), - Self::RecoverClient(fees) => state - .put_recover_client_fees(*fees) - .wrap_err("failed to put recover client fees"), - } - } -} - -#[async_trait::async_trait] -impl ActionHandler for FeeAssetChange { - async fn check_stateless(&self) -> eyre::Result<()> { - Ok(()) - } - - async fn check_and_execute(&self, mut state: S) -> eyre::Result<()> { - let from = state - .get_transaction_context() - .expect("transaction source must be present in state when executing an action") - .address_bytes(); - let authority_sudo_address = state - .get_sudo_address() - .await - .wrap_err("failed to get authority sudo address")?; - ensure!( - authority_sudo_address == from, - "unauthorized address for fee asset change" - ); - match self { - FeeAssetChange::Addition(asset) => { - state - .put_allowed_fee_asset(asset) - .context("failed to write allowed fee asset to state")?; - } - FeeAssetChange::Removal(asset) => { - state.delete_allowed_fee_asset(asset); - - pin!( - let assets = state.allowed_fee_assets(); - ); - ensure!( - assets - .filter_map(|item| std::future::ready(item.ok())) - .next() - .await - .is_some(), - "cannot remove last allowed fee asset", - ); - } - } - Ok(()) - } -} - -#[cfg(test)] -mod tests { - use astria_core::{ - primitive::v1::TransactionId, - protocol::transaction::v1::action::FeeChange, - }; - - use crate::{ - app::ActionHandler as _, - authority::StateWriteExt as _, - fees::StateReadExt as _, - transaction::{ - StateWriteExt as _, - TransactionContext, - }, - }; - - /// This macro generates a test named e.g. `transfer_fee_change_action_executes` which asserts - /// that executing a `FeeChange` tx for the given action results in the fees being stored for - /// the given action. - macro_rules! test_fee_change_action { - ( $( $fee_name:tt => $fee_ty:tt ),* $(,)?) => { - $( - paste::item! { - #[tokio::test] - async fn [< $fee_name _fee_change_action_executes >] () { - use astria_core::protocol::fees::v1:: [< $fee_ty FeeComponents >] as Fees; - - let storage = cnidarium::TempStorage::new().await.unwrap(); - let snapshot = storage.latest_snapshot(); - let mut state = cnidarium::StateDelta::new(snapshot); - - // Put the context to enable the txs to execute. - state.put_transaction_context(TransactionContext { - address_bytes: [1; 20], - transaction_id: TransactionId::new([0; 32]), - source_action_index: 0, - }); - state.put_sudo_address([1; 20]).unwrap(); - - assert!(state - .[< get_ $fee_name _fees >] () - .await - .expect(stringify!(should not error fetching unstored $fee_name fees)) - .is_none()); - - // Execute an initial fee change tx to store the first version of the fees. - let initial_fees = Fees { - base: 1, - multiplier: 2, - }; - let fee_change = FeeChange:: $fee_ty (initial_fees); - fee_change.check_and_execute(&mut state).await.unwrap(); - - let retrieved_fees = state - .[< get_ $fee_name _fees >] () - .await - .expect(stringify!(should not error fetching initial $fee_name fees)) - .expect(stringify!(initial $fee_name fees should be stored)); - assert_eq!(initial_fees, retrieved_fees); - - // Execute a second fee change tx to overwrite the fees. - let new_fees = Fees { - base: 3, - multiplier: 4, - }; - let fee_change = FeeChange:: $fee_ty (new_fees); - fee_change.check_and_execute(&mut state).await.unwrap(); - - let retrieved_fees = state - .[< get_ $fee_name _fees >] () - .await - .expect(stringify!(should not error fetching new $fee_name fees)) - .expect(stringify!(new $fee_name fees should be stored)); - assert_ne!(initial_fees, retrieved_fees); - assert_eq!(new_fees, retrieved_fees); - } - } - )* - }; - } - - test_fee_change_action!( - transfer => Transfer, - rollup_data_submission => RollupDataSubmission, - ics20_withdrawal => Ics20Withdrawal, - init_bridge_account => InitBridgeAccount, - bridge_lock => BridgeLock, - bridge_unlock => BridgeUnlock, - bridge_sudo_change => BridgeSudoChange, - validator_update => ValidatorUpdate, - ibc_relayer_change => IbcRelayerChange, - ibc_relay => IbcRelay, - fee_asset_change => FeeAssetChange, - fee_change => FeeChange, - sudo_address_change => SudoAddressChange, - ibc_sudo_change => IbcSudoChange, - recover_client => RecoverClient, - ); -} diff --git a/crates/astria-sequencer/src/fees/storage/values.rs b/crates/astria-sequencer/src/fees/storage/values.rs index 88a3062d4d..0d5327eb78 100644 --- a/crates/astria-sequencer/src/fees/storage/values.rs +++ b/crates/astria-sequencer/src/fees/storage/values.rs @@ -30,7 +30,7 @@ pub(crate) struct Value(ValueImpl); #[expect( clippy::enum_variant_names, - reason = "all types are fee types, and this is for storage internals only" + reason = "want to make it clear that these are fees and not actions" )] #[derive(Debug, BorshSerialize, BorshDeserialize)] enum ValueImpl { diff --git a/tools/protobuf-compiler/src/main.rs b/tools/protobuf-compiler/src/main.rs index 17cc2e50ef..c166ce0b54 100644 --- a/tools/protobuf-compiler/src/main.rs +++ b/tools/protobuf-compiler/src/main.rs @@ -73,7 +73,7 @@ fn main() { .bytes([".astria", ".celestia", ".cosmos", ".tendermint"]) .client_mod_attribute(".", "#[cfg(feature=\"client\")]") .server_mod_attribute(".", "#[cfg(feature=\"server\")]") - .extern_path(".astria_vendored.penumbra", "::penumbra-sdk-proto") + .extern_path(".astria_vendored.penumbra", "::penumbra-proto") .type_attribute(".astria.primitive.v1.Uint128", "#[derive(Copy)]") .type_attribute( ".astria.protocol.genesis.v1.IbcParameters",