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
Validatorcontract and wire V1 block for Balancer V3Scope
Context, Balancer V3 issue:
Figure: V1 Frontend using V2 Proxy as controller
Add
src/Validator.solthat V2 calls before state changes.Roles:
ADMIN_ROLEmanages other roles.V1_FRONTEND_ROLEmarks the chain’s V1 frontend.V1_BLOCKED_ROLEmarks counterparties V1 must not touch, for example the Balancer V3 Vault.BLACKLISTED_ROLEblocks addresses globally.Tests in
test/Validator.t.sol. We have 100% coverage forValidator.Implementation
Validatoris 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*_withCallerentrypoints in V2.msg.senderhasV1_FRONTEND_ROLE, return false whenfromortohasV1_BLOCKED_ROLE.fromortohasBLACKLISTED_ROLE.DEFAULT_ADMIN_ROLEgranted to deployer.ADMIN_ROLEis 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.solsetter (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>)