Skip to content

Commit

Permalink
Merge branch 'develop' into stateful-upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinssgh authored Sep 21, 2023
2 parents a966abb + 4547c2b commit 5e03c66
Show file tree
Hide file tree
Showing 52 changed files with 1,592 additions and 285 deletions.
9 changes: 9 additions & 0 deletions .github/actions/upgrade-testing/create_genesis.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@
genesis = open(os.environ["NEW_GENESIS"], "r").read()
genesis_json_object = json.loads(genesis)

#cut this out for now because it fails to start when done in python with the exact same keys being replaced with same value. Will fix later.
# genesis_json_object["staking"]["params"]["bond_denom"] = "azeta"
# genesis_json_object["crisis"]["constant_fee"]["denom"] = "azeta"
# genesis_json_object["gov"]["deposit_params"]["min_deposit"][0]["denom"] = "azeta"
# genesis_json_object["mint"]["params"]["mint_denom"] = "azeta"
# genesis_json_object["evm"]["params"]["evm_denom"] = "azeta"
# genesis_json_object["block"]["max_gas"] = "10000000"
# genesis_json_object["gov"]["voting_params"]["voting_period"] = '60s'

exported_genesis = open(os.environ["OLD_GENESIS"], "r").read()
exported_genesis_json_object = json.loads(exported_genesis)

Expand Down
49 changes: 49 additions & 0 deletions .github/actions/upgrade-testing/scripts/create_genesis.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import json
import os

print("OPEN NEW GENESIS")
genesis = open(os.environ["NEW_GENESIS"], "r").read()
genesis_json_object = json.loads(genesis)

print("OPEN OLD GENESIS")
exported_genesis = open(os.environ["OLD_GENESIS"], "r").read()
exported_genesis_json_object = json.loads(exported_genesis)

print("PULL STATE OUT OF OLD GENESIS")
crosschain = exported_genesis_json_object["app_state"]["crosschain"]
observer = exported_genesis_json_object["app_state"]["observer"]
emissions = exported_genesis_json_object["app_state"]["emissions"]
fungible = exported_genesis_json_object["app_state"]["fungible"]
evm = exported_genesis_json_object["app_state"]["evm"]
auth_accounts = exported_genesis_json_object["app_state"]["auth"]["accounts"]

print("MANIPULATE NEW GENESIS")
genesis_json_object["app_state"]["auth"]["accounts"] = genesis_json_object["app_state"]["auth"]["accounts"] + auth_accounts
genesis_json_object["app_state"]["crosschain"] = crosschain
genesis_json_object["app_state"]["observer"] = observer
genesis_json_object["app_state"]["emissions"] = emissions
genesis_json_object["app_state"]["fungible"] = fungible

evm_accounts = []
for index, account in enumerate(evm["accounts"]):
if account["address"] == "0x0000000000000000000000000000000000000001":
print("pop account", account["address"])
elif account["address"] == "0x0000000000000000000000000000000000000006":
print("pop account", account["address"])
elif account["address"] == "0x0000000000000000000000000000000000000002":
print("pop account", account["address"])
elif account["address"] == "0x0000000000000000000000000000000000000002":
print("pop account", account["address"])
elif account["address"] == "0x0000000000000000000000000000000000000008":
print("pop account", account["address"])
else:
evm_accounts.append(account)
evm["accounts"] = evm_accounts
genesis_json_object["app_state"]["evm"] = evm

print("WRITE GENESIS-EDITED")
genesis = open("genesis-edited.json", "w")
genesis_string = json.dumps(genesis_json_object, indent=2)
dumped_genesis_object = genesis_string.replace("0x0000000000000000000000000000000000000001","0x387A12B28fe02DcAa467c6a1070D19B82F718Bb5")
genesis.write(genesis_string)
genesis.close()
23 changes: 23 additions & 0 deletions .github/actions/upgrade-testing/scripts/get_proposal_id.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import json
import subprocess
import os

os.environ['NODE'] = "http://127.0.0.1:26657"
def run_command(self, cmd):
COMMAND_PREFIX = "export PATH=" + self.go_path + ":${PATH} && "
cmd = COMMAND_PREFIX + cmd
result = subprocess.run(cmd, stdout=subprocess.PIPE, shell=True)
result_output = result.stdout.decode('utf-8')
return result_output

try:
QUERY_GOV_PROPOSAL = f"""zetacored query gov proposals --output json --node {os.environ['NODE']}"""
GOV_PROPOSALS = json.loads(run_command(QUERY_GOV_PROPOSAL))
for proposal in GOV_PROPOSALS["proposals"]:
try:
PROPOSAL_ID = proposal["id"]
except Exception as e:
print(1)
print(PROPOSAL_ID)
except Exception as e:
print(1)
63 changes: 63 additions & 0 deletions .github/actions/upgrade-testing/scripts/raise_gov_proposal.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import os
import requests
import json

os.environ['NODE'] = "http://127.0.0.1:26657"
CURRENT_HEIGHT = requests.get(f"{os.environ['NODE']}/status").json()["result"]["sync_info"]["latest_block_height"]
UPGRADE_HEIGHT = int(CURRENT_HEIGHT) + (
int(os.environ['PROPOSAL_TIME_SECONDS']) / int(os.environ['BLOCK_TIME_SECONDS'])) + 20
github_file = open(os.environ["GITHUB_ENV"], "a+")
github_file.write(f"UPGRADE_HEIGHT={UPGRADE_HEIGHT}")
github_file.close()

proposal_json = {
"messages": [
{
"@type": "/cosmos.upgrade.v1beta1.MsgSoftwareUpgrade",
"authority": os.environ["GOV_ADDRESS"],
"plan": {
"name": os.environ['VERSION'],
"time": "0001-01-01T00:00:00Z",
"height": str(UPGRADE_HEIGHT).split('.')[0],
"info": os.environ["UPGRADE_INFO"],
"upgraded_client_state": None
}
}
],
"metadata": os.environ["METADATA"],
"deposit": os.environ["DEPOSIT"]
}

proposal_json = json.dumps(proposal_json)
write_gov_json = open("gov.json", "w")
write_gov_json.write(proposal_json)
write_gov_json.close()

GOV_PROPOSAL = f"""zetacored tx gov submit-proposal gov.json \
--from {os.environ['MONIKER']} \
--chain-id "{os.environ['CHAINID']}" \
--keyring-backend test \
--node "{os.environ['NODE']}" \
--gas=auto \
--gas-adjustment=2 \
--gas-prices={os.environ['GAS_PRICES']} \
-y
"""

# GOV_PROPOSAL = f"""zetacored tx gov submit-legacy-proposal software-upgrade "{os.environ['VERSION']}" \
# --from "{os.environ['MONIKER']}" \
# --deposit {os.environ["DEPOSIT"]} \
# --upgrade-height "{str(UPGRADE_HEIGHT).split('.')[0]}" \
# --upgrade-info '{os.environ["UPGRADE_INFO"]}' \
# --title "{os.environ['VERSION']}" \
# --description "Zeta Release {os.environ['VERSION']}" \
# --chain-id "{os.environ['CHAINID']}" \
# --node "{os.environ['NODE']}" \
# --keyring-backend test \
# --gas=auto \
# --gas-adjustment=2 \
# --gas-prices={os.environ['GAS_PRICES']} \
# -y \
# --no-validate"""

print(GOV_PROPOSAL)
1 change: 0 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,6 @@ jobs:
shell: alpine.sh --root {0}
run: |
git config --global --add safe.directory '*'
go mod tidy
make install-testnet
cp "$HOME"/go/bin/* ./
Expand Down
Loading

0 comments on commit 5e03c66

Please sign in to comment.