Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VRF-881: fixed toml config for VRF Load tests; VRF-882: add more cust… #11991

Merged
merged 28 commits into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
5e316af
VRF-881: fixed toml config for VRF Load tests; VRF-882: add more cust…
iljapavlovs Feb 11, 2024
0e3ef15
VRF-881: fixing lint
iljapavlovs Feb 11, 2024
00dee3f
Merge branch 'develop' into chore/vrf-881-vrf-882
iljapavlovs Feb 12, 2024
9842d96
Merge branch 'develop' into chore/vrf-881-vrf-882
iljapavlovs Feb 14, 2024
b275212
VRF-881: upgrading ctf library
iljapavlovs Feb 14, 2024
72c46f5
VRF-881: adding load test metric calculation in seconds for VRF V2Plu…
iljapavlovs Feb 15, 2024
2ad88c2
Merge branch 'develop' into chore/vrf-881-vrf-882
iljapavlovs Feb 15, 2024
6a8a917
VRF-881: sync with develop
iljapavlovs Feb 15, 2024
31eba76
VRF-881: sync with develop
iljapavlovs Feb 16, 2024
d2ccd41
VRF-881: sync with develop
iljapavlovs Feb 20, 2024
9609c3b
VRF-881: PR comments;
iljapavlovs Feb 21, 2024
3839179
VRF-881: fixing Lint issues
iljapavlovs Feb 21, 2024
17751ef
Merge branch 'develop' into chore/vrf-881-vrf-882
iljapavlovs Feb 21, 2024
79cd6b0
VRF-881: fixing BHS tests
iljapavlovs Feb 21, 2024
62c88d9
VRF-881: adding smoke test type
iljapavlovs Feb 21, 2024
a756318
Merge branch 'develop' into chore/vrf-881-vrf-882
iljapavlovs Feb 22, 2024
a73b63d
Merge branch 'develop' into chore/vrf-881-vrf-882
iljapavlovs Feb 23, 2024
5bf2f63
VRF-881: PR comments
iljapavlovs Feb 23, 2024
54a36e8
VRF-881: fixing load test
iljapavlovs Feb 23, 2024
e5b26b2
VRF-881: fixing config
iljapavlovs Feb 23, 2024
43ffb33
VRF-881: fixing e2e tests
iljapavlovs Feb 23, 2024
542c642
Merge branch 'develop' into chore/vrf-881-vrf-882
iljapavlovs Feb 23, 2024
8ba7497
VRF-881: fixing sonar
iljapavlovs Feb 23, 2024
214acd0
Merge remote-tracking branch 'origin/chore/vrf-881-vrf-882' into chor…
iljapavlovs Feb 23, 2024
1fe0b96
VRF-881: fixing sonar and refactoring
iljapavlovs Feb 24, 2024
58b8b18
Merge branch 'develop' into chore/vrf-881-vrf-882
iljapavlovs Feb 24, 2024
d03afbb
VRF-881: fixing lint issues
iljapavlovs Feb 24, 2024
7b7a3cf
Merge branch 'develop' into chore/vrf-881-vrf-882
iljapavlovs Feb 24, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/on-demand-vrfv2-performance-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ on:
description: Performance Test Type of test to run
type: choice
options:
- "Smoke"
- "Soak"
- "Load"
- "Stress"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ on:
description: Performance Test Type of test to run
type: choice
options:
- "Smoke"
- "Soak"
- "Load"
- "Stress"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ import {VRFV2PlusClient} from "../libraries/VRFV2PlusClient.sol";
contract VRFV2PlusLoadTestWithMetrics is VRFConsumerBaseV2Plus {
uint256 public s_responseCount;
uint256 public s_requestCount;
uint256 public s_averageFulfillmentInMillions = 0; // in millions for better precision
uint256 public s_slowestFulfillment = 0;
uint256 public s_fastestFulfillment = 999;
uint256 public s_averageResponseTimeInBlocksMillions = 0; // in millions for better precision
uint256 public s_slowestResponseTimeInBlocks = 0;
uint256 public s_fastestResponseTimeInBlocks = 999;
uint256 public s_slowestResponseTimeInSeconds = 0;
uint256 public s_fastestResponseTimeInSeconds = 999;
uint256 public s_averageResponseTimeInSecondsMillions = 0;

uint256 public s_lastRequestId;
// solhint-disable-next-line chainlink-solidity/prefix-storage-variables-with-s-underscore
mapping(uint256 => uint256) internal requestHeights; // requestIds to block number when rand request was made

struct RequestStatus {
bool fulfilled;
Expand All @@ -34,22 +36,38 @@ contract VRFV2PlusLoadTestWithMetrics is VRFConsumerBaseV2Plus {

// solhint-disable-next-line chainlink-solidity/prefix-internal-functions-with-underscore
function fulfillRandomWords(uint256 _requestId, uint256[] memory _randomWords) internal override {
uint256 fulfilmentBlockNumber = ChainSpecificUtil._getBlockNumber();
uint256 requestDelay = fulfilmentBlockNumber - requestHeights[_requestId];
uint256 requestDelayInMillions = requestDelay * 1_000_000;

if (requestDelay > s_slowestFulfillment) {
s_slowestFulfillment = requestDelay;
}
s_fastestFulfillment = requestDelay < s_fastestFulfillment ? requestDelay : s_fastestFulfillment;
s_averageFulfillmentInMillions = s_responseCount > 0
? (s_averageFulfillmentInMillions * s_responseCount + requestDelayInMillions) / (s_responseCount + 1)
: requestDelayInMillions;

s_requests[_requestId].fulfilled = true;
s_requests[_requestId].randomWords = _randomWords;
s_requests[_requestId].fulfilmentTimestamp = block.timestamp;
s_requests[_requestId].fulfilmentBlockNumber = fulfilmentBlockNumber;
s_requests[_requestId].fulfilmentBlockNumber = ChainSpecificUtil._getBlockNumber();

uint256 responseTimeInBlocks = s_requests[_requestId].fulfilmentBlockNumber -
s_requests[_requestId].requestBlockNumber;
uint256 responseTimeInSeconds = s_requests[_requestId].fulfilmentTimestamp -
s_requests[_requestId].requestTimestamp;

(
s_slowestResponseTimeInBlocks,
s_fastestResponseTimeInBlocks,
s_averageResponseTimeInBlocksMillions
) = _calculateMetrics(
responseTimeInBlocks,
s_fastestResponseTimeInBlocks,
s_slowestResponseTimeInBlocks,
s_averageResponseTimeInBlocksMillions,
s_responseCount
);
(
s_slowestResponseTimeInSeconds,
s_fastestResponseTimeInSeconds,
s_averageResponseTimeInSecondsMillions
) = _calculateMetrics(
responseTimeInSeconds,
s_fastestResponseTimeInSeconds,
s_slowestResponseTimeInSeconds,
s_averageResponseTimeInSecondsMillions,
s_responseCount
);

s_responseCount++;
}
Expand Down Expand Up @@ -86,14 +104,16 @@ contract VRFV2PlusLoadTestWithMetrics is VRFConsumerBaseV2Plus {
fulfilmentBlockNumber: 0
});
s_requestCount++;
requestHeights[requestId] = requestBlockNumber;
}
}

function reset() external {
s_averageFulfillmentInMillions = 0; // in millions for better precision
s_slowestFulfillment = 0;
s_fastestFulfillment = 999;
s_averageResponseTimeInBlocksMillions = 0; // in millions for better precision
s_slowestResponseTimeInBlocks = 0;
s_fastestResponseTimeInBlocks = 999;
s_averageResponseTimeInSecondsMillions = 0; // in millions for better precision
s_slowestResponseTimeInSeconds = 0;
s_fastestResponseTimeInSeconds = 999;
s_requestCount = 0;
s_responseCount = 0;
}
Expand Down Expand Up @@ -122,4 +142,23 @@ contract VRFV2PlusLoadTestWithMetrics is VRFConsumerBaseV2Plus {
request.fulfilmentBlockNumber
);
}

function _calculateMetrics(
uint256 _responseTime,
uint256 _fastestResponseTime,
uint256 _slowestResponseTime,
uint256 _averageInMillions,
uint256 _responseCount
) internal returns (uint256 slowest, uint256 fastest, uint256 average) {
uint256 _requestDelayInMillions = _responseTime * 1_000_000;
if (_responseTime > _slowestResponseTime) {
_slowestResponseTime = _responseTime;
}
_fastestResponseTime = _responseTime < _fastestResponseTime ? _responseTime : _fastestResponseTime;
uint256 _averageInMillions = _responseCount > 0
? (_averageInMillions * _responseCount + _requestDelayInMillions) / (_responseCount + 1)
: _requestDelayInMillions;

return (_slowestResponseTime, _fastestResponseTime, _averageInMillions);
}
}
Loading
Loading