Skip to content
This repository was archived by the owner on Jun 12, 2023. It is now read-only.

add genesis recreate cli #1467

Merged
merged 1 commit into from
Mar 9, 2022
Merged

add genesis recreate cli #1467

merged 1 commit into from
Mar 9, 2022

Conversation

andymck
Copy link
Contributor

@andymck andymck commented Mar 4, 2022

Adds CLI and associated helper scripts to export the ledger data to a batch of gen txns, which can then be loaded and used as part of an initial dkg. Allows a test network such as testnet to be reset whilst maintaining existing data.

Exported data includes accounts, gateways, validators, oracle price & chainvars.

Tested on a local chain via run.sh

@andymck andymck mentioned this pull request Mar 4, 2022
@andymck andymck force-pushed the andymck/recreate-genesis-cli branch from 8afc5cf to b15584b Compare March 4, 2022 13:14
Addrs = [Addr || Addr <- ValAddrs ],
SortedAddrs = lists:sort(Addrs),
ConsensusAddrs = lists:sublist(SortedAddrs, 1, N),
NewConsensusGroupTxn = blockchain_txn_consensus_group_v1:new(ConsensusAddrs, <<>>, 1, 0),
Copy link
Contributor

Choose a reason for hiding this comment

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

The risk here is that you pick some dead consensus members, how do you boot a chain with this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i could check for liveness based on last heartbeat, exclude any which are not recent from the sorted list

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Another option would be to carry across the existing CG members to the new group

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it'd be better to not include a consensus group txn, and let initial_dkg handle it?

Copy link
Contributor

Choose a reason for hiding this comment

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

Then you could simply boot the chain on the new validators by giving them the exported genesis txns and the initial consensus group members.

Copy link
Contributor

Choose a reason for hiding this comment

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

https://github.com/helium/miner/blob/master/src/miner_consensus_mgr.erl#L947-L958

So really you're not making the genesis block directly, you're making the contents of the genesis block

@andymck andymck force-pushed the andymck/recreate-genesis-cli branch 5 times, most recently from a4ad80b to b1f2e27 Compare March 9, 2022 11:49
" genesis key - create a keypair for use as a master key\n"
" genesis proof <privkey> - create a key proof for adding a master key to the genesis block\n"
" genesis export_ledger <masterkey> <txn_list_output_path> - export data from ledger as a list of txns including accounts, gateways, validators and chainvars\n"
" genesis recreate_ledger <n> <curve> <path_to_txn_list> <addrs> - export data from ledger as a list of txns including accounts, gateways, validators and chainvars\n"
Copy link
Contributor

Choose a reason for hiding this comment

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

This has copied help text from export_ledger

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed here: 1675824

%%
genesis_recreate_ledger_cmd() ->
[
[["genesis", "recreate_ledger", '*', '*'], [], [], fun genesis_recreate_ledger/3]
Copy link
Contributor

Choose a reason for hiding this comment

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

the second form, with 4 arguments isn;t listed here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@andymck andymck force-pushed the andymck/recreate-genesis-cli branch from 22217fc to 9667b7d Compare March 9, 2022 16:51
@Vagabond Vagabond merged commit 2483d3b into master Mar 9, 2022
@Vagabond Vagabond deleted the andymck/recreate-genesis-cli branch March 9, 2022 17:08
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants