Skip to content

Commit

Permalink
Merge branch 'feat/DEPLOY-295-l2ep-refactoring' of github.com:smartco…
Browse files Browse the repository at this point in the history
…ntractkit/chainlink into feat/DEPLOY-295-l2ep-refactoring
  • Loading branch information
chris-de-leon-cll committed Feb 7, 2024
2 parents e841c8a + ac26d09 commit b89490e
Show file tree
Hide file tree
Showing 24 changed files with 329 additions and 94 deletions.
62 changes: 30 additions & 32 deletions .github/workflows/client-compatibility-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ jobs:
ref: ${{ github.event.pull_request.head.sha || github.event.merge_group.head_sha }}
- name: Build Chainlink Image
uses: ./.github/actions/build-chainlink-image
with:
with:
tag_suffix: ""
dockerfile: core/chainlink.Dockerfile
git_commit_sha: ${{ github.sha }}
GRAFANA_CLOUD_BASIC_AUTH: ${{ secrets.GRAFANA_CLOUD_BASIC_AUTH }}
GRAFANA_CLOUD_HOST: ${{ secrets.GRAFANA_CLOUD_HOST }}
AWS_REGION: ${{ secrets.QA_AWS_REGION }}
AWS_ROLE_TO_ASSUME: ${{ secrets.QA_AWS_ROLE_TO_ASSUME }}

build-tests:
environment: integration
permissions:
Expand Down Expand Up @@ -102,51 +102,49 @@ jobs:
file: ocr
client: geth
timeout: 30m
pyroscope_env: ci-smoke-ocr-geth-simulated
# Uncomment, when https://smartcontract-it.atlassian.net/browse/TT-753 is DONE
# - name: ocr-nethermind
# test: TestOCRBasic
# file: ocr
# client: nethermind
# timeout: 30m
# pyroscope_env: ci-smoke-ocr-nethermind-simulated
pyroscope_env: ci-smoke-ocr-geth-simulated
- name: ocr-nethermind
test: TestOCRBasic
file: ocr
client: nethermind
timeout: 30m
pyroscope_env: ci-smoke-ocr-nethermind-simulated
- name: ocr-besu
test: TestOCRBasic
file: ocr
client: besu
timeout: 30m
pyroscope_env: ci-smoke-ocr-besu-simulated
pyroscope_env: ci-smoke-ocr-besu-simulated
- name: ocr-erigon
test: TestOCRBasic
file: ocr
client: erigon
timeout: 30m
pyroscope_env: ci-smoke-ocr-erigon-simulated
pyroscope_env: ci-smoke-ocr-erigon-simulated
- name: ocr2-geth
test: TestOCRv2Basic
test: "^TestOCRv2Basic/plugins$"
file: ocr2
client: geth
timeout: 30m
pyroscope_env: ci-smoke-ocr2-geth-simulated
# Uncomment, when https://smartcontract-it.atlassian.net/browse/TT-753 is DONE
# - name: ocr2-nethermind
# test: TestOCRv2Basic
# file: ocr2
# client: nethermind
# timeout: 30m
# pyroscope_env: ci-smoke-nethermind-evm-simulated
pyroscope_env: ci-smoke-ocr2-geth-simulated
- name: ocr2-nethermind
test: "^TestOCRv2Basic/plugins$"
file: ocr2
client: nethermind
timeout: 30m
pyroscope_env: ci-smoke-nethermind-evm-simulated
- name: ocr2-besu
test: TestOCRv2Basic
test: "^TestOCRv2Basic/plugins$"
file: ocr2
client: besu
timeout: 30m
pyroscope_env: ci-smoke-ocr2-besu-simulated
timeout: 30m
pyroscope_env: ci-smoke-ocr2-besu-simulated
- name: ocr2-erigon
test: TestOCRv2Basic
test: "^TestOCRv2Basic/plugins$"
file: ocr2
client: erigon
timeout: 60m
pyroscope_env: ci-smoke-ocr2-erigon-simulated
pyroscope_env: ci-smoke-ocr2-erigon-simulated
runs-on: ubuntu-latest
name: Client Compatibility Test ${{ matrix.name }}
steps:
Expand Down Expand Up @@ -175,8 +173,8 @@ jobs:
toml_array_format="${toml_array_format%,}]"
echo "$toml_array_format"
}
selected_networks=$(convert_to_toml_array "$SELECTED_NETWORKS")
selected_networks=$(convert_to_toml_array "$SELECTED_NETWORKS")
if [ -n "$ETH2_EL_CLIENT" ]; then
execution_layer="$ETH2_EL_CLIENT"
Expand All @@ -188,12 +186,12 @@ jobs:
pyroscope_enabled=true
else
pyroscope_enabled=false
fi
fi
cat << EOF > config.toml
[Network]
selected_networks=$selected_networks
[ChainlinkImage]
image="$CHAINLINK_IMAGE"
version="$CHAINLINK_VERSION"
Expand All @@ -218,7 +216,7 @@ jobs:
slots_per_epoch=2
addresses_to_fund=["0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266"]
EOF
BASE64_CONFIG_OVERRIDE=$(cat config.toml | base64 -w 0)
echo ::add-mask::$BASE64_CONFIG_OVERRIDE
echo "BASE64_CONFIG_OVERRIDE=$BASE64_CONFIG_OVERRIDE" >> $GITHUB_ENV
Expand All @@ -240,7 +238,7 @@ jobs:
QA_AWS_REGION: ${{ secrets.QA_AWS_REGION }}
QA_AWS_ROLE_TO_ASSUME: ${{ secrets.QA_AWS_ROLE_TO_ASSUME }}
QA_KUBECONFIG: ${{ secrets.QA_KUBECONFIG }}

start-slack-thread:
name: Start Slack Thread
if: ${{ always() && needs.*.result != 'skipped' && needs.*.result != 'cancelled' }}
Expand Down
8 changes: 4 additions & 4 deletions contracts/src/v0.8/automation/dev/MercuryRegistry.sol
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
pragma solidity 0.8.6;

import "../../shared/access/ConfirmedOwner.sol";
import "../interfaces/AutomationCompatibleInterface.sol";
import "../interfaces/StreamsLookupCompatibleInterface.sol";
import "../../ChainSpecificUtil.sol";
import {ConfirmedOwner} from "../../shared/access/ConfirmedOwner.sol";
import {AutomationCompatibleInterface} from "../interfaces/AutomationCompatibleInterface.sol";
import {StreamsLookupCompatibleInterface} from "../interfaces/StreamsLookupCompatibleInterface.sol";
import {ChainSpecificUtil} from "../../ChainSpecificUtil.sol";

/*--------------------------------------------------------------------------------------------------------------------+
| Mercury + Automation |
Expand Down
16 changes: 8 additions & 8 deletions contracts/src/v0.8/automation/dev/MercuryRegistryBatchUpkeep.sol
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
pragma solidity 0.8.6;

import "../../shared/access/ConfirmedOwner.sol";
import "../interfaces/AutomationCompatibleInterface.sol";
import "../interfaces/StreamsLookupCompatibleInterface.sol";
import "./MercuryRegistry.sol";
import {ConfirmedOwner} from "../../shared/access/ConfirmedOwner.sol";
import {AutomationCompatibleInterface} from "../interfaces/AutomationCompatibleInterface.sol";
import {StreamsLookupCompatibleInterface} from "../interfaces/StreamsLookupCompatibleInterface.sol";
import {MercuryRegistry} from "./MercuryRegistry.sol";

contract MercuryRegistryBatchUpkeep is ConfirmedOwner, AutomationCompatibleInterface, StreamsLookupCompatibleInterface {
error BatchSizeTooLarge(uint256 batchsize, uint256 maxBatchSize);
// Use a reasonable maximum batch size. Every Mercury report is ~750 bytes, too many reports
// passed into a single batch could exceed the calldata or transaction size limit for some blockchains.
uint256 constant MAX_BATCH_SIZE = 50;
uint256 public constant MAX_BATCH_SIZE = 50;

MercuryRegistry immutable i_registry; // master registry, where feed data is stored
MercuryRegistry public immutable i_registry; // master registry, where feed data is stored

uint256 s_batchStart; // starting index of upkeep batch on the MercuryRegistry's s_feeds array, inclusive
uint256 s_batchEnd; // ending index of upkeep batch on the MercuryRegistry's s_feeds array, exclusive
uint256 public s_batchStart; // starting index of upkeep batch on the MercuryRegistry's s_feeds array, inclusive
uint256 public s_batchEnd; // ending index of upkeep batch on the MercuryRegistry's s_feeds array, exclusive

constructor(address mercuryRegistry, uint256 batchStart, uint256 batchEnd) ConfirmedOwner(msg.sender) {
i_registry = MercuryRegistry(mercuryRegistry);
Expand Down

Large diffs are not rendered by default.

189 changes: 189 additions & 0 deletions contracts/src/v0.8/automation/dev/test/AutomationRegistry2_2.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.16;

import {AutomationForwarderLogic} from "../../AutomationForwarderLogic.sol";
import {BaseTest} from "./BaseTest.t.sol";
import {AutomationRegistry2_2} from "../v2_2/AutomationRegistry2_2.sol";
import {AutomationRegistryBase2_2} from "../v2_2/AutomationRegistryBase2_2.sol";
import {AutomationRegistryLogicA2_2} from "../v2_2/AutomationRegistryLogicA2_2.sol";
import {AutomationRegistryLogicB2_2} from "../v2_2/AutomationRegistryLogicB2_2.sol";
import {IAutomationRegistryMaster} from "../interfaces/v2_2/IAutomationRegistryMaster.sol";

contract AutomationRegistry2_2_SetUp is BaseTest {
address internal constant LINK_ETH_FEED = 0x1111111111111111111111111111111111111110;
address internal constant FAST_GAS_FEED = 0x1111111111111111111111111111111111111112;
address internal constant LINK_TOKEN = 0x1111111111111111111111111111111111111113;

// Signer private keys used for these test
uint256 internal constant PRIVATE0 = 0x7b2e97fe057e6de99d6872a2ef2abf52c9b4469bc848c2465ac3fcd8d336e81d;
uint256 internal constant PRIVATE1 = 0xab56160806b05ef1796789248e1d7f34a6465c5280899159d645218cd216cee6;
uint256 internal constant PRIVATE2 = 0x6ec7caa8406a49b76736602810e0a2871959fbbb675e23a8590839e4717f1f7f;
uint256 internal constant PRIVATE3 = 0x80f14b11da94ae7f29d9a7713ea13dc838e31960a5c0f2baf45ed458947b730a;

uint64 internal constant OFFCHAIN_CONFIG_VERSION = 30; // 2 for OCR2
uint8 internal constant F = 1;

address[] internal s_valid_signers;
address[] internal s_valid_transmitters;
address[] internal s_registrars;

function setUp() public override {
s_valid_transmitters = new address[](4);
for (uint160 i = 0; i < 4; ++i) {
s_valid_transmitters[i] = address(4 + i);
}

s_valid_signers = new address[](4);
s_valid_signers[0] = vm.addr(PRIVATE0); //0xc110458BE52CaA6bB68E66969C3218A4D9Db0211
s_valid_signers[1] = vm.addr(PRIVATE1); //0xc110a19c08f1da7F5FfB281dc93630923F8E3719
s_valid_signers[2] = vm.addr(PRIVATE2); //0xc110fdF6e8fD679C7Cc11602d1cd829211A18e9b
s_valid_signers[3] = vm.addr(PRIVATE3); //0xc11028017c9b445B6bF8aE7da951B5cC28B326C0

s_registrars = new address[](1);
s_registrars[0] = 0x3a0eDE26aa188BFE00b9A0C9A431A1a0CA5f7966;
}

function deployRegistry2_2(AutomationRegistryBase2_2.Mode mode) public returns (IAutomationRegistryMaster) {
AutomationForwarderLogic forwarderLogic = new AutomationForwarderLogic();
AutomationRegistryLogicB2_2 logicB2_2 = new AutomationRegistryLogicB2_2(
mode,
LINK_TOKEN,
LINK_ETH_FEED,
FAST_GAS_FEED,
address(forwarderLogic)
);
AutomationRegistryLogicA2_2 logicA2_2 = new AutomationRegistryLogicA2_2(logicB2_2);
IAutomationRegistryMaster registry2_2 = IAutomationRegistryMaster(
address(new AutomationRegistry2_2(AutomationRegistryLogicB2_2(address(logicA2_2))))
);
return registry2_2;
}
}

contract AutomationRegistry2_2_LatestConfigDetails is AutomationRegistry2_2_SetUp {
function testGet() public {
IAutomationRegistryMaster registry = IAutomationRegistryMaster(
address(deployRegistry2_2(AutomationRegistryBase2_2.Mode(0)))
);
(uint32 configCount, uint32 blockNumber, bytes32 configDigest) = registry.latestConfigDetails();
assertEq(configCount, 0);
assertEq(blockNumber, 0);
assertEq(configDigest, "");
}
}

contract AutomationRegistry2_2_SetConfig is AutomationRegistry2_2_SetUp {
event ConfigSet(
uint32 previousConfigBlockNumber,
bytes32 configDigest,
uint64 configCount,
address[] signers,
address[] transmitters,
uint8 f,
bytes onchainConfig,
uint64 offchainConfigVersion,
bytes offchainConfig
);

function testSetConfigSuccess() public {
IAutomationRegistryMaster registry = IAutomationRegistryMaster(
address(deployRegistry2_2(AutomationRegistryBase2_2.Mode(0)))
);
(uint32 configCount, , ) = registry.latestConfigDetails();
assertEq(configCount, 0);

AutomationRegistryBase2_2.OnchainConfig memory cfg = AutomationRegistryBase2_2.OnchainConfig({
paymentPremiumPPB: 10_000,
flatFeeMicroLink: 40_000,
checkGasLimit: 5_000_000,
stalenessSeconds: 90_000,
gasCeilingMultiplier: 0,
minUpkeepSpend: 0,
maxPerformGas: 10_000_000,
maxCheckDataSize: 5_000,
maxPerformDataSize: 5_000,
maxRevertDataSize: 5_000,
fallbackGasPrice: 20_000_000_000,
fallbackLinkPrice: 200_000_000_000,
transcoder: 0xB1e66855FD67f6e85F0f0fA38cd6fBABdf00923c,
registrars: s_registrars,
upkeepPrivilegeManager: 0xD9c855F08A7e460691F41bBDDe6eC310bc0593D8,
reorgProtectionEnabled: true
});
bytes memory onchainConfigBytes = abi.encode(cfg);

uint256 a = 1234;
address b = address(0);
bytes memory offchainConfigBytes = abi.encode(a, b);
bytes32 configDigest = _configDigestFromConfigData(
block.chainid,
address(registry),
++configCount,
s_valid_signers,
s_valid_transmitters,
F,
onchainConfigBytes,
OFFCHAIN_CONFIG_VERSION,
offchainConfigBytes
);

vm.expectEmit();
emit ConfigSet(
0,
configDigest,
configCount,
s_valid_signers,
s_valid_transmitters,
F,
onchainConfigBytes,
OFFCHAIN_CONFIG_VERSION,
offchainConfigBytes
);

registry.setConfig(
s_valid_signers,
s_valid_transmitters,
F,
onchainConfigBytes,
OFFCHAIN_CONFIG_VERSION,
offchainConfigBytes
);

(, , address[] memory signers, address[] memory transmitters, uint8 f) = registry.getState();

assertEq(signers, s_valid_signers);
assertEq(transmitters, s_valid_transmitters);
assertEq(f, F);
}

function _configDigestFromConfigData(
uint256 chainId,
address contractAddress,
uint64 configCount,
address[] memory signers,
address[] memory transmitters,
uint8 f,
bytes memory onchainConfig,
uint64 offchainConfigVersion,
bytes memory offchainConfig
) internal pure returns (bytes32) {
uint256 h = uint256(
keccak256(
abi.encode(
chainId,
contractAddress,
configCount,
signers,
transmitters,
f,
onchainConfig,
offchainConfigVersion,
offchainConfig
)
)
);
uint256 prefixMask = type(uint256).max << (256 - 16); // 0xFFFF00..00
uint256 prefix = 0x0001 << (256 - 16); // 0x000100..00
return bytes32((prefix & prefixMask) | (h & ~prefixMask));
}
}
13 changes: 13 additions & 0 deletions contracts/src/v0.8/automation/dev/test/BaseTest.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.16;

import "forge-std/Test.sol";

contract BaseTest is Test {
address internal OWNER = 0x00007e64E1fB0C487F25dd6D3601ff6aF8d32e4e;

function setUp() public virtual {
vm.startPrank(OWNER);
deal(OWNER, 1e20);
}
}
Loading

0 comments on commit b89490e

Please sign in to comment.