-
Notifications
You must be signed in to change notification settings - Fork 0
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
exec plugin: Introduce a State Machine #63
Conversation
68cd53d
to
c5fe15e
Compare
Can we have a diagram with the states and the state transitions? |
In this PR flowchart TD
UNKNOWN[Initial State]
A[Get Commit Reports]
B[Get Report Messages]
C[Filter]
UNKNOWN --> A
A -->|no report| B
B -->|report + restart| A
In the next PR flowchart TD
UNKNOWN[Initial State]
A[Get Commit Reports]
B[Get Report Messages]
C[Filter]
UNKNOWN --> A
A -->|no report| B
B -->|no report| C
C -->|report + restart| A
|
// TODO: go to Filter after GetMessages | ||
return GetCommitReports | ||
|
||
case Unknown: |
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.
// Unknown is the default value indicating there was no previous state.
If there was no previous state, should it start getting new messages? Are we going to start the plugin state with Unknown? If we expect to start with it, why fallthrough?
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.
Basically, I chose to do it this way so that an uninitialized previous outcome (i.e. the first round after startup) can transition to the "Next" state with no special handling. So you can get to the first state from Unknown
or Filter
(or GetMessages
in this PR, since I haven't implemented Filter
yet).
@winder you can include those mermaid diagrams in a README.md file, it should render natively on GitHub IIRC. |
execute/exectypes/outcome.go
Outdated
GetMessages | ||
Filter |
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.
First state is self explanatory but these might need some comments, especially Filter
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.
Or maybe call it FilterValidMessages
?
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.
Added comments 👍
execute/exectypes/outcome.go
Outdated
@@ -7,8 +7,40 @@ import ( | |||
cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccipocr3" | |||
) | |||
|
|||
type PluginState int |
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 wonder if it would be useful to have a MarshalJSON
on this so that the outcomes that are JSON encoded are still easily understandable (due to a human-readable string rather than a number). I think similar logic applies to the commit states
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.
Maybe. I would personally prefer if these had a more efficient encoding rather than attempting to make them human readable.
In this case the states would be 1->2->3, so still pretty human readable.
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 may be unlike others when it comes to this but even just 1, 2 and 3 is already a cognitive jump because I have to continuously remind myself what each number means.
Having debugged the v2 plugins quite a bit I'd rather we optimize for debuggability to start and then come back and make encoding tighter if needed.
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.
OK. Changed this type to a string.
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.
Also worth noting that we have states for commit as well, with their own integers, and states in many other systems which have their own integers, etc. Having all of this in mind I feel like the actual string encoding is just better and it doesn't really have that much overhead to outcome encoding size
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.
The phases could also be named "ReadDest", "ReadSource" and "ReadDestAgain"
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.
Less descriptive I feel, I kinda like the current names better, but not sure what other folks think. @asoliman92?
113dd42
to
64e931b
Compare
64e931b
to
6d13781
Compare
Test Coverage
|
}, | ||
{ | ||
name: "panic", | ||
p: PluginState("ElToroLoco"), |
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.
🤠
What
Introduce a state machine to manage execution across multiple rounds of OCR.
Why
To help manage complexity when a 3rd round of OCR is required.