-
Notifications
You must be signed in to change notification settings - Fork 5
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
Conversation
5c3ed89
to
4e01194
Compare
execute/report/report.go
Outdated
// 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 { |
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.
Is it a valid input to have a Zero nonce? We return None status if it's Zero
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.
Yes, setting it to zero is how we allow out of order execution.
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.
I'll add a comment here explaining that.
execute/report/report.go
Outdated
} | ||
|
||
// Check expected nonce is valid for sequenced messages. | ||
if msg.Header.Nonce != expectedNonce[report.SourceChain][sender] { |
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 assumes that messages will be sent to this function in order? Should this be a holding assumption always?
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.
Yes, if they're sent out of my order the expected nonce will be wrong.
4e01194
to
b724aaa
Compare
|
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.
Looks great!
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.