Skip to content

Commit

Permalink
chore: fix wrapper config in v2plus scripts (#10845)
Browse files Browse the repository at this point in the history
  • Loading branch information
makramkd authored Oct 4, 2023
1 parent 61ccf8b commit c97bb57
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 10 deletions.
12 changes: 10 additions & 2 deletions core/scripts/vrfv2plus/testnet/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -1112,15 +1112,23 @@ func main() {
wrapperPremiumPercentage := cmd.Uint("wrapper-premium-percentage", 25, "gas premium charged by wrapper")
keyHash := cmd.String("key-hash", "", "the keyhash that wrapper requests should use")
maxNumWords := cmd.Uint("max-num-words", 10, "the keyhash that wrapper requests should use")
helpers.ParseArgs(cmd, os.Args[2:], "wrapper-address", "key-hash")
fallbackWeiPerUnitLink := cmd.String("fallback-wei-per-unit-link", "", "the fallback wei per unit link")
stalenessSeconds := cmd.Uint("staleness-seconds", 86400, "the number of seconds of staleness to allow")
fulfillmentFlatFeeLinkPPM := cmd.Uint("fulfillment-flat-fee-link-ppm", 500, "the link flat fee in ppm to charge for fulfillment")
fulfillmentFlatFeeNativePPM := cmd.Uint("fulfillment-flat-fee-native-ppm", 500, "the native flat fee in ppm to charge for fulfillment")
helpers.ParseArgs(cmd, os.Args[2:], "wrapper-address", "key-hash", "fallback-wei-per-unit-link")

wrapperConfigure(e,
common.HexToAddress(*wrapperAddress),
*wrapperGasOverhead,
*coordinatorGasOverhead,
*wrapperPremiumPercentage,
*keyHash,
*maxNumWords)
*maxNumWords,
decimal.RequireFromString(*fallbackWeiPerUnitLink).BigInt(),
uint32(*stalenessSeconds),
uint32(*fulfillmentFlatFeeLinkPPM),
uint32(*fulfillmentFlatFeeNativePPM))
case "wrapper-get-fulfillment-tx-size":
cmd := flag.NewFlagSet("wrapper-get-fulfillment-tx-size", flag.ExitOnError)
wrapperAddress := cmd.String("wrapper-address", "", "address of the VRFV2Wrapper contract")
Expand Down
37 changes: 30 additions & 7 deletions core/scripts/vrfv2plus/testnet/super_scripts.go
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,8 @@ func deployUniverse(e helpers.Environment) {
// required flags
linkAddress := deployCmd.String("link-address", "", "address of link token")
linkEthAddress := deployCmd.String("link-eth-feed", "", "address of link eth feed")
bhsAddress := deployCmd.String("bhs-address", "", "address of blockhash store")
batchBHSAddress := deployCmd.String("batch-bhs-address", "", "address of batch blockhash store")
subscriptionBalanceString := deployCmd.String("subscription-balance", "1e19", "amount to fund subscription")

// optional flags
Expand Down Expand Up @@ -548,11 +550,21 @@ func deployUniverse(e helpers.Environment) {
linkEthAddress = &address
}

fmt.Println("\nDeploying BHS...")
bhsContractAddress := deployBHS(e)
var bhsContractAddress common.Address
if len(*bhsAddress) == 0 {
fmt.Println("\nDeploying BHS...")
bhsContractAddress = deployBHS(e)
} else {
bhsContractAddress = common.HexToAddress(*bhsAddress)
}

fmt.Println("\nDeploying Batch BHS...")
batchBHSAddress := deployBatchBHS(e, bhsContractAddress)
var batchBHSContractAddress common.Address
if len(*batchBHSAddress) == 0 {
fmt.Println("\nDeploying Batch BHS...")
batchBHSContractAddress = deployBatchBHS(e, bhsContractAddress)
} else {
batchBHSContractAddress = common.HexToAddress(*batchBHSAddress)
}

var coordinatorAddress common.Address
fmt.Println("\nDeploying Coordinator...")
Expand Down Expand Up @@ -637,11 +649,12 @@ func deployUniverse(e helpers.Environment) {
)

fmt.Println(
"\n----------------------------",
"\nDeployment complete.",
"\nLINK Token contract address:", *linkAddress,
"\nLINK/ETH Feed contract address:", *linkEthAddress,
"\nBlockhash Store contract address:", bhsContractAddress,
"\nBatch Blockhash Store contract address:", batchBHSAddress,
"\nBatch Blockhash Store contract address:", batchBHSContractAddress,
"\nVRF Coordinator Address:", coordinatorAddress,
"\nBatch VRF Coordinator Address:", batchCoordinatorAddress,
"\nVRF Consumer Address:", consumerAddress,
Expand All @@ -651,6 +664,7 @@ func deployUniverse(e helpers.Environment) {
fmt.Sprintf("go run . eoa-request --consumer-address %s --sub-id %d --key-hash %s", consumerAddress, subID, keyHash),
"\nA node can now be configured to run a VRF job with the below job spec :\n",
formattedJobSpec,
"\n----------------------------",
)
}

Expand All @@ -666,7 +680,11 @@ func deployWrapperUniverse(e helpers.Environment) {
maxNumWords := cmd.Uint("max-num-words", 10, "the keyhash that wrapper requests should use")
subFunding := cmd.String("sub-funding", "10000000000000000000", "amount to fund the subscription with")
consumerFunding := cmd.String("consumer-funding", "10000000000000000000", "amount to fund the consumer with")
helpers.ParseArgs(cmd, os.Args[2:], "link-address", "link-eth-feed", "coordinator-address", "key-hash")
fallbackWeiPerUnitLink := cmd.String("fallback-wei-per-unit-link", "", "the fallback wei per unit link")
stalenessSeconds := cmd.Uint("staleness-seconds", 86400, "the number of seconds of staleness to allow")
fulfillmentFlatFeeLinkPPM := cmd.Uint("fulfillment-flat-fee-link-ppm", 500, "the link flat fee in ppm to charge for fulfillment")
fulfillmentFlatFeeNativePPM := cmd.Uint("fulfillment-flat-fee-native-ppm", 500, "the native flat fee in ppm to charge for fulfillment")
helpers.ParseArgs(cmd, os.Args[2:], "link-address", "link-eth-feed", "coordinator-address", "key-hash", "fallback-wei-per-unit-link")

amount, s := big.NewInt(0).SetString(*subFunding, 10)
if !s {
Expand All @@ -684,7 +702,12 @@ func deployWrapperUniverse(e helpers.Environment) {
*coordinatorGasOverhead,
*wrapperPremiumPercentage,
*keyHash,
*maxNumWords)
*maxNumWords,
decimal.RequireFromString(*fallbackWeiPerUnitLink).BigInt(),
uint32(*stalenessSeconds),
uint32(*fulfillmentFlatFeeLinkPPM),
uint32(*fulfillmentFlatFeeNativePPM),
)

consumer := wrapperConsumerDeploy(e,
common.HexToAddress(*linkAddress),
Expand Down
12 changes: 11 additions & 1 deletion core/scripts/vrfv2plus/testnet/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,10 @@ func wrapperConfigure(
wrapperGasOverhead, coordinatorGasOverhead, premiumPercentage uint,
keyHash string,
maxNumWords uint,
fallbackWeiPerUnitLink *big.Int,
stalenessSeconds uint32,
fulfillmentFlatFeeLinkPPM uint32,
fulfillmentFlatFeeNativePPM uint32,
) {
wrapper, err := vrfv2plus_wrapper.NewVRFV2PlusWrapper(wrapperAddress, e.Ec)
helpers.PanicErr(err)
Expand All @@ -215,7 +219,13 @@ func wrapperConfigure(
uint32(coordinatorGasOverhead),
uint8(premiumPercentage),
common.HexToHash(keyHash),
uint8(maxNumWords))
uint8(maxNumWords),
stalenessSeconds,
fallbackWeiPerUnitLink,
fulfillmentFlatFeeLinkPPM,
fulfillmentFlatFeeNativePPM,
)

helpers.PanicErr(err)
helpers.ConfirmTXMined(context.Background(), e.Ec, tx, e.ChainID)
}
Expand Down

0 comments on commit c97bb57

Please sign in to comment.