From 70b644746118572fc80e53cf6efbaad74dcbb48b Mon Sep 17 00:00:00 2001 From: lei shi Date: Fri, 26 Jan 2024 22:40:50 -0800 Subject: [PATCH] use bitmap to save space --- .../dev/v2_2/AutomationRegistry2_2.sol | 11 +- .../dev/v2_2/AutomationRegistryBase2_2.sol | 39 ++- .../dev/v2_2/AutomationRegistryLogicA2_2.sol | 2 +- .../dev/v2_2/AutomationRegistryLogicB2_2.sol | 9 +- .../automation/AutomationRegistry2_2.test.ts | 234 ++++++++++++------ .../v0.8/automation/KeeperRegistry2_1.test.ts | 234 ++++++++++++------ 6 files changed, 371 insertions(+), 158 deletions(-) diff --git a/contracts/src/v0.8/automation/dev/v2_2/AutomationRegistry2_2.sol b/contracts/src/v0.8/automation/dev/v2_2/AutomationRegistry2_2.sol index 77f11b22597..2e094bfb76f 100644 --- a/contracts/src/v0.8/automation/dev/v2_2/AutomationRegistry2_2.sol +++ b/contracts/src/v0.8/automation/dev/v2_2/AutomationRegistry2_2.sol @@ -73,8 +73,7 @@ contract AutomationRegistry2_2 is AutomationRegistryBase2_2, OCR2Abstract, Chain ) external override { uint256 gasOverhead = gasleft(); HotVars memory hotVars = s_hotVars; - - if (hotVars.paused) revert RegistryPaused(); + if (_isRegistryPaused()) revert RegistryPaused(); if (!s_transmitters[msg.sender].active) revert OnlyActiveTransmitters(); // Verify signatures @@ -196,7 +195,7 @@ contract AutomationRegistry2_2 is AutomationRegistryBase2_2, OCR2Abstract, Chain uint256 id, bytes calldata performData ) external cannotExecute returns (bool success, uint256 gasUsed) { - if (s_hotVars.paused) revert RegistryPaused(); + if (_isRegistryPaused()) revert RegistryPaused(); Upkeep memory upkeep = s_upkeep[id]; (success, gasUsed) = _performUpkeep(upkeep.forwarder, upkeep.performGas, performData); return (success, gasUsed); @@ -306,11 +305,11 @@ contract AutomationRegistry2_2 is AutomationRegistryBase2_2, OCR2Abstract, Chain flatFeeMicroLink: onchainConfig.flatFeeMicroLink, stalenessSeconds: onchainConfig.stalenessSeconds, gasCeilingMultiplier: onchainConfig.gasCeilingMultiplier, - paused: s_hotVars.paused, - reentrancyGuard: s_hotVars.reentrancyGuard, totalPremium: totalPremium, latestEpoch: 0, // DON restarts epoch - reorgProtectionEnabled: onchainConfig.reorgProtectionEnabled + boolFlags: (_isRegistryPaused() ? (1 << 0) : 0) | + (_isReentrancyGuarded() ? (1 << 1) : 0) | + (onchainConfig.reorgProtectionEnabled ? (1 << 2) : 0) }); s_storage = Storage({ diff --git a/contracts/src/v0.8/automation/dev/v2_2/AutomationRegistryBase2_2.sol b/contracts/src/v0.8/automation/dev/v2_2/AutomationRegistryBase2_2.sol index e66b107cbd8..b07a0f84bf4 100644 --- a/contracts/src/v0.8/automation/dev/v2_2/AutomationRegistryBase2_2.sol +++ b/contracts/src/v0.8/automation/dev/v2_2/AutomationRegistryBase2_2.sol @@ -316,9 +316,7 @@ abstract contract AutomationRegistryBase2_2 is ConfirmedOwner, ExecutionPreventi 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 reorgProtectionEnabled; // if this registry should enable re-org protection mechanism + uint8 boolFlags; // ──────────╯ bitmap for booleans: paused (position 0: pause switch for all upkeeps in the registry), reentrancyGuard (position 1: guard against reentrancy), reorgProtectionEnabled (position 2: if this registry should enable re-org protection mechanism) } /// @dev Config + State storage struct which is not on hot transmit path @@ -485,7 +483,7 @@ abstract contract AutomationRegistryBase2_2 is ConfirmedOwner, ExecutionPreventi bytes memory triggerConfig, bytes memory offchainConfig ) internal { - if (s_hotVars.paused) revert RegistryPaused(); + if (_isRegistryPaused()) revert RegistryPaused(); if (checkData.length > s_storage.maxCheckDataSize) revert CheckDataExceedsLimit(); if (upkeep.performGas < PERFORM_GAS_MIN || upkeep.performGas > s_storage.maxPerformGas) revert GasLimitOutsideRange(); @@ -778,7 +776,7 @@ abstract contract AutomationRegistryBase2_2 is ConfirmedOwner, ExecutionPreventi return false; } if ( - (hotVars.reorgProtectionEnabled && + (_isReorgProtectionEnabled() && (trigger.blockHash != bytes32("") && _blockHash(trigger.blockNum) != trigger.blockHash)) || trigger.blockNum >= _blockNum() ) { @@ -802,7 +800,7 @@ abstract contract AutomationRegistryBase2_2 is ConfirmedOwner, ExecutionPreventi LogTrigger memory trigger = abi.decode(rawTrigger, (LogTrigger)); bytes32 dedupID = keccak256(abi.encodePacked(upkeepId, trigger.logBlockHash, trigger.txHash, trigger.logIndex)); if ( - (hotVars.reorgProtectionEnabled && + (_isReorgProtectionEnabled() && (trigger.blockHash != bytes32("") && _blockHash(trigger.blockNum) != trigger.blockHash)) || trigger.blockNum >= _blockNum() ) { @@ -953,13 +951,36 @@ abstract contract AutomationRegistryBase2_2 is ConfirmedOwner, ExecutionPreventi } } + /** + * @notice Returns true if the registry is paused, false otherwise + */ + function _isRegistryPaused() internal view returns (bool) { + return (s_hotVars.boolFlags & (1 << 0)) != 0; + } + + /** + * @notice Returns true if the registry is reentrancy guarded, false otherwise + */ + function _isReentrancyGuarded() internal view returns (bool) { + return (s_hotVars.boolFlags & (1 << 1)) != 0; + } + + /** + * @notice Returns true if the registry enabled reorg protection, false otherwise + */ + function _isReorgProtectionEnabled() internal view returns (bool) { + return (s_hotVars.boolFlags & (1 << 2)) != 0; + } + /** * @dev replicates Open Zeppelin's ReentrancyGuard but optimized to fit our storage */ modifier nonReentrant() { - if (s_hotVars.reentrancyGuard) revert ReentrantCall(); - s_hotVars.reentrancyGuard = true; + if (_isReentrancyGuarded()) revert ReentrantCall(); + s_hotVars.boolFlags = s_hotVars.boolFlags | (1 << 1); _; - s_hotVars.reentrancyGuard = false; + + uint8 mask = 1 << 1; + s_hotVars.boolFlags = s_hotVars.boolFlags & ~mask; } } diff --git a/contracts/src/v0.8/automation/dev/v2_2/AutomationRegistryLogicA2_2.sol b/contracts/src/v0.8/automation/dev/v2_2/AutomationRegistryLogicA2_2.sol index 52c6880fa4a..f86a0c5811a 100644 --- a/contracts/src/v0.8/automation/dev/v2_2/AutomationRegistryLogicA2_2.sol +++ b/contracts/src/v0.8/automation/dev/v2_2/AutomationRegistryLogicA2_2.sol @@ -64,7 +64,7 @@ contract AutomationRegistryLogicA2_2 is AutomationRegistryBase2_2, Chainable { HotVars memory hotVars = s_hotVars; Upkeep memory upkeep = s_upkeep[id]; - if (hotVars.paused) return (false, bytes(""), UpkeepFailureReason.REGISTRY_PAUSED, 0, upkeep.performGas, 0, 0); + if (_isRegistryPaused()) return (false, bytes(""), UpkeepFailureReason.REGISTRY_PAUSED, 0, upkeep.performGas, 0, 0); if (upkeep.maxValidBlocknumber != UINT32_MAX) return (false, bytes(""), UpkeepFailureReason.UPKEEP_CANCELLED, 0, upkeep.performGas, 0, 0); if (upkeep.paused) return (false, bytes(""), UpkeepFailureReason.UPKEEP_PAUSED, 0, upkeep.performGas, 0, 0); diff --git a/contracts/src/v0.8/automation/dev/v2_2/AutomationRegistryLogicB2_2.sol b/contracts/src/v0.8/automation/dev/v2_2/AutomationRegistryLogicB2_2.sol index de691b0f174..fb622e1e370 100644 --- a/contracts/src/v0.8/automation/dev/v2_2/AutomationRegistryLogicB2_2.sol +++ b/contracts/src/v0.8/automation/dev/v2_2/AutomationRegistryLogicB2_2.sol @@ -231,7 +231,7 @@ contract AutomationRegistryLogicB2_2 is AutomationRegistryBase2_2 { * @notice pauses the entire registry */ function pause() external onlyOwner { - s_hotVars.paused = true; + s_hotVars.boolFlags = s_hotVars.boolFlags | (1 << 0); emit Paused(msg.sender); } @@ -239,7 +239,8 @@ contract AutomationRegistryLogicB2_2 is AutomationRegistryBase2_2 { * @notice unpauses the entire registry */ function unpause() external onlyOwner { - s_hotVars.paused = false; + uint8 mask = 1 << 0; + s_hotVars.boolFlags = s_hotVars.boolFlags & ~mask; emit Unpaused(msg.sender); } @@ -419,7 +420,7 @@ contract AutomationRegistryLogicB2_2 is AutomationRegistryBase2_2 { latestConfigBlockNumber: s_storage.latestConfigBlockNumber, latestConfigDigest: s_latestConfigDigest, latestEpoch: s_hotVars.latestEpoch, - paused: s_hotVars.paused + paused: _isRegistryPaused() }); config = OnchainConfig({ @@ -438,7 +439,7 @@ contract AutomationRegistryLogicB2_2 is AutomationRegistryBase2_2 { transcoder: s_storage.transcoder, registrars: s_registrars.values(), upkeepPrivilegeManager: s_storage.upkeepPrivilegeManager, - reorgProtectionEnabled: s_hotVars.reorgProtectionEnabled + reorgProtectionEnabled: _isReorgProtectionEnabled() }); return (state, config, s_signersList, s_transmittersList, s_hotVars.f); diff --git a/contracts/test/v0.8/automation/AutomationRegistry2_2.test.ts b/contracts/test/v0.8/automation/AutomationRegistry2_2.test.ts index 69d580b23a0..740e4ac1c27 100644 --- a/contracts/test/v0.8/automation/AutomationRegistry2_2.test.ts +++ b/contracts/test/v0.8/automation/AutomationRegistry2_2.test.ts @@ -953,9 +953,13 @@ describe('AutomationRegistry2_2', () => { .transfer(await admin.getAddress(), toWei('1000')) let tx = await registry .connect(owner) - [ - 'registerUpkeep(address,uint32,address,bytes,bytes)' - ](mock.address, performGas, await admin.getAddress(), randomBytes, '0x') + ['registerUpkeep(address,uint32,address,bytes,bytes)']( + mock.address, + performGas, + await admin.getAddress(), + randomBytes, + '0x', + ) upkeepId = await getUpkeepID(tx) autoFunderUpkeep = await upkeepAutoFunderFactory @@ -963,17 +967,27 @@ describe('AutomationRegistry2_2', () => { .deploy(linkToken.address, registry.address) tx = await registry .connect(owner) - [ - 'registerUpkeep(address,uint32,address,bytes,bytes)' - ](autoFunderUpkeep.address, performGas, autoFunderUpkeep.address, randomBytes, '0x') + ['registerUpkeep(address,uint32,address,bytes,bytes)']( + autoFunderUpkeep.address, + performGas, + autoFunderUpkeep.address, + randomBytes, + '0x', + ) afUpkeepId = await getUpkeepID(tx) ltUpkeep = await deployMockContract(owner, ILogAutomationactory.abi) tx = await registry .connect(owner) - [ - 'registerUpkeep(address,uint32,address,uint8,bytes,bytes,bytes)' - ](ltUpkeep.address, performGas, await admin.getAddress(), Trigger.LOG, '0x', logTriggerConfig, emptyBytes) + ['registerUpkeep(address,uint32,address,uint8,bytes,bytes,bytes)']( + ltUpkeep.address, + performGas, + await admin.getAddress(), + Trigger.LOG, + '0x', + logTriggerConfig, + emptyBytes, + ) logUpkeepId = await getUpkeepID(tx) await autoFunderUpkeep.setUpkeepId(afUpkeepId) @@ -984,9 +998,13 @@ describe('AutomationRegistry2_2', () => { tx = await registry .connect(owner) - [ - 'registerUpkeep(address,uint32,address,bytes,bytes)' - ](streamsLookupUpkeep.address, performGas, await admin.getAddress(), randomBytes, '0x') + ['registerUpkeep(address,uint32,address,bytes,bytes)']( + streamsLookupUpkeep.address, + performGas, + await admin.getAddress(), + randomBytes, + '0x', + ) streamsLookupUpkeepId = await getUpkeepID(tx) } @@ -1004,9 +1022,13 @@ describe('AutomationRegistry2_2', () => { await mock.setPerformGasToBurn(BigNumber.from('0')) const tx = await registry .connect(owner) - [ - 'registerUpkeep(address,uint32,address,bytes,bytes)' - ](mock.address, performGas, await admin.getAddress(), randomBytes, '0x') + ['registerUpkeep(address,uint32,address,bytes,bytes)']( + mock.address, + performGas, + await admin.getAddress(), + randomBytes, + '0x', + ) const condUpkeepId = await getUpkeepID(tx) passingConditionalUpkeepIds.push(condUpkeepId) @@ -1019,9 +1041,15 @@ describe('AutomationRegistry2_2', () => { await mock.setPerformGasToBurn(BigNumber.from('0')) const tx = await registry .connect(owner) - [ - 'registerUpkeep(address,uint32,address,uint8,bytes,bytes,bytes)' - ](mock.address, performGas, await admin.getAddress(), Trigger.LOG, '0x', logTriggerConfig, emptyBytes) + ['registerUpkeep(address,uint32,address,uint8,bytes,bytes,bytes)']( + mock.address, + performGas, + await admin.getAddress(), + Trigger.LOG, + '0x', + logTriggerConfig, + emptyBytes, + ) const logUpkeepId = await getUpkeepID(tx) passingLogUpkeepIds.push(logUpkeepId) @@ -1034,9 +1062,13 @@ describe('AutomationRegistry2_2', () => { await mock.setPerformGasToBurn(BigNumber.from('0')) const tx = await registry .connect(owner) - [ - 'registerUpkeep(address,uint32,address,bytes,bytes)' - ](mock.address, performGas, await admin.getAddress(), randomBytes, '0x') + ['registerUpkeep(address,uint32,address,bytes,bytes)']( + mock.address, + performGas, + await admin.getAddress(), + randomBytes, + '0x', + ) const failingUpkeepId = await getUpkeepID(tx) failingUpkeepIds.push(failingUpkeepId) } @@ -1518,9 +1550,13 @@ describe('AutomationRegistry2_2', () => { let tx = await arbRegistry .connect(owner) - [ - 'registerUpkeep(address,uint32,address,bytes,bytes)' - ](mock.address, performGas, await admin.getAddress(), randomBytes, '0x') + ['registerUpkeep(address,uint32,address,bytes,bytes)']( + mock.address, + performGas, + await admin.getAddress(), + randomBytes, + '0x', + ) const testUpkeepId = await getUpkeepID(tx) await arbRegistry.connect(owner).addFunds(testUpkeepId, toWei('100')) @@ -2492,9 +2528,13 @@ describe('AutomationRegistry2_2', () => { const mock = await upkeepMockFactory.deploy() const tx = await registry .connect(owner) - [ - 'registerUpkeep(address,uint32,address,bytes,bytes)' - ](mock.address, performGas, await admin.getAddress(), randomBytes, '0x') + ['registerUpkeep(address,uint32,address,bytes,bytes)']( + mock.address, + performGas, + await admin.getAddress(), + randomBytes, + '0x', + ) const testUpkeepId = await getUpkeepID(tx) upkeepIds.push(testUpkeepId) @@ -2529,9 +2569,13 @@ describe('AutomationRegistry2_2', () => { const mock = await upkeepMockFactory.deploy() const tx = await arbRegistry .connect(owner) - [ - 'registerUpkeep(address,uint32,address,bytes,bytes)' - ](mock.address, performGas, await admin.getAddress(), randomBytes, '0x') + ['registerUpkeep(address,uint32,address,bytes,bytes)']( + mock.address, + performGas, + await admin.getAddress(), + randomBytes, + '0x', + ) const testUpkeepId = await getUpkeepID(tx) upkeepIds.push(testUpkeepId) @@ -2588,9 +2632,13 @@ describe('AutomationRegistry2_2', () => { // add funds to upkeep 1 and perform and withdraw some payment const tx = await registry .connect(owner) - [ - 'registerUpkeep(address,uint32,address,bytes,bytes)' - ](mock.address, performGas, await admin.getAddress(), emptyBytes, emptyBytes) + ['registerUpkeep(address,uint32,address,bytes,bytes)']( + mock.address, + performGas, + await admin.getAddress(), + emptyBytes, + emptyBytes, + ) const id1 = await getUpkeepID(tx) await registry.connect(admin).addFunds(id1, toWei('5')) @@ -2612,9 +2660,13 @@ describe('AutomationRegistry2_2', () => { // add funds to upkeep 2 and perform and withdraw some payment const tx2 = await registry .connect(owner) - [ - 'registerUpkeep(address,uint32,address,bytes,bytes)' - ](mock.address, performGas, await admin.getAddress(), emptyBytes, emptyBytes) + ['registerUpkeep(address,uint32,address,bytes,bytes)']( + mock.address, + performGas, + await admin.getAddress(), + emptyBytes, + emptyBytes, + ) const id2 = await getUpkeepID(tx2) await registry.connect(admin).addFunds(id2, toWei('5')) @@ -2692,15 +2744,23 @@ describe('AutomationRegistry2_2', () => { it('uses maxPerformData size in checkUpkeep but actual performDataSize in transmit', async () => { const tx1 = await registry .connect(owner) - [ - 'registerUpkeep(address,uint32,address,bytes,bytes)' - ](mock.address, performGas, await admin.getAddress(), randomBytes, '0x') + ['registerUpkeep(address,uint32,address,bytes,bytes)']( + mock.address, + performGas, + await admin.getAddress(), + randomBytes, + '0x', + ) const upkeepID1 = await getUpkeepID(tx1) const tx2 = await registry .connect(owner) - [ - 'registerUpkeep(address,uint32,address,bytes,bytes)' - ](mock.address, performGas, await admin.getAddress(), randomBytes, '0x') + ['registerUpkeep(address,uint32,address,bytes,bytes)']( + mock.address, + performGas, + await admin.getAddress(), + randomBytes, + '0x', + ) const upkeepID2 = await getUpkeepID(tx2) await mock.setCanCheck(true) await mock.setCanPerform(true) @@ -2763,9 +2823,13 @@ describe('AutomationRegistry2_2', () => { beforeEach(async () => { const tx = await registry .connect(owner) - [ - 'registerUpkeep(address,uint32,address,bytes,bytes)' - ](mock.address, performGas, await admin.getAddress(), randomBytes, '0x') + ['registerUpkeep(address,uint32,address,bytes,bytes)']( + mock.address, + performGas, + await admin.getAddress(), + randomBytes, + '0x', + ) upkeepId2 = await getUpkeepID(tx) await registry.connect(admin).addFunds(upkeepId, toWei('100')) @@ -3906,9 +3970,13 @@ describe('AutomationRegistry2_2', () => { await evmRevert( registry .connect(owner) - [ - 'registerUpkeep(address,uint32,address,bytes,bytes)' - ](mock.address, performGas, await admin.getAddress(), emptyBytes, '0x'), + ['registerUpkeep(address,uint32,address,bytes,bytes)']( + mock.address, + performGas, + await admin.getAddress(), + emptyBytes, + '0x', + ), 'RegistryPaused()', ) }) @@ -3917,9 +3985,13 @@ describe('AutomationRegistry2_2', () => { await evmRevert( registry .connect(owner) - [ - 'registerUpkeep(address,uint32,address,bytes,bytes)' - ](zeroAddress, performGas, await admin.getAddress(), emptyBytes, '0x'), + ['registerUpkeep(address,uint32,address,bytes,bytes)']( + zeroAddress, + performGas, + await admin.getAddress(), + emptyBytes, + '0x', + ), 'NotAContract()', ) }) @@ -3928,9 +4000,13 @@ describe('AutomationRegistry2_2', () => { await evmRevert( registry .connect(keeper1) - [ - 'registerUpkeep(address,uint32,address,bytes,bytes)' - ](mock.address, performGas, await admin.getAddress(), emptyBytes, '0x'), + ['registerUpkeep(address,uint32,address,bytes,bytes)']( + mock.address, + performGas, + await admin.getAddress(), + emptyBytes, + '0x', + ), 'OnlyCallableByOwnerOrRegistrar()', ) }) @@ -3939,9 +4015,13 @@ describe('AutomationRegistry2_2', () => { await evmRevert( registry .connect(owner) - [ - 'registerUpkeep(address,uint32,address,bytes,bytes)' - ](mock.address, 2299, await admin.getAddress(), emptyBytes, '0x'), + ['registerUpkeep(address,uint32,address,bytes,bytes)']( + mock.address, + 2299, + await admin.getAddress(), + emptyBytes, + '0x', + ), 'GasLimitOutsideRange()', ) }) @@ -3950,9 +4030,13 @@ describe('AutomationRegistry2_2', () => { await evmRevert( registry .connect(owner) - [ - 'registerUpkeep(address,uint32,address,bytes,bytes)' - ](mock.address, 5000001, await admin.getAddress(), emptyBytes, '0x'), + ['registerUpkeep(address,uint32,address,bytes,bytes)']( + mock.address, + 5000001, + await admin.getAddress(), + emptyBytes, + '0x', + ), 'GasLimitOutsideRange()', ) }) @@ -3965,9 +4049,13 @@ describe('AutomationRegistry2_2', () => { await evmRevert( registry .connect(owner) - [ - 'registerUpkeep(address,uint32,address,bytes,bytes)' - ](mock.address, performGas, await admin.getAddress(), longBytes, '0x'), + ['registerUpkeep(address,uint32,address,bytes,bytes)']( + mock.address, + performGas, + await admin.getAddress(), + longBytes, + '0x', + ), 'CheckDataExceedsLimit()', ) }) @@ -3982,9 +4070,13 @@ describe('AutomationRegistry2_2', () => { const checkData = checkDatas[kdx] const tx = await registry .connect(owner) - [ - 'registerUpkeep(address,uint32,address,bytes,bytes)' - ](mock.address, performGas, await admin.getAddress(), checkData, '0x') + ['registerUpkeep(address,uint32,address,bytes,bytes)']( + mock.address, + performGas, + await admin.getAddress(), + checkData, + '0x', + ) //confirm the upkeep details and verify emitted events const testUpkeepId = await getUpkeepID(tx) @@ -4646,9 +4738,13 @@ describe('AutomationRegistry2_2', () => { await evmRevert( registry .connect(owner) - [ - 'registerUpkeep(address,uint32,address,bytes,bytes)' - ](mock.address, performGas, await admin.getAddress(), emptyBytes, '0x'), + ['registerUpkeep(address,uint32,address,bytes,bytes)']( + mock.address, + performGas, + await admin.getAddress(), + emptyBytes, + '0x', + ), 'RegistryPaused()', ) }) diff --git a/contracts/test/v0.8/automation/KeeperRegistry2_1.test.ts b/contracts/test/v0.8/automation/KeeperRegistry2_1.test.ts index 65f6a596fca..f6864bd36de 100644 --- a/contracts/test/v0.8/automation/KeeperRegistry2_1.test.ts +++ b/contracts/test/v0.8/automation/KeeperRegistry2_1.test.ts @@ -990,9 +990,13 @@ describe('KeeperRegistry2_1', () => { .transfer(await admin.getAddress(), toWei('1000')) let tx = await registry .connect(owner) - [ - 'registerUpkeep(address,uint32,address,bytes,bytes)' - ](mock.address, performGas, await admin.getAddress(), randomBytes, '0x') + ['registerUpkeep(address,uint32,address,bytes,bytes)']( + mock.address, + performGas, + await admin.getAddress(), + randomBytes, + '0x', + ) upkeepId = await getUpkeepID(tx) autoFunderUpkeep = await upkeepAutoFunderFactory @@ -1000,17 +1004,27 @@ describe('KeeperRegistry2_1', () => { .deploy(linkToken.address, registry.address) tx = await registry .connect(owner) - [ - 'registerUpkeep(address,uint32,address,bytes,bytes)' - ](autoFunderUpkeep.address, performGas, autoFunderUpkeep.address, randomBytes, '0x') + ['registerUpkeep(address,uint32,address,bytes,bytes)']( + autoFunderUpkeep.address, + performGas, + autoFunderUpkeep.address, + randomBytes, + '0x', + ) afUpkeepId = await getUpkeepID(tx) ltUpkeep = await deployMockContract(owner, ILogAutomationactory.abi) tx = await registry .connect(owner) - [ - 'registerUpkeep(address,uint32,address,uint8,bytes,bytes,bytes)' - ](ltUpkeep.address, performGas, await admin.getAddress(), Trigger.LOG, '0x', logTriggerConfig, emptyBytes) + ['registerUpkeep(address,uint32,address,uint8,bytes,bytes,bytes)']( + ltUpkeep.address, + performGas, + await admin.getAddress(), + Trigger.LOG, + '0x', + logTriggerConfig, + emptyBytes, + ) logUpkeepId = await getUpkeepID(tx) await autoFunderUpkeep.setUpkeepId(afUpkeepId) @@ -1021,9 +1035,13 @@ describe('KeeperRegistry2_1', () => { tx = await registry .connect(owner) - [ - 'registerUpkeep(address,uint32,address,bytes,bytes)' - ](streamsLookupUpkeep.address, performGas, await admin.getAddress(), randomBytes, '0x') + ['registerUpkeep(address,uint32,address,bytes,bytes)']( + streamsLookupUpkeep.address, + performGas, + await admin.getAddress(), + randomBytes, + '0x', + ) streamsLookupUpkeepId = await getUpkeepID(tx) } @@ -1041,9 +1059,13 @@ describe('KeeperRegistry2_1', () => { await mock.setPerformGasToBurn(BigNumber.from('0')) const tx = await registry .connect(owner) - [ - 'registerUpkeep(address,uint32,address,bytes,bytes)' - ](mock.address, performGas, await admin.getAddress(), randomBytes, '0x') + ['registerUpkeep(address,uint32,address,bytes,bytes)']( + mock.address, + performGas, + await admin.getAddress(), + randomBytes, + '0x', + ) const condUpkeepId = await getUpkeepID(tx) passingConditionalUpkeepIds.push(condUpkeepId) @@ -1056,9 +1078,15 @@ describe('KeeperRegistry2_1', () => { await mock.setPerformGasToBurn(BigNumber.from('0')) const tx = await registry .connect(owner) - [ - 'registerUpkeep(address,uint32,address,uint8,bytes,bytes,bytes)' - ](mock.address, performGas, await admin.getAddress(), Trigger.LOG, '0x', logTriggerConfig, emptyBytes) + ['registerUpkeep(address,uint32,address,uint8,bytes,bytes,bytes)']( + mock.address, + performGas, + await admin.getAddress(), + Trigger.LOG, + '0x', + logTriggerConfig, + emptyBytes, + ) const logUpkeepId = await getUpkeepID(tx) passingLogUpkeepIds.push(logUpkeepId) @@ -1071,9 +1099,13 @@ describe('KeeperRegistry2_1', () => { await mock.setPerformGasToBurn(BigNumber.from('0')) const tx = await registry .connect(owner) - [ - 'registerUpkeep(address,uint32,address,bytes,bytes)' - ](mock.address, performGas, await admin.getAddress(), randomBytes, '0x') + ['registerUpkeep(address,uint32,address,bytes,bytes)']( + mock.address, + performGas, + await admin.getAddress(), + randomBytes, + '0x', + ) const failingUpkeepId = await getUpkeepID(tx) failingUpkeepIds.push(failingUpkeepId) } @@ -1555,9 +1587,13 @@ describe('KeeperRegistry2_1', () => { let tx = await arbRegistry .connect(owner) - [ - 'registerUpkeep(address,uint32,address,bytes,bytes)' - ](mock.address, performGas, await admin.getAddress(), randomBytes, '0x') + ['registerUpkeep(address,uint32,address,bytes,bytes)']( + mock.address, + performGas, + await admin.getAddress(), + randomBytes, + '0x', + ) const testUpkeepId = await getUpkeepID(tx) await arbRegistry.connect(owner).addFunds(testUpkeepId, toWei('100')) @@ -2529,9 +2565,13 @@ describe('KeeperRegistry2_1', () => { const mock = await upkeepMockFactory.deploy() const tx = await registry .connect(owner) - [ - 'registerUpkeep(address,uint32,address,bytes,bytes)' - ](mock.address, performGas, await admin.getAddress(), randomBytes, '0x') + ['registerUpkeep(address,uint32,address,bytes,bytes)']( + mock.address, + performGas, + await admin.getAddress(), + randomBytes, + '0x', + ) const testUpkeepId = await getUpkeepID(tx) upkeepIds.push(testUpkeepId) @@ -2566,9 +2606,13 @@ describe('KeeperRegistry2_1', () => { const mock = await upkeepMockFactory.deploy() const tx = await arbRegistry .connect(owner) - [ - 'registerUpkeep(address,uint32,address,bytes,bytes)' - ](mock.address, performGas, await admin.getAddress(), randomBytes, '0x') + ['registerUpkeep(address,uint32,address,bytes,bytes)']( + mock.address, + performGas, + await admin.getAddress(), + randomBytes, + '0x', + ) const testUpkeepId = await getUpkeepID(tx) upkeepIds.push(testUpkeepId) @@ -2625,9 +2669,13 @@ describe('KeeperRegistry2_1', () => { // add funds to upkeep 1 and perform and withdraw some payment const tx = await registry .connect(owner) - [ - 'registerUpkeep(address,uint32,address,bytes,bytes)' - ](mock.address, performGas, await admin.getAddress(), emptyBytes, emptyBytes) + ['registerUpkeep(address,uint32,address,bytes,bytes)']( + mock.address, + performGas, + await admin.getAddress(), + emptyBytes, + emptyBytes, + ) const id1 = await getUpkeepID(tx) await registry.connect(admin).addFunds(id1, toWei('5')) @@ -2649,9 +2697,13 @@ describe('KeeperRegistry2_1', () => { // add funds to upkeep 2 and perform and withdraw some payment const tx2 = await registry .connect(owner) - [ - 'registerUpkeep(address,uint32,address,bytes,bytes)' - ](mock.address, performGas, await admin.getAddress(), emptyBytes, emptyBytes) + ['registerUpkeep(address,uint32,address,bytes,bytes)']( + mock.address, + performGas, + await admin.getAddress(), + emptyBytes, + emptyBytes, + ) const id2 = await getUpkeepID(tx2) await registry.connect(admin).addFunds(id2, toWei('5')) @@ -2729,15 +2781,23 @@ describe('KeeperRegistry2_1', () => { it('uses maxPerformData size in checkUpkeep but actual performDataSize in transmit', async () => { const tx1 = await registry .connect(owner) - [ - 'registerUpkeep(address,uint32,address,bytes,bytes)' - ](mock.address, performGas, await admin.getAddress(), randomBytes, '0x') + ['registerUpkeep(address,uint32,address,bytes,bytes)']( + mock.address, + performGas, + await admin.getAddress(), + randomBytes, + '0x', + ) const upkeepID1 = await getUpkeepID(tx1) const tx2 = await registry .connect(owner) - [ - 'registerUpkeep(address,uint32,address,bytes,bytes)' - ](mock.address, performGas, await admin.getAddress(), randomBytes, '0x') + ['registerUpkeep(address,uint32,address,bytes,bytes)']( + mock.address, + performGas, + await admin.getAddress(), + randomBytes, + '0x', + ) const upkeepID2 = await getUpkeepID(tx2) await mock.setCanCheck(true) await mock.setCanPerform(true) @@ -2800,9 +2860,13 @@ describe('KeeperRegistry2_1', () => { beforeEach(async () => { const tx = await registry .connect(owner) - [ - 'registerUpkeep(address,uint32,address,bytes,bytes)' - ](mock.address, performGas, await admin.getAddress(), randomBytes, '0x') + ['registerUpkeep(address,uint32,address,bytes,bytes)']( + mock.address, + performGas, + await admin.getAddress(), + randomBytes, + '0x', + ) upkeepId2 = await getUpkeepID(tx) await registry.connect(admin).addFunds(upkeepId, toWei('100')) @@ -3942,9 +4006,13 @@ describe('KeeperRegistry2_1', () => { await evmRevert( registry .connect(owner) - [ - 'registerUpkeep(address,uint32,address,bytes,bytes)' - ](mock.address, performGas, await admin.getAddress(), emptyBytes, '0x'), + ['registerUpkeep(address,uint32,address,bytes,bytes)']( + mock.address, + performGas, + await admin.getAddress(), + emptyBytes, + '0x', + ), 'RegistryPaused()', ) }) @@ -3953,9 +4021,13 @@ describe('KeeperRegistry2_1', () => { await evmRevert( registry .connect(owner) - [ - 'registerUpkeep(address,uint32,address,bytes,bytes)' - ](zeroAddress, performGas, await admin.getAddress(), emptyBytes, '0x'), + ['registerUpkeep(address,uint32,address,bytes,bytes)']( + zeroAddress, + performGas, + await admin.getAddress(), + emptyBytes, + '0x', + ), 'NotAContract()', ) }) @@ -3964,9 +4036,13 @@ describe('KeeperRegistry2_1', () => { await evmRevert( registry .connect(keeper1) - [ - 'registerUpkeep(address,uint32,address,bytes,bytes)' - ](mock.address, performGas, await admin.getAddress(), emptyBytes, '0x'), + ['registerUpkeep(address,uint32,address,bytes,bytes)']( + mock.address, + performGas, + await admin.getAddress(), + emptyBytes, + '0x', + ), 'OnlyCallableByOwnerOrRegistrar()', ) }) @@ -3975,9 +4051,13 @@ describe('KeeperRegistry2_1', () => { await evmRevert( registry .connect(owner) - [ - 'registerUpkeep(address,uint32,address,bytes,bytes)' - ](mock.address, 2299, await admin.getAddress(), emptyBytes, '0x'), + ['registerUpkeep(address,uint32,address,bytes,bytes)']( + mock.address, + 2299, + await admin.getAddress(), + emptyBytes, + '0x', + ), 'GasLimitOutsideRange()', ) }) @@ -3986,9 +4066,13 @@ describe('KeeperRegistry2_1', () => { await evmRevert( registry .connect(owner) - [ - 'registerUpkeep(address,uint32,address,bytes,bytes)' - ](mock.address, 5000001, await admin.getAddress(), emptyBytes, '0x'), + ['registerUpkeep(address,uint32,address,bytes,bytes)']( + mock.address, + 5000001, + await admin.getAddress(), + emptyBytes, + '0x', + ), 'GasLimitOutsideRange()', ) }) @@ -4001,9 +4085,13 @@ describe('KeeperRegistry2_1', () => { await evmRevert( registry .connect(owner) - [ - 'registerUpkeep(address,uint32,address,bytes,bytes)' - ](mock.address, performGas, await admin.getAddress(), longBytes, '0x'), + ['registerUpkeep(address,uint32,address,bytes,bytes)']( + mock.address, + performGas, + await admin.getAddress(), + longBytes, + '0x', + ), 'CheckDataExceedsLimit()', ) }) @@ -4018,9 +4106,13 @@ describe('KeeperRegistry2_1', () => { const checkData = checkDatas[kdx] const tx = await registry .connect(owner) - [ - 'registerUpkeep(address,uint32,address,bytes,bytes)' - ](mock.address, performGas, await admin.getAddress(), checkData, '0x') + ['registerUpkeep(address,uint32,address,bytes,bytes)']( + mock.address, + performGas, + await admin.getAddress(), + checkData, + '0x', + ) //confirm the upkeep details and verify emitted events const testUpkeepId = await getUpkeepID(tx) @@ -4681,9 +4773,13 @@ describe('KeeperRegistry2_1', () => { await evmRevert( registry .connect(owner) - [ - 'registerUpkeep(address,uint32,address,bytes,bytes)' - ](mock.address, performGas, await admin.getAddress(), emptyBytes, '0x'), + ['registerUpkeep(address,uint32,address,bytes,bytes)']( + mock.address, + performGas, + await admin.getAddress(), + emptyBytes, + '0x', + ), 'RegistryPaused()', ) })