Open zie1ony opened 3 months ago
Our CasperClient should cache state_root_hash to avoid quering it all the time. The cache should be purged after new deploys or after some time (like 5s).
CasperClient
state_root_hash
This are logs from loading the CEP18 token from the address and making token.name() call.
token.name()
[/Users/ziel/workspace/odra/odra3/odra-casper/rpc-client/src/casper_client.rs:742:9] &request = Object { "jsonrpc": String("2.0"), "method": String("chain_get_state_root_hash"), "id": Number(1), } [/Users/ziel/workspace/odra/odra3/odra-casper/rpc-client/src/casper_client.rs:742:9] &request = Object { "jsonrpc": String("2.0"), "method": String("query_global_state"), "params": Object { "state_identifier": Object { "StateRootHash": String("e478a8fcaf6c7be34244dc643db1bc1b48857369c078f88191de74cf4b0d78a8"), }, "key": String("hash-568fd396922fbbc8f8499f9b888795b2155aa60a68ef9cc38752b2771693a9ce"), "path": Array [], }, "id": Number(1), } [/Users/ziel/workspace/odra/odra3/odra-casper/rpc-client/src/casper_client.rs:742:9] &request = Object { "jsonrpc": String("2.0"), "method": String("chain_get_state_root_hash"), "id": Number(1), } [/Users/ziel/workspace/odra/odra3/odra-casper/rpc-client/src/casper_client.rs:742:9] &request = Object { "jsonrpc": String("2.0"), "method": String("query_global_state"), "params": Object { "state_identifier": Object { "StateRootHash": String("e478a8fcaf6c7be34244dc643db1bc1b48857369c078f88191de74cf4b0d78a8"), }, "key": String("hash-b10cb500c1f46a086ffeab094993e8e0946c75ffaae2cfbdf92332cd2c0ae12b"), "path": Array [], }, "id": Number(1), } [/Users/ziel/workspace/odra/odra3/odra-casper/rpc-client/src/casper_client.rs:742:9] &request = Object { "jsonrpc": String("2.0"), "method": String("chain_get_state_root_hash"), "id": Number(1), } [/Users/ziel/workspace/odra/odra3/odra-casper/rpc-client/src/casper_client.rs:742:9] &request = Object { "jsonrpc": String("2.0"), "method": String("query_global_state"), "params": Object { "state_identifier": Object { "StateRootHash": String("e478a8fcaf6c7be34244dc643db1bc1b48857369c078f88191de74cf4b0d78a8"), }, "key": String("uref-d68b26faf54e90ac363021c2844f93b87f9a3465d646046255cf1f8058191b03-007"), "path": Array [], }, "id": Number(1), } [/Users/ziel/workspace/odra/odra3/odra-casper/rpc-client/src/casper_client.rs:742:9] &request = Object { "jsonrpc": String("2.0"), "method": String("chain_get_state_root_hash"), "id": Number(1), } [/Users/ziel/workspace/odra/odra3/odra-casper/rpc-client/src/casper_client.rs:742:9] &request = Object { "jsonrpc": String("2.0"), "method": String("query_global_state"), "params": Object { "state_identifier": Object { "StateRootHash": String("e478a8fcaf6c7be34244dc643db1bc1b48857369c078f88191de74cf4b0d78a8"), }, "key": String("hash-568fd396922fbbc8f8499f9b888795b2155aa60a68ef9cc38752b2771693a9ce"), "path": Array [], }, "id": Number(1), } [/Users/ziel/workspace/odra/odra3/odra-casper/rpc-client/src/casper_client.rs:742:9] &request = Object { "jsonrpc": String("2.0"), "method": String("chain_get_state_root_hash"), "id": Number(1), } [/Users/ziel/workspace/odra/odra3/odra-casper/rpc-client/src/casper_client.rs:742:9] &request = Object { "jsonrpc": String("2.0"), "method": String("query_global_state"), "params": Object { "state_identifier": Object { "StateRootHash": String("e478a8fcaf6c7be34244dc643db1bc1b48857369c078f88191de74cf4b0d78a8"), }, "key": String("hash-b10cb500c1f46a086ffeab094993e8e0946c75ffaae2cfbdf92332cd2c0ae12b"), "path": Array [], }, "id": Number(1), } [/Users/ziel/workspace/odra/odra3/odra-casper/rpc-client/src/casper_client.rs:742:9] &request = Object { "jsonrpc": String("2.0"), "method": String("chain_get_state_root_hash"), "id": Number(1), } [/Users/ziel/workspace/odra/odra3/odra-casper/rpc-client/src/casper_client.rs:742:9] &request = Object { "jsonrpc": String("2.0"), "method": String("query_global_state"), "params": Object { "state_identifier": Object { "StateRootHash": String("e478a8fcaf6c7be34244dc643db1bc1b48857369c078f88191de74cf4b0d78a8"), }, "key": String("uref-3eda6dc6b8ab4bb06b1806310cb4165159883386bdf80bb3aca87b44860f994a-007"), "path": Array [], }, "id": Number(1), } [/Users/ziel/workspace/odra/odra3/odra-casper/rpc-client/src/casper_client.rs:742:9] &request = Object { "jsonrpc": String("2.0"), "method": String("chain_get_state_root_hash"), "id": Number(1), } [/Users/ziel/workspace/odra/odra3/odra-casper/rpc-client/src/casper_client.rs:742:9] &request = Object { "jsonrpc": String("2.0"), "method": String("query_global_state"), "params": Object { "state_identifier": Object { "StateRootHash": String("e478a8fcaf6c7be34244dc643db1bc1b48857369c078f88191de74cf4b0d78a8"), }, "key": String("hash-568fd396922fbbc8f8499f9b888795b2155aa60a68ef9cc38752b2771693a9ce"), "path": Array [], }, "id": Number(1), } [/Users/ziel/workspace/odra/odra3/odra-casper/rpc-client/src/casper_client.rs:742:9] &request = Object { "jsonrpc": String("2.0"), "method": String("chain_get_state_root_hash"), "id": Number(1), } [/Users/ziel/workspace/odra/odra3/odra-casper/rpc-client/src/casper_client.rs:742:9] &request = Object { "jsonrpc": String("2.0"), "method": String("query_global_state"), "params": Object { "state_identifier": Object { "StateRootHash": String("e478a8fcaf6c7be34244dc643db1bc1b48857369c078f88191de74cf4b0d78a8"), }, "key": String("hash-b10cb500c1f46a086ffeab094993e8e0946c75ffaae2cfbdf92332cd2c0ae12b"), "path": Array [], }, "id": Number(1), } [/Users/ziel/workspace/odra/odra3/odra-casper/rpc-client/src/casper_client.rs:742:9] &request = Object { "jsonrpc": String("2.0"), "method": String("chain_get_state_root_hash"), "id": Number(1), } [/Users/ziel/workspace/odra/odra3/odra-casper/rpc-client/src/casper_client.rs:742:9] &request = Object { "jsonrpc": String("2.0"), "method": String("query_global_state"), "params": Object { "state_identifier": Object { "StateRootHash": String("e478a8fcaf6c7be34244dc643db1bc1b48857369c078f88191de74cf4b0d78a8"), }, "key": String("uref-d68b26faf54e90ac363021c2844f93b87f9a3465d646046255cf1f8058191b03-007"), "path": Array [], }, "id": Number(1), }
I think all query_global_state's responses should be cached in map(query -> response)
query_global_state
map(query -> response)
Our
CasperClient
should cachestate_root_hash
to avoid quering it all the time. The cache should be purged after new deploys or after some time (like 5s).This are logs from loading the CEP18 token from the address and making
token.name()
call.