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

[CHIA-1562] validate block signature as part of run_block_generator() #745

Merged
merged 6 commits into from
Oct 9, 2024

Conversation

arvidn
Copy link
Contributor

@arvidn arvidn commented Oct 4, 2024

There is an opt-out for tests and maybe we'll need it in production too.

There are 3 main intentions:

  1. Allow releasing the GIL for longer periods at a time, by combining executing CLVM, parsing conditions and validating the signature
  2. Make the logic around validating signatures simpler, by always validating them when running a block (there's an opt-out for tests right now, and we may need it while transitioning).
  3. (in the future) avoid copying all the public keys and messages back into python.

In this first version, the BLSCache is not thread safe. This would likely be a problem since we use run_block_generator() from threads in python. It should probably contain a Mutex to serialize access to it.

The new flag DONT_VALIDATE_SIGNATURE can be passed in to skip the validation.
The new field validated_signature on SpendBundleConditions can be used to ensure it was in fact validated.

The main changes are in conditions.rs. The pkm_pairs are collected, as they are parsed, into a single list in the ParseState object. Here: https://github.com/Chia-Network/chia_rs/compare/run_block_validate_signature?expand=1#diff-c93029cf40a6e979ca6c9b02528cfc71cad2e7099818a2deeb92cb9cf5cf344bR788

At the end, these key-message pairs are validated against the signature in this new function validate_signature(): https://github.com/Chia-Network/chia_rs/compare/run_block_validate_signature?expand=1#diff-c93029cf40a6e979ca6c9b02528cfc71cad2e7099818a2deeb92cb9cf5cf344bR1502

@arvidn arvidn changed the title validate block signature as part of run_block_generator() [CHIA-1562] validate block signature as part of run_block_generator() Oct 4, 2024
@arvidn arvidn force-pushed the run_block_validate_signature branch 2 times, most recently from a8c6f33 to fe797f6 Compare October 4, 2024 17:03
Copy link

coveralls-official bot commented Oct 4, 2024

Pull Request Test Coverage Report for Build 11259684754

Details

  • 284 of 285 (99.65%) changed or added relevant lines in 8 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.3%) to 83.638%

Changes Missing Coverage Covered Lines Changed/Added Lines %
crates/chia-consensus/src/gen/conditions.rs 207 208 99.52%
Totals Coverage Status
Change from base Build 11238444984: 0.3%
Covered Lines: 12708
Relevant Lines: 15194

💛 - Coveralls

@arvidn arvidn requested review from Rigidity and matt-o-how and removed request for Rigidity October 4, 2024 18:50
@arvidn arvidn marked this pull request as ready for review October 4, 2024 18:50
@arvidn arvidn force-pushed the run_block_validate_signature branch 2 times, most recently from 100ccbe to f3dcac8 Compare October 8, 2024 14:43
@arvidn arvidn force-pushed the run_block_validate_signature branch from f3dcac8 to 759c6f0 Compare October 8, 2024 19:23
@arvidn
Copy link
Contributor Author

arvidn commented Oct 8, 2024

note that the meat of this patch is in conditions.rs, which github collapses by default in the diff view. Almost everything else are changes to tests to compensate.

matt-o-how
matt-o-how previously approved these changes Oct 9, 2024
Rigidity
Rigidity previously approved these changes Oct 9, 2024
crates/chia-consensus/src/gen/conditions.rs Outdated Show resolved Hide resolved
@arvidn arvidn dismissed stale reviews from Rigidity and matt-o-how via e6414dd October 9, 2024 17:04
@arvidn arvidn merged commit 24a9dee into main Oct 9, 2024
60 checks passed
@arvidn arvidn deleted the run_block_validate_signature branch October 9, 2024 20:45
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