XRPLF / rippled

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

PriceOracle: rippled returns inconsistent error codes with invalid inputs under different situations #4962

Open SaxenaKaustubh opened 3 months ago

SaxenaKaustubh commented 3 months ago

Rippled returns different error codes for invalid inputs under different situations. Following is the list of such fields:

OracleSet: Field Value Error Notes
PriceDataSeries "", 1, "Invalid", ([{}]), [{"PriceDataSeries": ""}]] invalidParams
PriceDataSeries None, ([]) temARRAY_EMPTY
TransactionType 123 internal
TransactionType "InvalidEntryShouldFail" invalidParams
Provider "" temMALFORMED
Provider None, 0, -1, 1, 1.2, "Invalid" invalidParams
URI None, 0, -1, 1, 1.2, "Invalid" invalidParams
URI "" temMALFORMED
AssetClass "", "020382A62402D2357ABC020382A6240205" temMALFORMED
AssetClass None, 0, -1, 1, 1.2, "Invalid" invalidParams
Oracle GET (using ledger_entry method call): Field Value Error Notes
oracle_document_id "", "Invalid", -1 malformedDocumentID
oracle_document_id None, 1.2 entryNotFound We may be truncating decimal 1.2 to int 1.
Get Aggregate Price (using get_aggregate_price method call): Field Value Error Notes
Trim "", -1, "abc" oracleMalformed
Trim None invalidParams
gregtatcam commented 1 month ago

There are different levels of validation. Some validation happens by a low layer validation, before the feature (Transactor or API) receives the parameters and then another validation happens in the feature code. The first PriceDataSeries validation happens by a lower layer validation. The reason it fails is that the values are not a valid array. The second PriceDataSeries validation happens by the feature code and it correctly identifies that the array is empty. TransactionType is validated by a lower layer and the feature code doesn't have control over it. All of the above is true for Provider, URI, AssetClass. The first failure, for instance "" happens by the feature and it correctly identifies it as temMALFORMED. The second failure, None, etc, happens by the lower layer. I don't think OracleSet errors are inconsistent. I will update ledger_entry validation to return malformedDocumentID for all invalid input. I will update Trim validation to return invalidParams for all invalid input.