Skip to content

Commit

Permalink
rebase to latest and add chainmodule getter
Browse files Browse the repository at this point in the history
  • Loading branch information
shileiwill committed Feb 9, 2024
1 parent 4c04799 commit 2dae7dc
Show file tree
Hide file tree
Showing 10 changed files with 80 additions and 212 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,13 @@ contract AutomationRegistry2_2_LatestConfigDetails is AutomationRegistry2_2_SetU

contract AutomationRegistry2_2_CheckUpkeep is AutomationRegistry2_2_SetUp {
function testPreventExecutionOnCheckUpkeep() public {
IAutomationRegistryMaster registry = IAutomationRegistryMaster(
address(deployRegistry2_2(AutomationRegistryBase2_2.Mode(0)))
);

uint256 id = 1;
bytes memory triggerData = abi.encodePacked("trigger_data");

// The tx.origin is the DEFAULT_SENDER (0x1804c8AB1F12E6bbf3894d4083f33e07309d1f38) of foundry
// Expecting a revert since the tx.origin is not address(0)
vm.expectRevert(abi.encodeWithSelector(IAutomationRegistryMaster.OnlySimulatedBackend.selector));
registry.checkUpkeep(id, triggerData);
registryMaster.checkUpkeep(id, triggerData);
}
}

Expand Down
16 changes: 8 additions & 8 deletions contracts/src/v0.8/automation/dev/v2_2/AutomationRegistry2_2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ contract AutomationRegistry2_2 is AutomationRegistryBase2_2, OCR2Abstract, Chain
bytes32[3] calldata reportContext,
bytes calldata rawReport,
bytes32[] calldata rs,
bytes32[] memory ss,
bytes32[] calldata ss,
bytes32 rawVs
) external override {
uint256 gasOverhead = gasleft();
Expand All @@ -87,10 +87,14 @@ contract AutomationRegistry2_2 is AutomationRegistryBase2_2, OCR2Abstract, Chain
uint40 epochAndRound = uint40(uint256(reportContext[1]));
uint32 epoch = uint32(epochAndRound >> 8);

_handleReport(hotVars, report, gasOverhead, epoch);
_handleReport(hotVars, report, gasOverhead);

if (epoch > hotVars.latestEpoch) {
s_hotVars.latestEpoch = epoch;
}
}

function _handleReport(HotVars memory hotVars, Report memory report, uint256 gasOverhead, uint32 epoch) private {
function _handleReport(HotVars memory hotVars, Report memory report, uint256 gasOverhead) private {
UpkeepTransmitInfo[] memory upkeepTransmitInfo = new UpkeepTransmitInfo[](report.upkeepIds.length);
uint16 numUpkeepsPassedChecks;

Expand Down Expand Up @@ -142,7 +146,7 @@ contract AutomationRegistry2_2 is AutomationRegistryBase2_2, OCR2Abstract, Chain
// This is the overall gas overhead that will be split across performed upkeeps
// Take upper bound of 16 gas per callData bytes, which is approximated to be reportLength
// Rest of msg.data is accounted for in accounting overheads
// NOTE in process of changing acounting, so pre-emptively changed reportLength to msg.data.length
// NOTE in process of changing accounting, so pre-emptively changed reportLength to msg.data.length
gasOverhead =
(gasOverhead - gasleft() + 16 * msg.data.length) +
ACCOUNTING_FIXED_GAS_OVERHEAD +
Expand Down Expand Up @@ -188,10 +192,6 @@ contract AutomationRegistry2_2 is AutomationRegistryBase2_2, OCR2Abstract, Chain
// record payments
s_transmitters[msg.sender].balance += totalReimbursement;
s_hotVars.totalPremium += totalPremium;

if (epoch > hotVars.latestEpoch) {
s_hotVars.latestEpoch = epoch;
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ pragma solidity 0.8.19;

import {EnumerableSet} from "../../../vendor/openzeppelin-solidity/v4.7.3/contracts/utils/structs/EnumerableSet.sol";
import {Address} from "../../../vendor/openzeppelin-solidity/v4.7.3/contracts/utils/Address.sol";
import {ArbGasInfo} from "../../../vendor/@arbitrum/nitro-contracts/src/precompiles/ArbGasInfo.sol";
import {OVM_GasPriceOracle} from "../../../vendor/@eth-optimism/contracts/v0.8.9/contracts/L2/predeploys/OVM_GasPriceOracle.sol";
import {ArbSys} from "../../../vendor/@arbitrum/nitro-contracts/src/precompiles/ArbSys.sol";
import {StreamsLookupCompatibleInterface} from "../../interfaces/StreamsLookupCompatibleInterface.sol";
import {ILogAutomation, Log} from "../../interfaces/ILogAutomation.sol";
import {IAutomationForwarder} from "../../interfaces/IAutomationForwarder.sol";
Expand Down Expand Up @@ -847,7 +844,7 @@ abstract contract AutomationRegistryBase2_2 is ConfirmedOwner {
bytes32[3] calldata reportContext,
bytes calldata report,
bytes32[] calldata rs,
bytes32[] memory ss,
bytes32[] calldata ss,
bytes32 rawVs
) internal view {
bytes32 h = keccak256(abi.encode(keccak256(report), reportContext));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ contract AutomationRegistryLogicB2_2 is AutomationRegistryBase2_2 {
address fastGasFeed,
address automationForwarderLogic,
address allowedReadOnlyAddress
)
AutomationRegistryBase2_2(link, linkNativeFeed, fastGasFeed, automationForwarderLogic, allowedReadOnlyAddress)
{}
) AutomationRegistryBase2_2(link, linkNativeFeed, fastGasFeed, automationForwarderLogic, allowedReadOnlyAddress) {}

// ================================================================
// | UPKEEP MANAGEMENT |
Expand Down Expand Up @@ -455,6 +453,13 @@ contract AutomationRegistryLogicB2_2 is AutomationRegistryBase2_2 {
return (state, config, s_signersList, s_transmittersList, s_hotVars.f);
}

/**
* @notice get the chain module
*/
function getChainModule() external view returns (IChainModule chainModule) {
return s_hotVars.chainModule;
}

/**
* @notice if this registry has reorg protection enabled
*/
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Loading

0 comments on commit 2dae7dc

Please sign in to comment.