Skip to content

Commit

Permalink
ORMPOracle deploy on mainnet (#116)
Browse files Browse the repository at this point in the history
* ORMPOracle deploy on mainnet

* upgrade on crab

* renam

* revert

* change fee

* fix ci

* fix ci
  • Loading branch information
hujw77 authored Feb 7, 2024
1 parent 4a98829 commit 1e946a7
Show file tree
Hide file tree
Showing 19 changed files with 70 additions and 74 deletions.
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,22 @@ Oracle and Relayer based Message Protocol.
| Contract | Canonical Cross-chain Deployment Address |
|------------|--------------------------------------------|
| ORMP | 0x00000000001523057a05d6293C1e5171eE33eE0A |
| Oracle | 0x00000000046bc530804d66B6b64f7aF69B4E4E81 |
| ORMPOracle | 0x0000000003ebeF32D8f0ED406a5CA8805c80AFba |
| Relayer | 0x0000000000808fE9bDCc1d180EfbF5C53552a6b1 |
| MsgDAO | 0x000000000879926D12aF396788C0785B7e581e53 |

## Supported Chains
### Mainnet
- Arbitrum
- Crab
- Darwinia
- Ethereum

### Testnet
- Arbitrum Sepolia
- Pangolin
- Sepolia

## Usage
To install with [**Foundry**](https://github.com/gakonst/foundry):
```sh
Expand Down
12 changes: 8 additions & 4 deletions bin/dao.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ set -x
# seth send -F $deployer $relayer "changeOwner(address)" $dao --chain arbitrum
# seth send -F $deployer $relayer "changeOwner(address)" $dao --chain ethereum

seth send -F $deployer $oracle "changeOwner(address)" $subapi_multisig --chain pangolin
# seth send -F $deployer $oracle "changeOwner(address)" $subapi_multisig --chain crab
seth send -F $deployer $oracle "changeOwner(address)" $subapi_multisig --chain sepolia
seth send -F $deployer $oracle "changeOwner(address)" $subapi_multisig --chain arbitrum-sepolia
# seth send -F $deployer $oracle "changeOwner(address)" $subapi_multisig --chain pangolin
# seth send -F $deployer $oracle "changeOwner(address)" $subapi_multisig --chain sepolia
# seth send -F $deployer $oracle "changeOwner(address)" $subapi_multisig --chain arbitrum-sepolia

seth send -F $deployer $oracle "changeOwner(address)" $subapi_multisig --chain crab
seth send -F $deployer $oracle "changeOwner(address)" $subapi_multisig --chain darwinia
seth send -F $deployer $oracle "changeOwner(address)" $subapi_multisig --chain ethereum
seth send -F $deployer $oracle "changeOwner(address)" $subapi_multisig --chain arbitrum
13 changes: 7 additions & 6 deletions bin/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

set -eo pipefail

# forge script script/deploy/Deploy.s.sol:Deploy --chain-id 1 --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 1 --broadcast --verify --slow
forge script script/deploy/Deploy.s.sol:Deploy --chain-id 44 --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 --skip-simulation

forge script script/deploy/Deploy.s.sol:Deploy --chain-id 43 --broadcast --verify --skip-simulation
forge script script/deploy/Deploy.s.sol:Deploy --chain-id 421614 --broadcast --verify --skip-simulation --slow
forge script script/deploy/Deploy.s.sol:Deploy --chain-id 11155111 --broadcast --verify --skip-simulation
# forge script script/deploy/Deploy.s.sol:Deploy --chain-id 43 --broadcast --verify --skip-simulation
# forge script script/deploy/Deploy.s.sol:Deploy --chain-id 421614 --broadcast --verify --skip-simulation --slow
# forge script script/deploy/Deploy.s.sol:Deploy --chain-id 11155111 --broadcast --verify --skip-simulation
33 changes: 14 additions & 19 deletions bin/fee.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,18 @@
set -eo pipefail

set -x
# forge script script/fee/Fee.s.sol:Fee --sig "run(uint256)" 42161 --chain-id 46 --broadcast --slow
# forge script script/fee/Fee.s.sol:Fee --sig "run(uint256)" 1 --chain-id 46 --broadcast --slow
# forge script script/fee/Fee.s.sol:Fee --sig "run(uint256)" 46 --chain-id 42161 --broadcast --slow --legacy --skip-simulation
# forge script script/fee/Fee.s.sol:Fee --sig "run(uint256)" 1 --chain-id 42161 --broadcast --slow --legacy --skip-simulation
# forge script script/fee/Fee.s.sol:Fee --sig "run(uint256)" 46 --chain-id 1 --broadcast --slow --legacy
# forge script script/fee/Fee.s.sol:Fee --sig "run(uint256)" 42161 --chain-id 1 --broadcast --slow --legacy
# forge script script/fee/Fee.s.sol:Fee --sig "run(uint256)" 46 --chain-id 44 --broadcast --slow --legacy
# forge script script/fee/Fee.s.sol:Fee --sig "run(uint256)" 44 --chain-id 46 --broadcast --slow --legacy
forge script script/fee/Fee.s.sol:Fee --sig "run(uint256)" 46 --chain-id 1 --broadcast --slow
forge script script/fee/Fee.s.sol:Fee --sig "run(uint256)" 42161 --chain-id 1 --broadcast --slow
forge script script/fee/Fee.s.sol:Fee --sig "run(uint256)" 42161 --chain-id 46 --broadcast --slow
forge script script/fee/Fee.s.sol:Fee --sig "run(uint256)" 1 --chain-id 46 --broadcast --slow
forge script script/fee/Fee.s.sol:Fee --sig "run(uint256)" 44 --chain-id 46 --broadcast --slow --legacy
forge script script/fee/Fee.s.sol:Fee --sig "run(uint256)" 46 --chain-id 42161 --broadcast --slow --legacy --skip-simulation
forge script script/fee/Fee.s.sol:Fee --sig "run(uint256)" 1 --chain-id 42161 --broadcast --slow --legacy --skip-simulation
forge script script/fee/Fee.s.sol:Fee --sig "run(uint256)" 46 --chain-id 44 --broadcast --slow --legacy

# forge script script/fee/Fee.s.sol:Fee --sig "run(uint256)" 11155111 --chain-id 44 --broadcast --slow
# forge script script/fee/Fee.s.sol:Fee --sig "run(uint256)" 421614 --chain-id 44 --broadcast --slow
# forge script script/fee/Fee.s.sol:Fee --sig "run(uint256)" 44 --chain-id 11155111 --broadcast --slow
# forge script script/fee/Fee.s.sol:Fee --sig "run(uint256)" 44 --chain-id 421614 --broadcast --skip-simulation --legacy --slow

forge script script/fee/Fee.s.sol:Fee --sig "run(uint256)" 11155111 --chain-id 43 --broadcast
forge script script/fee/Fee.s.sol:Fee --sig "run(uint256)" 421614 --chain-id 43 --broadcast
forge script script/fee/Fee.s.sol:Fee --sig "run(uint256)" 43 --chain-id 11155111 --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)" 43 --chain-id 421614 --broadcast --skip-simulation --legacy --slow
forge script script/fee/Fee.s.sol:Fee --sig "run(uint256)" 11155111 --chain-id 421614 --broadcast --skip-simulation --legacy --slow
# forge script script/fee/Fee.s.sol:Fee --sig "run(uint256)" 11155111 --chain-id 43 --broadcast
# forge script script/fee/Fee.s.sol:Fee --sig "run(uint256)" 421614 --chain-id 43 --broadcast
# forge script script/fee/Fee.s.sol:Fee --sig "run(uint256)" 43 --chain-id 11155111 --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)" 43 --chain-id 421614 --broadcast --skip-simulation --legacy --slow
# forge script script/fee/Fee.s.sol:Fee --sig "run(uint256)" 11155111 --chain-id 421614 --broadcast --skip-simulation --legacy --slow
6 changes: 3 additions & 3 deletions bin/upgrade.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ c3=$PWD/script/input/c3.json

deployer=$(jq -r ".DEPLOYER" $c3)
ormp=$(jq -r ".ORMP_ADDR" $c3)
oracle=$(jq -r ".ORACLEV2_ADDR" $c3)
oracle=$(jq -r ".ORMPORACLE_ADDR" $c3)
relayer=$(jq -r ".RELAYER_ADDR" $c3)

set -x

seth send -F $deployer $ormp "setDefaultConfig(address,address)" $oracle $relayer --chain crab
seth send -F $deployer $ormp "setDefaultConfig(address,address)" $oracle $relayer --chain sepolia
seth send -F $deployer $ormp "setDefaultConfig(address,address)" $oracle $relayer --chain arbitrum-sepolia
# seth send -F $deployer $ormp "setDefaultConfig(address,address)" $oracle $relayer --chain sepolia
# seth send -F $deployer $ormp "setDefaultConfig(address,address)" $oracle $relayer --chain arbitrum-sepolia
9 changes: 6 additions & 3 deletions bin/verify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,12 @@ verify() {
# verify $oracle 46 $(cast abi-encode "constructor(address,address)" $deployer $ormp) src/eco/OracleV2.sol:OracleV2
# verify $oracle 42161 $(cast abi-encode "constructor(address,address)" $deployer $ormp) src/eco/OracleV2.sol:OracleV2

# verify $oracle 44 $(cast abi-encode "constructor(address,address)" $deployer $ormp) src/eco/ORMPOracle.sol:ORMPOracle
verify $oracle 421614 $(cast abi-encode "constructor(address,address)" $deployer $ormp) src/eco/ORMPOracle.sol:ORMPOracle
verify $oracle 11155111 $(cast abi-encode "constructor(address,address)" $deployer $ormp) src/eco/ORMPOracle.sol:ORMPOracle
verify $oracle 1 $(cast abi-encode "constructor(address,address)" $deployer $ormp) src/eco/ORMPOracle.sol:ORMPOracle
verify $oracle 44 $(cast abi-encode "constructor(address,address)" $deployer $ormp) src/eco/ORMPOracle.sol:ORMPOracle
verify $oracle 46 $(cast abi-encode "constructor(address,address)" $deployer $ormp) src/eco/ORMPOracle.sol:ORMPOracle
verify $oracle 42161 $(cast abi-encode "constructor(address,address)" $deployer $ormp) src/eco/ORMPOracle.sol:ORMPOracle
# verify $oracle 421614 $(cast abi-encode "constructor(address,address)" $deployer $ormp) src/eco/ORMPOracle.sol:ORMPOracle
# verify $oracle 11155111 $(cast abi-encode "constructor(address,address)" $deployer $ormp) src/eco/ORMPOracle.sol:ORMPOracle

# 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
Expand Down
8 changes: 4 additions & 4 deletions script/deploy/Deploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,10 @@ contract Deploy is Common {

/// @notice Set the protocol config
function setConfig() public broadcast {
ORMP(ORMP_ADDR).setDefaultConfig(ORACLE_ADDR, RELAYER_ADDR);
(address o, address r) = ORMP(ORMP_ADDR).defaultUC();
require(o == ORACLE_ADDR, "!oracle");
require(r == RELAYER_ADDR, "!relayer");
// ORMP(ORMP_ADDR).setDefaultConfig(ORACLE_ADDR, RELAYER_ADDR);
// (address o, address r) = ORMP(ORMP_ADDR).defaultUC();
// require(o == ORACLE_ADDR, "!oracle");
// require(r == RELAYER_ADDR, "!relayer");

III(ORACLE_ADDR).setApproved(oracleOperator, true);
require(III(ORACLE_ADDR).isApproved(oracleOperator), "!o-operator");
Expand Down
2 changes: 1 addition & 1 deletion script/input/42161/fee.c.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"1": {
"dstPriceRatio": 10000000000,
"dstGasPriceInWei": 50000000000,
"baseGas": 100000,
"baseGas": 120000,
"gasPerByte": 16
}
}
Expand Down
18 changes: 0 additions & 18 deletions script/input/44/fee.c.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@
"ORACLE": {
"46": {
"fee": 10000000000000000000
},
"421614": {
"fee": 1000000000000000000
},
"11155111": {
"fee": 1000000000000000000
}
},
"RELAYER": {
Expand All @@ -16,18 +10,6 @@
"dstGasPriceInWei": 180000000000,
"baseGas": 200000,
"gasPerByte": 16
},
"421614": {
"dstPriceRatio": 9000000000000000,
"dstGasPriceInWei": 1000000,
"baseGas": 1,
"gasPerByte": 16
},
"11155111": {
"dstPriceRatio": 9000000000000000,
"dstGasPriceInWei": 1000000,
"baseGas": 100000,
"gasPerByte": 16
}
}
}
2 changes: 1 addition & 1 deletion script/input/46/fee.c.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"1": {
"dstPriceRatio": 9000000000000000,
"dstGasPriceInWei": 40000000000,
"baseGas": 100000,
"baseGas": 120000,
"gasPerByte": 16
},
"44": {
Expand Down
1 change: 1 addition & 0 deletions script/output/1/ORMPOracle.v.json

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion script/output/42161/deploy.a-latest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"DAO": "0x0f14341A7f464320319025540E8Fe48Ad0fe5aec",
"ORACLE": "0x0000000005Be70A35b6534bFBd21eC0c98B27b1f",
"ORACLE": "0x0000000003ebeF32D8f0ED406a5CA8805c80AFba",
"ORMP": "0x00000000001523057a05d6293C1e5171eE33eE0A",
"RELAYER": "0x0000000000808fE9bDCc1d180EfbF5C53552a6b1"
}
2 changes: 1 addition & 1 deletion script/output/44/ORMPOracle.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": "0x000000000DA67291724858F7e759A43B2d23225e",
"ORACLE": "0x0000000003ebeF32D8f0ED406a5CA8805c80AFba",
"ORMP": "0x00000000001523057a05d6293C1e5171eE33eE0A",
"RELAYER": "0x0000000000808fE9bDCc1d180EfbF5C53552a6b1"
}
1 change: 1 addition & 0 deletions script/output/46/ORMPOracle.v.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion script/output/46/deploy.a-latest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"DAO": "0x0f14341A7f464320319025540E8Fe48Ad0fe5aec",
"ORACLE": "0x0000000005Be70A35b6534bFBd21eC0c98B27b1f",
"ORACLE": "0x0000000003ebeF32D8f0ED406a5CA8805c80AFba",
"ORMP": "0x00000000001523057a05d6293C1e5171eE33eE0A",
"RELAYER": "0x0000000000808fE9bDCc1d180EfbF5C53552a6b1"
}
15 changes: 6 additions & 9 deletions test/bench/ORMP.b.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,16 @@ import "forge-std/Test.sol";
import {Chains} from "create3-deploy/script/Chains.sol";
import "../../src/Verifier.sol";
import "../../src/ORMP.sol";
import "../../src/eco/Oracle.sol";
import "../../src/eco/ORMPOracle.sol";
import "../../src/eco/Relayer.sol";

contract ORMPBenchmarkTest is Test {
using Chains for uint256;

ORMP ormp = ORMP(0x00000000001523057a05d6293C1e5171eE33eE0A);
Oracle oracle = Oracle(payable(0x00000000046bc530804d66B6b64f7aF69B4E4E81));
ORMPOracle oracle = ORMPOracle(payable(0x0000000003ebeF32D8f0ED406a5CA8805c80AFba));
Relayer relayer = Relayer(payable(0x0000000000808fE9bDCc1d180EfbF5C53552a6b1));

bytes32 root;
address immutable self = address(this);
uint256 chain1 = Chains.Darwinia;
uint256 chain2 = Chains.Arbitrum;
Expand Down Expand Up @@ -69,23 +68,21 @@ contract ORMPBenchmarkTest is Test {
}

function perform_recv(Message memory message) public {
root = ormp.root();
bytes32 root = ormp.root();
uint256 blockNumber = block.number;
Verifier.Proof memory proof =
Verifier.Proof({blockNumber: block.number, messageIndex: message.index, messageProof: ormp.prove()});

vm.createSelectFork(message.toChainId.toChainName());
// TODO: setDefaltOracle
vm.store(address(oracle), bytes32(uint256(0)), bytes32(uint256(uint160(self))));
assertEq(oracle.owner(), self);
vm.prank(address(oracle.owner()));
oracle.importMessageRoot(message.fromChainId, blockNumber, root);

vm.prank(address(relayer));
ormp.recv(message, abi.encode(proof));
}

function messageRootOf(uint256) external view returns (bytes32) {
return root;
}

function perform_send(uint256 fromChainId, uint256 toChainId, bytes calldata encoded) public {
vm.createSelectFork(fromChainId.toChainName());
uint256 f = ormp.fee(toChainId, self, 0, encoded, abi.encode(uint256(0)));
Expand Down

0 comments on commit 1e946a7

Please sign in to comment.