From 5b83ba6ba3684ab81e18920c17da7200d8b106fb Mon Sep 17 00:00:00 2001 From: qedk <1994constant@gmail.com> Date: Tue, 12 Oct 2021 11:42:31 +0530 Subject: [PATCH 1/2] fix: Fix RLPReader overflow bug --- contracts/lib/RLPReader.sol | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/contracts/lib/RLPReader.sol b/contracts/lib/RLPReader.sol index 7e635dc..45d29c8 100644 --- a/contracts/lib/RLPReader.sol +++ b/contracts/lib/RLPReader.sol @@ -333,12 +333,15 @@ library RLPReader { dest += WORD_SIZE; } + if (len == 0) return; + // left over bytes. Mask is used to remove unwanted bytes from the word uint mask = 256 ** (WORD_SIZE - len) - 1; + assembly { let srcpart := and(mload(src), not(mask)) // zero out src let destpart := and(mload(dest), mask) // retrieve the bytes mstore(dest, or(destpart, srcpart)) } } -} \ No newline at end of file +} From 3ed818962df0045d6aa6b9e16339de6c28e48fd6 Mon Sep 17 00:00:00 2001 From: qedk <1994constant@gmail.com> Date: Tue, 12 Oct 2021 13:43:06 +0530 Subject: [PATCH 2/2] Add hardhat-etherscan commands --- scripts/deploychild.js | 38 ++++++++++++++++---------------------- scripts/deployroot.js | 9 ++++++--- 2 files changed, 22 insertions(+), 25 deletions(-) diff --git a/scripts/deploychild.js b/scripts/deploychild.js index b52339b..b19a191 100644 --- a/scripts/deploychild.js +++ b/scripts/deploychild.js @@ -3,52 +3,46 @@ const config = require('../config/config.json') const hre = require('hardhat') async function main () { - let fxChild + let fxChild, erc20Token, erc721Token, erc1155Token const network = await hre.ethers.provider.getNetwork() if (network.chainId === 137) { // Polygon Mainnet fxChild = config.mainnet.fxChild.address + erc20Token = config.mainnet.fxERC20.address + erc721Token = config.mainnet.fxERC721.address + erc1155Token = config.mainnet.fxERC1155.address } else if (network.chainId === 80001) { // Mumbai Testnet fxChild = config.testnet.fxChild.address + erc20Token = config.testnet.fxERC20.address + erc721Token = config.testnet.fxERC721.address + erc1155Token = config.testnet.fxERC1155.address } else { fxChild = process.env.FX_CHILD + erc20Token = process.env.FX_ERC20 + erc721Token = process.env.FX_ERC721 + erc1155Token = process.env.FX_ERC1155 } - const ERC20Token = await hre.ethers.getContractFactory('FxERC20') - const erc20Token = await ERC20Token.deploy() - console.log(erc20Token.deployTransaction) - await erc20Token.deployTransaction.wait() - console.log('FxERC20 deployed to:', erc20Token.address) - const ERC20 = await hre.ethers.getContractFactory('FxERC20ChildTunnel') - const erc20 = await ERC20.deploy(fxChild, erc20Token.address) + const erc20 = await ERC20.deploy(fxChild, erc20Token) await erc20.deployTransaction.wait() console.log('ERC20ChildTunnel deployed to:', erc20.address) - - const ERC721Token = await hre.ethers.getContractFactory('FxERC721') - const erc721Token = await ERC721Token.deploy() - console.log(erc721Token.deployTransaction) - await erc721Token.deployTransaction.wait() - console.log('FxERC721 deployed to:', erc721Token.address) + console.log('npx hardhat verify --network mumbai', erc20.address, fxChild, erc20Token) const ERC721 = await hre.ethers.getContractFactory('FxERC721ChildTunnel') - const erc721 = await ERC721.deploy(fxChild, erc721Token.address) + const erc721 = await ERC721.deploy(fxChild, erc721Token) console.log(erc721.deployTransaction) await erc721.deployTransaction.wait() console.log('ERC721ChildTunnel deployed to:', erc721.address) - - const ERC1155Token = await hre.ethers.getContractFactory('FxERC1155') - const erc1155Token = await ERC1155Token.deploy() - console.log(erc1155Token.deployTransaction) - await erc1155Token.deployTransaction.wait() - console.log('FxERC1155 deployed to:', erc1155Token.address) + console.log('npx hardhat verify --network mumbai', erc721.address, fxChild, erc721Token) const ERC1155 = await hre.ethers.getContractFactory('FxERC1155ChildTunnel') - const erc1155 = await ERC1155.deploy(fxChild, erc1155Token.address) + const erc1155 = await ERC1155.deploy(fxChild, erc1155Token) console.log(erc1155.deployTransaction) await erc1155.deployTransaction.wait() console.log('ERC1155ChildTunnel deployed to:', erc1155.address) + console.log('npx hardhat verify --network mumbai', erc1155.address, fxChild, erc1155Token) } main() diff --git a/scripts/deployroot.js b/scripts/deployroot.js index fc413f3..469fe0d 100644 --- a/scripts/deployroot.js +++ b/scripts/deployroot.js @@ -3,9 +3,9 @@ const config = require('../config/config.json') const hre = require('hardhat') // Use your own deployed child tunnel addresses here instead! -const fxERC20ChildTunnel = '0x918cc10cf2393bb9803f9d9D3219539a1e736dd9' -const fxERC721ChildTunnel = '0xdC335C19868d49aCa554AA64d5ae8524A093De5b' -const fxERC1155ChildTunnel = '0x46d40260e48A6164bbF24206D3AB9426a41D8664' +const fxERC20ChildTunnel = '0x587C9FF1c528C7aeE2804Bf5301Dc2ec057A75a8' +const fxERC721ChildTunnel = '0x96d26FCA4cB14e14CABc28eF8bc8Aba0E03702A8' +const fxERC1155ChildTunnel = '0x24a16Db524d342968A11b9E1aD75b6D5eD002db7' async function main () { let fxRoot, checkpointManager, fxERC20, fxERC721, fxERC1155 @@ -38,6 +38,7 @@ async function main () { console.log(erc20.deployTransaction) await erc20.deployTransaction.wait() console.log('ERC20RootTunnel deployed to:', erc20.address) + console.log('npx hardhat verify --network goerli', erc20.address, checkpointManager, fxRoot, fxERC20) const setERC20Child = await erc20.setFxChildTunnel(fxERC20ChildTunnel) console.log(setERC20Child) @@ -49,6 +50,7 @@ async function main () { console.log(erc721.deployTransaction) await erc721.deployTransaction.wait() console.log('ERC721RootTunnel deployed to:', erc721.address) + console.log('npx hardhat verify --network goerli', erc721.address, checkpointManager, fxRoot, fxERC721) const setERC721Child = await erc721.setFxChildTunnel(fxERC721ChildTunnel) console.log(setERC721Child) @@ -60,6 +62,7 @@ async function main () { console.log(erc1155.deployTransaction) await erc1155.deployTransaction.wait() console.log('ERC1155RootTunnel deployed to:', erc1155.address) + console.log('npx hardhat verify --network goerli', erc1155.address, checkpointManager, fxRoot, fxERC1155) const setERC1155Child = await erc1155.setFxChildTunnel(fxERC1155ChildTunnel) console.log(setERC1155Child)