Tool to maintain Blockheaders/Transactions DB. Data is queried via RPC calls.
Table of Contents
To get this application runninng locally, follow these steps.
What you would need:
- Rust
https://www.rust-lang.org/tools/install
- Clone the repo
git clone https://github.com/OilerNetwork/fossil-headers-db.git
- Create a .env file in the project's root folder
fossil-headers-db/.env
DB_CONNECTION_STRING=<db_connection_string>
NODE_CONNECTION_STRING=<node_connection_string>
ROUTER_ENDPOINT=<router_endpoint_string>
RUST_LOG=<log_level> [optional]
- Build project
cargo build
Fetches blockheaders and transaction data via RPC and writes to DB.
Usage: cargo run update
Optional parameters:
- start <block_number>
-
First block number to start updating the database from. (Inclusive)
-
Default: Latest block in the database + 1
- end <block_number>
-
Last block number to update the database to. (Inclusive)
-
Default: Polling mode - updates to latest block, after which it polls for new blocks
- loopsize <num_threads>
-
Max number of threads running at once
-
Default: Max functional connections for our DB -- 4000 Examples:
cargo run update
cargo run update --loopsize 10
cargo run update --start 19983846
cargo run update --end 19983849
cargo run update -s 19983846 -e 19983849
cargo run update -s 19983846 -end 19983849 -l 100
Patches missing blockheaders and transaction data from the DB, retrieving via RPC
Usage: cargo run update
Optional parameters:
- start <block_number>
-
First block number to start checking the database from. (Inclusive)
-
Default: 0
- end <block_number>
-
Last block number to check the database to. (Inclusive)
-
Default: Last entry in the database
Examples:
cargo run fix
cargo run fix --start 19983846
cargo run fix --end 19983849
cargo run fix -s 19983846 -e 19983849
Used to ping server for alive status.
curl --location '<ROUTER_ENDPOINT>'
--header 'Content-Type: application/json'
Healthy
Retrieves the latest MMR state
curl --location '127.0.0.1:8080/mmr'
--header 'Content-Type: application/json'
{
"latest_blocknumber": 17992
"latest_roothash": "0x02e6baea3eba34b9c581bd719465a2181c5dc989891517add951ffb5b0d421f0",
"update_timestamp": "2024-08-02T05:24:06.928467Z"
}
Retrieve proof for the provided <blocknumber>
curl --location '127.0.0.1:8080/mmr/<blocknumber>'
--header 'Content-Type: application/json'
{
"peaks_hashes": "[\"0x5a0a7e39c749e1c03feaff0a6d8fca6181253d47c9aae3c6ddd0c0475a9c8a61\",\"0x04182373152d407f88a71a38960aa714e2b3a8988e3e3606e2ced21473e4a0c5\",\"0x2558950083d01e2a8a6699e44e3d97642586b3bde1d237a9d34c8d9d77178a22\",\"0x6a29cea580488bd512185f9cc16deec823dd58b85f1dd8408cc46c40f8ab10b8\",\"0x0d995a2bf7801bc7e56776bfc441b957d7959d662c5262405feb572be1928011\",\"0x1933e13bd7e5e4227b20a4f972a302eaad8da1fc0f455138d79af68da3c86e3f\",\"0x0a9b742073888cbd44e0b609aed502ccc8454d32b827e86f66181d6a7fa4a086\",\"0x7bef241cbe2dbbc2c04eb9431b2471b2678bc792bf460ec9d8b15882301f9da7\",\"0x8bd6d00cfe79edc41a17c724d965427d41ab865d58ce57690316ce368386080a\"]",
"element_index": "2",
"elements_count": "57113",
"element_hash": "0x88e96d4537bea4d9c05d12549907b32561d3bf31f45aae734cdc119f13406cb6",
"sibling_hashes": "[\"0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3\",\"0xabbd3abf1b19fd233c45ea4a2051369190b069f58f9c5fe8d016c461df048748\",\"0xa2ce5dd7d1a450b2e3ef0b41092b5a782d3090ac5d7f5257d82eb0ca67ba21ec\",\"0x09b3664e5f2495f402b45ae8b056a4e9c6beeafd44494aebcc671c0a337322ab\",\"0x84a1dee387cded87e6bee1382df8b40b363dd8212c96b18dff77da2df504db38\",\"0x8d970b7ad08cfc4ab69b323d941e80478a4c4fc99ee165c4e6525d3a1e46cda7\",\"0x5cba303c0aaf9f6bb48a7003bae08ae19b44732dc5d0366a127bdf4ee82c0d21\",\"0x520559e1f475be63069c022f59b99e9272dbbd8d2888635055d2b516539c8426\",\"0x6cb0b6aa14349728919cb59ccd3c0bb62721539202f4d5c42bfba1612a577de7\",\"0x2bf3c9d3a66d63d4b16e8ce7681ccbe7e382ef721001dac950088cfd2a3dfe5d\",\"0x66ba3f44720909e4ed0ba754efb13a1eb85fe6a1c80770441cc36d762108ee60\",\"0x3661b2303a69a0a960c4bb4e732daa56f44a57f95700e20ad1915866d18e1980\",\"0x044c1636b3a10f042b40ee3ee4ccd0156ddebd88d4daab1d2c68ed6d9918fa4c\",\"0xdee2ec7f050d0c19467f33e26363bfd869d5fa3847fd49bd1bb218469e92c7af\"]"
}