Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removes custom established VPs #2561

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 14 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::borsh::{BorshDeserialize, BorshSchema, BorshSerialize};
use namada_core::types::address::Address;
use namada_core::types::hash::Hash;
use namada_core::types::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::types::address::testing::arb_non_internal_address;
use namada_core::types::hash::testing::arb_hash;
use namada_core::types::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 @@
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.",

Check warning on line 1250 in crates/apps/src/lib/cli.rs

View check run for this annotation

Codecov / codecov/patch

crates/apps/src/lib/cli.rs#L1249-L1250

Added lines #L1249 - L1250 were not covered by tests
)
.add_args::<args::TxUpdateAccount<args::CliTypes>>()
}
Expand Down Expand Up @@ -3198,8 +3198,6 @@
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 @@ -3209,7 +3207,6 @@
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 @@ -4135,7 +4132,6 @@
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 @@ -4150,15 +4146,11 @@
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 @@ -4167,11 +4159,6 @@

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 @@ -4292,11 +4279,6 @@
.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 @@ -4328,9 +4310,6 @@
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 @@ -4359,9 +4338,6 @@
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 @@ -4383,7 +4359,6 @@
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 @@ -4436,11 +4411,6 @@
.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 @@ -4459,7 +4429,6 @@
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 @@ -4475,14 +4444,12 @@
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 @@ -4492,11 +4459,6 @@

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 @@ -6984,22 +6946,18 @@

#[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 @@ -7015,9 +6973,6 @@
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 @@ -741,7 +741,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 @@ -191,10 +191,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 @@ -204,10 +200,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 @@ -444,7 +436,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 @@ -459,7 +450,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 @@ -494,7 +484,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
Loading