-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Keystone: add router and other refactors #13426
Changes from all commits
a99dc5f
bb12d5f
b92b116
98d50f1
993075f
703bd0f
0dd9de0
1597c47
4ecff4c
9429f75
2c1557f
04a24c2
4fb78db
cb4e203
524d92e
f88b268
554a211
c065972
534fb23
8788619
741aaac
ee20856
f721969
6302a2c
562947d
87c1499
a4bb4fe
34af340
cedb25c
d3c9c39
9442537
4840536
7ea86d0
8bd2537
e03a7b8
385a346
13731d1
357bd54
b4f9481
75196ea
fcffda8
86bd0a3
fc64eb4
9172e6f
4de76c3
c1ffbfc
f1f81c0
434ab51
b36fe56
0857c79
2df7de5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"chainlink": patch | ||
--- | ||
|
||
#internal |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@chainlink/contracts': patch | ||
--- | ||
|
||
#internal |
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,17 +2,15 @@ | |
pragma solidity ^0.8.19; | ||
|
||
import {IReceiver} from "./interfaces/IReceiver.sol"; | ||
import {ConfirmedOwner} from "../shared/access/ConfirmedOwner.sol"; | ||
import {OwnerIsCreator} from "../shared/access/OwnerIsCreator.sol"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should drop this contract or merge it with the mock one we have for tests. I'll skip the review of the rest of the parts (the checks aren't reflective of what would happen in practice as they don't optimize storage reads). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not just an example contract and will be used by CCIP, maybe we can drop the mock instead There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @archseer it actually won't be used as-is by CCIP in prod, I was wrong about that. |
||
|
||
contract KeystoneFeedsConsumer is IReceiver, ConfirmedOwner { | ||
contract KeystoneFeedsConsumer is IReceiver, OwnerIsCreator { | ||
event FeedReceived(bytes32 indexed feedId, int192 price, uint32 timestamp); | ||
|
||
error UnauthorizedSender(address sender); | ||
error UnauthorizedWorkflowOwner(address workflowOwner); | ||
error UnauthorizedWorkflowName(bytes10 workflowName); | ||
|
||
constructor() ConfirmedOwner(msg.sender) {} | ||
|
||
struct ReceivedFeedReport { | ||
bytes32 FeedId; | ||
int192 Price; | ||
|
@@ -26,55 +24,55 @@ contract KeystoneFeedsConsumer is IReceiver, ConfirmedOwner { | |
|
||
mapping(bytes32 feedId => StoredFeedReport feedReport) internal s_feedReports; | ||
address[] internal s_allowedSendersList; | ||
mapping(address => bool) internal s_allowedSenders; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perfect place for enumerableSet |
||
mapping(address sender => bool) internal s_allowedSenders; | ||
address[] internal s_allowedWorkflowOwnersList; | ||
mapping(address => bool) internal s_allowedWorkflowOwners; | ||
mapping(address owner => bool) internal s_allowedWorkflowOwners; | ||
bytes10[] internal s_allowedWorkflowNamesList; | ||
mapping(bytes10 => bool) internal s_allowedWorkflowNames; | ||
mapping(bytes10 workflowName => bool) internal s_allowedWorkflowNames; | ||
|
||
function setConfig( | ||
address[] calldata _allowedSendersList, | ||
address[] calldata _allowedWorkflowOwnersList, | ||
bytes10[] calldata _allowedWorkflowNamesList | ||
) external onlyOwner { | ||
for (uint32 i = 0; i < s_allowedSendersList.length; i++) { | ||
for (uint32 i = 0; i < s_allowedSendersList.length; ++i) { | ||
s_allowedSenders[s_allowedSendersList[i]] = false; | ||
} | ||
for (uint32 i = 0; i < _allowedSendersList.length; i++) { | ||
for (uint32 i = 0; i < _allowedSendersList.length; ++i) { | ||
s_allowedSenders[_allowedSendersList[i]] = true; | ||
} | ||
s_allowedSendersList = _allowedSendersList; | ||
for (uint32 i = 0; i < s_allowedWorkflowOwnersList.length; i++) { | ||
for (uint32 i = 0; i < s_allowedWorkflowOwnersList.length; ++i) { | ||
s_allowedWorkflowOwners[s_allowedWorkflowOwnersList[i]] = false; | ||
} | ||
for (uint32 i = 0; i < _allowedWorkflowOwnersList.length; i++) { | ||
for (uint32 i = 0; i < _allowedWorkflowOwnersList.length; ++i) { | ||
s_allowedWorkflowOwners[_allowedWorkflowOwnersList[i]] = true; | ||
} | ||
s_allowedWorkflowOwnersList = _allowedWorkflowOwnersList; | ||
for (uint32 i = 0; i < s_allowedWorkflowNamesList.length; i++) { | ||
for (uint32 i = 0; i < s_allowedWorkflowNamesList.length; ++i) { | ||
s_allowedWorkflowNames[s_allowedWorkflowNamesList[i]] = false; | ||
} | ||
for (uint32 i = 0; i < _allowedWorkflowNamesList.length; i++) { | ||
for (uint32 i = 0; i < _allowedWorkflowNamesList.length; ++i) { | ||
s_allowedWorkflowNames[_allowedWorkflowNamesList[i]] = true; | ||
} | ||
s_allowedWorkflowNamesList = _allowedWorkflowNamesList; | ||
} | ||
|
||
function onReport(bytes calldata metadata, bytes calldata rawReport) external { | ||
if (s_allowedSenders[msg.sender] == false) { | ||
if (!s_allowedSenders[msg.sender]) { | ||
revert UnauthorizedSender(msg.sender); | ||
} | ||
|
||
(bytes10 workflowName, address workflowOwner) = _getInfo(metadata); | ||
if (s_allowedWorkflowNames[workflowName] == false) { | ||
if (!s_allowedWorkflowNames[workflowName]) { | ||
revert UnauthorizedWorkflowName(workflowName); | ||
} | ||
if (s_allowedWorkflowOwners[workflowOwner] == false) { | ||
if (!s_allowedWorkflowOwners[workflowOwner]) { | ||
revert UnauthorizedWorkflowOwner(workflowOwner); | ||
} | ||
|
||
ReceivedFeedReport[] memory feeds = abi.decode(rawReport, (ReceivedFeedReport[])); | ||
for (uint32 i = 0; i < feeds.length; i++) { | ||
for (uint256 i = 0; i < feeds.length; ++i) { | ||
s_feedReports[feeds[i].FeedId] = StoredFeedReport(feeds[i].Price, feeds[i].Timestamp); | ||
emit FeedReceived(feeds[i].FeedId, feeds[i].Price, feeds[i].Timestamp); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@archseer You only need one of these changesets I think :)