Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redeploy on testnet #71

Merged
merged 4 commits into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ Oracle and Relayer based Message Protocol.
### Canonical Cross-chain Deployment Addresses
| Contract | Canonical Cross-chain Deployment Address |
|------------|--------------------------------------------|
| ORMP | 0x0034607daf9c1dc6628f6e09E81bB232B6603A89 |
| Oracle | 0x0002396F1D52323fcd1ae8079b38808F046882c3 |
| Relayer | 0x007EED6207c9AF3715964Fb7f8B5f44E002a3498 |
| ORMP | 0x009D223Aad560e72282db9c0438Ef1ef2bf7703D |
| Oracle | 0x00BD655DDfA7aFeF4BB109FE1F938724527B49D8 |
| Relayer | 0x0065a081a11cc1f6e1692c2A08E9AF36b17973eC |

## Usage
To install with [**Foundry**](https://github.com/gakonst/foundry):
Expand Down
2 changes: 1 addition & 1 deletion bin/fee.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ set -eo pipefail

set -x
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)" 44 --chain-id 421614 --broadcast --skip-simulation
forge script script/fee/Fee.s.sol:Fee --sig "run(uint256)" 44 --chain-id 421614 --broadcast # --skip-simulation
6 changes: 3 additions & 3 deletions bin/verify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
set -eo pipefail

deployer=0x0f14341A7f464320319025540E8Fe48Ad0fe5aec
ormp=0x0034607daf9c1dc6628f6e09E81bB232B6603A89
oracle=0x0002396F1D52323fcd1ae8079b38808F046882c3
relayer=0x007EED6207c9AF3715964Fb7f8B5f44E002a3498
ormp=0x009D223Aad560e72282db9c0438Ef1ef2bf7703D
oracle=0x00BD655DDfA7aFeF4BB109FE1F938724527B49D8
relayer=0x0065a081a11cc1f6e1692c2A08E9AF36b17973eC

verify() {
local addr; addr=$1
Expand Down
75 changes: 38 additions & 37 deletions script/deploy/Deploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {console2 as console} from "forge-std/console2.sol";
import {Common} from "create3-deploy/script/Common.s.sol";
import {ScriptTools} from "create3-deploy/script/ScriptTools.sol";

import "../../src/ORMP.sol";
import {Config, ORMP} from "../../src/ORMP.sol";
import {Relayer} from "../../src/eco/Relayer.sol";
import {Oracle} from "../../src/eco/Oracle.sol";

Expand All @@ -29,12 +29,14 @@ contract Deploy is Common {
using stdJson for string;
using ScriptTools for string;

address immutable ORMP_ADDR = 0x0034607daf9c1dc6628f6e09E81bB232B6603A89;
bytes32 immutable ORMP_SALT = 0x4a177511c10933b157108cb8d40e2cbeeccafdec51c3445d5e117ac1981285be;
address immutable ORACLE_ADDR = 0x0002396F1D52323fcd1ae8079b38808F046882c3;
bytes32 immutable ORACLE_SALT = 0x4988d5215faf6ade0dcd51066e709ccb81edc58914ea7a60b0afa1f3a01c71f3;
address immutable RELAYER_ADDR = 0x007EED6207c9AF3715964Fb7f8B5f44E002a3498;
bytes32 immutable RELAYER_SALT = 0xcd9f567f57f0c293ba969f9c702f7684bb9e758d3a6bb88da8c99e6f1e851e5d;
address immutable ORMP_ADDR = 0x009D223Aad560e72282db9c0438Ef1ef2bf7703D;
bytes32 immutable ORMP_SALT = 0x0a68f3af806b448a1e6e4b5b2fced6f144cff5e1bfd733bcb51916a6d696e7aa;

address immutable ORACLE_ADDR = 0x00BD655DDfA7aFeF4BB109FE1F938724527B49D8;
bytes32 immutable ORACLE_SALT = 0xfbb782802ad938a1df1c89407273c248c1d7af7b4f9e94704564a4ca792a4296;

address immutable RELAYER_ADDR = 0x0065a081a11cc1f6e1692c2A08E9AF36b17973eC;
bytes32 immutable RELAYER_SALT = 0x5f1532f1a200d9076629b2691489b82712c30ba913251eae5871243a0faa5062;

string config;
string instanceId;
Expand Down Expand Up @@ -67,17 +69,16 @@ contract Deploy is Common {
function run() public {
require(deployer == msg.sender, "!deployer");

address ormp = deployProtocol();

address oracle = deployOralce(ormp);
address relayer = deployRelayer(ormp);
// deployProtocol();
// deployOralce();
// deployRelayer();

setConfig(ormp, oracle, relayer);
setConfig();

ScriptTools.exportContract(outputName, "DAO", dao);
ScriptTools.exportContract(outputName, "ORMP", ormp);
ScriptTools.exportContract(outputName, "ORACLE", oracle);
ScriptTools.exportContract(outputName, "RELAYER", relayer);
// ScriptTools.exportContract(outputName, "DAO", dao);
// ScriptTools.exportContract(outputName, "ORMP", ORMP_ADDR);
// ScriptTools.exportContract(outputName, "ORACLE", ORMP_ADDR);
// ScriptTools.exportContract(outputName, "RELAYER", RELAYER_ADDR);
}

/// @notice Deploy the protocol
Expand All @@ -92,50 +93,50 @@ contract Deploy is Common {
}

/// @notice Deploy the Oracle
function deployOralce(address ormp) public broadcast returns (address) {
function deployOralce() public broadcast returns (address) {
bytes memory byteCode = type(Oracle).creationCode;
bytes memory initCode = bytes.concat(byteCode, abi.encode(deployer, ormp));
bytes memory initCode = bytes.concat(byteCode, abi.encode(deployer, ORMP_ADDR));
address oracle = _deploy3(ORACLE_SALT, initCode);
require(oracle == ORACLE_ADDR, "!oracle");

require(III(oracle).owner() == deployer);
require(III(oracle).PROTOCOL() == ormp);
require(III(oracle).PROTOCOL() == ORMP_ADDR);
console.log("Oracle deployed at: %s", oracle);
return oracle;
}

/// @notice Deploy the Relayer
function deployRelayer(address ormp) public broadcast returns (address) {
function deployRelayer() public broadcast returns (address) {
bytes memory byteCode = type(Relayer).creationCode;
bytes memory initCode = bytes.concat(byteCode, abi.encode(deployer, ormp));
bytes memory initCode = bytes.concat(byteCode, abi.encode(deployer, ORMP_ADDR));
address relayer = _deploy3(RELAYER_SALT, initCode);
require(relayer == RELAYER_ADDR, "!relayer");

require(III(relayer).owner() == deployer);
require(III(relayer).PROTOCOL() == ormp);
require(III(relayer).PROTOCOL() == ORMP_ADDR);
console.log("Relayer deployed at: %s", relayer);
return relayer;
}

/// @notice Set the protocol config
function setConfig(address ormp, address oracle, address relayer) public broadcast {
ORMP(ormp).setDefaultConfig(oracle, relayer);
Config memory cfg = ORMP(ormp).getDefaultConfig();
require(cfg.oracle == oracle, "!oracle");
require(cfg.relayer == relayer, "!relayer");
function setConfig() public broadcast {
ORMP(ORMP_ADDR).setDefaultConfig(ORACLE_ADDR, RELAYER_ADDR);
Config memory cfg = ORMP(ORMP_ADDR).getDefaultConfig();
require(cfg.oracle == ORACLE_ADDR, "!oracle");
require(cfg.relayer == RELAYER_ADDR, "!relayer");

III(oracle).setApproved(oracleOperator, true);
require(III(oracle).isApproved(oracleOperator), "!o-operator");
III(relayer).setApproved(relayerOperator, true);
require(III(relayer).isApproved(relayerOperator), "!r-operator");
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(ormp).changeSetter{gas: 200000}(dao);
require(III(ormp).setter() == dao, "!dao");
III(ORMP_ADDR).changeSetter(dao);
require(III(ORMP_ADDR).setter() == dao, "!dao");

III(oracle).changeOwner(dao);
require(III(oracle).owner() == dao, "!dao");
III(ORACLE_ADDR).changeOwner(dao);
require(III(ORACLE_ADDR).owner() == dao, "!dao");

III(relayer).changeOwner(dao);
require(III(relayer).owner() == dao, "!dao");
III(RELAYER_ADDR).changeOwner(dao);
require(III(RELAYER_ADDR).owner() == dao, "!dao");
}
}
2 changes: 1 addition & 1 deletion script/input/421614/oracle.c.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"44": "0x00945C032A37454333d7044a52a5A42Aa0f6c608"
"44": "0x00d917EC19A6b8837ADFcF8adE3D6faF62e0F587"
}
2 changes: 1 addition & 1 deletion script/input/44/oracle.c.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"421614": "0x00945C032A37454333d7044a52a5A42Aa0f6c608"
"421614": "0x00d917EC19A6b8837ADFcF8adE3D6faF62e0F587"
}
8 changes: 4 additions & 4 deletions script/output/421614/deploy.a-latest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"DAO": "0x0f14341A7f464320319025540E8Fe48Ad0fe5aec",
"ORACLE": "0x0002396F1D52323fcd1ae8079b38808F046882c3",
"RELAYER": "0x007EED6207c9AF3715964Fb7f8B5f44E002a3498",
"ORMP": "0x0034607daf9c1dc6628f6e09E81bB232B6603A89"
}
"ORACLE": "0x00BD655DDfA7aFeF4BB109FE1F938724527B49D8",
"ORMP": "0x009D223Aad560e72282db9c0438Ef1ef2bf7703D",
"RELAYER": "0x0065a081a11cc1f6e1692c2A08E9AF36b17973eC"
}
8 changes: 4 additions & 4 deletions script/output/44/deploy.a-latest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"DAO": "0x0f14341A7f464320319025540E8Fe48Ad0fe5aec",
"ORACLE": "0x0002396F1D52323fcd1ae8079b38808F046882c3",
"RELAYER": "0x007EED6207c9AF3715964Fb7f8B5f44E002a3498",
"ORMP": "0x0034607daf9c1dc6628f6e09E81bB232B6603A89"
}
"ORACLE": "0x00BD655DDfA7aFeF4BB109FE1F938724527B49D8",
"ORMP": "0x009D223Aad560e72282db9c0438Ef1ef2bf7703D",
"RELAYER": "0x0065a081a11cc1f6e1692c2A08E9AF36b17973eC"
}
Loading