[go: up one dir, main page]

RPC: plug max-age header for external RPC process

What

Adds the Cache-control: public, max-age: <seconds> for head-n query responses to external rpc process.

Why

Continuation of !13767 (merged) to add the http cache header to external RPC process. It requires a small change to the Http_cache_header tool to handle the dynamic store.

How

Make change to the get_estimated_time_to_next_level to take a store getter instead of a store value.

Update external RPC process to create and use the middleware.

Tezt

dune exec tezt/tests/main.exe -- --file http_cache_headers.ml

Manually testing the MR

Same testing steps as !13767 (merged) but with external rpc process enabled.

  1. Apply sandbox_block_time.patch to make sandbox minimal_block_delay=10 and delay_increment_per_round=8
g apply sandbox_block_time.patch
  1. Setup sandbox
make # generate new sandbox parameters
DATA_DIR=/tmp/sandboxnode ./src/bin_node/octez-sandboxed-node.sh 1 --connections 0 --enable-http-cache-headers --external-rpc-addr 127.0.0.1:9999
eval `./src/bin_client/octez-init-sandboxed-client.sh 1`
octez-activate-alpha
  1. Bake and check max age
# get client base dir
octez-client config show 
>> { "base_dir": "/tmp/tezos-tmp-client.tSf5JMUn" ... 

./octez-baker-alpha -d /tmp/tezos-tmp-client.tSf5JMUn --endpoint http://localhost:9999 run with local node /tmp/sandboxnode

In a separate terminal:

curl -i  http://localhost:9999/chains/main/blocks/head/hash

HTTP/1.1 200 OK
content-type: application/json
cache-control: public, max-age=7
content-length: 54

"BMZ88qKMoRafCC2ZCN9u2oCXnTkkDesnys5rzjiMxPZBYKoXEut"

If no new block arrive after max-age, the field will be omitted.

# ^C the baker

curl -i  http://localhost:9999/chains/main/blocks/head/hash

HTTP/1.1 200 OK
content-type: application/json
content-length: 54

"BMZ88qKMoRafCC2ZCN9u2oCXnTkkDesnys5rzjiMxPZBYKoXEut"

Metrics using bench_RPS/rps.sh script for local/external rpc with this feature enabled/disabled.

metric local, disabled local, enabled ext, disabled ext, enabled
health-1-th 4078.79 3782.5 4510.77 4149.56
health-10-th 5972.86 5394.44 6797.42 5977.53
header-1-th 4242.22 4121.48 4489.87 4433.47
header-10-th 6089.46 5909.02 6673.03 6386.59
baking-1-th 752 740.99 780.19 767.37
baking-10-th 824.76 816.52 878.49 852.47
attestation-1-th 94.44 93.52 95.65 93.87
attestation-10-th 95.61 95.61 97.13 95.06
Edited by Ryan Tan

Merge request reports

Loading