Skip to content

Conversation

@MatheusFranco99
Copy link
Contributor

Overview

This PR adds gherkin tests files for the SCP protocol.

Copy link
Contributor

@GalRogozinski GalRogozinski left a 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)

Given there is a chain "1" with sequencer "A"
And there is a chain "2" with sequencer "B"

@start-instance
Copy link
Contributor

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.

Comment on lines 1 to 4
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.
Copy link
Contributor

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

Comment on lines 60 to 61
| returns success | true |
| returns an error other than "Read miss" | false |
Copy link
Contributor

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

| returns success | true |
| returns an error other than "Read miss" | false |

@mailbox @simulation
Copy link
Contributor

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

Copy link
Contributor

@GalRogozinski GalRogozinski left a 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

@MatheusFranco99 MatheusFranco99 marked this pull request as ready for review December 5, 2025 16:43
Copilot AI review requested due to automatic review settings December 5, 2025 16:43
Copy link
Contributor

Copilot AI left a 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>
Copy link

Copilot AI Dec 5, 2025

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>"

Suggested change
When sequencer "A" receives Decided for instance "0x1" with decision <decision>
When sequencer "A" receives Decided for instance "0x1" with decision "<decision>"

Copilot uses AI. Check for mistakes.
Copy link
Contributor

@GalRogozinski GalRogozinski left a 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:
Copy link
Contributor

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?

Suggested change
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:
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
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
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 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

Copy link
Contributor

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
Copy link
Contributor

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:
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
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

Comment on lines +30 to +39
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 |
Copy link
Contributor

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 |
Copy link
Contributor

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:
Copy link
Contributor

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.
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
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.

Comment on lines +149 to +151
| 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 |
Copy link
Contributor

Choose a reason for hiding this comment

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

format

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.

3 participants