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

Implement the peer simulator for Genesis tests #434

Merged
merged 15 commits into from
Dec 5, 2023

Conversation

facundominguez
Copy link
Contributor

@facundominguez facundominguez commented Oct 12, 2023

This PR introduces an initial implementation of a Peer Simulator for Genesis tests.

A simulated peer is told how to behave by a list of scheduled events that is generated for every test. In essence, it is an implementation of a ChainSync server and a BlockFetch server that behave as prescribed by the schedule.

The rest of the PR provides support infrastructure in the form of:

  • a Praos client node that plays the role of subject under test,
  • an example test for long range attacks, and
  • minimal definitions to generate a schedule from the chain schemas introduced in consensus-testlib: add chain generators #240.

This is a squash of the many commits in the integration branch of #367.

@facundominguez facundominguez added the Genesis PRs related to Genesis testing and implementation label Oct 12, 2023
@facundominguez facundominguez marked this pull request as ready for review October 13, 2023 17:38
@facundominguez facundominguez requested a review from a team as a code owner October 13, 2023 17:38
Copy link
Member

@dnadales dnadales left a comment

Choose a reason for hiding this comment

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

Thanks. Some overall comments:

  • Do we want to address all the comments marked as REVIEW in this PR?
  • Do we want to address all the comments marked as FIXME in this PR?
  • We need to make sure no record wildcards are used.
  • It'd be great if we could use the same formatting style as the rest of the codebase. Also, at the moment the coding styles within this PR are mixed, eg leading vs trailing commas.

traceWith tracer "Schedule is:"
for_ ps $ \tick -> traceWith tracer $ " " ++ condense tick
traceWith tracer "--------------------------------------------------------------------------------"
traceWith tracer "» Time says “Let there be”"
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps we should replace this with something that describes what these messages are delimiting.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Niols do you have any preferences of text to use here? "Running point schedule ..."?

traceWith tracer "--------------------------------------------------------------------------------"
for_ ps (dispatchTick tracer peers)
traceWith tracer "--------------------------------------------------------------------------------"
traceWith tracer "» A Clock stopped -"
Copy link
Member

Choose a reason for hiding this comment

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

Same here.

@@ -0,0 +1,16 @@
module Test.QuickCheck.Extras (
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps these functions could be upstreamed to QC eventually ...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed.

Copy link
Contributor Author

@facundominguez facundominguez left a comment

Choose a reason for hiding this comment

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

Do we want to address all the comments marked as REVIEW in this PR?

At this point, the REVIEW comments are notes for the Genesis team. Should we use a different tag for these?

Do we want to address all the comments marked as FIXME in this PR?

Likely the same as the previous item, but I'll ask.

We need to make sure no record wildcards are used.
It'd be great if we could use the same formatting style as the rest of the codebase.

Yes, I think at least I should be paying some more attention to the style guide than I've been doing so far.

@@ -0,0 +1,16 @@
module Test.QuickCheck.Extras (
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed.

Comment on lines 74 to 84
blockFetchCfg = BlockFetchConfiguration
{ bfcMaxConcurrencyBulkSync = 2
, bfcMaxConcurrencyDeadline = 2
, bfcMaxRequestsInflight = 4
, bfcDecisionLoopInterval = 0
, bfcSalt = 0
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The threadnet tests use hardcoded values as well.

One option would be to factor the hardcoded configuration and use it in both places.

Another alternative would be to make blockFetchCfg a function argument, and generate it with some randomness for all fields except bfcDecisionLoopInterval which could interfere with the scheduling during tests and should remain set to 0.

Please, let us know if you have any preferences.

facundominguez added a commit that referenced this pull request Dec 1, 2023
facundominguez added a commit that referenced this pull request Dec 4, 2023
@facundominguez
Copy link
Contributor Author

I brought almost all of the changes in response to comments to this PR. The only exception is the documentation of point schedules which I left in #501. Also merged the latest changes from main and signed all the commits.

If there are no more requests, this is good to merge.

@facundominguez facundominguez added this pull request to the merge queue Dec 5, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to no response for status checks Dec 5, 2023
@facundominguez facundominguez added this pull request to the merge queue Dec 5, 2023
Merged via the queue into main with commit d866659 Dec 5, 2023
12 checks passed
@facundominguez facundominguez deleted the fd/peer-simulator branch December 5, 2023 18:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Genesis PRs related to Genesis testing and implementation no changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants