Skip to content

Commit

Permalink
Introduce local development cluster script (#912)
Browse files Browse the repository at this point in the history
* Introduce local development cluster script
  • Loading branch information
vcastellm committed Nov 16, 2022
1 parent 3335564 commit 8627f12
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
4 changes: 2 additions & 2 deletions command/genesis/polybft_params.go
Expand Up @@ -39,7 +39,7 @@ const (
defaultPolyBftValidatorPrefixPath = "test-chain-"
defaultBridge = false

bootnodePortStart = 30301
bootnodePortStart = 1
defaultStakeBalance = 100
)

Expand Down Expand Up @@ -102,7 +102,7 @@ func (p *genesisParams) generatePolyBFTConfig() (*chain.Chain, error) {
// set generic validators as bootnodes if needed
if len(p.bootnodes) == 0 {
for i, validator := range validatorsInfo {
bnode := fmt.Sprintf("/ip4/%s/tcp/%d/p2p/%s", "127.0.0.1", bootnodePortStart+i, validator.NodeID)
bnode := fmt.Sprintf("/ip4/%s/tcp/%d0001/p2p/%s", "127.0.0.1", bootnodePortStart+i, validator.NodeID)
chainConfig.Bootnodes = append(chainConfig.Bootnodes, bnode)
}
}
Expand Down
31 changes: 31 additions & 0 deletions scripts/cluster
@@ -0,0 +1,31 @@
#!/usr/bin/env bash

set -e

# Reset test-dirs
rm -rf test-chain-*
rm -f genesis.json

go build -o polygon-edge .

if [ "$1" == "ibft" ]; then
echo "Running with ibft consensus"
nodeid=$(./polygon-edge secrets init --data-dir test-chain- --num 4 | grep Node | head -n 1 | awk -F ' ' '{print $4}')
genesis_params="--consensus ibft --ibft-validators-prefix-path test-chain- --bootnode /ip4/127.0.0.1/tcp/10001/p2p/$nodeid"

nodeid=$(./polygon-edge secrets init --data-dir test-chain- --num 4 | grep Node | head -n 1 | awk -F ' ' '{print $4}')
else
echo "Running with polybft consensus"
genesis_params="--consensus polybft --validator-set-size=4"
./polygon-edge polybft-secrets --data-dir test-chain- --num 4
fi

./polygon-edge genesis $genesis_params \
--block-gas-limit 10000000 \
--premine 0x85da99c8a7c2c95964c8efd687e95e632fc533d6:1000000000000000000000

./polygon-edge server --data-dir ./test-chain-1 --chain genesis.json --grpc-address :10000 --libp2p :10001 --jsonrpc :10002 --seal --log-level DEBUG &
./polygon-edge server --data-dir ./test-chain-2 --chain genesis.json --grpc-address :20000 --libp2p :20001 --jsonrpc :20002 --seal &
./polygon-edge server --data-dir ./test-chain-3 --chain genesis.json --grpc-address :30000 --libp2p :30001 --jsonrpc :30002 --seal &
./polygon-edge server --data-dir ./test-chain-4 --chain genesis.json --grpc-address :40000 --libp2p :40001 --jsonrpc :40002 --seal &
wait

0 comments on commit 8627f12

Please sign in to comment.