From 713c36534e301ecb4342a8e5784b6b1a54a13b34 Mon Sep 17 00:00:00 2001 From: Alain Olivier Date: Tue, 12 Mar 2024 15:21:15 +0100 Subject: [PATCH 01/11] chore(tasks): update forwarder-related tasks --- tasks/deploy_forwarder_bsc.js | 12 +++++++++--- tasks/deploy_forwarder_gnosis.js | 12 +++++++++--- tasks/deploy_forwarder_mainnet.js | 10 ++++++++-- tasks/deploy_forwarder_polygon.js | 12 +++++++++--- 4 files changed, 35 insertions(+), 11 deletions(-) diff --git a/tasks/deploy_forwarder_bsc.js b/tasks/deploy_forwarder_bsc.js index e00974e..0dbd508 100644 --- a/tasks/deploy_forwarder_bsc.js +++ b/tasks/deploy_forwarder_bsc.js @@ -2,7 +2,7 @@ const { task } = require('hardhat/config') const { ADDRESSES: { - BSC: { PNT } + BSC: { PNT, SAFE, FORWARDER } } } = require('../lib/constants') @@ -10,10 +10,16 @@ const deploy = async (_args, _hre) => { if (_hre.network.name !== 'bsc') { throw new Error('Invalid network') } - const Forwarder = await _hre.ethers.getContractFactory('ForwarderHost') + const Forwarder = await _hre.ethers.getContractFactory('Forwarder') console.log('Deploying forwarder on BSC ...') - const forwarder = await Forwarder.deploy(PNT) + const forwarder = await Forwarder.deploy(PNT, _hre.ethers.ZeroAddress) console.log('Forwarder deployed at', forwarder.target) } +// eslint-disable-next-line no-unused-vars +const transferOwnership = async (_args, _hre) => { + const c = await _hre.ethers.getContractAt('Forwarder', FORWARDER) + await c.transferOwnership(SAFE) +} + task('deploy:forwarder-bsc', 'Deploy Forwarder on BSC', deploy) diff --git a/tasks/deploy_forwarder_gnosis.js b/tasks/deploy_forwarder_gnosis.js index 7c4fd98..624c24e 100644 --- a/tasks/deploy_forwarder_gnosis.js +++ b/tasks/deploy_forwarder_gnosis.js @@ -2,7 +2,7 @@ const { task } = require('hardhat/config') const { ADDRESSES: { - GNOSIS: { PNT } + GNOSIS: { PNT, FORWARDER, SAFE } } } = require('../lib/constants') @@ -10,10 +10,16 @@ const deploy = async (_args, _hre) => { if (_hre.network.name !== 'gnosis') { throw new Error('Invalid network') } - const Forwarder = await _hre.ethers.getContractFactory('ForwarderHost') + const Forwarder = await _hre.ethers.getContractFactory('Forwarder') console.log('Deploying forwarder on Gnosis ...') - const forwarder = await Forwarder.deploy(PNT) + const forwarder = await Forwarder.deploy(PNT, _hre.ethers.ZeroAddress) console.log('Forwarder deployed at', forwarder.target) } +// eslint-disable-next-line no-unused-vars +const transferOwnership = async (_args, _hre) => { + const c = await _hre.ethers.getContractAt('Forwarder', FORWARDER) + await c.transferOwnership(SAFE) +} + task('deploy:forwarder-gnosis', 'Deploy Forwarder on Gnosis', deploy) diff --git a/tasks/deploy_forwarder_mainnet.js b/tasks/deploy_forwarder_mainnet.js index f640dc9..40b5cb4 100644 --- a/tasks/deploy_forwarder_mainnet.js +++ b/tasks/deploy_forwarder_mainnet.js @@ -2,7 +2,7 @@ const { task } = require('hardhat/config') const { ADDRESSES: { - MAINNET: { PNT, ERC20_VAULT } + MAINNET: { PNT, ERC20_VAULT, FORWARDER, SAFE } } } = require('../lib/constants') @@ -10,10 +10,16 @@ const deploy = async (_args, _hre) => { if (_hre.network.name !== 'mainnet') { throw new Error('Invalid network') } - const Forwarder = await _hre.ethers.getContractFactory('ForwarderNative') + const Forwarder = await _hre.ethers.getContractFactory('Forwarder') console.log('Deploying forwarder on Ethereum ...') const forwarder = await Forwarder.deploy(PNT, ERC20_VAULT) console.log('Forwarder deployed at', forwarder.target) } +// eslint-disable-next-line no-unused-vars +const transferOwnership = async (_args, _hre) => { + const c = await _hre.ethers.getContractAt('Forwarder', FORWARDER) + await c.transferOwnership(SAFE) +} + task('deploy:forwarder-mainnet', 'Deploy Forwarder on Mainnet', deploy) diff --git a/tasks/deploy_forwarder_polygon.js b/tasks/deploy_forwarder_polygon.js index 78df7bb..bc24ab7 100644 --- a/tasks/deploy_forwarder_polygon.js +++ b/tasks/deploy_forwarder_polygon.js @@ -2,7 +2,7 @@ const { task } = require('hardhat/config') const { ADDRESSES: { - POLYGON: { PNT } + POLYGON: { PNT, FORWARDER, SAFE } } } = require('../lib/constants') @@ -10,10 +10,16 @@ const deploy = async (_args, _hre) => { if (_hre.network.name !== 'polygon') { throw new Error('Invalid network') } - const Forwarder = await _hre.ethers.getContractFactory('ForwarderHost') + const Forwarder = await _hre.ethers.getContractFactory('Forwarder') console.log('Deploying forwarder on Polygon ...') - const forwarder = await Forwarder.deploy(PNT) + const forwarder = await Forwarder.deploy(PNT, _hre.ethers.ZeroAddress) console.log('Forwarder deployed at', forwarder.target) } +// eslint-disable-next-line no-unused-vars +const transferOwnership = async (_args, _hre) => { + const c = await _hre.ethers.getContractAt('Forwarder', FORWARDER) + await c.transferOwnership(SAFE) +} + task('deploy:forwarder-polygon', 'Deploy Forwarder on Polygon', deploy) From 394f2adb45ec30b00ce6b308846c3cdfa664fd6f Mon Sep 17 00:00:00 2001 From: Alain Olivier Date: Tue, 12 Mar 2024 15:21:48 +0100 Subject: [PATCH 02/11] chore(hardhat): remove gas configuration --- hardhat.config.js | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/hardhat.config.js b/hardhat.config.js index cc3cf38..3187638 100644 --- a/hardhat.config.js +++ b/hardhat.config.js @@ -59,24 +59,19 @@ module.exports = { }, mainnet: { url: getEnvironmentVariable('MAINNET_NODE'), - accounts, - gasPrice: 20e9 + accounts }, polygon: { url: getEnvironmentVariable('POLYGON_NODE'), - accounts, - gasPrice: 250e9 + accounts }, gnosis: { url: getEnvironmentVariable('GNOSIS_NODE'), - accounts, - gasPrice: 15e9, - gas: 5e6 + accounts }, bsc: { url: getEnvironmentVariable('BSC_NODE'), - accounts, - gasPrice: 5e9 + accounts } }, etherscan: { From 8dac3a04bb21d9c2f538af999953c525702b54a6 Mon Sep 17 00:00:00 2001 From: Alain Olivier Date: Tue, 12 Mar 2024 15:25:00 +0100 Subject: [PATCH 03/11] refactor(constants): update forwarders and cross-executor addresses --- lib/constants.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/constants.js b/lib/constants.js index 688b6c4..f393bc2 100644 --- a/lib/constants.js +++ b/lib/constants.js @@ -14,7 +14,7 @@ module.exports = { SAFE: '0xfE8BCE5b156D9bCD28b5373CDC6b4F08B4b9646a', FINANCE_VAULT: '0x6239968e6231164687CB40f8389d933dD7f7e0A5', FINANCE: '0x3d749Bc0eb27795Da58d2f67a2D6527A95567aEC', - FORWARDER: '0x99405B4E46256dD28e424A0EDf296A28e2aE32a0', + FORWARDER: '0x2422eb5B6a20C7b8e3567C12Ed6f5ED9d1Cf1f79', PNT: '0x8805Aa0C1a8e59b03fA95740F691E28942Cf44f6', DAOPNT: '0xFF8Ce5Aca26251Cc3f31e597291c71794C06092a', TOKEN_MANAGER: '0xCec0058735D50de98d3715792569921FEb9EfDC1', @@ -22,21 +22,21 @@ module.exports = { }, POLYGON: { PNT: '0xb6bcae6468760bc0cdfb9c8ef4ee75c9dd23e1ed', - FORWARDER: '0xC85cd78555DF9991245F15c7AA6c4eDBb7791c19', + FORWARDER: '0xC4A989fcb73c6563580dfe9d5439088a98D6C1de', PNT_MINTER: '0x66917DDA63bC429AE6555e6a2ec17f583FeA732a', SAFE: '0x9203CD49BAb23Ed6e1EE8D6AB376DD5A9CA8486B' }, BSC: { PNT: '0xdaacB0Ab6Fb34d24E8a67BfA14BF4D95D4C7aF92', - FORWARDER: '0x23bAa1e6572233f3cf02a002db865FCa495f2926', + FORWARDER: '0x545d1Da3095a74336D121a8e2078104DDC64AfCE', SAFE: '0x9203CD49BAb23Ed6e1EE8D6AB376DD5A9CA8486B' }, MAINNET: { PNT: '0x89Ab32156e46F46D02ade3FEcbe5Fc4243B9AAeD', ETHPNT: '0xf4ea6b892853413bd9d9f1a5d3a620a0ba39c5b2', PBTC: '0x62199b909fb8b8cf870f97bef2ce6783493c4908', - FORWARDER: '0x4200Bf8D6eEb6D7EA46b9C99564cCb4246416412', - CROSS_EXECUTOR: '0xE0bFE5Ae5ceBbf666C381f267187379117d0dA73', + FORWARDER: '0xe2cb2C8fDc086FC576b49aCF2F71D44DDe7e3804', + CROSS_EXECUTOR: '0x6a4Bd6DE0de7b80F24A307f31B40856da975b5A7', ERC20_VAULT: '0xe396757EC7E6aC7C8E5ABE7285dde47b98F22db8', DANDELION_VOTING: '0x2211bFD97b1c02aE8Ac305d206e9780ba7D8BfF4', FINANCE_VAULT: '0xdd92eb1478d3189707ab7f4a5ace3a615cdd0476', From 2ced11bdb3b995348f1801bcd8fe9324444d0f26 Mon Sep 17 00:00:00 2001 From: Alain Olivier Date: Tue, 12 Mar 2024 22:06:54 +0100 Subject: [PATCH 04/11] fix(tasks): fix userdata decoding in metadata decoding --- tasks/decode-forwarder-metadata.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tasks/decode-forwarder-metadata.js b/tasks/decode-forwarder-metadata.js index 11bf502..ab2d911 100644 --- a/tasks/decode-forwarder-metadata.js +++ b/tasks/decode-forwarder-metadata.js @@ -22,13 +22,12 @@ task('utils:decode-forwarder-metadata', 'Decode the pNetwork Forwarder Metadata' protocolReceipt } = decodeMetadata(ethers, metadata) - const [callsAndTargets, originAddress, callerAddress] = abiCoder.decode(['bytes', 'address', 'address'], userData) + const [callsAndTargets, callerAddress] = abiCoder.decode(['bytes', 'address'], userData) console.log({ version, userData: { callsAndTargets, - originAddress, callerAddress }, sourceNetworkId, From cab430e8ade0fc9020874a656eb3b172678b0ddb Mon Sep 17 00:00:00 2001 From: Alain Olivier Date: Tue, 12 Mar 2024 22:15:39 +0100 Subject: [PATCH 05/11] test(fork): update tests with latest forwarders deployment --- test/fork/dao.test.js | 80 ++++++++++++------------------------------- 1 file changed, 21 insertions(+), 59 deletions(-) diff --git a/test/fork/dao.test.js b/test/fork/dao.test.js index bdbe771..dc620c3 100644 --- a/test/fork/dao.test.js +++ b/test/fork/dao.test.js @@ -24,6 +24,7 @@ const { LENDING_MANAGER, FEES_MANAGER, REWARDS_MANAGER, + FORWARDER: FORWARDER_ON_GNOSIS, ACL, DANDELION_VOTING, FINANCE_VAULT, @@ -45,7 +46,7 @@ const { CROSS_EXECUTOR, SAFE: SAFE_ON_ETH }, - POLYGON: { PNT: PNT_ON_POLYGON, PNT_MINTER: PNT_MINTER_ON_POLYGON } + POLYGON: { PNT: PNT_ON_POLYGON, PNT_MINTER: PNT_MINTER_ON_POLYGON, FORWARDER: FORWARDER_ON_POLYGON } }, MISC: { ONE_DAY }, PNETWORK_NETWORK_IDS @@ -73,7 +74,7 @@ const FORWARDER_STAKE_USER_DATA_2 = '0x0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000ddb5f4535123daa5ae343c24006f4075abaf5f7b0000000000000000000000000000000000000000000000000000000000000220000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000020000000000000000000000008805aa0c1a8e59b03fa95740f691e28942cf44f6000000000000000000000000dee8ebe2b7152eccd935fd67134bf1bad55302bc0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000044095ea7b3000000000000000000000000dee8ebe2b7152eccd935fd67134bf1bad55302bc0000000000000000000000000000000000000000000000000b0bfa54806c1db90000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000642b54f551000000000000000000000000ddb5f4535123daa5ae343c24006f4075abaf5f7b0000000000000000000000000000000000000000000000000b0bfa54806c1db90000000000000000000000000000000000000000000000000000000000093a8000000000000000000000000000000000000000000000000000000000' const WITHDRAW_INFLATION_FROM_GNOSIS_USER_DATA = // secretlint-disable-next-line - '0x00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000cf759bccfef5f322af58adae2d28885658b5e0200000000000000000000000000000000000000000000000000000000000003a0000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000003000000000000000000000000f4ea6b892853413bd9d9f1a5d3a620a0ba39c5b2000000000000000000000000f4ea6b892853413bd9d9f1a5d3a620a0ba39c5b2000000000000000000000000e396757ec7e6ac7c8e5abe7285dde47b98f22db80000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000000443352d49b000000000000000000000000e0bfe5ae5cebbf666c381f267187379117d0da73000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044095ea7b3000000000000000000000000e396757ec7e6ac7c8e5abe7285dde47b98f22db8000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000124c322525d000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000f4ea6b892853413bd9d9f1a5d3a620a0ba39c5b200000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000010000f1918e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002a30783632333939363865363233313136343638374342343066383338396439333364443766376530413500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000' + '0x00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000cf759bccfef5f322af58adae2d28885658b5e0200000000000000000000000000000000000000000000000000000000000003a0000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000003000000000000000000000000f4ea6b892853413bd9d9f1a5d3a620a0ba39c5b2000000000000000000000000f4ea6b892853413bd9d9f1a5d3a620a0ba39c5b2000000000000000000000000e396757ec7e6ac7c8e5abe7285dde47b98f22db80000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000000443352d49b0000000000000000000000006a4bd6de0de7b80f24a307f31b40856da975b5a7000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044095ea7b3000000000000000000000000e396757ec7e6ac7c8e5abe7285dde47b98f22db8000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000124c322525d000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000f4ea6b892853413bd9d9f1a5d3a620a0ba39c5b200000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000010000f1918e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002a30783632333939363865363233313136343638374342343066383338396439333364443766376530413500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000' const WITHDRAW_INFLATION_FROM_GNOSIS_USER_DATA_2 = // secretlint-disable-next-line '0x000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000003000000000000000000000000f4ea6b892853413bd9d9f1a5d3a620a0ba39c5b2000000000000000000000000f4ea6b892853413bd9d9f1a5d3a620a0ba39c5b2000000000000000000000000e396757ec7e6ac7c8e5abe7285dde47b98f22db80000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000000443352d49b00000000000000000000000001234567890123456789012345678901234567890000000000000000000000000000000000000000000000056bc75e2d63100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044095ea7b3000000000000000000000000e396757ec7e6ac7c8e5abe7285dde47b98f22db80000000000000000000000000000000000000000000000056bc75e2d63100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000124c322525d0000000000000000000000000000000000000000000000056bc75e2d63100000000000000000000000000000f4ea6b892853413bd9d9f1a5d3a620a0ba39c5b200000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000010000f1918e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002a30786631663635363861373635353964383563463638453635393766413538373534343138346444343600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000' @@ -180,11 +181,6 @@ describe('Integration tests on Gnosis deployment', () => { ] const missingSteps = async () => { - const Forwader = await ethers.getContractFactory('Forwarder') - forwarder = await Forwader.deploy(PNT_ON_GNOSIS, ethers.ZeroAddress) - await forwarder.whitelistOriginAddress(PNETWORK_NETWORK_IDS.POLYGON, ADDRESS_PLACEHOLDER.toLowerCase()) - await forwarder.addUnprivilegedCall('0x095ea7b3') - await daoVoting.connect(daoOwner).changeForwarder(forwarder.target) await mintPntOnGnosis(forwarder.target, ethers.parseUnits('1')) await mintPntOnGnosis(daoVoting.target, ethers.parseUnits('1')) } @@ -281,6 +277,7 @@ describe('Integration tests on Gnosis deployment', () => { registrationManager = RegistrationManager.attach(REGISTRATION_MANAGER) feesManager = EpochsManager.attach(FEES_MANAGER) rewardsManager = RewardsManager.attach(REWARDS_MANAGER) + forwarder = await ethers.getContractAt('Forwarder', FORWARDER_ON_GNOSIS) await missingSteps() @@ -772,7 +769,7 @@ describe('Integration tests on Gnosis deployment', () => { .withArgs(user.address, ethers.parseUnits('10')) }) - it('[dapp] should stake from forwarder call', async () => { + it('[dapp] should stake from forwarder call (1)', async () => { expect(await daoPNT.balanceOf(USER_ADDRESS)).to.be.eq(ethers.parseUnits('0')) const smBalance = await pntOnGnosis.balanceOf(STAKING_MANAGER) const metadata = encodeMetadata(ethers, { @@ -780,7 +777,7 @@ describe('Integration tests on Gnosis deployment', () => { // secretlint-disable-next-line FORWARDER_STAKE_USER_DATA.replaceAll(ADDRESS_PLACEHOLDER.slice(2), pntOnGnosis.target.slice(2)), sourceNetworkId: PNETWORK_NETWORK_IDS.POLYGON, - senderAddress: ADDRESS_PLACEHOLDER, + senderAddress: FORWARDER_ON_POLYGON, destinationNetworkId: PNETWORK_NETWORK_IDS.GNOSIS, receiverAddress: forwarder.target }) @@ -800,7 +797,7 @@ describe('Integration tests on Gnosis deployment', () => { // secretlint-disable-next-line FORWARDER_STAKE_USER_DATA_2, sourceNetworkId: PNETWORK_NETWORK_IDS.POLYGON, - senderAddress: ADDRESS_PLACEHOLDER, + senderAddress: FORWARDER_ON_POLYGON, destinationNetworkId: PNETWORK_NETWORK_IDS.GNOSIS, receiverAddress: forwarder.target }) @@ -843,7 +840,7 @@ describe('Integration tests on Gnosis deployment', () => { ethers.zeroPadValue(ethers.toBeHex(voteId), 32).slice(2) ), sourceNetworkId: PNETWORK_NETWORK_IDS.POLYGON, - senderAddress: ADDRESS_PLACEHOLDER, + senderAddress: FORWARDER_ON_POLYGON, destinationNetworkId: PNETWORK_NETWORK_IDS.GNOSIS, receiverAddress: forwarder.target }) @@ -974,9 +971,6 @@ describe('Integration tests on Ethereum deployment', () => { pegoutToken(vault, pnetwork, _recipient, PNT_ON_ETH, _value, _metadata) const missingSteps = async () => { - const CrossExecutor = await ethers.getContractFactory('CrossExecutor') - crossExecutor = await CrossExecutor.deploy(PNT_ON_ETH, ERC20_VAULT, DANDELION_VOTING) - await crossExecutor.whitelistOriginAddress(PNETWORK_NETWORK_IDS.GNOSIS, ADDRESS_PLACEHOLDER.toLocaleLowerCase()) daoVotingV1 = await ethers.getContractAt(DandelionVotingAbi, DANDELION_VOTING_V1) // open vote to change inflationOwner const executionScript = encodeCallScript( @@ -1013,6 +1007,7 @@ describe('Integration tests on Ethereum deployment', () => { ethPnt = await ethers.getContractAt(EthPntAbi, ETHPNT) vault = await ethers.getContractAt('IERC20Vault', ERC20_VAULT) safe = await ethers.getImpersonatedSigner(SAFE_ON_ETH) + crossExecutor = await ethers.getContractAt('CrossExecutor', CROSS_EXECUTOR) await sendEth(ethers, faucet, pnetwork.address, '10') await sendEth(ethers, faucet, association.address, '10') await sendEth(ethers, faucet, safe.address, '10') @@ -1028,7 +1023,7 @@ describe('Integration tests on Ethereum deployment', () => { crossExecutor.target.slice(2) ), sourceNetworkId: PNETWORK_NETWORK_IDS.GNOSIS, - senderAddress: ADDRESS_PLACEHOLDER, + senderAddress: FORWARDER_ON_GNOSIS, destinationNetworkId: PNETWORK_NETWORK_IDS.MAINNET, receiverAddress: crossExecutor.target }) @@ -1056,7 +1051,7 @@ describe('Integration tests on Ethereum deployment', () => { crossExecutor.target.slice(2) ), sourceNetworkId: PNETWORK_NETWORK_IDS.GNOSIS, - senderAddress: ADDRESS_PLACEHOLDER, + senderAddress: FORWARDER_ON_GNOSIS, destinationNetworkId: PNETWORK_NETWORK_IDS.MAINNET, receiverAddress: crossExecutor.target }) @@ -1174,19 +1169,7 @@ describe('Integration tests on Ethereum deployment', () => { ) }) - it.skip('[dapp] should open a vote for migrating ethPNT treasury funds (3)', async () => { - await crossExecutor - .connect(safe) - .call( - ethPnt.target, - ethPnt.interface.encodeFunctionData('withdrawInflation', [crossExecutor.target, ethers.parseUnits('100')]) - ) - await crossExecutor - .connect(safe) - .call( - ethPnt.target, - ethPnt.interface.encodeFunctionData('transfer', [FINANCE_VAULT_V1, ethers.parseUnits('100')]) - ) + it('[dapp] should open a vote for migrating ethPNT treasury funds (3)', async () => { await daoVotingV1.connect(association).newVote( // secretlint-disable-next-line '0x00000001dd92eb1478d3189707ab7f4a5ace3a615cdd047600000064beabacc8000000000000000000000000f4ea6b892853413bd9d9f1a5d3a620a0ba39c5b20000000000000000000000002211bfd97b1c02ae8ac305d206e9780ba7d8bff40000000000000000000000000000000000000000000000056bc75e2d63100000f4ea6b892853413bd9d9f1a5d3a620a0ba39c5b200000044095ea7b3000000000000000000000000e396757ec7e6ac7c8e5abe7285dde47b98f22db80000000000000000000000000000000000000000000000056bc75e2d63100000e396757ec7e6ac7c8e5abe7285dde47b98f22db800000124c322525d0000000000000000000000000000000000000000000000056bc75e2d63100000000000000000000000000000f4ea6b892853413bd9d9f1a5d3a620a0ba39c5b200000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000010000f1918e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002a307866316636353638613736353539643835634636384536353937664135383735343431383464443436000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000', @@ -1215,7 +1198,7 @@ describe('Integration tests on Ethereum deployment', () => { }) // pBTC is not native! so the execution script should not peg-in - it.skip('[dapp] should open a vote for migrating pBTC treasury funds (4', async () => { + it.skip('[dapp] should open a vote for migrating pBTC treasury funds (4)', async () => { const amount = ethers.parseEther('100') const pbtc = await ethers.getContractAt(pBTConEthereumAbi, PBTC_ON_ETHEREUM) const minter = await ethers.getImpersonatedSigner(PBTC_MINTER) @@ -1248,32 +1231,12 @@ describe('Integration tests on Ethereum deployment', () => { PNETWORK_NETWORK_IDS.GNOSIS ) }) - - it.skip('should be able to change inflationOwner from CrossExecutor', async () => { - await expect( - crossExecutor - .connect(safe) - .call(ETHPNT, ethPnt.interface.encodeFunctionData('setInflationOwner', [association.address])) - ).to.emit(ethPnt, 'NewInflationOwner') - expect(await ethPnt.inflationOwner()).to.be.eq(association.address) - }) - - it.skip('should not be able to change inflationOwner from CrossExecutor without ownership', async () => { - await expect( - crossExecutor - .connect(association) - .call(ETHPNT, ethPnt.interface.encodeFunctionData('setInflationOwner', [association.address])) - ).to.be.revertedWith('Ownable: caller is not the owner') - expect(await ethPnt.inflationOwner()).to.be.eq(crossExecutor.target) - }) }) describe('Integration tests on Polygon deployment', () => { let pntOnPolygon, faucet, minter, user, forwarder const missingSteps = async () => { - const Forwader = await ethers.getContractFactory('Forwarder') - forwarder = await Forwader.deploy(PNT_ON_POLYGON, ethers.ZeroAddress) - await mintPToken(pntOnPolygon, minter, user.address, ethers.parseEther('1')) + await mintPToken(pntOnPolygon, minter, user.address, ethers.parseUnits('2')) await pntOnPolygon.connect(user).transfer(forwarder.target, ethers.parseUnits('1')) } @@ -1284,6 +1247,7 @@ describe('Integration tests on Polygon deployment', () => { minter = await ethers.getImpersonatedSigner(PNT_MINTER_ON_POLYGON) ;[faucet] = await ethers.getSigners() user = await ethers.getImpersonatedSigner(USER_ADDRESS) + forwarder = await ethers.getContractAt('Forwarder', FORWARDER_ON_POLYGON) await sendEth(ethers, faucet, user.address, '100') await missingSteps() }) @@ -1293,7 +1257,7 @@ describe('Integration tests on Polygon deployment', () => { await expect( forwarder.connect(user).call( '100000000000000000', - ADDRESS_PLACEHOLDER, + FORWARDER_ON_GNOSIS, // secretlint-disable-next-line '0x000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000123456789012345678901234567890123456789000000000000000000000000dee8ebe2b7152eccd935fd67134bf1bad55302bc0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000044095ea7b3000000000000000000000000dee8ebe2b7152eccd935fd67134bf1bad55302bc0000000000000000000000000000000000000000000000000162ea854d0fc0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000642b54f551000000000000000000000000ddb5f4535123daa5ae343c24006f4075abaf5f7b0000000000000000000000000000000000000000000000000162ea854d0fc0000000000000000000000000000000000000000000000000000000000000093a8000000000000000000000000000000000000000000000000000000000', PNETWORK_NETWORK_IDS.GNOSIS @@ -1303,7 +1267,7 @@ describe('Integration tests on Polygon deployment', () => { .withArgs( forwarder.target, 100000000000000000n, - ADDRESS_PLACEHOLDER.toLowerCase().slice(2), + FORWARDER_ON_GNOSIS.toLowerCase().slice(2), // secretlint-disable-next-line FORWARDER_STAKE_USER_DATA, PNETWORK_NETWORK_IDS.POLYGON, @@ -1317,15 +1281,14 @@ describe('Integration tests on Polygon deployment', () => { user.sendTransaction({ to: forwarder.target, // secretlint-disable-next-line - data: '0x996adf550000000000000000000000000000000000000000000000000b1310c5a2bfcbac00000000000000000000000099405b4e46256dd28e424a0edf296a28e2ae32a0000000000000000000000000000000000000000000000000000000000000008000f1918e000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000220000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000020000000000000000000000008805aa0c1a8e59b03fa95740f691e28942cf44f6000000000000000000000000dee8ebe2b7152eccd935fd67134bf1bad55302bc0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000044095ea7b3000000000000000000000000dee8ebe2b7152eccd935fd67134bf1bad55302bc0000000000000000000000000000000000000000000000000b0bfa54806c1db90000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000642b54f551000000000000000000000000ddb5f4535123daa5ae343c24006f4075abaf5f7b0000000000000000000000000000000000000000000000000b0bfa54806c1db90000000000000000000000000000000000000000000000000000000000093a8000000000000000000000000000000000000000000000000000000000' + data: '0x996adf550000000000000000000000000000000000000000000000000b1310c5a2bfcbac0000000000000000000000002422eb5b6a20c7b8e3567c12ed6f5ed9d1cf1f79000000000000000000000000000000000000000000000000000000000000008000f1918e000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000220000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000020000000000000000000000008805aa0c1a8e59b03fa95740f691e28942cf44f6000000000000000000000000dee8ebe2b7152eccd935fd67134bf1bad55302bc0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000044095ea7b3000000000000000000000000dee8ebe2b7152eccd935fd67134bf1bad55302bc0000000000000000000000000000000000000000000000000b0bfa54806c1db90000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000642b54f551000000000000000000000000ddb5f4535123daa5ae343c24006f4075abaf5f7b0000000000000000000000000000000000000000000000000b0bfa54806c1db90000000000000000000000000000000000000000000000000000000000093a8000000000000000000000000000000000000000000000000000000000' }) ) .to.emit(pntOnPolygon, 'Redeem') .withArgs( forwarder.target, ethers.parseUnits('0.797999999999789996'), - ADDRESS_PLACEHOLDER.toLowerCase().slice(2), - // secretlint-disable-next-line + FORWARDER_ON_GNOSIS.toLowerCase().slice(2), FORWARDER_STAKE_USER_DATA_2, PNETWORK_NETWORK_IDS.POLYGON, PNETWORK_NETWORK_IDS.GNOSIS @@ -1336,7 +1299,7 @@ describe('Integration tests on Polygon deployment', () => { await expect( forwarder.connect(user).call( '0', - ADDRESS_PLACEHOLDER, + FORWARDER_ON_GNOSIS, // secretlint-disable-next-line '0x0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000cf759bccfef5f322af58adae2d28885658b5e02000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000064571eed31000000000000000000000000ddb5f4535123daa5ae343c24006f4075abaf5f7b0000000000000000000000000000000000000000000000000000000000000025000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000', PNETWORK_NETWORK_IDS.GNOSIS @@ -1346,8 +1309,7 @@ describe('Integration tests on Polygon deployment', () => { .withArgs( forwarder.target, 1n, - ADDRESS_PLACEHOLDER.toLowerCase().slice(2), - // secretlint-disable-next-line + FORWARDER_ON_GNOSIS.slice(2).toLowerCase(), FORWARDER_DELEGATE_VOTE_USER_DATA, PNETWORK_NETWORK_IDS.POLYGON, PNETWORK_NETWORK_IDS.GNOSIS From bad397e5462a2eec5d36cfcca765db3e5dedf762 Mon Sep 17 00:00:00 2001 From: Alain Olivier Date: Wed, 13 Mar 2024 18:22:09 +0100 Subject: [PATCH 06/11] test(fork): add integration test for withdrawing inflation from Gnosis --- test/fork/dao.test.js | 67 ++++++++++++++++++------------------------- 1 file changed, 28 insertions(+), 39 deletions(-) diff --git a/test/fork/dao.test.js b/test/fork/dao.test.js index dc620c3..bb9ed50 100644 --- a/test/fork/dao.test.js +++ b/test/fork/dao.test.js @@ -75,9 +75,9 @@ const FORWARDER_STAKE_USER_DATA_2 = const WITHDRAW_INFLATION_FROM_GNOSIS_USER_DATA = // secretlint-disable-next-line '0x00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000cf759bccfef5f322af58adae2d28885658b5e0200000000000000000000000000000000000000000000000000000000000003a0000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000003000000000000000000000000f4ea6b892853413bd9d9f1a5d3a620a0ba39c5b2000000000000000000000000f4ea6b892853413bd9d9f1a5d3a620a0ba39c5b2000000000000000000000000e396757ec7e6ac7c8e5abe7285dde47b98f22db80000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000000443352d49b0000000000000000000000006a4bd6de0de7b80f24a307f31b40856da975b5a7000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044095ea7b3000000000000000000000000e396757ec7e6ac7c8e5abe7285dde47b98f22db8000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000124c322525d000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000f4ea6b892853413bd9d9f1a5d3a620a0ba39c5b200000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000010000f1918e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002a30783632333939363865363233313136343638374342343066383338396439333364443766376530413500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000' -const WITHDRAW_INFLATION_FROM_GNOSIS_USER_DATA_2 = +const WITHDRAW_INFLATION_FROM_GNOSIS_USER_DATA_3 = // secretlint-disable-next-line - '0x000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000003000000000000000000000000f4ea6b892853413bd9d9f1a5d3a620a0ba39c5b2000000000000000000000000f4ea6b892853413bd9d9f1a5d3a620a0ba39c5b2000000000000000000000000e396757ec7e6ac7c8e5abe7285dde47b98f22db80000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000000443352d49b00000000000000000000000001234567890123456789012345678901234567890000000000000000000000000000000000000000000000056bc75e2d63100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044095ea7b3000000000000000000000000e396757ec7e6ac7c8e5abe7285dde47b98f22db80000000000000000000000000000000000000000000000056bc75e2d63100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000124c322525d0000000000000000000000000000000000000000000000056bc75e2d63100000000000000000000000000000f4ea6b892853413bd9d9f1a5d3a620a0ba39c5b200000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000010000f1918e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002a30786631663635363861373635353964383563463638453635393766413538373534343138346444343600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000' + '0x00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000cf759bccfef5f322af58adae2d28885658b5e0200000000000000000000000000000000000000000000000000000000000003a0000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000003000000000000000000000000f4ea6b892853413bd9d9f1a5d3a620a0ba39c5b2000000000000000000000000f4ea6b892853413bd9d9f1a5d3a620a0ba39c5b2000000000000000000000000e396757ec7e6ac7c8e5abe7285dde47b98f22db80000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000000443352d49b0000000000000000000000006a4bd6de0de7b80f24a307f31b40856da975b5a70000000000000000000000000000000000000000000000056bc75e2d63100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044095ea7b3000000000000000000000000e396757ec7e6ac7c8e5abe7285dde47b98f22db80000000000000000000000000000000000000000000000056bc75e2d63100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000124c322525d0000000000000000000000000000000000000000000000056bc75e2d63100000000000000000000000000000f4ea6b892853413bd9d9f1a5d3a620a0ba39c5b200000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000010000f1918e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002a30786631663635363861373635353964383563463638453635393766413538373534343138346444343600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000' const getBytes = (_hexString) => Buffer.from(_hexString.slice(2), 'hex') @@ -897,37 +897,6 @@ describe('Integration tests on Gnosis deployment', () => { .withArgs(pntOnGnosis.target, ASSOCIATION, ethers.parseUnits('200')) }) - it('[dapp] should open a vote to withdraw inflation', async () => { - await mintPntOnGnosis(daoTreasury.target, ethers.parseUnits('1000000')) - await grantCreateVotesPermission(acl, daoOwner, tokenHolders[0]) - await daoVoting.connect(tokenHolders[0]).newVote( - // secretlint-disable-next-line - '0x000000010259461eed4d76d4f0f900f9035f6c4dfb39159a000004a408e1e4d3000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000440005fe7f90000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003a0000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000003000000000000000000000000f4ea6b892853413bd9d9f1a5d3a620a0ba39c5b2000000000000000000000000f4ea6b892853413bd9d9f1a5d3a620a0ba39c5b2000000000000000000000000e396757ec7e6ac7c8e5abe7285dde47b98f22db80000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000000443352d49b00000000000000000000000001234567890123456789012345678901234567890000000000000000000000000000000000000000000000056bc75e2d63100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044095ea7b3000000000000000000000000e396757ec7e6ac7c8e5abe7285dde47b98f22db80000000000000000000000000000000000000000000000056bc75e2d63100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000124c322525d0000000000000000000000000000000000000000000000056bc75e2d63100000000000000000000000000000f4ea6b892853413bd9d9f1a5d3a620a0ba39c5b200000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000010000f1918e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002a30786631663635363861373635353964383563463638453635393766413538373534343138346444343600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002a30783031323334353637383930313233343536373839303132333435363738393031323334353637383900000000000000000000000000000000000000000000'.replace( - '0259461eed4d76d4f0f900f9035f6c4dfb39159a', - pntOnGnosis.target.slice(2) - ), - 'A https://ipfs.io/ipfs/QmUmAhPhF7ABGZ7ypbDoqtbmqjSQDHL7p7y87rXAH5acvJ', - false - ) - const voteId = await daoVoting.votesLength() - await Promise.all(tokenHolders.map((_holder) => daoVoting.connect(_holder).vote(voteId, true))) - await time.increase(ONE_DAY * 4) - await expect(daoVoting.executeVote(voteId)) - .to.emit(daoVoting, 'ExecuteVote') - .withArgs(voteId) - .and.to.emit(pntOnGnosis, 'Transfer') - .withArgs(daoVoting.target, ethers.ZeroAddress, 1) - .and.to.emit(pntOnGnosis, 'Redeem') - .withArgs( - daoVoting.target, - 1, - ADDRESS_PLACEHOLDER, - WITHDRAW_INFLATION_FROM_GNOSIS_USER_DATA_2, - PNETWORK_NETWORK_IDS.GNOSIS, - PNETWORK_NETWORK_IDS.MAINNET - ) - }) - it('should correctly encode metadata', () => { const userData = '0xc0ffee03' // secretlint-disable-next-line @@ -955,6 +924,31 @@ describe('Integration tests on Gnosis deployment', () => { daoVoting.connect(tokenHolders[0]).newVote('0x', 'Should I become the owner?', true) ).to.be.revertedWith('DANDELION_VOTING_CAN_NOT_OPEN_VOTE') }) + + it('[dapp] should open a vote to withdraw inflation', async () => { + const votesLength = await daoVoting.votesLength() + expect(votesLength).to.be.eq(0) + const user = await ethers.getImpersonatedSigner('0xa41657bf225F8Ec7E2010C89c3F084172948264D') + await grantCreateVotesPermission(acl, daoOwner, user.address) + await user.sendTransaction({ + to: '0x0cf759bcCfEf5f322af58ADaE2D28885658B5e02', + // secretlint-disable-next-line + data: '0x24160baa000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000004e000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000460000000012422eb5b6a20c7b8e3567c12ed6f5ed9d1cf1f7900000444996adf5500000000000000000000000000000000000000000000000000000000000000000000000000000000000000006a4bd6de0de7b80f24a307f31b40856da975b5a70000000000000000000000000000000000000000000000000000000000000080005fe7f90000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003a0000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000003000000000000000000000000f4ea6b892853413bd9d9f1a5d3a620a0ba39c5b2000000000000000000000000f4ea6b892853413bd9d9f1a5d3a620a0ba39c5b2000000000000000000000000e396757ec7e6ac7c8e5abe7285dde47b98f22db80000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000000443352d49b0000000000000000000000006a4bd6de0de7b80f24a307f31b40856da975b5a70000000000000000000000000000000000000000000000056bc75e2d63100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044095ea7b3000000000000000000000000e396757ec7e6ac7c8e5abe7285dde47b98f22db80000000000000000000000000000000000000000000000056bc75e2d63100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000124c322525d0000000000000000000000000000000000000000000000056bc75e2d63100000000000000000000000000000f4ea6b892853413bd9d9f1a5d3a620a0ba39c5b200000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000010000f1918e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002a307866316636353638613736353539643835634636384536353937664135383735343431383464443436000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000051546573742077697468647261772068747470733a2f2f697066732e696f2f697066732f516d5975427641464677524c4d5643346265346b416976467532314a485770554b4a6855545a696f426931393977000000000000000000000000000000' + }) + const voteId = await daoVoting.votesLength() + await Promise.all(tokenHolders.map((_holder) => daoVoting.connect(_holder).vote(voteId, true))) + await time.increase(ONE_DAY * 4) + await expect(daoVoting.executeVote(voteId)) + .to.emit(pntOnGnosis, 'Redeem') + .withArgs( + FORWARDER_ON_GNOSIS, + 1, + CROSS_EXECUTOR.slice(2).toLowerCase(), + WITHDRAW_INFLATION_FROM_GNOSIS_USER_DATA_3, + PNETWORK_NETWORK_IDS.GNOSIS, + PNETWORK_NETWORK_IDS.MAINNET + ) + }) }) describe('Integration tests on Ethereum deployment', () => { @@ -1044,12 +1038,7 @@ describe('Integration tests on Ethereum deployment', () => { it('[dapp] should process pegOut, withdrawInflation, and pegIn to treasury (2)', async () => { const metadata = encodeMetadata(ethers, { - userData: - // secretlint-disable-next-line - WITHDRAW_INFLATION_FROM_GNOSIS_USER_DATA_2.replaceAll( - ADDRESS_PLACEHOLDER.slice(2), - crossExecutor.target.slice(2) - ), + userData: WITHDRAW_INFLATION_FROM_GNOSIS_USER_DATA_3, sourceNetworkId: PNETWORK_NETWORK_IDS.GNOSIS, senderAddress: FORWARDER_ON_GNOSIS, destinationNetworkId: PNETWORK_NETWORK_IDS.MAINNET, From e07f37bbbc562a1b7ea49f5c2264dc3520eb408e Mon Sep 17 00:00:00 2001 From: Alain Olivier Date: Thu, 14 Mar 2024 12:30:46 +0100 Subject: [PATCH 07/11] refactor(constants): add new ethPNT forwarder on mainnet --- lib/constants.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/constants.js b/lib/constants.js index f393bc2..a4e7c71 100644 --- a/lib/constants.js +++ b/lib/constants.js @@ -35,7 +35,8 @@ module.exports = { PNT: '0x89Ab32156e46F46D02ade3FEcbe5Fc4243B9AAeD', ETHPNT: '0xf4ea6b892853413bd9d9f1a5d3a620a0ba39c5b2', PBTC: '0x62199b909fb8b8cf870f97bef2ce6783493c4908', - FORWARDER: '0xe2cb2C8fDc086FC576b49aCF2F71D44DDe7e3804', + FORWARDER_PNT: '0xe2cb2C8fDc086FC576b49aCF2F71D44DDe7e3804', + FORWARDER_ETHPNT: '0xD60792770ca2B54b9231041c8AF641f48818dA8D', CROSS_EXECUTOR: '0x6a4Bd6DE0de7b80F24A307f31B40856da975b5A7', ERC20_VAULT: '0xe396757EC7E6aC7C8E5ABE7285dde47b98F22db8', DANDELION_VOTING: '0x2211bFD97b1c02aE8Ac305d206e9780ba7D8BfF4', From ad7f33c8a9bac0a60a7df33ce3c423522e0a97bb Mon Sep 17 00:00:00 2001 From: Alain Olivier Date: Thu, 14 Mar 2024 12:31:16 +0100 Subject: [PATCH 08/11] test(fork): add integration test for depositing rewards --- test/fork/dao.test.js | 55 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/test/fork/dao.test.js b/test/fork/dao.test.js index bb9ed50..59f4644 100644 --- a/test/fork/dao.test.js +++ b/test/fork/dao.test.js @@ -41,6 +41,7 @@ const { PNETWORK, ASSOCIATION, FINANCE_VAULT: FINANCE_VAULT_V1, + FORWARDER_ETHPNT: FORWARDER_ON_MAINNET_ETHPNT, PBTC: PBTC_ON_ETHEREUM, PBTC_MINTER, CROSS_EXECUTOR, @@ -78,6 +79,9 @@ const WITHDRAW_INFLATION_FROM_GNOSIS_USER_DATA = const WITHDRAW_INFLATION_FROM_GNOSIS_USER_DATA_3 = // secretlint-disable-next-line '0x00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000cf759bccfef5f322af58adae2d28885658b5e0200000000000000000000000000000000000000000000000000000000000003a0000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000003000000000000000000000000f4ea6b892853413bd9d9f1a5d3a620a0ba39c5b2000000000000000000000000f4ea6b892853413bd9d9f1a5d3a620a0ba39c5b2000000000000000000000000e396757ec7e6ac7c8e5abe7285dde47b98f22db80000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000000443352d49b0000000000000000000000006a4bd6de0de7b80f24a307f31b40856da975b5a70000000000000000000000000000000000000000000000056bc75e2d63100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044095ea7b3000000000000000000000000e396757ec7e6ac7c8e5abe7285dde47b98f22db80000000000000000000000000000000000000000000000056bc75e2d63100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000124c322525d0000000000000000000000000000000000000000000000056bc75e2d63100000000000000000000000000000f4ea6b892853413bd9d9f1a5d3a620a0ba39c5b200000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000010000f1918e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002a30786631663635363861373635353964383563463638453635393766413538373534343138346444343600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000' +const DEPOSIT_REWARDS_USER_DATA = + // secretlint-disable-next-line + '0x00000000000000000000000000000000000000000000000000000000000000400000000000000000000000002211bfd97b1c02ae8ac305d206e9780ba7d8bff40000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000020000000000000000000000008805aa0c1a8e59b03fa95740f691e28942cf44f60000000000000000000000002ec44f9f31a55b52b3c1ff98647e38d63f829fb70000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000044095ea7b30000000000000000000000002ec44f9f31a55b52b3c1ff98647e38d63f829fb70000000000000000000000000000000000000000000000000000000000000063000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044dc5e3ccd0000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000006300000000000000000000000000000000000000000000000000000000' const getBytes = (_hexString) => Buffer.from(_hexString.slice(2), 'hex') @@ -825,6 +829,21 @@ describe('Integration tests on Gnosis deployment', () => { ) }) + it('[dapp] should deposit rewards from forwarder call (1)', async () => { + const depositedAmount = await rewardsManager.depositedAmountByEpoch(4) + const metadata = encodeMetadata(ethers, { + userData: DEPOSIT_REWARDS_USER_DATA, + sourceNetworkId: PNETWORK_NETWORK_IDS.MAINNET, + senderAddress: FORWARDER_ON_MAINNET_ETHPNT, + destinationNetworkId: PNETWORK_NETWORK_IDS.GNOSIS, + receiverAddress: forwarder.target + }) + await expect(mintPToken(pntOnGnosis, pntMinter, forwarder.target, 99n, metadata)) + .to.emit(pntOnGnosis, 'Transfer') + .withArgs(FORWARDER_ON_GNOSIS, REWARDS_MANAGER, 99) + expect(await rewardsManager.depositedAmountByEpoch(4)).to.be.eq(99n + depositedAmount) + }) + it('[dapp] should delegateVote from forwarder call', async () => { const stakedAmount = ethers.parseUnits('10') await mintPntOnGnosis(user.address, stakedAmount) @@ -1186,6 +1205,42 @@ describe('Integration tests on Ethereum deployment', () => { ) }) + it('[dapp] should open a vote for depositing rewards', async () => { + expect(await ethPnt.inflationOwner()).to.be.eq(crossExecutor.target) + const INFLATION_OWNER_SLOT = '0x131' // 305 (found brute forcing eth_getStorageAt()) + await ethers.provider.send('hardhat_setStorageAt', [ + ethPnt.target, + INFLATION_OWNER_SLOT, + ethers.zeroPadValue(daoVotingV1.target, 32) + ]) + expect(await ethPnt.inflationOwner()).to.be.eq(daoVotingV1.target) + await daoVotingV1.connect(association).newVote( + // secretlint-disable-next-line + '0x00000001f4ea6b892853413bd9d9f1a5d3a620a0ba39c5b2000000443352d49b000000000000000000000000dd92eb1478d3189707ab7f4a5ace3a615cdd04760000000000000000000000000000000000000000000000056bc75e2d63100000dd92eb1478d3189707ab7f4a5ace3a615cdd047600000064beabacc8000000000000000000000000f4ea6b892853413bd9d9f1a5d3a620a0ba39c5b20000000000000000000000002211bfd97b1c02ae8ac305d206e9780ba7d8bff40000000000000000000000000000000000000000000000056bc75e2d63100000f4ea6b892853413bd9d9f1a5d3a620a0ba39c5b200000044095ea7b3000000000000000000000000d60792770ca2b54b9231041c8af641f48818da8d0000000000000000000000000000000000000000000000056bc75e2d63100000d60792770ca2b54b9231041c8af641f48818da8d000002a4996adf5500000000000000000000000000000000000000000000000000000000000000640000000000000000000000002422eb5b6a20c7b8e3567c12ed6f5ed9d1cf1f79000000000000000000000000000000000000000000000000000000000000008000f1918e000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000020000000000000000000000008805aa0c1a8e59b03fa95740f691e28942cf44f60000000000000000000000002ec44f9f31a55b52b3c1ff98647e38d63f829fb70000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000044095ea7b30000000000000000000000002ec44f9f31a55b52b3c1ff98647e38d63f829fb70000000000000000000000000000000000000000000000000000000000000063000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044dc5e3ccd0000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000006300000000000000000000000000000000000000000000000000000000', + 'shall we deposit rewards?', + false + ) + const voteId = await daoVotingV1.votesLength() + await Promise.all(tokenHolders.map((_holder) => daoVotingV1.connect(_holder).vote(voteId, true))) + const vote = await daoVotingV1.getVote(voteId) + await mineUpTo(vote[3] + 1n) + await expect(daoVotingV1.connect(association).executeVote(voteId)) + .to.emit(daoVotingV1, 'ExecuteVote') + .withArgs(voteId) + .and.to.emit(ethPnt, 'Transfer') + .withArgs(FORWARDER_ON_MAINNET_ETHPNT, vault.target, 100) + .and.to.emit(vault, 'PegIn') + .withArgs( + PNT_ON_ETH, + FORWARDER_ON_MAINNET_ETHPNT, + 100, + FORWARDER_ON_GNOSIS.slice(2).toLowerCase(), + DEPOSIT_REWARDS_USER_DATA, + PNETWORK_NETWORK_IDS.MAINNET, + PNETWORK_NETWORK_IDS.GNOSIS + ) + }) + // pBTC is not native! so the execution script should not peg-in it.skip('[dapp] should open a vote for migrating pBTC treasury funds (4)', async () => { const amount = ethers.parseEther('100') From 2525751b60ca24921ad7fa8903db89e652108c2c Mon Sep 17 00:00:00 2001 From: Alain Olivier Date: Thu, 14 Mar 2024 12:33:11 +0100 Subject: [PATCH 09/11] refactor(tasks): revise task for deploying forwarder on mainnet --- tasks/deploy_forwarder_mainnet.js | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/tasks/deploy_forwarder_mainnet.js b/tasks/deploy_forwarder_mainnet.js index 40b5cb4..ec9fd16 100644 --- a/tasks/deploy_forwarder_mainnet.js +++ b/tasks/deploy_forwarder_mainnet.js @@ -2,11 +2,11 @@ const { task } = require('hardhat/config') const { ADDRESSES: { - MAINNET: { PNT, ERC20_VAULT, FORWARDER, SAFE } + MAINNET: { PNT, ETHPNT, ERC20_VAULT, FORWARDER_PNT, FORWARDER_ETHPNT, SAFE } } } = require('../lib/constants') -const deploy = async (_args, _hre) => { +const deployForwarderPNT = async (_args, _hre) => { if (_hre.network.name !== 'mainnet') { throw new Error('Invalid network') } @@ -17,9 +17,26 @@ const deploy = async (_args, _hre) => { } // eslint-disable-next-line no-unused-vars -const transferOwnership = async (_args, _hre) => { - const c = await _hre.ethers.getContractAt('Forwarder', FORWARDER) +const deployForwarderEthPNT = async (_args, _hre) => { + if (_hre.network.name !== 'mainnet') { + throw new Error('Invalid network') + } + const Forwarder = await _hre.ethers.getContractFactory('Forwarder') + console.log('Deploying forwarder on Ethereum ...') + const forwarder = await Forwarder.deploy(ETHPNT, ERC20_VAULT) + console.log('Forwarder deployed at', forwarder.target) +} + +// eslint-disable-next-line no-unused-vars +const transferOwnershipForwarderPNT = async (_args, _hre) => { + const c = await _hre.ethers.getContractAt('Forwarder', FORWARDER_PNT) + await c.transferOwnership(SAFE) +} + +// eslint-disable-next-line no-unused-vars +const transferOwnershipForwarderEthPNT = async (_args, _hre) => { + const c = await _hre.ethers.getContractAt('Forwarder', FORWARDER_ETHPNT) await c.transferOwnership(SAFE) } -task('deploy:forwarder-mainnet', 'Deploy Forwarder on Mainnet', deploy) +task('deploy:forwarder-mainnet', 'Deploy Forwarder on Mainnet', deployForwarderPNT) From 2142f6497daf600c3910b1299468bd7b1057f0df Mon Sep 17 00:00:00 2001 From: Alain Olivier Date: Thu, 14 Mar 2024 17:33:37 +0100 Subject: [PATCH 10/11] test(fork): add integration test for staking migration --- test/fork/dao.test.js | 58 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/test/fork/dao.test.js b/test/fork/dao.test.js index 59f4644..f76dd55 100644 --- a/test/fork/dao.test.js +++ b/test/fork/dao.test.js @@ -41,6 +41,7 @@ const { PNETWORK, ASSOCIATION, FINANCE_VAULT: FINANCE_VAULT_V1, + FORWARDER_PNT: FORWARDER_ON_MAINNET_PNT, FORWARDER_ETHPNT: FORWARDER_ON_MAINNET_ETHPNT, PBTC: PBTC_ON_ETHEREUM, PBTC_MINTER, @@ -82,6 +83,9 @@ const WITHDRAW_INFLATION_FROM_GNOSIS_USER_DATA_3 = const DEPOSIT_REWARDS_USER_DATA = // secretlint-disable-next-line '0x00000000000000000000000000000000000000000000000000000000000000400000000000000000000000002211bfd97b1c02ae8ac305d206e9780ba7d8bff40000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000020000000000000000000000008805aa0c1a8e59b03fa95740f691e28942cf44f60000000000000000000000002ec44f9f31a55b52b3c1ff98647e38d63f829fb70000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000044095ea7b30000000000000000000000002ec44f9f31a55b52b3c1ff98647e38d63f829fb70000000000000000000000000000000000000000000000000000000000000063000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044dc5e3ccd0000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000006300000000000000000000000000000000000000000000000000000000' +const MIGRATE_USER_DATA = + // secretlint-disable-next-line + '0x0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000c4442915b1fb44972ee4d8404ce05a8d2a1248da0000000000000000000000000000000000000000000000000000000000000220000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000020000000000000000000000008805aa0c1a8e59b03fa95740f691e28942cf44f6000000000000000000000000dee8ebe2b7152eccd935fd67134bf1bad55302bc0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000044095ea7b3000000000000000000000000dee8ebe2b7152eccd935fd67134bf1bad55302bc0000000000000000000000000000000000000000000000056a6418b5058600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000642b54f551000000000000000000000000c4442915b1fb44972ee4d8404ce05a8d2a1248da0000000000000000000000000000000000000000000000056a6418b5058600000000000000000000000000000000000000000000000000000000000000093a8000000000000000000000000000000000000000000000000000000000' const getBytes = (_hexString) => Buffer.from(_hexString.slice(2), 'hex') @@ -844,6 +848,29 @@ describe('Integration tests on Gnosis deployment', () => { expect(await rewardsManager.depositedAmountByEpoch(4)).to.be.eq(99n + depositedAmount) }) + it('[dapp] should stake from forwarder call (migration)', async () => { + const amount = ethers.parseUnits('99.9') + const staker = tokenHolders[0] + const stakedAmount = await daoPNT.balanceOf(tokenHolders[0]) + expect(await pntOnGnosis.balanceOf(staker.address)).to.be.eq(5000) + const smBalance = await pntOnGnosis.balanceOf(STAKING_MANAGER) + const metadata = encodeMetadata(ethers, { + userData: MIGRATE_USER_DATA, + sourceNetworkId: PNETWORK_NETWORK_IDS.MAINNET, + senderAddress: FORWARDER_ON_MAINNET_PNT, + destinationNetworkId: PNETWORK_NETWORK_IDS.GNOSIS, + receiverAddress: forwarder.target + }) + await expect(mintPToken(pntOnGnosis, pntMinter, forwarder.target, amount, metadata)) + .to.emit(pntOnGnosis, 'Transfer') + .withArgs(FORWARDER_ON_GNOSIS, STAKING_MANAGER, amount) + .and.to.emit(stakingManager, 'Staked') + .withArgs(staker, amount, ONE_DAY * 7) + expect(await pntOnGnosis.balanceOf(staker.address)).to.be.eq(5000) + expect(await daoPNT.balanceOf(staker)).to.be.eq(amount + stakedAmount) + expect(await pntOnGnosis.balanceOf(STAKING_MANAGER)).to.be.eq(smBalance + amount) + }) + it('[dapp] should delegateVote from forwarder call', async () => { const stakedAmount = ethers.parseUnits('10') await mintPntOnGnosis(user.address, stakedAmount) @@ -1205,6 +1232,37 @@ describe('Integration tests on Ethereum deployment', () => { ) }) + it('[dappv1] should migrate stake to DAO v3', async () => { + const staker = tokenHolders[1] + await staker.sendTransaction({ + to: '0xeb10e80D99655B51E3a981E888a73D0B21e21A6C', + // secretlint-disable-next-line + data: '0x2e17de780000000000000000000000000000000000000000000000056bc75e2d63100000' + }) + await staker.sendTransaction({ + to: '0x89ab32156e46f46d02ade3fecbe5fc4243b9aaed', + // secretlint-disable-next-line + data: '0x095ea7b3000000000000000000000000e2cb2c8fdc086fc576b49acf2f71d44dde7e38040000000000000000000000000000000000000000000000056bc75e2d63100000' + }) + await expect( + staker.sendTransaction({ + to: '0xe2cb2C8fDc086FC576b49aCF2F71D44DDe7e3804', + // secretlint-disable-next-line + data: '0x996adf550000000000000000000000000000000000000000000000056bc75e2d631000000000000000000000000000002422eb5b6a20c7b8e3567c12ed6f5ed9d1cf1f79000000000000000000000000000000000000000000000000000000000000008000f1918e000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000220000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000020000000000000000000000008805aa0c1a8e59b03fa95740f691e28942cf44f6000000000000000000000000dee8ebe2b7152eccd935fd67134bf1bad55302bc0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000044095ea7b3000000000000000000000000dee8ebe2b7152eccd935fd67134bf1bad55302bc0000000000000000000000000000000000000000000000056a6418b5058600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000642b54f551000000000000000000000000c4442915b1fb44972ee4d8404ce05a8d2a1248da0000000000000000000000000000000000000000000000056a6418b5058600000000000000000000000000000000000000000000000000000000000000093a8000000000000000000000000000000000000000000000000000000000' + }) + ) + .to.emit(vault, 'PegIn') + .withArgs( + PNT_ON_ETH, + FORWARDER_ON_MAINNET_PNT, + ethers.parseUnits('100'), + FORWARDER_ON_GNOSIS.slice(2).toLocaleLowerCase(), + MIGRATE_USER_DATA, + PNETWORK_NETWORK_IDS.MAINNET, + PNETWORK_NETWORK_IDS.GNOSIS + ) + }) + it('[dapp] should open a vote for depositing rewards', async () => { expect(await ethPnt.inflationOwner()).to.be.eq(crossExecutor.target) const INFLATION_OWNER_SLOT = '0x131' // 305 (found brute forcing eth_getStorageAt()) From 399dd81621feb6085dd941d19916e447a61b2452 Mon Sep 17 00:00:00 2001 From: Alain Olivier Date: Thu, 14 Mar 2024 17:50:56 +0100 Subject: [PATCH 11/11] test(fork): fix failing tests --- test/fork/dao.test.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/test/fork/dao.test.js b/test/fork/dao.test.js index f76dd55..78ef93e 100644 --- a/test/fork/dao.test.js +++ b/test/fork/dao.test.js @@ -419,7 +419,7 @@ describe('Integration tests on Gnosis deployment', () => { it('should move tokens to treasury and transfer from it following a vote', async () => { await mintPntOnGnosis(daoTreasury.target, parseEther('200000')) expect(await pntOnGnosis.balanceOf(daoTreasury.target)).to.be.eq(parseEther('200000')) - expect(await pntOnGnosis.balanceOf(user.address)).to.be.eq(parseEther('0')) + const userBalance = await pntOnGnosis.balanceOf(user.address) const metadata = 'Should we transfer from vault to user?' const executionScript = encodeCallScript( @@ -438,7 +438,7 @@ describe('Integration tests on Gnosis deployment', () => { .and.to.emit(pntOnGnosis, 'Transfer') .withArgs(daoTreasury.target, user.address, parseEther('1')) - expect(await pntOnGnosis.balanceOf(user.address)).to.be.eq(parseEther('1')) + expect(await pntOnGnosis.balanceOf(user.address)).to.be.eq(parseEther('1') + userBalance) }) it('should create an immediate payment via finance app', async () => { @@ -446,14 +446,16 @@ describe('Integration tests on Gnosis deployment', () => { const amount = parseEther('1.5') await mintPntOnGnosis(daoTreasury.target, parseEther('200000')) expect(await pntOnGnosis.balanceOf(daoTreasury.target)).to.be.eq(parseEther('200000')) - expect(await pntOnGnosis.balanceOf(user.address)).to.be.eq(parseEther('0')) + const userBalance = await pntOnGnosis.balanceOf(user.address) + await expect(finance.connect(faucet).newImmediatePayment(pntOnGnosis.target, user.address, amount, 'test')) .to.emit(daoTreasury, 'VaultTransfer') .withArgs(pntOnGnosis.target, user.address, amount) .and.to.emit(pntOnGnosis, 'Transfer') .withArgs(daoTreasury.target, user.address, amount) + expect(await pntOnGnosis.balanceOf(daoTreasury.target)).to.be.eq(parseEther('200000') - amount) - expect(await pntOnGnosis.balanceOf(user.address)).to.be.eq(amount) + expect(await pntOnGnosis.balanceOf(user.address)).to.be.eq(amount + userBalance) }) it('should open a vote (1)', async () => {