Unverified Commit b2de5607 authored by Adam Tucker's avatar Adam Tucker Committed by GitHub
Browse files

Testnetify Improvements (#858)

* add votingperiod change, auto module account fix

* further automated dist module account fix, added changed to md
parent 2505e1ae
Showing with 42 additions and 73 deletions
+42 -73
# Testnetify.py
This script takes a state export JSON file (under the name testnet_genesis.json) and edits multiple values to give the operator address 1M spendable OSMO, makes your validator file possess over 1M OSMO, and makes the epoch duration 3600s.
This script takes a state export JSON file (under the name testnet_genesis.json) and edits multiple values to give the operator address 1M spendable OSMO, makes your validator file possess over 1M OSMO, makes the epoch duration 21600s, and sets the voting period to 180s.
## Instructions
......@@ -22,7 +22,9 @@ cp $HOME/testnet_genesis.json $HOME/testnet_genesis_bk.json
NOTE: There are three values in the python script you can change.
1. The operator address (op_address) and its corresponding public key (op_pubkey). I provided the mnemonic for the provided address (osmo12smx2wdlyttvyzvzg54y2vnqwq2qjateuf7thj), but you may change the address and corresponding pubkey if desired
2. The chain-id (new_chain_id)
3. The config.toml file location (at the very end of the script, change the path if its somewhere other than $HOME/.osmosisd/config)
3. The epoch duration (new_duration)
4. The voting period (new_voting_period)
5. The distribution module account currently must be subtracted by 3 due to a bug. If the account gets offset further, you must change dist_offset_amt
Mnemonic for provided address:
**bottom loan skill merry east cradle onion journey palm apology verb edit desert impose absurd oil bubble sweet glove shallow size build burst effort**
......@@ -51,7 +53,7 @@ After initializing, you will get a "couldn't connect to any seeds" error. Leave
Set up a second node with the same genesis.json file that was created using the first node.
On the first node, retrieve its public IP and also run this command to get your node ID
```sh
......@@ -67,14 +69,14 @@ node-id@IP:26656
Example: 665ebb897edc41d691c70b15916086a9c7761dc4@199.43.113.117:26656
On the second node, start the osmosis daemon
On the second node, ensure the genesis file is replaced with the genesis created on the first node and start the osmosis daemon
```sh
osmosisd start --x-crisis-skip-assert-invariants
```
Once the second peer initializes, the chain will no longer be halted
Once the second peer initializes, the chain will no longer be halted
(this is necessary due to a tendermint bug). The second peer can then be shut off if desired. If the first peer ever shuts down, the second peer must be started in order to kickstart the chain again.
As a last note, sometimes getting testnet nodes spun up for the first time can be finicky. If you are stuck getting the second node to connect to the first node, sometimes doing a `unsafe-reset-all` on both nodes fixes the issue. Also, try adding the second node as a persistent peer to the first node. These two methods have fixed nodes that do not want to cooperate. Lastly, if your node keeps killing the daemon, please ensure you have a swap file set up.
As a last note, sometimes getting testnet nodes spun up for the first time can be finicky. If you are stuck getting the second node to connect to the first node, sometimes doing a `unsafe-reset-all` on both nodes fixes the issue. Also, try adding the second node as a persistent peer to the first node. These two methods have fixed nodes that do not want to cooperate. Lastly, if your node keeps killing the daemon, please ensure you have a swap file set up.
Enjoy your state exported testnet!
\ No newline at end of file
......@@ -34,11 +34,13 @@ final_address = bech32_convert.stderr[:bech32_convert.stderr.find("\n")]
#own opp address
#exchange the op_address and op_pubkey with own address and pubkey or use above mnemonic for following address
#bottom loan skill merry east cradle onion journey palm apology verb edit desert impose absurd oil bubble sweet glove shallow size build burst effort
#CAN MODIFY
op_address = "osmo12smx2wdlyttvyzvzg54y2vnqwq2qjateuf7thj"
#own pub key
#op_base64_pre = subprocess.run(["osmosisd","query", "auth", "account", op_address], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
#op_pubkey = op_base64_pre.stdout[op_base64_pre.stdout.find("key: ")+5:op_base64_pre.stdout.find("sequence")-1]
#CAN MODIFY
op_pubkey = "A2MR6q+pOpLtdxh0tHHe2JrEY2KOcvRogtLxHDHzJvOh"
def sed_inplace(filename, pattern, repl):
......@@ -96,7 +98,6 @@ sed_inplace("testnet_genesis.json", "AqlNb1FM8veQrT4/apR5B3hww8VApc0LTtZnXhq7FqG
#open genesis json file with read write priv, load json
test_gen = open("testnet_genesis.json", "r+")
read_test_gen = json.loads(test_gen.read())
......@@ -105,7 +106,8 @@ read_test_gen = json.loads(test_gen.read())
#change chain-id
print("Current chain-id is " + read_test_gen['chain_id'])
new_chain_id = "czar-test-1"
#CAN MODIFY
new_chain_id = "osmo-test-2"
read_test_gen['chain_id'] = new_chain_id
print("New chain-id is " + read_test_gen['chain_id'])
......@@ -136,10 +138,18 @@ val_list_2_index = [i for i, elem in enumerate(val_list_2) if 'Sentinel' in elem
val_list_2[val_list_2_index]['pub_key']['value'] = val_pubkey
#distribution module fix
dist_address = "osmo1jv65s3grqf6v6jl3dp4t6c9t9rk99cd80yhvld"
app_state_balances_list = read_test_gen['app_state']['bank']['balances']
dist_index = [i for i, elem in enumerate(app_state_balances_list) if dist_address in elem['address']][0]
dist_all = app_state_balances_list[dist_index]['coins']
osmo_index = [i for i, elem in enumerate(dist_all) if 'uosmo' in elem['denom']][0]
current_dist_osmo_bal = dist_all[osmo_index]['amount']
dist_offset_amt = 3
print("Current distribution account uosmo balance is " + current_dist_osmo_bal)
new_dist_osmo_bal = str(int(current_dist_osmo_bal) - dist_offset_amt)
print("New distribution account uosmo balance is " + new_dist_osmo_bal)
dist_all[osmo_index]['amount'] = new_dist_osmo_bal
#change self delegation amount on operator address
......@@ -165,15 +175,6 @@ print("New stake is " + new_stake)
app_state_dist_list[dist_index]['starting_info']['stake'] = new_stake
#get index of val power
val_power_list = read_test_gen['validators']
val_power_index = [i for i, elem in enumerate(val_power_list) if 'Sentinel' in elem['name']][0]
......@@ -193,12 +194,6 @@ print("New validator power in second location is " + new_val_power)
read_test_gen['app_state']['staking']['last_validator_powers'][last_val_power_index]['power'] = new_val_power
#update last_total_power (last total bonded across all validators, add 1BN)
last_total_power = int(read_test_gen['app_state']['staking']['last_total_power'])
print("Current last total power is " + str(last_total_power))
......@@ -207,14 +202,6 @@ print("New last total power is " + new_last_total_power)
read_test_gen['app_state']['staking']['last_total_power'] = new_last_total_power
#update operator address amount (add 1 BN)
#find wallet index in bank balance
bank_balance_list = read_test_gen['app_state']['bank']['balances']
......@@ -230,11 +217,6 @@ print("New operator address uosmo balance is " + new_op_uosmo)
op_wallet[op_uosmo_index]['amount'] = new_op_uosmo
#update total OSMO supply (add 2 BN)
#supply list (ibc, ion, osmo)
supply = read_test_gen['app_state']['bank']['supply']
......@@ -247,20 +229,12 @@ osmo_supply = supply[osmo_index]['amount']
print("Current OSMO supply is " + osmo_supply)
#update osmo supply to new total osmo value (add 2 Billion OSMO)
osmo_supply_new = int(osmo_supply) + 2000000000000000
#subtract by however much module account is subtracted by
osmo_supply_new = int(osmo_supply) + 2000000000000000 - dist_offset_amt
print("New OSMO supply is " + str(osmo_supply_new))
supply[osmo_index]['amount'] = str(osmo_supply_new)
#update bonded_tokens_pool module balance osmo1fl48vsnmsdzcv85q5d2q4z5ajdha8yu3aq6l09 (add 1BN)
#get list of bank balances
bank_bal_list = read_test_gen['app_state']['bank']['balances']
......@@ -271,24 +245,20 @@ module_denom_list = bank_bal_list[module_acct_index]['coins']
osmo_bal_index = [i for i, elem in enumerate(module_denom_list) if 'uosmo' in elem['denom']][0]
osmo_bal = bank_bal_list[module_acct_index]['coins'][osmo_bal_index]['amount']
print("Current bonded tokens pool module account balance is " + osmo_bal)
#increase by 1BN
#increase by 1BN
new_osmo_bal = int(osmo_bal) + 1000000000000000
print("New bonded tokens pool module account balance is " + str(new_osmo_bal))
bank_bal_list[module_acct_index]['coins'][osmo_bal_index]['amount'] = str(new_osmo_bal)
#edit gov params
#change epoch duration to 3600s
#edit epoch params
#change epoch duration to 21600s
epochs_list = read_test_gen['app_state']['epochs']['epochs'][0]
duration_current = epochs_list['duration']
print("Current epoch durtaion is " + duration_current)
new_duration = '3600s'
print("Current epoch duration is " + duration_current)
#21600s for 6 hour epoch
#CAN MODIFY
new_duration = '21600s'
print("New epoch duration is " + new_duration)
epochs_list['duration'] = new_duration
......@@ -304,10 +274,15 @@ epochs_list['current_epoch_start_time'] = start_time_new
print("New epoch start time is " + start_time_new)
#edit gov params
#change VotingPeriod
current_voting_period = read_test_gen['app_state']['gov']['voting_params']['voting_period']
print("Current voting period is " + current_voting_period)
#180s for 3 minute voting period
#CAN MODIFY
new_voting_period = "180s"
print("New voting period is " + new_voting_period)
read_test_gen['app_state']['gov']['voting_params']['voting_period'] = new_voting_period
print("Please wait while file writes over itself, this may take 60 seconds or more")
......@@ -317,11 +292,3 @@ json.dump(read_test_gen, test_gen)
#delete remainder in case new data is shorter than old
test_gen.truncate()
#tendermint peer bug fix
HOME = subprocess.run(["echo $HOME"], capture_output=True, shell=True, text=True)
os.chdir(os.path.expanduser(HOME.stdout.strip()+'/.osmosisd/config'))
print("Changing fast sync mode from 'true' to 'false'")
sed_inplace("config.toml", "fast_sync = true", "fast_sync = false")
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment