-
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
add reorgProtectionEnabled feature flag in registry 2.2 #11862
Changes from 8 commits
5de68e5
33b2b98
838637c
048da4b
6a2f90f
0ee7d75
33656d4
52849d1
35aaba5
0872942
e8f88a4
3072cb8
652acfc
9176888
3b00b43
64e3ab1
700ee3e
9514873
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -69,6 +69,7 @@ abstract contract AutomationRegistryBase2_2 is ConfirmedOwner, ExecutionPreventi | |
AggregatorV3Interface internal immutable i_fastGasFeed; | ||
Mode internal immutable i_mode; | ||
address internal immutable i_automationForwarderLogic; | ||
bool internal skipReorgProtection; | ||
FelixFan1992 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
/** | ||
* @dev - The storage is gas optimised for one and only one function - transmit. All the storage accessed in transmit | ||
|
@@ -208,6 +209,7 @@ abstract contract AutomationRegistryBase2_2 is ConfirmedOwner, ExecutionPreventi | |
* @member transcoder address of the transcoder contract | ||
* @member registrars addresses of the registrar contracts | ||
* @member upkeepPrivilegeManager address which can set privilege for upkeeps | ||
* @member skipReorgProtection if this registry will skip re-org protection checks | ||
*/ | ||
struct OnchainConfig { | ||
uint32 paymentPremiumPPB; | ||
|
@@ -225,6 +227,7 @@ abstract contract AutomationRegistryBase2_2 is ConfirmedOwner, ExecutionPreventi | |
address transcoder; | ||
address[] registrars; | ||
address upkeepPrivilegeManager; | ||
bool skipReorgProtection; | ||
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. can we struct pack this a little better? Ex there is a free slot after 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. done. restructure this using Spack |
||
} | ||
|
||
/** | ||
|
@@ -740,7 +743,7 @@ abstract contract AutomationRegistryBase2_2 is ConfirmedOwner, ExecutionPreventi | |
if (!_validateConditionalTrigger(upkeepId, rawTrigger, transmitInfo)) return (false, dedupID); | ||
} else if (transmitInfo.triggerType == Trigger.LOG) { | ||
bool valid; | ||
(valid, dedupID) = _validateLogTrigger(upkeepId, rawTrigger, transmitInfo); | ||
(valid, dedupID) = _validateLogTrigger(upkeepId, rawTrigger); | ||
if (!valid) return (false, dedupID); | ||
} else { | ||
revert InvalidTriggerType(); | ||
|
@@ -774,7 +777,8 @@ abstract contract AutomationRegistryBase2_2 is ConfirmedOwner, ExecutionPreventi | |
return false; | ||
} | ||
if ( | ||
(trigger.blockHash != bytes32("") && _blockHash(trigger.blockNum) != trigger.blockHash) || | ||
(!skipReorgProtection && | ||
(trigger.blockHash != bytes32("") && _blockHash(trigger.blockNum) != trigger.blockHash)) || | ||
FelixFan1992 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
trigger.blockNum >= _blockNum() | ||
) { | ||
// There are two cases of reorged report | ||
|
@@ -789,15 +793,12 @@ abstract contract AutomationRegistryBase2_2 is ConfirmedOwner, ExecutionPreventi | |
return true; | ||
} | ||
|
||
function _validateLogTrigger( | ||
uint256 upkeepId, | ||
bytes memory rawTrigger, | ||
UpkeepTransmitInfo memory transmitInfo | ||
FelixFan1992 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
) internal returns (bool, bytes32) { | ||
function _validateLogTrigger(uint256 upkeepId, bytes memory rawTrigger) internal returns (bool, bytes32) { | ||
LogTrigger memory trigger = abi.decode(rawTrigger, (LogTrigger)); | ||
bytes32 dedupID = keccak256(abi.encodePacked(upkeepId, trigger.logBlockHash, trigger.txHash, trigger.logIndex)); | ||
if ( | ||
(trigger.blockHash != bytes32("") && _blockHash(trigger.blockNum) != trigger.blockHash) || | ||
(!skipReorgProtection && | ||
(trigger.blockHash != bytes32("") && _blockHash(trigger.blockNum) != trigger.blockHash)) || | ||
FelixFan1992 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
trigger.blockNum >= _blockNum() | ||
) { | ||
// Reorg protection is same as conditional trigger upkeeps | ||
|
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.
n00b: why prefix s_? with prefix s_, s_fallbackLinkPrice is a state variable (persistent storage onchain)? skipReorgProtection is just a local variable which will not be recorded onchain?
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.
s_ means this is a storage variable
i_ means this is a immutable variable