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-858: small refactoring - rename CTF VRF V2 and V2.5 packages #11877

Merged
merged 13 commits into from
Jan 25, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ jobs:
os: ubuntu-latest
pyroscope_env: ci-smoke-vrf-evm-simulated
- name: vrfv2
nodes: 2
nodes: 3
os: ubuntu-latest
pyroscope_env: ci-smoke-vrf2-evm-simulated
- name: vrfv2plus
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package vrfv2_actions
package vrfv2

import (
"math/big"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package vrfv2_actions
package vrfv2

import (
"context"
Expand Down Expand Up @@ -888,7 +888,7 @@ func RequestRandomnessWithForceFulfillAndWaitForFulfillment(
case randomWordsForcedEvent = <-randWordsForcedEventChannel:
LogRandomWordsForcedEvent(l, vrfOwner, randomWordsForcedEvent)
case <-time.After(randomWordsFulfilledEventTimeout):
err = fmt.Errorf("timeout waiting for ConfigSet, RandomWordsFulfilled and RandomWordsForced events")
return nil, nil, nil, fmt.Errorf("timeout waiting for ConfigSet, RandomWordsFulfilled and RandomWordsForced events")
}
}
return configSetEvent, randomWordsFulfilledEvent, randomWordsForcedEvent, err
Expand Down
10 changes: 5 additions & 5 deletions integration-tests/load/vrfv2/gun.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@ import (
"github.com/rs/zerolog"
"github.com/smartcontractkit/wasp"

"github.com/smartcontractkit/chainlink/integration-tests/actions/vrfv2_actions"
"github.com/smartcontractkit/chainlink/integration-tests/actions/vrf/vrfv2"
"github.com/smartcontractkit/chainlink/integration-tests/types"
)

/* SingleHashGun is a gun that constantly requests randomness for one feed */

type SingleHashGun struct {
contracts *vrfv2_actions.VRFV2Contracts
contracts *vrfv2.VRFV2Contracts
keyHash [32]byte
subIDs []uint64
testConfig types.VRFv2TestConfig
logger zerolog.Logger
}

func NewSingleHashGun(
contracts *vrfv2_actions.VRFV2Contracts,
contracts *vrfv2.VRFV2Contracts,
keyHash [32]byte,
subIDs []uint64,
testConfig types.VRFv2TestConfig,
Expand All @@ -43,14 +43,14 @@ func (m *SingleHashGun) Call(_ *wasp.Generator) *wasp.Response {
vrfv2Config := m.testConfig.GetVRFv2Config().General
//randomly increase/decrease randomness request count per TX
randomnessRequestCountPerRequest := deviateValue(*vrfv2Config.RandomnessRequestCountPerRequest, *vrfv2Config.RandomnessRequestCountPerRequestDeviation)
_, err := vrfv2_actions.RequestRandomnessAndWaitForFulfillment(
_, err := vrfv2.RequestRandomnessAndWaitForFulfillment(
m.logger,
//the same consumer is used for all requests and in all subs
m.contracts.LoadTestConsumers[0],
m.contracts.Coordinator,
//randomly pick a subID from pool of subIDs
m.subIDs[randInRange(0, len(m.subIDs)-1)],
&vrfv2_actions.VRFV2Data{VRFV2KeyData: vrfv2_actions.VRFV2KeyData{KeyHash: m.keyHash}},
&vrfv2.VRFV2Data{VRFV2KeyData: vrfv2.VRFV2KeyData{KeyHash: m.keyHash}},
*vrfv2Config.MinimumConfirmations,
*vrfv2Config.CallbackGasLimit,
*vrfv2Config.NumberOfWords,
Expand Down
24 changes: 12 additions & 12 deletions integration-tests/load/vrfv2/vrfv2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,21 @@ import (
"github.com/smartcontractkit/chainlink-testing-framework/logging"
"github.com/smartcontractkit/chainlink-testing-framework/utils/conversions"
"github.com/smartcontractkit/chainlink/integration-tests/actions"
"github.com/smartcontractkit/chainlink/integration-tests/actions/vrf/vrfv2"

"github.com/smartcontractkit/chainlink/integration-tests/contracts"
"github.com/smartcontractkit/chainlink/integration-tests/docker/test_env"
"github.com/smartcontractkit/chainlink/integration-tests/testreporters"

"github.com/stretchr/testify/require"

"github.com/smartcontractkit/chainlink/integration-tests/actions/vrfv2_actions"
tc "github.com/smartcontractkit/chainlink/integration-tests/testconfig"
)

var (
env *test_env.CLClusterTestEnv
vrfv2Contracts *vrfv2_actions.VRFV2Contracts
vrfv2Data *vrfv2_actions.VRFV2Data
vrfv2Contracts *vrfv2.VRFV2Contracts
vrfv2Data *vrfv2.VRFV2Data
subIDs []uint64
eoaWalletAddress string

Expand Down Expand Up @@ -110,15 +110,15 @@ func TestVRFV2Performance(t *testing.T) {
if *cfg.ExistingEnvConfig.CreateFundSubsAndAddConsumers {
linkToken, err := env.ContractLoader.LoadLINKToken(*vrfv2Config.Performance.LinkAddress)
require.NoError(t, err)
consumers, err = vrfv2_actions.DeployVRFV2Consumers(env.ContractDeployer, coordinator.Address(), 1)
consumers, err = vrfv2.DeployVRFV2Consumers(env.ContractDeployer, coordinator.Address(), 1)
require.NoError(t, err)
err = env.EVMClient.WaitForEvents()
require.NoError(t, err, vrfv2_actions.ErrWaitTXsComplete)
require.NoError(t, err, vrfv2.ErrWaitTXsComplete)
l.Info().
Str("Coordinator", *cfg.ExistingEnvConfig.CoordinatorAddress).
Int("Number of Subs to create", *vrfv2Config.General.NumberOfSubToCreate).
Msg("Creating and funding subscriptions, deploying and adding consumers to subs")
subIDs, err = vrfv2_actions.CreateFundSubsAndAddConsumers(
subIDs, err = vrfv2.CreateFundSubsAndAddConsumers(
env,
big.NewFloat(*cfg.General.SubscriptionFundingAmountLink),
linkToken,
Expand All @@ -137,14 +137,14 @@ func TestVRFV2Performance(t *testing.T) {
err = FundNodesIfNeeded(&testConfig, env.EVMClient, l)
require.NoError(t, err)

vrfv2Contracts = &vrfv2_actions.VRFV2Contracts{
vrfv2Contracts = &vrfv2.VRFV2Contracts{
Coordinator: coordinator,
LoadTestConsumers: consumers,
BHS: nil,
}

vrfv2Data = &vrfv2_actions.VRFV2Data{
VRFV2KeyData: vrfv2_actions.VRFV2KeyData{
vrfv2Data = &vrfv2.VRFV2Data{
VRFV2KeyData: vrfv2.VRFV2KeyData{
VRFKey: nil,
EncodedProvingKey: [2]*big.Int{},
KeyHash: common.HexToHash(*vrfv2Config.Performance.KeyHash),
Expand Down Expand Up @@ -200,7 +200,7 @@ func TestVRFV2Performance(t *testing.T) {
useVRFOwner := true
useTestCoordinator := true

vrfv2Contracts, subIDs, vrfv2Data, err = vrfv2_actions.SetupVRFV2Environment(
vrfv2Contracts, subIDs, vrfv2Data, err = vrfv2.SetupVRFV2Environment(
env,
&testConfig,
useVRFOwner,
Expand All @@ -222,7 +222,7 @@ func TestVRFV2Performance(t *testing.T) {
for _, subID := range subIDs {
subscription, err := vrfv2Contracts.Coordinator.GetSubscription(context.Background(), subID)
require.NoError(t, err, "error getting subscription information for subscription %d", subID)
vrfv2_actions.LogSubDetails(l, subscription, subID, vrfv2Contracts.Coordinator)
vrfv2.LogSubDetails(l, subscription, subID, vrfv2Contracts.Coordinator)
}

singleFeedConfig := &wasp.Config{
Expand Down Expand Up @@ -262,7 +262,7 @@ func TestVRFV2Performance(t *testing.T) {
var wg sync.WaitGroup
wg.Add(1)
//todo - timeout should be configurable depending on the perf test type
requestCount, fulfilmentCount, err := vrfv2_actions.WaitForRequestCountEqualToFulfilmentCount(consumer, 2*time.Minute, &wg)
requestCount, fulfilmentCount, err := vrfv2.WaitForRequestCountEqualToFulfilmentCount(consumer, 2*time.Minute, &wg)
require.NoError(t, err)
wg.Wait()

Expand Down
2 changes: 1 addition & 1 deletion integration-tests/load/vrfv2plus/gun.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/rs/zerolog"
"github.com/smartcontractkit/wasp"

"github.com/smartcontractkit/chainlink/integration-tests/actions/vrfv2plus"
"github.com/smartcontractkit/chainlink/integration-tests/actions/vrf/vrfv2plus"
vrfv2plus_config "github.com/smartcontractkit/chainlink/integration-tests/testconfig/vrfv2plus"
"github.com/smartcontractkit/chainlink/integration-tests/types"
)
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/load/vrfv2plus/vrfv2plus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ import (
"github.com/smartcontractkit/chainlink-testing-framework/logging"
"github.com/smartcontractkit/chainlink-testing-framework/utils/conversions"
"github.com/smartcontractkit/chainlink-testing-framework/utils/testcontext"
"github.com/smartcontractkit/chainlink/integration-tests/actions/vrf/vrfv2plus"
"github.com/smartcontractkit/chainlink/integration-tests/testreporters"

"github.com/smartcontractkit/chainlink/integration-tests/actions"
"github.com/smartcontractkit/chainlink/integration-tests/actions/vrfv2plus"
"github.com/smartcontractkit/chainlink/integration-tests/contracts"
"github.com/smartcontractkit/chainlink/integration-tests/docker/test_env"

Expand Down
2 changes: 1 addition & 1 deletion integration-tests/smoke/vrf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import (

"github.com/smartcontractkit/chainlink-testing-framework/logging"
"github.com/smartcontractkit/chainlink-testing-framework/utils/testcontext"
"github.com/smartcontractkit/chainlink/integration-tests/actions/vrf/vrfv1"

"github.com/smartcontractkit/chainlink/integration-tests/actions"
"github.com/smartcontractkit/chainlink/integration-tests/actions/vrfv1"
"github.com/smartcontractkit/chainlink/integration-tests/client"
"github.com/smartcontractkit/chainlink/integration-tests/docker/test_env"
tc "github.com/smartcontractkit/chainlink/integration-tests/testconfig"
Expand Down
43 changes: 21 additions & 22 deletions integration-tests/smoke/vrfv2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/stretchr/testify/require"

commonassets "github.com/smartcontractkit/chainlink-common/pkg/assets"
"github.com/smartcontractkit/chainlink/integration-tests/actions/vrf/vrfv2"

"github.com/smartcontractkit/chainlink-testing-framework/blockchain"
"github.com/smartcontractkit/chainlink-testing-framework/logging"
Expand All @@ -20,8 +21,6 @@ import (
"github.com/smartcontractkit/chainlink-testing-framework/utils/testcontext"

"github.com/smartcontractkit/chainlink/integration-tests/actions"
"github.com/smartcontractkit/chainlink/integration-tests/actions/vrfv2_actions"

"github.com/smartcontractkit/chainlink/integration-tests/docker/test_env"
tc "github.com/smartcontractkit/chainlink/integration-tests/testconfig"
)
Expand Down Expand Up @@ -59,7 +58,7 @@ func TestVRFv2Basic(t *testing.T) {
defaultWalletAddress := env.EVMClient.GetDefaultWallet().Address()

numberOfTxKeysToCreate := 1
vrfv2Contracts, subIDs, vrfv2Data, err := vrfv2_actions.SetupVRFV2Environment(
vrfv2Contracts, subIDs, vrfv2Data, err := vrfv2.SetupVRFV2Environment(
env,
&config,
useVRFOwner,
Expand All @@ -79,7 +78,7 @@ func TestVRFv2Basic(t *testing.T) {
subscription, err := vrfv2Contracts.Coordinator.GetSubscription(context.Background(), subID)
require.NoError(t, err, "error getting subscription information")

vrfv2_actions.LogSubDetails(l, subscription, subID, vrfv2Contracts.Coordinator)
vrfv2.LogSubDetails(l, subscription, subID, vrfv2Contracts.Coordinator)

t.Run("Request Randomness", func(t *testing.T) {
configCopy := config.MustCopy().(tc.TestConfig)
Expand All @@ -89,7 +88,7 @@ func TestVRFv2Basic(t *testing.T) {
require.NoError(t, err, "error reading job runs")

// test and assert
randomWordsFulfilledEvent, err := vrfv2_actions.RequestRandomnessAndWaitForFulfillment(
randomWordsFulfilledEvent, err := vrfv2.RequestRandomnessAndWaitForFulfillment(
l,
vrfv2Contracts.LoadTestConsumers[0],
vrfv2Contracts.Coordinator,
Expand Down Expand Up @@ -128,7 +127,7 @@ func TestVRFv2Basic(t *testing.T) {

t.Run("Direct Funding (VRFV2Wrapper)", func(t *testing.T) {
configCopy := config.MustCopy().(tc.TestConfig)
wrapperContracts, wrapperSubID, err := vrfv2_actions.SetupVRFV2WrapperEnvironment(
wrapperContracts, wrapperSubID, err := vrfv2.SetupVRFV2WrapperEnvironment(
env,
&configCopy,
linkToken,
Expand All @@ -148,7 +147,7 @@ func TestVRFv2Basic(t *testing.T) {
subBalanceBeforeRequest := wrapperSubscription.Balance

// Request Randomness and wait for fulfillment event
randomWordsFulfilledEvent, err := vrfv2_actions.DirectFundingRequestRandomnessAndWaitForFulfillment(
randomWordsFulfilledEvent, err := vrfv2.DirectFundingRequestRandomnessAndWaitForFulfillment(
l,
wrapperConsumer,
vrfv2Contracts.Coordinator,
Expand Down Expand Up @@ -204,7 +203,7 @@ func TestVRFv2Basic(t *testing.T) {

t.Run("Oracle Withdraw", func(t *testing.T) {
configCopy := config.MustCopy().(tc.TestConfig)
subIDsForOracleWithDraw, err := vrfv2_actions.CreateFundSubsAndAddConsumers(
subIDsForOracleWithDraw, err := vrfv2.CreateFundSubsAndAddConsumers(
env,
big.NewFloat(*configCopy.VRFv2.General.SubscriptionFundingAmountLink),
linkToken,
Expand All @@ -216,7 +215,7 @@ func TestVRFv2Basic(t *testing.T) {

subIDForOracleWithdraw := subIDsForOracleWithDraw[0]

fulfilledEventLink, err := vrfv2_actions.RequestRandomnessAndWaitForFulfillment(
fulfilledEventLink, err := vrfv2.RequestRandomnessAndWaitForFulfillment(
l,
vrfv2Contracts.LoadTestConsumers[0],
vrfv2Contracts.Coordinator,
Expand Down Expand Up @@ -245,7 +244,7 @@ func TestVRFv2Basic(t *testing.T) {
require.NoError(t, err, "Error withdrawing LINK from coordinator to default wallet")

err = env.EVMClient.WaitForEvents()
require.NoError(t, err, vrfv2_actions.ErrWaitTXsComplete)
require.NoError(t, err, vrfv2.ErrWaitTXsComplete)

defaultWalletBalanceLinkAfterOracleWithdraw, err := linkToken.BalanceOf(testcontext.Get(t), defaultWalletAddress)
require.NoError(t, err)
Expand All @@ -260,7 +259,7 @@ func TestVRFv2Basic(t *testing.T) {

t.Run("Canceling Sub And Returning Funds", func(t *testing.T) {
configCopy := config.MustCopy().(tc.TestConfig)
subIDsForCancelling, err := vrfv2_actions.CreateFundSubsAndAddConsumers(
subIDsForCancelling, err := vrfv2.CreateFundSubsAndAddConsumers(
env,
big.NewFloat(*configCopy.VRFv2.General.SubscriptionFundingAmountLink),
linkToken,
Expand Down Expand Up @@ -337,7 +336,7 @@ func TestVRFv2Basic(t *testing.T) {
// Underfund subscription to force fulfillments to fail
configCopy.VRFv2.General.SubscriptionFundingAmountLink = ptr.Ptr(float64(0.000000000000000001)) // 1 Juel

subIDsForCancelling, err := vrfv2_actions.CreateFundSubsAndAddConsumers(
subIDsForCancelling, err := vrfv2.CreateFundSubsAndAddConsumers(
env,
big.NewFloat(*configCopy.VRFv2.General.SubscriptionFundingAmountLink),
linkToken,
Expand All @@ -352,7 +351,7 @@ func TestVRFv2Basic(t *testing.T) {
subscriptionForCancelling, err := vrfv2Contracts.Coordinator.GetSubscription(testcontext.Get(t), subIDForCancelling)
require.NoError(t, err, "Error getting subscription information")

vrfv2_actions.LogSubDetails(l, subscriptionForCancelling, subIDForCancelling, vrfv2Contracts.Coordinator)
vrfv2.LogSubDetails(l, subscriptionForCancelling, subIDForCancelling, vrfv2Contracts.Coordinator)

// No GetActiveSubscriptionIds function available - skipping check

Expand All @@ -362,7 +361,7 @@ func TestVRFv2Basic(t *testing.T) {

// Request randomness - should fail due to underfunded subscription
randomWordsFulfilledEventTimeout := 5 * time.Second
_, err = vrfv2_actions.RequestRandomnessAndWaitForFulfillment(
_, err = vrfv2.RequestRandomnessAndWaitForFulfillment(
l,
vrfv2Contracts.LoadTestConsumers[0],
vrfv2Contracts.Coordinator,
Expand Down Expand Up @@ -482,7 +481,7 @@ func TestVRFv2MultipleSendingKeys(t *testing.T) {
defaultWalletAddress := env.EVMClient.GetDefaultWallet().Address()

numberOfTxKeysToCreate := 2
vrfv2Contracts, subIDs, vrfv2Data, err := vrfv2_actions.SetupVRFV2Environment(
vrfv2Contracts, subIDs, vrfv2Data, err := vrfv2.SetupVRFV2Environment(
env,
&config,
useVRFOwner,
Expand All @@ -502,7 +501,7 @@ func TestVRFv2MultipleSendingKeys(t *testing.T) {
subscription, err := vrfv2Contracts.Coordinator.GetSubscription(context.Background(), subID)
require.NoError(t, err, "error getting subscription information")

vrfv2_actions.LogSubDetails(l, subscription, subID, vrfv2Contracts.Coordinator)
vrfv2.LogSubDetails(l, subscription, subID, vrfv2Contracts.Coordinator)

t.Run("Request Randomness with multiple sending keys", func(t *testing.T) {
txKeys, _, err := env.ClCluster.Nodes[0].API.ReadTxKeys("evm")
Expand All @@ -512,7 +511,7 @@ func TestVRFv2MultipleSendingKeys(t *testing.T) {

var fulfillmentTxFromAddresses []string
for i := 0; i < numberOfTxKeysToCreate+1; i++ {
randomWordsFulfilledEvent, err := vrfv2_actions.RequestRandomnessAndWaitForFulfillment(
randomWordsFulfilledEvent, err := vrfv2.RequestRandomnessAndWaitForFulfillment(
l,
vrfv2Contracts.LoadTestConsumers[0],
vrfv2Contracts.Coordinator,
Expand Down Expand Up @@ -580,7 +579,7 @@ func TestVRFOwner(t *testing.T) {
defaultWalletAddress := env.EVMClient.GetDefaultWallet().Address()

numberOfTxKeysToCreate := 1
vrfv2Contracts, subIDs, vrfv2Data, err := vrfv2_actions.SetupVRFV2Environment(
vrfv2Contracts, subIDs, vrfv2Data, err := vrfv2.SetupVRFV2Environment(
env,
&config,
useVRFOwner,
Expand All @@ -600,7 +599,7 @@ func TestVRFOwner(t *testing.T) {
subscription, err := vrfv2Contracts.Coordinator.GetSubscription(context.Background(), subID)
require.NoError(t, err, "error getting subscription information")

vrfv2_actions.LogSubDetails(l, subscription, subID, vrfv2Contracts.Coordinator)
vrfv2.LogSubDetails(l, subscription, subID, vrfv2Contracts.Coordinator)

t.Run("Request Randomness With Force-Fulfill", func(t *testing.T) {
configCopy := config.MustCopy().(tc.TestConfig)
Expand All @@ -616,7 +615,7 @@ func TestVRFOwner(t *testing.T) {
require.NoError(t, err, "error transferring link to consumer contract")

err = env.EVMClient.WaitForEvents()
require.NoError(t, err, vrfv2_actions.ErrWaitTXsComplete)
require.NoError(t, err, vrfv2.ErrWaitTXsComplete)

consumerLinkBalance, err := linkToken.BalanceOf(testcontext.Get(t), vrfv2Contracts.LoadTestConsumers[0].Address())
require.NoError(t, err, "error getting consumer link balance")
Expand All @@ -628,10 +627,10 @@ func TestVRFOwner(t *testing.T) {
err = mockETHLinkFeed.SetBlockTimestampDeduction(big.NewInt(3))
require.NoError(t, err)
err = env.EVMClient.WaitForEvents()
require.NoError(t, err, vrfv2_actions.ErrWaitTXsComplete)
require.NoError(t, err, vrfv2.ErrWaitTXsComplete)

// test and assert
_, randFulfilledEvent, _, err := vrfv2_actions.RequestRandomnessWithForceFulfillAndWaitForFulfillment(
_, randFulfilledEvent, _, err := vrfv2.RequestRandomnessWithForceFulfillAndWaitForFulfillment(
l,
vrfv2Contracts.LoadTestConsumers[0],
vrfv2Contracts.Coordinator,
Expand Down
Loading
Loading