Skip to content

Commit

Permalink
VRF-586: add env setup script for VRF V2 Plus (#10892)
Browse files Browse the repository at this point in the history
* VRF-586: add env setup script for VRF V2 Plus

* VRF-586: deleting debug logs
  • Loading branch information
iljapavlovs authored Oct 10, 2023
1 parent dfb97e5 commit e499700
Show file tree
Hide file tree
Showing 28 changed files with 665 additions and 430 deletions.
34 changes: 34 additions & 0 deletions core/scripts/common/vrf/constants/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package constants

import (
"math/big"
)

var (
SubscriptionBalanceJuels = "1e19"
SubscriptionBalanceNativeWei = "1e18"

// optional flags
FallbackWeiPerUnitLink = big.NewInt(6e16)
BatchFulfillmentEnabled = true
MinConfs = 3
NodeSendingKeyFundingAmount = "1e17"
MaxGasLimit = int64(2.5e6)
StalenessSeconds = int64(86400)
GasAfterPayment = int64(33285)

//vrfv2
FlatFeeTier1 = int64(500)
FlatFeeTier2 = int64(500)
FlatFeeTier3 = int64(500)
FlatFeeTier4 = int64(500)
FlatFeeTier5 = int64(500)
ReqsForTier2 = int64(0)
ReqsForTier3 = int64(0)
ReqsForTier4 = int64(0)
ReqsForTier5 = int64(0)

//vrfv2plus
FlatFeeLinkPPM = int64(500)
FlatFeeNativePPM = int64(500)
)
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@ services:

secrets:
node_password:
file: ./secrets/password.txt
file: secrets/password.txt
apicredentials:
file: ./secrets/apicredentials
file: secrets/apicredentials

volumes:
docker-compose-db:
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[Feature]
LogPoller = false #VRF V2 uses Log Broadcast3er instead of Log poller
LogPoller = false #VRF V2 uses Log Broadcaster instead of Log poller

[[EVM]]
ChainID = '11155111'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[Feature]
LogPoller = false #VRF V2 uses Log Broadcast3er instead of Log poller
LogPoller = false #VRF V2 uses Log Broadcaster instead of Log poller

[[EVM]]
ChainID = '11155111'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package jobs

var (
VRFJobFormatted = `type = "vrf"
VRFV2JobFormatted = `type = "vrf"
name = "vrf_v2"
schemaVersion = 1
coordinatorAddress = "%s"
Expand Down Expand Up @@ -38,6 +38,46 @@ simulate [type=ethcall
decode_log->vrf->estimate_gas->simulate
"""`

VRFV2PlusJobFormatted = `
type = "vrf"
name = "vrf_v2_plus"
schemaVersion = 1
coordinatorAddress = "%s"
batchCoordinatorAddress = "%s"
batchFulfillmentEnabled = %t
batchFulfillmentGasMultiplier = 1.1
publicKey = "%s"
minIncomingConfirmations = %d
evmChainID = "%d"
fromAddresses = ["%s"]
pollPeriod = "300ms"
requestTimeout = "30m0s"
observationSource = """
decode_log [type=ethabidecodelog
abi="RandomWordsRequested(bytes32 indexed keyHash,uint256 requestId,uint256 preSeed,uint256 indexed subId,uint16 minimumRequestConfirmations,uint32 callbackGasLimit,uint32 numWords,bytes extraArgs,address indexed sender)"
data="$(jobRun.logData)"
topics="$(jobRun.logTopics)"]
generate_proof [type=vrfv2plus
publicKey="$(jobSpec.publicKey)"
requestBlockHash="$(jobRun.logBlockHash)"
requestBlockNumber="$(jobRun.logBlockNumber)"
topics="$(jobRun.logTopics)"]
estimate_gas [type=estimategaslimit
to="%s"
multiplier="1.1"
data="$(generate_proof.output)"]
simulate_fulfillment [type=ethcall
from="%s"
to="%s"
gas="$(estimate_gas)"
gasPrice="$(jobSpec.maxGasPrice)"
extractRevertReason=true
contract="%s"
data="$(generate_proof.output)"]
decode_log->generate_proof->estimate_gas->simulate_fulfillment
"""
`

BHSJobFormatted = `type = "blockhashstore"
schemaVersion = 1
name = "blockhashstore"
Expand Down
46 changes: 46 additions & 0 deletions core/scripts/common/vrf/model/model.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package model

import (
"github.com/ethereum/go-ethereum/common"
"math/big"
)

var (
VRFPrimaryNodeName = "vrf-primary-node"
VRFBackupNodeName = "vrf-backup-node"
BHSNodeName = "bhs-node"
BHSBackupNodeName = "bhs-backup-node"
BHFNodeName = "bhf-node"
)

type Node struct {
URL string
CredsFile string
SendingKeys []SendingKey
NumberOfSendingKeysToCreate int
SendingKeyFundingAmount *big.Int
VrfKeys []string
jobSpec string
}

type SendingKey struct {
Address string
BalanceEth *big.Int
}

type JobSpecs struct {
VRFPrimaryNode string
VRFBackupyNode string
BHSNode string
BHSBackupNode string
BHFNode string
}

type ContractAddresses struct {
LinkAddress string
LinkEthAddress string
BhsContractAddress common.Address
BatchBHSAddress common.Address
CoordinatorAddress common.Address
BatchCoordinatorAddress common.Address
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* Currently possible to fund all nodes with one amount of native tokens
## Commands:
1. If using Docker Compose
1. create `.env` file in `core/scripts/vrfv2/testnet/docker` (can use `sample.env` file as an example)
2. go to `core/scripts/vrfv2/testnet/docker` folder and start containers - `docker compose up`
1. create `.env` file in `core/scripts/common/vrf/docker` (can use `sample.env` file as an example)
2. go to `core/scripts/common/vrf/docker` folder and start containers - `docker compose up`
2. Update [rpc-nodes.toml](..%2Fdocker%2Ftoml-config%2Frpc-nodes.toml) with relevant RPC nodes
3. Create files with credentials desirably outside `chainlink` repo (just not to push creds accidentally). Populate the files with relevant credentials for the nodes
4. Ensure that following env variables are set
Expand All @@ -14,9 +14,10 @@ export ETH_URL=
export ETH_CHAIN_ID=
export ACCOUNT_KEY=
```
5. execute from `core/scripts/vrfv2/testnet/setup-envs` folder
5. execute from `core/scripts/common/vrf/setup-envs` folder
```
go run . \
--vrf-version="v2plus" \
--vrf-primary-node-url=http://localhost:6610 \
--vrf-primary-creds-file <path_to_file_with_creds> \
--vrf-backup-node-url=http://localhost:6611 \
Expand All @@ -27,13 +28,14 @@ go run . \
--bhs-bk-creds-file <path_to_file_with_creds> \
--bhf-node-url=http://localhost:6614 \
--bhf-creds-file <path_to_file_with_creds> \
--deploy-contracts true \
--batch-fulfillment-enabled true \
--min-confs 1 \
--num-eth-keys 5 \
--num-vrf-keys 1 \
--sending-key-funding-amount 100000000000000000
--deploy-contracts-and-create-jobs="true" \
--subscription-balance="1e19" \
--subscription-balance-native="1e18" \
--batch-fulfillment-enabled="true" \
--min-confs=3 \
--num-eth-keys=1 \
--num-vrf-keys=1 \
--sending-key-funding-amount="1e17"
```

Optional parameters - will not be deployed if specified (NOT WORKING YET)
Expand Down
Loading

0 comments on commit e499700

Please sign in to comment.