Skip to content

Commit

Permalink
add update codebase
Browse files Browse the repository at this point in the history
  • Loading branch information
MasterPi-2124 committed May 16, 2023
1 parent 6960dd5 commit ffc6a02
Show file tree
Hide file tree
Showing 112 changed files with 418 additions and 334 deletions.
24 changes: 16 additions & 8 deletions .github/workflows/upgrades.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ jobs:
id: generate
run: |
jobs="[\"$(echo "$(cat .github/workflows/utility/upgrades/chainsUpgrade.json)" | jq -r 'keys | map(tostring) | join("\", \"")')\"]"
echo $jobs
echo "Found these upgrades: $jobs"
echo "jobs=$jobs" >> $GITHUB_OUTPUT
ahihi:
upgrades:
runs-on: ubuntu-latest
needs: get_upgrades
name: Watching Upgrades
Expand All @@ -50,9 +50,17 @@ jobs:
job-name: ${{ needs.get_upgrades.outputs.chain-jobs && fromJson(needs.get_upgrades.outputs.chain-jobs) }}

steps:
- name: Process Job
run: |
echo "Processing Job ${{ matrix.job-name }}"
sleep 30
echo "Processed Job ${{ matrix.job-name }} Successfully!"
# Perform actions specific to each job
- name: Checkout
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: 3.11

- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
cd .github/workflows/utility/upgrades
python -m pip install requests
59 changes: 28 additions & 31 deletions .github/workflows/utility/upgrades/getUpgrades.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,40 +8,37 @@
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.51 Safari/537.36'
}

chainsData = {}
chainsUpgrade = {}

def getUpgrades():
# chainsFolders = sorted(os.listdir(rootdir))
# for chainfolder in chainsFolders:
# if chainfolder == "microtick": # Microtick doesn't have endpoints
# continue
# chainjson = os.path.join(chainfolder, "chain.json")
# if os.path.isfile(chainjson):
# current = json.load(open(os.path.join(rootdir, chainjson)))
# print(chainfolder)
# rpcs = [items["address"] for items in current["apis"]["rpc"]]
# apis = [items["address"] for items in current["apis"]["rest"]]
# for item in apis:
# try:
# data = requests.get(f"{item}/cosmos/upgrade/v1beta1/current_plan", headers=headers)
# data = data.json()['plan']
# if data != None:
# chainsUpgrade[chainfolder] = {
# "height": int(data["height"]),
# "version": data["name"]
# }
# break
# except Exception as e:
# print(f"Issue with request to {chainfolder}: {e}")
# continue
chainsFolders = sorted(os.listdir(rootdir))
for chainfolder in chainsFolders:
if chainfolder == "microtick": # Microtick doesn't have endpoints
continue
chainjson = os.path.join(chainfolder, "chain.json")
if os.path.isfile(chainjson):
current = json.load(open(os.path.join(rootdir, chainjson)))
print(chainfolder)
rpcs = [items["address"] for items in current["apis"]["rpc"]]
apis = [items["address"] for items in current["apis"]["rest"]]
for item in apis:
try:
data = requests.get(f"{item}/cosmos/upgrade/v1beta1/current_plan", headers=headers)
data = data.json()['plan']
if data != None:
chainsUpgrade[chainfolder] = {
"height": int(data["height"]),
"version": data["name"],
"rpc": rpcs,
"api": apis
}
print(f"Found upgrades for {chainfolder}!")
else:
print(f"No upgrades for {chainfolder}!")
break
except Exception as e:
print(f"Issue with request to {chainfolder}: {e}")
continue

# chainsData[chainfolder] = {
# "rpc": rpcs,
# "api": apis,
# }
# with open(".github/workflows/utility/upgrades/chainsEndpoint.json", "w") as file:
# json.dump(chainsData, file, indent=4)

with open(".github/workflows/utility/upgrades/chainsUpgrade.json", "w") as file:
json.dump(chainsUpgrade, file, indent=4)
65 changes: 65 additions & 0 deletions .github/workflows/utility/upgrades/watchUpgrades.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import requests
import json
import os
import time

rootdir = os.getcwd()
headers = {
'accept': 'application/json',
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.51 Safari/537.36'
}

def getBlock(chain):
with open(".github/workflows/utility/upgrades/chainsUpgrade.json", "r") as file:
data = json.load(file)
chainData = data[chain]
rpcs = chainData["rpc"]
upgradeHeight = chainData["height"]
for item in rpcs:
try:
while True:
data = requests.get(f"{item}/block", headers=headers)
currentHeight = int(data.json()['result']['block']['header']['height'])
if currentHeight < upgradeHeight:
time.sleep(40 * 60)
else:
chainjson = os.path.join(chain, "chain.json")
current = json.load(open(os.path.join(rootdir, chainjson), encoding='utf-8', errors='ignore'))
codebase = current["codebase"]
latestVersion = current["codebase"]["versions"][-1]

for key, value in latestVersion.iteritems():
if key != "name" and key != "height" and key != "proposal" and key != "tag" and key != "next_version_name":
codebase[key] = value

current["codebase"] = codebase

with open(os.path.join(rootdir, chainjson), "w") as file:
json.dump(current, file, indent=2, ensure_ascii=False)
return
except Exception as e:
print(f"Issue with request to {chain}: {e}")
continue

def update_codebase():
chainsFolders = sorted(os.listdir(rootdir))
for chainfolder in chainsFolders:
if chainfolder == "ethos" or chainfolder == "logos" or chainfolder == "mythos" or chainfolder == "octa":
continue
print(chainfolder)
chainjson = os.path.join(chainfolder, "chain.json")
if os.path.isfile(chainjson):
current = json.load(open(os.path.join(rootdir, chainjson), encoding='utf-8', errors='ignore'))
codebase = current["codebase"]
latestVersion = current["codebase"]["versions"][-1]

for key, value in latestVersion.items():
if key != "name" and key != "height" and key != "proposal" and key != "tag" and ke:
codebase[key] = value

current["codebase"] = codebase

with open(os.path.join(rootdir, chainjson), "w") as file:
json.dump(current, file, indent=2, ensure_ascii=False)

update_codebase()
3 changes: 1 addition & 2 deletions 8ball/chain.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@
"address": "rpc.8ball.nodexcapital.com:11056",
"provider": "NodeX Validator"
}

]
},
"apis": {
Expand Down Expand Up @@ -189,4 +188,4 @@
"tx_page": "https://explorer.nodexcapital.com/8ball/tx/${txHash}"
}
]
}
}
3 changes: 1 addition & 2 deletions acrechain/chain.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@
"address": "acrechain-mainnet-seed.autostake.com:26956",
"provider": "AutoStake 🛡️ Slash Protected"
}

],
"persistent_peers": [
{
Expand Down Expand Up @@ -286,4 +285,4 @@
"tx_page": "https://explorer.tcnetwork.io/acre/transaction/${txHash}"
}
]
}
}
2 changes: 1 addition & 1 deletion agoric/chain.json
Original file line number Diff line number Diff line change
Expand Up @@ -198,4 +198,4 @@
"account_page": "https://stakeflow.io/agoric/accounts/${accountAddress}"
}
]
}
}
2 changes: 1 addition & 1 deletion aioz/chain.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,4 +154,4 @@
"tx_page": "https://explorer.aioz.network/tx/${txHash}"
}
]
}
}
2 changes: 1 addition & 1 deletion akash/chain.json
Original file line number Diff line number Diff line change
Expand Up @@ -281,4 +281,4 @@
"account_page": "https://stakeflow.io/akash/accounts/${accountAddress}"
}
]
}
}
2 changes: 1 addition & 1 deletion arkh/chain.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,4 @@
"tx_page": "https://explorer.nodexcapital.com/arkhadian/tx/${txHash}"
}
]
}
}
2 changes: 1 addition & 1 deletion assetmantle/chain.json
Original file line number Diff line number Diff line change
Expand Up @@ -272,4 +272,4 @@
"account_page": "https://bigdipper.live/assetmantle/accounts/${accountAddress}"
}
]
}
}
10 changes: 5 additions & 5 deletions aura/chain.json
Original file line number Diff line number Diff line change
Expand Up @@ -172,14 +172,14 @@
"address": "https://mainnet-aura-api.konsortech.xyz",
"provider": "KonsorTech"
},
{
{
"address": "https://aura-api.tienthuattoan.ventures",
"provider": "TienThuatToan"
},
{
{
"address": "https://aura-api.lavenderfive.com",
"provider": "Lavender.Five Nodes 🐝"
}
}
],
"grpc": [
{
Expand All @@ -202,7 +202,7 @@
"address": "aura.grpc.kjnodes.com:11790",
"provider": "kjnodes"
},
{
{
"address": "aura-grpc.tienthuattoan.ventures:9090",
"provider": "TienThuatToan"
},
Expand Down Expand Up @@ -238,4 +238,4 @@
"account_page": "https://explorer.tcnetwork.io/aura/account/${accountAddress}"
}
]
}
}
2 changes: 1 addition & 1 deletion axelar/chain.json
Original file line number Diff line number Diff line change
Expand Up @@ -312,4 +312,4 @@
"account_page": "https://stakeflow.io/axelar/accounts/${accountAddress}"
}
]
}
}
2 changes: 1 addition & 1 deletion bandchain/chain.json
Original file line number Diff line number Diff line change
Expand Up @@ -184,4 +184,4 @@
"account_page": "https://stakeflow.io/band-protocol/accounts/${accountAddress}"
}
]
}
}
2 changes: 1 addition & 1 deletion beezee/chain.json
Original file line number Diff line number Diff line change
Expand Up @@ -145,4 +145,4 @@
"account_page": "https://atomscan.com/beezee/accounts/${accountAddress}"
}
]
}
}
10 changes: 5 additions & 5 deletions bitcanna/chain.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"fixed_min_gas_price": 0.001,
"low_gas_price": 0.001,
"average_gas_price": 0.0025,
"high_gas_price" :0.01
"high_gas_price": 0.01
}
]
},
Expand Down Expand Up @@ -56,7 +56,7 @@
"v1.6.2",
"v1.6.3"
],
"binaries": {
"binaries": {
"linux/amd64": "https://github.com/BitCannaGlobal/bcna/releases/download/v1.6.3/bcna_linux_amd64.tar.gz",
"darwin/arm64": "https://github.com/BitCannaGlobal/bcna/releases/download/v1.6.3/bcna_darwin_arm64.tar.gz",
"darwin/amd64": "https://github.com/BitCannaGlobal/bcna/releases/download/v1.6.3/bcna_darwin_amd64.tar.gz"
Expand Down Expand Up @@ -178,8 +178,8 @@
{
"address": "http://bitcanna.statesync.nodersteam.com:46657",
"provider": "[NODERS]TEAM"
},
{
},
{
"address": "https://bitcanna.nodejumper.io",
"provider": "NODEJUMPER"
},
Expand Down Expand Up @@ -295,4 +295,4 @@
"account_page": "https://atomscan.com/bitcanna/accounts/${accountAddress}"
}
]
}
}
2 changes: 1 addition & 1 deletion bitsong/chain.json
Original file line number Diff line number Diff line change
Expand Up @@ -209,4 +209,4 @@
"account_page": "https://atomscan.com/bitsong/accounts/${accountAddress}"
}
]
}
}
4 changes: 2 additions & 2 deletions bluzelle/chain.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"genesis_url": "https://a.client.sentry.net.bluzelle.com:26657/genesis"
},
"versions": [
{
{
"name": "v2.0",
"recommended_version": "v2.0",
"compatible_versions": [
Expand Down Expand Up @@ -200,4 +200,4 @@
"gamma4",
"nft"
]
}
}
2 changes: 1 addition & 1 deletion bostrom/chain.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,4 @@
"account_page": "https://atomscan.com/bostrom/accounts/${accountAddress}"
}
]
}
}
2 changes: 1 addition & 1 deletion canto/chain.json
Original file line number Diff line number Diff line change
Expand Up @@ -216,4 +216,4 @@
"tx_page": "https://explorer.tcnetwork.io/canto/transaction/${txHash}"
}
]
}
}
Loading

0 comments on commit ffc6a02

Please sign in to comment.