forked from sei-protocol/testnet
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix gentx scripts * fixes * rm send enabled deprecated * more fixes - timestamp and create val * Revert "rm send enabled deprecated" This reverts commit 46a6adf. * Revert "more fixes - timestamp and create val" This reverts commit 85c07c8. * set max gas
- Loading branch information
1 parent
c2ccc0a
commit 6da073f
Showing
7 changed files
with
112 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
from operator import ge | ||
import argparse | ||
import os | ||
import json | ||
import shutil | ||
from pathlib import Path | ||
|
||
''' | ||
Resets the genesis.json file to the default values & clears all balances / accounts | ||
Then will generate all the commands to add balances for all gentxs | ||
Assumes you've already run confirm-gen-txs.py | ||
''' | ||
|
||
EXP_SEND = [{"denom": "usei","enabled": True}] | ||
|
||
def main(chain_id, home_dir, initial_balance): | ||
reset_genesis_file(chain_id, home_dir) | ||
create_genesis_account_cmds(initial_balance) | ||
copy_gentx_folder(chain_id, home_dir) | ||
|
||
def reset_genesis_file(chain_id, home_dir): | ||
genesis_file = home_dir + "/config/genesis.json" | ||
# load genesis.json & remove all values for accounts & supply | ||
with open(genesis_file) as f: | ||
genesis = json.load(f) | ||
genesis["chain_id"] = str(chain_id) | ||
|
||
genesis["app_state"]['auth']["accounts"] = [] | ||
genesis["app_state"]['bank']["balances"] = [] | ||
genesis["app_state"]['bank']["supply"] = [] | ||
genesis["app_state"]['bank']["params"]["send_enabled"] = EXP_SEND | ||
|
||
genesis["app_state"]['genutil']["gen_txs"] = [] | ||
|
||
# save genesis.json | ||
with open(genesis_file, 'w') as f: | ||
json.dump(genesis, f, indent=4) | ||
print(f"# RESET: {genesis_file}\n") | ||
|
||
|
||
def create_genesis_account_cmds(initial_balance): | ||
print("-- Run the following commands to create genesis accounts --") | ||
with open('gentx-output.csv') as f: | ||
for line in f: | ||
validator_address = line.split(',')[0] | ||
print(f"seid add-genesis-account {validator_address} {initial_balance}") | ||
|
||
print("--- Run the following commands to create genesis accounts ---") | ||
|
||
def copy_gentx_folder(chain_id, home_dir): | ||
shutil.copytree(chain_id + "/gentx", home_dir + "/config/gentx") | ||
print(f"gentx folder copied to {home_dir}/config/gentx") | ||
print("--- Run the following command to create validators ---") | ||
print("seid collect-gentxs") | ||
|
||
if __name__ == "__main__": | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument('--chain-id', type=str) | ||
parser.add_argument('--home-dir', type=str) | ||
parser.add_argument('--initial-balance', type=str) | ||
args = parser.parse_args() | ||
assert (args.initial_balance[-4:] == 'usei') | ||
main(args.chain_id, args.home_dir, args.initial_balance) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import argparse | ||
import os | ||
import json | ||
|
||
""" | ||
Script to generate a CSV file of $wallet_address,$validator_address,$moniker | ||
Assumes that the file structure of the gentx files is: $chain_id/gentx/... | ||
""" | ||
def main(chain_id): | ||
# get all files within the gentx folder | ||
gentx_files = os.listdir(chain_id + "/gentx") | ||
|
||
invalids = "" | ||
|
||
with open('gentx-output.csv', 'w') as outfile: | ||
outfile.write("") # clean file | ||
|
||
for file in gentx_files: | ||
print(f'Extracting info from {file}') | ||
f = open(chain_id + '/gentx/' + file, 'r') | ||
data = json.load(f) | ||
|
||
validatorData = data['body']['messages'][0] | ||
moniker = validatorData['description']['moniker'] | ||
rate = float(validatorData['commission']['rate']) * 100 | ||
delegator_addr = validatorData['delegator_address'] | ||
validator_addr = validatorData['validator_address'] | ||
exp = validatorData['value'] | ||
### Basic validation ### | ||
if exp['denom'] != 'usei': | ||
invalids += f'[!] Invalid denomination for validator: {moniker} {exp["denom"]} \n' | ||
|
||
if int(exp['amount'] ) /10000000 != 1.0: | ||
invalids += f'[!] Invalid amount for validator: {moniker} {int(exp["amount"] ) /10000000}\n' | ||
|
||
with open('gentx-output.csv', 'a') as outfile: | ||
outfile.write(f"{delegator_addr},{validator_addr},{moniker}\n") | ||
|
||
with open('gentx-output.csv', 'a') as outfile: | ||
outfile.write(invalids) | ||
|
||
print('Written to file gentx-output.csv') | ||
|
||
if __name__ == "__main__": | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument('--chain-id', type=str) | ||
args = parser.parse_args() | ||
main(args.chain_id) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.