Skip to content

Commit

Permalink
Merge branch 'develop' into polygonZKEVMV2SoakTest
Browse files Browse the repository at this point in the history
  • Loading branch information
davidcauchi authored Aug 23, 2023
2 parents faa447b + f05f6d0 commit 6d662c8
Show file tree
Hide file tree
Showing 108 changed files with 8,095 additions and 974 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ jobs:
matrix:
product:
- name: automation
nodes: 9
nodes: 11
os: ubuntu-latest
pyroscope_env: ci-smoke-automation-evm-simulated
# temporarily disabled
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/solidity-foundry.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
src:
- 'contracts/src/v0.8/**/*'
- '.github/workflows/solidity-foundry.yml'
- 'contacts/foundry.toml'
- 'contracts/foundry.toml'
tests:
strategy:
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v16.13.2
v16.16.0
18 changes: 13 additions & 5 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,16 @@

/core/services/webhook @samsondav

# Chainlink Functions related services
core/services/ocr2/plugins/functions @bolekk @justinkaseman @KuphJr @pinebit
# Chainlink Functions
core/services/functions @smartcontractkit/functions
core/services/ocr2/plugins/functions @smartcontractkit/functions
core/services/s4 @pinebit @bolekk
core/service/ocr2/plugins/s4 @pinebit @bolekk
core/services/ocr2/plugins/threshold @KuphJr @bolekk
core/services/relay/evm/functions.go @bolekk @justinkaseman @KuphJr
core/services/relay/evm/functions @bolekk @justinkaseman @KuphJr
core/scripts/functions @smartcontractkit/functions
core/scripts/gateway @bolekk @pinebit

# API
/core/web @jkongie
Expand All @@ -62,16 +70,16 @@ core/services/ocr2/plugins/functions @bolekk @justinkaseman @KuphJr @pinebit
/contracts/ @se3000 @connorwstein
/contracts/**/*Keeper* @smartcontractkit/keepers
/contracts/**/*Upkeep* @smartcontractkit/keepers
/contracts/**/*Functions* @bolekk @justinkaseman @KuphJr @pinebit
/contracts/src/v0.8/functions @bolekk @justinkaseman @KuphJr @pinebit
/contracts/**/*Functions* @smartcontractkit/functions
/contracts/src/v0.8/functions @smartcontractkit/functions
contracts/test/v0.8/functions @smartcontractkit/functions
/contracts/src/v0.8/llo-feeds @austinborn @Fletch153

# Tests
/integration-tests/ @smartcontractkit/test-tooling-team
/integration-tests/**/*keeper* @smartcontractkit/keepers
/integration-tests/**/*automation* @smartcontractkit/keepers


# CI/CD
/.github/** @chainchad @javuto @jkongie @jmank88 @samsondav
/.github/workflows/integration-tests.yml @smartcontractkit/test-tooling-team
Expand Down
8 changes: 7 additions & 1 deletion contracts/gas-snapshots/functions.gas-snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,10 @@ FunctionsOracle_setRegistry:testOnlyOwnerReverts() (gas: 10927)
FunctionsOracle_setRegistry:testSetRegistrySuccess() (gas: 35791)
FunctionsOracle_setRegistry:testSetRegistry_gas() (gas: 31987)
FunctionsOracle_typeAndVersion:testTypeAndVersionSuccess() (gas: 6905)
FunctionsRouter_createSubscription:testCreateSubscriptionSuccess() (gas: 111376)
FunctionsRouter_Pause:test_Pause_RevertIfNotOwner() (gas: 13293)
FunctionsRouter_Pause:test_Pause_Success() (gas: 20205)
FunctionsRouter_Unpause:test_Unpause_RevertIfNotOwner() (gas: 13338)
FunctionsRouter_Unpause:test_Unpause_Success() (gas: 77279)
FunctionsSubscriptions_createSubscription:test_CreateSubscription_RevertIfNotAllowedSender() (gas: 26347)
FunctionsSubscriptions_createSubscription:test_CreateSubscription_RevertIfPaused() (gas: 15699)
FunctionsSubscriptions_createSubscription:test_CreateSubscription_Success() (gas: 152436)
32 changes: 32 additions & 0 deletions contracts/gas-snapshots/shared.gas-snapshot
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
BurnMintERC677_approve:testApproveSuccess() (gas: 52254)
BurnMintERC677_approve:testInvalidAddressReverts() (gas: 10641)
BurnMintERC677_burn:testBasicBurnSuccess() (gas: 164344)
BurnMintERC677_burn:testBurnFromZeroAddressReverts() (gas: 43462)
BurnMintERC677_burn:testExceedsBalanceReverts() (gas: 18035)
BurnMintERC677_burn:testSenderNotBurnerReverts() (gas: 13359)
BurnMintERC677_burnFrom:testBurnFromSuccess() (gas: 54662)
BurnMintERC677_burnFrom:testExceedsBalanceReverts() (gas: 32873)
BurnMintERC677_burnFrom:testInsufficientAllowanceReverts() (gas: 18107)
BurnMintERC677_burnFrom:testSenderNotBurnerReverts() (gas: 13359)
BurnMintERC677_burnFromAlias:testBurnFromSuccess() (gas: 54688)
BurnMintERC677_burnFromAlias:testExceedsBalanceReverts() (gas: 32889)
BurnMintERC677_burnFromAlias:testInsufficientAllowanceReverts() (gas: 18127)
BurnMintERC677_burnFromAlias:testSenderNotBurnerReverts() (gas: 13379)
BurnMintERC677_constructor:testConstructorSuccess() (gas: 1669109)
BurnMintERC677_decreaseApproval:testDecreaseApprovalSuccess() (gas: 28520)
BurnMintERC677_grantMintAndBurnRoles:testGrantMintAndBurnRolesSuccess() (gas: 120049)
BurnMintERC677_grantRole:testGrantBurnAccessSuccess() (gas: 52707)
BurnMintERC677_grantRole:testGrantManySuccess() (gas: 935521)
BurnMintERC677_grantRole:testGrantMintAccessSuccess() (gas: 93588)
BurnMintERC677_increaseApproval:testIncreaseApprovalSuccess() (gas: 40911)
BurnMintERC677_mint:testBasicMintSuccess() (gas: 149365)
BurnMintERC677_mint:testMaxSupplyExceededReverts() (gas: 46627)
BurnMintERC677_mint:testSenderNotMinterReverts() (gas: 11195)
BurnMintERC677_supportsInterface:testConstructorSuccess() (gas: 8685)
BurnMintERC677_transfer:testInvalidAddressReverts() (gas: 10617)
BurnMintERC677_transfer:testTransferSuccess() (gas: 39462)
OpStackBurnMintERC677_constructor:testConstructorSuccess() (gas: 1739317)
OpStackBurnMintERC677_interfaceCompatibility:testBurnCompatibility() (gas: 259440)
OpStackBurnMintERC677_interfaceCompatibility:testMintCompatibility() (gas: 137935)
OpStackBurnMintERC677_interfaceCompatibility:testStaticFunctionsCompatibility() (gas: 10622)
OpStackBurnMintERC677_supportsInterface:testConstructorSuccess() (gas: 8961)
2 changes: 1 addition & 1 deletion contracts/scripts/native_solc_compile_all
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ python3 -m pip install --require-hashes -r $SCRIPTPATH/requirements.txt
# 6 and 7 are legacy contracts, for each other product we have a native_solc_compile_all_$product script
# These scripts can be run individually, or all together with this script.
# To add new CL products, simply write a native_solc_compile_all_$product script and add it to the list below.
for product in 6 7 feeds functions llo-feeds transmission vrf automation logpoller events_mock
for product in 6 7 feeds functions llo-feeds transmission vrf automation logpoller events_mock shared
do
$SCRIPTPATH/native_solc_compile_all_$product
done
1 change: 1 addition & 0 deletions contracts/scripts/native_solc_compile_all_automation
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ 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/DummyProtocol.sol
compileContract dev/automation/2_1/interfaces/FeedLookupCompatibleInterface.sol

compileContract tests/VerifiableLoadUpkeep.sol
Expand Down
30 changes: 30 additions & 0 deletions contracts/scripts/native_solc_compile_all_shared
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env bash

set -e

echo " ┌──────────────────────────────────────────────┐"
echo " │ Compiling shared contracts... │"
echo " └──────────────────────────────────────────────┘"

SOLC_VERSION="0.8.19"
OPTIMIZE_RUNS=1000000


SCRIPTPATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
python3 -m pip install --require-hashes -r $SCRIPTPATH/requirements.txt
solc-select install $SOLC_VERSION
solc-select use $SOLC_VERSION
export SOLC_VERSION=$SOLC_VERSION

ROOT="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; cd ../../ && pwd -P )"

compileContract () {
solc --overwrite --optimize --optimize-runs $OPTIMIZE_RUNS --metadata-hash none \
-o $ROOT/contracts/solc/v$SOLC_VERSION \
--abi --bin --allow-paths $ROOT/contracts/src/v0.8\
$ROOT/contracts/src/v0.8/$1
}

compileContract shared/token/ERC677/BurnMintERC677.sol
compileContract shared/token/ERC677/LinkToken.sol
compileContract vendor/openzeppelin-solidity/v4.8.0/contracts/token/ERC20/ERC20.sol
12 changes: 6 additions & 6 deletions contracts/src/v0.8/dev/automation/2_1/AutomationUtils2_1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ contract AutomationUtils2_1 {
/**
* @dev this can be removed as OnchainConfig is now exposed directly from the registry
*/
function _onChainConfig(KeeperRegistryBase2_1.OnchainConfig memory) external {}
function _onChainConfig(KeeperRegistryBase2_1.OnchainConfig memory) external {} // 0x2ff92a81

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

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

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

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

function _log(Log memory) external {}
function _log(Log memory) external {} // 0xe9720a49
}
2 changes: 2 additions & 0 deletions contracts/src/v0.8/dev/automation/2_1/KeeperRegistry2_1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -279,9 +279,11 @@ contract KeeperRegistry2_1 is KeeperRegistryBase2_1, OCR2Abstract, Chainable, IE
address temp;
for (uint256 i = 0; i < signers.length; i++) {
if (s_signers[signers[i]].active) revert RepeatedSigner();
if (signers[i] == ZERO_ADDRESS) revert InvalidSigner();
s_signers[signers[i]] = Signer({active: true, index: uint8(i)});

temp = transmitters[i];
if (temp == ZERO_ADDRESS) revert InvalidTransmitter();
transmitter = s_transmitters[temp];
if (transmitter.active) revert RepeatedTransmitter();
transmitter.active = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ abstract contract KeeperRegistryBase2_1 is ConfirmedOwner, ExecutionPrevention {
error InvalidPayee();
error InvalidRecipient();
error InvalidReport();
error InvalidSigner();
error InvalidTransmitter();
error InvalidTriggerType();
error MaxCheckDataSizeCanOnlyIncrease();
error MaxPerformDataSizeCanOnlyIncrease();
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,14 @@ contract LogTriggeredFeedLookup is ILogAutomation, FeedLookupCompatibleInterface

// for mercury config
bool public useArbitrumBlockNum;
bool public verify;
string[] public feedsHex = ["0x4554482d5553442d415242495452554d2d544553544e45540000000000000000"];
string public feedParamKey = "feedIdHex";
string public timeParamKey = "blockNumber";

constructor(bool _useArbitrumBlockNum) {
constructor(bool _useArbitrumBlockNum, bool _verify) {
useArbitrumBlockNum = _useArbitrumBlockNum;
verify = _verify;
}

function setTimeParamKey(string memory timeParam) external {
Expand Down Expand Up @@ -81,7 +83,10 @@ contract LogTriggeredFeedLookup is ILogAutomation, FeedLookupCompatibleInterface
(bytes[] memory values, bytes memory extraData) = abi.decode(performData, (bytes[], bytes));
(uint256 orderId, uint256 amount, address exchange) = abi.decode(extraData, (uint256, uint256, address));

bytes memory verifiedResponse = VERIFIER.verify(values[0]);
bytes memory verifiedResponse = "";
if (verify) {
verifiedResponse = VERIFIER.verify(values[0]);
}

emit PerformingLogTriggerUpkeep(
tx.origin,
Expand Down
4 changes: 2 additions & 2 deletions contracts/src/v0.8/functions/dev/1_0_0/FunctionsBilling.sol
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,8 @@ abstract contract FunctionsBilling is Routable, IFunctionsBilling {
// In these two fulfillment results the user has been charged
// Otherwise, the Coordinator should hold on to the request commitment
if (
resultCode == FunctionsResponse.FulfillResult.USER_SUCCESS ||
resultCode == FunctionsResponse.FulfillResult.USER_ERROR
resultCode == FunctionsResponse.FulfillResult.FULFILLED ||
resultCode == FunctionsResponse.FulfillResult.USER_CALLBACK_ERROR
) {
delete s_requestCommitments[requestId];
// Reimburse the transmitter for the fulfillment gas cost
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,8 @@ contract FunctionsCoordinator is OCR2Base, IFunctionsCoordinator, FunctionsBilli
// In these two fulfillment results the user has been charged
// Otherwise, the DON will re-try
if (
result == FunctionsResponse.FulfillResult.USER_SUCCESS || result == FunctionsResponse.FulfillResult.USER_ERROR
result == FunctionsResponse.FulfillResult.FULFILLED ||
result == FunctionsResponse.FulfillResult.USER_CALLBACK_ERROR
) {
emit OracleResponse(requestIds[i], msg.sender);
}
Expand Down
12 changes: 7 additions & 5 deletions contracts/src/v0.8/functions/dev/1_0_0/FunctionsRouter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ contract FunctionsRouter is IFunctionsRouter, FunctionsSubscriptions, Pausable,
address transmitter,
FunctionsResponse.FulfillResult resultCode,
bytes response,
bytes returnData
bytes err,
bytes callbackReturnData
);

event RequestNotProcessed(
Expand Down Expand Up @@ -348,8 +349,8 @@ contract FunctionsRouter is IFunctionsRouter, FunctionsSubscriptions, Pausable,
);

resultCode = result.success
? FunctionsResponse.FulfillResult.USER_SUCCESS
: FunctionsResponse.FulfillResult.USER_ERROR;
? FunctionsResponse.FulfillResult.FULFILLED
: FunctionsResponse.FulfillResult.USER_CALLBACK_ERROR;

Receipt memory receipt = _pay(
commitment.subscriptionId,
Expand All @@ -367,8 +368,9 @@ contract FunctionsRouter is IFunctionsRouter, FunctionsSubscriptions, Pausable,
totalCostJuels: receipt.totalCostJuels,
transmitter: transmitter,
resultCode: resultCode,
response: result.success ? response : err,
returnData: result.returnData
response: response,
err: err,
callbackReturnData: result.returnData
});

return (resultCode, receipt.callbackGasCostJuels);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ library FunctionsResponse {
}

enum FulfillResult {
USER_SUCCESS, // 0
USER_ERROR, // 1
FULFILLED, // 0
USER_CALLBACK_ERROR, // 1
INVALID_REQUEST_ID, // 2
COST_EXCEEDS_COMMITMENT, // 3
INSUFFICIENT_GAS_PROVIDED, // 4
Expand Down
12 changes: 8 additions & 4 deletions contracts/src/v0.8/functions/tests/1_0_0/BaseTest.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@ import {Test} from "forge-std/Test.sol";

contract BaseTest is Test {
bool private s_baseTestInitialized;
address internal constant OWNER = 0x00007e64E1fB0C487F25dd6D3601ff6aF8d32e4e;

uint256 internal OWNER_PRIVATE_KEY = 0x1;
address internal OWNER_ADDRESS = vm.addr(OWNER_PRIVATE_KEY);

uint256 internal STRANGER_PRIVATE_KEY = 0x2;
address internal STRANGER_ADDRESS = vm.addr(STRANGER_PRIVATE_KEY);

function setUp() public virtual {
// BaseTest.setUp is often called multiple times from tests' setUp due to inheritance.
if (s_baseTestInitialized) return;
s_baseTestInitialized = true;

// Set msg.sender to OWNER until changePrank or stopPrank is called
vm.startPrank(OWNER);
// Set msg.sender to OWNER until stopPrank is called
vm.startPrank(OWNER_ADDRESS);
}
}
22 changes: 22 additions & 0 deletions contracts/src/v0.8/functions/tests/1_0_0/FunctionsClient.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

/// @notice #constructor
contract FunctionsClient_Constructor {

}

/// @notice #_sendRequest
contract FunctionsClient__SendRequest {

}

/// @notice #fulfillRequest
contract FunctionsClient_FulfillRequest {

}

/// @notice #handleOracleFulfillment
contract FunctionsClient_HandleOracleFulfillment {

}
Loading

0 comments on commit 6d662c8

Please sign in to comment.