Ensure that a CorDapp is present in cordapps directory when choosing an attachment for a missing class dependency #7994
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem description:
When building a transaction, the TransactionBuilder attempts to verify a transaction, and if it encounters a missing class dependency, it looks for it in the attachments and adds the attachment with the missing class to the transaction. However, it considers all of the attachments from the Attachment Storage rather than the CorDapps present in the node. This allows it to add an arbitrary trusted attachment that contains the missing class, even a legacy one! Moreover, it doesn't check if multiple attachments contain said class; it simply chooses the first one. Because of this, the attachment it chooses is runtime-dependent and non-deterministic. With the same set of attachments in the storage, one node may attach CorDapp A with the missing class and the other CorDapp B.
Implemented solution:
When fetching potential attachments which contain the missing class, we only consider the ones that are part of the cordapps folder in our node. We also check that only one such CorDapp is found to ensure deterministic behaviour.
For the legacy part of the transaction, we relax this requirement to maintain backwards compatibility, as existing CorDapps are already using this functionality.
PR Checklist:
https://docs.r3.com/release-notes.html
)?Thanks for your code, it's appreciated! :)