rippled icon indicating copy to clipboard operation
rippled copied to clipboard

The ledger command does not include "delivered_amount" field in transaction metadata

Open carlhua opened this issue 4 years ago • 7 comments

Issue Description

The ledger RPC command has a different format for metadata than the tx RPC command. In the ledger command's response, metaData (not meta) is found. DeliveredAmount (not delivered_amount) is found. It is also missing validated field. This should be fixed to match tx command's response.

Steps to Reproduce

  1. Go to https://xrpl.org/websocket-api-tool.html#ledger

  2. Choose full history server and send the following request { "id": 1, "command": "ledger", "ledger_index": 36527098, "full": false, "expand": true, "transactions": true, "accounts": false }

  3. Search the output for BFC631D4C12229F6F2BD14203349100356DFB72F4FD4067B9C7A4EFAB9850770. Note you'll find "metaData" (not "meta"), that contains "DeliveredAmount" (not "delivered_amount") and no "validated" field.

  4. Go to https://xrpl.org/websocket-api-tool.html#tx

  5. Post { "id": 1, "command": "tx", "transaction": "BFC631D4C12229F6F2BD14203349100356DFB72F4FD4067B9C7A4EFAB9850770" }

  6. You'll find "meta", "delivered_amount" and "validated".

Expected Result

Actual Result

Environment

Supporting Files

sample outputs are included. ledger.txt tx.txt

Exported from RIPD-1599

carlhua avatar Jun 03 '20 13:06 carlhua

This is related: https://github.com/ripple/rippled/issues/2599

[Sorry for closing -- accidental click.]

intelliot avatar Jun 03 '20 15:06 intelliot

I looked into this. The "meta" vs "metaData" issue is because of here: https://github.com/ripple/rippled/blob/f43aeda49c5362dc83c66507cae2ec71cfa7bfdf/src/ripple/app/ledger/impl/LedgerToJson.cpp#L133 We even will use "meta" if you request binary data, but "metaData" otherwise. Definitely should fix that.

"validated" is not a field of each transaction, but applies to all of the returned data. Either all of the data is validated, or none is. If you scroll all the way to the bottom, you will find "validated" : true. So, this output is as expected, and is not a bug.

I did not see "DeliveredAmount" in the output. I only saw "delivered_amount". I traced the code as well and could not find how "DeliveredAmount" could possibly end up in the output. This is the code that populates the delivered amount field: https://github.com/ripple/rippled/blob/f43aeda49c5362dc83c66507cae2ec71cfa7bfdf/src/ripple/rpc/impl/DeliveredAmount.cpp#L154

cjcobb23 avatar Jun 03 '20 16:06 cjcobb23

I reran this with the exact request that you specified and was able to see "DeliveredAmount". I saw a "DeliveredAmount" field as well as a "delivered_amount" field. Previously I had tried with a different ledger, and there was only "delivered_amount".

cjcobb23 avatar Jun 03 '20 20:06 cjcobb23

DeliveredAmount is a raw data field that is included in the canonical metadata format (including in binary) and contributes to the hash of the ledger. We cannot remove or change it without an amendment.

delivered_amount is a synthetic field that is added by the API. It covers some cases that DeliveredAmount doesn't (e.g. cases with a fixed payment amount) so that you can always use delivered_amount instead of sometimes using the Amount from the payment. This is documented in the Transaction Metadata page.

Also, the meta vs. metaData thing is part of a much bigger problem thoroughly described in XRPLF/clio#722 as @intelliot mentioned above.

mDuo13 avatar Jun 09 '20 21:06 mDuo13

Hi I could try to fix it.

Neyromancer avatar Jun 19 '20 10:06 Neyromancer

Is this being worked by someone? I can also pick it.

giorgosHadji avatar Aug 09 '23 21:08 giorgosHadji

@giorgosHadji - I do not think anyone is working on this. You can pick it.

intelliot avatar Aug 15 '23 07:08 intelliot