-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
VRF-330: enabling batch fulfillment for VRF e2e tests #13091
Conversation
if topic.Cmp(vrf_coordinator_v2_5.VRFCoordinatorV25RandomWordsFulfilled{}.Topic()) == 0 { | ||
randomWordsFulfilledEvent, err := coordinator.ParseRandomWordsFulfilled(*eventLog) | ||
if err != nil { | ||
return nil, fmt.Errorf("parse RandomWordsFulfilled log failed, err: %w", err) | ||
} | ||
randomWordsFulfilledEventArr = append(randomWordsFulfilledEventArr, randomWordsFulfilledEvent) | ||
} | ||
if topic.Cmp(vrf_coordinator_v2.VRFCoordinatorV2RandomWordsFulfilled{}.Topic()) == 0 { | ||
randomWordsFulfilledEvent, err := coordinator.ParseRandomWordsFulfilled(*eventLog) | ||
if err != nil { | ||
return nil, fmt.Errorf("parse RandomWordsFulfilled log failed, err: %w", err) | ||
} | ||
randomWordsFulfilledEventArr = append(randomWordsFulfilledEventArr, randomWordsFulfilledEvent) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That looks like the same code to me. Perpahs just checking if the topic comes from V2 or V25 and if that's not the case, throw an error? So something like this:
if topic.Cmp(vrf_coordinator_v2_5.VRFCoordinatorV25RandomWordsFulfilled{}.Topic()) != 0 && topic.Cmp(vrf_coordinator_v2.VRFCoordinatorV2RandomWordsFulfilled{}.Topic()) != 0 {
// return an error
}
// topic is detected, the processing is the same for both coordinator versions
randomWordsFulfilledEvent, err := coordinator.ParseRandomWordsFulfilled(*eventLog)
if err != nil {
return nil, fmt.Errorf("parse RandomWordsFulfilled log failed, err: %w", err)
}
randomWordsFulfilledEventArr = append(randomWordsFulfilledEventArr, randomWordsFulfilledEvent)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch, thanks!
|
|
||
//batchMaxGas := config.MaxGasLimit() (2.5 mill) + 400_000 = 2.9 mill | ||
//callback gas limit set by consumer = 500k | ||
// so 4 requests should be fulfilled inside 1 tx since 500k*4 < 2.9 mill |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove?
|
||
//ensure that no job present on the node | ||
err = actions.DeleteJobs([]*client.ChainlinkClient{vrfNode.CLNode.API}) | ||
require.NoError(t, err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add error message?
Msg("Request/Fulfilment Stats") | ||
|
||
clNodeTxs, resp, err := nodeTypeToNodeMap[vrfcommon.VRF].CLNode.API.ReadTransactions() | ||
require.NoError(t, err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add error message?
} | ||
} | ||
// verify that all fulfillments should be inside one tx | ||
require.Equal(t, 1, len(batchFulfillmentTxs)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add error message?
require.NoError(t, err) | ||
|
||
// verify that all fulfillments should be inside one tx | ||
require.Equal(t, int(randRequestCount), len(randomWordsFulfilledLogs)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add error message to the three above?
randRequestCount := expectedNumberOfFulfillmentsInsideOneBatchFulfillment | ||
|
||
t.Run("Batch Fulfillment Enabled", func(t *testing.T) { | ||
configCopy := config.MustCopy().(tc.TestConfig) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't want to run them in parallel?
require.True(t, exists, "VRF Node does not exist") | ||
//ensure that no job present on the node | ||
err = actions.DeleteJobs([]*client.ChainlinkClient{vrfNode.CLNode.API}) | ||
require.NoError(t, err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add error message?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reluctantly adding those, but I dont think those add much value
} | ||
} | ||
// verify that all fulfillments should be in separate txs | ||
require.Equal(t, int(randRequestCount), len(singleFulfillmentTxs)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add error message to requires above? 😅
l.Error().Err(err).Msg("Error cleaning up test environment") | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can't we define that as a function? you could have higher order function that returns this function as well, if needed. I see it's identical to the previous tests, why copy & paste?
|
||
//batchMaxGas := config.MaxGasLimit() (2.5 mill) + 400_000 = 2.9 mill | ||
//callback gas limit set by consumer = 500k | ||
// so 4 requests should be fulfilled inside 1 tx since 500k*4 < 2.9 mill |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove?
@@ -2083,3 +2080,287 @@ func TestVRFv2PlusNodeReorg(t *testing.T) { | |||
}) | |||
|
|||
} | |||
|
|||
func TestVRFv2PlusBatchFulfillmentEnabledDisabled(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well, tbh I would extract common logic to one function and then just pass as arguments vrfv2 and vrfv2plus specific parts so we don't have almost identical test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
conditional ;-)
No description provided.