Skip to content

Commit

Permalink
[AUTO-8227] Update Log Trigger Load Test (#11601)
Browse files Browse the repository at this point in the history
* add spam log

* change slack channel for testing

* update test config lines

* Revert "change slack channel for testing"

This reverts commit 1b81c0f.

* add prometheus enable config

* increase DB specs

* increase geth specs

* fix endTime in dashboard link

* Add checkBurnAmount performBurnAmount
Fix proper spam event

* add load types

* contracts prettier

* tests tidy

* add numberOfSpamNonMatchingEvents

* add configOverride input to action

* propagate CONFIG_OVERRIDE to test runner

* avoid using array in emitlog

* update specs
slack message in thread

* better test config printing

* run lint

* implement shared trigger

* nodeFunding as config
  • Loading branch information
anirudhwarrier authored Dec 19, 2023
1 parent 85e19b9 commit 9ae0b9a
Show file tree
Hide file tree
Showing 11 changed files with 499 additions and 131 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
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);
}
}
}
166 changes: 164 additions & 2 deletions core/gethwrappers/generated/log_emitter/log_emitter.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 9ae0b9a

Please sign in to comment.