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

Add a less strict solution representation #674

Merged
merged 2 commits into from
Aug 30, 2024
Merged

Add a less strict solution representation #674

merged 2 commits into from
Aug 30, 2024

Conversation

Rigidity
Copy link
Contributor

@Rigidity Rigidity commented Aug 21, 2024

Rationale

When parsing CLVM solutions currently, the nil terminator is strict since they are represented as a normal list. This is fine if the solution is structured correctly, but as seen in Chia-Network/chia-blockchain#18500, this is not always the case. I had an NFT which failed to parse due to this mistake of including the coin amount in the NFT state layer solution.

How does this fix the issue

Instead of requiring the solution's terminator (which here refers to the last CLVM pair's "rest" value after extracting all of the required values in the list) to be nil, it can be any value and is not checked. This is achieved by adding a new representation solution which is identical to list except with this extra bit of flexibility. When serialized, it still includes the nil terminator as it should.

Side effects

The SingletonSolution type is used in the fast-forward feature, so it's a consideration whether allowing this flexibility makes sense for that mempool logic. If not, a separate StrictSingletonSolution could be created with the representation list, for use cases like that. It's not clear to me whether this is important though.

@Rigidity Rigidity requested a review from arvidn August 21, 2024 02:37
@Rigidity Rigidity marked this pull request as ready for review August 21, 2024 02:37
Copy link

Pull Request Test Coverage Report for Build 10482486683

Details

  • 51 of 52 (98.08%) changed or added relevant lines in 4 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.04%) to 83.925%

Changes Missing Coverage Covered Lines Changed/Added Lines %
crates/clvm-derive/src/parser/attributes.rs 2 3 66.67%
Totals Coverage Status
Change from base Build 10422144649: 0.04%
Covered Lines: 12347
Relevant Lines: 14712

💛 - Coveralls

@arvidn arvidn merged commit a24aebc into main Aug 30, 2024
59 checks passed
@arvidn arvidn deleted the solution-repr branch August 30, 2024 14:42
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