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
31 changes: 0 additions & 31 deletions crates/astria-cli/src/cli/sequencer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ pub enum SudoCommand {
#[command(subcommand)]
command: FeeAssetChangeCommand,
},
Mint(MintArgs),
SudoAddressChange(SudoAddressChangeArgs),
ValidatorUpdate(ValidatorUpdateArgs),
}
Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion crates/astria-cli/src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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?;
}
Expand Down
30 changes: 0 additions & 30 deletions crates/astria-cli/src/commands/sequencer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use astria_core::{
FeeAssetChangeAction,
IbcRelayerChangeAction,
InitBridgeAccountAction,
MintAction,
SudoAddressChangeAction,
TransferAction,
},
Expand Down Expand Up @@ -40,7 +39,6 @@ use crate::cli::sequencer::{
FeeAssetChangeArgs,
IbcRelayerChangeArgs,
InitBridgeAccountArgs,
MintArgs,
SudoAddressChangeArgs,
TransferArgs,
ValidatorUpdateArgs,
Expand Down Expand Up @@ -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
Expand Down

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

96 changes: 0 additions & 96 deletions crates/astria-core/src/protocol/transaction/v1alpha1/action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ pub enum Action {
Transfer(TransferAction),
ValidatorUpdate(tendermint::validator::Update),
SudoAddressChange(SudoAddressChangeAction),
Mint(MintAction),
Ibc(IbcRelay),
Ics20Withdrawal(Ics20Withdrawal),
IbcRelayerChange(IbcRelayerChangeAction),
Expand All @@ -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()),
Expand All @@ -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()),
Expand Down Expand Up @@ -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()))?)
}
Expand Down Expand Up @@ -185,12 +179,6 @@ impl From<SudoAddressChangeAction> for Action {
}
}

impl From<MintAction> for Action {
fn from(value: MintAction) -> Self {
Self::Mint(value)
}
}

impl From<IbcRelay> for Action {
fn from(value: IbcRelay) -> Self {
Self::Ibc(value)
Expand Down Expand Up @@ -265,10 +253,6 @@ impl ActionError {
Self(ActionErrorKind::SudoAddressChange(inner))
}

fn mint(inner: MintActionError) -> Self {
Self(ActionErrorKind::Mint(inner))
}

fn ibc(inner: Box<dyn std::error::Error + Send + Sync>) -> Self {
Self(ActionErrorKind::Ibc(inner))
}
Expand Down Expand Up @@ -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<dyn std::error::Error + Send + Sync>),
#[error("ics20 withdrawal action was not valid")]
Expand Down Expand Up @@ -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<Self, MintActionError> {
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
Expand Down
1 change: 0 additions & 1 deletion crates/astria-sequencer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ name = "astria-sequencer"

[features]
default = []
mint = []

[dependencies]
astria-core = { path = "../astria-core", features = ["server", "serde"] }
Expand Down
49 changes: 0 additions & 49 deletions crates/astria-sequencer/src/app/tests_execute_transaction.rs
Original file line number Diff line number Diff line change
@@ -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::{
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 0 additions & 2 deletions crates/astria-sequencer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading