Skip to content
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

Ledger method crash when use Clio server #632

Open
jungsooyun opened this issue Aug 16, 2023 · 4 comments
Open

Ledger method crash when use Clio server #632

jungsooyun opened this issue Aug 16, 2023 · 4 comments

Comments

@jungsooyun
Copy link
Contributor

Hello, I've discovered that when using the Ledger method to retrieve ledger data, a crash occurs if the server is not pure rippled but Clio.

If it's a method that doesn't exist in Clio, the Clio server relays the request to the rippled server without any problem. However, since both Clio and rippled have the Ledger method but require different parameters, a crash occurs when sending a request to Clio using the Ledger model at https://github.com/XRPLF/xrpl-py/blob/master/xrpl/models/requests/ledger.py.

I personally use a ClioLedger model as shown below, but I'm curious about what the developers think. Since there seems to be a similar issue in xrpl.js, I think it might be necessary to coordinate opinions with the xrpl.js team and the Clio / rippled teams. If you think the method below is also fine, I'll submit it as a PR.

from CryptoQuant,

from dataclasses import dataclass, field

from xrpl.models.requests.request import LookupByLedgerRequest, Request, RequestMethod
from xrpl.models.utils import require_kwargs_on_init

@require_kwargs_on_init
@dataclass(frozen=True)
class ClioLedger(Request, LookupByLedgerRequest):
    """
    Retrieve information about the public ledger.
    `See ledger <https://xrpl.org/ledger.html>`_
    """

    method: RequestMethod = field(default=RequestMethod.LEDGER, init=False)
    transactions: bool = False
    expand: bool = False
    owner_funds: bool = False
    binary: bool = False
    queue: bool = False
    diff: bool = False
@mvadari
Copy link
Collaborator

mvadari commented Aug 16, 2023

The ledger command is supposed to be identical between rippled and Clio. Could you provide more information about what error you're receiving and a code snippet that causes this error?

@injaelee
Copy link

Heya @jungsooyun , we cannot reproduce the problem that you are facing. Please be specific with the following information.

  • Code snippet of the Ledger request
  • Expected Behavior
  • Observed Behavior
    • Describe the "crash": What went wrong and how is this preventing you from doing what you need to do
    • Stack trace of your application

Attempt to Reproduction

This is our attempt to reproduction.

# using xrpl-py==2.2.0
#
from xrpl.clients import JsonRpcClient
from xrpl.models.requests import Ledger
import logging

logger = logging.getLogger(__name__)
logging.basicConfig(level=logging.INFO)

def main():
	mainnet_url = "https://s1.ripple.com:51234"
	clio_url = "https://s2-clio.ripple.com:51234"

	for url in (mainnet_url, clio_url):
		logger.info("URL: %s", url)
		xrpl_client = JsonRpcClient(url)
		ledger_req = Ledger()
		logger.info(ledger_req)
		response = xrpl_client.request(ledger_req)
		logger.info(response)

if __name__ == "__main__":
	main()
INFO:__main__:URL: https://s1.ripple.com:51234
INFO:__main__:Ledger(ledger_hash=None, ledger_index=None, method=<RequestMethod.LEDGER: 'ledger'>, id=None, full=False, accounts=False, transactions=False, expand=False, owner_funds=False, binary=False, queue=False, type=None)
INFO:__main__:Response(status=<ResponseStatus.SUCCESS: 'success'>, result={'ledger_hash': 'BBB4A839B5772CEB63DB44539CD44E635C72072BB0EF9554BE556710D9585CF6', 'ledger_index': 81881624, 'validated': True, 'ledger': {'accepted': True, 'account_hash': '4B3943C645774B33FA17E7D7B0D792CB8EE9E7BE275BF16A95405CB8AB90F341', 'close_flags': 0, 'close_time': 745510861, 'close_time_human': '2023-Aug-16 14:21:01.000000000 UTC', 'close_time_resolution': 10, 'closed': True, 'hash': 'BBB4A839B5772CEB63DB44539CD44E635C72072BB0EF9554BE556710D9585CF6', 'ledger_hash': 'BBB4A839B5772CEB63DB44539CD44E635C72072BB0EF9554BE556710D9585CF6', 'ledger_index': '81881624', 'parent_close_time': 745510860, 'parent_hash': 'DB68EE348581E9059948A358BAC4F8AA6DA417ED2ECB8D0DFC979BBA7938A29D', 'seqNum': '81881624', 'totalCoins': '99988495351869696', 'total_coins': '99988495351869696', 'transaction_hash': '4F45A0C9538E916479DA29DA496E5FC62C6B16515E68BEF7DD33FE5B35566549'}}, id=None, type=<ResponseType.RESPONSE: 'response'>)
INFO:__main__:URL: https://s2-clio.ripple.com:51234
INFO:__main__:Ledger(ledger_hash=None, ledger_index=None, method=<RequestMethod.LEDGER: 'ledger'>, id=None, full=False, accounts=False, transactions=False, expand=False, owner_funds=False, binary=False, queue=False, type=None)
INFO:__main__:Response(status=<ResponseStatus.SUCCESS: 'success'>, result={'ledger_hash': 'BBB4A839B5772CEB63DB44539CD44E635C72072BB0EF9554BE556710D9585CF6', 'ledger_index': 81881624, 'validated': True, 'ledger': {'accepted': True, 'account_hash': '4B3943C645774B33FA17E7D7B0D792CB8EE9E7BE275BF16A95405CB8AB90F341', 'close_flags': 0, 'close_time': 745510861, 'close_time_human': '2023-Aug-16 14:21:01.000000000 UTC', 'close_time_resolution': 10, 'closed': True, 'hash': 'BBB4A839B5772CEB63DB44539CD44E635C72072BB0EF9554BE556710D9585CF6', 'ledger_hash': 'BBB4A839B5772CEB63DB44539CD44E635C72072BB0EF9554BE556710D9585CF6', 'ledger_index': '81881624', 'parent_close_time': 745510860, 'parent_hash': 'DB68EE348581E9059948A358BAC4F8AA6DA417ED2ECB8D0DFC979BBA7938A29D', 'seqNum': '81881624', 'totalCoins': '99988495351869696', 'total_coins': '99988495351869696', 'transaction_hash': '4F45A0C9538E916479DA29DA496E5FC62C6B16515E68BEF7DD33FE5B35566549'}}, id=None, type=<ResponseType.RESPONSE: 'response'>)```

@jungsooyun
Copy link
Contributor Author

@mvadari @injaelee

Sorry for late response.

  • Client/Server version used
    ServerInfo() gave me s1 is also clio node.
Client: xrpl-py==2.2.0 , python 3.7

Server (gets from `ServerInfo()`):
  - https://s1.ripple.com:51234: {'clio_version': '20230525020319-dev-aace437', 'rippled_version': '1.11.0'}
  - https://s2-clio.ripple.com:51234: {'clio_version': '20230525020319-dev-aace437', 'rippled_version': '1.11.0'}
  - https://xrplcluster.com: {'build_version': '1.11.0'}
  - personal clio node (quicknode): {'clio_version': '1.0.4+0c5a69e',  'rippled_version': '1.11.0'}
  • Code snippet
# using xrpl-py==2.2.0
#
from xrpl.clients import JsonRpcClient
from xrpl.models.requests import Ledger, ServerInfo
import logging

logger = logging.getLogger(__name__)
logging.basicConfig(level=logging.INFO)


def main():
    mainnet_url = "https://s1.ripple.com:51234"
    cluster_url = "https://xrplcluster.com"
    clio_url = "https://{masking}.xrp-mainnet.quiknode.pro/{masking}"
    # clio_url = "https://s2-clio.ripple.com:51234"

    for url in (mainnet_url, cluster_url, clio_url):
        logger.info("URL: %s", url)
        xrpl_client = JsonRpcClient(url)
        ledger_req = Ledger()
        logger.info(ledger_req)
        response = xrpl_client.request(ledger_req)
        logger.info(response)


if __name__ == "__main__":
    main()
  • Observed behavior
INFO:__main__:URL: https://s1.ripple.com:51234
INFO:__main__:Ledger(ledger_hash=None, ledger_index=None, method=<RequestMethod.LEDGER: 'ledger'>, id=None, full=False, accounts=False, transactions=False, expand=False, owner_funds=False, binary=False, queue=False, type=None)
INFO:__main__:Response(status=<ResponseStatus.SUCCESS: 'success'>, result={'ledger_hash': '9B8D5E93D976DB9A25904CDCC6F26AF043113EDDD33BF95DA3FB9E957848CBFD', 'ledger_index': 82305732, 'validated': True, 'ledger': {'accepted': True, 'account_hash': '146000A4AD549597E5031AB247FC4A9A32D7A5C66F5B6844EC7BBD278FAC72B6', 'close_flags': 0, 'close_time': 747133031, 'close_time_human': '2023-Sep-04 08:57:11.000000000 UTC', 'close_time_resolution': 10, 'closed': True, 'hash': '9B8D5E93D976DB9A25904CDCC6F26AF043113EDDD33BF95DA3FB9E957848CBFD', 'ledger_hash': '9B8D5E93D976DB9A25904CDCC6F26AF043113EDDD33BF95DA3FB9E957848CBFD', 'ledger_index': '82305732', 'parent_close_time': 747133030, 'parent_hash': '8FC342D8FB7F6CE638B0ECEB29E9587F3420D133FB86AEE8211F96B713DB97AD', 'seqNum': '82305732', 'totalCoins': '99988440856743849', 'total_coins': '99988440856743849', 'transaction_hash': '079B300AACAE16F7DDA9B5E0DA4F1C91D9A17299B58E993FDEBF461A088DF5C4'}}, id=None, type=<ResponseType.RESPONSE: 'response'>)

INFO:__main__:URL: https://xrplcluster.com
INFO:__main__:Ledger(ledger_hash=None, ledger_index=None, method=<RequestMethod.LEDGER: 'ledger'>, id=None, full=False, accounts=False, transactions=False, expand=False, owner_funds=False, binary=False, queue=False, type=None)
INFO:__main__:Response(status=<ResponseStatus.SUCCESS: 'success'>, result={'closed': {'ledger': {'accepted': True, 'account_hash': '146000A4AD549597E5031AB247FC4A9A32D7A5C66F5B6844EC7BBD278FAC72B6', 'close_flags': 0, 'close_time': 747133031, 'close_time_human': '2023-Sep-04 08:57:11.000000000 UTC', 'close_time_resolution': 10, 'closed': True, 'hash': '9B8D5E93D976DB9A25904CDCC6F26AF043113EDDD33BF95DA3FB9E957848CBFD', 'ledger_hash': '9B8D5E93D976DB9A25904CDCC6F26AF043113EDDD33BF95DA3FB9E957848CBFD', 'ledger_index': '82305732', 'parent_close_time': 747133030, 'parent_hash': '8FC342D8FB7F6CE638B0ECEB29E9587F3420D133FB86AEE8211F96B713DB97AD', 'seqNum': '82305732', 'totalCoins': '99988440856743849', 'total_coins': '99988440856743849', 'transaction_hash': '079B300AACAE16F7DDA9B5E0DA4F1C91D9A17299B58E993FDEBF461A088DF5C4'}}, 'open': {'ledger': {'closed': False, 'ledger_index': '82305733', 'parent_hash': '9B8D5E93D976DB9A25904CDCC6F26AF043113EDDD33BF95DA3FB9E957848CBFD', 'seqNum': '82305733'}}}, id=None, type=<ResponseType.RESPONSE: 'response'>)

INFO:__main__:URL: https://{masking}.xrp-mainnet.quiknode.pro/{masking}
INFO:__main__:Ledger(ledger_hash=None, ledger_index=None, method=<RequestMethod.LEDGER: 'ledger'>, id=None, full=False, accounts=False, transactions=False, expand=False, owner_funds=False, binary=False, queue=False, type=None)
INFO:__main__:Response(status=<ResponseStatus.ERROR: 'error'>, result={'error': 'notSupported', 'error_code': 75, 'error_message': 'Operation not supported.', 'type': 'response', 'request': {'method': 'ledger', 'params': [{'full': False, 'accounts': False, 'transactions': False, 'expand': False, 'owner_funds': False, 'binary': False, 'queue': False}]}}, id=None, type=<ResponseType.RESPONSE: 'response'>)
  • Expected behavior

Given that the latest version deployed on github clio is 1.0.4, I'm not certain if it's a version issue.

If it is a version issue, using the term 'crash' seems to have been a mistake. I apologize. However, if making a request using the diff parameter that's unique to the ledger method in clio, it seems xrpl-py would need a separate argument or class.

@mvadari
Copy link
Collaborator

mvadari commented Sep 20, 2023

I can replicate a difference in Clio/rippled response, but I can't replicate an error with s2-clio. Perhaps it's an issue with 1.0.4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants