Skip to content

Commit e740994

Browse files
committed
Merge branch 'brent/remove-staking-address' into brent/validator-commission-rates
* brent/remove-staking-address: changelog: #687 remove staking rewards address from cli strings and docs strings wallet: remove validator rewards key client: remove staking rewards address from init-validator result [ci] wasm checksums update remove staking reward address from genesis toml files remove staking reward address from all code
2 parents 4a8ba05 + 64654eb commit e740994

File tree

25 files changed

+46
-485
lines changed

25 files changed

+46
-485
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- PoS: Removed staking reward addresses in preparation of auto-staked rewards
2+
system. ([#687](https://github.com/anoma/namada/pull/687))

apps/src/lib/cli.rs

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -853,8 +853,8 @@ pub mod cmds {
853853
fn def() -> App {
854854
App::new(Self::CMD)
855855
.about(
856-
"Send a signed transaction to create a new validator and \
857-
its staking reward account.",
856+
"Send a signed transaction to create a new validator \
857+
account.",
858858
)
859859
.add_args::<args::TxInitValidator>()
860860
}
@@ -1232,9 +1232,9 @@ pub mod cmds {
12321232
fn def() -> App {
12331233
App::new(Self::CMD)
12341234
.about(
1235-
"Initialize genesis validator's address, staking reward \
1236-
address, consensus key, validator account key and \
1237-
staking rewards key and use it in the ledger's node.",
1235+
"Initialize genesis validator's address, consensus key \
1236+
and validator account key and use it in the ledger's \
1237+
node.",
12381238
)
12391239
.add_args::<args::InitGenesisValidator>()
12401240
}
@@ -1328,8 +1328,6 @@ pub mod args {
13281328
const RAW_ADDRESS: Arg<Address> = arg("address");
13291329
const RAW_ADDRESS_OPT: ArgOpt<Address> = RAW_ADDRESS.opt();
13301330
const RAW_PUBLIC_KEY_OPT: ArgOpt<common::PublicKey> = arg_opt("public-key");
1331-
const REWARDS_CODE_PATH: ArgOpt<PathBuf> = arg_opt("rewards-code-path");
1332-
const REWARDS_KEY: ArgOpt<WalletPublicKey> = arg_opt("rewards-key");
13331331
const SCHEME: ArgDefault<SchemeType> =
13341332
arg_default("scheme", DefaultFn(|| SchemeType::Ed25519));
13351333
const SIGNER: ArgOpt<WalletAddress> = arg_opt("signer");
@@ -1567,10 +1565,8 @@ pub mod args {
15671565
pub scheme: SchemeType,
15681566
pub account_key: Option<WalletPublicKey>,
15691567
pub consensus_key: Option<WalletKeypair>,
1570-
pub rewards_account_key: Option<WalletPublicKey>,
15711568
pub protocol_key: Option<WalletPublicKey>,
15721569
pub validator_vp_code_path: Option<PathBuf>,
1573-
pub rewards_vp_code_path: Option<PathBuf>,
15741570
pub unsafe_dont_encrypt: bool,
15751571
}
15761572

@@ -1581,21 +1577,17 @@ pub mod args {
15811577
let scheme = SCHEME.parse(matches);
15821578
let account_key = VALIDATOR_ACCOUNT_KEY.parse(matches);
15831579
let consensus_key = VALIDATOR_CONSENSUS_KEY.parse(matches);
1584-
let rewards_account_key = REWARDS_KEY.parse(matches);
15851580
let protocol_key = PROTOCOL_KEY.parse(matches);
15861581
let validator_vp_code_path = VALIDATOR_CODE_PATH.parse(matches);
1587-
let rewards_vp_code_path = REWARDS_CODE_PATH.parse(matches);
15881582
let unsafe_dont_encrypt = UNSAFE_DONT_ENCRYPT.parse(matches);
15891583
Self {
15901584
tx,
15911585
source,
15921586
scheme,
15931587
account_key,
15941588
consensus_key,
1595-
rewards_account_key,
15961589
protocol_key,
15971590
validator_vp_code_path,
1598-
rewards_vp_code_path,
15991591
unsafe_dont_encrypt,
16001592
}
16011593
}
@@ -1617,10 +1609,6 @@ pub mod args {
16171609
"A consensus key for the validator account. A new one \
16181610
will be generated if none given.",
16191611
))
1620-
.arg(REWARDS_KEY.def().about(
1621-
"A public key for the staking reward account. A new one \
1622-
will be generated if none given.",
1623-
))
16241612
.arg(PROTOCOL_KEY.def().about(
16251613
"A public key for signing protocol transactions. A new \
16261614
one will be generated if none given.",
@@ -1630,11 +1618,6 @@ pub mod args {
16301618
for the validator account. Uses the default validator VP \
16311619
if none specified.",
16321620
))
1633-
.arg(REWARDS_CODE_PATH.def().about(
1634-
"The path to the validity predicate WASM code to be used \
1635-
for the staking reward account. Uses the default staking \
1636-
reward VP if none specified.",
1637-
))
16381621
.arg(UNSAFE_DONT_ENCRYPT.def().about(
16391622
"UNSAFE: Do not encrypt the generated keypairs. Do not \
16401623
use this for keys used in a live network.",

apps/src/lib/client/tx.rs

Lines changed: 4 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,8 @@ pub async fn submit_init_validator(
159159
scheme,
160160
account_key,
161161
consensus_key,
162-
rewards_account_key,
163162
protocol_key,
164163
validator_vp_code_path,
165-
rewards_vp_code_path,
166164
unsafe_dont_encrypt,
167165
}: args::TxInitValidator,
168166
) {
@@ -174,7 +172,6 @@ pub async fn submit_init_validator(
174172

175173
let validator_key_alias = format!("{}-key", alias);
176174
let consensus_key_alias = format!("{}-consensus-key", alias);
177-
let rewards_key_alias = format!("{}-rewards-key", alias);
178175
let account_key = ctx.get_opt_cached(&account_key).unwrap_or_else(|| {
179176
println!("Generating validator account key...");
180177
ctx.wallet
@@ -208,18 +205,6 @@ pub async fn submit_init_validator(
208205
.1
209206
});
210207

211-
let rewards_account_key =
212-
ctx.get_opt_cached(&rewards_account_key).unwrap_or_else(|| {
213-
println!("Generating staking reward account key...");
214-
ctx.wallet
215-
.gen_key(
216-
scheme,
217-
Some(rewards_key_alias.clone()),
218-
unsafe_dont_encrypt,
219-
)
220-
.1
221-
.ref_to()
222-
});
223208
let protocol_key = ctx.get_opt_cached(&protocol_key);
224209

225210
if protocol_key.is_none() {
@@ -250,51 +235,24 @@ pub async fn submit_init_validator(
250235
safe_exit(1)
251236
}
252237
}
253-
let rewards_vp_code = rewards_vp_code_path
254-
.map(|path| ctx.read_wasm(path))
255-
.unwrap_or_else(|| ctx.read_wasm(VP_USER_WASM));
256-
// Validate the rewards VP code
257-
if let Err(err) = vm::validate_untrusted_wasm(&rewards_vp_code) {
258-
eprintln!(
259-
"Staking reward account validity predicate code validation failed \
260-
with {}",
261-
err
262-
);
263-
if !tx_args.force {
264-
safe_exit(1)
265-
}
266-
}
267238
let tx_code = ctx.read_wasm(TX_INIT_VALIDATOR_WASM);
268239

269240
let data = InitValidator {
270241
account_key,
271242
consensus_key: consensus_key.ref_to(),
272-
rewards_account_key,
273243
protocol_key,
274244
dkg_key,
275245
validator_vp_code,
276-
rewards_vp_code,
277246
};
278247
let data = data.try_to_vec().expect("Encoding tx data shouldn't fail");
279248
let tx = Tx::new(tx_code, Some(data));
280249
let (mut ctx, initialized_accounts) =
281250
process_tx(ctx, &tx_args, tx, Some(&source)).await;
282251
if !tx_args.dry_run {
283-
let (validator_address_alias, validator_address, rewards_address_alias) =
252+
let (validator_address_alias, validator_address) =
284253
match &initialized_accounts[..] {
285-
// There should be 2 accounts, one for the validator itself, one
286-
// for its staking reward address.
287-
[account_1, account_2] => {
288-
// We need to find out which address is which
289-
let (validator_address, rewards_address) =
290-
if rpc::is_validator(account_1, tx_args.ledger_address)
291-
.await
292-
{
293-
(account_1, account_2)
294-
} else {
295-
(account_2, account_1)
296-
};
297-
254+
// There should be 1 account for the validator itself
255+
[validator_address] => {
298256
let validator_address_alias = match tx_args
299257
.initialized_account_alias
300258
{
@@ -329,23 +287,7 @@ pub async fn submit_init_validator(
329287
validator_address.encode()
330288
);
331289
}
332-
let rewards_address_alias =
333-
format!("{}-rewards", validator_address_alias);
334-
if let Some(new_alias) = ctx.wallet.add_address(
335-
rewards_address_alias.clone(),
336-
rewards_address.clone(),
337-
) {
338-
println!(
339-
"Added alias {} for address {}.",
340-
new_alias,
341-
rewards_address.encode()
342-
);
343-
}
344-
(
345-
validator_address_alias,
346-
validator_address.clone(),
347-
rewards_address_alias,
348-
)
290+
(validator_address_alias, validator_address.clone())
349291
}
350292
_ => {
351293
eprintln!("Expected two accounts to be created");
@@ -366,10 +308,8 @@ pub async fn submit_init_validator(
366308
"The validator's addresses and keys were stored in the wallet:"
367309
);
368310
println!(" Validator address \"{}\"", validator_address_alias);
369-
println!(" Staking reward address \"{}\"", rewards_address_alias);
370311
println!(" Validator account key \"{}\"", validator_key_alias);
371312
println!(" Consensus key \"{}\"", consensus_key_alias);
372-
println!(" Staking reward key \"{}\"", rewards_key_alias);
373313
println!(
374314
"The ledger node has been setup to use this validator's address \
375315
and consensus key."

apps/src/lib/client/utils.rs

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -475,10 +475,7 @@ pub fn init_network(
475475

476476
// Generate account and reward addresses
477477
let address = address::gen_established_address("validator account");
478-
let reward_address =
479-
address::gen_established_address("validator reward account");
480478
config.address = Some(address.to_string());
481-
config.staking_reward_address = Some(reward_address.to_string());
482479

483480
// Generate the consensus, account and reward keys, unless they're
484481
// pre-defined.
@@ -518,24 +515,6 @@ pub fn init_network(
518515
keypair.ref_to()
519516
});
520517

521-
let staking_reward_pk = try_parse_public_key(
522-
format!("validator {name} staking reward key"),
523-
&config.staking_reward_public_key,
524-
)
525-
.unwrap_or_else(|| {
526-
let alias = format!("{}-reward-key", name);
527-
println!(
528-
"Generating validator {} staking reward account key...",
529-
name
530-
);
531-
let (_alias, keypair) = wallet.gen_key(
532-
SchemeType::Ed25519,
533-
Some(alias),
534-
unsafe_dont_encrypt,
535-
);
536-
keypair.ref_to()
537-
});
538-
539518
let protocol_pk = try_parse_public_key(
540519
format!("validator {name} protocol key"),
541520
&config.protocol_public_key,
@@ -583,8 +562,6 @@ pub fn init_network(
583562
Some(genesis_config::HexString(consensus_pk.to_string()));
584563
config.account_public_key =
585564
Some(genesis_config::HexString(account_pk.to_string()));
586-
config.staking_reward_public_key =
587-
Some(genesis_config::HexString(staking_reward_pk.to_string()));
588565

589566
config.protocol_public_key =
590567
Some(genesis_config::HexString(protocol_pk.to_string()));
@@ -593,7 +570,6 @@ pub fn init_network(
593570

594571
// Write keypairs to wallet
595572
wallet.add_address(name.clone(), address);
596-
wallet.add_address(format!("{}-reward", &name), reward_address);
597573

598574
wallet.save().unwrap();
599575
});
@@ -898,9 +874,8 @@ fn init_established_account(
898874
}
899875
}
900876

901-
/// Initialize genesis validator's address, staking reward address,
902-
/// consensus key, validator account key and staking rewards key and use
903-
/// it in the ledger's node.
877+
/// Initialize genesis validator's address, consensus key and validator account
878+
/// key and use it in the ledger's node.
904879
pub fn init_genesis_validator(
905880
global_args: args::Global,
906881
args::InitGenesisValidator {
@@ -940,9 +915,6 @@ pub fn init_genesis_validator(
940915
account_public_key: Some(HexString(
941916
pre_genesis.account_key.ref_to().to_string(),
942917
)),
943-
staking_reward_public_key: Some(HexString(
944-
pre_genesis.rewards_key.ref_to().to_string(),
945-
)),
946918
protocol_public_key: Some(HexString(
947919
pre_genesis
948920
.store

0 commit comments

Comments
 (0)