AntelopeIO / leap

C++ implementation of the Antelope protocol
Other
116 stars 70 forks source link

`read-only-threads` is required to submit `/v1/chain/send_read_only_transaction` #2104

Closed aaroncox closed 7 months ago

aaroncox commented 8 months ago

On v5.0.0, without providing read-only-theads in the config.ini - the /v1/chain/send_read_only_transaction API endpoint does not work.

Against a Jungle4 testnet node, if I execute the following query:

curl http://localhost:8888/v1/chain/send_read_only_transaction -d '{"transaction":{"signatures":[],"compression":1,"packed_context_free_data":"789c63000000010001","packed_trx":"789c636040068c06c71c8e2f48be60c830a52fedfceacdbb1838c0e2528bb31800a31509a1"}}'

The response from curl is:

curl: (52) Empty reply from server

Now if I modify the config and add read-only-theads = 4, and rerun the same curl command, I get a response:

{"transaction_id":"f0ec94d0dfdfd810cbdfb88d6ee43e6314e0fea623886ecccfb35284f1ee48be","processed":{"id":"f0ec94d0dfdfd810cbdfb88d6ee43e6314e0fea623886ecccfb35284f1ee48be","block_num":119599286,"block_time":"2024-01-18T06:47:55.000","producer_block_id":null,"receipt":{"status":"executed","cpu_usage_us":0,"net_usage_words":9},"elapsed":369,"net_usage":72,"scheduled":false,"action_traces":[{"action_ordinal":1,"creator_action_ordinal":0,"closest_unnotified_ancestor_action_ordinal":0,"receipt":{"receiver":"abcabcabc333","act_digest":"c065e5fbaadf68523d6da2ea62aa49cf876468ec441aea6c6ece2263b35ed8a9","global_sequence":0,"recv_sequence":0,"auth_sequence":[],"code_sequence":5,"abi_sequence":5},"receiver":"abcabcabc333","act":{"account":"abcabcabc333","name":"returnvalue","authorization":[],"data":{"message":"hello"},"hex_data":"00000000001aa36a"},"context_free":false,"elapsed":333,"console":"","trx_id":"f0ec94d0dfdfd810cbdfb88d6ee43e6314e0fea623886ecccfb35284f1ee48be","block_num":119599286,"block_time":"2024-01-18T06:47:55.000","producer_block_id":null,"account_ram_deltas":[],"except":null,"error_code":null,"return_value_hex_data":"1656616c69646174696f6e20686173207061737365642e","return_value_data":"Validation has passed."}],"account_ram_delta":null,"except":null,"error_code":null}}

The configuration that is causing the error is as follow, with read-only-threads commented out.

chain-threads = 2
net-threads = 2
http-threads = 2
# read-only-threads = 4
wasm-runtime = eos-vm-jit

# api
enable-account-queries = true
http-server-address = 0.0.0.0:12888
p2p-listen-endpoint = 0.0.0.0:12876
verbose-http-errors = true
http-validate-host = false

# state
read-mode = head
validation-mode = full
chain-state-db-size-mb = 131070

# blocks - Retain 24 hours worth of blocks (2 * 60 * 60 * 24 = 172800)
blocks-dir = "/eosio/blocks"
block-log-retain-blocks = 172800

# plugins
plugin = eosio::chain_plugin eosio::chain_api_plugin
plugin = eosio::http_plugin

Any ideas?

heifner commented 8 months ago

I have not tested your config.ini, however doesn't look like you are specifying eosio::chain_api_plugin as it is on the same line as eosio::chain_plugin.

plugin = eosio::chain_plugin eosio::chain_api_plugin
plugin = eosio::chain_plugin
plugin = eosio::chain_api_plugin
spoonincode commented 8 months ago

That's a valid way of specifying plugins because of this oddity, https://github.com/AntelopeIO/appbase/blob/main/application_base.cpp#L404 so it makes sense why, https://github.com/AntelopeIO/leap/blob/4531e9751a8d6d712801ffab1e2b24fe37dc9ca8/plugins/producer_plugin/producer_plugin.cpp#L1223 wouldn't find it.

aaroncox commented 8 months ago

Wow good catch... and that's quite the obscure bug 😂

We have specified multiple plugins on the same line like that since EOS launched, kind of grouping the ones that go together on the same line to enable/disable the pairing at the same time.

I'll understand based on this situation though if moving forward we should deprecate that method of specifying plugins.

heifner commented 7 months ago

Current fix is not finding chain_api_plugin initialized during producer_plugin initialize on hotstuff_integration branch.