From 6666be1e37c1133e4a1e1b41e48089760285e3ca Mon Sep 17 00:00:00 2001 From: echo Date: Fri, 5 Jan 2024 11:44:26 +0800 Subject: [PATCH] upgrade to oracle v2 on crab and sepolia --- bin/dao.sh | 10 +++++++-- bin/deploy.sh | 7 +++--- bin/fee.sh | 2 +- bin/verify.sh | 5 +++-- script/deploy/Deploy.s.sol | 24 ++++++++------------- script/fee/Fee.s.sol | 6 +----- script/input/1/deploy.c.json | 1 - script/input/11155111/deploy.c.json | 1 - script/input/44/deploy.c.json | 1 - script/input/44/fee.c.json | 4 ++-- script/input/c3.json | 8 +++---- script/output/11155111/deploy.a-latest.json | 2 +- script/output/44/OracleV2.v.json | 1 + script/output/44/deploy.a-latest.json | 2 +- 14 files changed, 34 insertions(+), 40 deletions(-) create mode 100644 script/output/44/OracleV2.v.json diff --git a/bin/dao.sh b/bin/dao.sh index f9dc25f..ee55848 100755 --- a/bin/dao.sh +++ b/bin/dao.sh @@ -6,10 +6,13 @@ c3=$PWD/script/input/c3.json deployer=$(jq -r ".DEPLOYER" $c3) dao=$(jq -r ".MSGDAO" $c3) +subapi_dao=$(jq -r ".SUBAPIDAO_ADDR" $c3) ormp=$(jq -r ".ORMP_ADDR" $c3) -oracle=$(jq -r ".ORACLE_ADDR" $c3) +oracle=$(jq -r ".ORACLEV2_ADDR" $c3) relayer=$(jq -r ".RELAYER_ADDR" $c3) +set -x + # seth send -F $deployer $ormp "changeSetter(address)" $dao --chain darwinia # seth send -F $deployer $ormp "changeSetter(address)" $dao --chain arbitrum # seth send -F $deployer $ormp "changeSetter(address)" $dao --chain ethereum @@ -20,4 +23,7 @@ relayer=$(jq -r ".RELAYER_ADDR" $c3) # seth send -F $deployer $relayer "changeOwner(address)" $dao --chain darwinia # seth send -F $deployer $relayer "changeOwner(address)" $dao --chain arbitrum -seth send -F $deployer $relayer "changeOwner(address)" $dao --chain ethereum +# seth send -F $deployer $relayer "changeOwner(address)" $dao --chain ethereum + +seth send -F $deployer $oracle "changeOwner(address)" $subapi_dao --chain crab +seth send -F $deployer $oracle "changeOwner(address)" $subapi_dao --chain sepolia diff --git a/bin/deploy.sh b/bin/deploy.sh index 416f073..2c02470 100755 --- a/bin/deploy.sh +++ b/bin/deploy.sh @@ -3,10 +3,9 @@ set -eo pipefail # forge script script/deploy/Deploy.s.sol:Deploy --chain-id 1 --legacy --broadcast --verify --slow -forge script script/deploy/Deploy.s.sol:Deploy --chain-id 46 --broadcast --verify --slow -forge script script/deploy/Deploy.s.sol:Deploy --chain-id 42161 --broadcast --verify --slow --legacy +# forge script script/deploy/Deploy.s.sol:Deploy --chain-id 46 --broadcast --verify --slow +# forge script script/deploy/Deploy.s.sol:Deploy --chain-id 42161 --broadcast --verify --slow --legacy -# forge script script/deploy/Deploy.s.sol:Deploy --chain-id 44 --broadcast --verify +# forge script script/deploy/Deploy.s.sol:Deploy --chain-id 44 --broadcast --verify --skip-simulation # forge script script/deploy/Deploy.s.sol:Deploy --chain-id 421614 --broadcast --verify # forge script script/deploy/Deploy.s.sol:Deploy --chain-id 11155111 --broadcast --verify - diff --git a/bin/fee.sh b/bin/fee.sh index d4c1cd2..287e32c 100755 --- a/bin/fee.sh +++ b/bin/fee.sh @@ -15,6 +15,6 @@ set -x forge script script/fee/Fee.s.sol:Fee --sig "run(uint256)" 11155111 --chain-id 44 --broadcast # forge script script/fee/Fee.s.sol:Fee --sig "run(uint256)" 421614 --chain-id 44 --broadcast # forge script script/fee/Fee.s.sol:Fee --sig "run(uint256)" 421614 --chain-id 11155111 --broadcast -# forge script script/fee/Fee.s.sol:Fee --sig "run(uint256)" 44 --chain-id 11155111 --broadcast +forge script script/fee/Fee.s.sol:Fee --sig "run(uint256)" 44 --chain-id 11155111 --broadcast # forge script script/fee/Fee.s.sol:Fee --sig "run(uint256)" 44 --chain-id 421614 --broadcast --skip-simulation --legacy # forge script script/fee/Fee.s.sol:Fee --sig "run(uint256)" 11155111 --chain-id 421614 --broadcast --skip-simulation --legacy diff --git a/bin/verify.sh b/bin/verify.sh index 12e5c68..8ef7edb 100755 --- a/bin/verify.sh +++ b/bin/verify.sh @@ -6,9 +6,8 @@ c3=$PWD/script/input/c3.json deployer=$(jq -r ".DEPLOYER" $c3) ormp=$(jq -r ".ORMP_ADDR" $c3) -oracle=$(jq -r ".ORACLE_ADDR" $c3) +oracle=$(jq -r ".ORACLEV2_ADDR" $c3) relayer=$(jq -r ".RELAYER_ADDR" $c3) -subapi=$(jq -r ".SUBAPI_ADDR" $c3) verify() { local addr; addr=$1 @@ -28,6 +27,8 @@ verify() { $path > script/output/$chain_id/$name.v.json) } +verify $oracle 44 $(cast abi-encode "constructor(address,address)" $deployer $ormp) src/eco/OracleV2.sol:OracleV2 + # verify $ormp 42161 $(cast abi-encode "constructor(address)" $deployer) src/ORMP.sol:ORMP # verify $ormp 46 $(cast abi-encode "constructor(address)" $deployer) src/ORMP.sol:ORMP # verify $oracle 42161 $(cast abi-encode "constructor(address,address,address)" $deployer $ormp $subapi) src/eco/Oracle.sol:Oracle diff --git a/script/deploy/Deploy.s.sol b/script/deploy/Deploy.s.sol index 81f7c04..7e19d48 100644 --- a/script/deploy/Deploy.s.sol +++ b/script/deploy/Deploy.s.sol @@ -9,7 +9,7 @@ import {ScriptTools} from "create3-deploy/script/ScriptTools.sol"; import {ORMP} from "../../src/ORMP.sol"; import {Relayer} from "../../src/eco/Relayer.sol"; -import {Oracle} from "../../src/eco/Oracle.sol"; +import {OracleV2} from "../../src/eco/OracleV2.sol"; interface III { function PROTOCOL() external view returns (address); @@ -35,7 +35,6 @@ contract Deploy is Common { bytes32 ORACLE_SALT; address RELAYER_ADDR; bytes32 RELAYER_SALT; - address SUBAPI_ADDR; string c3; string config; @@ -43,7 +42,6 @@ contract Deploy is Common { string outputName; address deployer; address dao; - address oracleOperator; address relayerOperator; /// @notice The name of the script, used to ensure the right deploy artifacts @@ -62,15 +60,13 @@ contract Deploy is Common { ORMP_ADDR = c3.readAddress(".ORMP_ADDR"); ORMP_SALT = c3.readBytes32(".ORMP_SALT"); - ORACLE_ADDR = c3.readAddress(".ORACLE_ADDR"); - ORACLE_SALT = c3.readBytes32(".ORACLE_SALT"); + ORACLE_ADDR = c3.readAddress(".ORACLEV2_ADDR"); + ORACLE_SALT = c3.readBytes32(".ORACLEV2_SALT"); RELAYER_ADDR = c3.readAddress(".RELAYER_ADDR"); RELAYER_SALT = c3.readBytes32(".RELAYER_SALT"); - SUBAPI_ADDR = c3.readAddress(".SUBAPI_ADDR"); deployer = config.readAddress(".DEPLOYER"); dao = config.readAddress(".DAO"); - oracleOperator = config.readAddress(".ORACLE_OPERATOR"); relayerOperator = config.readAddress(".RELAYER_OPERATOR"); } @@ -78,9 +74,9 @@ contract Deploy is Common { function run() public { require(deployer == msg.sender, "!deployer"); - deployProtocol(); + // deployProtocol(); deployOralce(); - deployRelayer(); + // deployRelayer(); setConfig(); @@ -103,8 +99,8 @@ contract Deploy is Common { /// @notice Deploy the Oracle function deployOralce() public broadcast returns (address) { - bytes memory byteCode = type(Oracle).creationCode; - bytes memory initCode = bytes.concat(byteCode, abi.encode(deployer, ORMP_ADDR, SUBAPI_ADDR)); + bytes memory byteCode = type(OracleV2).creationCode; + bytes memory initCode = bytes.concat(byteCode, abi.encode(deployer, ORMP_ADDR)); address oracle = _deploy3(ORACLE_SALT, initCode); require(oracle == ORACLE_ADDR, "!oracle"); @@ -134,10 +130,8 @@ contract Deploy is Common { require(o == ORACLE_ADDR, "!oracle"); require(r == RELAYER_ADDR, "!relayer"); - III(ORACLE_ADDR).setApproved(oracleOperator, true); - require(III(ORACLE_ADDR).isApproved(oracleOperator), "!o-operator"); - III(RELAYER_ADDR).setApproved(relayerOperator, true); - require(III(RELAYER_ADDR).isApproved(relayerOperator), "!r-operator"); + // III(RELAYER_ADDR).setApproved(relayerOperator, true); + // require(III(RELAYER_ADDR).isApproved(relayerOperator), "!r-operator"); // III(ORMP_ADDR).changeSetter(dao); // require(III(ORMP_ADDR).setter() == dao, "!dao"); diff --git a/script/fee/Fee.s.sol b/script/fee/Fee.s.sol index 1beabf3..d2b1ac1 100644 --- a/script/fee/Fee.s.sol +++ b/script/fee/Fee.s.sol @@ -43,7 +43,7 @@ contract Fee is Common { function run(uint256 chainId) public { require(dao == msg.sender, "!dao"); setOracleFee(chainId); - setRelayerFee(chainId); + // setRelayerFee(chainId); } function setOracleFee(uint256 chainId) public broadcast { @@ -51,10 +51,6 @@ contract Fee is Common { uint256 fee = config.readUint(key); address oracle = deployedContracts.readAddress(".ORACLE"); - bool approved = III(oracle).isApproved(dao); - if (!approved) { - III(oracle).setApproved(dao, true); - } III(oracle).setFee(chainId, fee); require(III(oracle).fee(chainId, address(0)) == fee); } diff --git a/script/input/1/deploy.c.json b/script/input/1/deploy.c.json index 0324c37..0ed3a38 100644 --- a/script/input/1/deploy.c.json +++ b/script/input/1/deploy.c.json @@ -1,6 +1,5 @@ { "DAO": "0x0f14341A7f464320319025540E8Fe48Ad0fe5aec", "DEPLOYER": "0x0f14341A7f464320319025540E8Fe48Ad0fe5aec", - "ORACLE_OPERATOR": "0x912D7601569cBc2DF8A7f0aaE50BFd18e8C64d05", "RELAYER_OPERATOR": "0x912D7601569cBc2DF8A7f0aaE50BFd18e8C64d05" } diff --git a/script/input/11155111/deploy.c.json b/script/input/11155111/deploy.c.json index 164a43d..a57b2ee 100644 --- a/script/input/11155111/deploy.c.json +++ b/script/input/11155111/deploy.c.json @@ -1,6 +1,5 @@ { "DAO": "0x0f14341A7f464320319025540E8Fe48Ad0fe5aec", "DEPLOYER": "0x0f14341A7f464320319025540E8Fe48Ad0fe5aec", - "ORACLE_OPERATOR": "0x0b001c95E86D64C1Ad6e43944C568A6C31b53887", "RELAYER_OPERATOR": "0x0b001c95E86D64C1Ad6e43944C568A6C31b53887" } diff --git a/script/input/44/deploy.c.json b/script/input/44/deploy.c.json index 164a43d..a57b2ee 100644 --- a/script/input/44/deploy.c.json +++ b/script/input/44/deploy.c.json @@ -1,6 +1,5 @@ { "DAO": "0x0f14341A7f464320319025540E8Fe48Ad0fe5aec", "DEPLOYER": "0x0f14341A7f464320319025540E8Fe48Ad0fe5aec", - "ORACLE_OPERATOR": "0x0b001c95E86D64C1Ad6e43944C568A6C31b53887", "RELAYER_OPERATOR": "0x0b001c95E86D64C1Ad6e43944C568A6C31b53887" } diff --git a/script/input/44/fee.c.json b/script/input/44/fee.c.json index 0c69002..51726d7 100644 --- a/script/input/44/fee.c.json +++ b/script/input/44/fee.c.json @@ -4,10 +4,10 @@ "fee": 75000000000000000000 }, "421614": { - "fee": 5000000000000000000 + "fee": 1000000000000000000 }, "11155111": { - "fee": 5000000000000000000 + "fee": 1000000000000000000 } }, "RELAYER": { diff --git a/script/input/c3.json b/script/input/c3.json index 1bc7d49..59b70c0 100644 --- a/script/input/c3.json +++ b/script/input/c3.json @@ -1,11 +1,11 @@ { "DEPLOYER": "0x0f14341A7f464320319025540E8Fe48Ad0fe5aec", "MSGDAO": "0x000000000879926D12aF396788C0785B7e581e53", + "SUBAPIDAO_ADDR": "0x000000000a0D8ac9cc6CbD817fA77090322FF29d", "ORMP_ADDR": "0x00000000001523057a05d6293C1e5171eE33eE0A", "ORMP_SALT": "0x4d629bbdb40d29206f12a51aa81faf14553b218f96845742a89e02e55ecfcef6", - "ORACLE_ADDR": "0x00000000046bc530804d66B6b64f7aF69B4E4E81", - "ORACLE_SALT": "0x2f280285b23be5539441999307347b699ec014dc1acf3db714d3d133b1a3cfe5", + "ORACLEV2_ADDR": "0x00000000023D0348fD049690E97b2E76DB051Cc9", + "ORACLEV2_SALT": "0x5be22c3cd3874db1d1f82a4071a72772f6f9a33db0ac2f983d72aa39884d3b4e", "RELAYER_ADDR": "0x0000000000808fE9bDCc1d180EfbF5C53552a6b1", - "RELAYER_SALT": "0x9d38bcb32422a45bc9c08605d4457bcd3dadddfee1573a352ace5f1defa45621", - "SUBAPI_ADDR": "0x00000000096c285629Fe3EAb3dd042c27b9dcBa6" + "RELAYER_SALT": "0x9d38bcb32422a45bc9c08605d4457bcd3dadddfee1573a352ace5f1defa45621" } diff --git a/script/output/11155111/deploy.a-latest.json b/script/output/11155111/deploy.a-latest.json index 4bf9fcd..73b6447 100644 --- a/script/output/11155111/deploy.a-latest.json +++ b/script/output/11155111/deploy.a-latest.json @@ -1,6 +1,6 @@ { "DAO": "0x0f14341A7f464320319025540E8Fe48Ad0fe5aec", - "ORACLE": "0x00000000046bc530804d66B6b64f7aF69B4E4E81", + "ORACLE": "0x00000000023D0348fD049690E97b2E76DB051Cc9", "ORMP": "0x00000000001523057a05d6293C1e5171eE33eE0A", "RELAYER": "0x0000000000808fE9bDCc1d180EfbF5C53552a6b1" } \ No newline at end of file diff --git a/script/output/44/OracleV2.v.json b/script/output/44/OracleV2.v.json new file mode 100644 index 0000000..799042c --- /dev/null +++ b/script/output/44/OracleV2.v.json @@ -0,0 +1 @@ +{"language": "Solidity", "sources": {"src/eco/OracleV2.sol": {"content": "// This file is part of Darwinia.\n// Copyright (C) 2018-2023 Darwinia Network\n// SPDX-License-Identifier: GPL-3.0\n//\n// Darwinia is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Darwinia is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Darwinia. If not, see .\n\npragma solidity 0.8.17;\n\nimport \"../Verifier.sol\";\nimport \"../interfaces/IFeedOracle.sol\";\n\ncontract OracleV2 is Verifier {\n event Assigned(bytes32 indexed msgHash, uint256 fee);\n event SetFee(uint256 indexed chainId, uint256 fee);\n event SetApproved(address operator, bool approve);\n event ImporedMessageRoot(uint256 indexed chaindId, uint256 indexed blockNumber, bytes32 messageRoot);\n\n address public immutable PROTOCOL;\n\n address public owner;\n // chainId => price\n mapping(uint256 => uint256) public feeOf;\n // chainId => blockNumber => messageRoot\n mapping(uint256 => mapping(uint256 => bytes32)) rootOf;\n\n modifier onlyOwner() {\n require(msg.sender == owner, \"!owner\");\n _;\n }\n\n constructor(address dao, address ormp) {\n PROTOCOL = ormp;\n owner = dao;\n }\n\n receive() external payable {}\n\n function importMessageRoot(uint256 chainId, uint256 blockNumber, bytes32 messageRoot) external onlyOwner {\n rootOf[chainId][blockNumber] = messageRoot;\n emit ImporedMessageRoot(chainId, blockNumber, messageRoot);\n }\n\n function withdraw(address to, uint256 amount) external onlyOwner {\n (bool success,) = to.call{value: amount}(\"\");\n require(success, \"!withdraw\");\n }\n\n function changeOwner(address owner_) external onlyOwner {\n owner = owner_;\n }\n\n function setFee(uint256 chainId, uint256 fee_) external onlyOwner {\n feeOf[chainId] = fee_;\n emit SetFee(chainId, fee_);\n }\n\n function fee(uint256 toChainId, address /*ua*/ ) public view returns (uint256) {\n return feeOf[toChainId];\n }\n\n function assign(bytes32 msgHash) external payable {\n require(msg.sender == PROTOCOL, \"!auth\");\n emit Assigned(msgHash, msg.value);\n }\n\n function merkleRoot(uint256 chainId, uint256 blockNumber) public view override returns (bytes32) {\n return rootOf[chainId][blockNumber];\n }\n}\n", "keccak256": "0xd72862299a6de413837b84e2956420a5dda14d8104d135506153a5e9be2ea5ff"}, "src/Verifier.sol": {"content": "// This file is part of Darwinia.\n// Copyright (C) 2018-2023 Darwinia Network\n// SPDX-License-Identifier: GPL-3.0\n//\n// Darwinia is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Darwinia is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Darwinia. If not, see .\n\npragma solidity 0.8.17;\n\nimport \"./interfaces/IVerifier.sol\";\nimport \"./imt/IncrementalMerkleTree.sol\";\n\nabstract contract Verifier is IVerifier {\n /// @notice Message proof.\n /// @param blockNumber The block number corresponding to the proof.\n /// @param messageIndex Leaf index of the message hash in incremental merkle tree.\n /// @param messageProof Merkle proof of the message hash.\n struct Proof {\n uint256 blockNumber;\n uint256 messageIndex;\n bytes32[32] messageProof;\n }\n\n /// @inheritdoc IVerifier\n function merkleRoot(uint256 chainId, uint256 blockNumber) public view virtual returns (bytes32);\n\n /// @inheritdoc IVerifier\n function verifyMessageProof(uint256 fromChainId, bytes32 msgHash, bytes calldata proof)\n external\n view\n returns (bool)\n {\n // decode proof\n Proof memory p = abi.decode(proof, (Proof));\n\n // fetch message root in block number from chain\n bytes32 imtRootOracle = merkleRoot(fromChainId, p.blockNumber);\n // calculate the expected root based on the proof\n bytes32 imtRootProof = IncrementalMerkleTree.branchRoot(msgHash, p.messageProof, p.messageIndex);\n\n // check oracle's merkle root equal relayer's merkle root\n return imtRootOracle == imtRootProof;\n }\n}\n", "keccak256": "0x3d61b8b81941f72eca88bc91c727de428e79bb512269bb56acab874b6832730e"}, "src/interfaces/IFeedOracle.sol": {"content": "// This file is part of Darwinia.\n// Copyright (C) 2018-2023 Darwinia Network\n// SPDX-License-Identifier: GPL-3.0\n//\n// Darwinia is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Darwinia is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Darwinia. If not, see .\n\npragma solidity 0.8.17;\n\ninterface IFeedOracle {\n function messageRootOf(uint256 chainid) external view returns (bytes32);\n}\n", "keccak256": "0x573bea2faeba8db09c2cdf8524f6e56107b22274e024e8297f7ba31141e959e2"}, "src/interfaces/IVerifier.sol": {"content": "// This file is part of Darwinia.\n// Copyright (C) 2018-2023 Darwinia Network\n// SPDX-License-Identifier: GPL-3.0\n//\n// Darwinia is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Darwinia is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Darwinia. If not, see .\n\npragma solidity 0.8.17;\n\ninterface IVerifier {\n /// @notice Fetch message root oracle.\n /// @param chainId The destination chain id.\n /// @param blockNumber The block number where the message root is located.\n /// @return Message root in destination chain.\n function merkleRoot(uint256 chainId, uint256 blockNumber) external view returns (bytes32);\n\n /// @notice Verify message proof\n /// @dev Message proof provided by relayer. Oracle should provide message root of\n /// source chain, and verify the merkle proof of the message hash.\n /// @param fromChainId Source chain id.\n /// @param msgHash Hash of the message.\n /// @param proof Merkle proof of the message\n /// @return Result of the message verify.\n function verifyMessageProof(uint256 fromChainId, bytes32 msgHash, bytes calldata proof)\n external\n view\n returns (bool);\n}\n", "keccak256": "0x60ad4dbeb54c04aa1c389a2dab7c9bca361eb2df245b3a29f0851be697876099"}, "src/imt/IncrementalMerkleTree.sol": {"content": "// SPDX-License-Identifier: MIT OR Apache-2.0\npragma solidity 0.8.17;\n\n// Inspired: https://github.com/nomad-xyz/monorepo/blob/main/packages/contracts-core/contracts/libs/Merkle.sol\n\n/// @title IncrementalMerkleTree\n/// @author Illusory Systems Inc.\n/// @notice An incremental merkle tree modeled on the eth2 deposit contract.\nlibrary IncrementalMerkleTree {\n uint256 private constant TREE_DEPTH = 32;\n uint256 private constant MAX_LEAVES = 2 ** TREE_DEPTH - 1;\n\n /// @notice Struct representing incremental merkle tree. Contains current\n /// branch and the number of inserted leaves in the tree.\n struct Tree {\n bytes32[TREE_DEPTH] branch;\n uint256 count;\n }\n\n /// @notice Inserts `_node` into merkle tree\n /// @dev Reverts if tree is full\n /// @param _node Element to insert into tree\n function insert(Tree storage _tree, bytes32 _node) internal {\n require(_tree.count < MAX_LEAVES, \"merkle tree full\");\n\n _tree.count += 1;\n uint256 size = _tree.count;\n for (uint256 i = 0; i < TREE_DEPTH; i++) {\n if ((size & 1) == 1) {\n _tree.branch[i] = _node;\n return;\n }\n _node = keccak256(abi.encodePacked(_tree.branch[i], _node));\n size /= 2;\n }\n // As the loop should always end prematurely with the `return` statement,\n // this code should be unreachable. We assert `false` just to be safe.\n assert(false);\n }\n\n /// @notice Calculates and returns`_tree`'s current root given array of zero\n /// hashes\n /// @param _zeroes Array of zero hashes\n /// @return _current Calculated root of `_tree`\n function rootWithCtx(Tree storage _tree, bytes32[TREE_DEPTH] memory _zeroes)\n internal\n view\n returns (bytes32 _current)\n {\n uint256 _index = _tree.count;\n\n for (uint256 i = 0; i < TREE_DEPTH; i++) {\n uint256 _ithBit = (_index >> i) & 0x01;\n bytes32 _next = _tree.branch[i];\n if (_ithBit == 1) {\n _current = keccak256(abi.encodePacked(_next, _current));\n } else {\n _current = keccak256(abi.encodePacked(_current, _zeroes[i]));\n }\n }\n }\n\n /// @notice Calculates and returns`_tree`'s current root\n function root(Tree storage _tree) internal view returns (bytes32) {\n return rootWithCtx(_tree, zeroHashes());\n }\n\n /// @notice Returns array of TREE_DEPTH zero hashes\n /// @return _zeroes Array of TREE_DEPTH zero hashes\n function zeroHashes() internal pure returns (bytes32[TREE_DEPTH] memory _zeroes) {\n _zeroes[0] = Z_0;\n _zeroes[1] = Z_1;\n _zeroes[2] = Z_2;\n _zeroes[3] = Z_3;\n _zeroes[4] = Z_4;\n _zeroes[5] = Z_5;\n _zeroes[6] = Z_6;\n _zeroes[7] = Z_7;\n _zeroes[8] = Z_8;\n _zeroes[9] = Z_9;\n _zeroes[10] = Z_10;\n _zeroes[11] = Z_11;\n _zeroes[12] = Z_12;\n _zeroes[13] = Z_13;\n _zeroes[14] = Z_14;\n _zeroes[15] = Z_15;\n _zeroes[16] = Z_16;\n _zeroes[17] = Z_17;\n _zeroes[18] = Z_18;\n _zeroes[19] = Z_19;\n _zeroes[20] = Z_20;\n _zeroes[21] = Z_21;\n _zeroes[22] = Z_22;\n _zeroes[23] = Z_23;\n _zeroes[24] = Z_24;\n _zeroes[25] = Z_25;\n _zeroes[26] = Z_26;\n _zeroes[27] = Z_27;\n _zeroes[28] = Z_28;\n _zeroes[29] = Z_29;\n _zeroes[30] = Z_30;\n _zeroes[31] = Z_31;\n }\n\n /// @notice Calculates and returns the merkle root for the given leaf\n /// `_item`, a merkle branch, and the index of `_item` in the tree.\n /// @param _item Merkle leaf\n /// @param _branch Merkle proof\n /// @param _index Index of `_item` in tree\n /// @return _current Calculated merkle root\n function branchRoot(bytes32 _item, bytes32[TREE_DEPTH] memory _branch, uint256 _index)\n internal\n pure\n returns (bytes32 _current)\n {\n _current = _item;\n\n for (uint256 i = 0; i < TREE_DEPTH; i++) {\n uint256 _ithBit = (_index >> i) & 0x01;\n bytes32 _next = _branch[i];\n if (_ithBit == 1) {\n _current = keccak256(abi.encodePacked(_next, _current));\n } else {\n _current = keccak256(abi.encodePacked(_current, _next));\n }\n }\n }\n\n function prove(Tree storage _tree) internal view returns (bytes32[TREE_DEPTH] memory proof) {\n uint256 _index = _tree.count - 1;\n bytes32[TREE_DEPTH] memory left = _tree.branch;\n bytes32[TREE_DEPTH] memory right = zeroHashes();\n for (uint256 i = 0; i < TREE_DEPTH; i++) {\n uint256 _ith_bit = (_index >> i) & 0x01;\n if (_ith_bit == 1) {\n proof[i] = left[i];\n } else {\n proof[i] = right[i];\n }\n }\n }\n\n // keccak256 zero hashes\n bytes32 private constant Z_0 = hex\"0000000000000000000000000000000000000000000000000000000000000000\";\n bytes32 private constant Z_1 = hex\"ad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb5\";\n bytes32 private constant Z_2 = hex\"b4c11951957c6f8f642c4af61cd6b24640fec6dc7fc607ee8206a99e92410d30\";\n bytes32 private constant Z_3 = hex\"21ddb9a356815c3fac1026b6dec5df3124afbadb485c9ba5a3e3398a04b7ba85\";\n bytes32 private constant Z_4 = hex\"e58769b32a1beaf1ea27375a44095a0d1fb664ce2dd358e7fcbfb78c26a19344\";\n bytes32 private constant Z_5 = hex\"0eb01ebfc9ed27500cd4dfc979272d1f0913cc9f66540d7e8005811109e1cf2d\";\n bytes32 private constant Z_6 = hex\"887c22bd8750d34016ac3c66b5ff102dacdd73f6b014e710b51e8022af9a1968\";\n bytes32 private constant Z_7 = hex\"ffd70157e48063fc33c97a050f7f640233bf646cc98d9524c6b92bcf3ab56f83\";\n bytes32 private constant Z_8 = hex\"9867cc5f7f196b93bae1e27e6320742445d290f2263827498b54fec539f756af\";\n bytes32 private constant Z_9 = hex\"cefad4e508c098b9a7e1d8feb19955fb02ba9675585078710969d3440f5054e0\";\n bytes32 private constant Z_10 = hex\"f9dc3e7fe016e050eff260334f18a5d4fe391d82092319f5964f2e2eb7c1c3a5\";\n bytes32 private constant Z_11 = hex\"f8b13a49e282f609c317a833fb8d976d11517c571d1221a265d25af778ecf892\";\n bytes32 private constant Z_12 = hex\"3490c6ceeb450aecdc82e28293031d10c7d73bf85e57bf041a97360aa2c5d99c\";\n bytes32 private constant Z_13 = hex\"c1df82d9c4b87413eae2ef048f94b4d3554cea73d92b0f7af96e0271c691e2bb\";\n bytes32 private constant Z_14 = hex\"5c67add7c6caf302256adedf7ab114da0acfe870d449a3a489f781d659e8becc\";\n bytes32 private constant Z_15 = hex\"da7bce9f4e8618b6bd2f4132ce798cdc7a60e7e1460a7299e3c6342a579626d2\";\n bytes32 private constant Z_16 = hex\"2733e50f526ec2fa19a22b31e8ed50f23cd1fdf94c9154ed3a7609a2f1ff981f\";\n bytes32 private constant Z_17 = hex\"e1d3b5c807b281e4683cc6d6315cf95b9ade8641defcb32372f1c126e398ef7a\";\n bytes32 private constant Z_18 = hex\"5a2dce0a8a7f68bb74560f8f71837c2c2ebbcbf7fffb42ae1896f13f7c7479a0\";\n bytes32 private constant Z_19 = hex\"b46a28b6f55540f89444f63de0378e3d121be09e06cc9ded1c20e65876d36aa0\";\n bytes32 private constant Z_20 = hex\"c65e9645644786b620e2dd2ad648ddfcbf4a7e5b1a3a4ecfe7f64667a3f0b7e2\";\n bytes32 private constant Z_21 = hex\"f4418588ed35a2458cffeb39b93d26f18d2ab13bdce6aee58e7b99359ec2dfd9\";\n bytes32 private constant Z_22 = hex\"5a9c16dc00d6ef18b7933a6f8dc65ccb55667138776f7dea101070dc8796e377\";\n bytes32 private constant Z_23 = hex\"4df84f40ae0c8229d0d6069e5c8f39a7c299677a09d367fc7b05e3bc380ee652\";\n bytes32 private constant Z_24 = hex\"cdc72595f74c7b1043d0e1ffbab734648c838dfb0527d971b602bc216c9619ef\";\n bytes32 private constant Z_25 = hex\"0abf5ac974a1ed57f4050aa510dd9c74f508277b39d7973bb2dfccc5eeb0618d\";\n bytes32 private constant Z_26 = hex\"b8cd74046ff337f0a7bf2c8e03e10f642c1886798d71806ab1e888d9e5ee87d0\";\n bytes32 private constant Z_27 = hex\"838c5655cb21c6cb83313b5a631175dff4963772cce9108188b34ac87c81c41e\";\n bytes32 private constant Z_28 = hex\"662ee4dd2dd7b2bc707961b1e646c4047669dcb6584f0d8d770daf5d7e7deb2e\";\n bytes32 private constant Z_29 = hex\"388ab20e2573d171a88108e79d820e98f26c0b84aa8b2f4aa4968dbb818ea322\";\n bytes32 private constant Z_30 = hex\"93237c50ba75ee485f4c22adf2f741400bdf8d6a9cc7df7ecae576221665d735\";\n bytes32 private constant Z_31 = hex\"8448818bb4ae4562849e949e17ac16e0be16688e156b5cf15e098c627c0056a9\";\n}\n", "keccak256": "0x535228355f8bd4339f42aa3dfe3cebcbdaad7a92704c4e3eeb0982dce8acf246"}}, "settings": {"remappings": ["forge-std/=lib/forge-std/src/", "ds-test/=lib/forge-std/lib/ds-test/src/", "create3-deploy/=lib/create3-deploy/"], "optimizer": {"enabled": true, "runs": 999999}, "metadata": {"useLiteralContent": false, "bytecodeHash": "ipfs"}, "outputSelection": {"*": {"": ["ast"], "*": ["abi", "evm.bytecode", "evm.deployedBytecode", "evm.methodIdentifiers", "metadata", "storageLayout", "devdoc", "userdoc"]}}, "evmVersion": "london", "libraries": {}, "compilationTarget": {"src/eco/OracleV2.sol": "OracleV2"}}} \ No newline at end of file diff --git a/script/output/44/deploy.a-latest.json b/script/output/44/deploy.a-latest.json index 4bf9fcd..73b6447 100644 --- a/script/output/44/deploy.a-latest.json +++ b/script/output/44/deploy.a-latest.json @@ -1,6 +1,6 @@ { "DAO": "0x0f14341A7f464320319025540E8Fe48Ad0fe5aec", - "ORACLE": "0x00000000046bc530804d66B6b64f7aF69B4E4E81", + "ORACLE": "0x00000000023D0348fD049690E97b2E76DB051Cc9", "ORMP": "0x00000000001523057a05d6293C1e5171eE33eE0A", "RELAYER": "0x0000000000808fE9bDCc1d180EfbF5C53552a6b1" } \ No newline at end of file