Skip to content

Conversation

@abailly
Copy link
Contributor

@abailly abailly commented Oct 18, 2024

Description

This PR introduces generators, properties, and an executable to be able to QuickCheck Praos headers validation in a somewhat exhaustive and explicit way. Here is a brief summary:

  • Generators produce GeneratorContext with various keys and parameters used in the forging of headers, and valid Praos Header StandardCrypto from such a context
  • From a valid Header one can apply a Mutation that invalidates one particular rule for headers validation, using Generators too
  • Header and GeneratorContext have JSON serialisers, with keys and bytes being output as base64-encoded strings
  • the gen-header program can be used to generate a Sample of headers and context to be stored as part of a regression test suite, and to provide reference test vectors for other projects interested in validating headers

The JSON output looks like the following:

{
  "context": {
    "coldSignKey": "WCDQ24vfOrWlhgg65ZbHHxtyBt+QAGBoUx+IhgP1jYdHMg==",
    "kesSignKey": "WQJgmgx5dL86RoXLVEB18TH...=",
    "nonce": "ggFYII+ejLTnuete4jqw0uaCyPDzh1xOLhiTO/RSqyZ3v/wt",
    "praosSlotsPerKESPeriod": 9496,
    "vrfSignKey": "WEBzzMvKExinGbhtUaOcCMvRUw77NVnEfq85OV+MSvEb5m+NMN2tyMLgmaZNOhuAifLI3K/FQVZkEU8Rmb7A6EAj"
  },
  "headers": [
    {
      "header": "gooaAK6SORoAud8OWCA+ah5Aq6Nyw4uKwFeVWEMJ4Dw1tcOrDFFciVxibi06a...=",
      "mutation": "NoMutation"
    },
    {
      "header": "gooaAEIEphoA2MMuWCDqcIOxbDmAD0BU8mv3D7DauIjLAGG/o301UMqD5...=",
      "mutation": "MutateColdKey"
    },

TODO:

  • Don't restyle existing files (added by @nfrisby)
  • (deferred to other PR) Complete Mutation type to cover all kind of potential validation errors
  • Include more components in the GeneratorContext (eg. stake distribution, KES period...)
  • Add generate and validate commands to gen-header
  • Add documentation
  • Cover more Eras (?)

@nfrisby
Copy link
Contributor

nfrisby commented Oct 18, 2024

  • Cover more Eras (?)

So far, headers are very much specific to protocols more so than era. Byron (RealPBFT), Shelley (TPraos), and Babbage (proper Praos) were the only eras that altered the protocol.

@abailly
Copy link
Contributor Author

abailly commented Oct 19, 2024

Thanks a lot @nfrisby for taking the time to review this draft, it comforts me this can be useful and gives useful directions to improve it. The reason for this comment about eras is that the code pretty much pins down the block header's era to Conway which might or might not be desirable.

@abailly abailly force-pushed the abailly/generate-headers branch from 2249b54 to 2f64542 Compare October 25, 2024 09:56
ghost pushed a commit to abailly/ouroboros-consensus that referenced this pull request Oct 25, 2024
@ghost ghost force-pushed the abailly/generate-headers branch 2 times, most recently from fbfdb6e to 6bcbaab Compare October 28, 2024 17:44
@abailly abailly force-pushed the abailly/generate-headers branch from 6bcbaab to eff65bf Compare October 28, 2024 21:26
@abailly abailly marked this pull request as ready for review October 29, 2024 07:44
@abailly
Copy link
Contributor Author

abailly commented Oct 29, 2024

Took me a while to have CI passing and fix some issues in the generators' logic but I think it's now ready for a proper review.
While the mutations do not cover all the validation logic, I think it's better to have a first partial version, and complete it in a later PR.

@abailly abailly requested review from amesgen and nfrisby October 29, 2024 07:45
@abailly abailly force-pushed the abailly/generate-headers branch from 59cc1a4 to 4a37b00 Compare November 4, 2024 13:08
@abailly
Copy link
Contributor Author

abailly commented Nov 8, 2024

Any plans to merge this? It's CI green and I think I have addressed all reviewer's comments

@abailly abailly force-pushed the abailly/generate-headers branch from 4a37b00 to fce0ef5 Compare November 12, 2024 10:18
@abailly
Copy link
Contributor Author

abailly commented Nov 12, 2024

@jasagredo I have removed changelog entry, but how do I prevent the CI from failing?

@jasagredo
Copy link
Contributor

I mentioned it in the suggestion above. I have set the no changelog label now. Next time you push it will pass.

@abailly
Copy link
Contributor Author

abailly commented Nov 12, 2024

I mentioned it in the suggestion above. I have set the no changelog label now. Next time you push it will pass.

I understand, point is: I cannot do this. I would suggest finding another way, perhaps looking at commit messages, otherwise this will annoy external contributors.

@jasagredo
Copy link
Contributor

Ah I didn't realize you couldn't do it. Indeed that is annoying for contributors hmmm. We will try to come up with a better solution.

Copy link
Contributor

@jasagredo jasagredo left a comment

Choose a reason for hiding this comment

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

Just some minor comments.

Also yesterday we discussed it in our meeting and you can actually just push an empty changelog fragment in your PR to go around the CI check. I think it makes sense as that says "I am declaring that this PR has no relevant changes worth to be included in the changelog".

@abailly abailly requested a review from jasagredo November 14, 2024 10:02
Copy link
Contributor

@jasagredo jasagredo left a comment

Choose a reason for hiding this comment

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

You are required to sign your commits before I the PR can be merged.

@jasagredo
Copy link
Contributor

The error in CI is a flaky tests that has not been flaky for a very long time and we are recently seeing more instances of it. Let's pray that the signed force-push makes it go away...

@abailly
Copy link
Contributor Author

abailly commented Nov 14, 2024

Ok, I will sign the commits

abailly and others added 11 commits November 14, 2024 12:22
* Provide base generator and mutations for headers, covering some
parts related to KES header signature
* Extract testable method from Protocol.Praos module
* Add a property testing the consistency of validation logic with both valid
and mutated headers
* Add a command-line tool to generate JSON-formatted test vectors and
validate them
some mutations are not possible for some content of the header, eg. if
ocertN = 0 then it's not possible to generate a smaller expected value
also remove hardcoded maxKESEvo parameter from test run
* remove changelog entry
* add explicit export list
* use generic JSON derivation
@abailly abailly force-pushed the abailly/generate-headers branch from 0cd6683 to 0653bac Compare November 14, 2024 11:22
@jasagredo jasagredo added this pull request to the merge queue Nov 14, 2024
Merged via the queue into IntersectMBO:main with commit 254ed5e Nov 14, 2024
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants