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

This deployment script should prioritize deploying to mumbai rather than geth. #25

Open
giovanni-pucci opened this issue Jun 13, 2023 · 0 comments

Comments

@giovanni-pucci
Copy link

This deployment script should prioritize deploying to mumbai rather than geth.

Description

This repo is definitely a time saver, we should however prioritize a real use case rather than a sandbox environment.

We are aiming towards an actual deployment on mumbai testnet and polygon mainnet of the v1.0.0 of the polygon-edge client.

I was able to do more than half of the the required changes, but certain use cases may require more than that and I need to figure it out step by step, instead it would be awesome to simply tweak some settings and have it running.

For instance, the --test flag deploys contracts that would ideally already exist or would be manually deployed to mumbai.

I would also suggest that the docs themselves talk more about the steps to take and everything we should have in mind to get this deployment working OOB on a testnet without deploying the geth server.

Code samples

I'll leave this bootstrap script here for some insights on the changes done:

#!/bin/bash -x

main() {

if [[ -d "/var/lib/bootstrap" ]]; then
	echo "It appears this network has already been boot strapped"
	exit
fi

mkdir /var/lib/bootstrap
pushd /var/lib/bootstrap

{% for item in hostvars %}
{% if (hostvars[item].tags.Role == "fullnode" or hostvars[item].tags.Role == "validator") %}
polygon-edge polybft-secrets --data-dir {{ hostvars[item].tags["Name"] }} \
	--json \
	--insecure > {{ hostvars[item].tags["Name"] }}.json
{% endif %}
{% endfor %}

polygon-edge genesis \
	--consensus polybft \
	{% for item in hostvars %}{% if (hostvars[item].tags.Role == "fullnode" or hostvars[item].tags.Role == "validator") %} --bootnode /dns4/{{ hostvars[item].tags["Name"] }}/tcp/{{ edge_p2p_port }}/p2p/$(cat {{ hostvars[item].tags["Name"] }}.json | jq -r '.[0].node_id') {% endif %}{% endfor %} \
	{% for item in hostvars %}{% if (hostvars[item].tags.Role == "fullnode" or hostvars[item].tags.Role == "validator") %} --premine $(cat {{ hostvars[item].tags["Name"] }}.json | jq -r '.[0].address'):1000000000000000000000000 {% endif %}{% endfor %} \
	{% for item in hostvars %}
	{% if (hostvars[item].tags.Hostname == "validator-001") %}
	--reward-wallet $(cat {{ hostvars[item].tags["Name"] }}.json | jq -r '.[0].address'):1000000000000000000000000000 \
	{% endif %}
	{% endfor %}
  --premine {{ loadtest_account }}:1000000000000000000000000000 \
	--premine {{ bridge_account }}:1000000000000000000000000000 \
	--block-gas-limit {{ block_gas_limit }} --block-time {{ block_time }}s \
  {% for item in hostvars %}{% if (hostvars[item].tags.Role == "validator") %} --validators /dns4/{{ hostvars[item].tags["Name"] }}/tcp/{{ edge_p2p_port }}/p2p/$(cat {{ hostvars[item].tags["Name"] }}.json | jq -r '.[0].node_id'):$(cat {{ hostvars[item].tags["Name"] }}.json | jq -r '.[0].address' | sed 's/^0x//'):$(cat {{ hostvars[item].tags["Name"] }}.json | jq -r '.[0].bls_pubkey') {% endif %}{% endfor %} \
  --epoch-size 10 \
	--transactions-allow-list-admin {{ loadtest_account }},$(cat validator-*.json | jq -r ".[].address" | tr "\n" ",") \
	--transactions-allow-list-enabled {{ loadtest_account }},{{ bridge_account }},$(cat validator-*.json | jq -r ".[].address" | tr "\n" ",") \
	--contract-deployer-allow-list-admin {{ loadtest_account }},$(cat validator-*.json | jq -r ".[].address" | tr "\n" ",") \
  --contract-deployer-allow-list-enabled {{ loadtest_account }},{{ bridge_account }},$(cat validator-*.json | jq -r ".[].address" | tr "\n" ",") \
	--native-token-config "My Token:MTK:8:true" \
	--chain-id 2007

{% for item in hostvars %}
{% if (hostvars[item].tags.Role == "validator") %}

cast send --rpc-url {{ rootchain_json_rpc }} --from {{ loadtest_account }} --private-key {{ deployer_key }} --value 0.02ether $(cat {{ hostvars[item].tags["Name"] }}.json | jq -r '.[0].address')

{% endif %}
{% endfor %}

polygon-edge polybft stake-manager-deploy \
	--jsonrpc {{ rootchain_json_rpc }} \
	--private-key {{ deployer_key }} \
	--genesis ./genesis.json \
	--stake-token 0x0e698696674eabb217457ecebce36c2a8777f531

polygon-edge rootchain deploy \
	--deployer-key {{ deployer_key }} \
	--json-rpc {{ rootchain_json_rpc }} \
	--genesis ./genesis.json \
	--stake-manager $(cat genesis.json | jq -r '.params.engine.polybft.bridge.stakeManagerAddr') \
	--stake-token $(cat genesis.json | jq -r '.params.engine.polybft.bridge.stakeTokenAddr')

polygon-edge polybft whitelist-validators \
	--private-key {{ deployer_key }} \
	--addresses $(cat validator-*.json | jq -r ".[].address" | tr "\n" ",") \
	--supernet-manager $(cat genesis.json | jq -r '.params.engine.polybft.bridge.customSupernetManagerAddr') \
	--json-rpc {{ rootchain_json_rpc }}

{% for item in hostvars %}
{% if (hostvars[item].tags.Role == "validator") %}

polygon-edge polybft register-validator --data-dir {{ hostvars[item].tags["Name"] }} \
	--supernet-manager $(cat genesis.json | jq -r '.params.engine.polybft.bridge.customSupernetManagerAddr') \
	--json-rpc {{ rootchain_json_rpc }}

{% endif %}
{% endfor %}

{% for item in hostvars %}
{% if (hostvars[item].tags.Role == "validator") %}
polygon-edge polybft stake --data-dir {{ hostvars[item].tags["Name"] }} \
	--chain-id $(cat genesis.json | jq -r '.params.engine.polybft.bridge.supernetID') \
	--amount 10 \
	--stake-manager $(cat genesis.json | jq -r '.params.engine.polybft.bridge.stakeManagerAddr') \
	--stake-token $(cat genesis.json | jq -r '.params.engine.polybft.bridge.stakeTokenAddr') \
	--jsonrpc {{ rootchain_json_rpc }}
{% endif %}
{% endfor %}

polygon-edge polybft supernet --private-key {{ deployer_key }} \
	--supernet-manager $(cat genesis.json | jq -r '.params.engine.polybft.bridge.customSupernetManagerAddr') \
	--stake-manager $(cat genesis.json | jq -r '.params.engine.polybft.bridge.stakeManagerAddr') \
	--finalize-genesis-set --enable-staking \
	--jsonrpc {{ rootchain_json_rpc }}

tar czf {{ base_dn }}.tar.gz *.json *.private genesis.json
popd

}

main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant