-
Notifications
You must be signed in to change notification settings - Fork 1.8k
/
Copy pathsetup_steps.go
553 lines (504 loc) · 18.1 KB
/
setup_steps.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
package vrfv2plus
import (
"context"
"fmt"
"math/big"
"testing"
"time"
"github.com/shopspring/decimal"
"golang.org/x/sync/errgroup"
"github.com/ethereum/go-ethereum/common"
"github.com/google/uuid"
"github.com/rs/zerolog"
vrfcommon "github.com/smartcontractkit/chainlink/integration-tests/actions/vrf/common"
tc "github.com/smartcontractkit/chainlink/integration-tests/testconfig"
"github.com/smartcontractkit/chainlink/integration-tests/types/config/node"
"github.com/smartcontractkit/chainlink/v2/core/chains/evm/assets"
"github.com/smartcontractkit/chainlink/integration-tests/actions"
"github.com/smartcontractkit/chainlink/integration-tests/client"
"github.com/smartcontractkit/chainlink/integration-tests/contracts"
"github.com/smartcontractkit/chainlink/integration-tests/docker/test_env"
vrfv2plus_config "github.com/smartcontractkit/chainlink/integration-tests/testconfig/vrfv2plus"
"github.com/smartcontractkit/chainlink/integration-tests/types"
)
func CreateVRFV2PlusJob(
chainlinkNode *client.ChainlinkClient,
vrfJobSpecConfig vrfcommon.VRFJobSpecConfig,
) (*client.Job, error) {
jobUUID := uuid.New()
os := &client.VRFV2PlusTxPipelineSpec{
Address: vrfJobSpecConfig.CoordinatorAddress,
EstimateGasMultiplier: vrfJobSpecConfig.EstimateGasMultiplier,
FromAddress: vrfJobSpecConfig.FromAddresses[0],
SimulationBlock: vrfJobSpecConfig.SimulationBlock,
}
ost, err := os.String()
if err != nil {
return nil, fmt.Errorf(vrfcommon.ErrGenericFormat, vrfcommon.ErrParseJob, err)
}
jobSpec := client.VRFV2PlusJobSpec{
Name: fmt.Sprintf("vrf-v2-plus-%s", jobUUID),
CoordinatorAddress: vrfJobSpecConfig.CoordinatorAddress,
FromAddresses: vrfJobSpecConfig.FromAddresses,
EVMChainID: vrfJobSpecConfig.EVMChainID,
MinIncomingConfirmations: vrfJobSpecConfig.MinIncomingConfirmations,
PublicKey: vrfJobSpecConfig.PublicKey,
ExternalJobID: jobUUID.String(),
ObservationSource: ost,
BatchFulfillmentEnabled: vrfJobSpecConfig.BatchFulfillmentEnabled,
BatchFulfillmentGasMultiplier: vrfJobSpecConfig.BatchFulfillmentGasMultiplier,
PollPeriod: vrfJobSpecConfig.PollPeriod,
RequestTimeout: vrfJobSpecConfig.RequestTimeout,
}
if vrfJobSpecConfig.BatchFulfillmentEnabled {
jobSpec.BatchCoordinatorAddress = vrfJobSpecConfig.BatchCoordinatorAddress
}
job, err := chainlinkNode.MustCreateJob(&jobSpec)
if err != nil {
return nil, fmt.Errorf(vrfcommon.ErrGenericFormat, ErrCreatingVRFv2PlusJob, err)
}
return job, nil
}
// SetupVRFV2_5Environment will create specified number of subscriptions and add the same conumer/s to each of them
func SetupVRFV2_5Environment(
ctx context.Context,
env *test_env.CLClusterTestEnv,
chainID int64,
nodesToCreate []vrfcommon.VRFNodeType,
vrfv2PlusTestConfig types.VRFv2PlusTestConfig,
linkToken contracts.LinkToken,
mockNativeLINKFeed contracts.VRFMockETHLINKFeed,
numberOfTxKeysToCreate int,
l zerolog.Logger,
) (*vrfcommon.VRFContracts, *vrfcommon.VRFKeyData, map[vrfcommon.VRFNodeType]*vrfcommon.VRFNode, error) {
l.Info().Msg("Starting VRFV2 Plus environment setup")
configGeneral := vrfv2PlusTestConfig.GetVRFv2PlusConfig().General
vrfContracts, err := SetupVRFV2PlusContracts(
env,
chainID,
linkToken,
mockNativeLINKFeed,
configGeneral,
l,
)
if err != nil {
return nil, nil, nil, err
}
nodeTypeToNodeMap, err := vrfcommon.CreateNodeTypeToNodeMap(env.ClCluster, nodesToCreate)
if err != nil {
return nil, nil, nil, err
}
vrfKey, pubKeyCompressed, err := vrfcommon.CreateVRFKeyOnVRFNode(nodeTypeToNodeMap[vrfcommon.VRF], l)
if err != nil {
return nil, nil, nil, err
}
l.Info().Str("Coordinator", vrfContracts.CoordinatorV2Plus.Address()).Msg("Registering Proving Key")
provingKey, err := VRFV2_5RegisterProvingKey(vrfKey, vrfContracts.CoordinatorV2Plus, uint64(assets.GWei(*configGeneral.CLNodeMaxGasPriceGWei).Int64()))
if err != nil {
return nil, nil, nil, fmt.Errorf(vrfcommon.ErrGenericFormat, vrfcommon.ErrRegisteringProvingKey, err)
}
keyHash, err := vrfContracts.CoordinatorV2Plus.HashOfKey(ctx, provingKey)
if err != nil {
return nil, nil, nil, fmt.Errorf(vrfcommon.ErrGenericFormat, vrfcommon.ErrCreatingProvingKeyHash, err)
}
evmClient, err := env.GetEVMClient(chainID)
if err != nil {
return nil, nil, nil, err
}
vrfTXKeyAddressStrings, _, err := vrfcommon.CreateFundAndGetSendingKeys(
evmClient,
nodeTypeToNodeMap[vrfcommon.VRF],
*vrfv2PlusTestConfig.GetCommonConfig().ChainlinkNodeFunding,
numberOfTxKeysToCreate,
big.NewInt(chainID),
)
if err != nil {
return nil, nil, nil, err
}
err = evmClient.WaitForEvents()
if err != nil {
return nil, nil, nil, fmt.Errorf(vrfcommon.ErrGenericFormat, vrfcommon.ErrWaitTXsComplete, err)
}
nodeTypeToNodeMap[vrfcommon.VRF].TXKeyAddressStrings = vrfTXKeyAddressStrings
g := errgroup.Group{}
if vrfNode, exists := nodeTypeToNodeMap[vrfcommon.VRF]; exists {
g.Go(func() error {
err := setupVRFNode(vrfContracts, big.NewInt(chainID), configGeneral, pubKeyCompressed, l, vrfNode)
if err != nil {
return err
}
return nil
})
}
if bhsNode, exists := nodeTypeToNodeMap[vrfcommon.BHS]; exists {
g.Go(func() error {
err := vrfcommon.SetupBHSNode(
env,
configGeneral.General,
numberOfTxKeysToCreate,
big.NewInt(chainID),
vrfContracts.CoordinatorV2Plus.Address(),
vrfContracts.BHS.Address(),
*vrfv2PlusTestConfig.GetCommonConfig().ChainlinkNodeFunding,
l,
bhsNode,
)
if err != nil {
return err
}
return nil
})
}
if bhfNode, exists := nodeTypeToNodeMap[vrfcommon.BHF]; exists {
g.Go(func() error {
err := vrfcommon.SetupBHFNode(
env,
configGeneral.General,
numberOfTxKeysToCreate,
big.NewInt(chainID),
vrfContracts.CoordinatorV2Plus.Address(),
vrfContracts.BHS.Address(),
vrfContracts.BatchBHS.Address(),
*vrfv2PlusTestConfig.GetCommonConfig().ChainlinkNodeFunding,
l,
bhfNode,
)
if err != nil {
return err
}
return nil
})
}
if err := g.Wait(); err != nil {
return nil, nil, nil, fmt.Errorf("VRF node setup ended up with an error: %w", err)
}
vrfKeyData := vrfcommon.VRFKeyData{
VRFKey: vrfKey,
EncodedProvingKey: provingKey,
KeyHash: keyHash,
PubKeyCompressed: pubKeyCompressed,
}
l.Info().Msg("VRFV2 Plus environment setup is finished")
return vrfContracts, &vrfKeyData, nodeTypeToNodeMap, nil
}
func setupVRFNode(contracts *vrfcommon.VRFContracts, chainID *big.Int, config *vrfv2plus_config.General, pubKeyCompressed string, l zerolog.Logger, vrfNode *vrfcommon.VRFNode) error {
vrfJobSpecConfig := vrfcommon.VRFJobSpecConfig{
ForwardingAllowed: *config.VRFJobForwardingAllowed,
CoordinatorAddress: contracts.CoordinatorV2Plus.Address(),
BatchCoordinatorAddress: contracts.BatchCoordinatorV2Plus.Address(),
FromAddresses: vrfNode.TXKeyAddressStrings,
EVMChainID: chainID.String(),
MinIncomingConfirmations: int(*config.MinimumConfirmations),
PublicKey: pubKeyCompressed,
EstimateGasMultiplier: *config.VRFJobEstimateGasMultiplier,
BatchFulfillmentEnabled: *config.VRFJobBatchFulfillmentEnabled,
BatchFulfillmentGasMultiplier: *config.VRFJobBatchFulfillmentGasMultiplier,
PollPeriod: config.VRFJobPollPeriod.Duration,
RequestTimeout: config.VRFJobRequestTimeout.Duration,
SimulationBlock: config.VRFJobSimulationBlock,
VRFOwnerConfig: nil,
}
l.Info().Msg("Creating VRFV2 Plus Job")
job, err := CreateVRFV2PlusJob(
vrfNode.CLNode.API,
vrfJobSpecConfig,
)
if err != nil {
return fmt.Errorf(vrfcommon.ErrGenericFormat, ErrCreateVRFV2PlusJobs, err)
}
vrfNode.Job = job
// this part is here because VRFv2 can work with only a specific key
// [[EVM.KeySpecific]]
// Key = '...'
nodeConfig := node.NewConfig(vrfNode.CLNode.NodeConfig,
node.WithLogPollInterval(1*time.Second),
node.WithVRFv2EVMEstimator(vrfNode.TXKeyAddressStrings, *config.CLNodeMaxGasPriceGWei),
)
l.Info().Msg("Restarting Node with new sending key PriceMax configuration")
err = vrfNode.CLNode.Restart(nodeConfig)
if err != nil {
return fmt.Errorf(vrfcommon.ErrGenericFormat, vrfcommon.ErrRestartCLNode, err)
}
return nil
}
func SetupVRFV2PlusWrapperEnvironment(
ctx context.Context,
env *test_env.CLClusterTestEnv,
chainID int64,
vrfv2PlusTestConfig types.VRFv2PlusTestConfig,
linkToken contracts.LinkToken,
mockNativeLINKFeed contracts.MockETHLINKFeed,
coordinator contracts.VRFCoordinatorV2_5,
keyHash [32]byte,
wrapperConsumerContractsAmount int,
) (*VRFV2PlusWrapperContracts, *big.Int, error) {
// external EOA has to create a subscription for the wrapper first
wrapperSubId, err := CreateSubAndFindSubID(env, chainID, coordinator)
if err != nil {
return nil, nil, err
}
vrfv2PlusConfig := vrfv2PlusTestConfig.GetVRFv2PlusConfig().General
evmClient, err := env.GetEVMClient(chainID)
if err != nil {
return nil, nil, err
}
wrapperContracts, err := DeployVRFV2PlusDirectFundingContracts(
env.ContractDeployer,
evmClient,
linkToken.Address(),
mockNativeLINKFeed.Address(),
coordinator,
wrapperConsumerContractsAmount,
wrapperSubId,
)
if err != nil {
return nil, nil, err
}
err = evmClient.WaitForEvents()
if err != nil {
return nil, nil, fmt.Errorf(vrfcommon.ErrGenericFormat, vrfcommon.ErrWaitTXsComplete, err)
}
// once the wrapper is deployed, wrapper address will become consumer of external EOA subscription
err = coordinator.AddConsumer(wrapperSubId, wrapperContracts.VRFV2PlusWrapper.Address())
if err != nil {
return nil, nil, err
}
err = evmClient.WaitForEvents()
if err != nil {
return nil, nil, fmt.Errorf(vrfcommon.ErrGenericFormat, vrfcommon.ErrWaitTXsComplete, err)
}
err = wrapperContracts.VRFV2PlusWrapper.SetConfig(
*vrfv2PlusConfig.WrapperGasOverhead,
*vrfv2PlusConfig.CoordinatorGasOverheadNative,
*vrfv2PlusConfig.CoordinatorGasOverheadLink,
*vrfv2PlusConfig.CoordinatorGasOverheadPerWord,
*vrfv2PlusConfig.CoordinatorNativePremiumPercentage,
*vrfv2PlusConfig.CoordinatorLinkPremiumPercentage,
keyHash,
*vrfv2PlusConfig.WrapperMaxNumberOfWords,
*vrfv2PlusConfig.StalenessSeconds,
decimal.RequireFromString(*vrfv2PlusConfig.FallbackWeiPerUnitLink).BigInt(),
*vrfv2PlusConfig.FulfillmentFlatFeeNativePPM,
*vrfv2PlusConfig.FulfillmentFlatFeeLinkDiscountPPM,
)
if err != nil {
return nil, nil, err
}
err = evmClient.WaitForEvents()
if err != nil {
return nil, nil, fmt.Errorf(vrfcommon.ErrGenericFormat, vrfcommon.ErrWaitTXsComplete, err)
}
//fund sub
wrapperSubID, err := wrapperContracts.VRFV2PlusWrapper.GetSubID(ctx)
if err != nil {
return nil, nil, err
}
err = evmClient.WaitForEvents()
if err != nil {
return nil, nil, fmt.Errorf(vrfcommon.ErrGenericFormat, vrfcommon.ErrWaitTXsComplete, err)
}
err = FundSubscriptions(
env,
chainID,
big.NewFloat(*vrfv2PlusTestConfig.GetVRFv2PlusConfig().General.SubscriptionFundingAmountNative),
big.NewFloat(*vrfv2PlusTestConfig.GetVRFv2PlusConfig().General.SubscriptionFundingAmountLink),
linkToken,
coordinator,
[]*big.Int{wrapperSubID},
)
if err != nil {
return nil, nil, err
}
//fund consumer with Link
err = linkToken.Transfer(
wrapperContracts.LoadTestConsumers[0].Address(),
big.NewInt(0).Mul(big.NewInt(1e18), big.NewInt(*vrfv2PlusConfig.WrapperConsumerFundingAmountLink)),
)
if err != nil {
return nil, nil, err
}
err = evmClient.WaitForEvents()
if err != nil {
return nil, nil, fmt.Errorf(vrfcommon.ErrGenericFormat, vrfcommon.ErrWaitTXsComplete, err)
}
//fund consumer with Eth
err = wrapperContracts.LoadTestConsumers[0].Fund(big.NewFloat(*vrfv2PlusConfig.WrapperConsumerFundingAmountNativeToken))
if err != nil {
return nil, nil, err
}
err = evmClient.WaitForEvents()
if err != nil {
return nil, nil, fmt.Errorf(vrfcommon.ErrGenericFormat, vrfcommon.ErrWaitTXsComplete, err)
}
return wrapperContracts, wrapperSubID, nil
}
func SetupVRFV2PlusUniverse(ctx context.Context, t *testing.T, testConfig tc.TestConfig, chainID int64, cleanupFn func(), newEnvConfig vrfcommon.NewEnvConfig, l zerolog.Logger) (*test_env.CLClusterTestEnv, *vrfcommon.VRFContracts, *vrfcommon.VRFKeyData, map[vrfcommon.VRFNodeType]*vrfcommon.VRFNode, error) {
var (
env *test_env.CLClusterTestEnv
vrfContracts *vrfcommon.VRFContracts
vrfKey *vrfcommon.VRFKeyData
nodeTypeToNode map[vrfcommon.VRFNodeType]*vrfcommon.VRFNode
err error
)
if *testConfig.VRFv2Plus.General.UseExistingEnv {
vrfContracts, vrfKey, env, err = SetupVRFV2PlusForExistingEnv(ctx, t, testConfig, chainID, cleanupFn, 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)
if err != nil {
return nil, nil, nil, nil, fmt.Errorf("%s, err: %w", "Error setting up VRF V2 Plus for New env", err)
}
}
return env, vrfContracts, vrfKey, nodeTypeToNode, nil
}
func SetupVRFV2PlusForNewEnv(
ctx context.Context,
t *testing.T,
testConfig tc.TestConfig,
chainID int64,
cleanupFn func(),
newEnvConfig vrfcommon.NewEnvConfig,
l zerolog.Logger,
) (*vrfcommon.VRFContracts, *vrfcommon.VRFKeyData, *test_env.CLClusterTestEnv, map[vrfcommon.VRFNodeType]*vrfcommon.VRFNode, error) {
network, err := actions.EthereumNetworkConfigFromConfig(l, &testConfig)
if err != nil {
return nil, nil, nil, nil, fmt.Errorf("%s, err: %w", "Error building ethereum network config", err)
}
env, err := test_env.NewCLTestEnvBuilder().
WithTestInstance(t).
WithTestConfig(&testConfig).
WithPrivateEthereumNetwork(network.EthereumNetworkConfig).
WithCLNodes(len(newEnvConfig.NodesToCreate)).
WithFunding(big.NewFloat(*testConfig.Common.ChainlinkNodeFunding)).
WithCustomCleanup(cleanupFn).
Build()
if err != nil {
return nil, nil, nil, nil, fmt.Errorf("%s, err: %w", "error creating test env", err)
}
env.ParallelTransactions(true)
mockETHLinkFeed, err := env.ContractDeployer.DeployVRFMockETHLINKFeed(big.NewInt(*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 := actions.DeployLINKToken(env.ContractDeployer)
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,
newEnvConfig.NodesToCreate,
&testConfig,
linkToken,
mockETHLinkFeed,
newEnvConfig.NumberOfTxKeysToCreate,
l,
)
if err != nil {
return nil, nil, nil, nil, fmt.Errorf("%s, err: %w", "error setting up VRF v2_5 env", err)
}
return vrfContracts, vrfKey, env, nodeTypeToNode, nil
}
func SetupVRFV2PlusForExistingEnv(ctx context.Context, 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
env, err := test_env.NewCLTestEnvBuilder().
WithTestInstance(t).
WithTestConfig(&testConfig).
WithCustomCleanup(cleanupFn).
Build()
if err != nil {
return nil, nil, nil, fmt.Errorf("%s, err: %w", "error creating test env", err)
}
coordinator, err := env.ContractLoader.LoadVRFCoordinatorV2_5(*commonExistingEnvConfig.CoordinatorAddress)
if err != nil {
return nil, nil, nil, fmt.Errorf("%s, err: %w", "error loading VRFCoordinator2_5", err)
}
linkToken, err := env.ContractLoader.LoadLINKToken(*commonExistingEnvConfig.LinkAddress)
if err != nil {
return nil, nil, nil, fmt.Errorf("%s, err: %w", "error loading LinkToken", err)
}
evmClient, err := env.GetEVMClient(chainID)
if err != nil {
return nil, nil, nil, err
}
err = vrfcommon.FundNodesIfNeeded(ctx, commonExistingEnvConfig, evmClient, l)
if err != nil {
return nil, nil, nil, fmt.Errorf("err: %w", err)
}
vrfContracts := &vrfcommon.VRFContracts{
CoordinatorV2Plus: coordinator,
VRFV2PlusConsumer: nil,
LinkToken: linkToken,
BHS: nil,
}
vrfKey := &vrfcommon.VRFKeyData{
VRFKey: nil,
EncodedProvingKey: [2]*big.Int{},
KeyHash: common.HexToHash(*commonExistingEnvConfig.KeyHash),
}
return vrfContracts, vrfKey, env, nil
}
func SetupSubsAndConsumersForExistingEnv(
env *test_env.CLClusterTestEnv,
chainID int64,
coordinator contracts.VRFCoordinatorV2_5,
linkToken contracts.LinkToken,
numberOfConsumerContractsToDeployAndAddToSub int,
numberOfSubToCreate int,
testConfig tc.TestConfig,
l zerolog.Logger,
) ([]*big.Int, []contracts.VRFv2PlusLoadTestConsumer, error) {
var (
subIDs []*big.Int
consumers []contracts.VRFv2PlusLoadTestConsumer
err error
)
if *testConfig.VRFv2Plus.General.UseExistingEnv {
commonExistingEnvConfig := testConfig.VRFv2Plus.ExistingEnvConfig.ExistingEnvConfig
if *commonExistingEnvConfig.CreateFundSubsAndAddConsumers {
consumers, subIDs, err = SetupNewConsumersAndSubs(
env,
chainID,
coordinator,
testConfig,
linkToken,
numberOfConsumerContractsToDeployAndAddToSub,
numberOfSubToCreate,
l,
)
if err != nil {
return nil, nil, fmt.Errorf("err: %w", err)
}
} else {
consumer, err := env.ContractLoader.LoadVRFv2PlusLoadTestConsumer(*commonExistingEnvConfig.ConsumerAddress)
if err != nil {
return nil, nil, fmt.Errorf("err: %w", err)
}
consumers = append(consumers, consumer)
var ok bool
subID, ok := new(big.Int).SetString(*testConfig.VRFv2Plus.ExistingEnvConfig.SubID, 10)
if !ok {
return nil, nil, fmt.Errorf("unable to parse subID: %s %w", *testConfig.VRFv2Plus.ExistingEnvConfig.SubID, err)
}
subIDs = append(subIDs, subID)
}
} else {
consumers, subIDs, err = SetupNewConsumersAndSubs(
env,
chainID,
coordinator,
testConfig,
linkToken,
numberOfConsumerContractsToDeployAndAddToSub,
numberOfSubToCreate,
l,
)
if err != nil {
return nil, nil, fmt.Errorf("err: %w", err)
}
}
return subIDs, consumers, nil
}