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-745: refactor VRF v2 tests to match VRF v2 Plus setup #11257

Merged
merged 18 commits into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
136 changes: 136 additions & 0 deletions .github/workflows/on-demand-vrfv2-performance-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
name: On Demand VRFV2 Performance Test
on:
workflow_dispatch:
inputs:
network:
description: Network to run tests on
type: choice
options:
- "ETHEREUM_MAINNET"
- "SIMULATED"
- "SEPOLIA"
- "OPTIMISM_MAINNET"
- "OPTIMISM_GOERLI"
- "ARBITRUM_MAINNET"
- "ARBITRUM_GOERLI"
- "ARBITRUM_SEPOLIA"
- "BSC_MAINNET"
- "BSC_TESTNET"
- "POLYGON_MAINNET"
- "POLYGON_MUMBAI"
- "AVALANCHE_FUJI"
- "AVALANCHE_MAINNET"
fundingPrivateKey:
description: Private funding key (Skip for Simulated)
required: false
type: string
wsURL:
description: WS URL for the network (Skip for Simulated)
required: false
type: string
httpURL:
description: HTTP URL for the network (Skip for Simulated)
required: false
type: string
chainlinkImage:
description: Container image location for the Chainlink nodes
required: true
default: public.ecr.aws/chainlink/chainlink
chainlinkVersion:
description: Container image version for the Chainlink nodes
required: true
default: "2.6.0"
performanceTestType:
description: Performance Test Type of test to run
type: choice
options:
- "Soak"
- "Load"
- "Stress"
- "Spike"
testDuration:
description: Duration of the test (time string)
required: true
default: 5m
useExistingEnv:
description: Set `true` to use existing environment or `false` to deploy CL node and all contracts
required: false
default: false
configBase64:
description: TOML config in base64 (Needed when overriding config or providing contract addresses for existing env)
required: false
jobs:
vrfv2_performance_test:
name: ${{ inputs.network }} VRFV2 Performance Test
environment: integration
runs-on: ubuntu20.04-8cores-32GB
permissions:
checks: write
pull-requests: write
id-token: write
contents: read
env:
LOKI_URL: ${{ secrets.LOKI_URL }}
LOKI_TOKEN: ${{ secrets.LOKI_TOKEN }}
SELECTED_NETWORKS: ${{ inputs.network }}
TEST_TYPE: ${{ inputs.performanceTestType }}
VRFV2_TEST_DURATION: ${{ inputs.testDuration }}
VRFV2_USE_EXISTING_ENV: ${{ inputs.useExistingEnv }}
CONFIG: ${{ inputs.configBase64 }}
TEST_LOG_LEVEL: debug
REF_NAME: ${{ github.head_ref || github.ref_name }}
CHAINLINK_IMAGE: ${{ inputs.chainlinkImage }}
CHAINLINK_VERSION: ${{ inputs.chainlinkVersion }}
SLACK_API_KEY: ${{ secrets.QA_SLACK_API_KEY }}
SLACK_CHANNEL: ${{ secrets.QA_VRF_SLACK_CHANNEL }}
WASP_LOG_LEVEL: info
steps:
- name: Collect Metrics
id: collect-gha-metrics
uses: smartcontractkit/push-gha-metrics-action@d1618b772a97fd87e6505de97b872ee0b1f1729a # v2.0.2
with:
basic-auth: ${{ secrets.GRAFANA_CLOUD_BASIC_AUTH }}
hostname: ${{ secrets.GRAFANA_CLOUD_HOST }}
this-job-name: ${{ inputs.network }} VRFV2 Performance Test
continue-on-error: true
- name: Setup Push Tag
shell: bash
run: |
echo "### chainlink image used for this test run :link:" >>$GITHUB_STEP_SUMMARY
echo "\`${{ inputs.chainlinkVersion }}\`" >>$GITHUB_STEP_SUMMARY
echo "### chainlink-tests image tag for this test run :ship:" >>$GITHUB_STEP_SUMMARY
echo "\`${GITHUB_SHA}\`" >>$GITHUB_STEP_SUMMARY
- name: Get Inputs
run: |
EVM_URLS=$(jq -r '.inputs.wsURL' $GITHUB_EVENT_PATH)
EVM_HTTP_URLS=$(jq -r '.inputs.httpURL' $GITHUB_EVENT_PATH)
EVM_KEYS=$(jq -r '.inputs.fundingPrivateKey' $GITHUB_EVENT_PATH)

echo ::add-mask::$EVM_URLS
echo ::add-mask::$EVM_HTTP_URLS
echo ::add-mask::$EVM_KEYS

echo EVM_URLS=$EVM_URLS >> $GITHUB_ENV
echo EVM_HTTP_URLS=$EVM_HTTP_URLS >> $GITHUB_ENV
echo EVM_KEYS=$EVM_KEYS >> $GITHUB_ENV

- name: Checkout code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
fetch-depth: 0
- name: Run Tests
uses: smartcontractkit/chainlink-github-actions/chainlink-testing-framework/run-tests@7d541cbbca52d45b8a718257af86d9cf49774d1f # v2.2.15
with:
test_command_to_run: cd ./integration-tests && go test -v -count=1 -timeout 24h -run TestVRFV2Performance/vrfv2_performance_test ./load/vrfv2
test_download_vendor_packages_command: cd ./integration-tests && go mod download
cl_repo: ${{ inputs.chainlinkImage }}
cl_image_tag: ${{ inputs.chainlinkVersion }}
aws_registries: ${{ secrets.QA_AWS_ACCOUNT_NUMBER }}
artifacts_name: vrf-test-logs
artifacts_location: ./integration-tests/load/vrfv2/logs/
token: ${{ secrets.GITHUB_TOKEN }}
go_mod_path: ./integration-tests/go.mod
should_cleanup: false
QA_AWS_REGION: ${{ secrets.QA_AWS_REGION }}
QA_AWS_ROLE_TO_ASSUME: ${{ secrets.QA_AWS_ROLE_TO_ASSUME }}
QA_KUBECONFIG: ${{ secrets.QA_KUBECONFIG }}
7 changes: 4 additions & 3 deletions .github/workflows/on-demand-vrfv2plus-performance-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ on:
- "OPTIMISM_GOERLI"
- "ARBITRUM_MAINNET"
- "ARBITRUM_GOERLI"
- "ARBITRUM_SEPOLIA"
- "BSC_MAINNET"
- "BSC_TESTNET"
- "POLYGON_MAINNET"
- "MUMBAI"
- "POLYGON_MUMBAI"
- "AVALANCHE_FUJI"
- "AVALANCHE_MAINNET"
fundingPrivateKey:
Expand Down Expand Up @@ -120,13 +121,13 @@ jobs:
- name: Run Tests
uses: smartcontractkit/chainlink-github-actions/chainlink-testing-framework/run-tests@e865e376b8c2d594028c8d645dd6c47169b72974 # v2.2.16
with:
test_command_to_run: cd ./integration-tests && go test -v -count=1 -timeout 6h -run TestVRFV2PlusPerformance/vrfv2plus_performance_test ./load/vrfv2plus
test_command_to_run: cd ./integration-tests && go test -v -count=1 -timeout 24h -run TestVRFV2PlusPerformance/vrfv2plus_performance_test ./load/vrfv2plus
test_download_vendor_packages_command: cd ./integration-tests && go mod download
cl_repo: ${{ inputs.chainlinkImage }}
cl_image_tag: ${{ inputs.chainlinkVersion }}
aws_registries: ${{ secrets.QA_AWS_ACCOUNT_NUMBER }}
artifacts_name: vrf-test-logs
artifacts_location: ./integration-tests/load/logs/
artifacts_location: ./integration-tests/load/vrfv2plus/logs/
token: ${{ secrets.GITHUB_TOKEN }}
go_mod_path: ./integration-tests/go.mod
should_cleanup: false
Expand Down
54 changes: 54 additions & 0 deletions integration-tests/actions/vrfv2_actions/vrfv2_config/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package vrfv2_config

import "time"

type VRFV2Config struct {
ChainlinkNodeFunding float64 `envconfig:"CHAINLINK_NODE_FUNDING" default:".1"` // Amount of native currency to fund each chainlink node with
CLNodeMaxGasPriceGWei int64 `envconfig:"MAX_GAS_PRICE_GWEI" default:"1000"` // Max gas price in GWei for the chainlink node
IsNativePayment bool `envconfig:"IS_NATIVE_PAYMENT" default:"false"` // Whether to use native payment or LINK token
LinkNativeFeedResponse int64 `envconfig:"LINK_NATIVE_FEED_RESPONSE" default:"1000000000000000000"` // Response of the LINK/ETH feed
MinimumConfirmations uint16 `envconfig:"MINIMUM_CONFIRMATIONS" default:"3"` // Minimum number of confirmations for the VRF Coordinator
SubscriptionFundingAmountLink float64 `envconfig:"SUBSCRIPTION_FUNDING_AMOUNT_LINK" default:"5"` // Amount of LINK to fund the subscription with
NumberOfWords uint32 `envconfig:"NUMBER_OF_WORDS" default:"3"` // Number of words to request
CallbackGasLimit uint32 `envconfig:"CALLBACK_GAS_LIMIT" default:"1000000"` // Gas limit for the callback
MaxGasLimitCoordinatorConfig uint32 `envconfig:"MAX_GAS_LIMIT_COORDINATOR_CONFIG" default:"2500000"` // Max gas limit for the VRF Coordinator config
FallbackWeiPerUnitLink int64 `envconfig:"FALLBACK_WEI_PER_UNIT_LINK" default:"60000000000000000"` // Fallback wei per unit LINK for the VRF Coordinator config
StalenessSeconds uint32 `envconfig:"STALENESS_SECONDS" default:"86400"` // Staleness in seconds for the VRF Coordinator config
GasAfterPaymentCalculation uint32 `envconfig:"GAS_AFTER_PAYMENT_CALCULATION" default:"33825"` // Gas after payment calculation for the VRF Coordinator config
FulfillmentFlatFeeLinkPPMTier1 uint32 `envconfig:"FULFILLMENT_FLAT_FEE_LINK_PPM_TIER_1" default:"500"`
FulfillmentFlatFeeLinkPPMTier2 uint32 `envconfig:"FULFILLMENT_FLAT_FEE_LINK_PPM_TIER_2" default:"500"`
FulfillmentFlatFeeLinkPPMTier3 uint32 `envconfig:"FULFILLMENT_FLAT_FEE_LINK_PPM_TIER_3" default:"500"`
FulfillmentFlatFeeLinkPPMTier4 uint32 `envconfig:"FULFILLMENT_FLAT_FEE_LINK_PPM_TIER_4" default:"500"`
FulfillmentFlatFeeLinkPPMTier5 uint32 `envconfig:"FULFILLMENT_FLAT_FEE_LINK_PPM_TIER_5" default:"500"`
ReqsForTier2 int64 `envconfig:"REQS_FOR_TIER_2" default:"0"`
ReqsForTier3 int64 `envconfig:"REQS_FOR_TIER_3" default:"0"`
ReqsForTier4 int64 `envconfig:"REQS_FOR_TIER_4" default:"0"`
ReqsForTier5 int64 `envconfig:"REQS_FOR_TIER_5" default:"0"`

NumberOfSubToCreate int `envconfig:"NUMBER_OF_SUB_TO_CREATE" default:"1"` // Number of subscriptions to create

RandomnessRequestCountPerRequest uint16 `envconfig:"RANDOMNESS_REQUEST_COUNT_PER_REQUEST" default:"1"` // How many randomness requests to send per request
RandomnessRequestCountPerRequestDeviation uint16 `envconfig:"RANDOMNESS_REQUEST_COUNT_PER_REQUEST_DEVIATION" default:"0"` // How many randomness requests to send per request

RandomWordsFulfilledEventTimeout time.Duration `envconfig:"RANDOM_WORDS_FULFILLED_EVENT_TIMEOUT" default:"2m"` // How long to wait for the RandomWordsFulfilled event to be emitted

//Wrapper Config
WrapperGasOverhead uint32 `envconfig:"WRAPPER_GAS_OVERHEAD" default:"50000"`
CoordinatorGasOverhead uint32 `envconfig:"COORDINATOR_GAS_OVERHEAD" default:"52000"`
WrapperPremiumPercentage uint8 `envconfig:"WRAPPER_PREMIUM_PERCENTAGE" default:"25"`
WrapperMaxNumberOfWords uint8 `envconfig:"WRAPPER_MAX_NUMBER_OF_WORDS" default:"10"`
WrapperConsumerFundingAmountNativeToken float64 `envconfig:"WRAPPER_CONSUMER_FUNDING_AMOUNT_NATIVE_TOKEN" default:"1"`
WrapperConsumerFundingAmountLink int64 `envconfig:"WRAPPER_CONSUMER_FUNDING_AMOUNT_LINK" default:"10"`

//LOAD/SOAK Test Config
TestDuration time.Duration `envconfig:"TEST_DURATION" default:"3m"` // How long to run the test for
RPS int64 `envconfig:"RPS" default:"1"` // How many requests per second to send
RateLimitUnitDuration time.Duration `envconfig:"RATE_LIMIT_UNIT_DURATION" default:"1m"`
//Using existing environment and contracts
UseExistingEnv bool `envconfig:"USE_EXISTING_ENV" default:"false"` // Whether to use an existing environment or create a new one
CoordinatorAddress string `envconfig:"COORDINATOR_ADDRESS" default:""` // Coordinator address
ConsumerAddress string `envconfig:"CONSUMER_ADDRESS" default:""` // Consumer address
LinkAddress string `envconfig:"LINK_ADDRESS" default:""` // Link address
SubID uint64 `envconfig:"SUB_ID" default:""` // Subscription ID
KeyHash string `envconfig:"KEY_HASH" default:""`
}

This file was deleted.

20 changes: 17 additions & 3 deletions integration-tests/actions/vrfv2_actions/vrfv2_models.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,21 @@ type VRFV2JobInfo struct {
}

type VRFV2Contracts struct {
Coordinator contracts.VRFCoordinatorV2
BHS contracts.BlockHashStore
LoadTestConsumer contracts.VRFv2LoadTestConsumer
Coordinator contracts.VRFCoordinatorV2
BHS contracts.BlockHashStore
LoadTestConsumers []contracts.VRFv2LoadTestConsumer
}

// VRFV2PlusKeyData defines a jobs into and proving key info
type VRFV2KeyData struct {
VRFKey *client.VRFKey
EncodedProvingKey VRFV2EncodedProvingKey
KeyHash [32]byte
}

type VRFV2Data struct {
VRFV2KeyData
VRFJob *client.Job
PrimaryEthAddress string
ChainID *big.Int
}
Loading
Loading