From f986d1bd9a93c35f5aeffcd5931d3fbcdb389352 Mon Sep 17 00:00:00 2001 From: Ethan Date: Wed, 7 Dec 2022 18:04:26 +0800 Subject: [PATCH 1/6] add deploy scripts --- scripts/deployAll.js | 449 ++++++++++++++++++++++++++++++++++++++++++ scripts/deployBase.js | 144 -------------- 2 files changed, 449 insertions(+), 144 deletions(-) create mode 100644 scripts/deployAll.js delete mode 100644 scripts/deployBase.js diff --git a/scripts/deployAll.js b/scripts/deployAll.js new file mode 100644 index 0000000..161c18f --- /dev/null +++ b/scripts/deployAll.js @@ -0,0 +1,449 @@ +const hre = require("hardhat"); +const Web3 = require("web3"); +const abi = require("@ethersproject/abi"); +const fs = require("fs"); +const { ethers } = require("hardhat"); +const { keccak256 } = require("ethereumjs-util"); +hre.web3 = new Web3(hre.network.provider); +require("colors"); + +var configPath = './contractConfig.json' + +async function main() { + [deployer] = await hre.ethers.getSigners(); + + var config = {} + await readConfig(hre.network.name).then((netConfig) => { + if (netConfig !== undefined) { + config = netConfig + } + }).catch((err) => { + console.error(err); + process.exit(1); + }); + if (config.Name === undefined) { + config.Name = hre.network.name + } + if (config.PolyChainID === undefined) { + if (hre.config.networks[hre.network.name].polyId === undefined) { + console.error("unknown network: invalid PolyChainID".red); + process.exit(1); + } + config.PolyChainID = hre.config.networks[hre.network.name].polyId + } + if (config.Provider === undefined) { + config.Provider = hre.config.networks[hre.network.name].url + writeConfig(config) + } + if (config.Deployer === undefined) { + config.Deployer = deployer.address + } + + const LockProxy = await ethers.getContractFactory("LockProxy"); + const ProxyAdmin = await ethers.getContractFactory("ProxyAdmin"); + const RippleLockProxy = await ethers.getContractFactory("RippleLockProxy"); + const EthCrossChainData = await hre.ethers.getContractFactory("EthCrossChainData"); + const CallerFactory = await hre.ethers.getContractFactory("CallerFactoryWithAdmin"); + let EthCrossChainManagerImplementation = await hre.ethers.getContractFactory("EthCrossChainManagerImplementation"); + const EthCrossChainManager = await hre.ethers.getContractFactory("EthCrossChainManager"); + const WrapperV1 = await hre.ethers.getContractFactory("PolyWrapperV1"); + const WrapperV2 = await hre.ethers.getContractFactory("PolyWrapperV2"); + const WrapperV3 = await hre.ethers.getContractFactory("PolyWrapperV3"); + let polyId = config.PolyChainID + let eccd + let ccmi + let ccm + let cf + let lockProxy + let wrapper1 + let wrapper2 + let wrapper3 + let proxyAdmin + let rippleLockProxy + let rippleLockProxyImpl + let abiCoder = new abi.AbiCoder + let rippleName = "Poly Peg Ripple Token" + let rippleSymbol = "pXRP" + let rippleDeciamls = 6 + let rippleInitData = "0xde7ea79d" + abiCoder.encode(['string','string','uint8','address'],[rippleName,rippleSymbol,rippleDeciamls,deployer.address]).slice(2); + let rippleSalt = 2; + + console.log("\nDeploy contracts on chain with Poly_Chain_Id:".cyan, polyId); + + if (config.LockProxy === undefined) { + // deploy LockProxy + console.log("\ndeploy LockProxy ......".cyan); + lockProxy = await LockProxy.deploy(); + await lockProxy.deployed(); + console.log("LockProxy deployed to:".green, lockProxy.address.blue); + config.LockProxy = lockProxy.address + writeConfig(config) + } else { + console.log("\nLockProxy already deployed at".green, config.LockProxy.blue) + lockProxy = await LockProxy.attach(config.LockProxy) + } + + if (config.EthCrossChainData === undefined) { + // deploy EthCrossChainData + console.log("\ndeploy EthCrossChainData ......".cyan); + eccd = await EthCrossChainData.deploy(); + await eccd.deployed(); + console.log("EthCrossChainData deployed to:".green, eccd.address.blue); + config.EthCrossChainData = eccd.address + writeConfig(config) + } else { + console.log("\nEthCrossChainData already deployed at".green, config.EthCrossChainData.blue) + eccd = await EthCrossChainData.attach(config.EthCrossChainData) + } + + if (config.CallerFactory === undefined) { + // deploy CallerFactory + console.log("\ndeploy CallerFactory ......".cyan); + cf = await CallerFactory.deploy([lockProxy.address]); + await cf.deployed(); + console.log("CallerFactory deployed to:".green, cf.address.blue); + config.CallerFactory = cf.address + writeConfig(config) + } else { + console.log("\nCallerFactory already deployed at".green, config.CallerFactory.blue) + cf = await CallerFactory.attach(config.CallerFactory) + } + + if (config.EthCrossChainManagerImplementation === undefined) { + // update Const.sol + console.log("\nupdate Const.sol ......".cyan); + await updateConst(config.PolyChainID, eccd.address, cf.address); + console.log("Const.sol updated".green); + await hre.run('compile'); + + // deploy EthCrossChainManagerImplementation + console.log("\ndeploy EthCrossChainManagerImplementation ......".cyan); + EthCrossChainManagerImplementation = await hre.ethers.getContractFactory("EthCrossChainManagerImplementation"); + ccmi = await EthCrossChainManagerImplementation.deploy(); + await ccmi.deployed(); + console.log("EthCrossChainManagerImplementation deployed to:".green, ccmi.address.blue); + config.EthCrossChainManagerImplementation = ccmi.address + writeConfig(config) + } else { + console.log("\nEthCrossChainManagerImplementation already deployed at".green, config.EthCrossChainManagerImplementation.blue) + ccmi = await EthCrossChainManagerImplementation.attach(config.EthCrossChainManagerImplementation) + } + + if (config.EthCrossChainManager === undefined) { + // deploy EthCrossChainManager + console.log("\ndeploy EthCrossChainManager ......".cyan); + ccm = await EthCrossChainManager.deploy(ccmi.address,deployer.address,'0x'); + await ccm.deployed(); + console.log("EthCrossChainManager deployed to:".green, ccm.address.blue); + config.EthCrossChainManager = ccm.address + writeConfig(config) + } else { + console.log("\nEthCrossChainManager already deployed at".green, config.EthCrossChainManager.blue) + ccm = await EthCrossChainManager.attach(config.EthCrossChainManager) + } + + let eccdOwner = await eccd.owner() + // transfer ownership + if (eccdOwner == ccm.address) { + console.log("\neccd ownership already transferred".green); + } else { + console.log("\ntransfer eccd's ownership to ccm ......".cyan); + tx = await eccd.transferOwnership(ccm.address); + await tx.wait(); + console.log("ownership transferred".green); + } + + let alreadySetCCMP = await lockProxy.managerProxyContract(); + if (alreadySetCCMP == ccm.address) { + console.log("\nmanagerProxyContract already set".green); + } else { + // setup LockProxy + console.log("\nsetup LockProxy ......".cyan); + tx = await lockProxy.setManagerProxy(ccm.address); + await tx.wait(); + console.log("setManagerProxy Done".green); + } + + if (config.WrapperV1 === undefined) { + // deploy WrapperV1 + console.log("\ndeploy WrapperV1 ......".cyan); + wrapper1 = await WrapperV1.deploy(deployer.address, polyId); + await wrapper1.deployed(); + console.log("WrapperV1 deployed to:".green, wrapper1.address.blue); + config.WrapperV1 = wrapper1.address + writeConfig(config) + } else { + console.log("\nWrapperV1 already deployed at".green, config.WrapperV1.blue) + wrapper1 = await WrapperV1.attach(config.WrapperV1) + } + + let alreadySetLockProxy1 = await wrapper1.lockProxy(); + let alreadySetFeeCollector1 = await wrapper1.feeCollector(); + console.log("\nsetup WrapperV1 ......".cyan); + if (alreadySetLockProxy1 == lockProxy.address) { + console.log("wrapper1 lockProxy already set".green); + } else { + // setLockProxy + console.log("setLockProxy ......".cyan); + tx = await wrapper1.setLockProxy(lockProxy.address); + await tx.wait(); + console.log("setLockProxy Done".green); + } + if (alreadySetFeeCollector1 != "0x0000000000000000000000000000000000000000") { + console.log("wrapper1 feeCollector already set".green); + } else { + // setFeeCollector + console.log("setFeeCollector ......".cyan); + tx = await wrapper1.setFeeCollector(deployer.address); + await tx.wait(); + console.log("setFeeCollector Done".green); + } + + if (config.WrapperV2 === undefined) { + // deploy WrapperV2 + console.log("\ndeploy WrapperV2 ......".cyan); + wrapper2 = await WrapperV2.deploy(deployer.address, polyId); + await wrapper2.deployed(); + console.log("WrapperV2 deployed to:".green, wrapper2.address.blue); + config.WrapperV2 = wrapper2.address + config.Wrapper = wrapper2.address + writeConfig(config) + } else { + console.log("\nWrapperV2 already deployed at".green, config.WrapperV2.blue) + wrapper2 = await WrapperV2.attach(config.WrapperV2) + if (config.wrapper != wrapper2.address) { + config.Wrapper = wrapper2.address + writeConfig(config) + } + } + + let alreadySetLockProxy2 = await wrapper2.lockProxy(); + let alreadySetFeeCollector2 = await wrapper2.feeCollector(); + console.log("\nsetup WrapperV2 ......".cyan); + if (alreadySetLockProxy2 == lockProxy.address) { + console.log("wrapper2 lockProxy already set".green); + } else { + // setLockProxy + console.log("setLockProxy ......".cyan); + tx = await wrapper2.setLockProxy(lockProxy.address); + await tx.wait(); + console.log("nsetLockProxy Done".green); + } + if (alreadySetFeeCollector2 != "0x0000000000000000000000000000000000000000") { + console.log("wrapper2 feeCollector already set".green); + } else { + // setFeeCollector + console.log("setFeeCollector ......".cyan); + tx = await wrapper2.setFeeCollector(deployer.address); + await tx.wait(); + console.log("setFeeCollector Done".green); + } + + if (config.WrapperV3 === undefined) { + // deploy WrapperV3 + console.log("\ndeploy WrapperV3 ......".cyan); + wrapper3 = await WrapperV3.deploy(deployer.address, polyId); + await wrapper3.deployed(); + console.log("WrapperV3 deployed to:".green, wrapper3.address.blue); + config.WrapperV3 = wrapper3.address + config.Wrapper = wrapper3.address + writeConfig(config) + } else { + console.log("\nWrapperV3 already deployed at".green, config.WrapperV3.blue) + wrapper3 = await WrapperV3.attach(config.WrapperV3) + if (config.wrapper != wrapper3.address) { + config.Wrapper = wrapper3.address + writeConfig(config) + } + } + + if (config.RippleLockProxyImplementation === undefined) { + // deploy rippleLockProxy Implementation + console.log("\ndeploy RippleLockProxyImplementation ......".cyan); + rippleLockProxyImpl = await RippleLockProxy.deploy(rippleName, rippleSymbol, rippleDeciamls); + await rippleLockProxyImpl.deployed(); + console.log("RippleLockProxyImplementation deployed to:".green, rippleLockProxyImpl.address.blue); + config.RippleLockProxyImplementation = rippleLockProxyImpl.address; + writeConfig(config) + } else { + console.log("\nRippleLockProxyImplementation already deployed at".green, config.RippleLockProxyImplementation.blue) + rippleLockProxyImpl = await RippleLockProxy.attach(config.RippleLockProxyImplementation) + } + + if (config.ProxyAdmin === undefined) { + // deploy ProxyAdmin + console.log("\ndeploy ProxyAdmin ......".cyan); + proxyAdmin = await ProxyAdmin.deploy(); + await proxyAdmin.deployed(); + console.log("ProxyAdmin deployed to:".green, proxyAdmin.address.blue); + config.ProxyAdmin = proxyAdmin.address; + writeConfig(config) + } else { + console.log("\nProxyAdmin already deployed at".green, config.ProxyAdmin.blue) + proxyAdmin = await ProxyAdmin.attach(config.ProxyAdmin) + } + + if (config.RippleLockProxy === undefined) { + // deploy rippleLockProxy + console.log("\ndeploy RippleLockProxy......".cyan); + tx = await cf.deploy(rippleSalt, rippleLockProxyImpl.address, proxyAdmin.address, rippleInitData); + await tx.wait(); + let rippleLockProxyAddress = await cf.getDeploymentAddress(rippleSalt, deployer.address); + rippleLockProxy = await RippleLockProxy.attach(rippleLockProxyAddress); + console.log("RippleLockProxy deployed to:".green, rippleLockProxy.address.blue); + config.RippleLockProxy = rippleLockProxy.address; + writeConfig(config) + } else { + console.log("\nRippleLockProxy already deployed at".green, config.RippleLockProxy.blue) + rippleLockProxy = await RippleLockProxy.attach(config.RippleLockProxy) + } + let xrp = await rippleLockProxy.token(); + console.log("\nXRP-Token deployed at".green, xrp.blue); + + let alreadySetCCMPRipple = await rippleLockProxy.managerProxyContract(); + if (alreadySetCCMPRipple == ccm.address) { + console.log("\nmanagerContract of ripple LockProxy already set".green); + } else { + // setup RippleLockProxy + console.log("\nsetup RippleLockProxy ......".cyan); + tx = await rippleLockProxy.setManager(ccm.address); + await tx.wait(); + console.log("setManager Done".green); + } + + let alreadyAddLockProxy3 = await wrapper3.isValidLockProxy(lockProxy.address); + let alreadySetFeeCollector3 = await wrapper3.feeCollector(); + let alreadyAddRippleLockProxy3 = await wrapper3.isValidLockProxy(rippleLockProxy.address); + console.log("\nsetup WrapperV3 ......".cyan); + if (alreadyAddLockProxy3) { + console.log("wrapper3 lockProxy already add".green); + } else { + // addLockProxy + console.log("addLockProxy ......".cyan); + tx = await wrapper3.addLockProxy(lockProxy.address); + await tx.wait(); + console.log("addLockProxy Done".green); + } + if (alreadyAddRippleLockProxy3) { + console.log("wrapper3 rippleLockProxy already add".green); + } else { + // addLockProxy + console.log("add RippleLockProxy ......".cyan); + tx = await wrapper3.addLockProxy(rippleLockProxy.address); + await tx.wait(); + console.log("add RippleLockProxy Done".green); + } + if (alreadySetFeeCollector3 != "0x0000000000000000000000000000000000000000") { + console.log("wrapper3 feeCollector already set".green); + } else { + // setFeeCollector + console.log("setFeeCollector ......".cyan); + tx = await wrapper3.setFeeCollector(deployer.address); + await tx.wait(); + console.log("setFeeCollector Done".green); + } + + // write config + console.log("constract output:\n".cyan,config); + await writeConfig(config) + console.log("\nwrite config done\n".green); + + console.log("\nDone.\n".magenta); +} + +async function updateConst(polyChainId, eccd, callerFactory) { + + fs.writeFileSync('./contracts/core/cross_chain_manager/logic/Const.sol', + 'pragma solidity ^0.5.0;\n'+ + 'contract Const {\n'+ + ' bytes constant ZionCrossChainManagerAddress = hex"0000000000000000000000000000000000001003"; \n'+ + // ' bytes constant ZionCrossChainManagerAddress = hex"5747C05FF236F8d18BB21Bc02ecc389deF853cae"; \n'+ + ' \n'+ + ' address constant EthCrossChainDataAddress = '+eccd+'; \n'+ + ' address constant EthCrossChainCallerFactoryAddress = '+callerFactory+'; \n'+ + ' uint constant chainId = '+polyChainId+'; \n}', + function(err) { + if (err) { + console.error(err); + process.exit(1); + } + }); +} + +async function readConfig(networkName) { + let jsonData + try { + jsonData = fs.readFileSync(configPath) + } catch(err) { + if (err.code == 'ENOENT') { + createEmptyConfig() + return + }else{ + console.error(err); + process.exit(1); + } + } + if (jsonData === undefined) { + return + } + var json=JSON.parse(jsonData.toString()) + if (json.Networks === undefined) { + return + } + for (let i=0; i{ + if (err) { + console.error(err); + process.exit(1); + }else{ + previous=data.toString(); + } + }); + var json = JSON.parse(data.toString()) + var writeIndex = json.Networks.length + for (let i=0; i process.exit(0)) + .catch((err) => { + console.error(err) + process.exit(1) + }); diff --git a/scripts/deployBase.js b/scripts/deployBase.js deleted file mode 100644 index b72c407..0000000 --- a/scripts/deployBase.js +++ /dev/null @@ -1,144 +0,0 @@ -const { ethers } = require("hardhat"); -const hre = require("hardhat"); -const fs = require("fs"); -const Web3 = require("web3"); -const colors = require('colors'); -hre.web3 = new Web3(hre.network.provider); - -async function main() { - - [deployer] = await hre.ethers.getSigners(); - - // check if given networkId is registered - await getPolyChainId().then((polyId) => { - console.log("\nDeploy EthCrossChainManager on chain with Poly_Chain_Id:".cyan, polyId); - }).catch((error) => { - throw error; - });; - - console.log("Start , deployer:".cyan, deployer.address.blue); - - await hre.run('compile'); - - // deploy EthCrossChainData - console.log("\ndeploy EthCrossChainData ......".cyan); - const ECCD = await hre.ethers.getContractFactory("EthCrossChainData"); - const eccd = await ECCD.deploy(); - await eccd.deployed(); - console.log("EthCrossChainData deployed to:".green, eccd.address.blue); - - // deploy CallerFactory - console.log("\ndeploy CallerFactory ......".cyan); - const CallerFactory = await hre.ethers.getContractFactory("CallerFactory"); - const cf = await CallerFactory.deploy(); - await cf.deployed(); - console.log("CallerFactory deployed to:".green, cf.address.blue); - - // update Const.sol - console.log("\nupdate Const.sol ......".cyan); - await updateConst(eccd.address, cf.address); - console.log("Const.sol updated".green); - await hre.run('compile'); - - // deploy EthCrossChainManagerImplementation - console.log("\ndeploy EthCrossChainManagerImplementation ......".cyan); - const CCM = await hre.ethers.getContractFactory("EthCrossChainManagerImplementation"); - const ccm = await CCM.deploy(); - await ccm.deployed(); - console.log("EthCrossChainManagerImplementation deployed to:".green, ccm.address.blue); - - // deploy EthCrossChainManager - console.log("\ndeploy EthCrossChainManager ......".cyan); - const CCMP = await hre.ethers.getContractFactory("EthCrossChainManager"); - const ccmp = await CCMP.deploy(ccm.address,deployer.address,'0x'); - await ccmp.deployed(); - console.log("EthCrossChainManager deployed to:".green, ccmp.address.blue); - - // transfer ownership - console.log("\ntransfer eccd's ownership to ccm ......".cyan); - await eccd.transferOwnership(ccmp.address); - console.log("ownership transferred".green); - - console.log("\nDone.\n".magenta); - -} - -function verifyAtEtherscan(address, constructorArguments) { - return hre.run("verify:verify", { - address: address, - constructorArguments: constructorArguments, - }); -} - -async function updateConst(eccd, callerFactory) { - const polyChainId = await getPolyChainId(); - - await fs.writeFile('./contracts/core/cross_chain_manager/logic/Const.sol', - 'pragma solidity ^0.5.0;\n'+ - 'contract Const {\n'+ - ' bytes constant ZionCrossChainManagerAddress = hex"5747C05FF236F8d18BB21Bc02ecc389deF853cae"; \n'+ - ' bytes constant ZionValidaterManagerAddress = hex"A4Bf827047a08510722B2d62e668a72FCCFa232C"; \n'+ - ' address constant EthCrossChainDataAddress = '+eccd+'; \n'+ - ' address constant EthCrossChainCallerFactoryAddress = '+callerFactory+'; \n'+ - ' uint constant chainId = '+polyChainId+'; \n}', - function(err) { - if (err) { - console.error(err); - process.exit(1); - } - }); -} - -async function getPolyChainId() { - const chainId = await hre.web3.eth.getChainId(); - switch (chainId) { - - // mainnet - case 1: // eth-main - return 2; - case 56: // bsc-main - return 6; - case 128: // heco-main - return 7; - case 137: // polygon-main - return 17; - case 66: // ok-main - return 12; - case 1718: // plt-main - return 8; - - // testnet - case 3: // eth-test - return 2; - case 97: // bsc-test - return 79; - case 256: // heco-test - return 7; - case 80001: // polygon-test - return 202; - case 65: // ok-test - return 200; - case 101: // plt-test - return 107; - case 421611: // arbitrum-test - return 205; - - // hardhat devnet - case 31337: - return 77777; - - // unknown chainid - default: - throw new Error("fail to get Poly_Chain_Id, unknown Network_Id: "+chainId); - } -} - -// We recommend this pattern to be able to use async/await everywhere -// and properly handle errors. -main() - .then(() => process.exit(0)) - .catch((error) => { - console.error(error); - process.exit(1); - }); - From 24490d33c89e0c4d9d7df1348fd85285d69726d8 Mon Sep 17 00:00:00 2001 From: Ethan Date: Thu, 15 Dec 2022 16:03:12 +0800 Subject: [PATCH 2/6] verify-helper: remove set function --- contracts/core/cross_chain_manager/logic/VerifyHelper.sol | 5 ----- 1 file changed, 5 deletions(-) diff --git a/contracts/core/cross_chain_manager/logic/VerifyHelper.sol b/contracts/core/cross_chain_manager/logic/VerifyHelper.sol index 1c8e93a..8bdd4bf 100644 --- a/contracts/core/cross_chain_manager/logic/VerifyHelper.sol +++ b/contracts/core/cross_chain_manager/logic/VerifyHelper.sol @@ -14,11 +14,6 @@ contract VerifyHelper { ZionCrossChainManagerAddress = zionCrossChainManagerAddress; } - function set(address ethCrossChainDataAddress, bytes memory zionCrossChainManagerAddress) public { - EthCrossChainDataAddress = ethCrossChainDataAddress; - ZionCrossChainManagerAddress = zionCrossChainManagerAddress; - } - function verifyHeader( bytes memory rawHeader, bytes memory rawSeals, From d9f452ab82285c7a3dd74f2f5257af4acf27adc4 Mon Sep 17 00:00:00 2001 From: Ethan Date: Mon, 16 Jan 2023 11:04:11 +0800 Subject: [PATCH 3/6] wrap lock function --- contracts/core/lockProxy/RippleLockProxy.sol | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/contracts/core/lockProxy/RippleLockProxy.sol b/contracts/core/lockProxy/RippleLockProxy.sol index 95239f6..44c75e2 100644 --- a/contracts/core/lockProxy/RippleLockProxy.sol +++ b/contracts/core/lockProxy/RippleLockProxy.sol @@ -164,4 +164,17 @@ contract RippleLockProxy is Ownable { (args.toAddress, args.amount) = abi.decode(valueBs, (bytes,uint256)); return args; } + + // function for wrapper only + function assetHashMap(address fromAssetHash, uint64 toChainId) external view returns (bytes memory) { + return proxyHashMap[toChainId]; + } + function lock( + address fromAssetHash, + uint64 toChainId, + bytes calldata toAddress, + uint256 amount + ) external payable returns (bool) { + return lock(toChainId, toAddress, amount); + } } \ No newline at end of file From b9448f3308cfc619fa6edc9a4ec9b016463f46e1 Mon Sep 17 00:00:00 2001 From: Ethan Date: Wed, 18 Jan 2023 16:42:53 +0800 Subject: [PATCH 4/6] update verify header function --- .../cross_chain_manager/libs/ECCUtils/EthCrossChainUtils.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/core/cross_chain_manager/libs/ECCUtils/EthCrossChainUtils.sol b/contracts/core/cross_chain_manager/libs/ECCUtils/EthCrossChainUtils.sol index e0a3f1f..d53f28e 100644 --- a/contracts/core/cross_chain_manager/libs/ECCUtils/EthCrossChainUtils.sol +++ b/contracts/core/cross_chain_manager/libs/ECCUtils/EthCrossChainUtils.sol @@ -41,7 +41,7 @@ library ECCUtils { for (uint i=0; i Date: Wed, 15 Mar 2023 16:53:03 +0800 Subject: [PATCH 5/6] update testcase --- contracts/mocks/ECCUtils/ECCUtilsMock.sol | 15 ++++++ package.json | 25 ++++++++-- test/ECCUtilsTest.js | 56 +++++++++++------------ 3 files changed, 63 insertions(+), 33 deletions(-) diff --git a/contracts/mocks/ECCUtils/ECCUtilsMock.sol b/contracts/mocks/ECCUtils/ECCUtilsMock.sol index 6a9bf84..dd91c83 100644 --- a/contracts/mocks/ECCUtils/ECCUtilsMock.sol +++ b/contracts/mocks/ECCUtils/ECCUtilsMock.sol @@ -12,6 +12,21 @@ contract ECCUtilsMock { function verifyHeader(bytes32 headerHash, bytes memory rawSeals, address[] memory validators) public pure returns(bool) { return ECCUtils.verifyHeader(headerHash, rawSeals, validators); } + + function verifyHeader(bytes32 headerHash, bytes memory rawSeals) public pure returns(address[] memory) { + uint offset = 0x20; + bytes memory seal; + + (rawSeals,) = rlpSplit(rawSeals, 0x20); + uint sealCount = rawSeals.length/(67); + address[] memory signers = new address[](sealCount); + + for (uint i=0; i Date: Thu, 24 Aug 2023 15:11:26 +0800 Subject: [PATCH 6/6] add ExcuteTxEvnet --- .../logic/EthCrossChainManagerImplementation.sol | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/contracts/core/cross_chain_manager/logic/EthCrossChainManagerImplementation.sol b/contracts/core/cross_chain_manager/logic/EthCrossChainManagerImplementation.sol index 6d0c458..49a6132 100644 --- a/contracts/core/cross_chain_manager/logic/EthCrossChainManagerImplementation.sol +++ b/contracts/core/cross_chain_manager/logic/EthCrossChainManagerImplementation.sol @@ -16,7 +16,8 @@ contract EthCrossChainManagerImplementation is Const { event ChangeEpochEvent(uint256 height, bytes rawHeader, address[] oldValidators, address[] newValidators); event CrossChainEvent(address indexed sender, bytes txId, address proxyOrAssetContract, uint64 toChainId, bytes toContract, bytes rawdata); event VerifyHeaderAndExecuteTxEvent(uint64 fromChainID, bytes toContract, bytes crossChainTxHash, bytes fromChainTxHash); - + event ExecuteTxEvent(address toContract, bytes method, bytes args); + // see in Const.sol // address constant EthCrossChainDataAddress = 0x0000000000000000000000000000000000000000; // address constant EthCrossChainCallerFactoryAddress = 0x0000000000000000000000000000000000000000; @@ -164,6 +165,8 @@ contract EthCrossChainManagerImplementation is Const { require(returnData.length != 0, "No return value from business contract!"); bool res = abi.decode(returnData, (bool)); require(res == true, "EthCrossChain call business contract return is not true"); + + emit ExecuteTxEvent(_toContract, _method, _args); return true; }