Skip to content
Closed
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
3 changes: 3 additions & 0 deletions .changelog/unreleased/SDK/2561-remove-update-vp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- `InitAccount` and `UpdateAccount` don't require `vp_code_hash` anymore.
`TxInitAccount`. `TxUpdateAccount` and `TxInitValidator` don't have a path to
the vp code anymore. ([\#2561](https://github.com/anoma/namada/pull/2561))
2 changes: 2 additions & 0 deletions .changelog/unreleased/improvements/2561-remove-update-vp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Removed custom vps for established accounts.
([\#2561](https://github.com/anoma/namada/pull/2561))
12 changes: 1 addition & 11 deletions crates/account/src/types.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use namada_core::address::Address;
use namada_core::borsh::{BorshDeserialize, BorshSchema, BorshSerialize};
use namada_core::hash::Hash;
use namada_core::key::common;
use serde::{Deserialize, Serialize};

Expand All @@ -20,13 +19,11 @@ pub struct InitAccount {
/// for signature verification of transactions for the newly created
/// account.
pub public_keys: Vec<common::PublicKey>,
/// The VP code hash
pub vp_code_hash: Hash,
/// The account signature threshold
pub threshold: u8,
}

/// A tx data type to update an account's validity predicate
/// A tx data type to update an account's signature threshold and keys
#[derive(
Debug,
Clone,
Expand All @@ -40,8 +37,6 @@ pub struct InitAccount {
pub struct UpdateAccount {
/// An address of the account
pub addr: Address,
/// The new VP code hash
pub vp_code_hash: Option<Hash>,
/// Public keys to be written into the account's storage. This can be used
/// for signature verification of transactions for the newly created
/// account.
Expand All @@ -54,7 +49,6 @@ pub struct UpdateAccount {
/// Tests and strategies for accounts
pub mod tests {
use namada_core::address::testing::arb_non_internal_address;
use namada_core::hash::testing::arb_hash;
use namada_core::key::testing::arb_common_pk;
use proptest::prelude::Just;
use proptest::{collection, option, prop_compose};
Expand All @@ -68,11 +62,9 @@ pub mod tests {
)(
threshold in 0..=public_keys.len() as u8,
public_keys in Just(public_keys),
vp_code_hash in arb_hash(),
) -> InitAccount {
InitAccount {
public_keys,
vp_code_hash,
threshold,
}
}
Expand All @@ -84,13 +76,11 @@ pub mod tests {
public_keys in collection::vec(arb_common_pk(), 0..10),
)(
addr in arb_non_internal_address(),
vp_code_hash in option::of(arb_hash()),
threshold in option::of(0..=public_keys.len() as u8),
public_keys in Just(public_keys),
) -> UpdateAccount {
UpdateAccount {
addr,
vp_code_hash,
public_keys,
threshold,
}
Expand Down
49 changes: 2 additions & 47 deletions crates/apps/src/lib/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1246,8 +1246,8 @@ pub mod cmds {
fn def() -> App {
App::new(Self::CMD)
.about(
"Send a signed transaction to update account's validity \
predicate.",
"Send a signed transaction to update account's threshold \
or keys.",
)
.add_args::<args::TxUpdateAccount<args::CliTypes>>()
}
Expand Down Expand Up @@ -3197,8 +3197,6 @@ pub mod args {
arg_multi("account-keys");
pub const VALIDATOR_CONSENSUS_KEY: ArgOpt<WalletPublicKey> =
arg_opt("consensus-key");
pub const VALIDATOR_CODE_PATH: ArgOpt<PathBuf> =
arg_opt("validator-code-path");
pub const VALIDATOR_ETH_COLD_KEY: ArgOpt<WalletPublicKey> =
arg_opt("eth-cold-key");
pub const VALIDATOR_ETH_HOT_KEY: ArgOpt<WalletPublicKey> =
Expand All @@ -3208,7 +3206,6 @@ pub mod args {
pub const VIEWING_KEY: Arg<WalletViewingKey> = arg("key");
pub const VIEWING_KEYS: ArgMulti<WalletViewingKey, GlobStar> =
arg_multi("viewing-keys");
pub const VP: ArgOpt<String> = arg_opt("vp");
pub const WALLET_ALIAS_FORCE: ArgFlag = flag("wallet-alias-force");
pub const WASM_CHECKSUMS_PATH: Arg<PathBuf> = arg("wasm-checksums-path");
pub const WASM_DIR: ArgOpt<PathBuf> = arg_opt("wasm-dir");
Expand Down Expand Up @@ -4134,7 +4131,6 @@ pub mod args {
let chain_ctx = ctx.borrow_mut_chain_or_exit();
TxInitAccount::<SdkTypes> {
tx,
vp_code_path: self.vp_code_path,
tx_code_path: self.tx_code_path,
public_keys: self
.public_keys
Expand All @@ -4149,15 +4145,11 @@ pub mod args {
impl Args for TxInitAccount<CliTypes> {
fn parse(matches: &ArgMatches) -> Self {
let tx = Tx::parse(matches);
let vp_code_path = CODE_PATH_OPT
.parse(matches)
.unwrap_or_else(|| PathBuf::from(VP_USER_WASM));
let tx_code_path = PathBuf::from(TX_INIT_ACCOUNT_WASM);
let public_keys = PUBLIC_KEYS.parse(matches);
let threshold = THRESHOLD.parse(matches);
Self {
tx,
vp_code_path,
public_keys,
threshold,
tx_code_path,
Expand All @@ -4166,11 +4158,6 @@ pub mod args {

fn def(app: App) -> App {
app.add_args::<Tx<CliTypes>>()
.arg(CODE_PATH_OPT.def().help(
"The path to the validity predicate WASM code to be used \
for the new account. Uses the default user VP if none \
specified.",
))
.arg(PUBLIC_KEYS.def().help(
"A list public keys to be associated with the new account \
in hexadecimal encoding.",
Expand Down Expand Up @@ -4291,11 +4278,6 @@ pub mod args {
.arg(WEBSITE_OPT.def().help("The validator's website."))
.arg(DISCORD_OPT.def().help("The validator's discord handle."))
.arg(AVATAR_OPT.def().help("The validator's avatar."))
.arg(VALIDATOR_CODE_PATH.def().help(
"The path to the validity predicate WASM code to be used \
for the validator account. Uses the default validator VP \
if none specified.",
))
.arg(UNSAFE_DONT_ENCRYPT.def().help(
"UNSAFE: Do not encrypt the generated keypairs. Do not \
use this for keys used in a live network.",
Expand Down Expand Up @@ -4327,9 +4309,6 @@ pub mod args {
website: self.website,
discord_handle: self.discord_handle,
avatar: self.avatar,
validator_vp_code_path: self
.validator_vp_code_path
.to_path_buf(),
unsafe_dont_encrypt: self.unsafe_dont_encrypt,
tx_init_account_code_path: self
.tx_init_account_code_path
Expand Down Expand Up @@ -4358,9 +4337,6 @@ pub mod args {
let website = WEBSITE_OPT.parse(matches);
let discord_handle = DISCORD_OPT.parse(matches);
let avatar = AVATAR_OPT.parse(matches);
let validator_vp_code_path = VALIDATOR_CODE_PATH
.parse(matches)
.unwrap_or_else(|| PathBuf::from(VP_USER_WASM));
let unsafe_dont_encrypt = UNSAFE_DONT_ENCRYPT.parse(matches);
let tx_init_account_code_path = PathBuf::from(TX_INIT_ACCOUNT_WASM);
let tx_become_validator_code_path =
Expand All @@ -4382,7 +4358,6 @@ pub mod args {
website,
discord_handle,
avatar,
validator_vp_code_path,
unsafe_dont_encrypt,
tx_init_account_code_path,
tx_become_validator_code_path,
Expand Down Expand Up @@ -4435,11 +4410,6 @@ pub mod args {
.arg(WEBSITE_OPT.def().help("The validator's website."))
.arg(DISCORD_OPT.def().help("The validator's discord handle."))
.arg(AVATAR_OPT.def().help("The validator's avatar."))
.arg(VALIDATOR_CODE_PATH.def().help(
"The path to the validity predicate WASM code to be used \
for the validator account. Uses the default validator VP \
if none specified.",
))
.arg(UNSAFE_DONT_ENCRYPT.def().help(
"UNSAFE: Do not encrypt the generated keypairs. Do not \
use this for keys used in a live network.",
Expand All @@ -4458,7 +4428,6 @@ pub mod args {
let chain_ctx = ctx.borrow_mut_chain_or_exit();
TxUpdateAccount::<SdkTypes> {
tx,
vp_code_path: self.vp_code_path,
tx_code_path: self.tx_code_path,
addr: chain_ctx.get(&self.addr),
public_keys: self
Expand All @@ -4474,14 +4443,12 @@ pub mod args {
impl Args for TxUpdateAccount<CliTypes> {
fn parse(matches: &ArgMatches) -> Self {
let tx = Tx::parse(matches);
let vp_code_path = CODE_PATH_OPT.parse(matches);
let addr = ADDRESS.parse(matches);
let tx_code_path = PathBuf::from(TX_UPDATE_ACCOUNT_WASM);
let public_keys = PUBLIC_KEYS.parse(matches);
let threshold = THRESHOLD.parse(matches);
Self {
tx,
vp_code_path,
addr,
tx_code_path,
public_keys,
Expand All @@ -4491,11 +4458,6 @@ pub mod args {

fn def(app: App) -> App {
app.add_args::<Tx<CliTypes>>()
.arg(
CODE_PATH_OPT.def().help(
"The path to the new validity predicate WASM code.",
),
)
.arg(ADDRESS.def().help(
"The account's address. It's key is used to produce the \
signature.",
Expand Down Expand Up @@ -6983,22 +6945,18 @@ pub mod args {

#[derive(Clone, Debug)]
pub struct InitGenesisEstablishedAccount {
pub vp: String,
pub wallet_aliases: Vec<String>,
pub threshold: u8,
pub output_path: PathBuf,
}

impl Args for InitGenesisEstablishedAccount {
fn parse(matches: &ArgMatches) -> Self {
use crate::config::genesis::utils::VP_USER;
let wallet_aliases = ALIAS_MANY.parse(matches);
let vp = VP.parse(matches).unwrap_or_else(|| VP_USER.to_string());
let threshold = THRESHOLD.parse(matches).unwrap_or(1);
let output_path = PATH.parse(matches);
Self {
wallet_aliases,
vp,
threshold,
output_path,
}
Expand All @@ -7014,9 +6972,6 @@ pub mod args {
authorization. Must be less than or equal to the maximum \
number of key aliases provided.",
))
.arg(VP.def().help(
"The validity predicate of the account. Defaults to `vp_user`.",
))
.arg(PATH.def().help(
"The path of the .toml file to write the established account \
transaction to. Overwrites the file if it exists.",
Expand Down
2 changes: 0 additions & 2 deletions crates/apps/src/lib/client/tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -874,7 +874,6 @@ pub async fn submit_init_validator(
description,
discord_handle,
avatar,
validator_vp_code_path,
unsafe_dont_encrypt,
tx_init_account_code_path,
tx_become_validator_code_path,
Expand All @@ -884,7 +883,6 @@ pub async fn submit_init_validator(
namada,
args::TxInitAccount {
tx: tx_args.clone(),
vp_code_path: validator_vp_code_path,
tx_code_path: tx_init_account_code_path,
public_keys: account_keys,
threshold,
Expand Down
1 change: 0 additions & 1 deletion crates/apps/src/lib/client/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,6 @@ pub fn init_genesis_established_account(
.collect();

let (address, txs) = genesis::transactions::init_established_account(
args.vp,
public_keys,
args.threshold,
);
Expand Down
11 changes: 0 additions & 11 deletions crates/apps/src/lib/config/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,6 @@ pub struct Validator {
/// These tokens are not staked and hence do not contribute to the
/// validator's voting power
pub non_staked_balance: token::Amount,
/// Validity predicate code WASM
pub validator_vp_code_path: String,
/// Expected SHA-256 hash of the validator VP
pub validator_vp_sha256: [u8; 32],
}

#[derive(
Expand All @@ -206,10 +202,6 @@ pub struct Validator {
pub struct EstablishedAccount {
/// Address
pub address: Address,
/// Validity predicate code WASM
pub vp_code_path: String,
/// Expected SHA-256 hash of the validity predicate wasm
pub vp_sha256: [u8; 32],
/// A public key to be stored in the account's storage, if any
pub public_key: Option<common::PublicKey>,
/// Account's sub-space storage. The values must be borsh encoded bytes.
Expand Down Expand Up @@ -446,7 +438,6 @@ pub fn make_dev_genesis(
genesis.transactions.established_account.as_mut().unwrap();

let tx = transactions::EstablishedAccountTx {
vp: utils::VP_USER.to_string(),
public_keys: vec![StringEncoded::new(
consensus_keypair.ref_to(),
)],
Expand All @@ -461,7 +452,6 @@ pub fn make_dev_genesis(

let validator_account_tx = transactions::ValidatorAccountTx {
address: StringEncoded::new(address.clone()),
vp: utils::VP_USER.to_string(),
commission_rate: Dec::new(5, 2).expect("This can't fail"),
max_commission_rate_change: Dec::new(1, 2)
.expect("This can't fail"),
Expand Down Expand Up @@ -496,7 +486,6 @@ pub fn make_dev_genesis(
tx: transactions::Signed::new(
transactions::ValidatorAccountTx {
address: StringEncoded::new(address.clone()),
vp: validator_account_tx.vp,
commission_rate: validator_account_tx.commission_rate,
max_commission_rate_change: validator_account_tx
.max_commission_rate_change,
Expand Down
Loading