XRPLF / rippled

Decentralized cryptocurrency blockchain daemon implementing the XRP Ledger protocol in C++
https://xrpl.org
ISC License
4.54k stars 1.47k forks source link

Update oracle issue: Updating just one PriceDataSeries leads to deleting all other entries in the PriceDataSeries but only deletes them halfway #4919

Open manojsdoshi opened 9 months ago

manojsdoshi commented 9 months ago

Create Oracle request:

    "method" :  "submit",
    "params": [
        {
        "tx_json": {
    "Account" : "rMbZT8cR4PY4swdWTNNQyQ1bmE3sefyYbb",  
    "AssetClass" : "63757272656E6379",
    //"AssetClass" : "GH",
    "Fee" : "10",
    "LastUpdateTime" : "{{current_timestamp}}",
    "OracleDocumentID" : 100,
    "PriceDataSeries" : [
       {
          "PriceData" : {
             "AssetPrice" : 742,
             "BaseAsset" : "XRP",
             "QuoteAsset" : "USD",
             "Scale" : 1
          }
       },
       {
            "PriceData" : {
             "AssetPrice" : 740,
             "BaseAsset" : "BTC",
             "QuoteAsset" : "USD",
             "Scale" : 1
          }
       },
           {
            "PriceData" : {
             "AssetPrice" : 741,
             "BaseAsset" : "BTC",
             "QuoteAsset" : "INR",
             "Scale" : 1
          }
       },
        {
            "PriceData" : {
             "AssetPrice" : 747,
             "BaseAsset" : "BTC",
             "QuoteAsset" : "AAA",
             "Scale" : 1
          }
       },
        {
            "PriceData" : {
             "AssetPrice" : 747,
             "BaseAsset" : "BTC",
             "QuoteAsset" : "BBB",
             "Scale" : 1
          }
       },
        {
            "PriceData" : {
             "AssetPrice" : 747,
             "BaseAsset" : "BTC",
             "QuoteAsset" : "CCC",
             "Scale" : 1
          }
       },
        {
            "PriceData" : {
             "AssetPrice" : 747,
             "BaseAsset" : "BTC",
             "QuoteAsset" : "DDD",
             "Scale" : 1
          }
       },
        {
            "PriceData" : {
             "AssetPrice" : 747,
             "BaseAsset" : "BTC",
             "QuoteAsset" : "EEE",
             "Scale" : 1
          }
       },
        {
            "PriceData" : {
             "AssetPrice" : 747,
             "BaseAsset" : "BTC",
             "QuoteAsset" : "FFF",
             "Scale" : 1
          }
       },
        {
            "PriceData" : {
             "AssetPrice" : 747,
             "BaseAsset" : "BTC",
             "QuoteAsset" : "GGG",
             "Scale" : 11
          }
       }
    ],
    "Provider" : "123",
    "TransactionType" : "OracleSet",
    "URI": "123"
 },
        "secret": "ssy6qoX4KB5py7gLMeNtqhGwNjoUo"
        }
    ]
}

Create oracle response

    "result": {
        "deprecated": "Signing support in the 'submit' command has been deprecated and will be removed in a future version of the server. Please migrate to a standalone signing tool.",
        "engine_result": "tesSUCCESS",
        "engine_result_code": 0,
        "engine_result_message": "The transaction was applied. Only final in a validated ledger.",
        "status": "success",
        "tx_blob": "12003322800000002400006ADB2F65CD261620330000006468400000000000000A732103946E24AD1AEB88BD09CBCB262953B28E17D61937B4C59B4739F95DB7B8036D0074463044022067D4E7E2F33126A3FFD024A65EF1705AA1E8397E953B6A3DD9154DA74BAF91F102204349678E12D8E14A835D5EEA7F04BF0EDFBBAC74F7FCFFBDD2FB2889CF7FF1AD75020123701C0863757272656E6379701D0201238114E1EBC1931D8D1EF35707D000E92FF02A64C4E8B7F018E020301700000000000002E6041001011A0000000000000000000000000000000000000000021A0000000000000000000000005553440000000000E1E020301700000000000002E4041001011A0000000000000000000000004254430000000000021A0000000000000000000000005553440000000000E1E020301700000000000002E5041001011A0000000000000000000000004254430000000000021A000000000000000000000000494E520000000000E1E020301700000000000002EB041001011A0000000000000000000000004254430000000000021A0000000000000000000000004141410000000000E1E020301700000000000002EB041001011A0000000000000000000000004254430000000000021A0000000000000000000000004242420000000000E1E020301700000000000002EB041001011A0000000000000000000000004254430000000000021A0000000000000000000000004343430000000000E1E020301700000000000002EB041001011A0000000000000000000000004254430000000000021A0000000000000000000000004444440000000000E1E020301700000000000002EB041001011A0000000000000000000000004254430000000000021A0000000000000000000000004545450000000000E1E020301700000000000002EB041001011A0000000000000000000000004254430000000000021A0000000000000000000000004646460000000000E1E020301700000000000002EB04100B011A0000000000000000000000004254430000000000021A0000000000000000000000004747470000000000E1F1",
        "tx_json": {
            "Account": "rMbZT8cR4PY4swdWTNNQyQ1bmE3sefyYbb",
            "AssetClass": "63757272656E6379",
            "Fee": "10",
            "Flags": 2147483648,
            "LastUpdateTime": 1707943446,
            "OracleDocumentID": 100,
            "PriceDataSeries": [
                {
                    "PriceData": {
                        "AssetPrice": "2e6",
                        "BaseAsset": "XRP",
                        "QuoteAsset": "USD",
                        "Scale": 1
                    }
                },
                {
                    "PriceData": {
                        "AssetPrice": "2e4",
                        "BaseAsset": "BTC",
                        "QuoteAsset": "USD",
                        "Scale": 1
                    }
                },
                {
                    "PriceData": {
                        "AssetPrice": "2e5",
                        "BaseAsset": "BTC",
                        "QuoteAsset": "INR",
                        "Scale": 1
                    }
                },
                {
                    "PriceData": {
                        "AssetPrice": "2eb",
                        "BaseAsset": "BTC",
                        "QuoteAsset": "AAA",
                        "Scale": 1
                    }
                },
                {
                    "PriceData": {
                        "AssetPrice": "2eb",
                        "BaseAsset": "BTC",
                        "QuoteAsset": "BBB",
                        "Scale": 1
                    }
                },
                {
                    "PriceData": {
                        "AssetPrice": "2eb",
                        "BaseAsset": "BTC",
                        "QuoteAsset": "CCC",
                        "Scale": 1
                    }
                },
                {
                    "PriceData": {
                        "AssetPrice": "2eb",
                        "BaseAsset": "BTC",
                        "QuoteAsset": "DDD",
                        "Scale": 1
                    }
                },
                {
                    "PriceData": {
                        "AssetPrice": "2eb",
                        "BaseAsset": "BTC",
                        "QuoteAsset": "EEE",
                        "Scale": 1
                    }
                },
                {
                    "PriceData": {
                        "AssetPrice": "2eb",
                        "BaseAsset": "BTC",
                        "QuoteAsset": "FFF",
                        "Scale": 1
                    }
                },
                {
                    "PriceData": {
                        "AssetPrice": "2eb",
                        "BaseAsset": "BTC",
                        "QuoteAsset": "GGG",
                        "Scale": 11
                    }
                }
            ],
            "Provider": "0123",
            "Sequence": 27355,
            "SigningPubKey": "03946E24AD1AEB88BD09CBCB262953B28E17D61937B4C59B4739F95DB7B8036D00",
            "TransactionType": "OracleSet",
            "TxnSignature": "3044022067D4E7E2F33126A3FFD024A65EF1705AA1E8397E953B6A3DD9154DA74BAF91F102204349678E12D8E14A835D5EEA7F04BF0EDFBBAC74F7FCFFBDD2FB2889CF7FF1AD",
            "URI": "0123",
            "hash": "A993C918CED41F2050384F89D5546E4B62483B9CA4A5FFFCE2683C9FF910FEE7"
        }
    }
}

Update Oracle Request:

    "method" :  "submit",
    "params": [
        {
        "tx_json": {
    "Account" : "rMbZT8cR4PY4swdWTNNQyQ1bmE3sefyYbb",  
    "AssetClass" : "63757272656E6379",
    //"AssetClass" : "GH",
    "Fee" : "10",
    "LastUpdateTime" : "{{current_timestamp}}",
    "OracleDocumentID" : 100,
    "PriceDataSeries" : [
       {
          "PriceData" : {
             "AssetPrice" : 741,
             "BaseAsset" : "XRP",
             "QuoteAsset" : "USD",
             "Scale" : 1
          }
       }
    ],
    "Provider" : "123",
    "TransactionType" : "OracleSet",
    "URI": "123"
 },
        "secret": "ssy6qoX4KB5py7gLMeNtqhGwNjoUo"
        }
    ]
}

Update oracle response:

    "result": {
        "deprecated": "Signing support in the 'submit' command has been deprecated and will be removed in a future version of the server. Please migrate to a standalone signing tool.",
        "engine_result": "tesSUCCESS",
        "engine_result_code": 0,
        "engine_result_message": "The transaction was applied. Only final in a validated ledger.",
        "status": "success",
        "tx_blob": "12003322800000002400006ADC2F65CD269A20330000006468400000000000000A732103946E24AD1AEB88BD09CBCB262953B28E17D61937B4C59B4739F95DB7B8036D007446304402207CD237D810E09B9BE2CEF08FB0B89FF672AAD2402076E609F7E5933661C41BD202201A5A0FCE9D7C339EAC0D25B7EA07E26D312B1A54B28F2BD5600C520EDF7ECCAE75020123701C0863757272656E6379701D0201238114E1EBC1931D8D1EF35707D000E92FF02A64C4E8B7F018E020301700000000000002E5041001011A0000000000000000000000000000000000000000021A0000000000000000000000005553440000000000E1F1",
        "tx_json": {
            "Account": "rMbZT8cR4PY4swdWTNNQyQ1bmE3sefyYbb",
            "AssetClass": "63757272656E6379",
            "Fee": "10",
            "Flags": 2147483648,
            "LastUpdateTime": 1707943578,
            "OracleDocumentID": 100,
            "PriceDataSeries": [
                {
                    "PriceData": {
                        "AssetPrice": "2e5",
                        "BaseAsset": "XRP",
                        "QuoteAsset": "USD",
                        "Scale": 1
                    }
                }
            ],
            "Provider": "0123",
            "Sequence": 27356,
            "SigningPubKey": "03946E24AD1AEB88BD09CBCB262953B28E17D61937B4C59B4739F95DB7B8036D00",
            "TransactionType": "OracleSet",
            "TxnSignature": "304402207CD237D810E09B9BE2CEF08FB0B89FF672AAD2402076E609F7E5933661C41BD202201A5A0FCE9D7C339EAC0D25B7EA07E26D312B1A54B28F2BD5600C520EDF7ECCAE",
            "URI": "0123",
            "hash": "41C54F3D42AD3B538CFEA5DA98B7DBC32CD432063C46CBA0B0160E2CE059855F"
        }
    }
}

But when we get the Oracle we see the entries that were just deleted without the asset prices:

    "result": {
        "index": "3C9E703D1C0DD0516559100DE01EEC27ECCF629B43A58C3100F08BEB78D1A934",
        "ledger_hash": "39E2EFD0E58B2A38794965BE5FDB4184151EDCF063EEAB6272BBCE780BABCDE6",
        "ledger_index": 27446,
        "node": {
            "AssetClass": "63757272656E6379",
            "Flags": 0,
            "LastUpdateTime": 1707943578,
            "LedgerEntryType": "Oracle",
            "Owner": "rMbZT8cR4PY4swdWTNNQyQ1bmE3sefyYbb",
            "OwnerNode": "0",
            "PreviousTxnID": "41C54F3D42AD3B538CFEA5DA98B7DBC32CD432063C46CBA0B0160E2CE059855F",
            "PreviousTxnLgrSeq": 27417,
            "PriceDataSeries": [
                {
                    "PriceData": {
                        "BaseAsset": "BTC",
                        "QuoteAsset": "FFF"
                    }
                },
                {
                    "PriceData": {
                        "BaseAsset": "BTC",
                        "QuoteAsset": "EEE"
                    }
                },
                {
                    "PriceData": {
                        "BaseAsset": "BTC",
                        "QuoteAsset": "CCC"
                    }
                },
                {
                    "PriceData": {
                        "BaseAsset": "BTC",
                        "QuoteAsset": "GGG"
                    }
                },
                {
                    "PriceData": {
                        "BaseAsset": "BTC",
                        "QuoteAsset": "BBB"
                    }
                },
                {
                    "PriceData": {
                        "BaseAsset": "BTC",
                        "QuoteAsset": "AAA"
                    }
                },
                {
                    "PriceData": {
                        "BaseAsset": "BTC",
                        "QuoteAsset": "INR"
                    }
                },
                {
                    "PriceData": {
                        "BaseAsset": "BTC",
                        "QuoteAsset": "DDD"
                    }
                },
                {
                    "PriceData": {
                        "BaseAsset": "BTC",
                        "QuoteAsset": "USD"
                    }
                },
                {
                    "PriceData": {
                        "AssetPrice": "2e5",
                        "BaseAsset": "XRP",
                        "QuoteAsset": "USD",
                        "Scale": 1
                    }
                }
            ],
            "Provider": "0123",
            "URI": "0123",
            "index": "3C9E703D1C0DD0516559100DE01EEC27ECCF629B43A58C3100F08BEB78D1A934"
        },
        "status": "success",
        "validated": true
    }
}
gregtatcam commented 9 months ago

This is expected behavior. When you update fewer entries then the most recent Oracle has these entries update. But since the LastUpdateTime applies to all entries, the entries that have not been included in the last OracleSet have their prices missing to indicate that they are out of date. A user then has to look at the previous object(s) to find the historical data for the entries that are not updated with the most recent OracleSet.