From f85296761829d3ca26ec800df6bf630a6bb0af96 Mon Sep 17 00:00:00 2001 From: kalm Date: Tue, 18 Feb 2025 02:02:30 -0800 Subject: [PATCH] explorer: move explorer source code from research to bin/explorer for project releases This commit relocates the explorer code from the research directory to `bin/explorer` to include it as part of future releases. ### Summary of Updates: #### Darkfi Project - Updated `Cargo.toml` to include `bin/explorer/explorerd` as a workspace member - Updated `Cargo.lock` to include the `explorerd` package - Updated the `Makefile` to include `explorerd` in the build process #### Explorer Daemon - Renamed the project directory from `blockchain-explorer` to `explorer` - Moved the explorer daemon source code to `bin/explorer/explorerd` - Updated the cargo package name to `explorerd` - Updated log statement targets from `blockchain-explorer::` to `explorerd::` - Renamed the explorer configuration file to `explorerd_config.toml` - Removed Halo2 patches as they are now included in the root package - Changed default db_path to use explorerd instead of blockchain-explorer in the path - Changed binary crate Arg structopt name from blockchain-explorer to explorerd #### Explorer Site - Moved the explorer site source code to `bin/explorer/site` - Updated README.md to include new build instructions for explorerd --- Cargo.lock | 88 ++++++++++++++++++ Cargo.toml | 1 + Makefile | 11 ++- bin/explorer/explorerd/.gitignore | 1 + .../explorer/explorerd}/Cargo.toml | 8 +- .../explorer/explorerd}/Makefile | 9 +- .../explorer/explorerd/explorerd_config.toml | 4 +- .../explorer/explorerd}/src/blocks.rs | 14 +-- .../explorerd}/src/contract_meta_store.rs | 0 .../explorer/explorerd}/src/contracts.rs | 0 .../explorer/explorerd}/src/error.rs | 2 +- .../explorer/explorerd}/src/main.rs | 48 +++++----- .../explorer/explorerd}/src/metrics_store.rs | 0 .../explorer/explorerd}/src/rpc.rs | 12 +-- .../explorer/explorerd}/src/rpc_blocks.rs | 54 +++++------ .../explorer/explorerd}/src/rpc_contracts.rs | 0 .../explorer/explorerd}/src/rpc_statistics.rs | 6 +- .../explorerd}/src/rpc_transactions.rs | 4 +- .../explorer/explorerd}/src/statistics.rs | 0 .../explorer/explorerd}/src/test_utils/mod.rs | 0 .../explorer/explorerd}/src/transactions.rs | 2 +- .../explorer}/site/.gitignore | 0 .../explorer}/site/README.md | 11 ++- .../explorer}/site/app.py | 0 .../explorer}/site/blueprints/__init__.py | 0 .../explorer}/site/blueprints/block.py | 0 .../explorer}/site/blueprints/contract.py | 0 .../explorer}/site/blueprints/explore.py | 0 .../explorer}/site/blueprints/transaction.py | 0 .../explorer}/site/requirements.txt | 0 .../explorer}/site/rpc.py | 0 .../explorer}/site/static/bootstrap.min.css | 0 .../site/static/font-files/Chomsky.otf | Bin .../site/static/font-files/Chomsky.woff | Bin .../site/static/font-files/Chomsky.woff2 | Bin .../font-files/IBMPlexMonoExtraLight.otf | Bin .../font-files/IBMPlexMonoExtraLight.woff | Bin .../font-files/IBMPlexMonoExtraLight.woff2 | Bin .../font-files/IBMPlexSansArabic-Regular.woff | Bin .../IBMPlexSansArabic-Regular.woff2 | Bin .../site/static/font-files/Inter-Bold.woff | Bin .../static/font-files/Inter-BoldItalic.woff | Bin .../site/static/font-files/Inter-Italic.woff | Bin .../site/static/font-files/Inter-Regular.woff | Bin .../static/font-files/Inter-SemiBold.woff | Bin .../font-files/Inter-SemiBoldItalic.woff | Bin .../static/font-files/InterDisplay-Black.woff | Bin .../font-files/InterDisplay-BlackItalic.woff | Bin .../font-files/InterDisplay-ExtraLight.woff | Bin .../font-files/InterDisplay-ExtraLight.woff2 | Bin .../site/static/font-files/ReemKufi-Bold.woff | Bin .../static/font-files/ReemKufi-Bold.woff2 | Bin .../font-files/weissrundgotisch.regular.woff | Bin .../font-files/weissrundgotisch.regular.woff2 | Bin .../explorer}/site/static/img/darkfi.svg | 0 .../explorer}/site/static/img/darkfi05.jpg | Bin .../explorer}/site/static/img/darkfi25.jpg | Bin .../explorer}/site/static/img/icon.png | Bin .../explorer}/site/static/img/sunset2.png | Bin .../explorer}/site/static/style.css | 0 .../explorer}/site/templates/404.html | 0 .../explorer}/site/templates/500.html | 0 .../explorer}/site/templates/base.html | 0 .../explorer}/site/templates/block.html | 0 .../site/templates/contract_source.html | 0 .../site/templates/contract_source_list.html | 0 .../explorer}/site/templates/index.html | 0 .../explorer}/site/templates/transaction.html | 0 .../research/blockchain-explorer/.gitignore | 5 - 69 files changed, 185 insertions(+), 95 deletions(-) create mode 100644 bin/explorer/explorerd/.gitignore rename {script/research/blockchain-explorer => bin/explorer/explorerd}/Cargo.toml (82%) rename {script/research/blockchain-explorer => bin/explorer/explorerd}/Makefile (88%) rename script/research/blockchain-explorer/blockchain_explorer_config.toml => bin/explorer/explorerd/explorerd_config.toml (80%) rename {script/research/blockchain-explorer => bin/explorer/explorerd}/src/blocks.rs (93%) rename {script/research/blockchain-explorer => bin/explorer/explorerd}/src/contract_meta_store.rs (100%) rename {script/research/blockchain-explorer => bin/explorer/explorerd}/src/contracts.rs (100%) rename {script/research/blockchain-explorer => bin/explorer/explorerd}/src/error.rs (96%) rename {script/research/blockchain-explorer => bin/explorer/explorerd}/src/main.rs (86%) rename {script/research/blockchain-explorer => bin/explorer/explorerd}/src/metrics_store.rs (100%) rename {script/research/blockchain-explorer => bin/explorer/explorerd}/src/rpc.rs (88%) rename {script/research/blockchain-explorer => bin/explorer/explorerd}/src/rpc_blocks.rs (85%) rename {script/research/blockchain-explorer => bin/explorer/explorerd}/src/rpc_contracts.rs (100%) rename {script/research/blockchain-explorer => bin/explorer/explorerd}/src/rpc_statistics.rs (92%) rename {script/research/blockchain-explorer => bin/explorer/explorerd}/src/rpc_transactions.rs (92%) rename {script/research/blockchain-explorer => bin/explorer/explorerd}/src/statistics.rs (100%) rename {script/research/blockchain-explorer => bin/explorer/explorerd}/src/test_utils/mod.rs (100%) rename {script/research/blockchain-explorer => bin/explorer/explorerd}/src/transactions.rs (99%) rename {script/research/blockchain-explorer => bin/explorer}/site/.gitignore (100%) rename {script/research/blockchain-explorer => bin/explorer}/site/README.md (76%) rename {script/research/blockchain-explorer => bin/explorer}/site/app.py (100%) rename {script/research/blockchain-explorer => bin/explorer}/site/blueprints/__init__.py (100%) rename {script/research/blockchain-explorer => bin/explorer}/site/blueprints/block.py (100%) rename {script/research/blockchain-explorer => bin/explorer}/site/blueprints/contract.py (100%) rename {script/research/blockchain-explorer => bin/explorer}/site/blueprints/explore.py (100%) rename {script/research/blockchain-explorer => bin/explorer}/site/blueprints/transaction.py (100%) rename {script/research/blockchain-explorer => bin/explorer}/site/requirements.txt (100%) rename {script/research/blockchain-explorer => bin/explorer}/site/rpc.py (100%) rename {script/research/blockchain-explorer => bin/explorer}/site/static/bootstrap.min.css (100%) rename {script/research/blockchain-explorer => bin/explorer}/site/static/font-files/Chomsky.otf (100%) rename {script/research/blockchain-explorer => bin/explorer}/site/static/font-files/Chomsky.woff (100%) rename {script/research/blockchain-explorer => bin/explorer}/site/static/font-files/Chomsky.woff2 (100%) rename {script/research/blockchain-explorer => bin/explorer}/site/static/font-files/IBMPlexMonoExtraLight.otf (100%) rename {script/research/blockchain-explorer => bin/explorer}/site/static/font-files/IBMPlexMonoExtraLight.woff (100%) rename {script/research/blockchain-explorer => bin/explorer}/site/static/font-files/IBMPlexMonoExtraLight.woff2 (100%) rename {script/research/blockchain-explorer => bin/explorer}/site/static/font-files/IBMPlexSansArabic-Regular.woff (100%) rename {script/research/blockchain-explorer => bin/explorer}/site/static/font-files/IBMPlexSansArabic-Regular.woff2 (100%) rename {script/research/blockchain-explorer => bin/explorer}/site/static/font-files/Inter-Bold.woff (100%) rename {script/research/blockchain-explorer => bin/explorer}/site/static/font-files/Inter-BoldItalic.woff (100%) rename {script/research/blockchain-explorer => bin/explorer}/site/static/font-files/Inter-Italic.woff (100%) rename {script/research/blockchain-explorer => bin/explorer}/site/static/font-files/Inter-Regular.woff (100%) rename {script/research/blockchain-explorer => bin/explorer}/site/static/font-files/Inter-SemiBold.woff (100%) rename {script/research/blockchain-explorer => bin/explorer}/site/static/font-files/Inter-SemiBoldItalic.woff (100%) rename {script/research/blockchain-explorer => bin/explorer}/site/static/font-files/InterDisplay-Black.woff (100%) rename {script/research/blockchain-explorer => bin/explorer}/site/static/font-files/InterDisplay-BlackItalic.woff (100%) rename {script/research/blockchain-explorer => bin/explorer}/site/static/font-files/InterDisplay-ExtraLight.woff (100%) rename {script/research/blockchain-explorer => bin/explorer}/site/static/font-files/InterDisplay-ExtraLight.woff2 (100%) rename {script/research/blockchain-explorer => bin/explorer}/site/static/font-files/ReemKufi-Bold.woff (100%) rename {script/research/blockchain-explorer => bin/explorer}/site/static/font-files/ReemKufi-Bold.woff2 (100%) rename {script/research/blockchain-explorer => bin/explorer}/site/static/font-files/weissrundgotisch.regular.woff (100%) rename {script/research/blockchain-explorer => bin/explorer}/site/static/font-files/weissrundgotisch.regular.woff2 (100%) rename {script/research/blockchain-explorer => bin/explorer}/site/static/img/darkfi.svg (100%) rename {script/research/blockchain-explorer => bin/explorer}/site/static/img/darkfi05.jpg (100%) rename {script/research/blockchain-explorer => bin/explorer}/site/static/img/darkfi25.jpg (100%) rename {script/research/blockchain-explorer => bin/explorer}/site/static/img/icon.png (100%) rename {script/research/blockchain-explorer => bin/explorer}/site/static/img/sunset2.png (100%) rename {script/research/blockchain-explorer => bin/explorer}/site/static/style.css (100%) rename {script/research/blockchain-explorer => bin/explorer}/site/templates/404.html (100%) rename {script/research/blockchain-explorer => bin/explorer}/site/templates/500.html (100%) rename {script/research/blockchain-explorer => bin/explorer}/site/templates/base.html (100%) rename {script/research/blockchain-explorer => bin/explorer}/site/templates/block.html (100%) rename {script/research/blockchain-explorer => bin/explorer}/site/templates/contract_source.html (100%) rename {script/research/blockchain-explorer => bin/explorer}/site/templates/contract_source_list.html (100%) rename {script/research/blockchain-explorer => bin/explorer}/site/templates/index.html (100%) rename {script/research/blockchain-explorer => bin/explorer}/site/templates/transaction.html (100%) delete mode 100644 script/research/blockchain-explorer/.gitignore diff --git a/Cargo.lock b/Cargo.lock index 4e724ae08..2a7ee1a7c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3102,6 +3102,32 @@ dependencies = [ "pin-project-lite 0.2.16", ] +[[package]] +name = "explorerd" +version = "0.4.1" +dependencies = [ + "async-trait", + "darkfi", + "darkfi-sdk", + "darkfi-serial", + "drk", + "easy-parallel", + "lazy_static", + "log", + "serde", + "signal-hook", + "signal-hook-async-std", + "simplelog", + "sled-overlay", + "smol", + "structopt", + "structopt-toml", + "tar", + "tempdir", + "tinyjson", + "url", +] + [[package]] name = "fallible-iterator" version = "0.3.0" @@ -3405,6 +3431,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "fuchsia-cprng" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" + [[package]] name = "funty" version = "2.0.0" @@ -5938,6 +5970,19 @@ dependencies = [ "ptr_meta 0.3.0", ] +[[package]] +name = "rand" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293" +dependencies = [ + "fuchsia-cprng", + "libc", + "rand_core 0.3.1", + "rdrand", + "winapi", +] + [[package]] name = "rand" version = "0.7.3" @@ -5982,6 +6027,21 @@ dependencies = [ "rand_core 0.6.4", ] +[[package]] +name = "rand_core" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" +dependencies = [ + "rand_core 0.4.2", +] + +[[package]] +name = "rand_core" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" + [[package]] name = "rand_core" version = "0.5.1" @@ -6059,6 +6119,15 @@ dependencies = [ "yasna", ] +[[package]] +name = "rdrand" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" +dependencies = [ + "rand_core 0.3.1", +] + [[package]] name = "redox_syscall" version = "0.2.16" @@ -6168,6 +6237,15 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "remove_dir_all" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" +dependencies = [ + "winapi", +] + [[package]] name = "rend" version = "0.5.2" @@ -7521,6 +7599,16 @@ dependencies = [ "url", ] +[[package]] +name = "tempdir" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15f2b5fb00ccdf689e0149d1b1b3c03fead81c2b37735d812fa8bddbbf41b6d8" +dependencies = [ + "rand 0.4.6", + "remove_dir_all", +] + [[package]] name = "tempfile" version = "3.17.1" diff --git a/Cargo.toml b/Cargo.toml index 602dcccf6..dfb93b3a5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,6 +23,7 @@ members = [ "bin/zkas", "bin/darkfid", "bin/minerd", + "bin/explorer/explorerd", "bin/darkfi-mmproxy", "bin/drk", #"bin/fud/fu", diff --git a/Makefile b/Makefile index d5a94749c..792b755a2 100644 --- a/Makefile +++ b/Makefile @@ -30,7 +30,8 @@ BINS = \ genevd \ lilith \ taud \ - vanityaddr + vanityaddr \ + explorerd all: $(BINS) @@ -119,6 +120,13 @@ vanityaddr: RUST_TARGET="$(RUST_TARGET)" \ RUSTFLAGS="$(RUSTFLAGS)" +explorerd: + $(MAKE) -C bin/explorer/$@ \ + PREFIX="$(PREFIX)" \ + CARGO="$(CARGO)" \ + RUST_TARGET="$(RUST_TARGET)" \ + RUSTFLAGS="$(RUSTFLAGS)" + # -- END OF BINS -- fmt: @@ -176,6 +184,7 @@ clean: $(MAKE) -C bin/lilith clean $(MAKE) -C bin/tau/taud clean $(MAKE) -C bin/vanityaddr clean + $(MAKE) -C bin/explorer/explorerd RUSTFLAGS="$(RUSTFLAGS)" $(CARGO) clean --target=$(RUST_TARGET) --release rm -f $(PROOFS_BIN) diff --git a/bin/explorer/explorerd/.gitignore b/bin/explorer/explorerd/.gitignore new file mode 100644 index 000000000..d2da95e1b --- /dev/null +++ b/bin/explorer/explorerd/.gitignore @@ -0,0 +1 @@ +/native_contracts_src \ No newline at end of file diff --git a/script/research/blockchain-explorer/Cargo.toml b/bin/explorer/explorerd/Cargo.toml similarity index 82% rename from script/research/blockchain-explorer/Cargo.toml rename to bin/explorer/explorerd/Cargo.toml index ec8a25c96..36ee38f0f 100644 --- a/script/research/blockchain-explorer/Cargo.toml +++ b/bin/explorer/explorerd/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "blockchain-explorer" +name = "explorerd" version = "0.4.1" description = "Daemon to listen for new blocks from darkfid and store them in an easily accessible format for further usage." authors = ["Dyne.org foundation "] @@ -7,8 +7,6 @@ repository = "https://codeberg.org/darkrenaissance/darkfi" license = "AGPL-3.0-only" edition = "2021" -[workspace] - [dependencies] # Darkfi darkfi = {path = "../../../", features = ["async-daemonize", "validator"]} @@ -43,7 +41,3 @@ tar = "0.4.43" # Testing tempdir = "0.3.7" - -[patch.crates-io] -halo2_proofs = {git="https://github.com/parazyd/halo2", branch="v4"} -halo2_gadgets = {git="https://github.com/parazyd/halo2", branch="v4"} diff --git a/script/research/blockchain-explorer/Makefile b/bin/explorer/explorerd/Makefile similarity index 88% rename from script/research/blockchain-explorer/Makefile rename to bin/explorer/explorerd/Makefile index b214e7ff1..4d7c972b6 100644 --- a/script/research/blockchain-explorer/Makefile +++ b/bin/explorer/explorerd/Makefile @@ -19,13 +19,12 @@ SRC = \ BIN = $(shell grep '^name = ' Cargo.toml | sed 1q | cut -d' ' -f3 | tr -d '"') -all: $(BIN) bundle_contracts_src +all: $(BIN) -$(BIN): $(SRC) +$(BIN): $(SRC) bundle_contracts_src RUSTFLAGS="$(RUSTFLAGS)" $(CARGO) build --target=$(RUST_TARGET) --release --package $@ - # TODO: Update target path to darkfi project workspace once explorer is transitioned to bin - cp -f target/$(RUST_TARGET)/release/$@ $@ - cp -f target/$(RUST_TARGET)/release/$@ ../../../$@ + cp -f ../../../target/$(RUST_TARGET)/release/$@ $@ + cp -f ../../../target/$(RUST_TARGET)/release/$@ ../../../$@ clean: RUSTFLAGS="$(RUSTFLAGS)" $(CARGO) clean --target=$(RUST_TARGET) --release --package $(BIN) diff --git a/script/research/blockchain-explorer/blockchain_explorer_config.toml b/bin/explorer/explorerd/explorerd_config.toml similarity index 80% rename from script/research/blockchain-explorer/blockchain_explorer_config.toml rename to bin/explorer/explorerd/explorerd_config.toml index 472fc7900..3d5663231 100644 --- a/script/research/blockchain-explorer/blockchain_explorer_config.toml +++ b/bin/explorer/explorerd/explorerd_config.toml @@ -1,4 +1,4 @@ -## blockchain-explorer configuration file +## explorerd configuration file ## ## Please make sure you go through all the settings so you can configure ## your daemon properly. @@ -10,7 +10,7 @@ rpc_listen = "tcp://127.0.0.1:14567" # Path to daemon database -db_path = "~/.local/share/darkfi/blockchain-explorer/daemon.db" +db_path = "~/.local/share/darkfi/explorerd/daemon.db" # Password for the daemon database db_pass = "changeme" diff --git a/script/research/blockchain-explorer/src/blocks.rs b/bin/explorer/explorerd/src/blocks.rs similarity index 93% rename from script/research/blockchain-explorer/src/blocks.rs rename to bin/explorer/explorerd/src/blocks.rs index f8ae654c8..09028d5d0 100644 --- a/script/research/blockchain-explorer/src/blocks.rs +++ b/bin/explorer/explorerd/src/blocks.rs @@ -96,7 +96,7 @@ impl ExplorerService { let tree = db.open_tree(tree_name)?; tree.clear()?; let tree_name_str = std::str::from_utf8(tree_name)?; - debug!(target: "blockchain-explorer::blocks", "Successfully reset block tree: {tree_name_str}"); + debug!(target: "explorerd::blocks", "Successfully reset block tree: {tree_name_str}"); } Ok(()) @@ -136,7 +136,7 @@ impl ExplorerService { // Add the block and commit the changes to persist it let _ = blockchain_overlay.lock().unwrap().add_block(block)?; blockchain_overlay.lock().unwrap().overlay.lock().unwrap().apply()?; - debug!(target: "blockchain_explorer::blocks::put_block", "Added block {:?}", block); + debug!(target: "explorerd::blocks::put_block", "Added block {:?}", block); Ok(()) } @@ -247,7 +247,7 @@ impl ExplorerService { let block_store = &self.db.blockchain.blocks; let tx_store = &self.db.blockchain.transactions; - debug!(target: "blockchain_explorer::blocks::reset_to_height", "Resetting to height {reset_height}: block_count={}, txs_count={}", block_store.len(), tx_store.len()); + debug!(target: "explorerd::blocks::reset_to_height", "Resetting to height {reset_height}: block_count={}, txs_count={}", block_store.len(), tx_store.len()); // Get the last block height let (last_block_height, _) = block_store.get_last().map_err(|e| { @@ -258,7 +258,7 @@ impl ExplorerService { // Skip resetting blocks if `reset_height` is greater than or equal to `last_block_height` if reset_height >= last_block_height { - warn!(target: "blockchain_explorer::blocks::reset_to_height", + warn!(target: "explorerd::blocks::reset_to_height", "Nothing to reset because reset_height is greater than or equal to last_block_height: {reset_height} >= {last_block_height}"); return Ok(()); } @@ -299,7 +299,7 @@ impl ExplorerService { block_order.remove(&height_key).map_err(ConflictableTransactionError::Abort)?; } - debug!(target: "blockchain_explorer::blocks::reset_to_height", "Removed block at height: {height}"); + debug!(target: "explorerd::blocks::reset_to_height", "Removed block at height: {height}"); } // Iterate through the transaction hashes, removing the related transactions @@ -308,7 +308,7 @@ impl ExplorerService { tx_main.remove(tx_hash.inner()).map_err(ConflictableTransactionError::Abort)?; // Remove transaction from the `location` tree tx_location.remove(tx_hash.inner()).map_err(ConflictableTransactionError::Abort)?; - debug!(target: "blockchain_explorer::blocks::reset_to_height", "Removed transaction ({tx_count}): {tx_hash}"); + debug!(target: "explorerd::blocks::reset_to_height", "Removed transaction ({tx_count}): {tx_hash}"); } Ok(()) @@ -317,7 +317,7 @@ impl ExplorerService { Error::DatabaseError(format!("[reset_to_height]: Resetting height failed: {e:?}")) }); - debug!(target: "blockchain_explorer::blocks::reset_to_height", "Successfully reset to height {reset_height}: block_count={}, txs_count={}", block_store.len(), tx_store.len()); + debug!(target: "explorerd::blocks::reset_to_height", "Successfully reset to height {reset_height}: block_count={}, txs_count={}", block_store.len(), tx_store.len()); tx_result } diff --git a/script/research/blockchain-explorer/src/contract_meta_store.rs b/bin/explorer/explorerd/src/contract_meta_store.rs similarity index 100% rename from script/research/blockchain-explorer/src/contract_meta_store.rs rename to bin/explorer/explorerd/src/contract_meta_store.rs diff --git a/script/research/blockchain-explorer/src/contracts.rs b/bin/explorer/explorerd/src/contracts.rs similarity index 100% rename from script/research/blockchain-explorer/src/contracts.rs rename to bin/explorer/explorerd/src/contracts.rs diff --git a/script/research/blockchain-explorer/src/error.rs b/bin/explorer/explorerd/src/error.rs similarity index 96% rename from script/research/blockchain-explorer/src/error.rs rename to bin/explorer/explorerd/src/error.rs index da43de208..7b845cd97 100644 --- a/script/research/blockchain-explorer/src/error.rs +++ b/bin/explorer/explorerd/src/error.rs @@ -53,7 +53,7 @@ pub fn server_error(e: RpcError, id: u16, msg: Option<&str>) -> JsonResult { /// and returning a [`DatabaseError`]. pub fn handle_database_error(target: &str, message: &str, error: impl std::fmt::Debug) -> Error { let error_message = format!("{}: {:?}", message, error); - let formatted_target = format!("blockchain-explorer:: {target}"); + let formatted_target = format!("explorerd:: {target}"); error!(target: &formatted_target, "{}", error_message); Error::DatabaseError(error_message) } diff --git a/script/research/blockchain-explorer/src/main.rs b/bin/explorer/explorerd/src/main.rs similarity index 86% rename from script/research/blockchain-explorer/src/main.rs rename to bin/explorer/explorerd/src/main.rs index 4327c64b5..58ce88186 100644 --- a/script/research/blockchain-explorer/src/main.rs +++ b/bin/explorer/explorerd/src/main.rs @@ -82,8 +82,8 @@ mod metrics_store; /// Database store functionality related to contract metadata mod contract_meta_store; -const CONFIG_FILE: &str = "blockchain_explorer_config.toml"; -const CONFIG_FILE_CONTENTS: &str = include_str!("../blockchain_explorer_config.toml"); +const CONFIG_FILE: &str = "explorerd_config.toml"; +const CONFIG_FILE_CONTENTS: &str = include_str!("../explorerd_config.toml"); // Load the contract source archives to bootstrap them on explorer startup lazy_static! { @@ -107,7 +107,7 @@ lazy_static! { #[derive(Clone, Debug, Deserialize, StructOpt, StructOptToml)] #[serde(default)] -#[structopt(name = "blockchain-explorer", about = cli_desc!())] +#[structopt(name = "explorerd", about = cli_desc!())] struct Args { #[structopt(short, long)] /// Configuration file to use @@ -117,7 +117,7 @@ struct Args { /// JSON-RPC listen URL rpc_listen: Url, - #[structopt(long, default_value = "~/.local/share/darkfi/blockchain-explorer/daemon.db")] + #[structopt(long, default_value = "~/.local/share/darkfi/explorerd/daemon.db")] /// Path to daemon database db_path: String, @@ -232,7 +232,7 @@ impl ExplorerService { /// transactions up to the reset height, ensuring consistency. Returns a result indicating /// success or an error if the operation fails. pub fn reset_explorer_state(&self, height: u32) -> Result<()> { - debug!(target: "blockchain-explorer::reset_explorer_state", "Resetting explorer state to height: {height}"); + debug!(target: "explorerd::reset_explorer_state", "Resetting explorer state to height: {height}"); // Check if a genesis block reset or to a specific height match height { @@ -240,18 +240,18 @@ impl ExplorerService { 0 => { self.reset_blocks()?; self.reset_transactions()?; - debug!(target: "blockchain-explorer::reset_explorer_state", "Successfully reset explorer state to accept a new genesis block"); + debug!(target: "explorerd::reset_explorer_state", "Successfully reset explorer state to accept a new genesis block"); } // Reset for all other heights _ => { self.reset_to_height(height)?; - debug!(target: "blockchain-explorer::reset_explorer_state", "Successfully reset blocks to height: {height}"); + debug!(target: "explorerd::reset_explorer_state", "Successfully reset blocks to height: {height}"); } } // Reset gas metrics to the specified height to reflect the updated blockchain state self.db.metrics_store.reset_gas_metrics(height)?; - debug!(target: "blockchain-explorer::reset_explorer_state", "Successfully reset metrics store to height: {height}"); + debug!(target: "explorerd::reset_explorer_state", "Successfully reset metrics store to height: {height}"); Ok(()) } @@ -279,7 +279,7 @@ impl ExplorerDb { let blockchain = Blockchain::new(&sled_db)?; let metrics_store = MetricsStore::new(&sled_db)?; let contract_meta_store = ContractMetaStore::new(&sled_db)?; - info!(target: "blockchain-explorer", "Initialized explorer database {}: block count: {}, tx count: {}", db_path.display(), blockchain.len(), blockchain.txs_len()); + info!(target: "explorerd", "Initialized explorer database {}: block count: {}, tx count: {}", db_path.display(), blockchain.len(), blockchain.txs_len()); Ok(Self { sled_db, blockchain, metrics_store, contract_meta_store }) } } @@ -307,7 +307,7 @@ impl Explorerd { async fn new(db_path: String, endpoint: Url, ex: Arc>) -> Result { // Initialize rpc client let rpc_client = RpcClient::new(endpoint.clone(), ex).await?; - info!(target: "blockchain-explorer", "Created rpc client: {:?}", endpoint); + info!(target: "explorerd", "Created rpc client: {:?}", endpoint); // Create explorer service let service = ExplorerService::new(db_path)?; @@ -321,13 +321,13 @@ impl Explorerd { async_daemonize!(realmain); async fn realmain(args: Args, ex: Arc>) -> Result<()> { - info!(target: "blockchain-explorer", "Initializing DarkFi blockchain explorer node..."); + info!(target: "explorerd", "Initializing DarkFi blockchain explorer node..."); let explorer = Explorerd::new(args.db_path, args.endpoint.clone(), ex.clone()).await?; let explorer = Arc::new(explorer); - info!(target: "blockchain-explorer", "Node initialized successfully!"); + info!(target: "explorerd", "Node initialized successfully!"); // JSON-RPC server - info!(target: "blockchain-explorer", "Starting JSON-RPC server"); + info!(target: "explorerd", "Starting JSON-RPC server"); // Here we create a task variable so we can manually close the task later. let rpc_task = StoppableTask::new(); let explorer_ = explorer.clone(); @@ -336,7 +336,9 @@ async fn realmain(args: Args, ex: Arc>) -> Result<()> { |res| async move { match res { Ok(()) | Err(Error::RpcServerStopped) => explorer_.stop_connections().await, - Err(e) => error!(target: "blockchain-explorer", "Failed starting sync JSON-RPC server: {}", e), + Err(e) => { + error!(target: "explorerd", "Failed starting sync JSON-RPC server: {}", e) + } } }, Error::RpcServerStopped, @@ -344,21 +346,21 @@ async fn realmain(args: Args, ex: Arc>) -> Result<()> { ); // Sync blocks - info!(target: "blockchain-explorer", "Syncing blocks from darkfid..."); + info!(target: "explorerd", "Syncing blocks from darkfid..."); if let Err(e) = explorer.sync_blocks(args.reset).await { let error_message = format!("Error syncing blocks: {:?}", e); - error!(target: "blockchain-explorer", "{error_message}"); + error!(target: "explorerd", "{error_message}"); return Err(Error::DatabaseError(error_message)); } // Subscribe blocks - info!(target: "blockchain-explorer", "Subscribing to new blocks..."); + info!(target: "explorerd", "Subscribing to new blocks..."); let (subscriber_task, listener_task) = match subscribe_blocks(explorer.clone(), args.endpoint, ex.clone()).await { Ok(pair) => pair, Err(e) => { let error_message = format!("Error setting up blocks subscriber: {:?}", e); - error!(target: "blockchain-explorer", "{error_message}"); + error!(target: "explorerd", "{error_message}"); return Err(Error::DatabaseError(error_message)); } }; @@ -366,18 +368,18 @@ async fn realmain(args: Args, ex: Arc>) -> Result<()> { // Signal handling for graceful termination. let (signals_handler, signals_task) = SignalHandler::new(ex)?; signals_handler.wait_termination(signals_task).await?; - info!(target: "blockchain-explorer", "Caught termination signal, cleaning up and exiting..."); + info!(target: "explorerd", "Caught termination signal, cleaning up and exiting..."); - info!(target: "blockchain-explorer", "Stopping JSON-RPC server..."); + info!(target: "explorerd", "Stopping JSON-RPC server..."); rpc_task.stop().await; - info!(target: "blockchain-explorer", "Stopping darkfid listener..."); + info!(target: "explorerd", "Stopping darkfid listener..."); listener_task.stop().await; - info!(target: "blockchain-explorer", "Stopping darkfid subscriber..."); + info!(target: "explorerd", "Stopping darkfid subscriber..."); subscriber_task.stop().await; - info!(target: "blockchain-explorer", "Stopping JSON-RPC client..."); + info!(target: "explorerd", "Stopping JSON-RPC client..."); explorer.rpc_client.stop().await; Ok(()) diff --git a/script/research/blockchain-explorer/src/metrics_store.rs b/bin/explorer/explorerd/src/metrics_store.rs similarity index 100% rename from script/research/blockchain-explorer/src/metrics_store.rs rename to bin/explorer/explorerd/src/metrics_store.rs diff --git a/script/research/blockchain-explorer/src/rpc.rs b/bin/explorer/explorerd/src/rpc.rs similarity index 88% rename from script/research/blockchain-explorer/src/rpc.rs rename to bin/explorer/explorerd/src/rpc.rs index 347cf41e8..0887e51c1 100644 --- a/script/research/blockchain-explorer/src/rpc.rs +++ b/bin/explorer/explorerd/src/rpc.rs @@ -40,7 +40,7 @@ use crate::{ #[async_trait] impl RequestHandler<()> for Explorerd { async fn handle_request(&self, req: JsonRequest) -> JsonResult { - debug!(target: "blockchain-explorer::rpc", "--> {}", req.stringify().unwrap()); + debug!(target: "explorerd::rpc", "--> {}", req.stringify().unwrap()); match req.method.as_str() { // ===================== @@ -113,9 +113,9 @@ impl Explorerd { // --> {"jsonrpc": "2.0", "method": "ping_darkfid", "params": [], "id": 1} // <-- {"jsonrpc": "2.0", "result": "true", "id": 1} async fn ping_darkfid(&self, id: u16, _params: JsonValue) -> JsonResult { - debug!(target: "blockchain-explorer::rpc::ping_darkfid", "Pinging darkfid daemon..."); + debug!(target: "explorerd::rpc::ping_darkfid", "Pinging darkfid daemon..."); if let Err(e) = self.darkfid_daemon_request("ping", &JsonValue::Array(vec![])).await { - error!(target: "blockchain-explorer::rpc::ping_darkfid", "Failed to ping darkfid daemon: {}", e); + error!(target: "explorerd::rpc::ping_darkfid", "Failed to ping darkfid daemon: {}", e); return server_error(RpcError::PingFailed, id, None) } JsonResponse::new(JsonValue::Boolean(true), id).into() @@ -127,13 +127,13 @@ impl Explorerd { method: &str, params: &JsonValue, ) -> Result { - debug!(target: "blockchain-explorer::rpc::darkfid_daemon_request", "Executing request {} with params: {:?}", method, params); + debug!(target: "explorerd::rpc::darkfid_daemon_request", "Executing request {} with params: {:?}", method, params); let latency = Instant::now(); let req = JsonRequest::new(method, params.clone()); let rep = self.rpc_client.request(req).await?; let latency = latency.elapsed(); - trace!(target: "blockchain-explorer::rpc::darkfid_daemon_request", "Got reply: {:?}", rep); - debug!(target: "blockchain-explorer::rpc::darkfid_daemon_request", "Latency: {:?}", latency); + trace!(target: "explorerd::rpc::darkfid_daemon_request", "Got reply: {:?}", rep); + debug!(target: "explorerd::rpc::darkfid_daemon_request", "Latency: {:?}", latency); Ok(rep) } } diff --git a/script/research/blockchain-explorer/src/rpc_blocks.rs b/bin/explorer/explorerd/src/rpc_blocks.rs similarity index 85% rename from script/research/blockchain-explorer/src/rpc_blocks.rs rename to bin/explorer/explorerd/src/rpc_blocks.rs index be24782c8..400b10fb4 100644 --- a/script/research/blockchain-explorer/src/rpc_blocks.rs +++ b/bin/explorer/explorerd/src/rpc_blocks.rs @@ -84,8 +84,8 @@ impl Explorerd { // Declare a mutable variable to track the current sync height while processing blocks let mut current_height = last_synced_height; - info!(target: "blockchain-explorer::rpc_blocks::sync_blocks", "Requested to sync from block number: {current_height}"); - info!(target: "blockchain-explorer::rpc_blocks::sync_blocks", "Last confirmed block number reported by darkfid: {last_darkfid_height} - {last_darkfid_hash}"); + info!(target: "explorerd::rpc_blocks::sync_blocks", "Requested to sync from block number: {current_height}"); + info!(target: "explorerd::rpc_blocks::sync_blocks", "Last confirmed block number reported by darkfid: {last_darkfid_height} - {last_darkfid_hash}"); // A reorg is detected if the hash of the last synced block differs from the hash of the last confirmed block, // unless the reset flag is set or the current height is 0 @@ -96,13 +96,13 @@ impl Explorerd { if reset { self.service.reset_explorer_state(0)?; current_height = 0; - info!(target: "blockchain-explorer::rpc_blocks::sync_blocks", "Successfully reset explorer database based on set reset parameter"); + info!(target: "explorerd::rpc_blocks::sync_blocks", "Successfully reset explorer database based on set reset parameter"); } else if reorg_detected { current_height = self.process_sync_blocks_reorg(last_synced_height, last_darkfid_height).await?; // Log only if a reorg occurred if current_height != last_synced_height { - info!(target: "blockchain-explorer::rpc_blocks::sync_blocks", "Successfully completed reorg to height: {current_height}"); + info!(target: "explorerd::rpc_blocks::sync_blocks", "Successfully completed reorg to height: {current_height}"); } // Prepare to sync the next block after reorg current_height += 1; @@ -134,13 +134,13 @@ impl Explorerd { )) }; - info!(target: "blockchain-explorer::rpc_blocks::sync_blocks", "Synced block {current_height}"); + info!(target: "explorerd::rpc_blocks::sync_blocks", "Synced block {current_height}"); // Increment the current height to sync the next block current_height += 1; } - info!(target: "blockchain-explorer::rpc_blocks::sync_blocks", "Completed sync, total number of explorer blocks: {}", self.service.db.blockchain.blocks.len()); + info!(target: "explorerd::rpc_blocks::sync_blocks", "Completed sync, total number of explorer blocks: {}", self.service.db.blockchain.blocks.len()); Ok(()) } @@ -164,7 +164,7 @@ impl Explorerd { ) -> Result { // Log reorg detection in the case that explorer height is greater or equal to height of darkfi node if last_synced_height >= last_darkfid_height { - info!(target: "blockchain-explorer::rpc_blocks::process_sync_blocks_reorg", + info!(target: "explorerd::rpc_blocks::process_sync_blocks_reorg", "Reorg detected with heights: explorer.{last_synced_height} >= darkfid.{last_darkfid_height}"); } @@ -173,7 +173,7 @@ impl Explorerd { // Search for an explorer block that matches a darkfi node block while cur_height > 0 { let synced_block = self.service.get_block_by_height(cur_height)?; - debug!(target: "blockchain-explorer::rpc_blocks::process_sync_blocks_reorg", "Searching for common block: {}", cur_height); + debug!(target: "explorerd::rpc_blocks::process_sync_blocks_reorg", "Searching for common block: {}", cur_height); // Check if we found a synced block for current height being searched if let Some(synced_block) = synced_block { @@ -185,14 +185,14 @@ impl Explorerd { // If hashes match but the cur_height differs from the last synced height, reset the explorer state if cur_height != last_synced_height { self.service.reset_explorer_state(cur_height)?; - debug!(target: "blockchain-explorer::rpc_blocks::process_sync_blocks_reorg", "Successfully completed reorg to height: {cur_height}"); + debug!(target: "explorerd::rpc_blocks::process_sync_blocks_reorg", "Successfully completed reorg to height: {cur_height}"); } break; } else { // Log reorg detection with height and header hash mismatch details if cur_height == last_synced_height { info!( - target: "blockchain-explorer::rpc_blocks::process_sync_blocks_reorg", + target: "explorerd::rpc_blocks::process_sync_blocks_reorg", "Reorg detected at height {}: explorer.{} != darkfid.{}", cur_height, synced_block.header_hash, @@ -254,7 +254,7 @@ impl Explorerd { let blocks_result = match self.service.get_last_n(n) { Ok(blocks) => blocks, Err(e) => { - error!(target: "blockchain-explorer::rpc_blocks::blocks_get_last_n_blocks", "Failed fetching blocks: {}", e); + error!(target: "explorerd::rpc_blocks::blocks_get_last_n_blocks", "Failed fetching blocks: {}", e); return JsonError::new(InternalError, None, id).into(); } }; @@ -310,7 +310,7 @@ impl Explorerd { let blocks_result = match self.service.get_by_range(start, end) { Ok(blocks) => blocks, Err(e) => { - error!(target: "blockchain-explorer::rpc_blocks::blocks_get_blocks_in_height_range", "Failed fetching blocks: {}", e); + error!(target: "explorerd::rpc_blocks::blocks_get_blocks_in_height_range", "Failed fetching blocks: {}", e); return JsonError::new(InternalError, None, id).into(); } }; @@ -354,7 +354,7 @@ impl Explorerd { Ok(Some(block)) => JsonResponse::new(block.to_json_array(), id).into(), Ok(None) => JsonResponse::new(JsonValue::Array(vec![]), id).into(), Err(e) => { - error!(target: "blockchain-explorer::rpc_blocks", "Failed fetching block: {:?}", e); + error!(target: "explorerd::rpc_blocks", "Failed fetching block: {:?}", e); JsonError::new(InternalError, None, id).into() } } @@ -401,16 +401,16 @@ pub async fn subscribe_blocks( // Check if there is a mismatch, throwing an error to prevent operating in a potentially inconsistent state if blocks_mismatch { - warn!(target: "blockchain-explorer::rpc_blocks::subscribe_blocks", + warn!(target: "explorerd::rpc_blocks::subscribe_blocks", "Warning: Last synced block is not the last confirmed block: \ last_darkfid_height={last_darkfid_height}, last_synced_height={height}, last_darkfid_hash={last_darkfid_hash}, last_synced_hash={hash}"); - warn!(target: "blockchain-explorer::rpc_blocks::subscribe_blocks", "You should first fully sync the blockchain, and then subscribe"); + warn!(target: "explorerd::rpc_blocks::subscribe_blocks", "You should first fully sync the blockchain, and then subscribe"); return Err(Error::DatabaseError( "[subscribe_blocks] Blockchain not fully synced".to_string(), )); } - info!(target: "blockchain-explorer::rpc_blocks::subscribe_blocks", "Subscribing to receive notifications of incoming blocks"); + info!(target: "explorerd::rpc_blocks::subscribe_blocks", "Subscribing to receive notifications of incoming blocks"); let publisher = Publisher::new(); let subscription = publisher.clone().subscribe().await; let _ex = ex.clone(); @@ -426,14 +426,14 @@ pub async fn subscribe_blocks( |res| async move { match res { Ok(()) => { /* Do nothing */ } - Err(e) => error!(target: "blockchain-explorer::rpc_blocks::subscribe_blocks", "[subscribe_blocks] JSON-RPC server error: {e:?}"), + Err(e) => error!(target: "explorerd::rpc_blocks::subscribe_blocks", "[subscribe_blocks] JSON-RPC server error: {e:?}"), } }, Error::RpcServerStopped, ex.clone(), ); - info!(target: "blockchain-explorer::rpc_blocks::subscribe_blocks", "Detached subscription to background"); - info!(target: "blockchain-explorer::rpc_blocks::subscribe_blocks", "All is good. Waiting for block notifications..."); + info!(target: "explorerd::rpc_blocks::subscribe_blocks", "Detached subscription to background"); + info!(target: "explorerd::rpc_blocks::subscribe_blocks", "All is good. Waiting for block notifications..."); let listener_task = StoppableTask::new(); listener_task.clone().start( @@ -442,7 +442,7 @@ pub async fn subscribe_blocks( loop { match subscription.receive().await { JsonResult::Notification(n) => { - debug!(target: "blockchain-explorer::rpc_blocks::subscribe_blocks", "Got Block notification from darkfid subscription"); + debug!(target: "explorerd::rpc_blocks::subscribe_blocks", "Got Block notification from darkfid subscription"); if n.method != "blockchain.subscribe_blocks" { return Err(Error::UnexpectedJsonRpc(format!( "Got foreign notification from darkfid: {}", @@ -475,16 +475,16 @@ pub async fn subscribe_blocks( ))) }, }; - info!(target: "blockchain-explorer::rpc_blocks::subscribe_blocks", "======================================="); - info!(target: "blockchain-explorer::rpc_blocks::subscribe_blocks", "Block Notification: {}", darkfid_block.hash().to_string()); - info!(target: "blockchain-explorer::rpc_blocks::subscribe_blocks", "======================================="); + info!(target: "explorerd::rpc_blocks::subscribe_blocks", "======================================="); + info!(target: "explorerd::rpc_blocks::subscribe_blocks", "Block Notification: {}", darkfid_block.hash().to_string()); + info!(target: "explorerd::rpc_blocks::subscribe_blocks", "======================================="); // Store darkfi node block height for later use let darkfid_block_height = darkfid_block.header.height; // Check if we need to perform a reorg due to mismatch in block heights if darkfid_block_height <= height { - info!(target: "blockchain-explorer::rpc_blocks::subscribe_blocks", + info!(target: "explorerd::rpc_blocks::subscribe_blocks", "Reorg detected with heights: darkfid.{darkfid_block_height} <= explorer.{height}"); // Calculate the reset height @@ -492,7 +492,7 @@ pub async fn subscribe_blocks( // Execute the reorg by resetting the explorer state to reset height explorer.service.reset_explorer_state(reset_height)?; - info!(target: "blockchain-explorer::rpc_blocks::subscribe_blocks", "Successfully completed reorg to height: {reset_height}"); + info!(target: "explorerd::rpc_blocks::subscribe_blocks", "Successfully completed reorg to height: {reset_height}"); } if let Err(e) = explorer.service.put_block(&darkfid_block).await { @@ -501,7 +501,7 @@ pub async fn subscribe_blocks( ))) } - info!(target: "blockchain-explorer::rpc_blocks::subscribe_blocks", "Successfully stored new block at height: {}", darkfid_block.header.height ); + info!(target: "explorerd::rpc_blocks::subscribe_blocks", "Successfully stored new block at height: {}", darkfid_block.header.height ); // Process the next block height = darkfid_block.header.height; @@ -525,7 +525,7 @@ pub async fn subscribe_blocks( |res| async move { match res { Ok(()) => { /* Do nothing */ } - Err(e) => error!(target: "blockchain-explorer::rpc_blocks::subscribe_blocks", "[subscribe_blocks] JSON-RPC server error: {e:?}"), + Err(e) => error!(target: "explorerd::rpc_blocks::subscribe_blocks", "[subscribe_blocks] JSON-RPC server error: {e:?}"), } }, Error::RpcServerStopped, diff --git a/script/research/blockchain-explorer/src/rpc_contracts.rs b/bin/explorer/explorerd/src/rpc_contracts.rs similarity index 100% rename from script/research/blockchain-explorer/src/rpc_contracts.rs rename to bin/explorer/explorerd/src/rpc_contracts.rs diff --git a/script/research/blockchain-explorer/src/rpc_statistics.rs b/bin/explorer/explorerd/src/rpc_statistics.rs similarity index 92% rename from script/research/blockchain-explorer/src/rpc_statistics.rs rename to bin/explorer/explorerd/src/rpc_statistics.rs index 6675f0831..6fc65e539 100644 --- a/script/research/blockchain-explorer/src/rpc_statistics.rs +++ b/bin/explorer/explorerd/src/rpc_statistics.rs @@ -54,7 +54,7 @@ impl Explorerd { Ok(None) => JsonResponse::new(JsonValue::Array(vec![]), id).into(), Err(e) => { error!( - target: "blockchain-explorer::rpc_statistics::statistics_get_basic_statistics", + target: "explorerd::rpc_statistics::statistics_get_basic_statistics", "Failed fetching basic statistics: {}", e ); JsonError::new(InternalError, None, id).into() @@ -84,7 +84,7 @@ impl Explorerd { let metrics = match self.service.get_metrics_statistics().await { Ok(v) => v, Err(e) => { - error!(target: "blockchain-explorer::rpc_statistics::statistics_get_metric_statistics", "Failed fetching metric statistics: {}", e); + error!(target: "explorerd::rpc_statistics::statistics_get_metric_statistics", "Failed fetching metric statistics: {}", e); return JsonError::new(InternalError, None, id).into() } }; @@ -120,7 +120,7 @@ impl Explorerd { let metrics = match self.service.get_latest_metrics_statistics().await { Ok(v) => v, Err(e) => { - error!(target: "blockchain-explorer::rpc_statistics::statistics_get_latest_metric_statistics", "Failed fetching metric statistics: {}", e); + error!(target: "explorerd::rpc_statistics::statistics_get_latest_metric_statistics", "Failed fetching metric statistics: {}", e); return JsonError::new(InternalError, None, id).into() } }; diff --git a/script/research/blockchain-explorer/src/rpc_transactions.rs b/bin/explorer/explorerd/src/rpc_transactions.rs similarity index 92% rename from script/research/blockchain-explorer/src/rpc_transactions.rs rename to bin/explorer/explorerd/src/rpc_transactions.rs index 45a244336..d3e51a88a 100644 --- a/script/research/blockchain-explorer/src/rpc_transactions.rs +++ b/bin/explorer/explorerd/src/rpc_transactions.rs @@ -54,7 +54,7 @@ impl Explorerd { let transactions = match self.service.get_transactions_by_header_hash(header_hash) { Ok(v) => v, Err(e) => { - error!(target: "blockchain-explorer::rpc_transactions::transactions_get_transaction_by_header_hash", "Failed fetching block transactions: {}", e); + error!(target: "explorerd::rpc_transactions::transactions_get_transaction_by_header_hash", "Failed fetching block transactions: {}", e); return JsonError::new(InternalError, None, id).into() } }; @@ -100,7 +100,7 @@ impl Explorerd { Ok(Some(transaction)) => JsonResponse::new(transaction.to_json_array(), id).into(), Ok(None) => JsonResponse::new(JsonValue::Array(vec![]), id).into(), Err(e) => { - error!(target: "blockchain-explorer::rpc_transactions::transactions_get_transaction_by_hash", "Failed fetching transaction: {}", e); + error!(target: "explorerd::rpc_transactions::transactions_get_transaction_by_hash", "Failed fetching transaction: {}", e); JsonError::new(InternalError, None, id).into() } } diff --git a/script/research/blockchain-explorer/src/statistics.rs b/bin/explorer/explorerd/src/statistics.rs similarity index 100% rename from script/research/blockchain-explorer/src/statistics.rs rename to bin/explorer/explorerd/src/statistics.rs diff --git a/script/research/blockchain-explorer/src/test_utils/mod.rs b/bin/explorer/explorerd/src/test_utils/mod.rs similarity index 100% rename from script/research/blockchain-explorer/src/test_utils/mod.rs rename to bin/explorer/explorerd/src/test_utils/mod.rs diff --git a/script/research/blockchain-explorer/src/transactions.rs b/bin/explorer/explorerd/src/transactions.rs similarity index 99% rename from script/research/blockchain-explorer/src/transactions.rs rename to bin/explorer/explorerd/src/transactions.rs index fdbfabbd7..a126709b9 100644 --- a/script/research/blockchain-explorer/src/transactions.rs +++ b/bin/explorer/explorerd/src/transactions.rs @@ -98,7 +98,7 @@ impl ExplorerService { let tree = &self.db.blockchain.sled_db.open_tree(tree_name)?; tree.clear()?; let tree_name_str = std::str::from_utf8(tree_name)?; - debug!(target: "blockchain-explorer::blocks", "Successfully reset transaction tree: {tree_name_str}"); + debug!(target: "explorerd::blocks", "Successfully reset transaction tree: {tree_name_str}"); } Ok(()) diff --git a/script/research/blockchain-explorer/site/.gitignore b/bin/explorer/site/.gitignore similarity index 100% rename from script/research/blockchain-explorer/site/.gitignore rename to bin/explorer/site/.gitignore diff --git a/script/research/blockchain-explorer/site/README.md b/bin/explorer/site/README.md similarity index 76% rename from script/research/blockchain-explorer/site/README.md rename to bin/explorer/site/README.md index f33fd2038..c508eb6a6 100644 --- a/script/research/blockchain-explorer/site/README.md +++ b/bin/explorer/site/README.md @@ -18,19 +18,20 @@ First we start a `darkfid` localnet: It is advised to shutdown the `minerd` daemon after couple of blocks, to not waste resources. -Update the `blockchain-explorer` configuration to the localnet `darkfid` JSON-RPC endpoint -and start a the daemon: +Update the `explorerd` configuration to the localnet `darkfid` JSON-RPC endpoint +and start the daemon: ``` -% cd script/research/blockchain-explorer -% cargo +nightly run --release --all-features +% cd bin/explorer/explorerd +% make install +% explorerd -c explored_config.toml ``` Then we enter the site folder and we generate a new python virtual environment, source it and install required dependencies: ``` -% cd script/research/blockchain-explorer/site +% cd bin/explorer/site % python -m venv venv % source venv/bin/activate % pip install -r requirements.txt diff --git a/script/research/blockchain-explorer/site/app.py b/bin/explorer/site/app.py similarity index 100% rename from script/research/blockchain-explorer/site/app.py rename to bin/explorer/site/app.py diff --git a/script/research/blockchain-explorer/site/blueprints/__init__.py b/bin/explorer/site/blueprints/__init__.py similarity index 100% rename from script/research/blockchain-explorer/site/blueprints/__init__.py rename to bin/explorer/site/blueprints/__init__.py diff --git a/script/research/blockchain-explorer/site/blueprints/block.py b/bin/explorer/site/blueprints/block.py similarity index 100% rename from script/research/blockchain-explorer/site/blueprints/block.py rename to bin/explorer/site/blueprints/block.py diff --git a/script/research/blockchain-explorer/site/blueprints/contract.py b/bin/explorer/site/blueprints/contract.py similarity index 100% rename from script/research/blockchain-explorer/site/blueprints/contract.py rename to bin/explorer/site/blueprints/contract.py diff --git a/script/research/blockchain-explorer/site/blueprints/explore.py b/bin/explorer/site/blueprints/explore.py similarity index 100% rename from script/research/blockchain-explorer/site/blueprints/explore.py rename to bin/explorer/site/blueprints/explore.py diff --git a/script/research/blockchain-explorer/site/blueprints/transaction.py b/bin/explorer/site/blueprints/transaction.py similarity index 100% rename from script/research/blockchain-explorer/site/blueprints/transaction.py rename to bin/explorer/site/blueprints/transaction.py diff --git a/script/research/blockchain-explorer/site/requirements.txt b/bin/explorer/site/requirements.txt similarity index 100% rename from script/research/blockchain-explorer/site/requirements.txt rename to bin/explorer/site/requirements.txt diff --git a/script/research/blockchain-explorer/site/rpc.py b/bin/explorer/site/rpc.py similarity index 100% rename from script/research/blockchain-explorer/site/rpc.py rename to bin/explorer/site/rpc.py diff --git a/script/research/blockchain-explorer/site/static/bootstrap.min.css b/bin/explorer/site/static/bootstrap.min.css similarity index 100% rename from script/research/blockchain-explorer/site/static/bootstrap.min.css rename to bin/explorer/site/static/bootstrap.min.css diff --git a/script/research/blockchain-explorer/site/static/font-files/Chomsky.otf b/bin/explorer/site/static/font-files/Chomsky.otf similarity index 100% rename from script/research/blockchain-explorer/site/static/font-files/Chomsky.otf rename to bin/explorer/site/static/font-files/Chomsky.otf diff --git a/script/research/blockchain-explorer/site/static/font-files/Chomsky.woff b/bin/explorer/site/static/font-files/Chomsky.woff similarity index 100% rename from script/research/blockchain-explorer/site/static/font-files/Chomsky.woff rename to bin/explorer/site/static/font-files/Chomsky.woff diff --git a/script/research/blockchain-explorer/site/static/font-files/Chomsky.woff2 b/bin/explorer/site/static/font-files/Chomsky.woff2 similarity index 100% rename from script/research/blockchain-explorer/site/static/font-files/Chomsky.woff2 rename to bin/explorer/site/static/font-files/Chomsky.woff2 diff --git a/script/research/blockchain-explorer/site/static/font-files/IBMPlexMonoExtraLight.otf b/bin/explorer/site/static/font-files/IBMPlexMonoExtraLight.otf similarity index 100% rename from script/research/blockchain-explorer/site/static/font-files/IBMPlexMonoExtraLight.otf rename to bin/explorer/site/static/font-files/IBMPlexMonoExtraLight.otf diff --git a/script/research/blockchain-explorer/site/static/font-files/IBMPlexMonoExtraLight.woff b/bin/explorer/site/static/font-files/IBMPlexMonoExtraLight.woff similarity index 100% rename from script/research/blockchain-explorer/site/static/font-files/IBMPlexMonoExtraLight.woff rename to bin/explorer/site/static/font-files/IBMPlexMonoExtraLight.woff diff --git a/script/research/blockchain-explorer/site/static/font-files/IBMPlexMonoExtraLight.woff2 b/bin/explorer/site/static/font-files/IBMPlexMonoExtraLight.woff2 similarity index 100% rename from script/research/blockchain-explorer/site/static/font-files/IBMPlexMonoExtraLight.woff2 rename to bin/explorer/site/static/font-files/IBMPlexMonoExtraLight.woff2 diff --git a/script/research/blockchain-explorer/site/static/font-files/IBMPlexSansArabic-Regular.woff b/bin/explorer/site/static/font-files/IBMPlexSansArabic-Regular.woff similarity index 100% rename from script/research/blockchain-explorer/site/static/font-files/IBMPlexSansArabic-Regular.woff rename to bin/explorer/site/static/font-files/IBMPlexSansArabic-Regular.woff diff --git a/script/research/blockchain-explorer/site/static/font-files/IBMPlexSansArabic-Regular.woff2 b/bin/explorer/site/static/font-files/IBMPlexSansArabic-Regular.woff2 similarity index 100% rename from script/research/blockchain-explorer/site/static/font-files/IBMPlexSansArabic-Regular.woff2 rename to bin/explorer/site/static/font-files/IBMPlexSansArabic-Regular.woff2 diff --git a/script/research/blockchain-explorer/site/static/font-files/Inter-Bold.woff b/bin/explorer/site/static/font-files/Inter-Bold.woff similarity index 100% rename from script/research/blockchain-explorer/site/static/font-files/Inter-Bold.woff rename to bin/explorer/site/static/font-files/Inter-Bold.woff diff --git a/script/research/blockchain-explorer/site/static/font-files/Inter-BoldItalic.woff b/bin/explorer/site/static/font-files/Inter-BoldItalic.woff similarity index 100% rename from script/research/blockchain-explorer/site/static/font-files/Inter-BoldItalic.woff rename to bin/explorer/site/static/font-files/Inter-BoldItalic.woff diff --git a/script/research/blockchain-explorer/site/static/font-files/Inter-Italic.woff b/bin/explorer/site/static/font-files/Inter-Italic.woff similarity index 100% rename from script/research/blockchain-explorer/site/static/font-files/Inter-Italic.woff rename to bin/explorer/site/static/font-files/Inter-Italic.woff diff --git a/script/research/blockchain-explorer/site/static/font-files/Inter-Regular.woff b/bin/explorer/site/static/font-files/Inter-Regular.woff similarity index 100% rename from script/research/blockchain-explorer/site/static/font-files/Inter-Regular.woff rename to bin/explorer/site/static/font-files/Inter-Regular.woff diff --git a/script/research/blockchain-explorer/site/static/font-files/Inter-SemiBold.woff b/bin/explorer/site/static/font-files/Inter-SemiBold.woff similarity index 100% rename from script/research/blockchain-explorer/site/static/font-files/Inter-SemiBold.woff rename to bin/explorer/site/static/font-files/Inter-SemiBold.woff diff --git a/script/research/blockchain-explorer/site/static/font-files/Inter-SemiBoldItalic.woff b/bin/explorer/site/static/font-files/Inter-SemiBoldItalic.woff similarity index 100% rename from script/research/blockchain-explorer/site/static/font-files/Inter-SemiBoldItalic.woff rename to bin/explorer/site/static/font-files/Inter-SemiBoldItalic.woff diff --git a/script/research/blockchain-explorer/site/static/font-files/InterDisplay-Black.woff b/bin/explorer/site/static/font-files/InterDisplay-Black.woff similarity index 100% rename from script/research/blockchain-explorer/site/static/font-files/InterDisplay-Black.woff rename to bin/explorer/site/static/font-files/InterDisplay-Black.woff diff --git a/script/research/blockchain-explorer/site/static/font-files/InterDisplay-BlackItalic.woff b/bin/explorer/site/static/font-files/InterDisplay-BlackItalic.woff similarity index 100% rename from script/research/blockchain-explorer/site/static/font-files/InterDisplay-BlackItalic.woff rename to bin/explorer/site/static/font-files/InterDisplay-BlackItalic.woff diff --git a/script/research/blockchain-explorer/site/static/font-files/InterDisplay-ExtraLight.woff b/bin/explorer/site/static/font-files/InterDisplay-ExtraLight.woff similarity index 100% rename from script/research/blockchain-explorer/site/static/font-files/InterDisplay-ExtraLight.woff rename to bin/explorer/site/static/font-files/InterDisplay-ExtraLight.woff diff --git a/script/research/blockchain-explorer/site/static/font-files/InterDisplay-ExtraLight.woff2 b/bin/explorer/site/static/font-files/InterDisplay-ExtraLight.woff2 similarity index 100% rename from script/research/blockchain-explorer/site/static/font-files/InterDisplay-ExtraLight.woff2 rename to bin/explorer/site/static/font-files/InterDisplay-ExtraLight.woff2 diff --git a/script/research/blockchain-explorer/site/static/font-files/ReemKufi-Bold.woff b/bin/explorer/site/static/font-files/ReemKufi-Bold.woff similarity index 100% rename from script/research/blockchain-explorer/site/static/font-files/ReemKufi-Bold.woff rename to bin/explorer/site/static/font-files/ReemKufi-Bold.woff diff --git a/script/research/blockchain-explorer/site/static/font-files/ReemKufi-Bold.woff2 b/bin/explorer/site/static/font-files/ReemKufi-Bold.woff2 similarity index 100% rename from script/research/blockchain-explorer/site/static/font-files/ReemKufi-Bold.woff2 rename to bin/explorer/site/static/font-files/ReemKufi-Bold.woff2 diff --git a/script/research/blockchain-explorer/site/static/font-files/weissrundgotisch.regular.woff b/bin/explorer/site/static/font-files/weissrundgotisch.regular.woff similarity index 100% rename from script/research/blockchain-explorer/site/static/font-files/weissrundgotisch.regular.woff rename to bin/explorer/site/static/font-files/weissrundgotisch.regular.woff diff --git a/script/research/blockchain-explorer/site/static/font-files/weissrundgotisch.regular.woff2 b/bin/explorer/site/static/font-files/weissrundgotisch.regular.woff2 similarity index 100% rename from script/research/blockchain-explorer/site/static/font-files/weissrundgotisch.regular.woff2 rename to bin/explorer/site/static/font-files/weissrundgotisch.regular.woff2 diff --git a/script/research/blockchain-explorer/site/static/img/darkfi.svg b/bin/explorer/site/static/img/darkfi.svg similarity index 100% rename from script/research/blockchain-explorer/site/static/img/darkfi.svg rename to bin/explorer/site/static/img/darkfi.svg diff --git a/script/research/blockchain-explorer/site/static/img/darkfi05.jpg b/bin/explorer/site/static/img/darkfi05.jpg similarity index 100% rename from script/research/blockchain-explorer/site/static/img/darkfi05.jpg rename to bin/explorer/site/static/img/darkfi05.jpg diff --git a/script/research/blockchain-explorer/site/static/img/darkfi25.jpg b/bin/explorer/site/static/img/darkfi25.jpg similarity index 100% rename from script/research/blockchain-explorer/site/static/img/darkfi25.jpg rename to bin/explorer/site/static/img/darkfi25.jpg diff --git a/script/research/blockchain-explorer/site/static/img/icon.png b/bin/explorer/site/static/img/icon.png similarity index 100% rename from script/research/blockchain-explorer/site/static/img/icon.png rename to bin/explorer/site/static/img/icon.png diff --git a/script/research/blockchain-explorer/site/static/img/sunset2.png b/bin/explorer/site/static/img/sunset2.png similarity index 100% rename from script/research/blockchain-explorer/site/static/img/sunset2.png rename to bin/explorer/site/static/img/sunset2.png diff --git a/script/research/blockchain-explorer/site/static/style.css b/bin/explorer/site/static/style.css similarity index 100% rename from script/research/blockchain-explorer/site/static/style.css rename to bin/explorer/site/static/style.css diff --git a/script/research/blockchain-explorer/site/templates/404.html b/bin/explorer/site/templates/404.html similarity index 100% rename from script/research/blockchain-explorer/site/templates/404.html rename to bin/explorer/site/templates/404.html diff --git a/script/research/blockchain-explorer/site/templates/500.html b/bin/explorer/site/templates/500.html similarity index 100% rename from script/research/blockchain-explorer/site/templates/500.html rename to bin/explorer/site/templates/500.html diff --git a/script/research/blockchain-explorer/site/templates/base.html b/bin/explorer/site/templates/base.html similarity index 100% rename from script/research/blockchain-explorer/site/templates/base.html rename to bin/explorer/site/templates/base.html diff --git a/script/research/blockchain-explorer/site/templates/block.html b/bin/explorer/site/templates/block.html similarity index 100% rename from script/research/blockchain-explorer/site/templates/block.html rename to bin/explorer/site/templates/block.html diff --git a/script/research/blockchain-explorer/site/templates/contract_source.html b/bin/explorer/site/templates/contract_source.html similarity index 100% rename from script/research/blockchain-explorer/site/templates/contract_source.html rename to bin/explorer/site/templates/contract_source.html diff --git a/script/research/blockchain-explorer/site/templates/contract_source_list.html b/bin/explorer/site/templates/contract_source_list.html similarity index 100% rename from script/research/blockchain-explorer/site/templates/contract_source_list.html rename to bin/explorer/site/templates/contract_source_list.html diff --git a/script/research/blockchain-explorer/site/templates/index.html b/bin/explorer/site/templates/index.html similarity index 100% rename from script/research/blockchain-explorer/site/templates/index.html rename to bin/explorer/site/templates/index.html diff --git a/script/research/blockchain-explorer/site/templates/transaction.html b/bin/explorer/site/templates/transaction.html similarity index 100% rename from script/research/blockchain-explorer/site/templates/transaction.html rename to bin/explorer/site/templates/transaction.html diff --git a/script/research/blockchain-explorer/.gitignore b/script/research/blockchain-explorer/.gitignore deleted file mode 100644 index f5d00cd3f..000000000 --- a/script/research/blockchain-explorer/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -/target -Cargo.lock -rustfmt.toml -*_db -/native_contracts_src