Permission smart contract deployment
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:
-
AddAddress
go run main.go whitelist deployment --addAddress 0x5383Cb489FaCa92365Bb6f9f1FB40bD032E6365d --addAddress 0x5383Cb489FaCa92365Bb6f9f1FB40bD032E6365d
-
removeAddress
go run main.go whitelist deployment --removeAddress 0x5383Cb489FaCa92365Bb6f9f1FB40bD032E6365d --removeAddress 0x5383Cb489FaCa92365Bb6f9f1FB40bD032E6365d
After changing the deployment whitelist, nodes should be restarted to fetch the latest whitelist from genesis config
- Show all whitelist
go run main.go whitelist show
Changes include
- [ ] Bugfix (non-breaking change that solves an issue)
- [ ] Hotfix (change that solves an urgent issue, and requires immediate attention)
- [x] New feature (non-breaking change that adds functionality)
- [ ] Breaking change (change that is not backwards-compatible and/or changes current functionality)
Checklist
- [x] I have assigned this PR to myself
- [x] I have added at least 1 reviewer
- [x] I have added the relevant labels
- [ ] I have updated the official documentation
- [x] I have added sufficient documentation in code
Testing
- [x] I have tested this code with the official test suite
- [x] I have tested this code manually
Manual tests
Scenarios covered by unit tests:
-
Deployment whitelist is empty anyone can deploy:
- Start a network
- Deploy smart contract from any address
-
Addresses inside the whitelist can deploy smart contract
- Start a network
- Add the address to the whitelist
- Only that address should be able to deploy a smart contract
Other scenarios
- User should be able to burn tokens on 0x address
- 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 Report
Merging #692 (da99143) into develop (210de9e) will increase coverage by
0.07%. The diff coverage is89.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%) |
:arrow_up: |
| syncer/client.go | 61.79% <0.00%> (-1.42%) |
:arrow_down: |
| txpool/account.go | 94.94% <0.00%> (+1.68%) |
:arrow_up: |
:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more
Codecov Report
Merging #692 (138f49e) into develop (de62840) will decrease coverage by
0.21%. The diff coverage is5.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 +4Impacted Files Coverage Δ chain/params.go
50.00% <ø> (ø)types/transaction.go53.03% <0.00%> (-8.38%)⬇️ types/types.go64.65% <0.00%> (-3.53%)⬇️ txpool/txpool.go70.62% <25.00%> (-0.42%)⬇️ network/server_discovery.go73.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
Code coverage is affected because we don't have tests for commands 😭
Save the excuses for the coverage police 👮♂️
@Aleksao998
After the first round of reviews, I will write docs
This is a clever way of saying you'll do it later 😄
@Aleksao998
Linter failing after latest pushes