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

Permission smart contract deployment #692

Merged
merged 44 commits into from
Aug 31, 2022

Conversation

Aleksao998
Copy link
Contributor

@Aleksao998 Aleksao998 commented Aug 22, 2022

Description

This PR implements permission smart contract deployment feature.

How it works:
The idea behind this feature is that we want to enable nodes to restrict who can deploy smart contracts. We've decided to add a deployment whitelist and only addresses inside this list can deploy smart contracts. When the deployment whitelist is empty anyone can deploy contracts

To make this easy to use, we've added a few CLI commands:

  1. AddAddress
    go run main.go whitelist deployment --add 0x5383Cb489FaCa92365Bb6f9f1FB40bD032E6365d --add 0x5383Cb489FaCa92365Bb6f9f1FB40bD032E6365d

Screenshot 2022-08-22 at 19 01 35

  1. removeAddress
    go run main.go whitelist deployment --remove 0x5383Cb489FaCa92365Bb6f9f1FB40bD032E6365d --remove 0x5383Cb489FaCa92365Bb6f9f1FB40bD032E6365d

Screenshot 2022-08-22 at 19 03 10

After changing the deployment whitelist, nodes should be restarted to fetch the latest whitelist from genesis config

  1. Show all whitelist
    go run main.go whitelist show

Screenshot 2022-08-22 at 19 05 02 1

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

Manual tests

Scenarios covered by unit tests:

  1. Deployment whitelist is empty anyone can deploy:

    1. Start a network
    2. Deploy smart contract from any address
  2. Addresses inside the whitelist can deploy smart contract

    1. Start a network
    2. Add the address to the whitelist
    3. Only that address should be able to deploy a smart contract

Other scenarios

  1. User should be able to burn tokens on 0x address
  2. Whitelist should not affect EOA transfers and smart contract interaction

Documentation update

After the first round of reviews, I will write docs

Additional comments

Fixes EDGE-735

@codecov
Copy link

codecov bot commented Aug 22, 2022

Codecov Report

Merging #692 (da99143) into develop (210de9e) will increase coverage by 0.07%.
The diff coverage is 89.65%.

@@             Coverage Diff             @@
##           develop     #692      +/-   ##
===========================================
+ Coverage    48.72%   48.79%   +0.07%     
===========================================
  Files          112      112              
  Lines        15432    15460      +28     
===========================================
+ Hits          7519     7544      +25     
- Misses        7279     7281       +2     
- Partials       634      635       +1     
Impacted Files Coverage Δ
chain/params.go 50.00% <ø> (ø)
types/transaction.go 61.40% <ø> (ø)
txpool/txpool.go 73.33% <89.65%> (+0.92%) ⬆️
syncer/client.go 61.79% <0.00%> (-1.42%) ⬇️
txpool/account.go 94.94% <0.00%> (+1.68%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@Aleksao998
Copy link
Contributor Author

Codecov Report

Merging #692 (138f49e) into develop (de62840) will decrease coverage by 0.21%.
The diff coverage is 5.26%.

❗ Current head 138f49e differs from pull request most recent head 12ffd1b. Consider uploading reports for the commit 12ffd1b to get more accurate results

@@             Coverage Diff             @@
##           develop     #692      +/-   ##
===========================================
- Coverage    48.77%   48.55%   -0.22%     
===========================================
  Files          112      112              
  Lines        15382    15401      +19     
===========================================
- Hits          7502     7478      -24     
- Misses        7249     7288      +39     
- Partials       631      635       +4     

Impacted Files Coverage Δ
chain/params.go 50.00% <ø> (ø)
types/transaction.go 53.03% <0.00%> (-8.38%) ⬇️
types/types.go 64.65% <0.00%> (-3.53%) ⬇️
txpool/txpool.go 70.62% <25.00%> (-0.42%) ⬇️
network/server_discovery.go 73.88% <0.00%> (-15.93%) ⬇️
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Code coverage is affected because we don't have tests for commands 😭

@Aleksao998 Aleksao998 self-assigned this Aug 22, 2022
@Aleksao998 Aleksao998 added the feature New update to Polygon Edge label Aug 22, 2022
@Aleksao998 Aleksao998 marked this pull request as ready for review August 22, 2022 17:12
@zivkovicmilos
Copy link
Contributor

@Aleksao998

Code coverage is affected because we don't have tests for commands 😭

Save the excuses for the coverage police 👮‍♂️

txpool/txpool.go Outdated Show resolved Hide resolved
txpool/txpool.go Outdated Show resolved Hide resolved
chain/params.go Outdated Show resolved Hide resolved
Copy link
Contributor

@Kourin1996 Kourin1996 left a comment

Choose a reason for hiding this comment

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

Just small comments

command/whitelist/deployment/params.go Outdated Show resolved Hide resolved
command/whitelist/deployment/result.go Outdated Show resolved Hide resolved
helper/common/common.go Outdated Show resolved Hide resolved
helper/common/common.go Outdated Show resolved Hide resolved
command/whitelist/deployment/params.go Outdated Show resolved Hide resolved
command/whitelist/show/result.go Show resolved Hide resolved
helper/common/common.go Outdated Show resolved Hide resolved
chain/params.go Outdated Show resolved Hide resolved
txpool/txpool.go Outdated Show resolved Hide resolved
helper/common/common.go Outdated Show resolved Hide resolved
@zivkovicmilos zivkovicmilos added this to the 0.6 Release milestone Aug 24, 2022
txpool/txpool.go Outdated Show resolved Hide resolved
types/types.go Outdated Show resolved Hide resolved
Copy link
Contributor

@dbrajovic dbrajovic left a comment

Choose a reason for hiding this comment

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

Make linty happy and we can merge 👍

@Aleksao998 Aleksao998 merged commit 74ab62e into develop Aug 31, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Aug 31, 2022
@Aleksao998 Aleksao998 deleted the feature/permission_smart_contract_deployment branch September 16, 2022 10:11
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