Skip to content

Commit

Permalink
Pause checkUpkeep when registry is paused (#9704)
Browse files Browse the repository at this point in the history
* Pause checkUpkeep when registry is paused

* regen wrappers

* fix test

* regen wrappers
  • Loading branch information
infiloop2 authored Jun 22, 2023
1 parent dd2d5bb commit 8dd42ed
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,8 @@ abstract contract KeeperRegistryBase2_1 is ConfirmedOwner, ExecutionPrevention {
PERFORM_DATA_EXCEEDS_LIMIT,
INSUFFICIENT_BALANCE,
CALLBACK_REVERTED,
REVERT_DATA_EXCEEDS_LIMIT
REVERT_DATA_EXCEEDS_LIMIT,
REGISTRY_PAUSED
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ contract KeeperRegistryLogicA2_1 is
Trigger triggerType = getTriggerType(id);
HotVars memory hotVars = s_hotVars;
Upkeep memory upkeep = s_upkeep[id];

if (hotVars.paused) return (false, bytes(""), UpkeepFailureReason.REGISTRY_PAUSED, 0, upkeep.executeGas, 0, 0);
if (upkeep.maxValidBlocknumber != UINT32_MAX)
return (false, bytes(""), UpkeepFailureReason.UPKEEP_CANCELLED, 0, upkeep.executeGas, 0, 0);
if (upkeep.paused) return (false, bytes(""), UpkeepFailureReason.UPKEEP_PAUSED, 0, upkeep.executeGas, 0, 0);
Expand Down
18 changes: 18 additions & 0 deletions contracts/test/v0.8/automation/KeeperRegistry2_1.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ enum UpkeepFailureReason {
INSUFFICIENT_BALANCE,
CHECK_CALLBACK_REVERTED,
REVERT_DATA_EXCEEDS_LIMIT,
REGISTRY_PAUSED,
}

// copied from AutomationRegistryInterface2_1.sol
Expand Down Expand Up @@ -3012,6 +3013,23 @@ describe('KeeperRegistry2_1', () => {
expect(checkUpkeepResult.gasLimit).to.equal(executeGas)
})

it('returns false and error code if the registry is paused', async () => {
await registry.connect(owner).pause()

const checkUpkeepResult = await registry
.connect(zeroAddress)
.callStatic['checkUpkeep(uint256)'](upkeepId)

assert.equal(checkUpkeepResult.upkeepNeeded, false)
assert.equal(checkUpkeepResult.performData, '0x')
assert.equal(
checkUpkeepResult.upkeepFailureReason,
UpkeepFailureReason.REGISTRY_PAUSED,
)
expect(checkUpkeepResult.gasUsed).to.equal(0)
expect(checkUpkeepResult.gasLimit).to.equal(executeGas)
})

it('returns false and error code if the upkeep is paused', async () => {
await registry.connect(admin).pauseUpkeep(upkeepId)

Expand Down
Loading

0 comments on commit 8dd42ed

Please sign in to comment.