[go: up one dir, main page]

Draft: Proxy_server: use store instead of RPC call when possible

Context

This MR introduces a new feature to Tezos Proxy server: the ability to read the store directly, instead of doing a RPC call to the node.

When the data required by the Proxy server is stored on a store on the same machine the service runs on, it is a waste of resource to do an RPC call, when the data could directly be read from disk. Note that it is only possible when the server is aware of the store, i.e. when it was provided a DATA_DIR argument. This MR makes it possible, by doing the following:

  • When DATA_DIR is provided in main_proxy_server.ml, instantiate a store, and pass it to Proxy_services.build_directory.
  • When building the directory in lib_proxy/proxy_sercices.ml, use the store if it's available. Otherwise default to a RPC call (old method).

Closes #2502

Manually testing the MR

This MR can be tested the same way we test the proxy server, as detailed on this page. The only difference is that the proxy server should be launched with the -l option, as to log RPC requests made to the main node.

Here is a comparison of the logs of the proxy server when receiving the request generated by:

$ ./octez-client --endpoint http://127.0.0.1:18732 rpc get /chains/main/blocks/head/context/contracts

Logs on master

Oct 27 15:03:02.867 - alpha.proxy_rpc: chains/<main>/blocks/<head>/header                                                                                                                                          
>>>>2: http://127.0.0.1:18731/chains/main/blocks/head/header                                                                                                                                                       
<<<<2: 200 OK                                                                                            
  { "protocol": "ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK",                                                                                                                                             
    "chain_id": "NetXdQprcVkpaWU",                                                                       
    "hash": "BLz5bQKqZAqFKxZnNtsS7XFF9wR5Cj2NeDRcs28TGXj6NTVfdFY",                                                                                                                                                 
    "level": 2, "proto": 1,                                                                              
    "predecessor": "BM6Yod1B2dYW2rHWNuSW1LJmmevPWFgvZ47NGWYLELxYrhYi5SD",                                                                                                                                          
    "timestamp": "2022-10-25T16:22:22Z", "validation_pass": 4,                                                                                                                                                     
    "operations_hash":                                                                                                                                                                                             
      "LLoa7bxRTKaQN2bLYoitYB6bU2DvLnBAqrVjZcvJ364cTcX2PZYKU",                                                                                                                                                     
    "fitness": [ "02", "00000002", "", "ffffffff", "0000000a" ],                                                                                                                                                   
    "context": "CoUsjmksXj6wsdLSg4UVdgCtw3DDtQ9KZLduf3fJmE2x2DYVJpxd",                                                                                                                                             
    "payload_hash": "vh2XZya2pAueroruR4dMBt1C9GGRiaqxWzxo6RSv38vVdB7wDAD5",                                                                                                                                        
    "payload_round": 10, "proof_of_work_nonce": "06d3043000000000",                                                                                                                                                
    "liquidity_baking_toggle_vote": "pass",                                                              
    "signature":                                                                                         
      "sigsVtu5nLbwm8vtynsHumx1HQJ9ZaFDa2wgzBqCtqsTJyCMEhCavf3V36Nr8Wv5mDMHuqzAukk9h6F9p17ZXw5HnwaxtKeJ" }                                                                                                         
Oct 27 15:03:02.869 - alpha.proxy_rpc: proxy cache created for chain main and block head                                                                                                                           
>>>>3: http://127.0.0.1:18731/chains/main/blocks/head/context/constants                                                                                                                                            
<<<<3: 200 OK                                                                                            
  { "proof_of_work_nonce_size": 8, "nonce_length": 32,                                                   
    [...]                                                                                                                                               
    "zk_rollup_min_pending_to_process": 10 }                                                             
Oct 27 15:03:03.873 - proxy_services: clearing data for chain main and block head

Logs on nbacquey@lib_client/use_store

Oct 27 14:59:34.359 - alpha.proxy_rpc: chains/<main>/blocks/<head>/header                                                                                                                                          
Oct 27 14:59:34.359 - alpha.proxy_rpc: proxy cache created for chain main and block head                                                                                                                           
>>>>2: http://127.0.0.1:18731/chains/main/blocks/head/context/constants                                                                                                                                            
<<<<2: 200 OK                                                                                            
  { "proof_of_work_nonce_size": 8, "nonce_length": 32,                                                   
    [...]                                                                                                                                               
    "zk_rollup_min_pending_to_process": 10 }                                                             
Oct 27 14:59:35.363 - proxy_services: clearing data for chain main and block head

Observations

We notice that the changes introduced in this MR allow the proxy server to avoid the RPC call to /chains/main/blocks/head/header, as intended.

Checklist

  • Select suitable reviewers using the Reviewers field below.
  • Select as Assignee the next person who should take action on that MR
Edited by nbacquey

Merge request reports

Loading