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

Implement cert verifier address provider #1368

Merged
merged 16 commits into from
Mar 7, 2025
Merged

Conversation

litt3
Copy link
Contributor

@litt3 litt3 commented Mar 6, 2025

Closes EGDA-979

Why are these changes needed?

  • As described in this issue, a single cert verifier address isn't enough for payload dispersal: the active address may change after the disperser chooses an RBN, once dynamic cert verifier changes are possible
  • To future proof the client APIs for when dynamic cert verifier addresses are supported, this PR makes necessary API changes, so that a CertVerifierAddressProvider is used throughout the clients, instead of manually passing in an address for each call
    • This change represents a nice simplification of the APIs, in addition to the benefit of supporting future efforts
  • This PR also does a lot of work organizing code into packages. These changes were necessary, so that the new structures could be put into reasonable packages without introducing circular dependencies. IMO the changes in this PR represent a substantial improvement to the package structure of the clients.

Checks

  • I've made sure the tests are passing. Note that there might be a few flaky tests, in that case, please comment that they are not relevant.
  • I've checked the new test coverage and the coverage percentage didn't drop.
  • Testing Strategy
    • Unit tests
    • Integration tests
    • This PR is not tested :(

@litt3 litt3 self-assigned this Mar 6, 2025
@litt3 litt3 marked this pull request as ready for review March 6, 2025 17:28
@litt3 litt3 requested review from anupsv, samlaf and cody-littley March 6, 2025 17:28
blob, err := payload.ToBlob(pd.config.PayloadPolynomialForm)
if err != nil {
return nil, fmt.Errorf("convert payload to blob: %w", err)
}

timeoutCtx, cancel := context.WithTimeout(ctx, pd.config.ContractCallTimeout)
defer cancel()
requiredQuorums, err := pd.requiredQuorumsStore.GetQuorumNumbersRequired(timeoutCtx, certVerifierAddress)
requiredQuorums, err := pd.certVerifier.GetQuorumNumbersRequired(timeoutCtx)
Copy link
Contributor

Choose a reason for hiding this comment

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

This utilizes the cache righT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Correct. The cache is now internal to the cert verifier, rather than being managed by the payload disperser.

// This method is synchronized in a way that, if called by multiple goroutines, only a single goroutine will actually
// poll the internal eth client for the most recent block number. The goroutine responsible for polling at a given time
// updates an atomic integer, so that all goroutines may check the most recent block without duplicating work.
func (bnp *BlockNumberProvider) MaybeWaitForBlockNumber(ctx context.Context, targetBlockNumber uint64) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

The maybe is quite confusing until i went through the logic twice. Idk if we can rename it or soemthing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Renamed to WaitForBlockNumber ceee94b9

Copy link
Contributor

@samlaf samlaf left a comment

Choose a reason for hiding this comment

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

Looks like very nice cleanup. Have a bunch of nits but honestly would be happy merging in this state.

Comment on lines +40 to +46
// checkAndSetCertVerifierAddress checks whether the input address string is empty, and skips the test if it is
//
// If the input address is not empty, this method configures the test client to use the input address as the cert
// verifier address.
func checkAndSetCertVerifierAddress(t *testing.T, c *client.TestClient, certVerifierAddress string) {
if certVerifierAddress == "" {
t.Skip("Requested cert verifier address is not configured")
Copy link
Contributor

Choose a reason for hiding this comment

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

first time I see this kind of pattern of skipping a test inside some function. Is this something you've used before? Curious if there would be another way to skip the test earlier and inside the test itself.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is this something you've used before?

Nope, I just did this since there were two things that needed to happen, each time a test handles a cert verifier address. Don't feel too strongly about it, would you prefer doing each of things manually on a per-test basis?

Copy link
Contributor

Choose a reason for hiding this comment

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

As we've discussed before, I'm just scared of dynamic stuff. Can this skip be done midway through the test after some processing has been done? Or is it purely a construct used at the beginning of tests? If the latter then fine with me.

Copy link
Contributor

Choose a reason for hiding this comment

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

we talked offline. Would prefer in the future that we don't have this kind of dynamic skipping of tests. But let's move on for now, more tests is always better than no tests!

@litt3 litt3 requested review from cody-littley, samlaf and anupsv March 7, 2025 15:19
type BlockNumberProvider struct {
// BlockNumberMonitor is a utility for waiting for a certain ethereum block number
//
// TODO: this utility is not currently in use, but DO NOT delete it. It will be necessary for the upcoming
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// TODO: this utility is not currently in use, but DO NOT delete it. It will be necessary for the upcoming
// TODO(litt): this utility is not currently in use, but DO NOT delete it. It will be necessary for the upcoming

Copy link
Contributor

Choose a reason for hiding this comment

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

which litt? ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Litt specified, and disambiguated

litt3 added 2 commits March 7, 2025 10:58
Signed-off-by: litt3 <[email protected]>
Signed-off-by: litt3 <[email protected]>
@litt3 litt3 merged commit 8f43a4a into master Mar 7, 2025
10 of 12 checks passed
@litt3 litt3 deleted the cert-verifier-address-provider branch March 7, 2025 17:24
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.

4 participants