Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize livenet queries amount #472

Open
zie1ony opened this issue Jun 5, 2024 · 1 comment
Open

Optimize livenet queries amount #472

zie1ony opened this issue Jun 5, 2024 · 1 comment

Comments

@zie1ony
Copy link
Contributor

zie1ony commented Jun 5, 2024

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).

This are logs from loading the CEP18 token from the address and making token.name() call.

[/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),
}
@zie1ony
Copy link
Contributor Author

zie1ony commented Jun 5, 2024

I think all query_global_state's responses should be cached in map(query -> response)

@zie1ony zie1ony changed the title Cache state_root_hash. Optimize livenet Jun 12, 2024
@zie1ony zie1ony changed the title Optimize livenet Optimize livenet queries amount Jun 12, 2024
@zie1ony zie1ony moved this from 🆕 Discuss to 🔖 Ready in ⚔️Tavern 🐉 Jun 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 🔖 Ready
Development

No branches or pull requests

1 participant