Skip to content
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

Merged
merged 22 commits into from
May 7, 2024

Conversation

iljapavlovs
Copy link
Collaborator

No description provided.

Comment on lines 114 to 127
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)
}
Copy link
Contributor

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)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch, thanks!

@cl-sonarqube-production
Copy link

@iljapavlovs iljapavlovs requested review from jinhoonbang and removed request for a team May 7, 2024 14:20

//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
Copy link
Contributor

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)
Copy link
Contributor

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)
Copy link
Contributor

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))
Copy link
Contributor

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))
Copy link
Contributor

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)
Copy link
Contributor

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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add error message?

Copy link
Collaborator Author

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))
Copy link
Contributor

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")
}
}
}
Copy link
Contributor

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
Copy link
Contributor

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) {
Copy link
Contributor

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

Copy link
Contributor

@Tofel Tofel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

conditional ;-)

@iljapavlovs iljapavlovs added this pull request to the merge queue May 7, 2024
Merged via the queue into develop with commit b0b4354 May 7, 2024
107 checks passed
@iljapavlovs iljapavlovs deleted the chore/VRF-330-batchfulfilment-enabled branch May 7, 2024 14:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants