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

Collection Malleability #7114

Open
wants to merge 14 commits into
base: feature/malleability
Choose a base branch
from

Conversation

jordanschalm
Copy link
Member

@jordanschalm jordanschalm commented Mar 4, 2025

This PR cleans up Fingerprint definitions for TransactionBody, Collection, and cluster.Payload. It also adds tests demonstrating non-malleability of Collection.

Fingerprint

This PR removes the Fingerprint method from TransactionBody, Collection, and cluster.Payload, in favour of defining an EncodeRLP method for TransactionBody. In contrast with Fingerprint, the EncodeRLP method is used for encoding the transaction even when it appears in nested structures. This way, we don't need to implement Fingerprint for every data structure that includes a TransactionBody somewhere.

  • removed Fingerprint methods except for TransactionBody, which now delegates to EncodeRLP, since it is more likely to be used externally and was a public function

Other Changes

  • move CollectionFromTransactions to unittest package as it is only used in tests
  • remove Collection.Guarantee() method, as it is only used in tests and constitutes an anti-pattern of creating a partially constructed object.
  • remove CollectionList, which was unused

Ref: #6721

@codecov-commenter
Copy link

codecov-commenter commented Mar 4, 2025

Codecov Report

Attention: Patch coverage is 26.31579% with 14 lines in your changes missing coverage. Please review.

Project coverage is 41.23%. Comparing base (8a4dfe0) to head (602f6b0).

Files with missing lines Patch % Lines
utils/unittest/cluster.go 0.00% 6 Missing ⚠️
model/flow/collection.go 0.00% 5 Missing ⚠️
utils/unittest/fixtures.go 0.00% 3 Missing ⚠️
Additional details and impacted files
@@                  Coverage Diff                  @@
##           feature/malleability    #7114   +/-   ##
=====================================================
  Coverage                 41.23%   41.23%           
=====================================================
  Files                      2168     2168           
  Lines                    190257   190216   -41     
=====================================================
- Hits                      78448    78432   -16     
+ Misses                   105228   105206   -22     
+ Partials                   6581     6578    -3     
Flag Coverage Δ
unittests 41.23% <26.31%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

jordanschalm and others added 8 commits March 20, 2025 14:23
This is only used in tests. It represents an anti-pattern for non-test
code, as it creates a partially constructed entity (missing signatures
etc.). Replaced with direct struct instantiation for test use cases
used in too many places to deal with here, but can be removed toward end
of malleability workstream
@jordanschalm jordanschalm marked this pull request as ready for review March 21, 2025 00:07
@jordanschalm jordanschalm requested a review from a team as a code owner March 21, 2025 00:07
Copy link
Member

@durkmurder durkmurder left a comment

Choose a reason for hiding this comment

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

Looks great, thanks for documentation updates

// Fingerprint returns the canonical, unique byte representation for the TransactionBody.
// As RLP encoding logic for TransactionBody is over-ridden by EncodeRLP below, this is
// equivalent to directly RLP encoding the TransactionBody.
// This public function is retained primarily for backward compatibility.
Copy link
Member

Choose a reason for hiding this comment

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

I am a bit confused about backward compatibility aspect. I don't see it being used, maybe we can just remove it?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm thinking of third-parties using flow-go as a dependency - this seemed like a function fairly likely to be used in that context and I wanted to avoid breaking changes. Just a hunch though, and they should be using flow-go-sdk...

Copy link
Contributor

@UlyanaAndrukhiv UlyanaAndrukhiv left a comment

Choose a reason for hiding this comment

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

Looks good to me!

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.

4 participants