diff --git a/integration-tests/actions/vrf/common/actions.go b/integration-tests/actions/vrf/common/actions.go index fa7ba94ae70..d57bdc33b90 100644 --- a/integration-tests/actions/vrf/common/actions.go +++ b/integration-tests/actions/vrf/common/actions.go @@ -5,6 +5,7 @@ import ( "fmt" "math/big" "sync" + "testing" "time" "github.com/ethereum/go-ethereum/common" @@ -13,6 +14,7 @@ import ( "github.com/smartcontractkit/seth" + ctf_test_env "github.com/smartcontractkit/chainlink-testing-framework/docker/test_env" "github.com/smartcontractkit/chainlink-testing-framework/utils/conversions" actions_seth "github.com/smartcontractkit/chainlink/integration-tests/actions/seth" "github.com/smartcontractkit/chainlink/integration-tests/client" @@ -350,3 +352,20 @@ func FundNodesIfNeeded(ctx context.Context, existingEnvConfig *vrf_common_config } return nil } + +func BuildNewCLEnvForVRF(t *testing.T, envConfig VRFEnvConfig, newEnvConfig NewEnvConfig, network ctf_test_env.EthereumNetwork) (*test_env.CLClusterTestEnv, error) { + env, err := test_env.NewCLTestEnvBuilder(). + WithTestInstance(t). + WithTestConfig(&envConfig.TestConfig). + WithPrivateEthereumNetwork(network.EthereumNetworkConfig). + WithCLNodes(len(newEnvConfig.NodesToCreate)). + WithFunding(big.NewFloat(*envConfig.TestConfig.Common.ChainlinkNodeFunding)). + WithChainlinkNodeLogScanner(newEnvConfig.ChainlinkNodeLogScannerSettings). + WithCustomCleanup(envConfig.CleanupFn). + WithSeth(). + Build() + if err != nil { + return nil, fmt.Errorf("%s, err: %w", "error creating test env", err) + } + return env, nil +} diff --git a/integration-tests/actions/vrf/common/models.go b/integration-tests/actions/vrf/common/models.go index c88839b4c3b..9baa5c96e1d 100644 --- a/integration-tests/actions/vrf/common/models.go +++ b/integration-tests/actions/vrf/common/models.go @@ -8,6 +8,7 @@ import ( "github.com/smartcontractkit/chainlink/integration-tests/client" "github.com/smartcontractkit/chainlink/integration-tests/contracts" "github.com/smartcontractkit/chainlink/integration-tests/docker/test_env" + tc "github.com/smartcontractkit/chainlink/integration-tests/testconfig" ) type VRFEncodedProvingKey [2]*big.Int @@ -83,8 +84,15 @@ type VRFLoadTestConsumer interface { } type NewEnvConfig struct { - NodesToCreate []VRFNodeType - NumberOfTxKeysToCreate int - UseVRFOwner bool - UseTestCoordinator bool + NodesToCreate []VRFNodeType + NumberOfTxKeysToCreate int + UseVRFOwner bool + UseTestCoordinator bool + ChainlinkNodeLogScannerSettings test_env.ChainlinkNodeLogScannerSettings +} + +type VRFEnvConfig struct { + TestConfig tc.TestConfig + ChainID int64 + CleanupFn func() } diff --git a/integration-tests/actions/vrf/vrfv2/setup_steps.go b/integration-tests/actions/vrf/vrfv2/setup_steps.go index 2528d16dd77..f7a4d1f3fb8 100644 --- a/integration-tests/actions/vrf/vrfv2/setup_steps.go +++ b/integration-tests/actions/vrf/vrfv2/setup_steps.go @@ -305,12 +305,9 @@ func SetupVRFV2WrapperEnvironment( func SetupVRFV2Universe( ctx context.Context, t *testing.T, - testConfig tc.TestConfig, - chainID int64, - cleanupFn func(), + envConfig vrfcommon.VRFEnvConfig, newEnvConfig vrfcommon.NewEnvConfig, l zerolog.Logger, - chainlinkNodeLogScannerSettings test_env.ChainlinkNodeLogScannerSettings, ) (*test_env.CLClusterTestEnv, *vrfcommon.VRFContracts, *vrfcommon.VRFKeyData, map[vrfcommon.VRFNodeType]*vrfcommon.VRFNode, error) { var ( env *test_env.CLClusterTestEnv @@ -319,13 +316,13 @@ func SetupVRFV2Universe( nodeTypeToNodeMap map[vrfcommon.VRFNodeType]*vrfcommon.VRFNode err error ) - if *testConfig.VRFv2.General.UseExistingEnv { - vrfContracts, vrfKey, env, err = SetupVRFV2ForExistingEnv(t, testConfig, chainID, cleanupFn, l) + if *envConfig.TestConfig.VRFv2.General.UseExistingEnv { + vrfContracts, vrfKey, env, err = SetupVRFV2ForExistingEnv(t, envConfig, l) if err != nil { return nil, nil, nil, nil, fmt.Errorf("%s, err: %w", "Error setting up VRF V2 for Existing env", err) } } else { - vrfContracts, vrfKey, env, nodeTypeToNodeMap, err = SetupVRFV2ForNewEnv(ctx, t, testConfig, chainID, cleanupFn, newEnvConfig, l, chainlinkNodeLogScannerSettings) + vrfContracts, vrfKey, env, nodeTypeToNodeMap, err = SetupVRFV2ForNewEnv(ctx, t, envConfig, newEnvConfig, l) if err != nil { return nil, nil, nil, nil, fmt.Errorf("%s, err: %w", "Error setting up VRF V2 for New env", err) } @@ -336,54 +333,36 @@ func SetupVRFV2Universe( func SetupVRFV2ForNewEnv( ctx context.Context, t *testing.T, - testConfig tc.TestConfig, - chainID int64, - cleanupFn func(), + envConfig vrfcommon.VRFEnvConfig, newEnvConfig vrfcommon.NewEnvConfig, l zerolog.Logger, - chainlinkNodeLogScannerSettings test_env.ChainlinkNodeLogScannerSettings, ) (*vrfcommon.VRFContracts, *vrfcommon.VRFKeyData, *test_env.CLClusterTestEnv, map[vrfcommon.VRFNodeType]*vrfcommon.VRFNode, error) { - network, err := actions.EthereumNetworkConfigFromConfig(l, &testConfig) + network, err := actions.EthereumNetworkConfigFromConfig(l, &envConfig.TestConfig) if err != nil { - return nil, nil, nil, nil, fmt.Errorf("%s, err: %w", "Error building ethereum network config", err) + return nil, nil, nil, nil, fmt.Errorf("%s, err: %w", "Error building ethereum network config for V2", err) } - - env, err := test_env.NewCLTestEnvBuilder(). - WithTestInstance(t). - WithTestConfig(&testConfig). - WithPrivateEthereumNetwork(network.EthereumNetworkConfig). - WithCLNodes(len(newEnvConfig.NodesToCreate)). - WithFunding(big.NewFloat(*testConfig.Common.ChainlinkNodeFunding)). - WithChainlinkNodeLogScanner(chainlinkNodeLogScannerSettings). - WithCustomCleanup(cleanupFn). - WithSeth(). - Build() - + env, err := vrfcommon.BuildNewCLEnvForVRF(t, envConfig, newEnvConfig, network) if err != nil { - return nil, nil, nil, nil, fmt.Errorf("%s, err: %w", "error creating test env", err) + return nil, nil, nil, nil, err } - sethClient, err := env.GetSethClientForSelectedNetwork() if err != nil { return nil, nil, nil, nil, err } - - mockETHLinkFeed, err := contracts.DeployVRFMockETHLINKFeed(sethClient, big.NewInt(*testConfig.VRFv2.General.LinkNativeFeedResponse)) + mockETHLinkFeed, err := contracts.DeployVRFMockETHLINKFeed(sethClient, big.NewInt(*envConfig.TestConfig.VRFv2.General.LinkNativeFeedResponse)) if err != nil { return nil, nil, nil, nil, fmt.Errorf("%s, err: %w", "error deploying mock ETH/LINK feed", err) } - linkToken, err := contracts.DeployLinkTokenContract(l, sethClient) if err != nil { return nil, nil, nil, nil, fmt.Errorf("%s, err: %w", "error deploying LINK contract", err) } - vrfContracts, vrfKey, nodeTypeToNode, err := SetupVRFV2Environment( ctx, env, - chainID, + envConfig.ChainID, newEnvConfig.NodesToCreate, - &testConfig, + &envConfig.TestConfig, newEnvConfig.UseVRFOwner, newEnvConfig.UseTestCoordinator, linkToken, @@ -399,12 +378,12 @@ func SetupVRFV2ForNewEnv( return vrfContracts, vrfKey, env, nodeTypeToNode, nil } -func SetupVRFV2ForExistingEnv(t *testing.T, testConfig tc.TestConfig, chainID int64, cleanupFn func(), l zerolog.Logger) (*vrfcommon.VRFContracts, *vrfcommon.VRFKeyData, *test_env.CLClusterTestEnv, error) { - commonExistingEnvConfig := testConfig.VRFv2.ExistingEnvConfig.ExistingEnvConfig +func SetupVRFV2ForExistingEnv(t *testing.T, envConfig vrfcommon.VRFEnvConfig, l zerolog.Logger) (*vrfcommon.VRFContracts, *vrfcommon.VRFKeyData, *test_env.CLClusterTestEnv, error) { + commonExistingEnvConfig := envConfig.TestConfig.VRFv2.ExistingEnvConfig.ExistingEnvConfig env, err := test_env.NewCLTestEnvBuilder(). WithTestInstance(t). - WithTestConfig(&testConfig). - WithCustomCleanup(cleanupFn). + WithTestConfig(&envConfig.TestConfig). + WithCustomCleanup(envConfig.CleanupFn). WithSeth(). Build() if err != nil { @@ -423,21 +402,27 @@ func SetupVRFV2ForExistingEnv(t *testing.T, testConfig tc.TestConfig, chainID in if err != nil { return nil, nil, nil, fmt.Errorf("%s, err: %w", "error loading LinkToken", err) } - - sethClient, err := env.GetSethClient(chainID) + sethClient, err := env.GetSethClient(envConfig.ChainID) if err != nil { return nil, nil, nil, err } - err = vrfcommon.FundNodesIfNeeded(testcontext.Get(t), commonExistingEnvConfig, sethClient, l) if err != nil { return nil, nil, nil, fmt.Errorf("err: %w", err) } + blockHashStoreAddress, err := coordinator.GetBlockHashStoreAddress(testcontext.Get(t)) + if err != nil { + return nil, nil, nil, fmt.Errorf("err: %w", err) + } + blockHashStore, err := contracts.LoadBlockHashStore(sethClient, blockHashStoreAddress.String()) + if err != nil { + return nil, nil, nil, fmt.Errorf("%s, err: %w", "error loading BlockHashStore", err) + } vrfContracts := &vrfcommon.VRFContracts{ CoordinatorV2: coordinator, VRFV2Consumers: nil, LinkToken: linkToken, - BHS: nil, + BHS: blockHashStore, } vrfKey := &vrfcommon.VRFKeyData{ VRFKey: nil, diff --git a/integration-tests/actions/vrf/vrfv2plus/setup_steps.go b/integration-tests/actions/vrf/vrfv2plus/setup_steps.go index 42f7a85d75e..e8e79074881 100644 --- a/integration-tests/actions/vrf/vrfv2plus/setup_steps.go +++ b/integration-tests/actions/vrf/vrfv2plus/setup_steps.go @@ -358,12 +358,9 @@ func SetupVRFV2PlusWrapperEnvironment( func SetupVRFV2PlusUniverse( ctx context.Context, t *testing.T, - testConfig tc.TestConfig, - chainID int64, - cleanupFn func(), + envConfig vrfcommon.VRFEnvConfig, newEnvConfig vrfcommon.NewEnvConfig, l zerolog.Logger, - chainlinkNodeLogScannerSettings test_env.ChainlinkNodeLogScannerSettings, ) (*test_env.CLClusterTestEnv, *vrfcommon.VRFContracts, *vrfcommon.VRFKeyData, map[vrfcommon.VRFNodeType]*vrfcommon.VRFNode, error) { var ( env *test_env.CLClusterTestEnv @@ -372,13 +369,13 @@ func SetupVRFV2PlusUniverse( nodeTypeToNode map[vrfcommon.VRFNodeType]*vrfcommon.VRFNode err error ) - if *testConfig.VRFv2Plus.General.UseExistingEnv { - vrfContracts, vrfKey, env, err = SetupVRFV2PlusForExistingEnv(t, testConfig, chainID, cleanupFn, l) + if *envConfig.TestConfig.VRFv2Plus.General.UseExistingEnv { + vrfContracts, vrfKey, env, err = SetupVRFV2PlusForExistingEnv(t, envConfig, l) if err != nil { return nil, nil, nil, nil, fmt.Errorf("%s, err: %w", "Error setting up VRF V2 Plus for Existing env", err) } } else { - vrfContracts, vrfKey, env, nodeTypeToNode, err = SetupVRFV2PlusForNewEnv(ctx, t, testConfig, chainID, cleanupFn, newEnvConfig, l, chainlinkNodeLogScannerSettings) + vrfContracts, vrfKey, env, nodeTypeToNode, err = SetupVRFV2PlusForNewEnv(ctx, t, envConfig, newEnvConfig, l) if err != nil { return nil, nil, nil, nil, fmt.Errorf("%s, err: %w", "Error setting up VRF V2 Plus for New env", err) } @@ -389,52 +386,36 @@ func SetupVRFV2PlusUniverse( func SetupVRFV2PlusForNewEnv( ctx context.Context, t *testing.T, - testConfig tc.TestConfig, - chainID int64, - cleanupFn func(), + envConfig vrfcommon.VRFEnvConfig, newEnvConfig vrfcommon.NewEnvConfig, l zerolog.Logger, - chainlinkNodeLogScannerSettings test_env.ChainlinkNodeLogScannerSettings, ) (*vrfcommon.VRFContracts, *vrfcommon.VRFKeyData, *test_env.CLClusterTestEnv, map[vrfcommon.VRFNodeType]*vrfcommon.VRFNode, error) { - network, err := actions.EthereumNetworkConfigFromConfig(l, &testConfig) + network, err := actions.EthereumNetworkConfigFromConfig(l, &envConfig.TestConfig) if err != nil { - return nil, nil, nil, nil, fmt.Errorf("%s, err: %w", "Error building ethereum network config", err) + return nil, nil, nil, nil, fmt.Errorf("%s, err: %w", "Error building ethereum network config for V2Plus", err) } - env, err := test_env.NewCLTestEnvBuilder(). - WithTestInstance(t). - WithTestConfig(&testConfig). - WithPrivateEthereumNetwork(network.EthereumNetworkConfig). - WithCLNodes(len(newEnvConfig.NodesToCreate)). - WithFunding(big.NewFloat(*testConfig.Common.ChainlinkNodeFunding)). - WithChainlinkNodeLogScanner(chainlinkNodeLogScannerSettings). - WithCustomCleanup(cleanupFn). - WithSeth(). - Build() + env, err := vrfcommon.BuildNewCLEnvForVRF(t, envConfig, newEnvConfig, network) if err != nil { - return nil, nil, nil, nil, fmt.Errorf("%s, err: %w", "error creating test env", err) + return nil, nil, nil, nil, err } - - sethClient, err := env.GetSethClient(chainID) + sethClient, err := env.GetSethClient(envConfig.ChainID) if err != nil { return nil, nil, nil, nil, err } - - mockETHLinkFeed, err := contracts.DeployVRFMockETHLINKFeed(sethClient, big.NewInt(*testConfig.VRFv2Plus.General.LinkNativeFeedResponse)) + mockETHLinkFeed, err := contracts.DeployVRFMockETHLINKFeed(sethClient, big.NewInt(*envConfig.TestConfig.VRFv2Plus.General.LinkNativeFeedResponse)) if err != nil { return nil, nil, nil, nil, fmt.Errorf("%s, err: %w", "error deploying mock ETH/LINK feed", err) } - linkToken, err := contracts.DeployLinkTokenContract(l, sethClient) if err != nil { return nil, nil, nil, nil, fmt.Errorf("%s, err: %w", "error deploying LINK contract", err) } - vrfContracts, vrfKey, nodeTypeToNode, err := SetupVRFV2_5Environment( ctx, env, - chainID, + envConfig.ChainID, newEnvConfig.NodesToCreate, - &testConfig, + &envConfig.TestConfig, linkToken, mockETHLinkFeed, newEnvConfig.NumberOfTxKeysToCreate, @@ -446,23 +427,21 @@ func SetupVRFV2PlusForNewEnv( return vrfContracts, vrfKey, env, nodeTypeToNode, nil } -func SetupVRFV2PlusForExistingEnv(t *testing.T, testConfig tc.TestConfig, chainID int64, cleanupFn func(), l zerolog.Logger) (*vrfcommon.VRFContracts, *vrfcommon.VRFKeyData, *test_env.CLClusterTestEnv, error) { - commonExistingEnvConfig := testConfig.VRFv2Plus.ExistingEnvConfig.ExistingEnvConfig +func SetupVRFV2PlusForExistingEnv(t *testing.T, envConfig vrfcommon.VRFEnvConfig, l zerolog.Logger) (*vrfcommon.VRFContracts, *vrfcommon.VRFKeyData, *test_env.CLClusterTestEnv, error) { + commonExistingEnvConfig := envConfig.TestConfig.VRFv2Plus.ExistingEnvConfig.ExistingEnvConfig env, err := test_env.NewCLTestEnvBuilder(). WithTestInstance(t). - WithTestConfig(&testConfig). - WithCustomCleanup(cleanupFn). + WithTestConfig(&envConfig.TestConfig). + WithCustomCleanup(envConfig.CleanupFn). WithSeth(). Build() if err != nil { return nil, nil, nil, fmt.Errorf("%s, err: %w", "error creating test env", err) } - - sethClient, err := env.GetSethClient(chainID) + sethClient, err := env.GetSethClient(envConfig.ChainID) if err != nil { return nil, nil, nil, err } - coordinator, err := contracts.LoadVRFCoordinatorV2_5(sethClient, *commonExistingEnvConfig.CoordinatorAddress) if err != nil { return nil, nil, nil, fmt.Errorf("%s, err: %w", "error loading VRFCoordinator2_5", err) @@ -471,18 +450,24 @@ func SetupVRFV2PlusForExistingEnv(t *testing.T, testConfig tc.TestConfig, chainI if err != nil { return nil, nil, nil, fmt.Errorf("%s, err: %w", "error loading LinkToken", err) } - err = vrfcommon.FundNodesIfNeeded(testcontext.Get(t), commonExistingEnvConfig, sethClient, l) if err != nil { return nil, nil, nil, fmt.Errorf("err: %w", err) } + blockHashStoreAddress, err := coordinator.GetBlockHashStoreAddress(testcontext.Get(t)) + if err != nil { + return nil, nil, nil, fmt.Errorf("err: %w", err) + } + blockHashStore, err := contracts.LoadBlockHashStore(sethClient, blockHashStoreAddress.String()) + if err != nil { + return nil, nil, nil, fmt.Errorf("%s, err: %w", "error loading BlockHashStore", err) + } vrfContracts := &vrfcommon.VRFContracts{ CoordinatorV2Plus: coordinator, VRFV2PlusConsumer: nil, LinkToken: linkToken, - BHS: nil, + BHS: blockHashStore, } - vrfKey := &vrfcommon.VRFKeyData{ VRFKey: nil, EncodedProvingKey: [2]*big.Int{}, diff --git a/integration-tests/contracts/contract_loader.go b/integration-tests/contracts/contract_loader.go index a81643b17c0..0cfa53b81f4 100644 --- a/integration-tests/contracts/contract_loader.go +++ b/integration-tests/contracts/contract_loader.go @@ -6,14 +6,15 @@ import ( "github.com/smartcontractkit/seth" - "github.com/smartcontractkit/chainlink/integration-tests/wrappers" - "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/vrf_coordinator_v2_5" - "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/vrf_v2plus_load_test_with_metrics" - "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" "github.com/rs/zerolog" + "github.com/smartcontractkit/chainlink/integration-tests/wrappers" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/blockhash_store" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/vrf_coordinator_v2_5" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/vrf_v2plus_load_test_with_metrics" + "github.com/smartcontractkit/chainlink-testing-framework/blockchain" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/functions/generated/functions_coordinator" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/functions/generated/functions_load_test_client" @@ -384,6 +385,27 @@ func LoadVRFCoordinatorV2_5(seth *seth.Client, addr string) (VRFCoordinatorV2_5, }, nil } +func LoadBlockHashStore(seth *seth.Client, addr string) (BlockHashStore, error) { + address := common.HexToAddress(addr) + abi, err := blockhash_store.BlockhashStoreMetaData.GetAbi() + if err != nil { + return &EthereumBlockhashStore{}, fmt.Errorf("failed to get BlockHashStore ABI: %w", err) + } + seth.ContractStore.AddABI("BlockHashStore", *abi) + seth.ContractStore.AddBIN("BlockHashStore", common.FromHex(blockhash_store.BlockhashStoreMetaData.Bin)) + + contract, err := blockhash_store.NewBlockhashStore(address, wrappers.MustNewWrappedContractBackend(nil, seth)) + if err != nil { + return &EthereumBlockhashStore{}, fmt.Errorf("failed to instantiate BlockHashStore instance: %w", err) + } + + return &EthereumBlockhashStore{ + client: seth, + address: &address, + blockHashStore: contract, + }, nil +} + func LoadVRFv2PlusLoadTestConsumer(seth *seth.Client, addr string) (VRFv2PlusLoadTestConsumer, error) { address := common.HexToAddress(addr) abi, err := vrf_v2plus_load_test_with_metrics.VRFV2PlusLoadTestWithMetricsMetaData.GetAbi() diff --git a/integration-tests/contracts/contract_vrf_models.go b/integration-tests/contracts/contract_vrf_models.go index 7529696a77b..9ed08048998 100644 --- a/integration-tests/contracts/contract_vrf_models.go +++ b/integration-tests/contracts/contract_vrf_models.go @@ -75,6 +75,7 @@ type VRFCoordinatorV2 interface { WaitForRandomWordsFulfilledEvent(filter RandomWordsFulfilledEventFilter) (*CoordinatorRandomWordsFulfilled, error) WaitForConfigSetEvent(timeout time.Duration) (*CoordinatorConfigSet, error) OracleWithdraw(recipient common.Address, amount *big.Int) error + GetBlockHashStoreAddress(ctx context.Context) (common.Address, error) } type VRFCoordinatorV2_5 interface { @@ -118,6 +119,7 @@ type VRFCoordinatorV2_5 interface { ParseRandomWordsRequested(log types.Log) (*CoordinatorRandomWordsRequested, error) ParseRandomWordsFulfilled(log types.Log) (*CoordinatorRandomWordsFulfilled, error) WaitForConfigSetEvent(timeout time.Duration) (*CoordinatorConfigSet, error) + GetBlockHashStoreAddress(ctx context.Context) (common.Address, error) } type VRFCoordinatorV2PlusUpgradedVersion interface { diff --git a/integration-tests/contracts/ethereum_vrfv2_contracts.go b/integration-tests/contracts/ethereum_vrfv2_contracts.go index 8786f201b29..9a8ab1c5b5b 100644 --- a/integration-tests/contracts/ethereum_vrfv2_contracts.go +++ b/integration-tests/contracts/ethereum_vrfv2_contracts.go @@ -637,6 +637,18 @@ func (v *EthereumVRFCoordinatorV2) FindSubscriptionID(subID uint64) (uint64, err return subscriptionIterator.Event.SubId, nil } +func (v *EthereumVRFCoordinatorV2) GetBlockHashStoreAddress(ctx context.Context) (common.Address, error) { + opts := &bind.CallOpts{ + From: v.client.MustGetRootKeyAddress(), + Context: ctx, + } + blockHashStoreAddress, err := v.coordinator.BLOCKHASHSTORE(opts) + if err != nil { + return common.Address{}, err + } + return blockHashStoreAddress, nil +} + func (v *EthereumVRFCoordinatorV2) WaitForRandomWordsFulfilledEvent(filter RandomWordsFulfilledEventFilter) (*CoordinatorRandomWordsFulfilled, error) { randomWordsFulfilledEventsChannel := make(chan *vrf_coordinator_v2.VRFCoordinatorV2RandomWordsFulfilled) subscription, err := v.coordinator.WatchRandomWordsFulfilled(nil, randomWordsFulfilledEventsChannel, filter.RequestIds) diff --git a/integration-tests/contracts/ethereum_vrfv2plus_contracts.go b/integration-tests/contracts/ethereum_vrfv2plus_contracts.go index 16f2ec203e7..ba7234fbbf3 100644 --- a/integration-tests/contracts/ethereum_vrfv2plus_contracts.go +++ b/integration-tests/contracts/ethereum_vrfv2plus_contracts.go @@ -288,6 +288,18 @@ func (v *EthereumVRFCoordinatorV2_5) GetNativeTokenTotalBalance(ctx context.Cont return totalBalance, nil } +func (v *EthereumVRFCoordinatorV2_5) GetBlockHashStoreAddress(ctx context.Context) (common.Address, error) { + opts := &bind.CallOpts{ + From: v.client.MustGetRootKeyAddress(), + Context: ctx, + } + blockHashStoreAddress, err := v.coordinator.BLOCKHASHSTORE(opts) + if err != nil { + return common.Address{}, err + } + return blockHashStoreAddress, nil +} + // OwnerCancelSubscription cancels subscription by Coordinator owner // return funds to sub owner, // does not check if pending requests for a sub exist diff --git a/integration-tests/load/vrfv2/vrfv2_test.go b/integration-tests/load/vrfv2/vrfv2_test.go index 895e59a2b18..fb144e23a2e 100644 --- a/integration-tests/load/vrfv2/vrfv2_test.go +++ b/integration-tests/load/vrfv2/vrfv2_test.go @@ -94,15 +94,19 @@ func TestVRFV2Performance(t *testing.T) { } } } - + vrfEnvConfig := vrfcommon.VRFEnvConfig{ + TestConfig: testConfig, + ChainID: chainID, + CleanupFn: cleanupFn, + } newEnvConfig := vrfcommon.NewEnvConfig{ - NodesToCreate: []vrfcommon.VRFNodeType{vrfcommon.VRF}, - NumberOfTxKeysToCreate: *vrfv2Config.General.NumberOfSendingKeysToCreate, - UseVRFOwner: true, - UseTestCoordinator: true, + NodesToCreate: []vrfcommon.VRFNodeType{vrfcommon.VRF}, + NumberOfTxKeysToCreate: *vrfv2Config.General.NumberOfSendingKeysToCreate, + UseVRFOwner: true, + UseTestCoordinator: true, + ChainlinkNodeLogScannerSettings: test_env.DefaultChainlinkNodeLogScannerSettings, } - - testEnv, vrfContracts, vrfKey, _, err = vrfv2.SetupVRFV2Universe(testcontext.Get(t), t, testConfig, chainID, cleanupFn, newEnvConfig, l, test_env.DefaultChainlinkNodeLogScannerSettings) + testEnv, vrfContracts, vrfKey, _, err = vrfv2.SetupVRFV2Universe(testcontext.Get(t), t, vrfEnvConfig, newEnvConfig, l) require.NoError(t, err, "error setting up VRFV2 universe") var consumers []contracts.VRFv2LoadTestConsumer @@ -210,13 +214,13 @@ func TestVRFV2BHSPerformance(t *testing.T) { Bool("UseExistingEnv", *vrfv2Config.General.UseExistingEnv). Msg("Performance Test Configuration") - chainID := networks.MustGetSelectedNetworkConfig(testConfig.GetNetworkConfig())[0].ChainID - sethClient, err := testEnv.GetSethClient(chainID) - + network := networks.MustGetSelectedNetworkConfig(testConfig.GetNetworkConfig())[0] + chainID := network.ChainID + sethClient, err := actions_seth.GetChainClient(testConfig, network) + require.NoError(t, err, "Error creating seth client") cleanupFn := func() { teardown(t, vrfContracts.VRFV2Consumers[0], lc, updatedLabels, testReporter, testType, &testConfig) - require.NoError(t, err, "Getting Seth client shouldn't fail") if sethClient.Cfg.IsSimulatedNetwork() { l.Info(). Str("Network Name", sethClient.Cfg.Network.Name). @@ -233,15 +237,19 @@ func TestVRFV2BHSPerformance(t *testing.T) { } } } - + vrfEnvConfig := vrfcommon.VRFEnvConfig{ + TestConfig: testConfig, + ChainID: chainID, + CleanupFn: cleanupFn, + } newEnvConfig := vrfcommon.NewEnvConfig{ - NodesToCreate: []vrfcommon.VRFNodeType{vrfcommon.VRF}, - NumberOfTxKeysToCreate: *vrfv2Config.General.NumberOfSendingKeysToCreate, - UseVRFOwner: true, - UseTestCoordinator: true, + NodesToCreate: []vrfcommon.VRFNodeType{vrfcommon.VRF}, + NumberOfTxKeysToCreate: *vrfv2Config.General.NumberOfSendingKeysToCreate, + UseVRFOwner: true, + UseTestCoordinator: true, + ChainlinkNodeLogScannerSettings: test_env.DefaultChainlinkNodeLogScannerSettings, } - - testEnv, vrfContracts, vrfKey, _, err = vrfv2.SetupVRFV2Universe(testcontext.Get(t), t, testConfig, chainID, cleanupFn, newEnvConfig, l, test_env.DefaultChainlinkNodeLogScannerSettings) + testEnv, vrfContracts, vrfKey, _, err = vrfv2.SetupVRFV2Universe(testcontext.Get(t), t, vrfEnvConfig, newEnvConfig, l) require.NoError(t, err, "error setting up VRFV2 universe") t.Run("vrfv2 and bhs performance test", func(t *testing.T) { @@ -302,8 +310,6 @@ func TestVRFV2BHSPerformance(t *testing.T) { var wgBlockNumberTobe sync.WaitGroup wgBlockNumberTobe.Add(1) //Wait at least 256 blocks - sethClient, err := testEnv.GetSethClient(chainID) - require.NoError(t, err, "Getting Seth client shouldn't fail") latestBlockNumber, err := sethClient.Client.BlockNumber(testcontext.Get(t)) require.NoError(t, err) _, err = actions.WaitForBlockNumberToBe( diff --git a/integration-tests/load/vrfv2plus/vrfv2plus_test.go b/integration-tests/load/vrfv2plus/vrfv2plus_test.go index b62f2815329..05feb6fd5a9 100644 --- a/integration-tests/load/vrfv2plus/vrfv2plus_test.go +++ b/integration-tests/load/vrfv2plus/vrfv2plus_test.go @@ -91,13 +91,17 @@ func TestVRFV2PlusPerformance(t *testing.T) { } } } - + vrfEnvConfig := vrfcommon.VRFEnvConfig{ + TestConfig: testConfig, + ChainID: chainID, + CleanupFn: cleanupFn, + } newEnvConfig := vrfcommon.NewEnvConfig{ - NodesToCreate: []vrfcommon.VRFNodeType{vrfcommon.VRF}, - NumberOfTxKeysToCreate: *vrfv2PlusConfig.General.NumberOfSendingKeysToCreate, + NodesToCreate: []vrfcommon.VRFNodeType{vrfcommon.VRF}, + NumberOfTxKeysToCreate: *vrfv2PlusConfig.General.NumberOfSendingKeysToCreate, + ChainlinkNodeLogScannerSettings: test_env.DefaultChainlinkNodeLogScannerSettings, } - - testEnv, vrfContracts, vrfKey, _, err = vrfv2plus.SetupVRFV2PlusUniverse(testcontext.Get(t), t, testConfig, chainID, cleanupFn, newEnvConfig, l, test_env.DefaultChainlinkNodeLogScannerSettings) + testEnv, vrfContracts, vrfKey, _, err = vrfv2plus.SetupVRFV2PlusUniverse(testcontext.Get(t), t, vrfEnvConfig, newEnvConfig, l) require.NoError(t, err, "error setting up VRFV2Plus universe") var consumers []contracts.VRFv2PlusLoadTestConsumer @@ -209,7 +213,7 @@ func TestVRFV2PlusBHSPerformance(t *testing.T) { network := networks.MustGetSelectedNetworkConfig(testConfig.GetNetworkConfig())[0] chainID := network.ChainID - sethClient, err := actions_seth.GetChainClientWithConfigFunction(testConfig, network, actions_seth.OneEphemeralKeysLiveTestnetCheckFn) + sethClient, err := actions_seth.GetChainClient(testConfig, network) require.NoError(t, err, "Error creating seth client") cleanupFn := func() { @@ -232,12 +236,17 @@ func TestVRFV2PlusBHSPerformance(t *testing.T) { } } + vrfEnvConfig := vrfcommon.VRFEnvConfig{ + TestConfig: testConfig, + ChainID: chainID, + CleanupFn: cleanupFn, + } newEnvConfig := vrfcommon.NewEnvConfig{ - NodesToCreate: []vrfcommon.VRFNodeType{vrfcommon.VRF, vrfcommon.BHS}, - NumberOfTxKeysToCreate: *vrfv2PlusConfig.General.NumberOfSendingKeysToCreate, + NodesToCreate: []vrfcommon.VRFNodeType{vrfcommon.VRF, vrfcommon.BHS}, + NumberOfTxKeysToCreate: *vrfv2PlusConfig.General.NumberOfSendingKeysToCreate, + ChainlinkNodeLogScannerSettings: test_env.DefaultChainlinkNodeLogScannerSettings, } - - testEnv, vrfContracts, vrfKey, _, err = vrfv2plus.SetupVRFV2PlusUniverse(testcontext.Get(t), t, testConfig, chainID, cleanupFn, newEnvConfig, l, test_env.DefaultChainlinkNodeLogScannerSettings) + testEnv, vrfContracts, vrfKey, _, err = vrfv2plus.SetupVRFV2PlusUniverse(testcontext.Get(t), t, vrfEnvConfig, newEnvConfig, l) require.NoError(t, err, "error setting up VRFV2Plus universe") t.Run("vrfv2plus and bhs performance test", func(t *testing.T) { diff --git a/integration-tests/smoke/vrfv2_test.go b/integration-tests/smoke/vrfv2_test.go index 3fee1722cb0..0b8a3b9c8fa 100644 --- a/integration-tests/smoke/vrfv2_test.go +++ b/integration-tests/smoke/vrfv2_test.go @@ -3,6 +3,7 @@ package smoke import ( "fmt" "math/big" + "os" "strconv" "strings" "sync" @@ -72,14 +73,19 @@ func TestVRFv2Basic(t *testing.T) { } } } + vrfEnvConfig := vrfcommon.VRFEnvConfig{ + TestConfig: config, + ChainID: chainID, + CleanupFn: cleanupFn, + } newEnvConfig := vrfcommon.NewEnvConfig{ - NodesToCreate: []vrfcommon.VRFNodeType{vrfcommon.VRF}, - NumberOfTxKeysToCreate: 0, - UseVRFOwner: false, - UseTestCoordinator: false, + NodesToCreate: []vrfcommon.VRFNodeType{vrfcommon.VRF}, + NumberOfTxKeysToCreate: 0, + UseVRFOwner: false, + UseTestCoordinator: false, + ChainlinkNodeLogScannerSettings: test_env.DefaultChainlinkNodeLogScannerSettings, } - - testEnv, vrfContracts, vrfKey, nodeTypeToNodeMap, err = vrfv2.SetupVRFV2Universe(testcontext.Get(t), t, config, chainID, cleanupFn, newEnvConfig, l, test_env.DefaultChainlinkNodeLogScannerSettings) + testEnv, vrfContracts, vrfKey, nodeTypeToNodeMap, err = vrfv2.SetupVRFV2Universe(testcontext.Get(t), t, vrfEnvConfig, newEnvConfig, l) require.NoError(t, err, "Error setting up VRFV2 universe") sethClient, err := testEnv.GetSethClient(chainID) @@ -597,14 +603,19 @@ func TestVRFv2MultipleSendingKeys(t *testing.T) { } } } + vrfEnvConfig := vrfcommon.VRFEnvConfig{ + TestConfig: config, + ChainID: chainID, + CleanupFn: cleanupFn, + } newEnvConfig := vrfcommon.NewEnvConfig{ - NodesToCreate: []vrfcommon.VRFNodeType{vrfcommon.VRF}, - NumberOfTxKeysToCreate: 2, - UseVRFOwner: false, - UseTestCoordinator: false, + NodesToCreate: []vrfcommon.VRFNodeType{vrfcommon.VRF}, + NumberOfTxKeysToCreate: 2, + UseVRFOwner: false, + UseTestCoordinator: false, + ChainlinkNodeLogScannerSettings: test_env.DefaultChainlinkNodeLogScannerSettings, } - - testEnv, vrfContracts, vrfKey, nodeTypeToNodeMap, err = vrfv2.SetupVRFV2Universe(testcontext.Get(t), t, config, chainID, cleanupFn, newEnvConfig, l, test_env.DefaultChainlinkNodeLogScannerSettings) + testEnv, vrfContracts, vrfKey, nodeTypeToNodeMap, err = vrfv2.SetupVRFV2Universe(testcontext.Get(t), t, vrfEnvConfig, newEnvConfig, l) require.NoError(t, err, "Error setting up VRFV2 universe") t.Run("Request Randomness with multiple sending keys", func(t *testing.T) { @@ -702,14 +713,19 @@ func TestVRFOwner(t *testing.T) { } } } + vrfEnvConfig := vrfcommon.VRFEnvConfig{ + TestConfig: config, + ChainID: chainID, + CleanupFn: cleanupFn, + } newEnvConfig := vrfcommon.NewEnvConfig{ - NodesToCreate: []vrfcommon.VRFNodeType{vrfcommon.VRF}, - NumberOfTxKeysToCreate: 0, - UseVRFOwner: true, - UseTestCoordinator: true, + NodesToCreate: []vrfcommon.VRFNodeType{vrfcommon.VRF}, + NumberOfTxKeysToCreate: 0, + UseVRFOwner: true, + UseTestCoordinator: true, + ChainlinkNodeLogScannerSettings: test_env.DefaultChainlinkNodeLogScannerSettings, } - - testEnv, vrfContracts, vrfKey, _, err = vrfv2.SetupVRFV2Universe(testcontext.Get(t), t, config, chainID, cleanupFn, newEnvConfig, l, test_env.DefaultChainlinkNodeLogScannerSettings) + testEnv, vrfContracts, vrfKey, _, err = vrfv2.SetupVRFV2Universe(testcontext.Get(t), t, vrfEnvConfig, newEnvConfig, l) require.NoError(t, err, "Error setting up VRFV2 universe") t.Run("Request Randomness With Force-Fulfill", func(t *testing.T) { @@ -839,19 +855,24 @@ func TestVRFV2WithBHS(t *testing.T) { //decrease default span for checking blockhashes for unfulfilled requests vrfv2Config.General.BHSJobWaitBlocks = ptr.Ptr(2) vrfv2Config.General.BHSJobLookBackBlocks = ptr.Ptr(20) - + vrfEnvConfig := vrfcommon.VRFEnvConfig{ + TestConfig: config, + ChainID: chainID, + CleanupFn: cleanupFn, + } newEnvConfig := vrfcommon.NewEnvConfig{ NodesToCreate: []vrfcommon.VRFNodeType{vrfcommon.VRF, vrfcommon.BHS}, NumberOfTxKeysToCreate: 0, UseVRFOwner: false, UseTestCoordinator: false, } - - testEnv, vrfContracts, vrfKey, nodeTypeToNodeMap, err = vrfv2.SetupVRFV2Universe(testcontext.Get(t), t, config, chainID, cleanupFn, newEnvConfig, l, test_env.DefaultChainlinkNodeLogScannerSettings) + testEnv, vrfContracts, vrfKey, nodeTypeToNodeMap, err = vrfv2.SetupVRFV2Universe(testcontext.Get(t), t, vrfEnvConfig, newEnvConfig, l) require.NoError(t, err, "Error setting up VRFV2 universe") t.Run("BHS Job with complete E2E - wait 256 blocks to see if Rand Request is fulfilled", func(t *testing.T) { - t.Skip("Skipped since should be run on-demand on live testnet due to long execution time") + if os.Getenv("TEST_UNSKIP") != "true" { + t.Skip("Skipped due to long execution time. Should be run on-demand on live testnet with TEST_UNSKIP=\"true\".") + } //BHS node should fill in blockhashes into BHS contract depending on the waitBlocks and lookBackBlocks settings configCopy := config.MustCopy().(tc.TestConfig) @@ -1055,12 +1076,6 @@ func TestVRFV2NodeReorg(t *testing.T) { } } } - newEnvConfig := vrfcommon.NewEnvConfig{ - NodesToCreate: []vrfcommon.VRFNodeType{vrfcommon.VRF}, - NumberOfTxKeysToCreate: 0, - UseVRFOwner: false, - UseTestCoordinator: false, - } chainlinkNodeLogScannerSettings := test_env.GetDefaultChainlinkNodeLogScannerSettingsWithExtraAllowedMessages( testreporters.NewAllowedLogMessage( @@ -1074,8 +1089,19 @@ func TestVRFV2NodeReorg(t *testing.T) { zapcore.DPanicLevel, testreporters.WarnAboutAllowedMsgs_No), ) - - env, vrfContracts, vrfKey, _, err = vrfv2.SetupVRFV2Universe(testcontext.Get(t), t, config, chainID, cleanupFn, newEnvConfig, l, chainlinkNodeLogScannerSettings) + vrfEnvConfig := vrfcommon.VRFEnvConfig{ + TestConfig: config, + ChainID: chainID, + CleanupFn: cleanupFn, + } + newEnvConfig := vrfcommon.NewEnvConfig{ + NodesToCreate: []vrfcommon.VRFNodeType{vrfcommon.VRF}, + NumberOfTxKeysToCreate: 0, + UseVRFOwner: false, + UseTestCoordinator: false, + ChainlinkNodeLogScannerSettings: chainlinkNodeLogScannerSettings, + } + env, vrfContracts, vrfKey, _, err = vrfv2.SetupVRFV2Universe(testcontext.Get(t), t, vrfEnvConfig, newEnvConfig, l) require.NoError(t, err, "Error setting up VRFv2 universe") sethClient, err := env.GetSethClient(chainID) @@ -1230,14 +1256,18 @@ func TestVRFv2BatchFulfillmentEnabledDisabled(t *testing.T) { } } } + vrfEnvConfig := vrfcommon.VRFEnvConfig{ + TestConfig: config, + ChainID: chainID, + CleanupFn: cleanupFn, + } newEnvConfig := vrfcommon.NewEnvConfig{ NodesToCreate: []vrfcommon.VRFNodeType{vrfcommon.VRF}, NumberOfTxKeysToCreate: 0, UseVRFOwner: false, UseTestCoordinator: false, } - - env, vrfContracts, vrfKey, nodeTypeToNodeMap, err = vrfv2.SetupVRFV2Universe(testcontext.Get(t), t, config, chainID, cleanupFn, newEnvConfig, l, test_env.DefaultChainlinkNodeLogScannerSettings) + env, vrfContracts, vrfKey, nodeTypeToNodeMap, err = vrfv2.SetupVRFV2Universe(testcontext.Get(t), t, vrfEnvConfig, newEnvConfig, l) require.NoError(t, err, "Error setting up VRFv2 universe") sethClient, err := env.GetSethClient(chainID) diff --git a/integration-tests/smoke/vrfv2plus_test.go b/integration-tests/smoke/vrfv2plus_test.go index 4007c7719f3..ecc72632ab6 100644 --- a/integration-tests/smoke/vrfv2plus_test.go +++ b/integration-tests/smoke/vrfv2plus_test.go @@ -3,6 +3,7 @@ package smoke import ( "fmt" "math/big" + "os" "strings" "sync" "testing" @@ -70,14 +71,19 @@ func TestVRFv2Plus(t *testing.T) { } } } + vrfEnvConfig := vrfcommon.VRFEnvConfig{ + TestConfig: config, + ChainID: chainID, + CleanupFn: cleanupFn, + } newEnvConfig := vrfcommon.NewEnvConfig{ - NodesToCreate: []vrfcommon.VRFNodeType{vrfcommon.VRF}, - NumberOfTxKeysToCreate: 0, - UseVRFOwner: false, - UseTestCoordinator: false, + NodesToCreate: []vrfcommon.VRFNodeType{vrfcommon.VRF}, + NumberOfTxKeysToCreate: 0, + UseVRFOwner: false, + UseTestCoordinator: false, + ChainlinkNodeLogScannerSettings: test_env.DefaultChainlinkNodeLogScannerSettings, } - - env, vrfContracts, vrfKey, nodeTypeToNodeMap, err = vrfv2plus.SetupVRFV2PlusUniverse(testcontext.Get(t), t, config, chainID, cleanupFn, newEnvConfig, l, test_env.DefaultChainlinkNodeLogScannerSettings) + env, vrfContracts, vrfKey, nodeTypeToNodeMap, err = vrfv2plus.SetupVRFV2PlusUniverse(testcontext.Get(t), t, vrfEnvConfig, newEnvConfig, l) require.NoError(t, err, "Error setting up VRFv2Plus universe") sethClient, err := env.GetSethClient(chainID) @@ -770,14 +776,19 @@ func TestVRFv2PlusMultipleSendingKeys(t *testing.T) { } } } + vrfEnvConfig := vrfcommon.VRFEnvConfig{ + TestConfig: config, + ChainID: chainID, + CleanupFn: cleanupFn, + } newEnvConfig := vrfcommon.NewEnvConfig{ - NodesToCreate: []vrfcommon.VRFNodeType{vrfcommon.VRF}, - NumberOfTxKeysToCreate: 2, - UseVRFOwner: false, - UseTestCoordinator: false, + NodesToCreate: []vrfcommon.VRFNodeType{vrfcommon.VRF}, + NumberOfTxKeysToCreate: 2, + UseVRFOwner: false, + UseTestCoordinator: false, + ChainlinkNodeLogScannerSettings: test_env.DefaultChainlinkNodeLogScannerSettings, } - - env, vrfContracts, vrfKey, nodeTypeToNodeMap, err = vrfv2plus.SetupVRFV2PlusUniverse(testcontext.Get(t), t, config, chainID, cleanupFn, newEnvConfig, l, test_env.DefaultChainlinkNodeLogScannerSettings) + env, vrfContracts, vrfKey, nodeTypeToNodeMap, err = vrfv2plus.SetupVRFV2PlusUniverse(testcontext.Get(t), t, vrfEnvConfig, newEnvConfig, l) require.NoError(t, err, "error setting up VRFV2Plus universe") t.Run("Request Randomness with multiple sending keys", func(t *testing.T) { @@ -874,14 +885,19 @@ func TestVRFv2PlusMigration(t *testing.T) { } } } + vrfEnvConfig := vrfcommon.VRFEnvConfig{ + TestConfig: config, + ChainID: chainID, + CleanupFn: cleanupFn, + } newEnvConfig := vrfcommon.NewEnvConfig{ - NodesToCreate: []vrfcommon.VRFNodeType{vrfcommon.VRF}, - NumberOfTxKeysToCreate: 0, - UseVRFOwner: false, - UseTestCoordinator: false, + NodesToCreate: []vrfcommon.VRFNodeType{vrfcommon.VRF}, + NumberOfTxKeysToCreate: 0, + UseVRFOwner: false, + UseTestCoordinator: false, + ChainlinkNodeLogScannerSettings: test_env.DefaultChainlinkNodeLogScannerSettings, } - - env, vrfContracts, vrfKey, nodeTypeToNodeMap, err = vrfv2plus.SetupVRFV2PlusUniverse(testcontext.Get(t), t, config, chainID, cleanupFn, newEnvConfig, l, test_env.DefaultChainlinkNodeLogScannerSettings) + env, vrfContracts, vrfKey, nodeTypeToNodeMap, err = vrfv2plus.SetupVRFV2PlusUniverse(testcontext.Get(t), t, vrfEnvConfig, newEnvConfig, l) require.NoError(t, err, "error setting up VRFV2Plus universe") sethClient, err := env.GetSethClient(chainID) @@ -1271,15 +1287,19 @@ func TestVRFV2PlusWithBHS(t *testing.T) { //decrease default span for checking blockhashes for unfulfilled requests vrfv2PlusConfig.General.BHSJobWaitBlocks = ptr.Ptr(2) vrfv2PlusConfig.General.BHSJobLookBackBlocks = ptr.Ptr(20) - + vrfEnvConfig := vrfcommon.VRFEnvConfig{ + TestConfig: config, + ChainID: chainID, + CleanupFn: cleanupFn, + } newEnvConfig := vrfcommon.NewEnvConfig{ - NodesToCreate: []vrfcommon.VRFNodeType{vrfcommon.VRF, vrfcommon.BHS}, - NumberOfTxKeysToCreate: 0, - UseVRFOwner: false, - UseTestCoordinator: false, + NodesToCreate: []vrfcommon.VRFNodeType{vrfcommon.VRF, vrfcommon.BHS}, + NumberOfTxKeysToCreate: 0, + UseVRFOwner: false, + UseTestCoordinator: false, + ChainlinkNodeLogScannerSettings: test_env.DefaultChainlinkNodeLogScannerSettings, } - - env, vrfContracts, vrfKey, nodeTypeToNodeMap, err = vrfv2plus.SetupVRFV2PlusUniverse(testcontext.Get(t), t, config, chainID, cleanupFn, newEnvConfig, l, test_env.DefaultChainlinkNodeLogScannerSettings) + env, vrfContracts, vrfKey, nodeTypeToNodeMap, err = vrfv2plus.SetupVRFV2PlusUniverse(testcontext.Get(t), t, vrfEnvConfig, newEnvConfig, l) require.NoError(t, err, "error setting up VRFV2Plus universe") sethClient, err := env.GetSethClient(chainID) @@ -1287,7 +1307,9 @@ func TestVRFV2PlusWithBHS(t *testing.T) { var isNativeBilling = true t.Run("BHS Job with complete E2E - wait 256 blocks to see if Rand Request is fulfilled", func(t *testing.T) { - t.Skip("Skipped since should be run on-demand on live testnet due to long execution time") + if os.Getenv("TEST_UNSKIP") != "true" { + t.Skip("Skipped due to long execution time. Should be run on-demand on live testnet with TEST_UNSKIP=\"true\".") + } configCopy := config.MustCopy().(tc.TestConfig) //Underfund Subscription configCopy.VRFv2Plus.General.SubscriptionFundingAmountLink = ptr.Ptr(float64(0)) @@ -1502,22 +1524,25 @@ func TestVRFV2PlusWithBHF(t *testing.T) { config.VRFv2Plus.General.BHFJobLookBackBlocks = ptr.Ptr(500) config.VRFv2Plus.General.BHFJobPollPeriod = ptr.Ptr(blockchain.StrDuration{Duration: time.Second * 30}) config.VRFv2Plus.General.BHFJobRunTimeout = ptr.Ptr(blockchain.StrDuration{Duration: time.Minute * 24}) - - newEnvConfig := vrfcommon.NewEnvConfig{ - NodesToCreate: []vrfcommon.VRFNodeType{vrfcommon.VRF, vrfcommon.BHF}, - NumberOfTxKeysToCreate: 0, - UseVRFOwner: false, - UseTestCoordinator: false, + vrfEnvConfig := vrfcommon.VRFEnvConfig{ + TestConfig: config, + ChainID: chainID, + CleanupFn: cleanupFn, } - chainlinkNodeLogScannerSettings := test_env.GetDefaultChainlinkNodeLogScannerSettingsWithExtraAllowedMessages(testreporters.NewAllowedLogMessage( "Pipeline error", "Test is expecting this error to occur", zapcore.DPanicLevel, testreporters.WarnAboutAllowedMsgs_No)) - + newEnvConfig := vrfcommon.NewEnvConfig{ + NodesToCreate: []vrfcommon.VRFNodeType{vrfcommon.VRF, vrfcommon.BHF}, + NumberOfTxKeysToCreate: 0, + UseVRFOwner: false, + UseTestCoordinator: false, + ChainlinkNodeLogScannerSettings: chainlinkNodeLogScannerSettings, + } env, vrfContracts, vrfKey, nodeTypeToNodeMap, err = vrfv2plus.SetupVRFV2PlusUniverse( - testcontext.Get(t), t, config, chainID, cleanupFn, newEnvConfig, l, chainlinkNodeLogScannerSettings) + testcontext.Get(t), t, vrfEnvConfig, newEnvConfig, l) require.NoError(t, err) sethClient, err := env.GetSethClient(chainID) @@ -1525,7 +1550,6 @@ func TestVRFV2PlusWithBHF(t *testing.T) { var isNativeBilling = true t.Run("BHF Job with complete E2E - wait 256 blocks to see if Rand Request is fulfilled", func(t *testing.T) { - // t.Skip("Skipped since should be run on-demand on live testnet due to long execution time") configCopy := config.MustCopy().(tc.TestConfig) // Underfund Subscription configCopy.VRFv2Plus.General.SubscriptionFundingAmountLink = ptr.Ptr(float64(0)) @@ -1656,20 +1680,25 @@ func TestVRFv2PlusReplayAfterTimeout(t *testing.T) { } } } + vrfEnvConfig := vrfcommon.VRFEnvConfig{ + TestConfig: config, + ChainID: chainID, + CleanupFn: cleanupFn, + } newEnvConfig := vrfcommon.NewEnvConfig{ - NodesToCreate: []vrfcommon.VRFNodeType{vrfcommon.VRF}, - NumberOfTxKeysToCreate: 0, - UseVRFOwner: false, - UseTestCoordinator: false, + NodesToCreate: []vrfcommon.VRFNodeType{vrfcommon.VRF}, + NumberOfTxKeysToCreate: 0, + UseVRFOwner: false, + UseTestCoordinator: false, + ChainlinkNodeLogScannerSettings: test_env.DefaultChainlinkNodeLogScannerSettings, } - // 1. Add job spec with requestTimeout = 5 seconds timeout := time.Second * 5 config.VRFv2Plus.General.VRFJobRequestTimeout = ptr.Ptr(blockchain.StrDuration{Duration: timeout}) config.VRFv2Plus.General.SubscriptionFundingAmountLink = ptr.Ptr(float64(0)) config.VRFv2Plus.General.SubscriptionFundingAmountNative = ptr.Ptr(float64(0)) - env, vrfContracts, vrfKey, nodeTypeToNodeMap, err = vrfv2plus.SetupVRFV2PlusUniverse(testcontext.Get(t), t, config, chainID, cleanupFn, newEnvConfig, l, test_env.DefaultChainlinkNodeLogScannerSettings) + env, vrfContracts, vrfKey, nodeTypeToNodeMap, err = vrfv2plus.SetupVRFV2PlusUniverse(testcontext.Get(t), t, vrfEnvConfig, newEnvConfig, l) require.NoError(t, err, "error setting up VRFV2Plus universe") t.Run("Timed out request fulfilled after node restart with replay", func(t *testing.T) { @@ -1852,18 +1881,24 @@ func TestVRFv2PlusPendingBlockSimulationAndZeroConfirmationDelays(t *testing.T) } } } + vrfEnvConfig := vrfcommon.VRFEnvConfig{ + TestConfig: config, + ChainID: chainID, + CleanupFn: cleanupFn, + } newEnvConfig := vrfcommon.NewEnvConfig{ - NodesToCreate: []vrfcommon.VRFNodeType{vrfcommon.VRF}, - NumberOfTxKeysToCreate: 0, - UseVRFOwner: false, - UseTestCoordinator: false, + NodesToCreate: []vrfcommon.VRFNodeType{vrfcommon.VRF}, + NumberOfTxKeysToCreate: 0, + UseVRFOwner: false, + UseTestCoordinator: false, + ChainlinkNodeLogScannerSettings: test_env.DefaultChainlinkNodeLogScannerSettings, } // override config with minConf = 0 and use pending block for simulation config.VRFv2Plus.General.MinimumConfirmations = ptr.Ptr[uint16](0) config.VRFv2Plus.General.VRFJobSimulationBlock = ptr.Ptr[string]("pending") - env, vrfContracts, vrfKey, _, err = vrfv2plus.SetupVRFV2PlusUniverse(testcontext.Get(t), t, config, chainID, cleanupFn, newEnvConfig, l, test_env.DefaultChainlinkNodeLogScannerSettings) + env, vrfContracts, vrfKey, _, err = vrfv2plus.SetupVRFV2PlusUniverse(testcontext.Get(t), t, vrfEnvConfig, newEnvConfig, l) require.NoError(t, err, "error setting up VRFV2Plus universe") consumers, subIDs, err := vrfv2plus.SetupNewConsumersAndSubs( @@ -1942,13 +1977,11 @@ func TestVRFv2PlusNodeReorg(t *testing.T) { } } } - newEnvConfig := vrfcommon.NewEnvConfig{ - NodesToCreate: []vrfcommon.VRFNodeType{vrfcommon.VRF}, - NumberOfTxKeysToCreate: 0, - UseVRFOwner: false, - UseTestCoordinator: false, + vrfEnvConfig := vrfcommon.VRFEnvConfig{ + TestConfig: config, + ChainID: chainID, + CleanupFn: cleanupFn, } - chainlinkNodeLogScannerSettings := test_env.GetDefaultChainlinkNodeLogScannerSettingsWithExtraAllowedMessages( testreporters.NewAllowedLogMessage( "This is a problem and either means a very deep re-org occurred", @@ -1961,8 +1994,14 @@ func TestVRFv2PlusNodeReorg(t *testing.T) { zapcore.DPanicLevel, testreporters.WarnAboutAllowedMsgs_No), ) - - env, vrfContracts, vrfKey, _, err = vrfv2plus.SetupVRFV2PlusUniverse(testcontext.Get(t), t, config, chainID, cleanupFn, newEnvConfig, l, chainlinkNodeLogScannerSettings) + newEnvConfig := vrfcommon.NewEnvConfig{ + NodesToCreate: []vrfcommon.VRFNodeType{vrfcommon.VRF}, + NumberOfTxKeysToCreate: 0, + UseVRFOwner: false, + UseTestCoordinator: false, + ChainlinkNodeLogScannerSettings: chainlinkNodeLogScannerSettings, + } + env, vrfContracts, vrfKey, _, err = vrfv2plus.SetupVRFV2PlusUniverse(testcontext.Get(t), t, vrfEnvConfig, newEnvConfig, l) require.NoError(t, err, "Error setting up VRFv2Plus universe") var isNativeBilling = true @@ -2117,14 +2156,19 @@ func TestVRFv2PlusBatchFulfillmentEnabledDisabled(t *testing.T) { } } } + vrfEnvConfig := vrfcommon.VRFEnvConfig{ + TestConfig: config, + ChainID: chainID, + CleanupFn: cleanupFn, + } newEnvConfig := vrfcommon.NewEnvConfig{ - NodesToCreate: []vrfcommon.VRFNodeType{vrfcommon.VRF}, - NumberOfTxKeysToCreate: 0, - UseVRFOwner: false, - UseTestCoordinator: false, + NodesToCreate: []vrfcommon.VRFNodeType{vrfcommon.VRF}, + NumberOfTxKeysToCreate: 0, + UseVRFOwner: false, + UseTestCoordinator: false, + ChainlinkNodeLogScannerSettings: test_env.DefaultChainlinkNodeLogScannerSettings, } - - env, vrfContracts, vrfKey, nodeTypeToNodeMap, err = vrfv2plus.SetupVRFV2PlusUniverse(testcontext.Get(t), t, config, chainID, cleanupFn, newEnvConfig, l, test_env.DefaultChainlinkNodeLogScannerSettings) + env, vrfContracts, vrfKey, nodeTypeToNodeMap, err = vrfv2plus.SetupVRFV2PlusUniverse(testcontext.Get(t), t, vrfEnvConfig, newEnvConfig, l) require.NoError(t, err, "Error setting up VRFv2Plus universe") sethClient, err := env.GetSethClient(chainID)