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

Problem: JSON-RPC depends on setting in client.toml #390

Closed
samuel-tay opened this issue Mar 12, 2022 · 5 comments
Closed

Problem: JSON-RPC depends on setting in client.toml #390

samuel-tay opened this issue Mar 12, 2022 · 5 comments

Comments

@samuel-tay
Copy link

Describe the bug
If all settings are default, there is no issue. However, if laddr = "tcp://0.0.0.0:26657" is modified in config.toml and node = "tcp://localhost:26657" not updated in client.toml, then json-rpc will have issues.

I haven't fully tested, but I used web3.py and tried to request w3.eth.get_block(block_identifier='latest') and web3.exceptions.BlockNotFound: Block with id: 'latest' not found will be thrown. This was resolved when client.toml was configured to matched laddr in config.toml

To Reproduce
Web3 code can be provided on request.

Expected behavior
I would expect the json-rpc on the node to read the node config from config.toml instead of client.toml

Additional context
Problem might be from Tharsis

@yihuang
Copy link
Collaborator

yihuang commented Mar 12, 2022

I don't reproduce the issue on main branch, what I do:

  • init devnet
  • change client.toml's node to different port
  • start devnet
  • try web3 code:
>>> w3 = web3.Web3(provider=web3.HTTPProvider('http://localhost:26651'))
>>> w3.eth.get_block('latest')
AttributeDict({'baseFeePerGas': 716, 'difficulty': 0, 'extraData': HexBytes('0x'), 'gasLimit': 4294967295, 'gasUsed': 0, 'hash': HexBytes('0xc19485569d1f27cd6ec9a9ffa916d7ef9829546eaad71d8e20e748be05fd867b'), 'logsBloom': HexBytes('0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'), 'miner': '0x38B4089F7762E0C20E9BeD8e991E074550Ef5a52', 'mixHash': HexBytes('0x0000000000000000000000000000000000000000000000000000000000000000'), 'nonce': HexBytes('0x0000000000000000'), 'number': 106, 'parentHash': HexBytes('0xdce399b828bb9626241c4512a3846ebde0ad6b5eaa003efe2953081cb26469a0'), 'receiptsRoot': HexBytes('0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421'), 'sha3Uncles': HexBytes('0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347'), 'size': 699, 'stateRoot': HexBytes('0x3b1e365bc164f966240d601368c1e397bd5826ef7e030f68ca97bd6e720a1dd0'), 'timestamp': 1647069257, 'totalDifficulty': 0, 'transactions': [], 'transactionsRoot': HexBytes('0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421'), 'uncles': []})

@samuel-tay
Copy link
Author

samuel-tay commented Mar 12, 2022

I just tried a few more times and it is exactly as I described. I'm using 0.6.5

#Tendermint RPC: 0.0.0.0:65041
samuel@node:~$ sudo systemctl stop cronosd4
samuel@node:~$ sudo nano /home/cronos4/.cronos/config/client.toml #change to tcp://localhost:65042
samuel@node:~$ sudo systemctl start cronosd4
samuel@node:~$ python3
Python 3.8.10 (default, Nov 26 2021, 20:14:08)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import web3
>>> w3 = web3.Web3(provider=web3.HTTPProvider('http://localhost:65044'))
>>> w3.eth.get_block('latest')
AttributeDict({'difficulty': 0, 'extraData': HexBytes('0x'), 'gasLimit': 10000000, 'gasUsed': 2332981, 'hash': HexBytes('0xb312d23bfa5f36322d2b47f238fbfee2cf20f4f83030edc5cb63d682e341b5be'), 'logsBloom': HexBytes('0x00200004101000030001900080000400010a240084010000104108a0000001000000800300800044402000802000080208000000000c00050000000200246080000000401083208200010948101802200000000040040c00840001008104640000000500028001000000020010820a00080020000009100c0100009004220000100102034201c001200000002902000180000113480020080020004000000810030000800001100400000040000000104000100002020000001000b00000002000000202002411008080458000020000400000300010023028200000802068480052840000280200000800020000000000020000c00800400400088001010400'), 'miner': '0x0780aDEF7832a7F7682B757a5ec5Bd9fe7C38B4B', 'mixHash': HexBytes('0x0000000000000000000000000000000000000000000000000000000000000000'), 'nonce': HexBytes('0x0000000000000000'), 'number': 1866609, 'parentHash': HexBytes('0xe1c71ef8f79a465c1d2944c7dcf3b68337dc72ae6b4bfc156482d9e50039b508'), 'receiptsRoot': HexBytes('0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421'), 'sha3Uncles': HexBytes('0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347'), 'size': 8885, 'stateRoot': HexBytes('0x87ba691822da259f18f0aae546cf09020be9fa684cb5cdd8497731716eb0e685'), 'timestamp': 1647079465, 'totalDifficulty': 0, 'transactions': [HexBytes('0xf3460626eabab47b85b960b98a6899d992a223fafc0c1fedc101aaa69193e56e'), HexBytes('0xd7abcf5cd3bfd211c821de8d2efb8fe5cae08f00847a19a78f6b5d76aac5a29b'), HexBytes('0xf2f8860cda00c8879c3be6b34348b415bbd720862df8d7ce4d240616050e7b76'), HexBytes('0xed15666d4de4a2dbf65e8d8abe53829db10f5c510c13527a66ab9570cff99b8d'), HexBytes('0x80c59e569802b1cb8420ef2beaec74b3df2d4b95b6d79f5a5687383ee58d598e'), HexBytes('0x8e5afff35e8b8305aced6223551319c3512914a8b92d72fbe594d02a3c9e0833'), HexBytes('0xf47ebaf5126a50c3edfb206022c9b1f36a6e674a25a5b5afe6206be34010dab0'), HexBytes('0xd51811aa99b6765790d0298d341f49f8730aa10294a9ddfda38e1e2766af6fca'), HexBytes('0x5ae332a83f6c721022381383c2def0a560f5bf8484d4bc327610a8a9d79e1c04'), HexBytes('0x14f83a7262fd8549f4da718d0a4f5734c3a9fead7f69ecf36e4e285131c9ac5c'), HexBytes('0xb3155c2e469883c7fffa65c101f91d8b71733e6556955b134e88b39d91a02cb9')], 'transactionsRoot': HexBytes('0x5384d4cbc4732e60e66bfe5fd66919b564a73c141c32f42e1ec919ddb1ae14ab'), 'uncles': []})
>>>
samuel@node:~$ sudo systemctl stop cronosd4
samuel@node:~$ sudo nano /home/cronos4/.cronos/config/client.toml #change to tcp://localhost:65041
samuel@node:~$ sudo systemctl start cronosd4
samuel@node:~$ python3
Python 3.8.10 (default, Nov 26 2021, 20:14:08)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import web3
>>> w3 = web3.Web3(provider=web3.HTTPProvider('http://localhost:65044'))
>>> w3.eth.get_block('latest')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/samuel/.local/lib/python3.8/site-packages/web3/eth.py", line 677, in get_block
    return self._get_block(block_identifier, full_transactions)
  File "/home/samuel/.local/lib/python3.8/site-packages/web3/module.py", line 57, in caller
    result = w3.manager.request_blocking(method_str,
  File "/home/samuel/.local/lib/python3.8/site-packages/web3/manager.py", line 198, in request_blocking
    return self.formatted_response(response,
  File "/home/samuel/.local/lib/python3.8/site-packages/web3/manager.py", line 177, in formatted_response
    apply_null_result_formatters(null_result_formatters, response, params)
  File "/home/samuel/.local/lib/python3.8/site-packages/web3/manager.py", line 82, in apply_null_result_formatters
    formatted_resp = pipe(params, null_result_formatters)
  File "cytoolz/functoolz.pyx", line 667, in cytoolz.functoolz.pipe
  File "cytoolz/functoolz.pyx", line 642, in cytoolz.functoolz.c_pipe
  File "/home/samuel/.local/lib/python3.8/site-packages/web3/_utils/method_formatters.py", line 630, in raise_block_not_found
    raise BlockNotFound(message)
web3.exceptions.BlockNotFound: Block with id: 'latest' not found.

client.toml for reference

# The network chain ID
chain-id = ""
# The keyring's backend, where the keys are stored (os|file|kwallet|pass|test|memory)
keyring-backend = "os"
# CLI output format (text|json)
output = "text"
# <host>:<port> to Tendermint RPC interface for this chain
node = "tcp://localhost:65041"
# Transaction broadcasting mode (sync|async|block)
broadcast-mode = "sync"

@yihuang
Copy link
Collaborator

yihuang commented Mar 14, 2022

did you disable the rest-api and grpc server? in that case it doesn't use the "local" client. try enable the grpc or API server.

EDIT: I just reproduced the same issue by disable both grpc and API servers.

@yihuang
Copy link
Collaborator

yihuang commented Mar 14, 2022

will be fixed by evmos/ethermint#988.

@samuel-tay
Copy link
Author

Thanks @yihuang for fixing this so quickly! Your right, I did disable both api and grpc as you mentioned.

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

2 participants