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

Feature : add a new cli 'wallet convert' command for coverting tendermnint key json file #2516

Merged

Conversation

Jeongseup
Copy link
Contributor

@Jeongseup Jeongseup commented Feb 5, 2024

Describe your changes

I made a new cli command for namadw caused by #2515

Usage: namadaw [OPTIONS] <COMMAND>

### Sample
Commands:
  gen               Generates a new transparent / shielded secret key.
  derive            Derive transparent / shielded key from the mnemonic code or a seed stored on the hardware wallet device.
  gen-payment-addr  Generates a payment address from the given spending key.
  list              List known keys and addresses in the wallet.
  find              Find known keys and addresses in the wallet.
  export            Exports a transparent keypair / shielded spending key to a file.
  convert           Convert to tendermint priv_validator_key.json with your consensus key alias
  import            Imports a transparent keypair / shielded spending key from a file.
  add               Adds the given key or address to the wallet.
  remove            Remove the given alias and all associated keys / addresses from the wallet.
  help              Print this message or the help of the given subcommand(s)

How to use

  1. submit change consensus key transaction by using namadac
namada client change-consensus-key  \
	--validator <your validator address> \
	--signing-keys <your validator account key name> 
        # Add options whatever you want
  1. you can check created a new consensus key in wallet.toml
  Alias "validator-0-consensus-key-1" (encrypted):
    Public key hash: F1E5244875BAB4D5BDBFCDE1EC9862DF3DEC2478
    Public key: tpknam1qqv7xw0wad4v4vk6lyv0ft8hmandffwzeru3khrdvgesye7tjsy3vd2c636
  1. By protocol parameter, the consensus key which connected at your validator will be changed to by this new key after a few epochs(pipeline length)

  2. convert a key for generating priv_validator_key.json

namadaw convert --alias "validator-0-consensus-key-1"

you can see priv_validator_key.json_ file

  1. replace cometbft/config/priv_validator_key.json with it

  2. you can check tendermint address with both a new priv_validator_key.json address and find-validator command

Improvement plan

I'm not sure. Other validators would want to use this feature. Please any comments for improvement validators UX

Indicate on which release or other PRs this topic is based on

Checklist before merging to draft

  • I have added a changelog
  • Git history is in acceptable state

Connected Issue

tzemanovic
tzemanovic previously approved these changes Feb 6, 2024
Copy link
Member

@tzemanovic tzemanovic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks fine, thank you! (it just needs to be formatted to pass CI but we can be do that on merge)

@tzemanovic tzemanovic mentioned this pull request Feb 6, 2024
@brentstone brentstone mentioned this pull request Feb 8, 2024
This was referenced Feb 9, 2024
tzemanovic added a commit that referenced this pull request Feb 15, 2024
* jeongseup/add-consensus-key-to-tendermint-key:
  changelog: add #2516
  make fmt
  Add a new cli 'wallet convert' for coverting tendermnint key json file with consesus key in wallet.toml
tzemanovic added a commit that referenced this pull request Feb 15, 2024
* jeongseup/add-consensus-key-to-tendermint-key:
  changelog: add #2516
  make fmt
  Add a new cli 'wallet convert' for coverting tendermnint key json file with consesus key in wallet.toml
let mut wallet = load_wallet(ctx);
let sk = wallet.find_secret_key(&alias, None);
let key: serde_json::Value = validator_key_to_json(&sk.unwrap()).unwrap();
let file_name = format!("priv_validator_key.json_{}", alias);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it intended that the file will looks like priv_validator_key.json_alias rather than priv_validator_key_alias.json or smth similar?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I modify the code about that?

@Liver-23
Copy link
Contributor

Just to share my experience with the "covert" command from this PR.

so, did everything, and it works, I started to sign blocks with the new priv_validator_key created from the new consensus key
Some notes:

  • convert command creates a new pri_validator_key with a new name, so the original one will not be occasionally overwritten
  • once the file is ready, just put it in instead of the old one and restart
    result: my val started to sign block immediately after the restart

@Liver-23
Copy link
Contributor

Liver-23 commented Feb 16, 2024

Adding as a separate comment, unjail is failing with the following after that, it looks like something is not processed and now I can't sign unjail command

namadac unjail-validator --validator liveraven
Looking-up public key of tnam1qxzx92ztwjmtka0mdfd60wn7ejcljgx6sqe4800u from the ledger...
Enter your decryption password: 
Transaction added to mempool.
Wrapper transaction hash: 74012C8324BD93EA7BAF94BE705E12D67408E51138ED205287BC06B7BB0D42D1
Inner transaction hash: 1FA46FEE07EFB433CD453D53CAD1CCF62B1293175F2390A2678441E8760B9E76
Wrapper transaction accepted at height 29232. Used 21 gas.
Waiting for inner transaction result...
Transaction failed.
Details: {
  "inner_tx": null,
  "info": "Error trying to apply a transaction: Transaction runner error: Failed running wasm with: RuntimeError: unreachable\n    at <unnamed> (<module>[795]:0x6c10c)\n    at <unnamed> (<module>[90]:0x1eff6)\n    at <unnamed> (<module>[84]:0x1ec6a)\n    at <unnamed> (<module>[16]:0x13688)\n    at <unnamed> (<module>[830]:0x6d560)",
  "log": "",
  "height": 29233,
  "hash": "1FA46FEE07EFB433CD453D53CAD1CCF62B1293175F2390A2678441E8760B9E76",
  "code": "WasmRuntimeError",
  "gas_used": "4031"
}

Filed as #2640

@spidey-169
Copy link

Adding my experience using this as well here. Basically the namadaw convert NEW_CONSENSUS-KEY generates a priv_validator_key.json correctly. However, when I replace and try unjaining my validator, its gives Rejected by VPs errpr. Described in #2642

@Jeongseup
Copy link
Contributor Author

Jeongseup commented Feb 21, 2024

@brentstone I modified saved file name format as you said. Please check a new commit

--- a/crates/apps/src/lib/cli/wallet.rs
+++ b/crates/apps/src/lib/cli/wallet.rs
@@ -1257,7 +1257,7 @@ fn key_convert(
     let mut wallet = load_wallet(ctx);
     let sk = wallet.find_secret_key(&alias, None);
     let key: serde_json::Value = validator_key_to_json(&sk.unwrap()).unwrap();
-    let file_name = format!("priv_validator_key.json_{}", alias);
+    let file_name = format!("priv_validator_key_{}.json", alias);
     let file = File::create(&file_name).unwrap();
     serde_json::to_writer_pretty(file, &key).unwrap_or_else(|err| {
         edisplay_line!(io, "{}", err);

@tzemanovic tzemanovic merged commit 4d02192 into anoma:main Feb 22, 2024
13 of 15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants