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

WIP - Polygon Local Devnet Setup #136

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

Lohann
Copy link
Collaborator

@Lohann Lohann commented Jul 13, 2023

Description

Script that starts a local polygon devnet, the script is adapted from matic-cli.

Why so many files?

Most of the files are auto-generated, every time you run the matic-cli it generates a entire new network, with a different genesis, different accounts, different config, etc.. this is annoying because the docker-compose.yml depends of those settings, while is possible to create a script that parses the config and update the docker-compose.yml dynamically, that's too much work and out of the scope of this PR (which is already pretty big), this can be a future improvement. Matic-cli auto-generated artifacts are inside config, data and devnet folders, so you can skip while reviewing the code.

How to Test

Using matic-cli you are supposed to call many shell scripts in sequence in order to start and bootstrap the network. To address this limitation, I've managed to implement one bash script which do the whole setup in one step, also keeping the same set of accounts and network. After setup the devnet starts by simply calling docker compose up. There's two ways to setup the testnet:

Method 1 - Building from Source

1 - Install the required dependencies:

2 - run the setup script

cd ./ci/polygon
./setup.sh

Method 2 - Using docker

If you don't want to install any dependencies in your local machine, you can use Docker to setup

1 - Install the required dependencies

 cd ./ci/polygon
docker build . -t local-builder
docker run -it --rm -v $PWD:/builds local-builder:latest ./setup.sh

Start polygon devnet

This script will run docker compose up and deploy the matic smart-contracts.

./start.sh

After that, the polygon node will be available at port 8595 and the layer 1 evm at 9545, heimdall.

Stop polygon devnet

./stop.sh

Solidity 0.5.12

Polygon's smart-contract requires Solidity 0.5.12+ compiler, the solcjs and newer versions doesn't work (I tried). The other issue I had is that there's no binary for arm64 linux (required for my docker image), to address this I adapted this CI script which compiles any solidity version from source, is the only one I've found that works both for aarch64 and x64 targets.

UPDATE - 20/07

After talking to @dvc94ch, we decided to give more love to this PR in order to implement a cleaner solution for L2 networks.

Type of change

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

Code review prechecks:

  • Code follows the style guidelines of this project
  • Code has been self-reviewed
  • Inline comments have been added for each method
  • I have made corresponding changes to the documentation
  • Code changes introduces no new problems or warnings
  • Test cases have been added
  • Dependent changes have been merged and published in downstream modules

@Lohann Lohann marked this pull request as ready for review July 14, 2023 06:46
@dvc94ch
Copy link
Contributor

dvc94ch commented Jul 20, 2023

I must say I find this a bit messy and unsatisfying. do we need to add so much "crap" for each L2? if we really have to we can merge this.

@Lohann
Copy link
Collaborator Author

Lohann commented Jul 20, 2023

@dvc94ch With more 1 week of work, I can adaptate this code to run fully in a single script in rust, including create the polygon devnet dynamically, remove the static files and integrate this with existing rosetta-docker setup.

I wasn't sure if I should spend more time in this task because I already work the whole week on this, let me know if you want me to do this changes before merge this PR.

@dvc94ch
Copy link
Contributor

dvc94ch commented Jul 20, 2023

If it's only one week, then yes, please, let's do that.

@Lohann
Copy link
Collaborator Author

Lohann commented Jul 20, 2023

roger that!

@Lohann Lohann marked this pull request as draft July 20, 2023 17:01
@Lohann Lohann changed the title Polygon Local Devnet Setup WIP - Polygon Local Devnet Setup Jul 20, 2023
@isabellelaususan isabellelaususan linked an issue Sep 26, 2023 that may be closed by this pull request
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

Successfully merging this pull request may close these issues.

Polygon Connector
2 participants