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

Chainlink relayer with l2 validity #3

Merged
merged 8 commits into from
Jul 6, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
3 changes: 0 additions & 3 deletions .vscode/settings.json

This file was deleted.

22 changes: 16 additions & 6 deletions gov-input/mainnet/new-DeployChainlinkRelayer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,27 @@
"proposalType": "DeployChainlinkRelayers",
"ODGovernor_Address": "",
"ChainlinkRelayerFactory_Address": "",
"ChainlinkSequencerFeed": "0xFdB631F5EE196F0ed6FAa767959853A9F217697D",
"objectArray": [
{
"symbol": "LINK/USD",
"chainlinkFeed": "0x86E53CF1B870786351Da77A57575e79CB55812CB",
"oracleInterval": "86400"
"chainlinkPriceFeed": "0x86E53CF1B870786351Da77A57575e79CB55812CB",
"staleThreshold": "86400",
"gracePeriod": "3600"
},
{
"symbol": "GRT/USD",
"chainlinkFeed": "0x0F38D86FceF4955B705F35c9e41d1A16e0637c73",
"oracleInterval": "86400"
"chainlinkPriceFeed": "0x0F38D86FceF4955B705F35c9e41d1A16e0637c73",
"staleThreshold": "86400",
"gracePeriod": "3600"
},
{
"symbol": "ETH/USD",
"chainlinkPriceFeed": "0x639Fe6ab55C921f74e7fac1ee960C0B6293ba612",
"staleThreshold": "86400",
"gracePeriod": "3600"
}
],
"arrayLength": "2"
}
"arrayLength": "3",
"PredictedRelayerAddresses": []
}
10 changes: 7 additions & 3 deletions gov-input/sepolia/new-DeployChainlinkRelayer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,25 @@
"proposalType": "DeployChainlinkRelayers",
"ODGovernor_Address": "",
"ChainlinkRelayerFactory_Address": "",
"ChainlinkSequencerFeed": "0xFdB631F5EE196F0ed6FAa767959853A9F217697D",
"objectArray": [
{
"symbol": "LINK/USD",
"chainlinkPriceFeed": "0x86E53CF1B870786351Da77A57575e79CB55812CB",
"oracleInterval": "86400"
"staleThreshold": "86400",
"gracePeriod": "3600"
},
{
"symbol": "GRT/USD",
"chainlinkPriceFeed": "0x0F38D86FceF4955B705F35c9e41d1A16e0637c73",
"oracleInterval": "86400"
"staleThreshold": "86400",
"gracePeriod": "3600"
},
{
"symbol": "ETH/USD",
"chainlinkPriceFeed": "0x639Fe6ab55C921f74e7fac1ee960C0B6293ba612",
"oracleInterval": "86400"
"staleThreshold": "86400",
"gracePeriod": "3600"
}
],
"arrayLength": "3",
Expand Down
61 changes: 61 additions & 0 deletions gov-output/sepolia/deploy-chainlink-relayer-61857469.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{
"ChainlinkRelayerFactory_Address": "0x555691C860015a5CE8748296fbbAa624410F55A4",
"ChainlinkSequencerFeed": "0xFdB631F5EE196F0ed6FAa767959853A9F217697D",
"ODGovernor_Address": "0x69ae232E574352232aB8678869eAA3BEBd885211",
"PredictedRelayerAddresses": [
{
"symbol": "LINK/USD",
"address": "0x3Dc02C28D29D6A4D13dE03E7c596a94c76f7600a"
},
{
"symbol": "GRT/USD",
"address": "0xf589519a17bDC25749AFAcbC6BAFdd05BF5d24Af"
},
{
"symbol": "ETH/USD",
"address": "0x33660aB6E38F6D8011Eca7AAa6F3CC7ef6380d91"
}
],
"arrayLength": "3",
"calldatas": [
"0x251ad9a500000000000000000000000086e53cf1b870786351da77a57575e79cb55812cb000000000000000000000000fdb631f5ee196f0ed6faa767959853a9f217697d00000000000000000000000000000000000000000000000000000000000151800000000000000000000000000000000000000000000000000000000000000e10",
"0x251ad9a50000000000000000000000000f38d86fcef4955b705f35c9e41d1a16e0637c73000000000000000000000000fdb631f5ee196f0ed6faa767959853a9f217697d00000000000000000000000000000000000000000000000000000000000151800000000000000000000000000000000000000000000000000000000000000e10",
"0x251ad9a5000000000000000000000000639fe6ab55c921f74e7fac1ee960c0b6293ba612000000000000000000000000fdb631f5ee196f0ed6faa767959853a9f217697d00000000000000000000000000000000000000000000000000000000000151800000000000000000000000000000000000000000000000000000000000000e10"
],
"chainid": 421614,
"description": "Deploy new chainlink relayers",
"descriptionHash": "0x03087660ad65289d7f9f35887f72e304a35460e94606f1c40d6d3884e0e36a4c",
"network": "sepolia",
"objectArray": [
{
"symbol": "LINK/USD",
"chainlinkPriceFeed": "0x86E53CF1B870786351Da77A57575e79CB55812CB",
"staleThreshold": "86400",
"gracePeriod": "3600"
},
{
"symbol": "GRT/USD",
"chainlinkPriceFeed": "0x0F38D86FceF4955B705F35c9e41d1A16e0637c73",
"staleThreshold": "86400",
"gracePeriod": "3600"
},
{
"symbol": "ETH/USD",
"chainlinkPriceFeed": "0x639Fe6ab55C921f74e7fac1ee960C0B6293ba612",
"staleThreshold": "86400",
"gracePeriod": "3600"
}
],
"proposalId": 61857469553398489852308972851954168900597935201047788453491803085690968636070,
"proposalType": "DeployChainlinkRelayers",
"targets": [
"0x555691C860015a5CE8748296fbbAa624410F55A4",
"0x555691C860015a5CE8748296fbbAa624410F55A4",
"0x555691C860015a5CE8748296fbbAa624410F55A4"
],
"values": [
0,
0,
0
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ pragma solidity 0.8.20;

import {JSONScript} from '../helpers/JSONScript.s.sol';
import {ODGovernor} from '@opendollar/contracts/gov/ODGovernor.sol';
import {IERC20} from '@openzeppelin/token/ERC20/IERC20.sol';
import {Generator} from '../Generator.s.sol';
import {Strings} from '@openzeppelin/utils/Strings.sol';
import {IChainlinkRelayerFactory} from '@opendollar/interfaces/factories/IChainlinkRelayerFactory.sol';
import {IChainlinkRelayerFactory} from '../interfaces/IChainlinkRelayerFactory.sol';
import 'forge-std/StdJson.sol';

/// @title GenerateDeployChainlinkRelayersProposal Script
Expand All @@ -19,29 +18,34 @@ contract GenerateDeployChainlinkRelayersProposal is Generator, JSONScript {
string public description;
address public governanceAddress;
address public chainlinkRelayerFactory;
address public chainlinkSequencerFeed;
address[] public chainlinkFeed;
uint256[] public oracleInterval;
uint256[] public staleThreshold;
uint256[] public gracePeriod;

function _loadBaseData(string memory json) internal override {
governanceAddress = json.readAddress(string(abi.encodePacked('.ODGovernor_Address:')));
description = json.readString(string(abi.encodePacked('.description')));
chainlinkRelayerFactory = json.readAddress(string(abi.encodePacked('.ChainlinkRelayerFactory_Address')));
chainlinkSequencerFeed = json.readAddress(string(abi.encodePacked('.ChainlinkSequencerFeed')));
uint256 len = json.readUint(string(abi.encodePacked('.arrayLength')));

for (uint256 i; i < len; i++) {
string memory index = Strings.toString(i);
address feed = json.readAddress(string(abi.encodePacked('.objectArray[', index, '].chainlinkPriceFeed')));
uint256 interval = json.readUint(string(abi.encodePacked('.objectArray[', index, '].oracleInterval')));
uint256 interval = json.readUint(string(abi.encodePacked('.objectArray[', index, '].staleThreshold')));
uint256 grace = json.readUint(string(abi.encodePacked('.objectArray[', index, '].gracePeriod')));
Comment on lines +36 to +37
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider keeping variables names the same throughout

chainlinkFeed.push(feed);
oracleInterval.push(interval);
staleThreshold.push(interval);
gracePeriod.push(grace);
}
}

function _generateProposal() internal override {
ODGovernor gov = ODGovernor(payable(governanceAddress));

uint256 len = chainlinkFeed.length;
require(len == oracleInterval.length, 'CHAINLINK RELAYER: mismatched array lengths');
require(len == staleThreshold.length, 'CHAINLINK RELAYER: mismatched array lengths');

address[] memory targets = new address[](len);
uint256[] memory values = new uint256[](len);
Expand All @@ -50,7 +54,11 @@ contract GenerateDeployChainlinkRelayersProposal is Generator, JSONScript {
for (uint256 i = 0; i < len; i++) {
// encode relayer factory function data
calldatas[i] = abi.encodeWithSelector(
IChainlinkRelayerFactory.deployChainlinkRelayer.selector, chainlinkFeed[i], oracleInterval[i]
IChainlinkRelayerFactory.deployChainlinkRelayerWithL2Validity.selector,
chainlinkFeed[i],
chainlinkSequencerFeed,
staleThreshold[i],
gracePeriod[i]
);
targets[i] = chainlinkRelayerFactory;
values[i] = 0; // value is always 0
Expand Down
18 changes: 18 additions & 0 deletions src/contracts/interfaces/IChainlinkRelayerFactory.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.20;

import {IBaseOracle} from '@opendollar/interfaces/oracles/IBaseOracle.sol';

interface IChainlinkRelayerFactory {
// --- Events ---
event NewChainlinkRelayer(address indexed _chainlinkRelayer, address _aggregator, uint256 _staleThreshold);

function deployChainlinkRelayer(address _aggregator, uint256 _staleThreshold) external returns (IBaseOracle _relayer);

function deployChainlinkRelayerWithL2Validity(
address _priceAggregator,
address _sequencerAggregator,
uint256 _staleThreshold,
uint256 _gracePeriod
) external returns (IBaseOracle _chainlinkRelayer);
}
Loading