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

Add a flag to deploy command for stake manager address #1520

Conversation

goran-ethernal
Copy link
Contributor

@goran-ethernal goran-ethernal commented May 17, 2023

Description

Added a --stake-manager flag to deploy command which deploys rootchain contracts, which holds the address of the StakeManager contract on rootchain.

Given flag is mandatory, so the StakeManager contract has to be deployed already on the rootchain. This is needed since StakeManager is a single instance contract on rootchain so it should be deployed only once.

To help deployers, we provided a command that only deploys StakeManager contract. It is called stake-manager-deploy.
It has these flags:

  • data-dir - specifies the directory for the Polygon Edge data if the local FS is used.
  • config - the path to the SecretsManager config file, if omitted, the local FS secrets manager is used.
  • private-key - hex-encoded private key of the account which executes rootchain commands.
  • genesis - genesis file path, which contains chain configuration.
  • stake-token - address of ERC20 token used for staking on rootchain.
  • test - indicates if command is run in test mode. If test mode is used contract will be deployed using test account and a test stake ERC20 token will be deployed to be used for staking.

Flags data-dir and config are mutually exclusive.
Flag private-key is mutually exclusive with data-dir and config flags.
So if the StakeManager deployer doesn't have secrets initialized, then he would need to use the private-key flag.

Flag test is mutually exclusive with data-dir, config, private-key and stake-token flags, and is only used for testing purposes, since when this flag is on, test account will be used to deploy StakeManager and a mock ERC20 token will be deployed and used for staking.

If test is not used (in case when deploying StakeManager to let's say Mumbai main net), then deployer will need to provide the address to the token that was deployed on root that will be used for staking (in this case Matic).

stake-manager-deploy command will update the genesis file and save the StakeManager and StakeToken addresses to the Bridge config in genesis.json.

To summarize the flow of deploying supernet would be:

  1. Initialize secrets for each validator.
  2. Execute genesis command.
  3. Deploy StakeManager contract if it is not already deployed to the rootchain.
  4. Execute rootchain deploy command (provide StakeManager address to it).
  5. Whitelist validators (SupernetManager deployer must do it).
  6. Register validators (each validator for itself).
  7. Do initial staking (each validator for itself).
  8. Finalize genesis on SupernetManager (SupernetManager deployer must do it).

The PR also changes name of the --native-root-token flag in fund and stake commands to better picture which token is in question. So the --native-root-token flag in those commands is renamed to --stake-token.

Tagging @DannyS03 to update the docs.

Changes include

  • Bugfix (non-breaking change that solves an issue)
  • Hotfix (change that solves an urgent issue, and requires immediate attention)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (change that is not backwards-compatible and/or changes current functionality)

Checklist

  • I have assigned this PR to myself
  • I have added at least 1 reviewer
  • I have added the relevant labels
  • I have updated the official documentation
  • I have added sufficient documentation in code

Testing

  • I have tested this code with the official test suite
  • I have tested this code manually

@goran-ethernal goran-ethernal self-assigned this May 17, 2023
@goran-ethernal goran-ethernal requested a review from a team May 17, 2023 17:29
@goran-ethernal goran-ethernal added the feature New update to Polygon Edge label May 17, 2023
@goran-ethernal goran-ethernal marked this pull request as ready for review May 17, 2023 17:34
Copy link
Contributor

@vcastellm vcastellm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we mentioned, this need to be mandatory instead of optional and add a new SM deploy command.

@goran-ethernal goran-ethernal force-pushed the EVM-633-Add-a-flag-to-deploy-or-not-deploy-stake-manager branch 4 times, most recently from 39c1da0 to e1d3ddc Compare May 18, 2023 13:02
@goran-ethernal goran-ethernal force-pushed the EVM-633-Add-a-flag-to-deploy-or-not-deploy-stake-manager branch from 7dd1275 to a285718 Compare May 18, 2023 14:27
@goran-ethernal goran-ethernal force-pushed the EVM-633-Add-a-flag-to-deploy-or-not-deploy-stake-manager branch from 2332941 to 5c43c48 Compare May 23, 2023 09:40
@goran-ethernal goran-ethernal force-pushed the EVM-633-Add-a-flag-to-deploy-or-not-deploy-stake-manager branch from 5c43c48 to 0e9ca77 Compare May 24, 2023 12:14
@goran-ethernal goran-ethernal merged commit 2bef96a into develop May 24, 2023
10 checks passed
@goran-ethernal goran-ethernal deleted the EVM-633-Add-a-flag-to-deploy-or-not-deploy-stake-manager branch May 24, 2023 13:19
@github-actions github-actions bot locked and limited conversation to collaborators May 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature New update to Polygon Edge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants