+
Skip to content

Conversation

jakubzadroga
Copy link
Contributor

@jakubzadroga jakubzadroga commented Oct 14, 2025

Two separate problems were flagged by @Tagada14 :

  1. 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!
    Fix:
  • Default behaviour: Both installed CorDapps (from cordapps/ and legacy-contracts/) and database attachments are considered when a class is missing. Only JDK 17 class files from the database are attached. Legacy contracts only use installed CorDapps.
  • New system property: net.corda.node.attachments.missingAttachmentDbSearch
    Default: true → fallback to database allowed
    false → only installed CorDapps are considered; database attachments ignored
  1. 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.
    This has been fixed by improving the sorting mechanism when returning attachments - now attachments are additionally (apart from primary sorting by version descending) sorted by their IDs, which ensures deterministic order of returned attachments. For example, if we have two attachments with the same version, they'll be ordered alphabetically, not returned in random order as before.

Credits to @Tagada14 for finding the above bug and suggesting a good solution in #7994.

PR Checklist:

  • Have you run the unit, integration and smoke tests as described here?
  • If you added public APIs, did you write the JavaDocs/kdocs?
  • If the changes are of interest to application developers, have you added them to the changelog, and potentially the release notes (https://docs.r3.com/release-notes.html)?
  • If you are contributing for the first time, please read the contributor agreement now and add a comment to this pull request stating that your PR is in accordance with the Developer's Certificate of Origin.

Thanks for your code, it's appreciated! :)

@jakubzadroga jakubzadroga requested a review from rick-r3 as a code owner October 14, 2025 09:24
@jakubzadroga jakubzadroga marked this pull request as draft October 14, 2025 10:18
@jakubzadroga jakubzadroga marked this pull request as ready for review October 15, 2025 14:12
@Tagada14
Copy link

Please add back the test case that checks if multiple legacy cordapps contain the same class; the transaction will be built correctly. Your current implementation of course allows that, but this is an important behaviour from a backwards compatibility point of view. You should also include a test case that verifies your approach of sorting by first the version and then the ID, and make sure it works as expected.
I'm not sure why you chose to create your own PR rather than contributing to mine, but in this case you should clearly state where the original idea, and code comes from, and properly link the original PR.

@jakubzadroga jakubzadroga marked this pull request as draft October 16, 2025 09:32
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

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载