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

Provide partial test suite for header validation #3

Merged

Conversation

abailly
Copy link
Contributor

@abailly abailly commented Oct 24, 2024

This PR builds upon @AndrewWestberg's work on Praos headers validation, adding more tests in the form of JSON-formatted pairs of a context and a header, which may or may not be valid. A single test function loads the test vectors and iterates through the various headers, calling validation code and verifying the result. These tests increase code coverage from ~75% to ~95%.

In the course of writing these tests, I found a few minor issues I fixed in the validation code:

  • Adding a special case for when the header's producer has 100% of the stake (which lead me to report this issue), which obviously is not a real case but is nevertheless accounted for in Haskell code and useful
  • Using pool id instead of raw bytes as key to operational certificate counters' the consensus code maintains
  • Expose active slot coefficient from ledger instead of derived c value (ran the benchmarks locally and did not notice any significant impact), because of first point above
  • Switch position for tests on operational counters as otherwise it could lead to runtime panic from underflow
  • A couple more expressive error messages

There's more work that needs to be done to cover more of the validation process, which I plan to add in another PR:

  • Vary stake distributions
  • Cover VRF proof related checks

@abailly
Copy link
Contributor Author

abailly commented Oct 24, 2024

Consensus code PR: IntersectMBO/ouroboros-consensus#1285

@AndrewWestberg
Copy link
Contributor

Rebase on top of main since I merged my previous PR. It should be a minimal ff rebase for you.

Copy link
Contributor

@AndrewWestberg AndrewWestberg left a comment

Choose a reason for hiding this comment

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

Should be good to merge after rebasing. This is a good base to add additional tests for opcert mutations, etc on top of.

@abailly abailly force-pushed the abailly/test-header-validation branch from c3991fe to c219853 Compare October 28, 2024 07:29
Copy link
Contributor

@AndrewWestberg AndrewWestberg left a comment

Choose a reason for hiding this comment

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

Ensure we are using conventional commit messages.

https://www.conventionalcommits.org/en/v1.0.0/#summary

* add JSON-formatted test vectors file, to be expanded to cover
  more edge cases as needed
* add integration tests to check validation logic against those
  test cases
* fix some minor issues in validation code following introduction
  of those tests
@abailly
Copy link
Contributor Author

abailly commented Nov 8, 2024

@AndrewWestberg Can we merge this? It's been a while...

@AndrewWestberg AndrewWestberg merged commit 39bb96b into pragma-org:main Nov 12, 2024
@abailly abailly deleted the abailly/test-header-validation branch November 25, 2024 10:06
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.

2 participants