Skip to content

Commit

Permalink
rename FeedLookup to StreamsLookup (#10388)
Browse files Browse the repository at this point in the history
* rename FeedLookup to StreamsLookup

* udpate tests

* skip tests

* fix VL contract

* revived some tests

* update

* update

* update tests

* update tests

* fix tests
  • Loading branch information
FelixFan1992 authored Sep 1, 2023
1 parent 8728bb2 commit 98cb209
Show file tree
Hide file tree
Showing 26 changed files with 4,254 additions and 4,235 deletions.
8 changes: 4 additions & 4 deletions contracts/scripts/native_solc_compile_all_automation
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ compileContract dev/automation/2_1/interfaces/IKeeperRegistryMaster.sol
compileContract dev/automation/2_1/interfaces/ILogAutomation.sol
compileContract dev/automation/2_1/AutomationUtils2_1.sol
compileContract dev/automation/2_1/AutomationForwarderLogic.sol
compileContract dev/automation/tests/LogTriggeredFeedLookup.sol
compileContract dev/automation/tests/LogTriggeredStreamsLookup.sol
compileContract dev/automation/tests/DummyProtocol.sol
compileContract dev/automation/2_1/interfaces/FeedLookupCompatibleInterface.sol
compileContract dev/automation/2_1/interfaces/StreamsLookupCompatibleInterface.sol

compileContract tests/VerifiableLoadUpkeep.sol
compileContract tests/VerifiableLoadMercuryUpkeep.sol
compileContract tests/VerifiableLoadStreamsLookupUpkeep.sol
compileContract tests/VerifiableLoadLogTriggerUpkeep.sol
compileContract tests/AutomationConsumerBenchmark.sol
compileContract tests/MercuryUpkeep.sol
compileContract tests/StreamsLookupUpkeep.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {ArbGasInfo} from "../../../vendor/@arbitrum/nitro-contracts/src/precompi
import {OVM_GasPriceOracle} from "../../../vendor/@eth-optimism/contracts/0.8.9/contracts/L2/predeploys/OVM_GasPriceOracle.sol";
import {ExecutionPrevention} from "../../../automation/ExecutionPrevention.sol";
import {ArbSys} from "../../../vendor/@arbitrum/nitro-contracts/src/precompiles/ArbSys.sol";
import {FeedLookupCompatibleInterface} from "./interfaces/FeedLookupCompatibleInterface.sol";
import {StreamsLookupCompatibleInterface} from "./interfaces/StreamsLookupCompatibleInterface.sol";
import {ILogAutomation, Log} from "./interfaces/ILogAutomation.sol";
import {IAutomationForwarder} from "./interfaces/IAutomationForwarder.sol";
import {ConfirmedOwner} from "../../../shared/access/ConfirmedOwner.sol";
Expand All @@ -30,7 +30,7 @@ abstract contract KeeperRegistryBase2_1 is ConfirmedOwner, ExecutionPrevention {
address internal constant IGNORE_ADDRESS = 0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF;
bytes4 internal constant CHECK_SELECTOR = KeeperCompatibleInterface.checkUpkeep.selector;
bytes4 internal constant PERFORM_SELECTOR = KeeperCompatibleInterface.performUpkeep.selector;
bytes4 internal constant CHECK_CALLBACK_SELECTOR = FeedLookupCompatibleInterface.checkCallback.selector;
bytes4 internal constant CHECK_CALLBACK_SELECTOR = StreamsLookupCompatibleInterface.checkCallback.selector;
bytes4 internal constant CHECK_LOG_SELECTOR = ILogAutomation.checkLog.selector;
uint256 internal constant PERFORM_GAS_MIN = 2_300;
uint256 internal constant CANCELLATION_DELAY = 50;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,9 @@ contract KeeperRegistryLogicA2_1 is KeeperRegistryBase2_1, Chainable {
}

/**
* @dev checkCallback is used specifically for automation feed lookups (see FeedLookupCompatibleInterface.sol)
* @dev checkCallback is used specifically for automation data streams lookups (see StreamsLookupCompatibleInterface.sol)
* @param id the upkeepID to execute a callback for
* @param values the values returned from the feed lookup
* @param values the values returned from the data streams lookup
* @param extraData the user-provided extra context data
*/
function checkCallback(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface FeedLookupCompatibleInterface {
error FeedLookup(string feedParamKey, string[] feeds, string timeParamKey, uint256 time, bytes extraData);
interface StreamsLookupCompatibleInterface {
error StreamsLookup(string feedParamKey, string[] feeds, string timeParamKey, uint256 time, bytes extraData);

/**
* @notice any contract which wants to utilize FeedLookup feature needs to
* @notice any contract which wants to utilize StreamsLookup feature needs to
* implement this interface as well as the automation compatible interface.
* @param values an array of bytes returned from Mercury endpoint.
* @param extraData context data from feed lookup process.
* @param values an array of bytes returned from data streams endpoint.
* @param extraData context data from streams lookup process.
* @return upkeepNeeded boolean to indicate whether the keeper should call performUpkeep or not.
* @return performData bytes that the keeper should call performUpkeep with, if
* upkeep is needed. If you would like to encode data to decode later, try `abi.encode`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
pragma solidity 0.8.16;

import {ILogAutomation, Log} from "../2_1/interfaces/ILogAutomation.sol";
import "../2_1/interfaces/FeedLookupCompatibleInterface.sol";
import "../2_1/interfaces/StreamsLookupCompatibleInterface.sol";
import {ArbSys} from "../../../vendor/@arbitrum/nitro-contracts/src/precompiles/ArbSys.sol";

interface IVerifierProxy {
Expand All @@ -15,7 +15,7 @@ interface IVerifierProxy {
function verify(bytes memory signedReport) external returns (bytes memory verifierResponse);
}

contract LogTriggeredFeedLookup is ILogAutomation, FeedLookupCompatibleInterface {
contract LogTriggeredStreamsLookup is ILogAutomation, StreamsLookupCompatibleInterface {
event PerformingLogTriggerUpkeep(
address indexed from,
uint256 orderId,
Expand Down Expand Up @@ -74,7 +74,7 @@ contract LogTriggeredFeedLookup is ILogAutomation, FeedLookupCompatibleInterface
bytes memory t3 = abi.encodePacked(log.topics[3]);
address exchange = abi.decode(t3, (address));

revert FeedLookup(feedParamKey, feedsHex, timeParamKey, blockNum, abi.encode(orderId, amount, exchange));
revert StreamsLookup(feedParamKey, feedsHex, timeParamKey, blockNum, abi.encode(orderId, amount, exchange));
}
revert("could not find matching event sig");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pragma solidity 0.8.16;

import "../automation/interfaces/AutomationCompatibleInterface.sol";
import "../dev/automation/2_1/interfaces/FeedLookupCompatibleInterface.sol";
import "../dev/automation/2_1/interfaces/StreamsLookupCompatibleInterface.sol";
import {ArbSys} from "../vendor/@arbitrum/nitro-contracts/src/precompiles/ArbSys.sol";

interface IVerifierProxy {
Expand All @@ -14,7 +14,7 @@ interface IVerifierProxy {
function verify(bytes memory signedReport) external returns (bytes memory verifierResponse);
}

contract MercuryUpkeep is AutomationCompatibleInterface, FeedLookupCompatibleInterface {
contract StreamsLookupUpkeep is AutomationCompatibleInterface, StreamsLookupCompatibleInterface {
event MercuryPerformEvent(
address indexed sender,
uint256 indexed blockNumber,
Expand Down Expand Up @@ -107,7 +107,7 @@ contract MercuryUpkeep is AutomationCompatibleInterface, FeedLookupCompatibleInt
}
// encode ARB_SYS as extraData to verify that it is provided to checkCallback correctly.
// in reality, this can be any data or empty
revert FeedLookup(feedParamKey, feeds, timeParamKey, blockNumber, abi.encodePacked(address(ARB_SYS)));
revert StreamsLookup(feedParamKey, feeds, timeParamKey, blockNumber, abi.encodePacked(address(ARB_SYS)));
}

function performUpkeep(bytes calldata performData) external {
Expand Down
6 changes: 3 additions & 3 deletions contracts/src/v0.8/tests/VerifiableLoadLogTriggerUpkeep.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ pragma solidity 0.8.16;

import "./VerifiableLoadBase.sol";
import "../dev/automation/2_1/interfaces/ILogAutomation.sol";
import "../dev/automation/2_1/interfaces/FeedLookupCompatibleInterface.sol";
import "../dev/automation/2_1/interfaces/StreamsLookupCompatibleInterface.sol";

contract VerifiableLoadLogTriggerUpkeep is VerifiableLoadBase, FeedLookupCompatibleInterface, ILogAutomation {
contract VerifiableLoadLogTriggerUpkeep is VerifiableLoadBase, StreamsLookupCompatibleInterface, ILogAutomation {
bool public useMercury;
uint8 public logNum;

Expand Down Expand Up @@ -55,7 +55,7 @@ contract VerifiableLoadLogTriggerUpkeep is VerifiableLoadBase, FeedLookupCompati
}

if (useMercury) {
revert FeedLookup(feedParamKey, feedsHex, timeParamKey, blockNum, abi.encode(upkeepId, blockNum, addr));
revert StreamsLookup(feedParamKey, feedsHex, timeParamKey, blockNum, abi.encode(upkeepId, blockNum, addr));
}

// if we don't use mercury, create a perform data which resembles the output of checkCallback
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
pragma solidity 0.8.16;

import "./VerifiableLoadBase.sol";
import "../dev/automation/2_1/interfaces/FeedLookupCompatibleInterface.sol";
import "../dev/automation/2_1/interfaces/StreamsLookupCompatibleInterface.sol";

contract VerifiableLoadMercuryUpkeep is VerifiableLoadBase, FeedLookupCompatibleInterface {
contract VerifiableLoadStreamsLookupUpkeep is VerifiableLoadBase, StreamsLookupCompatibleInterface {
constructor(AutomationRegistrar2_1 _registrar, bool _useArb) VerifiableLoadBase(_registrar, _useArb) {}

function checkCallback(
Expand Down Expand Up @@ -34,7 +34,7 @@ contract VerifiableLoadMercuryUpkeep is VerifiableLoadBase, FeedLookupCompatible
return (false, pData);
}

revert FeedLookup(feedParamKey, feedsHex, timeParamKey, blockNum, abi.encode(upkeepId));
revert StreamsLookup(feedParamKey, feedsHex, timeParamKey, blockNum, abi.encode(upkeepId));
}

function performUpkeep(bytes calldata performData) external {
Expand Down
68 changes: 35 additions & 33 deletions contracts/test/v0.8/automation/KeeperRegistry2_1.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { evmRevert } from '../../test-helpers/matchers'
import { getUsers, Personas } from '../../test-helpers/setup'
import { randomAddress, toWei } from '../../test-helpers/helpers'
import { LinkToken__factory as LinkTokenFactory } from '../../../typechain/factories/LinkToken__factory'
import { MercuryUpkeep__factory as MercuryUpkeepFactory } from '../../../typechain/factories/MercuryUpkeep__factory'
import { StreamsLookupUpkeep__factory as StreamsLookupUpkeepFactory } from '../../../typechain/factories/StreamsLookupUpkeep__factory'
import { MockV3Aggregator__factory as MockV3AggregatorFactory } from '../../../typechain/factories/MockV3Aggregator__factory'
import { UpkeepMock__factory as UpkeepMockFactory } from '../../../typechain/factories/UpkeepMock__factory'
import { UpkeepAutoFunder__factory as UpkeepAutoFunderFactory } from '../../../typechain/factories/UpkeepAutoFunder__factory'
Expand All @@ -28,7 +28,7 @@ import { KeeperRegistryLogicB2_1__factory as KeeperRegistryLogicBFactory } from
import { AutomationForwarderLogic__factory as AutomationForwarderLogicFactory } from '../../../typechain/factories/AutomationForwarderLogic__factory'
import { MockArbSys__factory as MockArbSysFactory } from '../../../typechain/factories/MockArbSys__factory'
import { AutomationUtils2_1 as AutomationUtils } from '../../../typechain/AutomationUtils2_1'
import { MercuryUpkeep } from '../../../typechain/MercuryUpkeep'
import { StreamsLookupUpkeep } from '../../../typechain/StreamsLookupUpkeep'
import { MockV3Aggregator } from '../../../typechain/MockV3Aggregator'
import { LinkToken } from '../../../typechain/LinkToken'
import { UpkeepMock } from '../../../typechain/UpkeepMock'
Expand Down Expand Up @@ -181,7 +181,7 @@ let upkeepMockFactory: UpkeepMockFactory
let upkeepAutoFunderFactory: UpkeepAutoFunderFactory
let mockArbGasInfoFactory: MockArbGasInfoFactory
let mockOVMGasPriceOracleFactory: MockOVMGasPriceOracleFactory
let mercuryUpkeepFactory: MercuryUpkeepFactory
let streamsLookupUpkeepFactory: StreamsLookupUpkeepFactory
let personas: Personas

// contracts
Expand All @@ -199,7 +199,7 @@ let ltUpkeep: MockContract
let transcoder: UpkeepTranscoder
let mockArbGasInfo: MockArbGasInfo
let mockOVMGasPriceOracle: MockOVMGasPriceOracle
let mercuryUpkeep: MercuryUpkeep
let streamsLookupUpkeep: StreamsLookupUpkeep
let automationUtils: AutomationUtils

function now() {
Expand Down Expand Up @@ -450,7 +450,7 @@ describe('KeeperRegistry2_1', () => {
let upkeepId: BigNumber // conditional upkeep
let afUpkeepId: BigNumber // auto funding upkeep
let logUpkeepId: BigNumber // log trigger upkeepID
let mercuryUpkeepId: BigNumber // mercury upkeep
let streamsLookupUpkeepId: BigNumber // streams lookup upkeep
const numUpkeeps = 4 // see above
let keeperAddresses: string[]
let payees: string[]
Expand Down Expand Up @@ -481,7 +481,9 @@ describe('KeeperRegistry2_1', () => {
mockOVMGasPriceOracleFactory = await ethers.getContractFactory(
'MockOVMGasPriceOracle',
)
mercuryUpkeepFactory = await ethers.getContractFactory('MercuryUpkeep')
streamsLookupUpkeepFactory = await ethers.getContractFactory(
'StreamsLookupUpkeep',
)

owner = personas.Default
keeper1 = personas.Carol
Expand Down Expand Up @@ -703,17 +705,17 @@ describe('KeeperRegistry2_1', () => {
const verifyConsistentAccounting = async (
maxAllowedSpareChange: BigNumber,
) => {
let expectedLinkBalance = (await registry.getState()).state
const expectedLinkBalance = (await registry.getState()).state
.expectedLinkBalance
let linkTokenBalance = await linkToken.balanceOf(registry.address)
let upkeepIdBalance = (await registry.getUpkeep(upkeepId)).balance
const linkTokenBalance = await linkToken.balanceOf(registry.address)
const upkeepIdBalance = (await registry.getUpkeep(upkeepId)).balance
let totalKeeperBalance = BigNumber.from(0)
for (let i = 0; i < keeperAddresses.length; i++) {
totalKeeperBalance = totalKeeperBalance.add(
(await registry.getTransmitterInfo(keeperAddresses[i])).balance,
)
}
let ownerBalance = (await registry.getState()).state.ownerLinkBalance
const ownerBalance = (await registry.getState()).state.ownerLinkBalance
assert.isTrue(expectedLinkBalance.eq(linkTokenBalance))
assert.isTrue(
upkeepIdBalance
Expand Down Expand Up @@ -864,7 +866,7 @@ describe('KeeperRegistry2_1', () => {
mockOVMGasPriceOracle = await mockOVMGasPriceOracleFactory
.connect(owner)
.deploy()
mercuryUpkeep = await mercuryUpkeepFactory
streamsLookupUpkeep = await streamsLookupUpkeepFactory
.connect(owner)
.deploy(
BigNumber.from('10000'),
Expand Down Expand Up @@ -1032,23 +1034,23 @@ describe('KeeperRegistry2_1', () => {
tx = await registry
.connect(owner)
['registerUpkeep(address,uint32,address,bytes,bytes)'](
mercuryUpkeep.address,
streamsLookupUpkeep.address,
performGas,
await admin.getAddress(),
randomBytes,
'0x',
)
mercuryUpkeepId = await getUpkeepID(tx)
streamsLookupUpkeepId = await getUpkeepID(tx)
}

const getMultipleUpkeepsDeployedAndFunded = async (
numPassingConditionalUpkeeps: number,
numPassingLogUpkeeps: number,
numFailingUpkeeps: number,
) => {
let passingConditionalUpkeepIds = []
let passingLogUpkeepIds = []
let failingUpkeepIds = []
const passingConditionalUpkeepIds = []
const passingLogUpkeepIds = []
const failingUpkeepIds = []
for (let i = 0; i < numPassingConditionalUpkeeps; i++) {
const mock = await upkeepMockFactory.deploy()
await mock.setCanPerform(true)
Expand Down Expand Up @@ -2167,15 +2169,15 @@ describe('KeeperRegistry2_1', () => {
numFailingUpkeeps +
'] performs successful upkeeps and does not charge failing upkeeps',
async () => {
let allUpkeeps = await getMultipleUpkeepsDeployedAndFunded(
const allUpkeeps = await getMultipleUpkeepsDeployedAndFunded(
numPassingConditionalUpkeeps,
numPassingLogUpkeeps,
numFailingUpkeeps,
)
let passingConditionalUpkeepIds =
const passingConditionalUpkeepIds =
allUpkeeps.passingConditionalUpkeepIds
let passingLogUpkeepIds = allUpkeeps.passingLogUpkeepIds
let failingUpkeepIds = allUpkeeps.failingUpkeepIds
const passingLogUpkeepIds = allUpkeeps.passingLogUpkeepIds
const failingUpkeepIds = allUpkeeps.failingUpkeepIds

const keeperBefore = await registry.getTransmitterInfo(
await keeper1.getAddress(),
Expand Down Expand Up @@ -2394,15 +2396,15 @@ describe('KeeperRegistry2_1', () => {
numFailingUpkeeps +
'] splits gas overhead appropriately among performed upkeeps [ @skip-coverage ]',
async () => {
let allUpkeeps = await getMultipleUpkeepsDeployedAndFunded(
const allUpkeeps = await getMultipleUpkeepsDeployedAndFunded(
numPassingConditionalUpkeeps,
numPassingLogUpkeeps,
numFailingUpkeeps,
)
let passingConditionalUpkeepIds =
const passingConditionalUpkeepIds =
allUpkeeps.passingConditionalUpkeepIds
let passingLogUpkeepIds = allUpkeeps.passingLogUpkeepIds
let failingUpkeepIds = allUpkeeps.failingUpkeepIds
const passingLogUpkeepIds = allUpkeeps.passingLogUpkeepIds
const failingUpkeepIds = allUpkeeps.failingUpkeepIds

// Perform the upkeeps once to remove non-zero storage slots and have predictable gas measurement
let tx = await getTransmitTx(
Expand Down Expand Up @@ -3334,7 +3336,7 @@ describe('KeeperRegistry2_1', () => {
expect(upkeepIds).to.deep.equal([
afUpkeepId,
logUpkeepId,
mercuryUpkeepId,
streamsLookupUpkeepId,
])
})

Expand Down Expand Up @@ -5476,12 +5478,12 @@ describe('KeeperRegistry2_1', () => {

describe('#checkCallback', () => {
it('returns false with appropriate failure reason when target callback reverts', async () => {
await mercuryUpkeep.setShouldRevertCallback(true)
await streamsLookupUpkeep.setShouldRevertCallback(true)

const values: any[] = ['0x1234', '0xabcd']
const res = await registry
.connect(zeroAddress)
.callStatic.checkCallback(mercuryUpkeepId, values, '0x')
.callStatic.checkCallback(streamsLookupUpkeepId, values, '0x')

assert.isFalse(res.upkeepNeeded)
assert.equal(res.performData, '0x')
Expand All @@ -5500,7 +5502,7 @@ describe('KeeperRegistry2_1', () => {
const values: any[] = [longBytes, longBytes]
const res = await registry
.connect(zeroAddress)
.callStatic.checkCallback(mercuryUpkeepId, values, '0x')
.callStatic.checkCallback(streamsLookupUpkeepId, values, '0x')

assert.isFalse(res.upkeepNeeded)
assert.equal(res.performData, '0x')
Expand All @@ -5512,11 +5514,11 @@ describe('KeeperRegistry2_1', () => {
})

it('returns false with appropriate failure reason when target callback returns false', async () => {
await mercuryUpkeep.setCallbackReturnBool(false)
await streamsLookupUpkeep.setCallbackReturnBool(false)
const values: any[] = ['0x1234', '0xabcd']
const res = await registry
.connect(zeroAddress)
.callStatic.checkCallback(mercuryUpkeepId, values, '0x')
.callStatic.checkCallback(streamsLookupUpkeepId, values, '0x')

assert.isFalse(res.upkeepNeeded)
assert.equal(res.performData, '0x')
Expand All @@ -5532,7 +5534,7 @@ describe('KeeperRegistry2_1', () => {

const res = await registry
.connect(zeroAddress)
.callStatic.checkCallback(mercuryUpkeepId, values, '0x')
.callStatic.checkCallback(streamsLookupUpkeepId, values, '0x')
const expectedPerformData = ethers.utils.defaultAbiCoder.encode(
['bytes[]', 'bytes'],
[values, '0x'],
Expand Down Expand Up @@ -5659,8 +5661,8 @@ describe('KeeperRegistry2_1', () => {
await getTransmitTx(registry, keeper1, [upkeepId])

const registryPremium = (await registry.getState()).state.totalPremium
let k1 = await registry.getTransmitterInfo(await keeper1.getAddress())
let k2 = await registry.getTransmitterInfo(await keeper2.getAddress())
const k1 = await registry.getTransmitterInfo(await keeper1.getAddress())
const k2 = await registry.getTransmitterInfo(await keeper2.getAddress())

// Withdrawing for first time, last collected = 0
assert.isTrue(k1.lastCollected.eq(BigNumber.from(0)))
Expand Down
Loading

0 comments on commit 98cb209

Please sign in to comment.