Skip to content

Commit

Permalink
upgrade to oracle v2 on crab and sepolia
Browse files Browse the repository at this point in the history
  • Loading branch information
hujw77 committed Jan 5, 2024
1 parent 1866d51 commit 6666be1
Show file tree
Hide file tree
Showing 14 changed files with 34 additions and 40 deletions.
10 changes: 8 additions & 2 deletions bin/dao.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
7 changes: 3 additions & 4 deletions bin/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

2 changes: 1 addition & 1 deletion bin/fee.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 3 additions & 2 deletions bin/verify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
24 changes: 9 additions & 15 deletions script/deploy/Deploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -35,15 +35,13 @@ contract Deploy is Common {
bytes32 ORACLE_SALT;
address RELAYER_ADDR;
bytes32 RELAYER_SALT;
address SUBAPI_ADDR;

string c3;
string config;
string instanceId;
string outputName;
address deployer;
address dao;
address oracleOperator;
address relayerOperator;

/// @notice The name of the script, used to ensure the right deploy artifacts
Expand All @@ -62,25 +60,23 @@ 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");
}

/// @notice Deploy all of the contracts
function run() public {
require(deployer == msg.sender, "!deployer");

deployProtocol();
// deployProtocol();
deployOralce();
deployRelayer();
// deployRelayer();

setConfig();

Expand All @@ -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");

Expand Down Expand Up @@ -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");
Expand Down
6 changes: 1 addition & 5 deletions script/fee/Fee.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,14 @@ 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 {
string memory key = string.concat(".ORACLE", ".", vm.toString(chainId), ".fee");
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);
}
Expand Down
1 change: 0 additions & 1 deletion script/input/1/deploy.c.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"DAO": "0x0f14341A7f464320319025540E8Fe48Ad0fe5aec",
"DEPLOYER": "0x0f14341A7f464320319025540E8Fe48Ad0fe5aec",
"ORACLE_OPERATOR": "0x912D7601569cBc2DF8A7f0aaE50BFd18e8C64d05",
"RELAYER_OPERATOR": "0x912D7601569cBc2DF8A7f0aaE50BFd18e8C64d05"
}
1 change: 0 additions & 1 deletion script/input/11155111/deploy.c.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"DAO": "0x0f14341A7f464320319025540E8Fe48Ad0fe5aec",
"DEPLOYER": "0x0f14341A7f464320319025540E8Fe48Ad0fe5aec",
"ORACLE_OPERATOR": "0x0b001c95E86D64C1Ad6e43944C568A6C31b53887",
"RELAYER_OPERATOR": "0x0b001c95E86D64C1Ad6e43944C568A6C31b53887"
}
1 change: 0 additions & 1 deletion script/input/44/deploy.c.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"DAO": "0x0f14341A7f464320319025540E8Fe48Ad0fe5aec",
"DEPLOYER": "0x0f14341A7f464320319025540E8Fe48Ad0fe5aec",
"ORACLE_OPERATOR": "0x0b001c95E86D64C1Ad6e43944C568A6C31b53887",
"RELAYER_OPERATOR": "0x0b001c95E86D64C1Ad6e43944C568A6C31b53887"
}
4 changes: 2 additions & 2 deletions script/input/44/fee.c.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
"fee": 75000000000000000000
},
"421614": {
"fee": 5000000000000000000
"fee": 1000000000000000000
},
"11155111": {
"fee": 5000000000000000000
"fee": 1000000000000000000
}
},
"RELAYER": {
Expand Down
8 changes: 4 additions & 4 deletions script/input/c3.json
Original file line number Diff line number Diff line change
@@ -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"
}
2 changes: 1 addition & 1 deletion script/output/11155111/deploy.a-latest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"DAO": "0x0f14341A7f464320319025540E8Fe48Ad0fe5aec",
"ORACLE": "0x00000000046bc530804d66B6b64f7aF69B4E4E81",
"ORACLE": "0x00000000023D0348fD049690E97b2E76DB051Cc9",
"ORMP": "0x00000000001523057a05d6293C1e5171eE33eE0A",
"RELAYER": "0x0000000000808fE9bDCc1d180EfbF5C53552a6b1"
}
1 change: 1 addition & 0 deletions script/output/44/OracleV2.v.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion script/output/44/deploy.a-latest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"DAO": "0x0f14341A7f464320319025540E8Fe48Ad0fe5aec",
"ORACLE": "0x00000000046bc530804d66B6b64f7aF69B4E4E81",
"ORACLE": "0x00000000023D0348fD049690E97b2E76DB051Cc9",
"ORMP": "0x00000000001523057a05d6293C1e5171eE33eE0A",
"RELAYER": "0x0000000000808fE9bDCc1d180EfbF5C53552a6b1"
}

0 comments on commit 6666be1

Please sign in to comment.