diff --git a/integration-tests/actions/actions.go b/integration-tests/actions/actions.go index b657bacca94..65db18ad6f7 100644 --- a/integration-tests/actions/actions.go +++ b/integration-tests/actions/actions.go @@ -1205,6 +1205,13 @@ func BuildTOMLNodeConfigForK8s(testConfig ctfconfig.GlobalTestConfig, testNetwor return string(asStr), nil } +func IsOPStackChain(chainID int64) bool { + return chainID == 8453 || //BASE MAINNET + chainID == 84532 || //BASE SEPOLIA + chainID == 10 || //OPTIMISM MAINNET + chainID == 11155420 //OPTIMISM SEPOLIA +} + func RandBool() bool { return rand.Intn(2) == 1 } diff --git a/integration-tests/actions/vrf/vrfv2plus/contract_steps.go b/integration-tests/actions/vrf/vrfv2plus/contract_steps.go index 7e814ccceba..479b00d952e 100644 --- a/integration-tests/actions/vrf/vrfv2plus/contract_steps.go +++ b/integration-tests/actions/vrf/vrfv2plus/contract_steps.go @@ -24,6 +24,7 @@ import ( func DeployVRFV2_5Contracts( chainClient *seth.Client, + configGeneral *vrfv2plusconfig.General, ) (*vrfcommon.VRFContracts, error) { bhs, err := contracts.DeployBlockhashStore(chainClient) if err != nil { @@ -33,9 +34,25 @@ func DeployVRFV2_5Contracts( if err != nil { return nil, fmt.Errorf(vrfcommon.ErrGenericFormat, vrfcommon.ErrDeployBatchBlockHashStore, err) } - coordinator, err := contracts.DeployVRFCoordinatorV2_5(chainClient, bhs.Address()) - if err != nil { - return nil, fmt.Errorf(vrfcommon.ErrGenericFormat, ErrDeployCoordinatorV2Plus, err) + var coordinator contracts.VRFCoordinatorV2_5 + if actions.IsOPStackChain(chainClient.ChainID) { + opStackCoordinator, err := contracts.DeployVRFCoordinatorV2_5_Optimism(chainClient, bhs.Address()) + if err != nil { + return nil, fmt.Errorf(vrfcommon.ErrGenericFormat, ErrDeployCoordinatorV2Plus, err) + } + err = opStackCoordinator.SetL1FeeCalculation(configGeneral.L1FeeCalculationMode, configGeneral.L1FeeCoefficient) + if err != nil { + return nil, fmt.Errorf(vrfcommon.ErrGenericFormat, ErrSetL1FeeCalculation, err) + } + coordinator, err = contracts.LoadVRFCoordinatorV2_5(chainClient, opStackCoordinator.Address.String()) + if err != nil { + return nil, fmt.Errorf(vrfcommon.ErrGenericFormat, vrfcommon.ErrLoadingCoordinator, err) + } + } else { + coordinator, err = contracts.DeployVRFCoordinatorV2_5(chainClient, bhs.Address()) + if err != nil { + return nil, fmt.Errorf(vrfcommon.ErrGenericFormat, ErrDeployCoordinatorV2Plus, err) + } } batchCoordinator, err := contracts.DeployBatchVRFCoordinatorV2Plus(chainClient, coordinator.Address()) if err != nil { @@ -392,10 +409,28 @@ func DeployVRFV2PlusDirectFundingContracts( coordinator contracts.VRFCoordinatorV2_5, consumerContractsAmount int, wrapperSubId *big.Int, + configGeneral *vrfv2plusconfig.General, ) (*VRFV2PlusWrapperContracts, error) { - vrfv2PlusWrapper, err := contracts.DeployVRFV2PlusWrapper(sethClient, linkTokenAddress, linkEthFeedAddress, coordinator.Address(), wrapperSubId) - if err != nil { - return nil, fmt.Errorf(vrfcommon.ErrGenericFormat, ErrDeployWrapper, err) + var vrfv2PlusWrapper contracts.VRFV2PlusWrapper + var err error + if actions.IsOPStackChain(sethClient.ChainID) { + opStackWrapper, err := contracts.DeployVRFV2PlusWrapperOptimism(sethClient, linkTokenAddress, linkEthFeedAddress, coordinator.Address(), wrapperSubId) + if err != nil { + return nil, fmt.Errorf(vrfcommon.ErrGenericFormat, ErrDeployWrapper, err) + } + err = opStackWrapper.SetL1FeeCalculation(configGeneral.L1FeeCalculationMode, configGeneral.L1FeeCoefficient) + if err != nil { + return nil, fmt.Errorf(vrfcommon.ErrGenericFormat, ErrSetL1FeeCalculation, err) + } + vrfv2PlusWrapper, err = contracts.LoadVRFV2PlusWrapper(sethClient, opStackWrapper.Address.String()) + if err != nil { + return nil, fmt.Errorf(vrfcommon.ErrGenericFormat, vrfcommon.ErrLoadingCoordinator, err) + } + } else { + vrfv2PlusWrapper, err = contracts.DeployVRFV2PlusWrapper(sethClient, linkTokenAddress, linkEthFeedAddress, coordinator.Address(), wrapperSubId) + if err != nil { + return nil, fmt.Errorf(vrfcommon.ErrGenericFormat, ErrDeployWrapper, err) + } } consumers, err := DeployVRFV2PlusWrapperConsumers(sethClient, vrfv2PlusWrapper, consumerContractsAmount) if err != nil { @@ -530,7 +565,7 @@ func SetupVRFV2PlusContracts( l zerolog.Logger, ) (*vrfcommon.VRFContracts, error) { l.Info().Msg("Deploying VRFV2 Plus contracts") - vrfContracts, err := DeployVRFV2_5Contracts(sethClient) + vrfContracts, err := DeployVRFV2_5Contracts(sethClient, configGeneral) if err != nil { return nil, fmt.Errorf(vrfcommon.ErrGenericFormat, ErrDeployVRFV2_5Contracts, err) } diff --git a/integration-tests/actions/vrf/vrfv2plus/errors.go b/integration-tests/actions/vrf/vrfv2plus/errors.go index 250c4da85a7..a2802032ec9 100644 --- a/integration-tests/actions/vrf/vrfv2plus/errors.go +++ b/integration-tests/actions/vrf/vrfv2plus/errors.go @@ -16,4 +16,5 @@ const ( ErrLinkTotalBalance = "error waiting for RandomWordsFulfilled event" ErrNativeTokenBalance = "error waiting for RandomWordsFulfilled event" ErrDeployWrapper = "error deploying VRFV2PlusWrapper" + ErrSetL1FeeCalculation = "error setting L1 fee calculation" ) diff --git a/integration-tests/actions/vrf/vrfv2plus/setup_steps.go b/integration-tests/actions/vrf/vrfv2plus/setup_steps.go index 8a3661ed110..f3c7d53d6ee 100644 --- a/integration-tests/actions/vrf/vrfv2plus/setup_steps.go +++ b/integration-tests/actions/vrf/vrfv2plus/setup_steps.go @@ -268,6 +268,7 @@ func SetupVRFV2PlusWrapperEnvironment( coordinator, wrapperConsumerContractsAmount, wrapperSubId, + vrfv2PlusConfig, ) if err != nil { return nil, nil, fmt.Errorf(vrfcommon.ErrGenericFormat, vrfcommon.ErrWaitTXsComplete, err) diff --git a/integration-tests/contracts/ethereum_vrf_contracts.go b/integration-tests/contracts/ethereum_vrf_contracts.go index 3a18ae23d0a..e4dbb87d0b2 100644 --- a/integration-tests/contracts/ethereum_vrf_contracts.go +++ b/integration-tests/contracts/ethereum_vrf_contracts.go @@ -6,13 +6,15 @@ import ( "math/big" "time" - "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/vrf_coordinator_v2_5" - "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/vrf_v2plus_load_test_with_metrics" - "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" "github.com/rs/zerolog/log" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/vrf_coordinator_v2_5" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/vrf_v2plus_load_test_with_metrics" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/vrfv2plus_wrapper" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/vrfv2plus_wrapper_optimism" + "github.com/smartcontractkit/seth" "github.com/smartcontractkit/chainlink-testing-framework/blockchain" @@ -506,3 +508,41 @@ func LoadVRFv2PlusLoadTestConsumer(seth *seth.Client, addr string) (VRFv2PlusLoa consumer: contract, }, nil } + +func LoadVRFV2PlusWrapper(seth *seth.Client, addr string) (VRFV2PlusWrapper, error) { + address := common.HexToAddress(addr) + abi, err := vrfv2plus_wrapper.VRFV2PlusWrapperMetaData.GetAbi() + if err != nil { + return nil, fmt.Errorf("failed to get VRFV2PlusWrapper ABI: %w", err) + } + seth.ContractStore.AddABI("VRFV2PlusWrapper", *abi) + seth.ContractStore.AddBIN("VRFV2PlusWrapper", common.FromHex(vrfv2plus_wrapper.VRFV2PlusWrapperMetaData.Bin)) + contract, err := vrfv2plus_wrapper.NewVRFV2PlusWrapper(address, wrappers.MustNewWrappedContractBackend(nil, seth)) + if err != nil { + return nil, fmt.Errorf("failed to instantiate VRFV2PlusWrapper instance: %w", err) + } + return &EthereumVRFV2PlusWrapper{ + client: seth, + address: address, + wrapper: contract, + }, nil +} + +func LoadVRFV2PlusWrapperOptimism(seth *seth.Client, addr string) (*EthereumVRFV2PlusWrapperOptimism, error) { + address := common.HexToAddress(addr) + abi, err := vrfv2plus_wrapper_optimism.VRFV2PlusWrapperOptimismMetaData.GetAbi() + if err != nil { + return nil, fmt.Errorf("failed to get VRFV2PlusWrapper_Optimism ABI: %w", err) + } + seth.ContractStore.AddABI("VRFV2PlusWrapper_Optimism", *abi) + seth.ContractStore.AddBIN("VRFV2PlusWrapper_Optimism", common.FromHex(vrfv2plus_wrapper_optimism.VRFV2PlusWrapperOptimismMetaData.Bin)) + contract, err := vrfv2plus_wrapper_optimism.NewVRFV2PlusWrapperOptimism(address, wrappers.MustNewWrappedContractBackend(nil, seth)) + if err != nil { + return nil, fmt.Errorf("failed to instantiate VRFV2PlusWrapper_Optimism instance: %w", err) + } + return &EthereumVRFV2PlusWrapperOptimism{ + client: seth, + Address: address, + wrapper: contract, + }, nil +} diff --git a/integration-tests/contracts/ethereum_vrfv2plus_contracts.go b/integration-tests/contracts/ethereum_vrfv2plus_contracts.go index ea0ee18e937..8e099b4f6bc 100644 --- a/integration-tests/contracts/ethereum_vrfv2plus_contracts.go +++ b/integration-tests/contracts/ethereum_vrfv2plus_contracts.go @@ -17,10 +17,12 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/batch_blockhash_store" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/batch_vrf_coordinator_v2plus" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/vrf_coordinator_v2_5" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/vrf_coordinator_v2_5_optimism" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/vrf_v2plus_load_test_with_metrics" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/vrf_v2plus_upgraded_version" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/vrfv2plus_wrapper" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/vrfv2plus_wrapper_load_test_consumer" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/vrfv2plus_wrapper_optimism" ) type EthereumVRFCoordinatorV2_5 struct { @@ -29,6 +31,12 @@ type EthereumVRFCoordinatorV2_5 struct { coordinator vrf_coordinator_v2_5.VRFCoordinatorV25Interface } +type EthereumVRFCoordinatorV2_5_Optimism struct { + Address common.Address + client *seth.Client + coordinator vrf_coordinator_v2_5_optimism.VRFCoordinatorV25Optimism +} + type EthereumBatchVRFCoordinatorV2Plus struct { address common.Address client *seth.Client @@ -60,6 +68,12 @@ type EthereumVRFV2PlusWrapper struct { wrapper *vrfv2plus_wrapper.VRFV2PlusWrapper } +type EthereumVRFV2PlusWrapperOptimism struct { + Address common.Address + client *seth.Client + wrapper *vrfv2plus_wrapper_optimism.VRFV2PlusWrapperOptimism +} + func (v *EthereumVRFV2PlusWrapper) Address() string { return v.address.Hex() } @@ -114,22 +128,22 @@ func (v *EthereumVRFV2PlusWrapper) Coordinator(ctx context.Context) (common.Addr func DeployVRFCoordinatorV2_5(seth *seth.Client, bhsAddr string) (VRFCoordinatorV2_5, error) { abi, err := vrf_coordinator_v2_5.VRFCoordinatorV25MetaData.GetAbi() if err != nil { - return &EthereumVRFCoordinatorV2_5{}, fmt.Errorf("failed to get VRFCoordinatorV2Plus ABI: %w", err) + return &EthereumVRFCoordinatorV2_5{}, fmt.Errorf("failed to get VRFCoordinatorV2_5 ABI: %w", err) } coordinatorDeploymentData, err := seth.DeployContract( seth.NewTXOpts(), - "VRFCoordinatorV2Plus", + "VRFCoordinatorV2_5", *abi, common.FromHex(vrf_coordinator_v2_5.VRFCoordinatorV25MetaData.Bin), common.HexToAddress(bhsAddr)) if err != nil { - return &EthereumVRFCoordinatorV2_5{}, fmt.Errorf("VRFCoordinatorV2Plus instance deployment have failed: %w", err) + return &EthereumVRFCoordinatorV2_5{}, fmt.Errorf("VRFCoordinatorV2_5 instance deployment have failed: %w", err) } contract, err := vrf_coordinator_v2_5.NewVRFCoordinatorV25(coordinatorDeploymentData.Address, wrappers.MustNewWrappedContractBackend(nil, seth)) if err != nil { - return &EthereumVRFCoordinatorV2_5{}, fmt.Errorf("failed to instantiate VRFCoordinatorV2Plus instance: %w", err) + return &EthereumVRFCoordinatorV2_5{}, fmt.Errorf("failed to instantiate VRFCoordinatorV2_5 instance: %w", err) } return &EthereumVRFCoordinatorV2_5{ @@ -139,6 +153,31 @@ func DeployVRFCoordinatorV2_5(seth *seth.Client, bhsAddr string) (VRFCoordinator }, err } +func DeployVRFCoordinatorV2_5_Optimism(seth *seth.Client, bhsAddr string) (*EthereumVRFCoordinatorV2_5_Optimism, error) { + abi, err := vrf_coordinator_v2_5_optimism.VRFCoordinatorV25OptimismMetaData.GetAbi() + if err != nil { + return nil, fmt.Errorf("failed to get VRFCoordinatorV2_5_Optimism ABI: %w", err) + } + coordinatorDeploymentData, err := seth.DeployContract( + seth.NewTXOpts(), + "VRFCoordinatorV2_5_Optimism", + *abi, + common.FromHex(vrf_coordinator_v2_5_optimism.VRFCoordinatorV25OptimismMetaData.Bin), + common.HexToAddress(bhsAddr)) + if err != nil { + return nil, fmt.Errorf("VRFCoordinatorV2_5_Optimism instance deployment have failed: %w", err) + } + contract, err := vrf_coordinator_v2_5_optimism.NewVRFCoordinatorV25Optimism(coordinatorDeploymentData.Address, wrappers.MustNewWrappedContractBackend(nil, seth)) + if err != nil { + return nil, fmt.Errorf("failed to instantiate VRFCoordinatorV2_5_Optimism instance: %w", err) + } + return &EthereumVRFCoordinatorV2_5_Optimism{ + client: seth, + coordinator: *contract, + Address: coordinatorDeploymentData.Address, + }, err +} + func DeployBatchVRFCoordinatorV2Plus(seth *seth.Client, coordinatorAddress string) (BatchVRFCoordinatorV2Plus, error) { abi, err := batch_vrf_coordinator_v2plus.BatchVRFCoordinatorV2PlusMetaData.GetAbi() if err != nil { @@ -147,7 +186,7 @@ func DeployBatchVRFCoordinatorV2Plus(seth *seth.Client, coordinatorAddress strin coordinatorDeploymentData, err := seth.DeployContract( seth.NewTXOpts(), - "VRFCoordinatorV2Plus", + "BatchVRFCoordinatorV2Plus", *abi, common.FromHex(batch_vrf_coordinator_v2plus.BatchVRFCoordinatorV2PlusMetaData.Bin), common.HexToAddress(coordinatorAddress)) @@ -563,6 +602,14 @@ func (v *EthereumVRFCoordinatorV2_5) WaitForConfigSetEvent(timeout time.Duration } } +func (v *EthereumVRFCoordinatorV2_5_Optimism) SetL1FeeCalculation( + mode uint8, + coefficient uint8, +) error { + _, err := v.client.Decode(v.coordinator.SetL1FeeCalculation(v.client.NewTXOpts(), mode, coefficient)) + return err +} + func (v *EthereumVRFv2PlusLoadTestConsumer) Address() string { return v.address.Hex() } @@ -1093,7 +1140,6 @@ func DeployVRFV2PlusWrapper(seth *seth.Client, linkAddr string, linkEthFeedAddr if err != nil { return &EthereumVRFV2PlusWrapper{}, fmt.Errorf("failed to get VRFV2PlusWrapper ABI: %w", err) } - data, err := seth.DeployContract( seth.NewTXOpts(), "VRFV2PlusWrapper", @@ -1104,12 +1150,10 @@ func DeployVRFV2PlusWrapper(seth *seth.Client, linkAddr string, linkEthFeedAddr if err != nil { return &EthereumVRFV2PlusWrapper{}, fmt.Errorf("VRFV2PlusWrapper instance deployment have failed: %w", err) } - contract, err := vrfv2plus_wrapper.NewVRFV2PlusWrapper(data.Address, wrappers.MustNewWrappedContractBackend(nil, seth)) if err != nil { return &EthereumVRFV2PlusWrapper{}, fmt.Errorf("failed to instantiate VRFV2PlusWrapper instance: %w", err) } - return &EthereumVRFV2PlusWrapper{ client: seth, wrapper: contract, @@ -1117,12 +1161,37 @@ func DeployVRFV2PlusWrapper(seth *seth.Client, linkAddr string, linkEthFeedAddr }, err } +func DeployVRFV2PlusWrapperOptimism(seth *seth.Client, linkAddr string, linkEthFeedAddr string, coordinatorAddr string, subId *big.Int) (*EthereumVRFV2PlusWrapperOptimism, error) { + abi, err := vrfv2plus_wrapper_optimism.VRFV2PlusWrapperOptimismMetaData.GetAbi() + if err != nil { + return nil, fmt.Errorf("failed to get VRFV2PlusWrapperOptimism ABI: %w", err) + } + data, err := seth.DeployContract( + seth.NewTXOpts(), + "VRFV2PlusWrapperOptimism", + *abi, + common.FromHex(vrfv2plus_wrapper_optimism.VRFV2PlusWrapperOptimismMetaData.Bin), + common.HexToAddress(linkAddr), common.HexToAddress(linkEthFeedAddr), + common.HexToAddress(coordinatorAddr), subId) + if err != nil { + return nil, fmt.Errorf("VRFV2PlusWrapperOptimism instance deployment have failed: %w", err) + } + contract, err := vrfv2plus_wrapper_optimism.NewVRFV2PlusWrapperOptimism(data.Address, wrappers.MustNewWrappedContractBackend(nil, seth)) + if err != nil { + return nil, fmt.Errorf("failed to instantiate VRFV2PlusWrapperOptimism instance: %w", err) + } + return &EthereumVRFV2PlusWrapperOptimism{ + client: seth, + wrapper: contract, + Address: data.Address, + }, err +} + func DeployVRFV2PlusWrapperLoadTestConsumer(seth *seth.Client, vrfV2PlusWrapperAddr string) (VRFv2PlusWrapperLoadTestConsumer, error) { abi, err := vrfv2plus_wrapper_load_test_consumer.VRFV2PlusWrapperLoadTestConsumerMetaData.GetAbi() if err != nil { return &EthereumVRFV2PlusWrapperLoadTestConsumer{}, fmt.Errorf("failed to get VRFV2PlusWrapperLoadTestConsumer ABI: %w", err) } - data, err := seth.DeployContract( seth.NewTXOpts(), "VRFV2PlusWrapperLoadTestConsumer", @@ -1137,7 +1206,6 @@ func DeployVRFV2PlusWrapperLoadTestConsumer(seth *seth.Client, vrfV2PlusWrapperA if err != nil { return &EthereumVRFV2PlusWrapperLoadTestConsumer{}, fmt.Errorf("failed to instantiate VRFV2PlusWrapperLoadTestConsumer instance: %w", err) } - return &EthereumVRFV2PlusWrapperLoadTestConsumer{ client: seth, consumer: contract, @@ -1145,6 +1213,11 @@ func DeployVRFV2PlusWrapperLoadTestConsumer(seth *seth.Client, vrfV2PlusWrapperA }, err } +func (v *EthereumVRFV2PlusWrapperOptimism) SetL1FeeCalculation(mode uint8, coefficient uint8) error { + _, err := v.client.Decode(v.wrapper.SetL1FeeCalculation(v.client.NewTXOpts(), mode, coefficient)) + return err +} + func (v *EthereumVRFV2PlusWrapperLoadTestConsumer) Address() string { return v.address.Hex() } diff --git a/integration-tests/smoke/vrfv2_test.go b/integration-tests/smoke/vrfv2_test.go index cf3bc9431dc..7a53d2c57c8 100644 --- a/integration-tests/smoke/vrfv2_test.go +++ b/integration-tests/smoke/vrfv2_test.go @@ -912,11 +912,13 @@ func TestVRFV2WithBHS(t *testing.T) { require.NoError(t, err) err = vrfv2.FundSubscriptions(big.NewFloat(*configCopy.VRFv2.General.SubscriptionFundingAmountLink), vrfContracts.LinkToken, vrfContracts.CoordinatorV2, subIDsForBHS) require.NoError(t, err, "error funding subscriptions") - randomWordsFulfilledEvent, err := vrfContracts.CoordinatorV2.WaitForRandomWordsFulfilledEvent( - contracts.RandomWordsFulfilledEventFilter{ - RequestIds: []*big.Int{randomWordsRequestedEvent.RequestId}, - Timeout: configCopy.VRFv2.General.RandomWordsFulfilledEventTimeout.Duration, - }, + + randomWordsFulfilledEvent, err := vrfv2.WaitRandomWordsFulfilledEvent( + vrfContracts.CoordinatorV2, + randomWordsRequestedEvent.RequestId, + randomWordsRequestedEvent.Raw.BlockNumber, + configCopy.VRFv2.General.RandomWordsFulfilledEventTimeout.Duration, + l, ) require.NoError(t, err, "error waiting for randomness fulfilled event") vrfcommon.LogRandomWordsFulfilledEvent(l, vrfContracts.CoordinatorV2, randomWordsFulfilledEvent, false, 0) @@ -1189,11 +1191,12 @@ func TestVRFV2NodeReorg(t *testing.T) { // For context - when performing debug_setHead on geth simulated chain and therefore rewinding chain to a previous block, //then tx that was mined after reorg will not appear in canonical chain contrary to real world scenario //Hence, we only verify that VRF node will not generate fulfillment for the reorged fork request - _, err = vrfContracts.CoordinatorV2.WaitForRandomWordsFulfilledEvent( - contracts.RandomWordsFulfilledEventFilter{ - RequestIds: []*big.Int{randomWordsRequestedEvent.RequestId}, - Timeout: time.Second * 10, - }, + _, err = vrfv2.WaitRandomWordsFulfilledEvent( + vrfContracts.CoordinatorV2, + randomWordsRequestedEvent.RequestId, + randomWordsRequestedEvent.Raw.BlockNumber, + time.Second*10, + l, ) require.Error(t, err, "fulfillment should not be generated for the request which was made on reorged fork on Simulated Chain") }) diff --git a/integration-tests/smoke/vrfv2plus_test.go b/integration-tests/smoke/vrfv2plus_test.go index b0deaa3c9c8..f519aa6cd5f 100644 --- a/integration-tests/smoke/vrfv2plus_test.go +++ b/integration-tests/smoke/vrfv2plus_test.go @@ -1365,12 +1365,15 @@ func TestVRFV2PlusWithBHS(t *testing.T) { *configCopy.VRFv2Plus.General.SubscriptionBillingType, ) require.NoError(t, err, "error funding subscriptions") - randomWordsFulfilledEvent, err := vrfContracts.CoordinatorV2Plus.WaitForRandomWordsFulfilledEvent( - contracts.RandomWordsFulfilledEventFilter{ - RequestIds: []*big.Int{randomWordsRequestedEvent.RequestId}, - SubIDs: []*big.Int{subID}, - Timeout: configCopy.VRFv2Plus.General.RandomWordsFulfilledEventTimeout.Duration, - }, + randomWordsFulfilledEvent, err := vrfv2plus.WaitRandomWordsFulfilledEvent( + vrfContracts.CoordinatorV2Plus, + randomWordsRequestedEvent.RequestId, + subID, + randomWordsRequestedEvent.Raw.BlockNumber, + isNativeBilling, + configCopy.VRFv2Plus.General.RandomWordsFulfilledEventTimeout.Duration, + l, + 0, ) require.NoError(t, err, "error waiting for randomness fulfilled event") vrfcommon.LogRandomWordsFulfilledEvent(l, vrfContracts.CoordinatorV2Plus, randomWordsFulfilledEvent, isNativeBilling, 0) @@ -1606,12 +1609,16 @@ func TestVRFV2PlusWithBHF(t *testing.T) { *configCopy.VRFv2Plus.General.SubscriptionBillingType, ) require.NoError(t, err, "error funding subscriptions") - randomWordsFulfilledEvent, err := vrfContracts.CoordinatorV2Plus.WaitForRandomWordsFulfilledEvent( - contracts.RandomWordsFulfilledEventFilter{ - RequestIds: []*big.Int{randomWordsRequestedEvent.RequestId}, - SubIDs: []*big.Int{subID}, - Timeout: configCopy.VRFv2Plus.General.RandomWordsFulfilledEventTimeout.Duration, - }, + + randomWordsFulfilledEvent, err := vrfv2plus.WaitRandomWordsFulfilledEvent( + vrfContracts.CoordinatorV2Plus, + randomWordsRequestedEvent.RequestId, + subID, + randomWordsRequestedEvent.Raw.BlockNumber, + isNativeBilling, + configCopy.VRFv2Plus.General.RandomWordsFulfilledEventTimeout.Duration, + l, + 0, ) require.NoError(t, err, "error waiting for randomness fulfilled event") vrfcommon.LogRandomWordsFulfilledEvent(l, vrfContracts.CoordinatorV2Plus, randomWordsFulfilledEvent, isNativeBilling, 0) @@ -1790,12 +1797,15 @@ func TestVRFv2PlusReplayAfterTimeout(t *testing.T) { l.Info().Str("reqID", initialReqRandomWordsRequestedEvent.RequestId.String()). Str("subID", subID.String()). Msg("Waiting for initalReqRandomWordsFulfilledEvent") - initalReqRandomWordsFulfilledEvent, err := vrfContracts.CoordinatorV2Plus.WaitForRandomWordsFulfilledEvent( - contracts.RandomWordsFulfilledEventFilter{ - RequestIds: []*big.Int{initialReqRandomWordsRequestedEvent.RequestId}, - SubIDs: []*big.Int{subID}, - Timeout: configCopy.VRFv2Plus.General.RandomWordsFulfilledEventTimeout.Duration, - }, + initalReqRandomWordsFulfilledEvent, err := vrfv2plus.WaitRandomWordsFulfilledEvent( + vrfContracts.CoordinatorV2Plus, + initialReqRandomWordsRequestedEvent.RequestId, + subID, + initialReqRandomWordsRequestedEvent.Raw.BlockNumber, + isNativeBilling, + configCopy.VRFv2Plus.General.RandomWordsFulfilledEventTimeout.Duration, + l, + 0, ) require.NoError(t, err, "error waiting for initial request RandomWordsFulfilledEvent") @@ -2069,12 +2079,15 @@ func TestVRFv2PlusNodeReorg(t *testing.T) { // For context - when performing debug_setHead on geth simulated chain and therefore rewinding chain to a previous block, //then tx that was mined after reorg will not appear in canonical chain contrary to real world scenario //Hence, we only verify that VRF node will not generate fulfillment for the reorged fork request - _, err = vrfContracts.CoordinatorV2Plus.WaitForRandomWordsFulfilledEvent( - contracts.RandomWordsFulfilledEventFilter{ - RequestIds: []*big.Int{randomWordsRequestedEvent.RequestId}, - SubIDs: []*big.Int{subID}, - Timeout: time.Second * 10, - }, + _, err = vrfv2plus.WaitRandomWordsFulfilledEvent( + vrfContracts.CoordinatorV2Plus, + randomWordsRequestedEvent.RequestId, + subID, + randomWordsRequestedEvent.Raw.BlockNumber, + isNativeBilling, + time.Second*10, + l, + 0, ) require.Error(t, err, "fulfillment should not be generated for the request which was made on reorged fork on Simulated Chain") }) diff --git a/integration-tests/testconfig/vrfv2plus/config.go b/integration-tests/testconfig/vrfv2plus/config.go index eb5ba061984..9d863afdd14 100644 --- a/integration-tests/testconfig/vrfv2plus/config.go +++ b/integration-tests/testconfig/vrfv2plus/config.go @@ -55,6 +55,10 @@ type General struct { CoordinatorGasOverheadLink *uint32 `toml:"coordinator_gas_overhead_link"` CoordinatorNativePremiumPercentage *uint8 `toml:"coordinator_native_premium_percentage"` CoordinatorLinkPremiumPercentage *uint8 `toml:"coordinator_link_premium_percentage"` + + //OP Stack chains settings + L1FeeCalculationMode uint8 `toml:"l1_fee_calculation_mode"` + L1FeeCoefficient uint8 `toml:"l1_fee_coefficient"` } func (c *General) Validate() error { diff --git a/integration-tests/testconfig/vrfv2plus/vrfv2plus.toml b/integration-tests/testconfig/vrfv2plus/vrfv2plus.toml index 18837581124..8f8aa9530e7 100644 --- a/integration-tests/testconfig/vrfv2plus/vrfv2plus.toml +++ b/integration-tests/testconfig/vrfv2plus/vrfv2plus.toml @@ -97,6 +97,10 @@ fulfillment_flat_fee_link_discount_ppm=0 native_premium_percentage=24 link_premium_percentage=20 +# 0 = L1_GAS_FEES_MODE; 1 = L1_CALLDATA_GAS_COST_MODE; 2 = L1_GAS_FEES_UPPER_BOUND_MODE +l1_fee_calculation_mode = 2 +l1_fee_coefficient = 80 + # Wrapper config wrapped_gas_overhead = 50000 coordinator_gas_overhead_native = 52000