Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jinhoonbang committed Dec 21, 2023
1 parent 6b4b478 commit 279fec7
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 122 deletions.
60 changes: 0 additions & 60 deletions contracts/scripts/native_solc_compile_all_vrfv2plus

This file was deleted.

23 changes: 0 additions & 23 deletions core/gethwrappers/go_generate_vrfv2plus.go

This file was deleted.

26 changes: 16 additions & 10 deletions core/services/vrf/v2/integration_helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"github.com/smartcontractkit/chainlink/v2/core/internal/testutils/evmtest"
"github.com/smartcontractkit/chainlink/v2/core/services/chainlink"
"github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ethkey"
"github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/vrfkey"
"github.com/smartcontractkit/chainlink/v2/core/services/signatures/secp256k1"
v22 "github.com/smartcontractkit/chainlink/v2/core/services/vrf/v2"
"github.com/smartcontractkit/chainlink/v2/core/services/vrf/vrfcommon"
Expand Down Expand Up @@ -1681,16 +1682,7 @@ func testMaliciousConsumer(
time.Sleep(1 * time.Second)

// Register a proving key associated with the VRF job.
p, err := vrfkey.PublicKey.Point()
require.NoError(t, err)
if vrfVersion == vrfcommon.V2Plus {
_, err = uni.rootContract.RegisterProvingKey(
uni.neil, nil, pair(secp256k1.Coordinates(p)))
} else {
_, err = uni.rootContract.RegisterProvingKey(
uni.neil, &uni.nallory.From, pair(secp256k1.Coordinates(p)))
}
require.NoError(t, err)
registerProvingKey(t, uni, vrfkey)

subFunding := decimal.RequireFromString("1000000000000000000")
_, err = uni.maliciousConsumerContract.CreateSubscriptionAndFund(carol,
Expand Down Expand Up @@ -1744,3 +1736,17 @@ func testMaliciousConsumer(
}
require.Equal(t, 1, len(requests))
}

func registerProvingKey(t *testing.T, uni coordinatorV2UniverseCommon, vrfkey vrfkey.KeyV2) {
p, err := vrfkey.PublicKey.Point()
require.NoError(t, err)
if uni.rootContract.Version() == vrfcommon.V2Plus {
_, err = uni.rootContract.RegisterProvingKey(
uni.neil, nil, pair(secp256k1.Coordinates(p)))
} else {
_, err = uni.rootContract.RegisterProvingKey(
uni.neil, &uni.nallory.From, pair(secp256k1.Coordinates(p)))
}
require.NoError(t, err)
uni.backend.Commit()
}
1 change: 1 addition & 0 deletions core/services/vrf/v2/integration_v2_plus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -850,6 +850,7 @@ func TestVRFV2PlusIntegration_RequestCost(t *testing.T) {

vrfkey, err := app.GetKeyStore().VRF().Create()
require.NoError(t, err)
registerProvingKey(t, uni.coordinatorV2UniverseCommon, vrfkey)
p, err := vrfkey.PublicKey.Point()
require.NoError(t, err)
_, err = uni.rootContract.RegisterProvingKey(
Expand Down
34 changes: 5 additions & 29 deletions core/services/vrf/v2/integration_v2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1808,18 +1808,7 @@ func TestRequestCost(t *testing.T) {

vrfkey, err := app.GetKeyStore().VRF().Create()
require.NoError(t, err)
p, err := vrfkey.PublicKey.Point()
require.NoError(t, err)
if uni.rootContract.Version() == vrfcommon.V2Plus {
_, err = uni.rootContract.RegisterProvingKey(
uni.neil, nil, pair(secp256k1.Coordinates(p)))
} else {
_, err = uni.rootContract.RegisterProvingKey(
uni.neil, &uni.nallory.From, pair(secp256k1.Coordinates(p)))
}
require.NoError(t, err)
uni.backend.Commit()

registerProvingKey(t, uni.coordinatorV2UniverseCommon, vrfkey)
t.Run("non-proxied consumer", func(tt *testing.T) {
carol := uni.vrfConsumers[0]
carolContract := uni.consumerContracts[0]
Expand Down Expand Up @@ -1922,23 +1911,10 @@ func TestFulfillmentCost(t *testing.T) {
app := cltest.NewApplicationWithConfigV2AndKeyOnSimulatedBlockchain(t, cfg, uni.backend, key)
require.NoError(t, app.Start(testutils.Context(t)))

var vrfkey vrfkey.KeyV2
{
var err error
vrfkey, err = app.GetKeyStore().VRF().Create()
require.NoError(t, err)
p, err := vrfkey.PublicKey.Point()
require.NoError(t, err)
if uni.rootContract.Version() == vrfcommon.V2Plus {
_, err = uni.rootContract.RegisterProvingKey(
uni.neil, nil, pair(secp256k1.Coordinates(p)))
} else {
_, err = uni.rootContract.RegisterProvingKey(
uni.neil, &uni.nallory.From, pair(secp256k1.Coordinates(p)))
}
require.NoError(t, err)
uni.backend.Commit()
}
vrfkey, err := app.GetKeyStore().VRF().Create()
require.NoError(t, err)
registerProvingKey(t, uni.coordinatorV2UniverseCommon, vrfkey)

var (
nonProxiedConsumerGasEstimate uint64
proxiedConsumerGasEstimate uint64
Expand Down
1 change: 1 addition & 0 deletions integration-tests/smoke/vrfv2plus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,7 @@ func TestVRFv2Plus(t *testing.T) {
"Active subscription ids should not contain sub id after sub cancellation",
)
})

t.Run("Owner Withdraw", func(t *testing.T) {
testConfig := vrfv2PlusConfig
subIDsForWithdraw, err := vrfv2plus.CreateFundSubsAndAddConsumers(
Expand Down

0 comments on commit 279fec7

Please sign in to comment.