Issue: get the block height by Sidecar
zhy827827 opened this issue · comments
Kusuma
when i use curl http://localhost:8081/blocks/head/header |jq
{ "parentHash": "0x64c626a5ebd679edd1eecf50f2ddc038359a0bfd22d14ae853f643f8c8289159", "number": "17676323", "stateRoot": "0x5b1d6b8fba786f1f5833780b4623bbf6b955f8343009318b4e9e79dc2506d9f8", "extrinsicsRoot": "0x5f1b60f6cf0dada1c8af73a121e04fdc38bf87826e0e735a1b634ee349e3bba3",
"number": "17676323",
and i use curl -H "Content-Type: application/json" -d '{"id":1, "jsonrpc":"2.0", "method": "chain_getHeader", "params":[]}' http://localhost:9933 |jq
{ "jsonrpc": "2.0", "result": { "parentHash": "0xf85561e08349800579890c97b01a7b041ba17e01d6e983fafa530195b5fcd0eb", "number": "0x10db827", "stateRoot": "0xf3eb9f982de5ca7048e515ec113df9bc729fe43e94c5b035deaab772e6a72046", "extrinsicsRoot": "0x09aa9ea6f133566e9eb604a711799b3adfe78053649037ceeed959d9a9267c66",
"number": "17676327",
Sidecar always lags behind in obtaining block heights. But polkadot have not this issues. why?
use curl http://localhost:8081/blocks/head/header |jq
get value of 3-5 minutes and the like remains unchanged
By default /blocks/head/header
will get the latest finalized header. If you want the latest authored block you need to attach the finalized=false
query param.
OK, I'll test it
Not sure where it went but I got a notification with the following:
Add parameter finalized = false must be the post method, curl http://127.0.0.1:8080/blocks/head/header is get method,How should I set up?? thank you @TarikGul
There is no POST method, its just /blocks/head/header?finalized=false
By default /blocks/head/header
How to accelerate get the latest finalized header? @TarikGul What are the optimizations?
@zhy827827 There are no optimizations, it is the most simple endpoint in all of sidecar.
is it necessary to optimize the parameters when I started Kusama. Previously, there was no such problem of sidecar.
Performance for the /blocks/head/header
endpoint did decrease because of this PR: #1265 .It's affected when you query the block over and over again at a fast pace. The reason is because there was a bug in our caching mechanism so we had to change that.
Thank you.
use /blocks/head/header
lags far behind getting block heights using the Kusama API
Is it related to the node type? archive and full node ? we use archive node
sudo docker run -d -p 19944:9944 -p 19933:9933 --network=hostksm --name ksmarchive -v /opt/kusuma/data:/polkadot parity/polkadot:v0.9.42 --rpc-external --ws-external --chain kusama --rpc-cors all --pruning archive
Why won't I fall behind when I connect to the official node?
sudo docker run -d -p 28081:8080 --name ksmsidecartest1 --restart=always -e SAS_SUBSTRATE_URL=wss://kusama-rpc.polkadot.io parity/substrate-api-sidecar:v16.0.0
curl -H "Content-Type: application/json" http://127.0.0.1:28081/blocks/head/header |jq |grep 'number'
"number": "17960904",
Is it a problem with our kusamu node configuration? @TarikGul