-
Notifications
You must be signed in to change notification settings - Fork 0
SCP Gherkin Tests #10
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
base: main
Are you sure you want to change the base?
Conversation
GalRogozinski
left a comment
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.
Good job!
I like sequencer_2 better because it is more readable simply.
I think we can have maybe tags like: sequencer, publisher, contracts, or integration (we need to decide with Ayaz if we should have integration tests as spec tests)
gherkin/scp/sequencer_2.feature
Outdated
| Given there is a chain "1" with sequencer "A" | ||
| And there is a chain "2" with sequencer "B" | ||
|
|
||
| @start-instance |
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.
My thoughts were actually to divide the sequencer into files: start_instance.feature, timeout.feature, and etc.
Then we in the Feature section we have a place to document each feature.
So the tests become easy way to learn how each feature of the spec works.
gherkin/scp/sequencer_2.feature
Outdated
| Feature: Sequencer | ||
| Once the sequencer receives a StartInstance message it filters its own transactions, sets a timer, | ||
| and begins simulating with a mailbox tracer. It exchanges messages with peer sequencers and, | ||
| after the simulation completes, it votes and waits for a decision. |
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.
note it is also possible to put tags here
gherkin/scp/sequencer_2.feature
Outdated
| | returns success | true | | ||
| | returns an error other than "Read miss" | false | |
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.
nit: maybe the word "returns" is redundant
gherkin/scp/sequencer_2.feature
Outdated
| | returns success | true | | ||
| | returns an error other than "Read miss" | false | | ||
|
|
||
| @mailbox @simulation |
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.
you are mocking the simulation here, right?
So I disagree with this tag
GalRogozinski
left a comment
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, maybe we should use error codes?
Or maybe it is fine if we use meaningful constants but not enforce text
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.
Pull request overview
This PR introduces comprehensive Gherkin test specifications for the Shared Consensus Protocol (SCP), covering both sequencer and publisher behavior across multiple scenarios including instance lifecycle, voting, timeouts, simulations, and decision handling.
Key Changes:
- Added 7 Gherkin feature files documenting SCP protocol behavior
- Defined test scenarios for sequencer operations (start instance, timeout, simulation, decision)
- Defined test scenarios for publisher operations (start instance, votes, timeout)
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| gherkin/scp/sequencer/timeout.feature | Defines sequencer timeout behavior for voting and rejection scenarios |
| gherkin/scp/sequencer/start_instance.feature | Specifies sequencer instance initialization, transaction filtering, and timer startup |
| gherkin/scp/sequencer/simulation.feature | Covers transaction simulation outcomes, mailbox message handling, and read miss scenarios |
| gherkin/scp/sequencer/decision.feature | Documents instance finalization, decision processing, and invalid state handling |
| gherkin/scp/publisher/votes.feature | Specifies vote collection, validation, and consensus decision logic |
| gherkin/scp/publisher/timeout.feature | Defines publisher timeout behavior for instance rejection |
| gherkin/scp/publisher/start_instance.feature | Documents publisher instance initialization and StartInstance message broadcasting |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| | instance_id | 0x1 | | ||
| | chain_id | 1 | | ||
| | vote | true | | ||
| When sequencer "A" receives Decided for instance "0x1" with decision <decision> |
Copilot
AI
Dec 5, 2025
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 <decision> placeholder in the When clause is not properly formatted as a quoted value. Unlike other Scenario Outlines in these feature files, the decision value should be enclosed in quotes for consistency. Change to: When sequencer "A" receives Decided for instance "0x1" with decision "<decision>"
| When sequencer "A" receives Decided for instance "0x1" with decision <decision> | |
| When sequencer "A" receives Decided for instance "0x1" with decision "<decision>" |
GalRogozinski
left a comment
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.
Very nice!
I think maybe we should have happy-flow (or sanity) tags
|
|
||
| @publisher @scp @timeout | ||
| Scenario: Rejects instance when the timer expires before all votes are received | ||
| Given the shared publisher "SP" started an instance: |
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.
Should be same as above, unless you want this to be glued to different code?
| Given the shared publisher "SP" started an instance: | |
| Given the shared publisher "SP" starts an instance: |
|
|
||
| @publisher @scp @timeout | ||
| Scenario Outline: Ignores timer expiry after a decision has been published | ||
| Given the shared publisher "SP" started an instance: |
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.
| Given the shared publisher "SP" started an instance: | |
| Given the shared publisher "SP" starts an instance: |
| And there is a chain "1" with sequencer "A" | ||
| And there is a chain "2" with sequencer "B" | ||
|
|
||
| @publisher @scp @timeout |
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 redundant to have @timeout if you can just run a single feature file?
Maybe it isn't if you will have timeout tests outside the file
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.
You can argue that it adds clutter but adds convenience...
We can ask @ayaz-ssvlabs if he likes the @timeout for cli commands
| And there is a chain "2" with sequencer "B" | ||
|
|
||
| @publisher @scp @timeout | ||
| Scenario: Rejects instance when the timer expires before all votes are received |
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 also add "before any votes" scenario
| | instance_id | 0x3 | | ||
| | chain_id | 2 | | ||
| | vote | true | | ||
| Then the shared publisher "SP" should publish Decided with: |
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.
| Then the shared publisher "SP" should publish Decided with: | |
| Then the shared publisher "SP" publishes Decided with: |
You don't have to take this.
I just think it reads better in case the step will be also used as an AND step.
But only some humans might care
| Then sequencer "A" should publish Vote with: | ||
| | field | value | | ||
| | instance_id | 0x1 | | ||
| | chain_id | 1 | | ||
| | vote | <vote> | | ||
|
|
||
| Examples: | ||
| | result | vote | | ||
| | returns success | true | | ||
| | returns an error other than "Read miss" | false | |
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.
Good test
Maybe add in the end "AND no additional MailboxMessage should be forwarded"
| | source | 0xaaa | | ||
| | receiver | 0xbbb | | ||
| | session_id | 0x777 | | ||
| | label | TRANSFER | |
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.
do we have this label?
| 1: [tx1] | ||
| 2: [tx2] | ||
| """ | ||
| And sequencer "A" has already forwarded a mailbox message with: |
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.
This is less reusable...
consult with @ayaz-ssvlabs if he wants the clutter
| that belong to its own chain for simulation. | ||
| In case there are no transactions for its own chain, the sequencer should reject the instance immediately | ||
| as it shouldn't have received the message and this consists of an invalid protocol state. | ||
| After startup, the sequencer should immediately start simulating the transactions for the instance. |
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.
| After startup, the sequencer should immediately start simulating the transactions for the instance. | |
| After instance start, the sequencer should immediately start simulating the transactions for the instance. |
| | expected_state | storage_result | simulation_effect | | ||
| | has not stored | the message is appended to the pending mailbox queue for instance "0x1" | sequencer "A" should not start a new simulation | | ||
| | has already stored | the message is removed from the expected set and pending queue, then inserted into the inbox and a mailbox.putInbox transaction is added | sequencer "A" should start a new simulation | |
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.
format
Overview
This PR adds gherkin tests files for the SCP protocol.