-
Notifications
You must be signed in to change notification settings - Fork 20
Fix BEEF validation issues and refactor validation logic (#211, #96) #212
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
Conversation
- Add transactions with merkle paths to valid set before validation - Use iterative validation for proper dependency ordering - Ensure deterministic validation results Fixes #211
Use 'go get' instead of 'go install' for adding the SDK as a dependency. The go-sdk is a library package, not an executable. Fixes #202
|
Hey, I just added a similar fix here: I did not see you've already pushed the fix, you beat me to it 😄 I'll close my PR as a duplicate. There's just one thing, I think that the Other than that, thanks for the fix! |
- Fix validation to check BUMPs properly - Rename SortTxs to ValidateTransactions - Verify bump indices for RawTxAndBumpIndex - Fix test assumptions
- Use chainhash.Hash directly as map keys for better performance - Add *ByHash method variants to avoid unnecessary conversions - Update collectAncestors to return hash slice - Fix all tests to work with new hash-based implementation
Co-authored-by: chris-4chain <152964795+chris-4chain@users.noreply.github.com>
Co-authored-by: chris-4chain <152964795+chris-4chain@users.noreply.github.com>
rohenaz
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Description
This PR fixes multiple BEEF-related issues:
SortTxsRoot Cause Analysis
Issue #211: The validation logic was not properly handling transaction validation order, causing non-deterministic results.
Issue #96: The SDK was being too strict during BEEF parsing, panicking when transactions didn't have merkle paths or source transactions. This is valid BEEF data that should be handled gracefully.
Validation Logic: The validation wasn't properly checking if transactions appear in BUMPs (have proof) for all DataFormat types.
Solutions
Fixed validation order by ensuring transactions with merkle paths are added to the valid set before validating dependent transactions
Removed panic during parsing - transactions without merkle paths or source transactions are now handled gracefully
Refactored validation logic:
SortTxs()toValidateTransactions()for clarityTxIDOnlyandRawTxformats by checking if they appear in BUMPsRawTxAndBumpIndexhas accurate bump indexValidationResultwith categorized transaction listsFixed test assumptions that incorrectly expected all input transactions to be present in BEEF
Performance optimization:
chainhash.Hashdirectly as map keys instead of string conversions*ByHashmethod variants to avoid unnecessary hash/string conversionscollectAncestorsto return[]chainhash.Hashinstead of[]stringAdditional Fixes
go getinstead ofgo install([BUG] install cmd on readme does not work, replace with go get #202)Testing
Changes
verifyValid()to use newValidateTransactions()methodValidateTransactions()method with comprehensive validation logicreadAllTransactions()for missing source transactionsSortTxstoValidateTransactionsTestBeefGetValidTxidsto handle transactions with merkle paths correctlychainhash.Hashfor better performanceFixes #211
Fixes #96
Fixes #202