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

Refactor report builder interfaces. #430

Merged
merged 3 commits into from
Jan 10, 2025
Merged

Refactor report builder interfaces. #430

merged 3 commits into from
Jan 10, 2025

Conversation

winder
Copy link
Contributor

@winder winder commented Jan 9, 2025

This PR contains no functional changes, only refactoring to the execution report builder.

New functional options for report.NewBuilder which allow for more dynamic configuration without further modification to the function signature.

Break the message checking functions into multiple Check functions which can be added or removed based on requirements for a particular chain. This also allows more complex checks to be added without increasing the overall builder complexity, for example converting the nonce checking to the new scheme allowed me to remove two variables from the builder struct.

@winder winder force-pushed the will/builder-interfaces branch from 5c3ed89 to 4e01194 Compare January 9, 2025 17:12
@winder winder marked this pull request as ready for review January 9, 2025 17:35
@winder winder requested a review from a team as a code owner January 9, 2025 17:35
// temporary map to store state between nonce checks for this round.
expectedNonce := make(map[cciptypes.ChainSelector]map[string]uint64)
return func(lggr logger.Logger, msg cciptypes.Message, idx int, report exectypes.CommitData) (messageStatus, error) {
if msg.Header.Nonce != 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it a valid input to have a Zero nonce? We return None status if it's Zero

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, setting it to zero is how we allow out of order execution.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll add a comment here explaining that.

}

// Check expected nonce is valid for sequenced messages.
if msg.Header.Nonce != expectedNonce[report.SourceChain][sender] {
Copy link
Contributor

Choose a reason for hiding this comment

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

That assumes that messages will be sent to this function in order? Should this be a holding assumption always?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, if they're sent out of my order the expected nonce will be wrong.

asoliman92
asoliman92 previously approved these changes Jan 10, 2025
Copy link

Metric will/builder-interfaces main
Coverage 76.5% 76.5%

@winder winder requested a review from asoliman92 January 10, 2025 15:23
Copy link
Contributor

@asoliman92 asoliman92 left a comment

Choose a reason for hiding this comment

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

Looks great!

@winder winder merged commit 1eff813 into main Jan 10, 2025
17 checks passed
@winder winder deleted the will/builder-interfaces branch January 10, 2025 15:25
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.

2 participants