Skip to content
Open
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
7 changes: 7 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
TF_VAR_deployment_name="devnet13"
TF_VAR_company_name="othentic"
TF_VAR_owner="[email protected]"
TF_LOG="DEBUG"
TF_LOG_PATH="terraform.log"
TF_VAR_fullnode_count=0
AWS_REGION=us-east-1
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
.DS_Store
private.env
*.key
*.pem
*.pem
output.txt
/.terraform
.terraform.lock.hcl
34 changes: 24 additions & 10 deletions ansible/group_vars/all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ clean_deploy_title: devnet13
#### Genesis Flags ###
block_gas_limit: 50_000_000
block_time: 5
chain_id: 100
chain_id: 88989

### Version Flags ###
polycli_tag: 0.1.30 # https://github.com/maticnetwork/polygon-cli/releases
Expand All @@ -14,10 +14,10 @@ go_tag: 1.20.7.linux-amd64

### FUNDING ACCOUNTS ###
## this is the amount of value that will be transfered on the rootchain to the deployer address and the validators
rootchain_stake_token_fund_amount: 1000ether
rootchain_deployer_fund_amount: 10000000ether
rootchain_validator_fund_amount: 100ether
rootchain_validator_convert_amount_ether: 100
rootchain_stake_token_fund_amount: 1ether
rootchain_deployer_fund_amount: 6ether
rootchain_validator_fund_amount: 1ether
rootchain_validator_convert_amount_ether: 0.1
## smaller values for rootchain (testnets)
# rootchain_stake_token_fund_amount: 10ether
# rootchain_deployer_fund_amount: 10ether
Expand All @@ -26,7 +26,7 @@ rootchain_validator_convert_amount_ether: 100

### ROOTCHAIN ###
## this is the rpc url that will be used for the root chain
rootchain_json_rpc: http://geth-001:8545
rootchain_json_rpc: http://10.10.67.79:8545
# rootchain_json_rpc: https://polygon-mumbai.g.alchemy.com/v2/xxx
# rootchain_json_rpc: https://matic-mumbai.chainstacklabs.com

Expand All @@ -39,21 +39,21 @@ fund_rootchain_coinbase: true

## If the L1 is NOT an unlocked test account, then you'll need some wallet
# for funding validators. The address and private key here are used for this purpose
rootchain_coinbase_address: "0xREPLACE_WITH_ETH_ADDRESS"
rootchain_coinbase_private_key: "REPLACE_WITH_PRIVATE_KEY"
rootchain_coinbase_address: "0xA8A4f31fF1445dA283aC3624430c954A13D4675d"
rootchain_coinbase_private_key: "5bb82c5bd87bdef1c1262ea18f51eb60a99af46519b477c09e933b72995f8b74"
### ROOTCHAIN ###

### STAKE TOKEN ###
# enter "stake_token_address" if you are using a pre-existing rootchain, and already have deployed a stake token contract
# "stake_token_address" is only read when "is_deploy_stake_token_erc20: true"
stake_token_address: "0x5d732A66f1F2FB8A7A284AF5B35e043D1f0B0985"
stake_token_address: "0xd9b2df73f87719f986fbbe4b956c1331d84389e9"
is_stake_token_erc_20: true
is_deploy_stake_token_erc20: true

### NATIVE TOKEN ###
## mintable=false: non child-chain mintable native token: Supernets native token is configured to be the child token of already existing token on the rootchain, meaning that its supply originates from bridging the rootchain token
## mintable=true: child chain mintable native token: its supply is managed straight on the Supernets, without bridging some existing rootchain token
native_token_config: MyToken:MTK:18:true # configuration of native token in format <name:symbol:decimals count:mintable flag>
native_token_config: OthStakeToken:OTSTK:18:true # configuration of native token in format <name:symbol:decimals count:mintable flag>

### Infra/Ansible Flags ###
ansible_ssh_private_key_file: ~/devnet_private.key
Expand Down Expand Up @@ -97,3 +97,17 @@ geth_http_port: 8545
geth_miner_mnemonic: code code code code code code code code code code code quality
geth_chain_id: 1001
geth_p2p_port: 30303

### GETH vars ###
execution_client: "geth"
network: "holesky"
ethereum_dir: "/usr/local/bin"
consensus_dir: "{{ ethereum_dir }}/consensus"
execution_dir: "{{ ethereum_dir }}/execution"
jwt_path: "{{ execution_dir }}/jwtsecret"
prysm_url: "https://raw.githubusercontent.com/prysmaticlabs/prysm/master/prysm.sh"
geth_latest_release_url: "https://api.github.com/repos/ethereum/go-ethereum/releases/latest"
geth_commit_url: "https://api.github.com/repos/ethereum/go-ethereum/git/refs/tags"
geth_store_base_url: "https://gethstore.blob.core.windows.net/builds"
checkpoint_sync_url: "https://holesky.beaconstate.info"
genesis_beacon_api_url: "https://holesky.beaconstate.info"
4 changes: 2 additions & 2 deletions ansible/inventory/aws_ec2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
plugin: amazon.aws.aws_ec2

regions:
- eu-west-1
- us-east-1

keyed_groups:
- key: tags.Role
Expand All @@ -19,7 +19,7 @@ leading_separator: "no"
cache: "yes"

filters:
tag:BaseDN: "devnet13.edge.company.private"
tag:BaseDN: "devnet13.edge.othentic.private"

hostnames:
- instance-id
140 changes: 140 additions & 0 deletions ansible/roles/edge/files/bootstrap_bash.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
#!/bin/bash -x

# Set environment variables
export CLEAN_DEPLOY_TITLE="devnet13"
export BLOCK_GAS_LIMIT=50000000
export BLOCK_TIME=5s
export CHAIN
export POLYCLI_TAG="0.1.30"
export EDGE_TAG="761bc2231156ffa1445eb85cbdefec1a87544f65"
export GETH_TAG="v1.12.0"
export GO_TAG="1.20.7.linux-amd64"
export ROOTCHAIN_STAKE_TOKEN_FUND_AMOUNT="2ether"
export ROOTCHAIN_DEPLOYER_FUND_AMOUNT="10ether"
export ROOTCHAIN_VALIDATOR_FUND_AMOUNT="2ether"
export ROOTCHAIN_VALIDATOR_CONVERT_AMOUNT_ETHER="1ether"
export ROOTCHAIN_JSON_RPC="https://holesky.infura.io/v3/39bbce1963cb476aab6d41fdd4303985"
export FUND_ROOTCHAIN_COINBASE=false
export ROOTCHAIN_COINBASE_ADDRESS="0xA8A4f31fF1445dA283aC3624430c954A13D4675d"
export ROOTCHAIN_COINBASE_PRIVATE_KEY="5bb82c5bd87bdef1c1262ea18f51eb60a99af46519b477c09e933b72995f8b74"
export STAKE_TOKEN_ADDRESS="0xd9b2df73f87719f986fbbe4b956c1331d84389e9"
export IS_STAKE_TOKEN_ERC_20=true
export IS_DEPLOY_STAKE_TOKEN_ERC20=false
export NATIVE_TOKEN_CONFIG="BBBStakeToken:BBBSTK:18:true"
export BASE_DN="${CLEAN_DEPLOY_TITLE}.edge.polygon.private"
export COINBASE_ADDRESS="0xA8A4f31fF1445dA283aC3624430c954A13D4675d"

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

# Replace this with your actual host variables logic
# Example: declare -A hostvars=(["host1"]="fullnode" ["host2"]="validator")
declare -A hostvars=(["host1"]="fullnode" ["host2"]="validator")

for item in "${!hostvars[@]}"; do
role="${hostvars[$item]}"
if [[ "$role" == "fullnode" || "$role" == "validator" ]]; then
polygon-edge polybft-secrets --data-dir "$item" --json --insecure > "${item}.json"
fi
done

apt update
curl -fsSL https://deb.nodesource.com/setup_18.x | bash -
apt-get install -y nodejs

pushd /opt/polygon-edge/
make compile-core-contracts
cp -r /opt/polygon-edge/core-contracts /var/lib/bootstrap/core-contracts/
popd

BURN_CONTRACT_ADDRESS=0x0000000000000000000000000000000000000000
BALANCE=0x0

polycli wallet create --words 12 --language english | jq '.Addresses[0]' > rootchain-wallet.json

# Should the deployer be funded from an unlocked L1 chain or from a prefunded account on L1
if [ "$FUND_ROOTCHAIN_COINBASE" = true ]; then
COINBASE_ADDRESS=$(cast rpc --rpc-url $ROOTCHAIN_JSON_RPC eth_coinbase | sed 's/"//g')
cast send --rpc-url $ROOTCHAIN_JSON_RPC --from $COINBASE_ADDRESS --value $ROOTCHAIN_DEPLOYER_FUND_AMOUNT $(cat rootchain-wallet.json | jq -r '.ETHAddress') --unlocked
else
cast send --rpc-url $ROOTCHAIN_JSON_RPC --from $ROOTCHAIN_COINBASE_ADDRESS --value $ROOTCHAIN_DEPLOYER_FUND_AMOUNT $(cat rootchain-wallet.json | jq -r '.ETHAddress') --private-key $ROOTCHAIN_COINBASE_PRIVATE_KEY
fi

if [ "$IS_DEPLOY_STAKE_TOKEN_ERC20" = true ]; then
echo "Deploying MockERC20 (Stake Token) contract"
cast send --from $(cat rootchain-wallet.json | jq -r '.ETHAddress') \
--private-key $(cat rootchain-wallet.json | jq -r '.HexPrivateKey') \
--rpc-url $ROOTCHAIN_JSON_RPC -j --create \
"$(jq -r '.bytecode' ./core-contracts/artifacts/contracts/mocks/MockERC20.sol/MockERC20.json)" > MockStakeTokenERC20.json

cast send $(cat MockStakeTokenERC20.json | jq -r '.contractAddress') "function mint(address to, uint256 amount) returns()" $(cat rootchain-wallet.json | jq -r '.ETHAddress') $ROOTCHAIN_STAKE_TOKEN_FUND_AMOUNT \
--rpc-url $ROOTCHAIN_JSON_RPC \
--private-key $(cat rootchain-wallet.json | jq -r '.HexPrivateKey')
fi

# Constructing genesis
polygon-edge genesis \
--consensus polybft \
--chain-id $CHAIN_ID \
--premine $BURN_CONTRACT_ADDRESS \
--reward-wallet 0x0101010101010101010101010101010101010101:1000000000000000000000000000 \
--block-gas-limit $BLOCK_GAS_LIMIT \
--block-time $BLOCK_TIME

# Continue with the deployment process
polygon-edge polybft stake-manager-deploy \
--jsonrpc $ROOTCHAIN_JSON_RPC \
--private-key $(cat rootchain-wallet.json | jq -r '.HexPrivateKey')

polygon-edge rootchain deploy \
--stake-manager $(cat genesis.json | jq -r '.params.engine.polybft.bridge.stakeManagerAddr') \
--stake-token $(cat genesis.json | jq -r '.params.engine.polybft.bridge.stakeTokenAddr') \
--json-rpc $ROOTCHAIN_JSON_RPC \
--deployer-key $(cat rootchain-wallet.json | jq -r '.HexPrivateKey')

counter=1
for item in "${!hostvars[@]}"; do
role="${hostvars[$item]}"
if [[ "$role" == "validator" ]]; then
echo "Registering validator: ${counter}"
polygon-edge polybft register-validator \
--data-dir "$item" \
--supernet-manager $(cat genesis.json | jq -r '.params.engine.polybft.bridge.customSupernetManagerAddr') \
--jsonrpc $ROOTCHAIN_JSON_RPC

cast send --private-key $(cat "$item"/consensus/validator.key) \
--rpc-url $ROOTCHAIN_JSON_RPC -j \
$(cat genesis.json | jq -r '.params.engine.polybft.bridge.stakeTokenAddr') \
'function approve(address spender, uint256 amount) returns(bool)' \
$(cat genesis.json | jq -r '.params.engine.polybft.bridge.stakeManagerAddr') \
$ROOTCHAIN_VALIDATOR_CONVERT_AMOUNT_ETHER

polygon-edge polybft stake \
--data-dir "$item" \
--amount $ROOTCHAIN_VALIDATOR_CONVERT_AMOUNT_ETHER \
--supernet-id $(cat genesis.json | jq -r '.params.engine.polybft.supernetID') \
--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

((counter++))
fi
done

polygon-edge polybft supernet \
--private-key $(cat rootchain-wallet.json | jq -r '.HexPrivateKey') \
--supernet-manager $(cat genesis.json | jq -r '.params.engine.polybft.bridge.customSupernetManagerAddr') \
--finalize-genesis-set \
--enable-staking \
--jsonrpc $ROOTCHAIN_JSON_RPC

tar czf $BASE_DN.tar.gz *.json *.private
popd
}

main
6 changes: 0 additions & 6 deletions ansible/roles/edge/tasks/bootstrap-edge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@
dest: "{{ edge_home_dir }}/init.sh"
mode: 0700

- name: Produce rootchain-wallet.json
ansible.builtin.template:
src: rootchain-wallet.json
dest: "{{ edge_home_dir }}/rootchain-wallet.json"
mode: 0700

- name: Execute bootstrap on the first validator
ansible.builtin.shell: |
{{ edge_home_dir }}/init.sh &> {{ edge_home_dir }}/bootstrap_output.txt
Expand Down
Loading