From 871abd715fe93fb5d3eb0efde51ba44abf300d02 Mon Sep 17 00:00:00 2001 From: Westlad Date: Thu, 28 Apr 2022 15:47:11 +0100 Subject: [PATCH 1/3] fix: add amount restrictions for mainnet and goerli ERC contracts --- config/default.js | 80 ++++++++++++++----- .../migrations/2_deploy_upgradeable.js | 9 ++- .../migrations/3_test_tokens_migration.js | 6 +- test/e2e/tokens/erc20.test.mjs | 4 +- 4 files changed, 70 insertions(+), 29 deletions(-) diff --git a/config/default.js b/config/default.js index 12c71f2e8..5a776db45 100644 --- a/config/default.js +++ b/config/default.js @@ -267,28 +267,64 @@ module.exports = { bootChallenger: process.env.BOOT_CHALLENGER_ADDRESS || '0xfCb059A4dB5B961d3e48706fAC91a55Bad0035C9', }, - tokens: [ - { - name: 'MockERC20', - address: '0xB5Acbe9a0F1F8B98F3fC04471F7fE5d2c222cB44', - amount: 200, - }, - { - name: 'Test-Eth', - address: '0x3f152B63Ec5CA5831061B2DccFb29a874C317502', - amount: '10000000000000000000000', - }, - { - name: 'MATIC', - address: '0x499d11E0b6eAC7c0593d8Fb292DCBbF815Fb29Ae', - amount: '10000000000000000000000', - }, - { - name: 'USDC', - address: '0x07865c6e87b9f70255377e024ace6630c1eaa37f', - amount: '1000000000000', - }, - ], + tokens: { + blockchain1: [ + { + name: 'MockERC20', + address: '0xB5Acbe9a0F1F8B98F3fC04471F7fE5d2c222cB44', + amount: 200, + }, + { + name: 'Test-Eth', + address: '0x3f152B63Ec5CA5831061B2DccFb29a874C317502', + amount: '10000000000000000000000', + }, + { + name: 'MATIC', + address: '0x499d11E0b6eAC7c0593d8Fb292DCBbF815Fb29Ae', + amount: '10000000000000000000000', + }, + { + name: 'USDC', + address: '0x07865c6e87b9f70255377e024ace6630c1eaa37f', + amount: '1000000000000', + }, + ], + mainnet: [ + { + name: 'WETH', + address: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', + amount: '1000000000000000000', + }, + { + name: 'MATIC', + address: '0x7D1AfA7B718fb893dB30A3aBc0Cfc608AaCfeBB0', + amount: '1000000000000000000000', + }, + { + name: 'USDC', + address: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', + amount: '1000000000', + }, + ], + goerli: [ + { + name: 'WETH', + address: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', + amount: '1000000000000000000', + }, + { + name: 'MATIC', + address: '0x499d11E0b6eAC7c0593d8Fb292DCBbF815Fb29Ae', + amount: '1000000000000000000000', + }, + { + name: 'USDC', + address: '0x07865c6E87B9F70255377e024ace6630C1Eaa37F', + amount: '1000000000', + }, + ], + }, }, // for Browser use diff --git a/nightfall-deployer/migrations/2_deploy_upgradeable.js b/nightfall-deployer/migrations/2_deploy_upgradeable.js index 0a58ee7df..5c9381b8f 100644 --- a/nightfall-deployer/migrations/2_deploy_upgradeable.js +++ b/nightfall-deployer/migrations/2_deploy_upgradeable.js @@ -14,7 +14,8 @@ const State = artifacts.require('State.sol'); const config = require('config'); -const { addresses } = config.RESTRICTIONS; +const { RESTRICTIONS } = config; +const { addresses } = RESTRICTIONS; module.exports = async function (deployer) { await deployer.deploy(Verifier); @@ -43,4 +44,10 @@ module.exports = async function (deployer) { const { bootProposer, bootChallenger } = addresses; await proposers.setBootProposer(bootProposer); await challengers.setBootChallenger(bootChallenger); + const restrictions = await Shield.deployed(); + // restrict transfer amounts + for (let token of RESTRICTIONS.tokens[process.env.ETH_NETWORK]) { + console.log(`Max deposit restriction for ${token.name}: ${token.amount}`); + await restrictions.setRestriction(token.address, token.amount); + } }; diff --git a/nightfall-deployer/migrations/3_test_tokens_migration.js b/nightfall-deployer/migrations/3_test_tokens_migration.js index 2b196963b..af9d8b501 100644 --- a/nightfall-deployer/migrations/3_test_tokens_migration.js +++ b/nightfall-deployer/migrations/3_test_tokens_migration.js @@ -21,13 +21,9 @@ const nERC721 = 35; module.exports = function (deployer, _, accounts) { deployer.then(async () => { const restrictions = await Shield.deployed(); - - for (let token of RESTRICTIONS.tokens) { - console.log(`Max deposit restriction for ${token.name}: ${token.amount}`); - await restrictions.setRestriction(token.address, token.amount); - } if (DEPLOY_MOCK_TOKENS === 'false') return; + await deployer.deploy(ERC20Mock, 1001010000000000); // initialSupply const ERC20deployed = await ERC20Mock.deployed(); diff --git a/test/e2e/tokens/erc20.test.mjs b/test/e2e/tokens/erc20.test.mjs index 5cb064db8..7f9b46924 100644 --- a/test/e2e/tokens/erc20.test.mjs +++ b/test/e2e/tokens/erc20.test.mjs @@ -27,7 +27,9 @@ const { } = config.TEST_OPTIONS; const { - RESTRICTIONS: { tokens: defaultRestrictions }, + RESTRICTIONS: { + tokens: { blockchain1: defaultRestrictions }, + }, } = config; const nf3Users = [new Nf3(signingKeys.user1, environment), new Nf3(signingKeys.user2, environment)]; From 70f871104702142f419be9d6d5b8184cccc39863 Mon Sep 17 00:00:00 2001 From: Westlad Date: Fri, 29 Apr 2022 10:01:15 +0100 Subject: [PATCH 2/3] fix: added dai and usdt, added env variables and fixed weth address --- config/default.js | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/config/default.js b/config/default.js index 5a776db45..b9b417f2c 100644 --- a/config/default.js +++ b/config/default.js @@ -294,34 +294,44 @@ module.exports = { { name: 'WETH', address: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', - amount: '1000000000000000000', + amount: process.env.WETH_MAINNET_RESTRICT || '1000000000000000000', }, { name: 'MATIC', address: '0x7D1AfA7B718fb893dB30A3aBc0Cfc608AaCfeBB0', - amount: '1000000000000000000000', + amount: process.env.MATIC_MAINNET_RESTRICT || '1000000000000000000000', }, { name: 'USDC', address: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', - amount: '1000000000', + amount: process.env.USDC_MAINNET_RESTRICT || '1000000000', + }, + { + name: 'USDT', + address: '0xdAC17F958D2ee523a2206206994597C13D831ec7', + amount: process.env.USDT_MAINNET_RESTRICT || '1000000000', + }, + { + name: 'DAI', + address: '0x6B175474E89094C44Da98b954EedeAC495271d0F', + amount: process.env.DAI_MAINNET_RESTRICT || '1000000000000000000000', }, ], goerli: [ { name: 'WETH', - address: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', - amount: '1000000000000000000', + address: '0x3f152B63Ec5CA5831061B2DccFb29a874C317502', + amount: process.env.WETH_GOERLI_RESTRICT || '1000000000000000000', }, { name: 'MATIC', address: '0x499d11E0b6eAC7c0593d8Fb292DCBbF815Fb29Ae', - amount: '1000000000000000000000', + amount: process.env.MATIC_GOERLI_RESTRICT || '1000000000000000000000', }, { name: 'USDC', address: '0x07865c6E87B9F70255377e024ace6630C1Eaa37F', - amount: '1000000000', + amount: process.env.USDC_GOERLI_RESTRICT || '1000000000', }, ], }, From 1d54649f59ee1cfaa207214c5a19008caeb35774 Mon Sep 17 00:00:00 2001 From: Westlad Date: Fri, 29 Apr 2022 14:59:06 +0100 Subject: [PATCH 3/3] fix: add config for ping-pong test --- config/default.js | 22 +++++++++++++++++++ .../migrations/2_deploy_upgradeable.js | 1 + 2 files changed, 23 insertions(+) diff --git a/config/default.js b/config/default.js index b9b417f2c..f6912bcb9 100644 --- a/config/default.js +++ b/config/default.js @@ -290,6 +290,28 @@ module.exports = { amount: '1000000000000', }, ], + development: [ + { + name: 'MockERC20', + address: '0xB5Acbe9a0F1F8B98F3fC04471F7fE5d2c222cB44', + amount: 200, + }, + { + name: 'Test-Eth', + address: '0x3f152B63Ec5CA5831061B2DccFb29a874C317502', + amount: '10000000000000000000000', + }, + { + name: 'MATIC', + address: '0x499d11E0b6eAC7c0593d8Fb292DCBbF815Fb29Ae', + amount: '10000000000000000000000', + }, + { + name: 'USDC', + address: '0x07865c6e87b9f70255377e024ace6630c1eaa37f', + amount: '1000000000000', + }, + ], mainnet: [ { name: 'WETH', diff --git a/nightfall-deployer/migrations/2_deploy_upgradeable.js b/nightfall-deployer/migrations/2_deploy_upgradeable.js index 5c9381b8f..4a5fe56cc 100644 --- a/nightfall-deployer/migrations/2_deploy_upgradeable.js +++ b/nightfall-deployer/migrations/2_deploy_upgradeable.js @@ -46,6 +46,7 @@ module.exports = async function (deployer) { await challengers.setBootChallenger(bootChallenger); const restrictions = await Shield.deployed(); // restrict transfer amounts + console.log('**TEST**', process.env.ETH_NETWORK, RESTRICTIONS.tokens, RESTRICTIONS); for (let token of RESTRICTIONS.tokens[process.env.ETH_NETWORK]) { console.log(`Max deposit restriction for ${token.name}: ${token.amount}`); await restrictions.setRestriction(token.address, token.amount);