Skip to content

Commit

Permalink
Merge branch 'master' into add-optimism-deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
hexonaut committed Apr 11, 2024
2 parents 9b3255a + a634415 commit 6381731
Show file tree
Hide file tree
Showing 6 changed files with 103 additions and 12 deletions.
Binary file modified audits/ChainSecurity_MakerDAO_XChain_DSR_Oracle_audit.pdf
Binary file not shown.
28 changes: 28 additions & 0 deletions src/forwarders/DSROracleForwarderArbitrumOne.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity ^0.8.0;

import { XChainForwarders } from 'xchain-helpers/XChainForwarders.sol';

import { DSROracleForwarderBase } from './DSROracleForwarderBase.sol';

contract DSROracleForwarderArbitrumOne is DSROracleForwarderBase {

constructor(address _pot, address _l2Oracle) DSROracleForwarderBase(_pot, _l2Oracle) {
// Intentionally left blank
}

function refresh(
uint256 gasLimit,
uint256 maxFeePerGas,
uint256 baseFee
) public payable {
XChainForwarders.sendMessageArbitrumOne(
address(l2Oracle),
_packMessage(),
gasLimit,
maxFeePerGas,
baseFee
);
}

}
23 changes: 23 additions & 0 deletions src/receivers/DSROracleReceiverArbitrum.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity ^0.8.0;

import { ArbitrumReceiver } from 'xchain-helpers/ArbitrumReceiver.sol';

import { IDSRAuthOracle, IDSROracle } from '../interfaces/IDSRAuthOracle.sol';

contract DSROracleReceiverArbitrum is ArbitrumReceiver {

IDSRAuthOracle public oracle;

constructor(
address _l1Authority,
IDSRAuthOracle _oracle
) ArbitrumReceiver(_l1Authority) {
oracle = _oracle;
}

function setPotData(IDSROracle.PotData calldata data) external onlyCrossChainMessage {
oracle.setPotData(data);
}

}
38 changes: 38 additions & 0 deletions test/DSROracleIntegrationArbitrum.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity ^0.8.0;

import { ArbitrumDomain } from "xchain-helpers/testing/ArbitrumDomain.sol";

import { DSROracleForwarderArbitrumOne } from "src/forwarders/DSROracleForwarderArbitrumOne.sol";
import { DSROracleReceiverArbitrum } from "src/receivers/DSROracleReceiverArbitrum.sol";

import "./DSROracleXChainIntegrationBase.t.sol";

contract DSROracleIntegrationArbitrumTest is DSROracleXChainIntegrationBaseTest {

DSROracleForwarderArbitrumOne forwarder;
DSROracleReceiverArbitrum receiver;

function setupDomain() internal override {
remote = new ArbitrumDomain(getChain('arbitrum_one'), mainnet);

mainnet.selectFork();

address expectedReceiver = computeCreateAddress(address(this), 5);
forwarder = new DSROracleForwarderArbitrumOne(address(pot), expectedReceiver);

remote.selectFork();

oracle = new DSRAuthOracle();
receiver = new DSROracleReceiverArbitrum(address(forwarder), oracle);

oracle.grantRole(oracle.DATA_PROVIDER_ROLE(), address(receiver));

assertEq(address(receiver), expectedReceiver);
}

function doRefresh() internal override {
forwarder.refresh{value:1 ether}(500_000, 1 gwei, block.basefee + 10 gwei);
}

}
13 changes: 7 additions & 6 deletions test/DSROracleIntegrationGnosis.t.sol
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity ^0.8.0;

import "./DSROracleXChainIntegrationBase.t.sol";

import { GnosisDomain } from "xchain-helpers/testing/GnosisDomain.sol";

import { DSROracleForwarderGnosis } from "../src/forwarders/DSROracleForwarderGnosis.sol";
import { DSROracleReceiverGnosis } from "../src/receivers/DSROracleReceiverGnosis.sol";
import { DSROracleForwarderGnosis } from "src/forwarders/DSROracleForwarderGnosis.sol";
import { DSROracleReceiverGnosis } from "src/receivers/DSROracleReceiverGnosis.sol";

import "./DSROracleXChainIntegrationBase.t.sol";

contract DSROracleIntegrationGnosisTest is DSROracleXChainIntegrationBaseTest {

address constant AMB = 0x75Df5AF045d91108662D8080fD1FEFAd6aA0bb59;

DSROracleForwarderGnosis forwarder;
DSROracleReceiverGnosis receiver;
DSROracleReceiverGnosis receiver;

function setupDomain() internal override {
remote = new GnosisDomain(getChain('gnosis_chain'), mainnet);
Expand All @@ -24,8 +24,9 @@ contract DSROracleIntegrationGnosisTest is DSROracleXChainIntegrationBaseTest {

remote.selectFork();

oracle = new DSRAuthOracle();
oracle = new DSRAuthOracle();
receiver = new DSROracleReceiverGnosis(AMB, 1, address(forwarder), oracle);

oracle.grantRole(oracle.DATA_PROVIDER_ROLE(), address(receiver));
}

Expand Down
13 changes: 7 additions & 6 deletions test/DSROracleIntegrationOptimism.t.sol
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity ^0.8.0;

import "./DSROracleXChainIntegrationBase.t.sol";

import { OptimismDomain } from "xchain-helpers/testing/OptimismDomain.sol";

import { DSROracleForwarderOptimism } from "../src/forwarders/DSROracleForwarderOptimism.sol";
import { DSROracleReceiverOptimism } from "../src/receivers/DSROracleReceiverOptimism.sol";
import { DSROracleForwarderOptimism } from "src/forwarders/DSROracleForwarderOptimism.sol";
import { DSROracleReceiverOptimism } from "src/receivers/DSROracleReceiverOptimism.sol";

import "./DSROracleXChainIntegrationBase.t.sol";

contract DSROracleIntegrationOptimismTest is DSROracleXChainIntegrationBaseTest {

DSROracleForwarderOptimism forwarder;
DSROracleReceiverOptimism receiver;
DSROracleReceiverOptimism receiver;

function setupDomain() internal override {
remote = new OptimismDomain(getChain('optimism'), mainnet);
Expand All @@ -23,8 +23,9 @@ contract DSROracleIntegrationOptimismTest is DSROracleXChainIntegrationBaseTest

remote.selectFork();

oracle = new DSRAuthOracle();
oracle = new DSRAuthOracle();
receiver = new DSROracleReceiverOptimism(address(forwarder), oracle);

oracle.grantRole(oracle.DATA_PROVIDER_ROLE(), address(receiver));

assertEq(address(receiver), expectedReceiver);
Expand Down

0 comments on commit 6381731

Please sign in to comment.