Skip to content

Commit

Permalink
Merge branch 'develop' into move_eth_utils_to_evm
Browse files Browse the repository at this point in the history
  • Loading branch information
dimriou committed Dec 19, 2023
2 parents 30cf8c6 + 0e5b219 commit 1d624c3
Show file tree
Hide file tree
Showing 45 changed files with 972 additions and 256 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/automation-load-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ on:
description: TestInputs
required: false
type: string
ConfigOverride:
description: ConfigOverride
required: false
type: string
slackMemberID:
description: Notifies test results (Not your @)
required: true
Expand All @@ -43,6 +47,7 @@ jobs:
SLACK_API_KEY: ${{ secrets.QA_SLACK_API_KEY }}
SLACK_CHANNEL: C03KJ5S7KEK
TEST_INPUTS: ${{ inputs.TestInputs }}
CONFIG_OVERRIDE: ${{ inputs.ConfigOverride }}
CHAINLINK_ENV_USER: ${{ github.actor }}
REF_NAME: ${{ github.head_ref || github.ref_name }}
steps:
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -407,8 +407,6 @@ jobs:
pyroscope_env: ci-smoke-vrf-evm-simulated
- name: vrfv2
nodes: 1
run: -run TestVRFv2MultipleSendingKeys
file: vrfv2
os: ubuntu-latest
pyroscope_env: ci-smoke-vrf2-evm-simulated
- name: vrfv2plus
Expand Down
10 changes: 6 additions & 4 deletions .github/workflows/live-testnet-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
name: Live Testnet Tests
on:
schedule:
- cron: "0 0 * * *" # Run every Sunday at midnight
- cron: "0 5 * * *" # Run every Sunday at midnight EST
push:
tags:
- "*"
Expand Down Expand Up @@ -144,7 +144,7 @@ jobs:
id-token: write
contents: read
runs-on: ubuntu-latest
needs: [sepolia-smoke-tests, bsc-testnet-tests, optimism-sepolia-smoke-tests, arbitrum-sepolia-smoke-tests, base-goerli-smoke-tests, base-sepolia-smoke-tests, polygon-mumbai-smoke-tests, avalanche-fuji-smoke-tests, fantom-testnet-smoke-tests, celo-alfajores-smoke-tests, scroll-sepolia-smoke-tests, linea-goerli-smoke-tests]
needs: [sepolia-smoke-tests, bsc-testnet-tests, optimism-sepolia-smoke-tests, arbitrum-sepolia-smoke-tests, base-goerli-smoke-tests, base-sepolia-smoke-tests, polygon-mumbai-smoke-tests, avalanche-fuji-smoke-tests, fantom-testnet-smoke-tests, celo-alfajores-smoke-tests, linea-goerli-smoke-tests]
steps:
- name: Debug Result
run: echo ${{ join(needs.*.result, ',') }}
Expand Down Expand Up @@ -205,7 +205,7 @@ jobs:
strategy:
fail-fast: false
matrix:
network: [Sepolia, Optimism Sepolia, Arbitrum Sepolia, Base Goerli, Base Sepolia, Polygon Mumbai, Avalanche Fuji, Fantom Testnet, Celo Alfajores, Scroll Sepolia, Linea Goerli, BSC Testnet]
network: [Sepolia, Optimism Sepolia, Arbitrum Sepolia, Base Goerli, Base Sepolia, Polygon Mumbai, Avalanche Fuji, Fantom Testnet, Celo Alfajores, Linea Goerli, BSC Testnet]
steps:
- name: Get Results
id: test-results
Expand Down Expand Up @@ -775,8 +775,10 @@ jobs:
QA_AWS_REGION: ${{ secrets.QA_AWS_REGION }}
QA_AWS_ROLE_TO_ASSUME: ${{ secrets.QA_AWS_ROLE_TO_ASSUME }}
QA_KUBECONFIG: ${{ secrets.QA_KUBECONFIG }}

scroll-sepolia-smoke-tests:
# TODO: Disabled until bug TT-767 is fixed
if: false
environment: integration
permissions:
checks: write
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ pragma solidity 0.8.6;

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

struct CheckData {
uint256 checkBurnAmount;
uint256 performBurnAmount;
bytes32 eventSig;
}

contract SimpleLogUpkeepCounter is ILogAutomation {
event PerformingUpkeep(
address indexed from,
Expand All @@ -14,6 +20,7 @@ contract SimpleLogUpkeepCounter is ILogAutomation {
uint256 timeToPerform
);

mapping(bytes32 => bool) public dummyMap; // used to force storage lookup
uint256 public lastBlock;
uint256 public previousPerformBlock;
uint256 public initialBlock;
Expand All @@ -27,8 +34,27 @@ contract SimpleLogUpkeepCounter is ILogAutomation {
counter = 0;
}

function checkLog(Log calldata log, bytes memory) external view override returns (bool, bytes memory) {
return (true, abi.encode(log));
function _checkDataConfig(CheckData memory) external {}

function checkLog(Log calldata log, bytes calldata checkData) external view override returns (bool, bytes memory) {
(uint256 checkBurnAmount, uint256 performBurnAmount, bytes32 eventSig) = abi.decode(
checkData,
(uint256, uint256, bytes32)
);
uint256 startGas = gasleft();
bytes32 dummyIndex = blockhash(block.number - 1);
bool dummy;
// burn gas
if (checkBurnAmount > 0) {
while (startGas - gasleft() < checkBurnAmount) {
dummy = dummy && dummyMap[dummyIndex]; // arbitrary storage reads
dummyIndex = keccak256(abi.encode(dummyIndex, address(this)));
}
}
if (log.topics[2] == eventSig) {
return (true, abi.encode(log, checkData));
}
return (false, abi.encode(log, checkData));
}

function performUpkeep(bytes calldata performData) external override {
Expand All @@ -38,8 +64,22 @@ contract SimpleLogUpkeepCounter is ILogAutomation {
lastBlock = block.number;
counter = counter + 1;
previousPerformBlock = lastBlock;
Log memory log = abi.decode(performData, (Log));
(Log memory log, bytes memory extraData) = abi.decode(performData, (Log, bytes));
timeToPerform = block.timestamp - log.timestamp;
(uint256 checkBurnAmount, uint256 performBurnAmount, bytes32 eventSig) = abi.decode(
extraData,
(uint256, uint256, bytes32)
);
uint256 startGas = gasleft();
bytes32 dummyIndex = blockhash(block.number - 1);
bool dummy;
// burn gas
if (performBurnAmount > 0) {
while (startGas - gasleft() < performBurnAmount) {
dummy = dummy && dummyMap[dummyIndex]; // arbitrary storage reads
dummyIndex = keccak256(abi.encode(dummyIndex, address(this)));
}
}
emit PerformingUpkeep(tx.origin, initialBlock, lastBlock, previousPerformBlock, counter, timeToPerform);
}
}
7 changes: 7 additions & 0 deletions contracts/src/v0.8/tests/LogEmitter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ contract LogEmitter {
event Log1(uint256);
event Log2(uint256 indexed);
event Log3(string);
event Log4(uint256 indexed, uint256 indexed);

function EmitLog1(uint256[] memory v) public {
for (uint256 i = 0; i < v.length; i++) {
Expand All @@ -23,4 +24,10 @@ contract LogEmitter {
emit Log3(v[i]);
}
}

function EmitLog4(uint256 v, uint256 w, uint256 c) public {
for (uint256 i = 0; i < c; i++) {
emit Log4(v, w);
}
}
}
5 changes: 2 additions & 3 deletions core/chains/evm/headtracker/head_broadcaster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ import (

"github.com/smartcontractkit/chainlink-common/pkg/logger"
"github.com/smartcontractkit/chainlink-common/pkg/services/servicetest"
"github.com/smartcontractkit/chainlink-common/pkg/utils/mailbox"

"github.com/smartcontractkit/chainlink-common/pkg/utils/mailbox/mailboxtest"
commonhtrk "github.com/smartcontractkit/chainlink/v2/common/headtracker"
commonmocks "github.com/smartcontractkit/chainlink/v2/common/types/mocks"
"github.com/smartcontractkit/chainlink/v2/core/chains/evm/headtracker"
Expand Down Expand Up @@ -73,7 +72,7 @@ func TestHeadBroadcaster_Subscribe(t *testing.T) {

orm := headtracker.NewORM(db, logger, cfg.Database(), *ethClient.ConfiguredChainID())
hs := headtracker.NewHeadSaver(logger, orm, evmCfg.EVM(), evmCfg.EVM().HeadTracker())
mailMon := mailbox.NewMonitor(t.Name())
mailMon := mailboxtest.NewMonitor(t)
servicetest.Run(t, mailMon)
hb := headtracker.NewHeadBroadcaster(logger)
servicetest.Run(t, hb)
Expand Down
7 changes: 4 additions & 3 deletions core/chains/evm/headtracker/head_tracker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/smartcontractkit/chainlink-common/pkg/logger"
"github.com/smartcontractkit/chainlink-common/pkg/services"
"github.com/smartcontractkit/chainlink-common/pkg/utils/mailbox"
"github.com/smartcontractkit/chainlink-common/pkg/utils/mailbox/mailboxtest"

commonmocks "github.com/smartcontractkit/chainlink/v2/common/types/mocks"
evmclient "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client"
Expand Down Expand Up @@ -994,7 +995,7 @@ func createHeadTracker(t *testing.T, ethClient evmclient.Client, config headtrac
lggr := logger.Test(t)
hb := headtracker.NewHeadBroadcaster(lggr)
hs := headtracker.NewHeadSaver(lggr, orm, config, htConfig)
mailMon := mailbox.NewMonitor(t.Name())
mailMon := mailboxtest.NewMonitor(t)
return &headTrackerUniverse{
mu: new(sync.Mutex),
headTracker: headtracker.NewHeadTracker(lggr, ethClient, config, htConfig, hb, hs, mailMon),
Expand All @@ -1009,7 +1010,7 @@ func createHeadTrackerWithNeverSleeper(t *testing.T, ethClient evmclient.Client,
lggr := logger.Test(t)
hb := headtracker.NewHeadBroadcaster(lggr)
hs := headtracker.NewHeadSaver(lggr, orm, evmcfg.EVM(), evmcfg.EVM().HeadTracker())
mailMon := mailbox.NewMonitor(t.Name())
mailMon := mailboxtest.NewMonitor(t)
ht := headtracker.NewHeadTracker(lggr, ethClient, evmcfg.EVM(), evmcfg.EVM().HeadTracker(), hb, hs, mailMon)
_, err := hs.Load(testutils.Context(t))
require.NoError(t, err)
Expand All @@ -1027,7 +1028,7 @@ func createHeadTrackerWithChecker(t *testing.T, ethClient evmclient.Client, conf
hb := headtracker.NewHeadBroadcaster(lggr)
hs := headtracker.NewHeadSaver(lggr, orm, config, htConfig)
hb.Subscribe(checker)
mailMon := mailbox.NewMonitor(t.Name())
mailMon := mailboxtest.NewMonitor(t)
ht := headtracker.NewHeadTracker(lggr, ethClient, config, htConfig, hb, hs, mailMon)
return &headTrackerUniverse{
mu: new(sync.Mutex),
Expand Down
4 changes: 2 additions & 2 deletions core/chains/evm/log/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (

"github.com/smartcontractkit/chainlink-common/pkg/logger"
"github.com/smartcontractkit/chainlink-common/pkg/services/servicetest"
"github.com/smartcontractkit/chainlink-common/pkg/utils/mailbox"
"github.com/smartcontractkit/chainlink-common/pkg/utils/mailbox/mailboxtest"

evmclient "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client"
evmclimocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client/mocks"
Expand Down Expand Up @@ -90,7 +90,7 @@ func newBroadcasterHelperWithEthClient(t *testing.T, ethClient evmclient.Client,
})
config := evmtest.NewChainScopedConfig(t, globalConfig)
lggr := logger.Test(t)
mailMon := servicetest.Run(t, mailbox.NewMonitor(t.Name()))
mailMon := servicetest.Run(t, mailboxtest.NewMonitor(t))

db := pgtest.NewSqlxDB(t)
orm := log.NewORM(db, lggr, config.Database(), cltest.FixtureChainID)
Expand Down
4 changes: 2 additions & 2 deletions core/chains/evm/log/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (

"github.com/smartcontractkit/chainlink-common/pkg/logger"
"github.com/smartcontractkit/chainlink-common/pkg/services/servicetest"
"github.com/smartcontractkit/chainlink-common/pkg/utils/mailbox"
"github.com/smartcontractkit/chainlink-common/pkg/utils/mailbox/mailboxtest"

evmclimocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client/mocks"
"github.com/smartcontractkit/chainlink/v2/core/chains/evm/log"
Expand Down Expand Up @@ -1326,7 +1326,7 @@ func TestBroadcaster_AppendLogChannel(t *testing.T) {
ch3 := make(chan types.Log)

ethClient := evmtest.NewEthClientMockWithDefaultChain(t)
mailMon := servicetest.RunHealthy(t, mailbox.NewMonitor(t.Name()))
mailMon := servicetest.RunHealthy(t, mailboxtest.NewMonitor(t))
lb := log.NewBroadcaster(nil, ethClient, nil, logger.Test(t), nil, mailMon)
chCombined := lb.ExportedAppendLogChannel(ch1, ch2)
chCombined = lb.ExportedAppendLogChannel(chCombined, ch3)
Expand Down
2 changes: 1 addition & 1 deletion core/cmd/shell.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func (n ChainlinkAppFactory) NewApplication(ctx context.Context, cfg chainlink.G
}

keyStore := keystore.New(db, utils.GetScryptParams(cfg), appLggr, cfg.Database())
mailMon := mailbox.NewMonitor(cfg.AppID().String())
mailMon := mailbox.NewMonitor(cfg.AppID().String(), appLggr.Named("Mailbox"))

dbListener := cfg.Database().Listener()
eventBroadcaster := pg.NewEventBroadcaster(cfg.Database().URL(), dbListener.MinReconnectInterval(), dbListener.MaxReconnectDuration(), appLggr, cfg.AppID())
Expand Down
Loading

0 comments on commit 1d624c3

Please sign in to comment.