Skip to content

Commit

Permalink
use common interface for v2.3 (#12443)
Browse files Browse the repository at this point in the history
* use common interface for v2.3

* add changeset
  • Loading branch information
shileiwill authored Mar 18, 2024
1 parent 184a02e commit e604a73
Show file tree
Hide file tree
Showing 12 changed files with 240 additions and 370 deletions.
5 changes: 5 additions & 0 deletions .changeset/shy-jobs-speak.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": patch
---

use common interface for v2.3
5 changes: 5 additions & 0 deletions contracts/.changeset/three-spoons-clean.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@chainlink/contracts": patch
---

use common interface for v2.3

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -192,48 +192,6 @@ abstract contract AutomationRegistryBase2_3 is ConfirmedOwner {
REGISTRY_PAUSED
}

/**
* @notice OnchainConfigLegacy of the registry
* @dev only used in params and return values
* @member paymentPremiumPPB payment premium rate oracles receive on top of
* being reimbursed for gas, measured in parts per billion
* @member flatFeeMicroLink flat fee paid to oracles for performing upkeeps,
* priced in MicroLink; can be used in conjunction with or independently of
* paymentPremiumPPB
* @member checkGasLimit gas limit when checking for upkeep
* @member stalenessSeconds number of seconds that is allowed for feed data to
* be stale before switching to the fallback pricing
* @member gasCeilingMultiplier multiplier to apply to the fast gas feed price
* when calculating the payment ceiling for keepers
* @member minUpkeepSpend minimum LINK that an upkeep must spend before cancelling
* @member maxPerformGas max performGas allowed for an upkeep on this registry
* @member maxCheckDataSize max length of checkData bytes
* @member maxPerformDataSize max length of performData bytes
* @member maxRevertDataSize max length of revertData bytes
* @member fallbackGasPrice gas price used if the gas price feed is stale
* @member fallbackLinkPrice LINK price used if the LINK price feed is stale
* @member transcoder address of the transcoder contract
* @member registrars addresses of the registrar contracts
* @member upkeepPrivilegeManager address which can set privilege for upkeeps
*/
struct OnchainConfigLegacy {
uint32 paymentPremiumPPB;
uint32 flatFeeMicroLink; // min 0.000001 LINK, max 4294 LINK
uint32 checkGasLimit;
uint24 stalenessSeconds;
uint16 gasCeilingMultiplier;
uint96 minUpkeepSpend;
uint32 maxPerformGas;
uint32 maxCheckDataSize;
uint32 maxPerformDataSize;
uint32 maxRevertDataSize;
uint256 fallbackGasPrice;
uint256 fallbackLinkPrice;
address transcoder;
address[] registrars;
address upkeepPrivilegeManager;
}

/**
* @notice OnchainConfig of the registry
* @dev used only in setConfig()
Expand Down Expand Up @@ -282,33 +240,6 @@ abstract contract AutomationRegistryBase2_3 is ConfirmedOwner {
address financeAdmin; // TODO: pack this struct better
}

/**
* @notice state of the registry
* @dev only used in params and return values
* @dev this will likely be deprecated in a future version of the registry in favor of individual getters
* @member nonce used for ID generation
* @member expectedLinkBalance the expected balance of LINK of the registry
* @member totalPremium the total premium collected on registry so far
* @member numUpkeeps total number of upkeeps on the registry
* @member configCount ordinal number of current config, out of all configs applied to this contract so far
* @member latestConfigBlockNumber last block at which this config was set
* @member latestConfigDigest domain-separation tag for current config
* @member latestEpoch for which a report was transmitted
* @member paused freeze on execution scoped to the entire registry
*/
struct State {
uint32 nonce;
uint96 ownerLinkBalance;
uint256 expectedLinkBalance;
uint96 totalPremium;
uint256 numUpkeeps;
uint32 configCount;
uint32 latestConfigBlockNumber;
bytes32 latestConfigDigest;
uint32 latestEpoch;
bool paused;
}

/**
* @notice relevant state of an upkeep which is used in transmit function
* @member paused if this upkeep has been paused
Expand All @@ -331,34 +262,6 @@ abstract contract AutomationRegistryBase2_3 is ConfirmedOwner {
// 2 bytes left in 2nd EVM word - written in transmit path
}

/**
* @notice all information about an upkeep
* @dev only used in return values
* @dev this will likely be deprecated in a future version of the registry
* @member target the contract which needs to be serviced
* @member performGas the gas limit of upkeep execution
* @member checkData the checkData bytes for this upkeep
* @member balance the balance of this upkeep
* @member admin for this upkeep
* @member maxValidBlocknumber until which block this upkeep is valid
* @member lastPerformedBlockNumber the last block number when this upkeep was performed
* @member amountSpent the amount this upkeep has spent
* @member paused if this upkeep has been paused
* @member offchainConfig the off-chain config of this upkeep
*/
struct UpkeepInfo {
address target;
uint32 performGas;
bytes checkData;
uint96 balance;
address admin;
uint64 maxValidBlocknumber;
uint32 lastPerformedBlockNumber;
uint96 amountSpent;
bool paused;
bytes offchainConfig;
}

/// @dev Config + State storage struct which is on hot transmit path
struct HotVars {
uint96 totalPremium; // ─────────╮ total historical payment to oracles for premium
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {UpkeepFormat} from "../../interfaces/UpkeepTranscoderInterface.sol";
import {IAutomationForwarder} from "../../interfaces/IAutomationForwarder.sol";
import {IChainModule} from "../../interfaces/IChainModule.sol";
import {IERC20} from "../../../vendor/openzeppelin-solidity/v4.8.3/contracts/token/ERC20/IERC20.sol";
import {IAutomationV21PlusCommon} from "../../interfaces/IAutomationV21PlusCommon.sol";

contract AutomationRegistryLogicB2_3 is AutomationRegistryBase2_3 {
using Address for address;
Expand Down Expand Up @@ -359,10 +360,10 @@ contract AutomationRegistryLogicB2_3 is AutomationRegistryBase2_3 {
* @dev this function may be deprecated in a future version of automation in favor of individual
* getters for each field
*/
function getUpkeep(uint256 id) external view returns (UpkeepInfo memory upkeepInfo) {
function getUpkeep(uint256 id) external view returns (IAutomationV21PlusCommon.UpkeepInfoLegacy memory upkeepInfo) {
Upkeep memory reg = s_upkeep[id];
address target = address(reg.forwarder) == address(0) ? address(0) : reg.forwarder.getTarget();
upkeepInfo = UpkeepInfo({
upkeepInfo = IAutomationV21PlusCommon.UpkeepInfoLegacy({
target: target,
performGas: reg.performGas,
checkData: s_checkData[id],
Expand Down Expand Up @@ -449,14 +450,14 @@ contract AutomationRegistryLogicB2_3 is AutomationRegistryBase2_3 {
external
view
returns (
State memory state,
OnchainConfigLegacy memory config,
IAutomationV21PlusCommon.StateLegacy memory state,
IAutomationV21PlusCommon.OnchainConfigLegacy memory config,
address[] memory signers,
address[] memory transmitters,
uint8 f
)
{
state = State({
state = IAutomationV21PlusCommon.StateLegacy({
nonce: s_storage.nonce,
ownerLinkBalance: 0,
expectedLinkBalance: s_reserveAmounts[address(i_link)],
Expand All @@ -469,7 +470,7 @@ contract AutomationRegistryLogicB2_3 is AutomationRegistryBase2_3 {
paused: s_hotVars.paused
});

config = OnchainConfigLegacy({
config = IAutomationV21PlusCommon.OnchainConfigLegacy({
paymentPremiumPPB: s_hotVars.paymentPremiumPPB,
flatFeeMicroLink: s_hotVars.flatFeeMicroLink,
checkGasLimit: s_storage.checkGasLimit,
Expand Down
29 changes: 1 addition & 28 deletions contracts/src/v0.8/automation/dev/v2_3/AutomationUtils2_3.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,16 @@
pragma solidity 0.8.19;

import {AutomationRegistryBase2_3} from "./AutomationRegistryBase2_3.sol";
import {Log} from "../../interfaces/ILogAutomation.sol";

/**
* @notice this file exposes structs that are otherwise internal to the automation registry
* doing this allows those structs to be encoded and decoded with type safety in offchain code
* and tests because generated wrappers are made available
*/

/**
* @notice structure of trigger for log triggers
*/
struct LogTriggerConfig {
address contractAddress;
uint8 filterSelector; // denotes which topics apply to filter ex 000, 101, 111...only last 3 bits apply
bytes32 topic0;
bytes32 topic1;
bytes32 topic2;
bytes32 topic3;
}

contract AutomationUtils2_3 {
/**
* @dev this can be removed as OnchainConfig is now exposed directly from the registry
* @dev this uses the v2.3 Report, which uses linkUSD instead of linkNative (as in v2.2 and prior). This should be used only in typescript tests.
*/
function _onChainConfig(
AutomationRegistryBase2_3.OnchainConfig memory,
address[] memory,
AutomationRegistryBase2_3.BillingConfig[] memory
) external {}

function _report(AutomationRegistryBase2_3.Report memory) external {} // 0xe65d6546

function _logTriggerConfig(LogTriggerConfig memory) external {} // 0x21f373d7

function _logTrigger(AutomationRegistryBase2_3.LogTrigger memory) external {} // 0x1c8d8260

function _conditionalTrigger(AutomationRegistryBase2_3.ConditionalTrigger memory) external {} // 0x4b6df294

function _log(Log memory) external {} // 0xe9720a49
}
Loading

0 comments on commit e604a73

Please sign in to comment.