-
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
LinkBalMonV2(minPerform) and CCIPWatchlist AutoUpdate Contract #13605
Conversation
Adding 2 files. 1. I added a minPerform() function to the LinkBalMonV2 contract and tested it on Sepolia. The purpose of the minPerform function is to establish a minimum batch size required for the sampleUnderfunded address array. If the array size is less than minPerform, no top-up operation will be performed. This optimization is crucial for deploying the BalanceMonitor contract on Ethereum, which consumes significant gas. 2. Creation of a CCIPOnRampWatchlistUpdate contract to allow auto update of the watchlist on the LinkBalMonV2 when deployed to fund CCIP On-Ramps Testing File Link - https://docs.google.com/spreadsheets/d/1zk4J4xQrhSJhIEt7l1bpsG6_jrl6qTQLNa5EZia3JzU/edit?gid=829494086#gid=829494086 Specification File - https://docs.google.com/document/d/1p4naJOlrdPmZ5xsZkZE7FDw1cEQqWcQ3hgguhI21SNQ/edit#heading=h.3t9vh460y192
I see you updated files related to |
import {LinkAvailableBalanceMonitor} from "../upkeeps/LinkAvailableBalanceMonitor.sol"; | ||
|
||
|
||
struct Log { |
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.
can you import this and ILogAutomation from the existing ILogAutomation.sol
interface?
@@ -333,7 +337,8 @@ contract LinkAvailableBalanceMonitor is AccessControl, AutomationCompatibleInter | |||
bytes calldata | |||
) external view override whenNotPaused returns (bool upkeepNeeded, bytes memory performData) { | |||
address[] memory needsFunding = sampleUnderfundedAddresses(); | |||
if (needsFunding.length == 0) { | |||
uint16 minPerform = s_minPerform; | |||
if (needsFunding.length <= minPerform) { |
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.
nit: it's probably more idiomatic to do <
@@ -333,7 +337,8 @@ contract LinkAvailableBalanceMonitor is AccessControl, AutomationCompatibleInter | |||
bytes calldata | |||
) external view override whenNotPaused returns (bool upkeepNeeded, bytes memory performData) { | |||
address[] memory needsFunding = sampleUnderfundedAddresses(); | |||
if (needsFunding.length == 0) { | |||
uint16 minPerform = s_minPerform; |
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.
no need to create a new variable unless it will be read again in this function
require(routerAddress != address(0), "Router address not set"); | ||
|
||
// Define the event signature for OnRampSet(uint64,address) | ||
bytes32 eventSignature = keccak256(abi.encodePacked("OnRampSet(uint64,address)")); |
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.
since this event sig is known in advance, u can encode it and set it as a constant
function checkLog( | ||
Log calldata log, | ||
bytes memory checkData | ||
) external view override returns (bool upkeepNeeded, bytes memory performData) { |
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.
you can try to run
pnpm prettier:write
to format all the code
|
||
event setWatchlistOnMonitor(uint64 indexed _dstChainSelector,address indexed _onRamp); | ||
|
||
LinkAvailableBalanceMonitor public LinkAvailableBalanceMonitorAddress; |
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.
nit: variable starts with lowercase and it should be called linkAvailableBalanceMonitor
or monitor
bc it's not an address anymore
@@ -389,6 +394,12 @@ contract LinkAvailableBalanceMonitor is AccessControl, AutomationCompatibleInter | |||
s_maxPerform = maxPerform; | |||
} | |||
|
|||
/// @notice Update s_minPerform | |||
function setMinPerform(uint16 minPerform) public onlyRole(ADMIN_ROLE) { | |||
emit MinPerformSet(s_minPerform, minPerform); |
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.
nit: emit after the variable is set
if (log.source == routerAddress && log.topics.length > 0 && log.topics[0] == eventSignature) { | ||
// Extract the indexed parameter from the log | ||
uint64 destChainSelector = uint64(uint256(log.topics[1])); // cast to uint64 | ||
address onRamp = address(uint160(uint256(bytes32(log.data)))); // extract from log.data |
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.
depending on the possible values of destChainSelector
and onRamp
, maybe add some sanity checks for these values?
@@ -389,6 +394,12 @@ contract LinkAvailableBalanceMonitor is AccessControl, AutomationCompatibleInter | |||
s_maxPerform = maxPerform; | |||
} | |||
|
|||
/// @notice Update s_minPerform | |||
function setMinPerform(uint16 minPerform) public onlyRole(ADMIN_ROLE) { |
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.
this can be external
Made changed as per Felix's comments
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.
Made changes to CCIPAutoWatchlist contract and LinkAvailableBalanceMonitor contract
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.
Made changes to LinkBalanceMonitorContract as suggested
@@ -6,89 +6,67 @@ import "../../shared/access/ConfirmedOwner.sol"; | |||
import {AutomationCompatibleInterface} from "../interfaces/AutomationCompatibleInterface.sol"; | |||
import {AccessControl} from "../../vendor/openzeppelin-solidity/v4.8.3/contracts/access/AccessControl.sol"; | |||
import {LinkAvailableBalanceMonitor} from "../upkeeps/LinkAvailableBalanceMonitor.sol"; | |||
import "../interfaces/ILogAutomation.sol"; |
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.
let's import specific struct / interface
Address comments to the updateWatchlist function of the code Imported specific parts of ILogAutomation
Quality Gate passedIssues Measures |
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.
Sorry, but I can't sign off on these without unit tests! From your testing file it looks like you have a good understanding of what needs coverage, but those test cases need to manifest in code :)
Going to close this for now as it seems to have gotten stale. Please re-open when ready. |
Adding 2 files.
I added a minPerform() function to the LinkBalMonV2 contract and tested it on Sepolia. The purpose of the minPerform function is to establish a minimum batch size required for the sampleUnderfunded address array. If the array size is less than minPerform, no top-up operation will be performed. This optimization is crucial for deploying the BalanceMonitor contract on Ethereum, which consumes significant gas.
Creation of a CCIPOnRampWatchlistUpdate contract to allow auto update of the watchlist on the LinkBalMonV2 when deployed to fund CCIP On-Ramps
Testing File Link - https://docs.google.com/spreadsheets/d/1zk4J4xQrhSJhIEt7l1bpsG6_jrl6qTQLNa5EZia3JzU/edit?gid=829494086#gid=829494086 Specification File - https://docs.google.com/document/d/1p4naJOlrdPmZ5xsZkZE7FDw1cEQqWcQ3hgguhI21SNQ/edit#heading=h.3t9vh460y192
Ticket
Requires Dependencies
Resolves Dependencies