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

doc: matic-cli commands and config update #208

Merged
merged 7 commits into from
Nov 16, 2023
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
44 changes: 19 additions & 25 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,16 @@ jobs:
node-version: '16.17.1'

- name: Install npm dependencies
run: |
cd matic-cli
npm install --prefer-offline --no-audit --progress=false
working-directory: matic-cli
leovct marked this conversation as resolved.
Show resolved Hide resolved
run: npm install --prefer-offline --no-audit --progress=false

- name: Run prettier
run: |
cd matic-cli
npm run prettier:check
working-directory: matic-cli
run: npm run prettier:check

- name: Run lint
run: |
cd matic-cli
npm run lint:check
working-directory: matic-cli
run: npm run lint:check

integration-tests:
permissions:
Expand All @@ -57,8 +54,8 @@ jobs:
path: matic-cli

- name: Create .env file
working-directory: matic-cli
run: |
cd matic-cli
cp .env.example .env
sed -i 's,YOUR_IDENTIFIER,matic-cli-ci,' .env
sed -i 's,aws-key,matic-cli-ci-key,' .env
Expand All @@ -70,8 +67,8 @@ jobs:
uses: haythem/[email protected]

- name: Create secret.tfvars
working-directory: matic-cli
run: |
cd matic-cli
touch secret.tfvars
echo "SG_CIDR_BLOCKS=[\"${{ steps.ip.outputs.ipv4 }}/32\"]" >> secret.tfvars

Expand All @@ -83,8 +80,8 @@ jobs:
role-session-name: GithubActionsSession

- name: Create aws key pair
working-directory: matic-cli
run: |
cd matic-cli
mkdir aws
cd aws
aws ec2 create-key-pair --key-name matic-cli-ci-key --key-type rsa --key-format pem --query "KeyMaterial" --output text > matic-cli-ci-key.pem
Expand All @@ -96,44 +93,41 @@ jobs:
node-version: '16.17.1'

- name: Install npm dependencies
run: |
cd matic-cli
npm install --prefer-offline --no-audit --progress=false
working-directory: matic-cli
run: npm install --prefer-offline --no-audit --progress=false

- name: Init devnet
run: |
cd matic-cli
./bin/express-cli --init aws
working-directory: matic-cli
run: ./bin/express-cli --init aws

- name: Start devnet
working-directory: matic-cli/deployments/devnet-1
run: |
cd matic-cli/deployments/devnet-1
ls -la
../../bin/express-cli --start

- name: Run stateSynced and checkpoint tests
working-directory: matic-cli/deployments/devnet-1
run: |
cd matic-cli/deployments/devnet-1
../../bin/express-cli --send-state-sync
timeout 20m ../../bin/express-cli --monitor exit

- name: Run smart contracts events tests
working-directory: matic-cli/deployments/devnet-1
run: |
cd matic-cli/deployments/devnet-1
timeout 5m ../../bin/express-cli --send-staked-event 1
timeout 5m ../../bin/express-cli --send-stakeupdate-event 1
timeout 5m ../../bin/express-cli --send-topupfee-event 1
timeout 10m ../../bin/express-cli --send-unstakeinit-event 1

- name: Destroy devnet
if: always()
working-directory: matic-cli/deployments/devnet-1
run: |
cd matic-cli/deployments/devnet-1
echo "Running --destroy"
../../bin/express-cli --destroy

- name: Delete aws key pair
if: always()
run: |
cd matic-cli/aws
aws ec2 delete-key-pair --key-name matic-cli-ci-key
working-directory: matic-cli/aws
run: aws ec2 delete-key-pair --key-name matic-cli-ci-key
69 changes: 36 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,19 @@ test and monitor any devnet on AWS stacks from any local system.

It currently supports **only** devnets running `v0.3.x` stacks.

The `express-cli` interacts with `terraform` to create a fully working setup on AWS.
The `express-cli` interacts with `terraform` to create a fully working setup on AWS.
This setup is composed by a set of `EC2 VM` instances running a specific `ubuntu 22.04 ami`, mounted with `gp3 disks` ,
and a `public-subnet` with its `VPC`.
and a `public-subnet` with its `VPC`.
In case the infrastructure already exists, `matic-cli` can be used as a standalone tool to deploy Polygon stacks on
pre-configured VMs.

Please, refer to the section of this file you are more interested in (`express-cli` or `matic-cli`)

## Table of contents

- [`express-cli`](#express-cli)
- [`matic-cli`](#matic-cli)

## `express-cli`

### Requirements
Expand Down Expand Up @@ -45,7 +50,7 @@ In case you plan to utilize express-cli for Google Cloud, you will need to make

### Auth Configuration

As a prerequisite, you need to configure authentication on `aws`
As a prerequisite, you need to configure authentication on `aws`
This will create the folder `~/.aws` in your system
To do so, please run

Expand Down Expand Up @@ -144,8 +149,8 @@ First off, you need to `--init` terraform on your local machine, by executing th

- Creates the desired remote setup, based on the preferences defined in the `.env.devnet<id>` file
- `--start` command can be used also to target an existing AWS setup. If changes to `.env.devnet<id>` file are detected, the
previous devnet will be destroyed and a new one created, reusing the same AWS VMs
To destroy the remote devnet, you can execute the `--destroy` command.
previous devnet will be destroyed and a new one created, reusing the same AWS VMs
To destroy the remote devnet, you can execute the `--destroy` command.

- `../../bin/express-cli --destroy`

Expand Down Expand Up @@ -225,7 +230,7 @@ The `express-cli` also comes with additional utility commands, listed below. Som
- ` ../../bin/express-cli --monitor [exit]`

- Monitors the reception of state-syncs and checkpoints to make sure the whole network is in a healthy state.
If `--send-state-sync` hasn't been used before, only checkpoints will be detected. Monitor the setup.
If `--send-state-sync` hasn't been used before, only checkpoints will be detected. Monitor the setup.
If `exit` string is passed the process terminates when at least one `stateSync` and one `checkpoint` are detected.

- ` ../../bin/express-cli --instances-stop`
Expand Down Expand Up @@ -316,22 +321,21 @@ Please, make sure to install the following software/packages on the VMs.
- Build Essentials (_host_ and _remotes_)

```bash
sudo apt update
sudo apt install build-essential
sudo apt update --yes && sudo apt install --yes build-essential
```

- Go 1.18+ (_host_ and _remotes_)

```bash
wget https://raw.githubusercontent.com/maticnetwork/node-ansible/master/go-install.sh
bash go-install.sh --remove
bash go-install.sh
wget https://raw.githubusercontent.com/maticnetwork/node-ansible/master/go-install.sh \
marcello33 marked this conversation as resolved.
Show resolved Hide resolved
&& bash go-install.sh --remove \
&& bash go-install.sh
```

- Rabbitmq (_host_ and _remotes_)

```bash
sudo apt install rabbitmq-server
sudo apt install --yes rabbitmq-server
```

- Docker (_host_ and _remotes_, only needed in case of a docker setup)
Expand All @@ -342,21 +346,21 @@ Please, make sure to install the following software/packages on the VMs.
- Node v16.17.1 (only _host_)

```bash
curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
nvm install 16.17.1
curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash \
&& source /home/ubuntu/.bashrc \
&& nvm install 16.17.1
```

- Npm (only _host_)

```bash
sudo apt update
sudo apt install nodejs npm
sudo apt update --yes && sudo apt install --yes npm
```

- Python 2 (only _host_)

```bash
sudo apt install python2 && alias python="/usr/bin/python2
sudo apt install python2 --yes && alias python="/usr/bin/python2"
```

- Solc v0.5.16 (only _host_)
Expand All @@ -366,37 +370,36 @@ Please, make sure to install the following software/packages on the VMs.
```

- Ganache CLI (only _host_)

```bash
sudo npm install -g ganache
npm install --global ganache
```

### Usage

On the _host_ machine, please run

```bash
cd ~
git clone https://github.com/maticnetwork/matic-cli.git
cd matic-cli
npm i
mkdir devnet
cd devnet
cd \
&& git clone https://github.com/maticnetwork/matic-cli.git \
&& cd matic-cli \
&& npm install
```

#### Local dockerized network

Adjust the [docker configs](configs/devnet/docker-setup-config.yaml) and run

```bash
../bin/matic-cli setup devnet -c ../configs/devnet/docker-setup-config.yaml
mkdir devnet \
&& cd devnet \
&& ../bin/matic-cli setup devnet --config ../configs/devnet/docker-setup-config.yaml | tee setup.log
...
DONE Devnet is ready
```

Once the setup is done, follow these steps for local docker deployment

marcello33 marked this conversation as resolved.
Show resolved Hide resolved
- Move to devnet folder
```bash
cd matic-cli/devnet
```
- Start ganache

```bash
Expand Down Expand Up @@ -441,16 +444,16 @@ Note: in case of docker setup, we have provided [some additional scripts](src/se
Adjust the [remote configs](configs/devnet/remote-setup-config.yaml) and run

```bash
../bin/matic-cli setup devnet -c ../configs/devnet/remote-setup-config.yaml
../bin/matic-cli setup devnet --config ../configs/devnet/remote-setup-config.yaml
```

Alternatively, this step can be executed interactively with

```bash
../bin/matic-cli setup devnet -i
../bin/matic-cli setup devnet --interactive
```

Once the setup is done, follow these steps for remote deployment
Once the setup is done, follow these steps for remote deployment
In this case, the stack is already running, you would just need to deploy/sync some contracts, as follows:

- Move to devnet folder
Expand Down Expand Up @@ -481,7 +484,7 @@ Stop al services, remove the `matic-cli/devnet` folder, and you can start the pr
eval "$(ssh-agent -s)"
ssh-add `<.pem file>`
```
3. We have provided the default config values [here](configs/devnet) to ensure smooth functioning of the process
3. We have provided the default config values [here](configs/devnet) to ensure smooth functioning of the process
Please check the relative [README](configs/README.md) for more accurate description of such configs
These files are used as templates and dynamically modified by `express-cli`, hence they should not be deleted nor any modification remotely pushed
Therefore, they are under `.gitignore`, and in case you do not want those changes to be reflected in your local `git`,
Expand Down
2 changes: 1 addition & 1 deletion configs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ For `mati-cli`, the configs are directly used to spin the network up.
## Usage

```bash
matic-cli setup devnet -c path/to/config.yaml
matic-cli setup devnet --config path/to/config.yaml
```

## Option details with examples
Expand Down
36 changes: 26 additions & 10 deletions configs/devnet/docker-setup-config.yaml
Original file line number Diff line number Diff line change
@@ -1,27 +1,43 @@
defaultStake: 10000
defaultFee: 2000
borChainId: 15005
heimdallChainId: heimdall-4052
# Repositories
borRepo: https://github.com/maticnetwork/bor.git
borBranch: develop

heimdallRepo: https://github.com/maticnetwork/heimdall.git
heimdallBranch: develop

contractsRepo: https://github.com/maticnetwork/contracts.git
contractsBranch: mardizzone/node-16

genesisContractsRepo: https://github.com/maticnetwork/genesis-contracts.git
genesisContractsBranch: master

# Defaults
devnetType: docker
defaultStake: 10000
defaultFee: 2000

# L1
ethURL: http://ganache:9545
ethHostUser: ubuntu

# Heimdall
heimdallChainId: heimdall-4052
heimdallDockerBuildContext: https://github.com/maticnetwork/heimdall.git#develop

# Bor
borChainId: 15005
sprintSize: 64
sprintSizeBlockNumber: 0
blockNumber: '0'
blockTime: '2'
numOfBorValidators: 1
numOfBorSentries: 1
numOfBorArchiveNodes: 0
ethURL: http://ganache:9545
ethHostUser: ubuntu
devnetType: docker
borDockerBuildContext: https://github.com/maticnetwork/bor.git#develop
heimdallDockerBuildContext: https://github.com/maticnetwork/heimdall.git#develop
devnetBorUsers: ubuntu,ubuntu
devnetBorHosts:
- ec2-xx-xxx-xx-xxx.eu-west-1.compute.amazonaws.com # use localhost for local deployments
devnetBorHosts: ["ec2-xx-xxx-xx-xxx.eu-west-1.compute.amazonaws.com"] # use localhost for local deployments

# Erigon
numOfErigonValidators: 0
marcello33 marked this conversation as resolved.
Show resolved Hide resolved
numOfErigonSentries: 0
numOfErigonArchiveNodes: 0
Loading