Skip to content

fix(network): drop the [2,…] message tag wrapper from the rejection reason#548

Merged
scarmuega merged 1 commit into
txpipe:mainfrom
michalrus:fix-tx-reject
Feb 7, 2025
Merged

fix(network): drop the [2,…] message tag wrapper from the rejection reason#548
scarmuega merged 1 commit into
txpipe:mainfrom
michalrus:fix-tx-reject

Conversation

@michalrus
Copy link
Copy Markdown
Contributor

The bug

Currently, the rejection reason is always prefixed with 8202, because the entire d.input() is copied there. And d.input() always contains the whole input.

An (incorrect) example of a FeeTooSmallUTxO error:

82                                      # array(2)
   02                                   # unsigned(2)
   81                                   # array(1)
      82                                # array(2)
         06                             # unsigned(6)
         82                             # array(2)
            82                          # array(2)
               01                       # unsigned(1)
               82                       # array(2)
                  00                    # unsigned(0)
                  83                    # array(3)
                     06                 # unsigned(6)
                     1B 000000025050D4DD # unsigned(9937409245)
                     1A 003D0E39        # unsigned(4001337)
            82                          # array(2)
               01                       # unsigned(1)
               82                       # array(2)
                  00                    # unsigned(0)
                  83                    # array(3)
                     05                 # unsigned(5)
                     1A 0002851D        # unsigned(165149)
                     19 0539            # unsigned(1337)

This is not correct, because the first 2 bytes representing [2, …] are just a tag for Message::RejectTx, which we already give to the user, so the information is currently encoded twice.

The above example should have started on line 3 (3rd byte).

The fix

We need to:

  • offset d.input() in RejectReason by the current d.position(),

  • I've also moved d.set_position(_) – it's the cleanest to have it in the decoder for RejectReason, so that it behaves like other well-formed decoders, i.e. increments the current .pos.

@scarmuega scarmuega merged commit adab71f into txpipe:main Feb 7, 2025
@michalrus michalrus deleted the fix-tx-reject branch February 7, 2025 12:15
@michalrus
Copy link
Copy Markdown
Contributor Author

Thanks for the merge!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

No open projects
Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

3 participants