diff --git a/crates/astria-cli/src/cli/sequencer.rs b/crates/astria-cli/src/cli/sequencer.rs index 66183ac175..cca710530f 100644 --- a/crates/astria-cli/src/cli/sequencer.rs +++ b/crates/astria-cli/src/cli/sequencer.rs @@ -66,7 +66,6 @@ pub enum SudoCommand { #[command(subcommand)] command: FeeAssetChangeCommand, }, - Mint(MintArgs), SudoAddressChange(SudoAddressChangeArgs), ValidatorUpdate(ValidatorUpdateArgs), } @@ -285,36 +284,6 @@ pub struct BlockHeightGetArgs { pub sequencer_chain_id: String, } -#[derive(Args, Debug)] -pub struct MintArgs { - // TODO: https://github.com/astriaorg/astria/issues/594 - // Don't use a plain text private, prefer wrapper like from - // the secrecy crate with specialized `Debug` and `Drop` implementations - // that overwrite the key on drop and don't reveal it when printing. - #[arg(long, env = "SEQUENCER_PRIVATE_KEY")] - pub(crate) private_key: String, - /// The url of the Sequencer node - #[arg( - long, - env = "SEQUENCER_URL", - default_value = crate::cli::DEFAULT_SEQUENCER_RPC - )] - pub(crate) sequencer_url: String, - /// The chain id of the sequencing chain being used - #[arg( - long = "sequencer.chain-id", - env = "ROLLUP_SEQUENCER_CHAIN_ID", - default_value = crate::cli::DEFAULT_SEQUENCER_CHAIN_ID - )] - pub sequencer_chain_id: String, - /// The address to mint to - #[arg(long)] - pub(crate) to_address: SequencerAddressArg, - /// The amount to mint - #[arg(long)] - pub(crate) amount: u128, -} - #[derive(Args, Debug)] pub struct SudoAddressChangeArgs { // TODO: https://github.com/astriaorg/astria/issues/594 diff --git a/crates/astria-cli/src/commands/mod.rs b/crates/astria-cli/src/commands/mod.rs index 6d6a36789f..cf7930c600 100644 --- a/crates/astria-cli/src/commands/mod.rs +++ b/crates/astria-cli/src/commands/mod.rs @@ -97,7 +97,6 @@ pub async fn run(cli: Cli) -> eyre::Result<()> { sequencer::fee_asset_remove(&args).await?; } }, - SudoCommand::Mint(args) => sequencer::mint(&args).await?, SudoCommand::ValidatorUpdate(args) => { sequencer::validator_update(&args).await?; } diff --git a/crates/astria-cli/src/commands/sequencer.rs b/crates/astria-cli/src/commands/sequencer.rs index 785097a1d3..9b9460c08d 100644 --- a/crates/astria-cli/src/commands/sequencer.rs +++ b/crates/astria-cli/src/commands/sequencer.rs @@ -8,7 +8,6 @@ use astria_core::{ FeeAssetChangeAction, IbcRelayerChangeAction, InitBridgeAccountAction, - MintAction, SudoAddressChangeAction, TransferAction, }, @@ -40,7 +39,6 @@ use crate::cli::sequencer::{ FeeAssetChangeArgs, IbcRelayerChangeArgs, InitBridgeAccountArgs, - MintArgs, SudoAddressChangeArgs, TransferArgs, ValidatorUpdateArgs, @@ -370,34 +368,6 @@ pub(crate) async fn fee_asset_remove(args: &FeeAssetChangeArgs) -> eyre::Result< Ok(()) } -/// Mints native asset to an account -/// -/// # Arguments -/// -/// * `args` - The arguments passed to the command -/// -/// # Errors -/// -/// * If the http client cannot be created -/// * If the transaction failed to be submitted -pub(crate) async fn mint(args: &MintArgs) -> eyre::Result<()> { - let res = submit_transaction( - args.sequencer_url.as_str(), - args.sequencer_chain_id.clone(), - args.private_key.as_str(), - Action::Mint(MintAction { - to: args.to_address.0, - amount: args.amount, - }), - ) - .await - .wrap_err("failed to submit Mint transaction")?; - - println!("Mint completed!"); - println!("Included in block: {}", res.height); - Ok(()) -} - /// Changes the Sequencer's sudo address to a new address /// /// # Arguments diff --git a/crates/astria-core/src/generated/astria.protocol.transactions.v1alpha1.rs b/crates/astria-core/src/generated/astria.protocol.transactions.v1alpha1.rs index 43a88f12b5..09b82f6408 100644 --- a/crates/astria-core/src/generated/astria.protocol.transactions.v1alpha1.rs +++ b/crates/astria-core/src/generated/astria.protocol.transactions.v1alpha1.rs @@ -59,7 +59,7 @@ impl ::prost::Name for TransactionParams { pub struct Action { #[prost( oneof = "action::Value", - tags = "1, 2, 11, 12, 13, 21, 22, 50, 51, 52, 53, 54, 55" + tags = "1, 2, 11, 12, 13, 21, 22, 50, 51, 52, 53, 55" )] pub value: ::core::option::Option, } @@ -85,7 +85,7 @@ pub mod action { IbcAction(::penumbra_proto::core::component::ibc::v1::IbcRelay), #[prost(message, tag = "22")] Ics20Withdrawal(super::Ics20Withdrawal), - /// POA sudo actions are defined of 50-60 + /// POA sudo actions are defined on 50-60 #[prost(message, tag = "50")] SudoAddressChangeAction(super::SudoAddressChangeAction), #[prost(message, tag = "51")] @@ -94,8 +94,6 @@ pub mod action { IbcRelayerChangeAction(super::IbcRelayerChangeAction), #[prost(message, tag = "53")] FeeAssetChangeAction(super::FeeAssetChangeAction), - #[prost(message, tag = "54")] - MintAction(super::MintAction), #[prost(message, tag = "55")] FeeChangeAction(super::FeeChangeAction), } @@ -173,25 +171,6 @@ impl ::prost::Name for SudoAddressChangeAction { ::prost::alloc::format!("astria.protocol.transactions.v1alpha1.{}", Self::NAME) } } -/// `MintAction` represents a minting transaction. -/// It can only be executed by the chain's sudo address. -/// -/// It contains the address to mint to, and the amount to mint. -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct MintAction { - #[prost(message, optional, tag = "1")] - pub to: ::core::option::Option, - #[prost(message, optional, tag = "2")] - pub amount: ::core::option::Option, -} -impl ::prost::Name for MintAction { - const NAME: &'static str = "MintAction"; - const PACKAGE: &'static str = "astria.protocol.transactions.v1alpha1"; - fn full_name() -> ::prost::alloc::string::String { - ::prost::alloc::format!("astria.protocol.transactions.v1alpha1.{}", Self::NAME) - } -} #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct Ics20Withdrawal { diff --git a/crates/astria-core/src/protocol/transaction/v1alpha1/action.rs b/crates/astria-core/src/protocol/transaction/v1alpha1/action.rs index d30e416ab3..04034202a9 100644 --- a/crates/astria-core/src/protocol/transaction/v1alpha1/action.rs +++ b/crates/astria-core/src/protocol/transaction/v1alpha1/action.rs @@ -29,7 +29,6 @@ pub enum Action { Transfer(TransferAction), ValidatorUpdate(tendermint::validator::Update), SudoAddressChange(SudoAddressChangeAction), - Mint(MintAction), Ibc(IbcRelay), Ics20Withdrawal(Ics20Withdrawal), IbcRelayerChange(IbcRelayerChangeAction), @@ -49,7 +48,6 @@ impl Action { Action::Transfer(act) => Value::TransferAction(act.into_raw()), Action::ValidatorUpdate(act) => Value::ValidatorUpdateAction(act.into()), Action::SudoAddressChange(act) => Value::SudoAddressChangeAction(act.into_raw()), - Action::Mint(act) => Value::MintAction(act.into_raw()), Action::Ibc(act) => Value::IbcAction(act.into()), Action::Ics20Withdrawal(act) => Value::Ics20Withdrawal(act.into_raw()), Action::IbcRelayerChange(act) => Value::IbcRelayerChangeAction(act.into_raw()), @@ -74,7 +72,6 @@ impl Action { Action::SudoAddressChange(act) => { Value::SudoAddressChangeAction(act.clone().into_raw()) } - Action::Mint(act) => Value::MintAction(act.to_raw()), Action::Ibc(act) => Value::IbcAction(act.clone().into()), Action::Ics20Withdrawal(act) => Value::Ics20Withdrawal(act.to_raw()), Action::IbcRelayerChange(act) => Value::IbcRelayerChangeAction(act.to_raw()), @@ -117,9 +114,6 @@ impl Action { SudoAddressChangeAction::try_from_raw(act) .map_err(ActionError::sudo_address_change)?, ), - Value::MintAction(act) => { - Self::Mint(MintAction::try_from_raw(act).map_err(ActionError::mint)?) - } Value::IbcAction(act) => { Self::Ibc(IbcRelay::try_from(act).map_err(|e| ActionError::ibc(e.into()))?) } @@ -185,12 +179,6 @@ impl From for Action { } } -impl From for Action { - fn from(value: MintAction) -> Self { - Self::Mint(value) - } -} - impl From for Action { fn from(value: IbcRelay) -> Self { Self::Ibc(value) @@ -265,10 +253,6 @@ impl ActionError { Self(ActionErrorKind::SudoAddressChange(inner)) } - fn mint(inner: MintActionError) -> Self { - Self(ActionErrorKind::Mint(inner)) - } - fn ibc(inner: Box) -> Self { Self(ActionErrorKind::Ibc(inner)) } @@ -314,8 +298,6 @@ enum ActionErrorKind { ValidatorUpdate(#[source] tendermint::error::Error), #[error("sudo address change action was not valid")] SudoAddressChange(#[source] SudoAddressChangeActionError), - #[error("mint action was not valid")] - Mint(#[source] MintActionError), #[error("ibc action was not valid")] Ibc(#[source] Box), #[error("ics20 withdrawal action was not valid")] @@ -607,84 +589,6 @@ enum SudoAddressChangeActionErrorKind { Address(#[source] IncorrectAddressLength), } -#[allow(clippy::module_name_repetitions)] -#[derive(Clone, Debug)] -pub struct MintAction { - pub to: Address, - pub amount: u128, -} - -impl MintAction { - #[must_use] - pub fn into_raw(self) -> raw::MintAction { - let Self { - to, - amount, - } = self; - raw::MintAction { - to: Some(to.to_raw()), - amount: Some(amount.into()), - } - } - - #[must_use] - pub fn to_raw(&self) -> raw::MintAction { - let Self { - to, - amount, - } = self; - raw::MintAction { - to: Some(to.to_raw()), - amount: Some((*amount).into()), - } - } - - /// Convert from a raw, unchecked protobuf [`raw::MintAction`]. - /// - /// # Errors - /// - /// Returns an error if the raw action's `to` address did not have the expected - /// length. - pub fn try_from_raw(proto: raw::MintAction) -> Result { - let raw::MintAction { - to, - amount, - } = proto; - let Some(to) = to else { - return Err(MintActionError::field_not_set("to")); - }; - let to = Address::try_from_raw(&to).map_err(MintActionError::address_length)?; - let amount = amount.map_or(0, Into::into); - Ok(Self { - to, - amount, - }) - } -} - -#[allow(clippy::module_name_repetitions)] -#[derive(Debug, thiserror::Error)] -#[error(transparent)] -pub struct MintActionError(MintActionErrorKind); - -impl MintActionError { - fn field_not_set(field: &'static str) -> Self { - Self(MintActionErrorKind::FieldNotSet(field)) - } - - fn address_length(inner: IncorrectAddressLength) -> Self { - Self(MintActionErrorKind::AddressLength(inner)) - } -} - -#[derive(Debug, thiserror::Error)] -enum MintActionErrorKind { - #[error("the expected field in the raw source type was not set: `{0}`")] - FieldNotSet(&'static str), - #[error("`to` field did not contain a valid address")] - AddressLength(#[source] IncorrectAddressLength), -} - /// Represents an IBC withdrawal of an asset from a source chain to a destination chain. /// /// The parameters match the arguments to the `sendFungibleTokens` function in the diff --git a/crates/astria-sequencer/Cargo.toml b/crates/astria-sequencer/Cargo.toml index bda8420479..d49b8000b9 100644 --- a/crates/astria-sequencer/Cargo.toml +++ b/crates/astria-sequencer/Cargo.toml @@ -13,7 +13,6 @@ name = "astria-sequencer" [features] default = [] -mint = [] [dependencies] astria-core = { path = "../astria-core", features = ["server", "serde"] } diff --git a/crates/astria-sequencer/src/app/tests_execute_transaction.rs b/crates/astria-sequencer/src/app/tests_execute_transaction.rs index 96fd92bc51..7ea28736c9 100644 --- a/crates/astria-sequencer/src/app/tests_execute_transaction.rs +++ b/crates/astria-sequencer/src/app/tests_execute_transaction.rs @@ -1,7 +1,5 @@ use std::sync::Arc; -#[cfg(feature = "mint")] -use astria_core::protocol::transaction::v1alpha1::action::MintAction; use astria_core::{ crypto::SigningKey, primitive::v1::{ @@ -808,53 +806,6 @@ async fn app_execute_transaction_bridge_lock_action_invalid_for_eoa() { assert!(app.execute_transaction(signed_tx).await.is_err()); } -#[cfg(feature = "mint")] -#[tokio::test] -async fn app_execute_transaction_mint() { - let (alice_signing_key, alice_address) = get_alice_signing_key_and_address(); - - let genesis_state = GenesisState { - accounts: default_genesis_accounts(), - authority_sudo_address: alice_address, - ibc_sudo_address: [0u8; 20].into(), - ibc_relayer_addresses: vec![], - native_asset_base_denomination: DEFAULT_NATIVE_ASSET_DENOM.to_string(), - ibc_params: IBCParameters::default(), - allowed_fee_assets: vec![DEFAULT_NATIVE_ASSET_DENOM.to_owned().into()], - fees: default_fees(), - }; - let mut app = initialize_app(Some(genesis_state), vec![]).await; - - let bob_address = address_from_hex_string(BOB_ADDRESS); - let value = 333_333; - let tx = UnsignedTransaction { - params: TransactionParams { - nonce: 0, - chain_id: "test".to_string(), - }, - actions: vec![ - MintAction { - to: bob_address, - amount: value, - } - .into(), - ], - }; - - let signed_tx = Arc::new(tx.into_signed(&alice_signing_key)); - app.execute_transaction(signed_tx).await.unwrap(); - - assert_eq!( - app.state - .get_account_balance(bob_address, get_native_asset().id()) - .await - .unwrap(), - value + 10u128.pow(19) - ); - assert_eq!(app.state.get_account_nonce(bob_address).await.unwrap(), 0); - assert_eq!(app.state.get_account_nonce(alice_address).await.unwrap(), 1); -} - #[tokio::test] async fn app_execute_transaction_invalid_nonce() { let mut app = initialize_app(None, vec![]).await; diff --git a/crates/astria-sequencer/src/lib.rs b/crates/astria-sequencer/src/lib.rs index 2da9838bd1..96e0077613 100644 --- a/crates/astria-sequencer/src/lib.rs +++ b/crates/astria-sequencer/src/lib.rs @@ -13,8 +13,6 @@ pub(crate) mod grpc; pub(crate) mod ibc; mod mempool; pub mod metrics_init; -#[cfg(feature = "mint")] -pub(crate) mod mint; pub(crate) mod proposal; pub(crate) mod sequence; mod sequencer; diff --git a/crates/astria-sequencer/src/main.rs b/crates/astria-sequencer/src/main.rs index 842c267d93..1adb08e16a 100644 --- a/crates/astria-sequencer/src/main.rs +++ b/crates/astria-sequencer/src/main.rs @@ -56,20 +56,6 @@ async fn main() -> ExitCode { "initializing sequencer" ); - #[cfg(feature = "mint")] - if cfg.enable_mint { - tokio::spawn(async { - let duration = std::time::Duration::from_secs(5); - loop { - eprintln!("MINT FEATURE IS ENABLED!"); - eprintln!("do not enable minting in production!"); - tracing::warn!("MINT FEATURE IS ENABLED!"); - tracing::warn!("do not enable minting in production!"); - tokio::time::sleep(duration).await; - } - }); - } - Sequencer::run_until_stopped(cfg) .await .expect("failed to run sequencer"); diff --git a/crates/astria-sequencer/src/mint/action.rs b/crates/astria-sequencer/src/mint/action.rs deleted file mode 100644 index 09ba618cc9..0000000000 --- a/crates/astria-sequencer/src/mint/action.rs +++ /dev/null @@ -1,58 +0,0 @@ -use anyhow::{ - ensure, - Context as _, - Result, -}; -use astria_core::{ - primitive::v1::Address, - protocol::transaction::v1alpha1::action::MintAction, -}; -use tracing::instrument; - -use crate::{ - accounts::state_ext::{ - StateReadExt as AccountStateReadExt, - StateWriteExt as AccountStateWriteExt, - }, - asset::get_native_asset, - authority::state_ext::StateReadExt as AuthorityStateReadExt, - transaction::action_handler::ActionHandler, -}; - -#[async_trait::async_trait] -impl ActionHandler for MintAction { - async fn check_stateful( - &self, - state: &S, - from: Address, - ) -> Result<()> { - // ensure signer is the valid `sudo` key in state - let sudo_address = state - .get_sudo_address() - .await - .context("failed to get sudo address from state")?; - ensure!(sudo_address == from, "signer is not the sudo key"); - Ok(()) - } - - #[instrument(skip_all)] - async fn execute( - &self, - state: &mut S, - _: Address, - ) -> Result<()> { - let native_asset = get_native_asset().id(); - - let to_balance = state - .get_account_balance(self.to, native_asset) - .await - .context("failed getting `to` account balance")?; - let new_balance = to_balance - .checked_add(self.amount) - .context("`to` balance would overflow")?; - state - .put_account_balance(self.to, native_asset, new_balance) - .context("failed updating `to` account balance")?; - Ok(()) - } -} diff --git a/crates/astria-sequencer/src/mint/mod.rs b/crates/astria-sequencer/src/mint/mod.rs deleted file mode 100644 index f04dbbc6c9..0000000000 --- a/crates/astria-sequencer/src/mint/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub(crate) mod action; diff --git a/crates/astria-sequencer/src/transaction/checks.rs b/crates/astria-sequencer/src/transaction/checks.rs index 3ee0d91239..a2074e0e2b 100644 --- a/crates/astria-sequencer/src/transaction/checks.rs +++ b/crates/astria-sequencer/src/transaction/checks.rs @@ -140,8 +140,7 @@ pub(crate) async fn check_balance_for_total_fees( | Action::Ibc(_) | Action::IbcRelayerChange(_) | Action::FeeAssetChange(_) - | Action::FeeChange(_) - | Action::Mint(_) => { + | Action::FeeChange(_) => { continue; } } diff --git a/crates/astria-sequencer/src/transaction/mod.rs b/crates/astria-sequencer/src/transaction/mod.rs index 23781ea535..1eaa5f2a30 100644 --- a/crates/astria-sequencer/src/transaction/mod.rs +++ b/crates/astria-sequencer/src/transaction/mod.rs @@ -4,8 +4,6 @@ mod checks; use std::fmt; pub(crate) use action_handler::ActionHandler; -#[cfg(not(feature = "mint"))] -use anyhow::bail; use anyhow::{ ensure, Context as _, @@ -155,13 +153,6 @@ impl ActionHandler for UnsignedTransaction { .check_stateless() .await .context("stateless check failed for BridgeLockAction")?, - #[cfg(feature = "mint")] - Action::Mint(act) => act - .check_stateless() - .await - .context("stateless check failed for MintAction")?, - #[cfg(not(feature = "mint"))] - _ => bail!("unsupported action type: {:?}", action), } } Ok(()) @@ -245,13 +236,6 @@ impl ActionHandler for UnsignedTransaction { .check_stateful(state, from) .await .context("stateful check failed for BridgeUnlockAction")?, - #[cfg(feature = "mint")] - Action::Mint(act) => act - .check_stateful(state, from) - .await - .context("stateful check failed for MintAction")?, - #[cfg(not(feature = "mint"))] - _ => bail!("unsupported action type: {:?}", action), } } @@ -343,14 +327,6 @@ impl ActionHandler for UnsignedTransaction { .await .context("execution failed for BridgeUnlockAction")?; } - #[cfg(feature = "mint")] - Action::Mint(act) => { - act.execute(state, from) - .await - .context("execution failed for MintAction")?; - } - #[cfg(not(feature = "mint"))] - _ => bail!("unsupported action type: {:?}", action), } } diff --git a/proto/protocolapis/astria/protocol/transactions/v1alpha1/types.proto b/proto/protocolapis/astria/protocol/transactions/v1alpha1/types.proto index 5be997d2ac..17d462f2ff 100644 --- a/proto/protocolapis/astria/protocol/transactions/v1alpha1/types.proto +++ b/proto/protocolapis/astria/protocol/transactions/v1alpha1/types.proto @@ -47,18 +47,21 @@ message Action { astria_vendored.penumbra.core.component.ibc.v1.IbcRelay ibc_action = 21; Ics20Withdrawal ics20_withdrawal = 22; - // POA sudo actions are defined of 50-60 + // POA sudo actions are defined on 50-60 SudoAddressChangeAction sudo_address_change_action = 50; astria_vendored.tendermint.abci.ValidatorUpdate validator_update_action = 51; IbcRelayerChangeAction ibc_relayer_change_action = 52; FeeAssetChangeAction fee_asset_change_action = 53; - MintAction mint_action = 54; FeeChangeAction fee_change_action = 55; } reserved 3 to 10; reserved 14 to 20; reserved 23 to 30; reserved 56 to 60; + + // deprecated fields + reserved 54; // deprecated "mint_action" + reserved "mint_action"; } // `TransferAction` represents a value transfer transaction. @@ -95,15 +98,6 @@ message SudoAddressChangeAction { astria.primitive.v1.Address new_address = 1; } -// `MintAction` represents a minting transaction. -// It can only be executed by the chain's sudo address. -// -// It contains the address to mint to, and the amount to mint. -message MintAction { - astria.primitive.v1.Address to = 1; - astria.primitive.v1.Uint128 amount = 2; -} - message Ics20Withdrawal { // first two fields are a transparent value consisting of an amount and a denom. astria.primitive.v1.Uint128 amount = 1;