/
setup_ocr2vrf.go
572 lines (482 loc) · 21.1 KB
/
setup_ocr2vrf.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
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
package main
import (
"flag"
"fmt"
"math/big"
"os"
"strings"
"github.com/ethereum/go-ethereum/common"
"github.com/shopspring/decimal"
"github.com/urfave/cli"
helpers "github.com/smartcontractkit/chainlink/core/scripts/common"
"github.com/smartcontractkit/chainlink/v2/core/cmd"
)
type jobType string
const (
jobTypeDKG jobType = "DKG"
jobTypeOCR2VRF jobType = "OCR2VRF"
)
func fundOCR2VRFNodes(e helpers.Environment) {
fs := flag.NewFlagSet("ocr2vrf-setup", flag.ExitOnError)
ethSendingKeysString := fs.String("eth-sending-keys", "", "eth sending keys")
fundingAmount := fs.String("funding-amount", "1e18", "funding amount in wei. can use scientific notation, e.g 10e18 for 10 ether") // 1 ETH
helpers.ParseArgs(fs, os.Args[2:], "eth-sending-keys")
flatSendingKeys := strings.Split(*ethSendingKeysString, ",")
helpers.FundNodes(e, flatSendingKeys, decimal.RequireFromString(*fundingAmount).BigInt())
}
func setupOCR2VRFNodes(e helpers.Environment) {
// Websocket URL & HTTP url required.
wsUrl := os.Getenv("ETH_URL")
httpUrl := os.Getenv("ETH_HTTP_URL")
if len(wsUrl) == 0 || len(httpUrl) == 0 {
fmt.Println("ETH_URL & ETH_HTTP_URL are required for this script.")
os.Exit(1)
}
fs := flag.NewFlagSet("ocr2vrf-setup", flag.ExitOnError)
keyID := fs.String("key-id", "aee00d81f822f882b6fe28489822f59ebb21ea95c0ae21d9f67c0239461148fc", "key ID")
linkAddress := fs.String("link-address", "", "LINK token address")
linkEthFeed := fs.String("link-eth-feed", "", "LINK-ETH feed address")
useForwarder := fs.Bool("use-forwarder", false, "boolean to use the forwarder")
confDelays := fs.String("conf-delays", "1,2,3,4,5,6,7,8", "8 confirmation delays")
weiPerUnitLink := fs.String("wei-per-unit-link", "6e16", "wei per unit link price for feed")
beaconPeriodBlocks := fs.Int64("beacon-period-blocks", 3, "beacon period in blocks")
subscriptionBalanceString := fs.String("subscription-balance", "1e19", "amount to fund subscription")
maxCallbackGasLimit := fs.Uint("max-cb-gas-limit", 2.5e6, "max callback gas limit")
maxCallbackArgumentsLength := fs.Uint("max-cb-args-length", 32*10 /* 10 EVM words */, "max callback arguments length")
apiFile := fs.String("api", "../../../tools/secrets/apicredentials", "api credentials file")
passwordFile := fs.String("password", "../../../tools/secrets/password.txt", "password file")
databasePrefix := fs.String("database-prefix", "postgres://postgres:postgres_password_padded_for_security@localhost:5432/ocr2vrf-test", "database prefix")
databaseSuffixes := fs.String("database-suffixes", "sslmode=disable", "database parameters to be added")
nodeCount := fs.Int("node-count", 6, "number of nodes")
fundingAmount := fs.Int64("funding-amount", 1e17, "amount to fund nodes") // .1 ETH
resetDatabase := fs.Bool("reset-database", true, "boolean to reset database")
helpers.ParseArgs(fs, os.Args[2:])
if *nodeCount < 6 {
fmt.Println("Node count too low for OCR2VRF job, need at least 6.")
os.Exit(1)
}
delays := helpers.ParseIntSlice(*confDelays)
if len(delays) != 8 {
fmt.Println("confDelays must have a length of 8")
os.Exit(1)
}
var link common.Address
if *linkAddress == "" {
link = helpers.DeployLinkToken(e)
} else {
link = common.HexToAddress(*linkAddress)
}
// Deploy DKG and VRF contracts, and add VRF
// as a consumer of DKG events.
fmt.Println("Deploying DKG contract...")
dkgAddress := deployDKG(e)
// Deploy a new feed if needed
var feedAddress common.Address
if *linkEthFeed == "" {
fmt.Println("Deploying LINK-ETH feed...")
feedAddress = helpers.DeployLinkEthFeed(e, *linkAddress, decimal.RequireFromString(*weiPerUnitLink).BigInt())
} else {
feedAddress = common.HexToAddress(*linkEthFeed)
}
fmt.Println("Deploying VRF coordinator...")
vrfCoordinatorAddress, vrfCoordinator := deployVRFCoordinator(e, big.NewInt(*beaconPeriodBlocks), link.String(), feedAddress.String())
fmt.Println("Configuring VRF coordinator...")
configureVRFCoordinator(e, vrfCoordinator, uint32(*maxCallbackGasLimit), uint32(*maxCallbackArgumentsLength))
fmt.Println("Deploying VRF beacon...")
vrfBeaconAddress := deployVRFBeacon(e, vrfCoordinatorAddress.String(), link.String(), dkgAddress.String(), *keyID)
fmt.Println("Adding VRF Beacon as DKG client...")
addClientToDKG(e, dkgAddress.String(), *keyID, vrfBeaconAddress.String())
fmt.Println("Adding VRF Beacon as producer in VRF Coordinator")
setProducer(e, vrfCoordinatorAddress.String(), vrfBeaconAddress.String())
fmt.Println("Deploying beacon consumer...")
consumerAddress := deployVRFBeaconCoordinatorConsumer(e, vrfCoordinatorAddress.String(), false, big.NewInt(*beaconPeriodBlocks))
fmt.Println("Creating subscription...")
createSubscription(e, vrfCoordinatorAddress.String())
subID := findSubscriptionID(e, vrfCoordinatorAddress.String())
fmt.Println("Adding consumer to subscription...")
addConsumer(e, vrfCoordinatorAddress.String(), consumerAddress.String(), subID)
subscriptionBalance := decimal.RequireFromString(*subscriptionBalanceString).BigInt()
if subscriptionBalance.Cmp(big.NewInt(0)) > 0 {
fmt.Println("\nFunding subscription with", subscriptionBalance, "juels...")
eoaFundSubscription(e, vrfCoordinatorAddress.String(), link.String(), subscriptionBalance, subID)
} else {
fmt.Println("Subscription", subID, "NOT getting funded. You must fund the subscription in order to use it!")
}
var forwarderAddresses []common.Address
var forwarderAddressesStrings []string
// If using the forwarder, set up a forwarder for each node.
if *useForwarder {
fmt.Println("Deploying transaction forwarders...")
for i := 0; i < *nodeCount-1; i++ {
// Deploy an authorized forwarder, and add it to the list of forwarders.
f := deployAuthorizedForwarder(e, link, e.Owner.From)
forwarderAddresses = append(forwarderAddresses, f)
forwarderAddressesStrings = append(forwarderAddressesStrings, f.String())
}
fmt.Printf("ForwarderAddresses : %v", forwarderAddressesStrings)
}
fmt.Println("Deploying batch beacon consumer...")
loadTestConsumerAddress := deployLoadTestVRFBeaconCoordinatorConsumer(e, vrfCoordinatorAddress.String(), false, big.NewInt(*beaconPeriodBlocks))
addConsumer(e, vrfCoordinatorAddress.String(), loadTestConsumerAddress.String(), subID)
fmt.Println("Configuring nodes with OCR2VRF jobs...")
var (
onChainPublicKeys []string
offChainPublicKeys []string
configPublicKeys []string
peerIDs []string
transmitters []string
dkgEncrypters []string
dkgSigners []string
sendingKeys [][]string
)
for i := 0; i < *nodeCount; i++ {
flagSet := flag.NewFlagSet("run-ocr2vrf-job-creation", flag.ExitOnError)
flagSet.String("api", *apiFile, "api file")
flagSet.String("password", *passwordFile, "password file")
flagSet.String("vrfpassword", *passwordFile, "vrf password file")
flagSet.String("bootstrapPort", fmt.Sprintf("%d", 8000), "port of bootstrap")
flagSet.Int64("chainID", e.ChainID, "the chain ID")
flagSet.Bool("applyInitServerConfig", true, "override for using initServerConfig in App.Before")
flagSet.String("job-type", string(jobTypeOCR2VRF), "the job type")
// used by bootstrap template instantiation
flagSet.String("contractID", dkgAddress.String(), "the contract to get peers from")
// DKG args
flagSet.String("keyID", *keyID, "")
flagSet.String("dkg-address", dkgAddress.String(), "the contract address of the DKG")
// VRF args
flagSet.String("vrf-beacon-address", vrfBeaconAddress.String(), "the contract address of the VRF Beacon")
flagSet.String("vrf-coordinator-address", vrfCoordinatorAddress.String(), "the contract address of the VRF Coordinator")
flagSet.String("link-eth-feed-address", feedAddress.Hex(), "link eth feed address")
// Apply forwarder args if using the forwarder.
if i > 0 && *useForwarder {
flagSet.Bool("use-forwarder", *useForwarder, "use a transaction forwarder")
flagSet.String("forwarder-address", forwarderAddressesStrings[i-1], "transaction forwarder address")
}
flagSet.Bool("dangerWillRobinson", *resetDatabase, "for resetting databases")
flagSet.Bool("isBootstrapper", i == 0, "is first node")
bootstrapperPeerID := ""
if len(peerIDs) != 0 {
bootstrapperPeerID = peerIDs[0]
}
flagSet.String("bootstrapperPeerID", bootstrapperPeerID, "peerID of first node")
payload := SetupNode(e, flagSet, i, *databasePrefix, *databaseSuffixes, *useForwarder, *resetDatabase, wsUrl, httpUrl)
onChainPublicKeys = append(onChainPublicKeys, payload.OnChainPublicKey)
offChainPublicKeys = append(offChainPublicKeys, payload.OffChainPublicKey)
configPublicKeys = append(configPublicKeys, payload.ConfigPublicKey)
peerIDs = append(peerIDs, payload.PeerID)
transmitters = append(transmitters, payload.Transmitter)
dkgEncrypters = append(dkgEncrypters, payload.DkgEncrypt)
dkgSigners = append(dkgSigners, payload.DkgSign)
sendingKeys = append(sendingKeys, payload.SendingKeys)
}
var nodesToFund []string
// If using the forwarder, set up a forwarder for each node.
if *useForwarder {
fmt.Println("Setting authorized senders...")
for i, f := range forwarderAddresses {
// Convert the sending strings for a transmitter to addresses.
var sendinKeysAddresses []common.Address
sendingKeysStrings := sendingKeys[i+1]
for _, s := range sendingKeysStrings {
sendinKeysAddresses = append(sendinKeysAddresses, common.HexToAddress(s))
}
// Set authorized senders for the corresponding forwarder.
setAuthorizedSenders(e, f, sendinKeysAddresses)
// Fund the sending keys.
nodesToFund = append(nodesToFund, sendingKeysStrings...)
// Set the authorized forwarder as the OCR transmitter.
transmitters[i+1] = f.String()
}
} else {
nodesToFund = append(nodesToFund, transmitters[1:]...)
}
var payees []common.Address
var reportTransmitters []common.Address // all transmitters excluding bootstrap
for _, t := range transmitters[1:] {
payees = append(payees, e.Owner.From)
reportTransmitters = append(reportTransmitters, common.HexToAddress(t))
}
fmt.Printf("Setting EOA: %s as payee for transmitters: %v \n", e.Owner.From, reportTransmitters)
setPayees(e, vrfBeaconAddress.String(), reportTransmitters, payees)
fmt.Println("Funding transmitters...")
helpers.FundNodes(e, nodesToFund, big.NewInt(*fundingAmount))
printStandardCommands(
dkgAddress,
vrfBeaconAddress,
consumerAddress,
loadTestConsumerAddress,
keyID,
confDelays,
onChainPublicKeys[1:],
offChainPublicKeys[1:],
configPublicKeys[1:],
peerIDs[1:],
transmitters[1:],
dkgEncrypters[1:],
dkgSigners[1:],
subID.String(),
)
}
func setupOCR2VRFNodesForInfraWithForwarder(e helpers.Environment) {
fs := flag.NewFlagSet("ocr2vrf-setup-infra", flag.ExitOnError)
keyID := fs.String("key-id", "aee00d81f822f882b6fe28489822f59ebb21ea95c0ae21d9f67c0239461148fc", "key ID")
linkAddress := fs.String("link-address", "", "LINK token address")
linkEthFeed := fs.String("link-eth-feed", "", "LINK-ETH feed address")
confDelays := fs.String("conf-delays", "1,2,3,4,5,6,7,8", "8 confirmation delays")
beaconPeriodBlocks := fs.Int64("beacon-period-blocks", 3, "beacon period in blocks")
subscriptionBalanceString := fs.String("subscription-balance", "1e19", "amount to fund subscription")
peerIDsString := fs.String("peer-ids", "", "peer ids")
dkgSignersString := fs.String("dkg-sign-keys", "", "dkg signing keys")
dkgEncryptersString := fs.String("dkg-encrypt-keys", "", "dkg encrypt keys")
ocr2KeyBundleIDsString := fs.String("key-bundle-ids", "", "ocr2 key bundle ids")
onChainPublicKeysString := fs.String("on-chain-public-keys", "", "ocr2 on-chain public keys")
offChainPublicKeysString := fs.String("off-chain-public-keys", "", "ocr2 off-chain public keys")
configPublicKeysString := fs.String("config-public-keys", "", "ocr2 config public keys")
ethSendingKeysString := fs.String("eth-sending-keys", "", "eth sending keys")
nodeCount := fs.Int("node-count", 6, "number of nodes")
fundingAmount := fs.Int64("funding-amount", 1e17, "amount to fund nodes") // .1 ETH
helpers.ParseArgs(
fs,
os.Args[2:],
"link-address",
"link-eth-feed",
"dkg-sign-keys",
"dkg-encrypt-keys",
"key-bundle-ids",
"on-chain-public-keys",
"off-chain-public-keys",
"config-public-keys",
"eth-sending-keys",
"peer-ids",
)
peerIDs := strings.Split(*peerIDsString, ",")
dkgSigners := strings.Split(*dkgSignersString, ",")
dkgEncrypters := strings.Split(*dkgEncryptersString, ",")
ocr2KeyBundleIDs := strings.Split(*ocr2KeyBundleIDsString, ",")
onChainPublicKeys := strings.Split(*onChainPublicKeysString, ",")
offChainPublicKeys := strings.Split(*offChainPublicKeysString, ",")
configPublicKeys := strings.Split(*configPublicKeysString, ",")
var sendingKeys [][]string
flatSendingKeys := strings.Split(*ethSendingKeysString, ",")
sendingKeysPerNode := len(flatSendingKeys) / (*nodeCount - 1)
for i := 0; i < *nodeCount-1; i++ {
sendingKeys = append(sendingKeys, flatSendingKeys[i*sendingKeysPerNode:i*sendingKeysPerNode+sendingKeysPerNode])
}
if *nodeCount < 6 {
fmt.Println("Node count too low for OCR2VRF job, need at least 6.")
os.Exit(1)
}
delays := helpers.ParseIntSlice(*confDelays)
if len(delays) != 8 {
fmt.Println("confDelays must have a length of 8")
os.Exit(1)
}
link := common.HexToAddress(*linkAddress)
feedAddress := common.HexToAddress(*linkEthFeed)
// Deploy DKG and VRF contracts, and add VRF
// as a consumer of DKG events.
fmt.Println("Deploying DKG contract...")
dkgAddress := deployDKG(e)
fmt.Println("Deploying VRF coordinator...")
vrfCoordinatorAddress, _ := deployVRFCoordinator(e, big.NewInt(*beaconPeriodBlocks), link.String(), feedAddress.String())
fmt.Println("Deploying VRF beacon...")
vrfBeaconAddress := deployVRFBeacon(e, vrfCoordinatorAddress.String(), link.String(), dkgAddress.String(), *keyID)
fmt.Println("Adding VRF Beacon as DKG client...")
addClientToDKG(e, dkgAddress.String(), *keyID, vrfBeaconAddress.String())
fmt.Println("Adding VRF Beacon as producer in VRF Coordinator")
setProducer(e, vrfCoordinatorAddress.String(), vrfBeaconAddress.String())
fmt.Println("Deploying beacon consumer...")
consumerAddress := deployVRFBeaconCoordinatorConsumer(e, vrfCoordinatorAddress.String(), false, big.NewInt(*beaconPeriodBlocks))
fmt.Println("Creating subscription...")
createSubscription(e, vrfCoordinatorAddress.String())
subID := findSubscriptionID(e, vrfCoordinatorAddress.String())
fmt.Println("Adding consumer to subscription...")
addConsumer(e, vrfCoordinatorAddress.String(), consumerAddress.String(), subID)
subscriptionBalance := decimal.RequireFromString(*subscriptionBalanceString).BigInt()
if subscriptionBalance.Cmp(big.NewInt(0)) > 0 {
fmt.Println("\nFunding subscription with", subscriptionBalance, "juels...")
eoaFundSubscription(e, vrfCoordinatorAddress.String(), link.String(), subscriptionBalance, subID)
} else {
fmt.Println("Subscription", subID, "NOT getting funded. You must fund the subscription in order to use it!")
}
var forwarderAddresses []common.Address
var forwarderAddressesStrings []string
var nodesToFund []string
var transmitters []string
// Set up a forwarder for each node.
fmt.Println("Deploying transaction forwarders...")
for i := 0; i < *nodeCount-1; i++ {
// Deploy an authorized forwarder, and add it to the list of forwarders.
f := deployAuthorizedForwarder(e, link, e.Owner.From)
forwarderAddresses = append(forwarderAddresses, f)
forwarderAddressesStrings = append(forwarderAddressesStrings, f.String())
}
// Assign the sending keys to the deployed forwarders.
fmt.Printf("ForwarderAddresses : %v\n", forwarderAddressesStrings)
for i, f := range forwarderAddresses {
// Convert the sending strings for a transmitter to addresses.
var sendinKeysAddresses []common.Address
sendingKeysStrings := sendingKeys[i]
for _, s := range sendingKeysStrings {
sendinKeysAddresses = append(sendinKeysAddresses, common.HexToAddress(s))
}
// Set authorized senders for the corresponding forwarder.
setAuthorizedSenders(e, f, sendinKeysAddresses)
// Fund the sending keys.
nodesToFund = append(nodesToFund, sendingKeysStrings...)
// Set the authorized forwarder as the OCR transmitter.
transmitters = append(transmitters, f.String())
}
var payees []common.Address
var reportTransmitters []common.Address
for _, t := range transmitters {
payees = append(payees, e.Owner.From)
reportTransmitters = append(reportTransmitters, common.HexToAddress(t))
}
fmt.Printf("Setting EOA: %s as payee for transmitters: %v \n", e.Owner.From, reportTransmitters)
setPayees(e, vrfBeaconAddress.String(), reportTransmitters, payees)
fmt.Println("Funding transmitters...")
helpers.FundNodes(e, nodesToFund, big.NewInt(*fundingAmount))
fmt.Println("Deploying batch beacon consumer...")
loadTestConsumerAddress := deployLoadTestVRFBeaconCoordinatorConsumer(e, vrfCoordinatorAddress.String(), false, big.NewInt(*beaconPeriodBlocks))
addConsumer(e, vrfCoordinatorAddress.String(), loadTestConsumerAddress.String(), subID)
for i := 0; i < *nodeCount; i++ {
// Apply forwarder args if using the forwarder.
if i > 0 {
adjustedIndex := i - 1
vrfJob := fmt.Sprintf(
cmd.OCR2VRFTemplate,
e.ChainID,
vrfBeaconAddress.String(),
ocr2KeyBundleIDs[adjustedIndex],
forwarderAddresses[adjustedIndex].String(),
true, // forwardingAllowed
"", // P2P Bootstrapper
e.ChainID,
sendingKeys[adjustedIndex],
dkgEncrypters[adjustedIndex],
dkgSigners[adjustedIndex],
*keyID,
dkgAddress.String(),
vrfCoordinatorAddress.String(),
*linkEthFeed,
)
fmt.Printf("VRF JOB FOR NODE %d:\n%v\n", i-1, vrfJob) // zero-based index to match infra.
} else {
bootstrapJob := fmt.Sprintf(cmd.BootstrapTemplate, e.ChainID, dkgAddress.String(), e.ChainID)
fmt.Printf("VRF BOOTSTRAP JOB:\n%v\n", bootstrapJob)
}
}
printStandardCommands(
dkgAddress,
vrfBeaconAddress,
consumerAddress,
loadTestConsumerAddress,
keyID,
confDelays,
onChainPublicKeys,
offChainPublicKeys,
configPublicKeys,
peerIDs,
transmitters,
dkgEncrypters,
dkgSigners,
subID.String(),
)
}
func printStandardCommands(
dkgAddress common.Address,
vrfBeaconAddress common.Address,
consumerAddress common.Address,
loadTestConsumerAddress common.Address,
keyID *string,
confDelays *string,
onChainPublicKeys []string,
offChainPublicKeys []string,
configPublicKeys []string,
peerIDs []string,
transmitters []string,
dkgEncrypters []string,
dkgSigners []string,
subID string,
) {
fmt.Println("Generated dkg setConfig command:")
dkgCommand := fmt.Sprintf(
"go run . dkg-set-config -dkg-address %s -key-id %s -onchain-pub-keys %s -offchain-pub-keys %s -config-pub-keys %s -peer-ids %s -transmitters %s -dkg-encryption-pub-keys %s -dkg-signing-pub-keys %s -schedule 1,1,1,1,1",
dkgAddress.String(),
*keyID,
strings.Join(onChainPublicKeys, ","),
strings.Join(offChainPublicKeys, ","),
strings.Join(configPublicKeys, ","),
strings.Join(peerIDs, ","),
strings.Join(transmitters, ","),
strings.Join(dkgEncrypters, ","),
strings.Join(dkgSigners, ","),
)
fmt.Println(dkgCommand)
fmt.Println()
fmt.Println("Generated vrf setConfig command:")
vrfCommand := fmt.Sprintf(
"go run . beacon-set-config -beacon-address %s -conf-delays %s -onchain-pub-keys %s -offchain-pub-keys %s -config-pub-keys %s -peer-ids %s -transmitters %s -schedule 1,1,1,1,1",
vrfBeaconAddress.String(),
*confDelays,
strings.Join(onChainPublicKeys, ","),
strings.Join(offChainPublicKeys, ","),
strings.Join(configPublicKeys, ","),
strings.Join(peerIDs, ","),
strings.Join(transmitters, ","),
)
fmt.Println(vrfCommand)
fmt.Println()
fmt.Println("Consumer address:", consumerAddress.String())
fmt.Println("Consumer request command:")
requestCommand := fmt.Sprintf(
"go run . consumer-request-randomness -consumer-address %s -sub-id %s",
consumerAddress.Hex(), subID)
fmt.Println(requestCommand)
fmt.Println()
fmt.Println("Consumer callback request command:")
callbackCommand := fmt.Sprintf(
"go run . consumer-request-callback -consumer-address %s -sub-id %s",
consumerAddress.Hex(), subID)
fmt.Println(callbackCommand)
fmt.Println()
fmt.Println("Consumer callback batch request command:")
callbackCommand = fmt.Sprintf(
"go run . consumer-request-callback-batch -consumer-address %s -sub-id %s -batch-size <batch-size>",
loadTestConsumerAddress.Hex(), subID)
fmt.Println(callbackCommand)
fmt.Println()
fmt.Println("Consumer redeem randomness command:")
redeemCommand := fmt.Sprintf(
"go run . consumer-redeem-randomness -consumer-address %s -sub-id %s -request-id <req-id>",
consumerAddress.Hex(), subID)
fmt.Println(redeemCommand)
fmt.Println()
}
func SetupNode(
e helpers.Environment,
flagSet *flag.FlagSet,
nodeIdx int,
databasePrefix,
databaseSuffixes string,
useForwarder bool,
resetDB bool,
wsUrl string,
httpUrl string,
) *cmd.SetupOCR2VRFNodePayload {
configureEnvironmentVariables((useForwarder) && (nodeIdx > 0), e.ChainID, wsUrl, httpUrl, nodeIdx, databasePrefix, databaseSuffixes)
client := newSetupClient()
app := cmd.NewApp(client)
ctx := cli.NewContext(app, flagSet, nil)
defer func() {
err := app.After(ctx)
helpers.PanicErr(err)
}()
err := app.Before(ctx)
helpers.PanicErr(err)
if resetDB {
resetDatabase(client, ctx)
}
return setupOCR2VRFNodeFromClient(client, ctx, e)
}