From fe2e8fd21d65c9faee6afa6668b8e12797b957ce Mon Sep 17 00:00:00 2001 From: Ilja Pavlovs Date: Mon, 6 May 2024 02:09:02 +0300 Subject: [PATCH] VRF-1035: Add retrieval of VRF Wrapper Config in superscripts (#12977) --- core/scripts/vrfv2/testnet/main.go | 13 ++++++++++--- core/scripts/vrfv2/testnet/v2scripts/util.go | 15 +++++++++++---- core/scripts/vrfv2plus/testnet/main.go | 11 +++++++++-- .../vrfv2plus/testnet/v2plusscripts/util.go | 7 +++++++ 4 files changed, 37 insertions(+), 9 deletions(-) diff --git a/core/scripts/vrfv2/testnet/main.go b/core/scripts/vrfv2/testnet/main.go index 88f4d9e0f73..c0e62af781d 100644 --- a/core/scripts/vrfv2/testnet/main.go +++ b/core/scripts/vrfv2/testnet/main.go @@ -12,9 +12,6 @@ import ( "strings" "sync" - "github.com/smartcontractkit/chainlink/core/scripts/vrfv2/testnet/v2scripts" - "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/vrf_owner_test_consumer" - "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" @@ -22,6 +19,9 @@ import ( "github.com/ethereum/go-ethereum/crypto" "github.com/shopspring/decimal" + "github.com/smartcontractkit/chainlink/core/scripts/vrfv2/testnet/v2scripts" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/vrf_owner_test_consumer" + "github.com/jmoiron/sqlx" helpers "github.com/smartcontractkit/chainlink/core/scripts/common" @@ -1294,6 +1294,13 @@ func main() { *wrapperPremiumPercentage, *keyHash, *maxNumWords) + case "wrapper-get-config": + cmd := flag.NewFlagSet("wrapper-get-config", flag.ExitOnError) + wrapperAddress := cmd.String("wrapper-address", "", "wrapper address") + helpers.ParseArgs(cmd, os.Args[2:], "wrapper-address") + wrapper, err := vrfv2_wrapper.NewVRFV2Wrapper(common.HexToAddress(*wrapperAddress), e.Ec) + helpers.PanicErr(err) + v2scripts.PrintWrapperConfig(wrapper) 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") diff --git a/core/scripts/vrfv2/testnet/v2scripts/util.go b/core/scripts/vrfv2/testnet/v2scripts/util.go index 325ced2ab21..2f6e7df23ec 100644 --- a/core/scripts/vrfv2/testnet/v2scripts/util.go +++ b/core/scripts/vrfv2/testnet/v2scripts/util.go @@ -7,14 +7,14 @@ import ( "fmt" "math/big" - "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/vrf_coordinator_test_v2" - "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/vrf_coordinator_v2" - "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/vrf_load_test_with_metrics" - "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/crypto" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/vrf_coordinator_test_v2" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/vrf_coordinator_v2" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/vrf_load_test_with_metrics" + helpers "github.com/smartcontractkit/chainlink/core/scripts/common" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/batch_blockhash_store" @@ -208,6 +208,13 @@ func WrapperConfigure( helpers.ConfirmTXMined(context.Background(), e.Ec, tx, e.ChainID) } +func PrintWrapperConfig(wrapper *vrfv2_wrapper.VRFV2Wrapper) { + cfg, err := wrapper.GetConfig(nil) + helpers.PanicErr(err) + fmt.Printf("Wrapper config: %+v\n", cfg) + fmt.Printf("Wrapper Keyhash: %s\n", fmt.Sprintf("0x%x", cfg.KeyHash)) +} + func WrapperConsumerDeploy( e helpers.Environment, link, wrapper common.Address, diff --git a/core/scripts/vrfv2plus/testnet/main.go b/core/scripts/vrfv2plus/testnet/main.go index c2e6a710858..7b47a2f8529 100644 --- a/core/scripts/vrfv2plus/testnet/main.go +++ b/core/scripts/vrfv2plus/testnet/main.go @@ -11,6 +11,8 @@ import ( "os" "strings" + "github.com/ethereum/go-ethereum" + "github.com/smartcontractkit/chainlink/core/scripts/vrfv2plus/testnet/v2plusscripts" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/chain_specific_util_helper" @@ -18,7 +20,6 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/vrf_coordinator_v2plus_interface" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/vrf_v2plus_load_test_with_metrics" - "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" @@ -1234,7 +1235,13 @@ func main() { uint32(*stalenessSeconds), uint32(*fulfillmentFlatFeeNativePPM), uint32(*fulfillmentFlatFeeLinkDiscountPPM)) - + case "wrapper-get-config": + cmd := flag.NewFlagSet("wrapper-get-config", flag.ExitOnError) + wrapperAddress := cmd.String("wrapper-address", "", "wrapper address") + helpers.ParseArgs(cmd, os.Args[2:], "wrapper-address") + wrapper, err := vrfv2plus_wrapper.NewVRFV2PlusWrapper(common.HexToAddress(*wrapperAddress), e.Ec) + helpers.PanicErr(err) + v2plusscripts.PrintWrapperConfig(wrapper) 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") diff --git a/core/scripts/vrfv2plus/testnet/v2plusscripts/util.go b/core/scripts/vrfv2plus/testnet/v2plusscripts/util.go index 6fbdc88b869..3d511605811 100644 --- a/core/scripts/vrfv2plus/testnet/v2plusscripts/util.go +++ b/core/scripts/vrfv2plus/testnet/v2plusscripts/util.go @@ -287,6 +287,13 @@ func WrapperConfigure( helpers.ConfirmTXMined(context.Background(), e.Ec, tx, e.ChainID) } +func PrintWrapperConfig(wrapper *vrfv2plus_wrapper.VRFV2PlusWrapper) { + cfg, err := wrapper.GetConfig(nil) + helpers.PanicErr(err) + fmt.Printf("Wrapper config: %+v\n", cfg) + fmt.Printf("Wrapper Keyhash: %s\n", fmt.Sprintf("0x%x", cfg.KeyHash)) +} + func WrapperConsumerDeploy( e helpers.Environment, link, wrapper common.Address,