skalenetwork / skale-consensus

Running the very core of SKL network, SKALE BFT consensus is universal, modern, modular, high-performance, asynchronous, provably-secure, agent-based Proof-of-Stake blockchain consensus engine in C++ 17. Includes provably secure embedded Oracle. Used by SKALE elastic blockchains. Easy and flexible enough to implement your own blockchain or smart contract platform. BLS signatures and Binary Asynchronous Consensus are main building blocks.
https://docs.skale.network/technology/consensus-spec
GNU Affero General Public License v3.0
78 stars 32 forks source link

Not informative log-output for unsupported but valid methods #754

Closed oleksandrSydorenkoJ closed 1 year ago

oleksandrSydorenkoJ commented 1 year ago

Preconditions: Active schain medium type Oracle-demo

Versions: skalenetwork/schain:3.16.1-beta.0

Steps to reproduce:

  1. Run oracle demo for eth_gasPrice
    
            '"cid":<skaleChainId>,"uri":"eth://","jsps":["/result"],encoding":"json","ethApi":"eth_gasPrice","params":[]'
2. check output

**Expected state:**
Oracle request should return readable error - not supported method for Oracle. 
For the invalid request Oracle should return the full request line with detailed mistake in request.  

**Actual state:**
Oracle request returns ``message': 'Oracle request failed with status 10'`` error related to [#define ORACLE_INVALID_JSON_REQUEST 10](https://github.com/skalenetwork/skale-consensus/tree/develop/oracle#list-of-oracle-error-codes) 

**Logs**

========== Calculating PoW number ========== PoW number: 11256 ========== Sending request to Oracle ========== Request >>> {'id': 83, 'jsonrpc': '2.0', 'method': 'oracle_submitRequest', 'params': ['{"cid":123,"uri":"eth://","jsps":["/result"],encoding":"json","ethApi":"eth_gasPrice","params":[],"time":1681213811000,"pow":11256}']} Response <<< {'error': {'code': 10, 'data': None, 'message': 'Oracle request failed with status 10'}, 'id': 83, 'jsonrpc': '2.0'} Send oracle request failed

oleksandrSydorenkoJ commented 1 year ago

Re-checked on skalenetwork/schain:3.16.1-beta.2 Error-log output is implemented for this version of skaled.

There are unclear responses from Oracle

  1. Send oracle request to web2 with bad latency logs from skaled:
    [2023-04-18 12:36:03.581] [46:main] [error] 131990:Curl easy perform failed for url: http://httpbin.org/anything with error code:28

    logs from Oracle:

    
    Response <<<  {'error': {'code': 24, 'data': None, 'message': 'Invalid oracle spec in submitOracleRequest Oracle check failed: Unparsable Oracle spec:{"cid":921257266,"uri":"http://httpbin.org/anything","jsps":["/url","/headers/Content-Length"],"post":"string=string_value","encoding":"json,"time":1681821585000,"pow":2348}'}, 'id': 83, 'jsonrpc': '2.0'}

2. Valid but unsupported methods:
Logs from skaled

2023-04-18 12:44:22.921177 http://1.1.1.1:31223 >>> {"id":83,"jsonrpc":"2.0","method":"oracle_submitRequest","params":["{\"cid\":1,\"uri\":\"eth://\",\"jsps\":[\"/result\"],\"\"encoding\":\"json\",\"ethApi\":\"eth_gasPrice\",\"params\":[],\"time\":1681821862000,\"pow\":1900}"]} 2023-04-18 12:44:22.921260 {"cid":1,"uri":"eth://","jsps":["/result"],""encoding":"json","ethApi":"eth_gasPrice","params":[],"time":1681821862000,"pow":1900} [2023-04-18 12:44:22.921] [config] [error] Invalid oracle spec in submitOracleRequest Oracle check failed: Unparsable Oracle spec:{"cid":1,"uri":"eth://","jsps":["/result"],""encoding":"json","ethApi":"eth_gasPrice","params":[],"time":1681821862000,"pow":1900} 2023-04-18 12:44:22.921425 http://1.1.1.1:31223 <<< {"error":{"code":24,"data":null,"message":"Invalid oracle spec in submitOracleRequest Oracle check failed: Unparsable Oracle spec:{\"cid\":1,\"uri\":\"eth://\",\"jsps\":[\"/result\"],\"\"encoding\":\"json\",\"ethApi\":\"eth_gasPrice\",\"params\":[],\"time\":1681821862000,\"pow\":1900}"},"id":83,"jsonrpc":"2.0"}

logs from Oracle:

Request >>> {'id': 83, 'jsonrpc': '2.0', 'method': 'oracle_submitRequest', 'params': ['{"cid":1,"uri":"eth://","jsps":["/result"],""encoding":"json","ethApi":"eth_gasPrice","params":[],"time":1681821862000,"pow":1900}']} Response <<< {'error': {'code': 24, 'data': None, 'message': 'Invalid oracle spec in submitOracleRequest Oracle check failed: Unparsable Oracle spec:{"cid":1,"uri":"eth://","jsps":["/result"],""encoding":"json","ethApi":"eth_gasPrice","params":[],"time":1681821862000,"pow":1900}'}, 'id': 83, 'jsonrpc': '2.0'}

3. No space after error message: ``not allowed in Oracle urishttp``

Response <<< {'error': {'code': 23, 'data': None, 'message': 'Invalid oracle spec in submitOracleRequest Oracle check failed: IP addresses not allowed in Oracle urishttp://146.59.55.165:3009/status/schains'}, 'id': 83, 'jsonrpc': '2.0'}

oleksandrSydorenkoJ commented 1 year ago

Error logs handling will be fixed in the separate issue Improve Oracle error handling