New Validator contract and wire V1 block for Balancer V3 #54
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
New
Validator
contract and wire V1 block for Balancer V3Scope
Context, Balancer V3 issue:
Figure: V1 Frontend using V2 Proxy as controller
Add
src/Validator.sol
that V2 calls before state changes.Roles:
ADMIN_ROLE
manages other roles.V1_FRONTEND_ROLE
marks the chain’s V1 frontend.V1_BLOCKED_ROLE
marks counterparties V1 must not touch, for example the Balancer V3 Vault.BLACKLISTED_ROLE
blocks addresses globally.Tests in
test/Validator.t.sol
. We have 100% coverage forValidator
.Implementation
Validator
is a pure view gate:validate(from, to, amount) -> bool
.smart-contracts/src/Validator.sol
Lines 45 to 103 in 31f0320
msg.sender
. Because it's using the*_withCaller
entrypoints in V2.msg.sender
hasV1_FRONTEND_ROLE
, return false whenfrom
orto
hasV1_BLOCKED_ROLE
.from
orto
hasBLACKLISTED_ROLE
.DEFAULT_ADMIN_ROLE
granted to deployer.ADMIN_ROLE
is admin for all other roles.isAdminAccount
,isV1Blocked
,isBlacklisted
,isV1Frontend
.CONTRACT_ID()
for downstream checks by the V2 when setting the new Validator.validator.validate(...)
before moving balances. Example fromsrc/controllers/GnosisController.sol
:smart-contracts/src/controllers/GnosisControllerToken.sol
Lines 80 to 103 in 29464dd
src/Token.sol
setter (already present), used to switch to the new validator:smart-contracts/src/Token.sol
Lines 110 to 114 in 29464dd
How to Test
Install
Unit tests
Coverage
Sample output:
We have 100% coverage for the validator.
Deployment plan (Gnosis first)
Validator
.setAdmin(<monerium admins>)
setV1Frontend(0xcB444e90D8198415266c6a2724b7900fb12FC56E)
setV1Blocked(0xbA1333333333a1BA1108E8412f11850A5C319bA9)
Token.setValidator(<validatorAddress>)