-
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 11 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 |
---|---|---|
|
@@ -208,6 +208,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 +226,7 @@ abstract contract AutomationRegistryBase2_2 is ConfirmedOwner, ExecutionPreventi | |
address transcoder; | ||
address[] registrars; | ||
address upkeepPrivilegeManager; | ||
bool skipReorgProtection; | ||
} | ||
|
||
/** | ||
|
@@ -307,16 +309,16 @@ abstract contract AutomationRegistryBase2_2 is ConfirmedOwner, ExecutionPreventi | |
|
||
/// @dev Config + State storage struct which is on hot transmit path | ||
struct HotVars { | ||
uint8 f; // maximum number of faulty oracles | ||
uint32 paymentPremiumPPB; // premium percentage charged to user over tx cost | ||
uint32 flatFeeMicroLink; // flat fee charged to user for every perform | ||
uint24 stalenessSeconds; // Staleness tolerance for feeds | ||
uint16 gasCeilingMultiplier; // multiplier on top of fast gas feed for upper bound | ||
bool paused; // pause switch for all upkeeps in the registry | ||
bool reentrancyGuard; // guard against reentrancy | ||
uint96 totalPremium; // total historical payment to oracles for premium | ||
uint32 latestEpoch; // latest epoch for which a report was transmitted | ||
// 1 EVM word full | ||
uint96 totalPremium; // ─────────╮ total historical payment to oracles for premium | ||
uint32 paymentPremiumPPB; // │ premium percentage charged to user over tx cost | ||
uint32 flatFeeMicroLink; // │ flat fee charged to user for every perform | ||
uint32 latestEpoch; // │ latest epoch for which a report was transmitted | ||
uint24 stalenessSeconds; // │ Staleness tolerance for feeds | ||
uint16 gasCeilingMultiplier; // │ multiplier on top of fast gas feed for upper bound | ||
uint8 f; // │ maximum number of faulty oracles | ||
bool paused; // │ pause switch for all upkeeps in the registry | ||
bool reentrancyGuard; // ────────╯ guard against reentrancy | ||
bool skipReorgProtection; // if this registry should skip re-org protection mechanism | ||
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. idea for the future - we can totally combine these booleans into a single uint8 using a bitmap, then the struct would be 1 word again :) 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. I created a ticket and assigned to myself: https://smartcontract-it.atlassian.net/browse/AUTO-8859 |
||
} | ||
|
||
/// @dev Config + State storage struct which is not on hot transmit path | ||
|
@@ -733,14 +735,15 @@ abstract contract AutomationRegistryBase2_2 is ConfirmedOwner, ExecutionPreventi | |
function _prePerformChecks( | ||
uint256 upkeepId, | ||
bytes memory rawTrigger, | ||
UpkeepTransmitInfo memory transmitInfo | ||
UpkeepTransmitInfo memory transmitInfo, | ||
HotVars memory hotVars | ||
) internal returns (bool, bytes32) { | ||
bytes32 dedupID; | ||
if (transmitInfo.triggerType == Trigger.CONDITION) { | ||
if (!_validateConditionalTrigger(upkeepId, rawTrigger, transmitInfo)) return (false, dedupID); | ||
if (!_validateConditionalTrigger(upkeepId, rawTrigger, transmitInfo, hotVars)) return (false, dedupID); | ||
} else if (transmitInfo.triggerType == Trigger.LOG) { | ||
bool valid; | ||
(valid, dedupID) = _validateLogTrigger(upkeepId, rawTrigger, transmitInfo); | ||
(valid, dedupID) = _validateLogTrigger(upkeepId, rawTrigger, hotVars); | ||
if (!valid) return (false, dedupID); | ||
} else { | ||
revert InvalidTriggerType(); | ||
|
@@ -765,7 +768,8 @@ abstract contract AutomationRegistryBase2_2 is ConfirmedOwner, ExecutionPreventi | |
function _validateConditionalTrigger( | ||
uint256 upkeepId, | ||
bytes memory rawTrigger, | ||
UpkeepTransmitInfo memory transmitInfo | ||
UpkeepTransmitInfo memory transmitInfo, | ||
HotVars memory hotVars | ||
) internal returns (bool) { | ||
ConditionalTrigger memory trigger = abi.decode(rawTrigger, (ConditionalTrigger)); | ||
if (trigger.blockNum < transmitInfo.upkeep.lastPerformedBlockNumber) { | ||
|
@@ -774,7 +778,8 @@ abstract contract AutomationRegistryBase2_2 is ConfirmedOwner, ExecutionPreventi | |
return false; | ||
} | ||
if ( | ||
(trigger.blockHash != bytes32("") && _blockHash(trigger.blockNum) != trigger.blockHash) || | ||
(!hotVars.skipReorgProtection && | ||
(trigger.blockHash != bytes32("") && _blockHash(trigger.blockNum) != trigger.blockHash)) || | ||
trigger.blockNum >= _blockNum() | ||
) { | ||
// There are two cases of reorged report | ||
|
@@ -792,12 +797,13 @@ abstract contract AutomationRegistryBase2_2 is ConfirmedOwner, ExecutionPreventi | |
function _validateLogTrigger( | ||
uint256 upkeepId, | ||
bytes memory rawTrigger, | ||
UpkeepTransmitInfo memory transmitInfo | ||
FelixFan1992 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
HotVars memory hotVars | ||
) 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) || | ||
(!hotVars.skipReorgProtection && | ||
FelixFan1992 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
(trigger.blockHash != bytes32("") && _blockHash(trigger.blockNum) != trigger.blockHash)) || | ||
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.
can we struct pack this a little better? Ex there is a free slot after
minUpkeepSpend
- also, some comments on where the words begin & end would be nice, like what we do for theStorage
structThere 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.
done. restructure this using Spack