From 2ff95da79d1d36b2c2ef73b24a59c5117301d760 Mon Sep 17 00:00:00 2001 From: Liu-Cheng Xu Date: Tue, 3 Dec 2024 14:26:13 +0800 Subject: [PATCH] Fix import-blocks from Bitcoin Core database (#79) --- Cargo.lock | 217 ++++++++++-------- Cargo.toml | 2 +- .../src/commands/blockchain/parse_block.rs | 28 +-- 3 files changed, 135 insertions(+), 112 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f554f848..1b55d74c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -518,7 +518,7 @@ dependencies = [ "nom", "num-traits", "rusticata-macros", - "thiserror", + "thiserror 1.0.68", "time", ] @@ -534,7 +534,7 @@ dependencies = [ "nom", "num-traits", "rusticata-macros", - "thiserror", + "thiserror 1.0.68", "time", ] @@ -976,7 +976,7 @@ dependencies = [ [[package]] name = "bitcoin-explorer" version = "1.2.20" -source = "git+https://github.com/liuchengxu/Rusty-Bitcoin-Explorer?branch=rust-bitcoin-upgrade#2f86bf35f2dd9fdf23ba292778c1d45fa073f86e" +source = "git+https://github.com/liuchengxu/Rusty-Bitcoin-Explorer?branch=main#7e679918020de55be3619ae5825036b062ea1fd1" dependencies = [ "bitcoin 0.31.0", "byteorder", @@ -988,6 +988,7 @@ dependencies = [ "par-iter-sync", "rayon", "serde", + "thiserror 2.0.3", ] [[package]] @@ -1223,7 +1224,7 @@ version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68534a48cbf63a4b1323c433cf21238c9ec23711e0df13b08c33e5c2082663ce" dependencies = [ - "thiserror", + "thiserror 1.0.68", ] [[package]] @@ -1331,7 +1332,7 @@ dependencies = [ "semver 1.0.23", "serde", "serde_json", - "thiserror", + "thiserror 1.0.68", ] [[package]] @@ -2056,7 +2057,7 @@ dependencies = [ "sp-blockchain", "sp-state-machine", "sp-version", - "thiserror", + "thiserror 1.0.68", ] [[package]] @@ -2736,7 +2737,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec6f82451ff7f0568c6181287189126d492b5654e30a788add08027b6363d019" dependencies = [ "fatality-proc-macro", - "thiserror", + "thiserror 1.0.68", ] [[package]] @@ -2760,7 +2761,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e182f7dbc2ef73d9ef67351c5fbbea084729c48362d3ce9dd44c28e32e277fe5" dependencies = [ "libc", - "thiserror", + "thiserror 1.0.68", ] [[package]] @@ -2903,7 +2904,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8835f84f38484cc86f110a805655697908257fb9a7af005234060891557198e9" dependencies = [ "nonempty", - "thiserror", + "thiserror 1.0.68", ] [[package]] @@ -2994,7 +2995,7 @@ dependencies = [ "sp-wasm-interface 20.0.0 (git+https://github.com/subcoin-project/polkadot-sdk?branch=subcoin-v4)", "subxt", "subxt-signer", - "thiserror", + "thiserror 1.0.68", "thousands", ] @@ -3509,7 +3510,7 @@ dependencies = [ "pest_derive", "serde", "serde_json", - "thiserror", + "thiserror 1.0.68", ] [[package]] @@ -3642,7 +3643,7 @@ dependencies = [ "ipnet", "once_cell", "rand", - "thiserror", + "thiserror 1.0.68", "tinyvec", "tokio", "tracing", @@ -3665,7 +3666,7 @@ dependencies = [ "rand", "resolv-conf", "smallvec", - "thiserror", + "thiserror 1.0.68", "tokio", "tracing", ] @@ -4193,7 +4194,7 @@ dependencies = [ "combine", "jni-sys", "log", - "thiserror", + "thiserror 1.0.68", "walkdir", ] @@ -4252,7 +4253,7 @@ dependencies = [ "rustls-pki-types", "rustls-platform-verifier", "soketto 0.8.0", - "thiserror", + "thiserror 1.0.68", "tokio", "tokio-rustls 0.26.0", "tokio-util", @@ -4280,7 +4281,7 @@ dependencies = [ "rustc-hash 2.0.0", "serde", "serde_json", - "thiserror", + "thiserror 1.0.68", "tokio", "tokio-stream", "tracing", @@ -4318,7 +4319,7 @@ dependencies = [ "serde", "serde_json", "soketto 0.8.0", - "thiserror", + "thiserror 1.0.68", "tokio", "tokio-stream", "tokio-util", @@ -4335,7 +4336,7 @@ dependencies = [ "http 1.1.0", "serde", "serde_json", - "thiserror", + "thiserror 1.0.68", ] [[package]] @@ -4514,7 +4515,7 @@ dependencies = [ "multiaddr 0.18.1", "pin-project", "rw-stream-sink", - "thiserror", + "thiserror 1.0.68", ] [[package]] @@ -4564,7 +4565,7 @@ dependencies = [ "rand", "rw-stream-sink", "smallvec", - "thiserror", + "thiserror 1.0.68", "unsigned-varint 0.7.2", "void", ] @@ -4604,7 +4605,7 @@ dependencies = [ "quick-protobuf", "quick-protobuf-codec", "smallvec", - "thiserror", + "thiserror 1.0.68", "void", ] @@ -4621,7 +4622,7 @@ dependencies = [ "quick-protobuf", "rand", "sha2 0.10.8", - "thiserror", + "thiserror 1.0.68", "tracing", "zeroize", ] @@ -4649,7 +4650,7 @@ dependencies = [ "rand", "sha2 0.10.8", "smallvec", - "thiserror", + "thiserror 1.0.68", "uint 0.9.5", "unsigned-varint 0.7.2", "void", @@ -4713,7 +4714,7 @@ dependencies = [ "sha2 0.10.8", "snow", "static_assertions", - "thiserror", + "thiserror 1.0.68", "x25519-dalek", "zeroize", ] @@ -4756,7 +4757,7 @@ dependencies = [ "ring 0.16.20", "rustls 0.21.12", "socket2 0.5.7", - "thiserror", + "thiserror 1.0.68", "tokio", ] @@ -4845,7 +4846,7 @@ dependencies = [ "ring 0.16.20", "rustls 0.21.12", "rustls-webpki 0.101.7", - "thiserror", + "thiserror 1.0.68", "x509-parser 0.15.1", "yasna", ] @@ -4909,7 +4910,7 @@ dependencies = [ "futures", "libp2p-core", "log", - "thiserror", + "thiserror 1.0.68", "yamux", ] @@ -5091,7 +5092,7 @@ dependencies = [ "snow", "socket2 0.5.7", "static_assertions", - "thiserror", + "thiserror 1.0.68", "tokio", "tokio-stream", "tokio-tungstenite", @@ -5359,7 +5360,7 @@ dependencies = [ "rand_chacha", "rand_distr", "subtle 2.6.1", - "thiserror", + "thiserror 1.0.68", "zeroize", ] @@ -5626,7 +5627,7 @@ dependencies = [ "anyhow", "byteorder", "paste", - "thiserror", + "thiserror 1.0.68", ] [[package]] @@ -5640,7 +5641,7 @@ dependencies = [ "log", "netlink-packet-core", "netlink-sys", - "thiserror", + "thiserror 1.0.68", "tokio", ] @@ -5665,7 +5666,7 @@ checksum = "a4a43439bf756eed340bdf8feba761e2d50c7d47175d87545cd5cbe4a137c4d1" dependencies = [ "cc", "libc", - "thiserror", + "thiserror 1.0.68", "winapi", ] @@ -5919,7 +5920,7 @@ dependencies = [ "orchestra-proc-macro", "pin-project", "prioritized-metered-channel", - "thiserror", + "thiserror 1.0.68", "tracing", ] @@ -6210,7 +6211,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cd53dff83f26735fdc1ca837098ccf133605d794cdae66acfc2bfac3ec809d95" dependencies = [ "memchr", - "thiserror", + "thiserror 1.0.68", "ucd-trie", ] @@ -6374,7 +6375,7 @@ dependencies = [ "sc-network-types", "sp-runtime", "strum 0.26.3", - "thiserror", + "thiserror 1.0.68", "tracing-gum", ] @@ -6400,7 +6401,7 @@ dependencies = [ "sp-keystore", "sp-maybe-compressed-blob", "sp-runtime", - "thiserror", + "thiserror 1.0.68", "zstd 0.12.4", ] @@ -6430,7 +6431,7 @@ dependencies = [ "sp-consensus-babe", "sp-runtime", "substrate-prometheus-endpoint", - "thiserror", + "thiserror 1.0.68", ] [[package]] @@ -6496,7 +6497,7 @@ dependencies = [ "sp-runtime", "sp-staking", "sp-std 14.0.0 (git+https://github.com/subcoin-project/polkadot-sdk?branch=subcoin-v4)", - "thiserror", + "thiserror 1.0.68", ] [[package]] @@ -6734,7 +6735,7 @@ dependencies = [ "futures", "futures-timer", "nanorand", - "thiserror", + "thiserror 1.0.68", "tracing", ] @@ -6744,7 +6745,7 @@ version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e17d47ce914bf4de440332250b0edd23ce48c005f59fab39d3335866b114f11a" dependencies = [ - "thiserror", + "thiserror 1.0.68", "toml 0.5.11", ] @@ -6845,7 +6846,7 @@ dependencies = [ "lazy_static", "memchr", "parking_lot 0.12.3", - "thiserror", + "thiserror 1.0.68", ] [[package]] @@ -6995,7 +6996,7 @@ dependencies = [ "asynchronous-codec", "bytes", "quick-protobuf", - "thiserror", + "thiserror 1.0.68", "unsigned-varint 0.7.2", ] @@ -7023,7 +7024,7 @@ dependencies = [ "quinn-udp", "rustc-hash 1.1.0", "rustls 0.21.12", - "thiserror", + "thiserror 1.0.68", "tokio", "tracing", ] @@ -7040,7 +7041,7 @@ dependencies = [ "rustc-hash 1.1.0", "rustls 0.21.12", "slab", - "thiserror", + "thiserror 1.0.68", "tinyvec", "tracing", ] @@ -7204,7 +7205,7 @@ checksum = "bd283d9651eeda4b2a83a43c1c91b266c40fd76ecd39a50a8c630ae69dc72891" dependencies = [ "getrandom", "libredox", - "thiserror", + "thiserror 1.0.68", ] [[package]] @@ -7410,7 +7411,7 @@ dependencies = [ "netlink-packet-route", "netlink-proto", "nix", - "thiserror", + "thiserror 1.0.68", "tokio", ] @@ -7696,7 +7697,7 @@ dependencies = [ "log", "sp-core", "sp-wasm-interface 20.0.0 (git+https://github.com/subcoin-project/polkadot-sdk?branch=subcoin-v4)", - "thiserror", + "thiserror 1.0.68", ] [[package]] @@ -7725,7 +7726,7 @@ dependencies = [ "sp-keystore", "sp-runtime", "substrate-prometheus-endpoint", - "thiserror", + "thiserror 1.0.68", ] [[package]] @@ -7819,7 +7820,7 @@ dependencies = [ "sp-panic-handler", "sp-runtime", "sp-version", - "thiserror", + "thiserror 1.0.68", "tokio", ] @@ -7897,7 +7898,7 @@ dependencies = [ "sp-runtime", "sp-state-machine", "substrate-prometheus-endpoint", - "thiserror", + "thiserror 1.0.68", ] [[package]] @@ -7923,7 +7924,7 @@ dependencies = [ "sp-state-machine", "subcoin-primitives", "substrate-prometheus-endpoint", - "thiserror", + "thiserror 1.0.68", "tracing", ] @@ -7959,7 +7960,7 @@ dependencies = [ "sc-allocator", "sp-maybe-compressed-blob", "sp-wasm-interface 20.0.0 (git+https://github.com/subcoin-project/polkadot-sdk?branch=subcoin-v4)", - "thiserror", + "thiserror 1.0.68", "wasm-instrument", ] @@ -8020,7 +8021,7 @@ dependencies = [ "sp-application-crypto", "sp-core", "sp-keystore", - "thiserror", + "thiserror 1.0.68", ] [[package]] @@ -8049,7 +8050,7 @@ dependencies = [ "sp-keystore", "sp-mixnet", "sp-runtime", - "thiserror", + "thiserror 1.0.68", ] [[package]] @@ -8094,7 +8095,7 @@ dependencies = [ "sp-core", "sp-runtime", "substrate-prometheus-endpoint", - "thiserror", + "thiserror 1.0.68", "tokio", "tokio-stream", "unsigned-varint 0.7.2", @@ -8139,7 +8140,7 @@ dependencies = [ "sp-blockchain", "sp-core", "sp-runtime", - "thiserror", + "thiserror 1.0.68", ] [[package]] @@ -8173,7 +8174,7 @@ dependencies = [ "sp-core", "sp-runtime", "substrate-prometheus-endpoint", - "thiserror", + "thiserror 1.0.68", "tokio", "tokio-stream", "zstd 0.12.4", @@ -8213,7 +8214,7 @@ dependencies = [ "multiaddr 0.18.1", "multihash 0.19.1", "rand", - "thiserror", + "thiserror 1.0.68", "zeroize", ] @@ -8266,7 +8267,7 @@ dependencies = [ "sp-rpc", "sp-runtime", "sp-version", - "thiserror", + "thiserror 1.0.68", ] [[package]] @@ -8319,7 +8320,7 @@ dependencies = [ "sp-rpc", "sp-runtime", "sp-version", - "thiserror", + "thiserror 1.0.68", "tokio", "tokio-stream", ] @@ -8382,7 +8383,7 @@ dependencies = [ "static_init", "substrate-prometheus-endpoint", "tempfile", - "thiserror", + "thiserror 1.0.68", "tokio", "tracing", "tracing-futures", @@ -8408,7 +8409,7 @@ dependencies = [ "fs4", "log", "sp-core", - "thiserror", + "thiserror 1.0.68", "tokio", ] @@ -8449,7 +8450,7 @@ dependencies = [ "sc-utils", "serde", "serde_json", - "thiserror", + "thiserror 1.0.68", "wasm-timer", ] @@ -8475,7 +8476,7 @@ dependencies = [ "sp-rpc", "sp-runtime", "sp-tracing 16.0.0 (git+https://github.com/subcoin-project/polkadot-sdk?branch=subcoin-v4)", - "thiserror", + "thiserror 1.0.68", "tracing", "tracing-log", "tracing-subscriber", @@ -8518,7 +8519,7 @@ dependencies = [ "sp-tracing 16.0.0 (git+https://github.com/subcoin-project/polkadot-sdk?branch=subcoin-v4)", "sp-transaction-pool", "substrate-prometheus-endpoint", - "thiserror", + "thiserror 1.0.68", "tokio", "tokio-stream", ] @@ -8536,7 +8537,7 @@ dependencies = [ "sp-blockchain", "sp-core", "sp-runtime", - "thiserror", + "thiserror 1.0.68", ] [[package]] @@ -8666,7 +8667,7 @@ dependencies = [ "quote", "scale-info", "syn 2.0.87", - "thiserror", + "thiserror 1.0.68", ] [[package]] @@ -9313,7 +9314,7 @@ dependencies = [ "sp-state-machine", "sp-trie", "sp-version", - "thiserror", + "thiserror 1.0.68", ] [[package]] @@ -9411,7 +9412,7 @@ dependencies = [ "sp-database", "sp-runtime", "sp-state-machine", - "thiserror", + "thiserror 1.0.68", "tracing", ] @@ -9427,7 +9428,7 @@ dependencies = [ "sp-inherents", "sp-runtime", "sp-state-machine", - "thiserror", + "thiserror 1.0.68", ] [[package]] @@ -9517,7 +9518,7 @@ dependencies = [ "sp-storage 19.0.0 (git+https://github.com/subcoin-project/polkadot-sdk?branch=subcoin-v4)", "ss58-registry", "substrate-bip39", - "thiserror", + "thiserror 1.0.68", "tracing", "w3f-bls", "zeroize", @@ -9651,7 +9652,7 @@ dependencies = [ "parity-scale-codec", "scale-info", "sp-runtime", - "thiserror", + "thiserror 1.0.68", ] [[package]] @@ -9706,7 +9707,7 @@ name = "sp-maybe-compressed-blob" version = "11.0.0" source = "git+https://github.com/subcoin-project/polkadot-sdk?branch=subcoin-v4#b4153b97fd4d6e328e5d447c2cca74614651c497" dependencies = [ - "thiserror", + "thiserror 1.0.68", "zstd 0.12.4", ] @@ -9895,7 +9896,7 @@ dependencies = [ "sp-externalities 0.25.0 (git+https://github.com/subcoin-project/polkadot-sdk?branch=subcoin-v4)", "sp-panic-handler", "sp-trie", - "thiserror", + "thiserror 1.0.68", "tracing", "trie-db", ] @@ -9920,7 +9921,7 @@ dependencies = [ "sp-externalities 0.25.0 (git+https://github.com/subcoin-project/polkadot-sdk?branch=subcoin-v4)", "sp-runtime", "sp-runtime-interface 24.0.0 (git+https://github.com/subcoin-project/polkadot-sdk?branch=subcoin-v4)", - "thiserror", + "thiserror 1.0.68", "x25519-dalek", ] @@ -9967,7 +9968,7 @@ dependencies = [ "parity-scale-codec", "sp-inherents", "sp-runtime", - "thiserror", + "thiserror 1.0.68", ] [[package]] @@ -10031,7 +10032,7 @@ dependencies = [ "schnellru", "sp-core", "sp-externalities 0.25.0 (git+https://github.com/subcoin-project/polkadot-sdk?branch=subcoin-v4)", - "thiserror", + "thiserror 1.0.68", "tracing", "trie-db", "trie-root", @@ -10051,7 +10052,7 @@ dependencies = [ "sp-runtime", "sp-std 14.0.0 (git+https://github.com/subcoin-project/polkadot-sdk?branch=subcoin-v4)", "sp-version-proc-macro", - "thiserror", + "thiserror 1.0.68", ] [[package]] @@ -10325,7 +10326,7 @@ dependencies = [ "subcoin-service", "subcoin-test-service", "substrate-prometheus-endpoint", - "thiserror", + "thiserror 1.0.68", "tokio", "tracing", ] @@ -10413,7 +10414,7 @@ dependencies = [ "sp-runtime", "subcoin-network", "subcoin-primitives", - "thiserror", + "thiserror 1.0.68", ] [[package]] @@ -10502,7 +10503,7 @@ dependencies = [ "substrate-frame-rpc-system", "substrate-prometheus-endpoint", "tempfile", - "thiserror", + "thiserror 1.0.68", "tokio", "tracing", ] @@ -10618,7 +10619,7 @@ dependencies = [ "hyper-util", "log", "prometheus", - "thiserror", + "thiserror 1.0.68", "tokio", ] @@ -10683,7 +10684,7 @@ dependencies = [ "subxt-lightclient", "subxt-macro", "subxt-metadata", - "thiserror", + "thiserror 1.0.68", "tokio", "tokio-util", "tracing", @@ -10705,7 +10706,7 @@ dependencies = [ "scale-typegen", "subxt-metadata", "syn 2.0.87", - "thiserror", + "thiserror 1.0.68", ] [[package]] @@ -10748,7 +10749,7 @@ dependencies = [ "serde", "serde_json", "smoldot-light", - "thiserror", + "thiserror 1.0.68", "tokio", "tokio-stream", "tracing", @@ -10821,7 +10822,7 @@ checksum = "3082b17a86e3c3fe45d858d94d68f6b5247caace193dad6201688f24db8ba9bb" dependencies = [ "hex", "parity-scale-codec", - "thiserror", + "thiserror 1.0.68", ] [[package]] @@ -10945,7 +10946,16 @@ version = "1.0.68" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "02dd99dc800bbb97186339685293e1cc5d9df1f8fae2d0aecd9ff1c77efea892" dependencies = [ - "thiserror-impl", + "thiserror-impl 1.0.68", +] + +[[package]] +name = "thiserror" +version = "2.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c006c85c7651b3cf2ada4584faa36773bd07bac24acfb39f3c431b36d7e667aa" +dependencies = [ + "thiserror-impl 2.0.3", ] [[package]] @@ -10959,6 +10969,17 @@ dependencies = [ "syn 2.0.87", ] +[[package]] +name = "thiserror-impl" +version = "2.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f077553d607adc1caf65430528a576c757a71ed73944b66ebb58ef2bbd243568" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + [[package]] name = "thousands" version = "0.2.0" @@ -11377,7 +11398,7 @@ dependencies = [ "rand", "smallvec", "socket2 0.4.10", - "thiserror", + "thiserror 1.0.68", "tinyvec", "tokio", "tracing", @@ -11402,7 +11423,7 @@ dependencies = [ "once_cell", "rand", "smallvec", - "thiserror", + "thiserror 1.0.68", "tinyvec", "tokio", "tracing", @@ -11424,7 +11445,7 @@ dependencies = [ "rand", "resolv-conf", "smallvec", - "thiserror", + "thiserror 1.0.68", "tokio", "tracing", "trust-dns-proto 0.23.2", @@ -11457,7 +11478,7 @@ dependencies = [ "rand", "rustls 0.21.12", "sha1", - "thiserror", + "thiserror 1.0.68", "url", "utf-8", ] @@ -11675,7 +11696,7 @@ dependencies = [ "rand_core", "sha2 0.10.8", "sha3", - "thiserror", + "thiserror 1.0.68", "zeroize", ] @@ -11799,7 +11820,7 @@ dependencies = [ "strum 0.24.1", "strum_macros 0.24.3", "tempfile", - "thiserror", + "thiserror 1.0.68", "wasm-opt-cxx-sys", "wasm-opt-sys", ] @@ -11975,7 +11996,7 @@ dependencies = [ "log", "object 0.30.4", "target-lexicon", - "thiserror", + "thiserror 1.0.68", "wasmparser", "wasmtime-cranelift-shared", "wasmtime-environ", @@ -12010,7 +12031,7 @@ dependencies = [ "object 0.30.4", "serde", "target-lexicon", - "thiserror", + "thiserror 1.0.68", "wasmparser", "wasmtime-types", ] @@ -12093,7 +12114,7 @@ checksum = "a4f6fffd2a1011887d57f07654dd112791e872e3ff4a2e626aee8059ee17f06f" dependencies = [ "cranelift-entity", "serde", - "thiserror", + "thiserror 1.0.68", "wasmparser", ] @@ -12484,7 +12505,7 @@ dependencies = [ "nom", "oid-registry 0.6.1", "rusticata-macros", - "thiserror", + "thiserror 1.0.68", "time", ] @@ -12501,7 +12522,7 @@ dependencies = [ "nom", "oid-registry 0.7.0", "rusticata-macros", - "thiserror", + "thiserror 1.0.68", "time", ] diff --git a/Cargo.toml b/Cargo.toml index 0c2081c3..9eb7c64e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -34,7 +34,7 @@ async-channel = "1.8.0" async-trait = "0.1" bitcoin = { git = "https://github.com/liuchengxu/rust-bitcoin", branch = "0.32.x-subcoin", default-features = false } bitcoinconsensus = "0.105.0+25.1" -bitcoin-explorer = { git = "https://github.com/liuchengxu/Rusty-Bitcoin-Explorer", branch = "rust-bitcoin-upgrade", default-features = false } +bitcoin-explorer = { git = "https://github.com/liuchengxu/Rusty-Bitcoin-Explorer", branch = "main", default-features = false } chrono = "0.4.37" clap = { version = "4", features = ["derive"] } codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false } diff --git a/crates/subcoin-node/src/commands/blockchain/parse_block.rs b/crates/subcoin-node/src/commands/blockchain/parse_block.rs index baae075b..9fff1ec6 100644 --- a/crates/subcoin-node/src/commands/blockchain/parse_block.rs +++ b/crates/subcoin-node/src/commands/blockchain/parse_block.rs @@ -1,7 +1,6 @@ use crate::commands::blockchain::{ClientParams, MergedParams}; -use sc_client_api::HeaderBackend; +use sc_client_api::{BlockBackend, HeaderBackend}; use std::sync::Arc; -use subcoin_primitives::BitcoinTransactionAdapter; use subcoin_service::FullClient; #[derive(Debug, clap::Parser)] @@ -30,23 +29,26 @@ impl ParseBlockCmd { sp_blockchain::Error::Backend(format!("Hash for {block_number} not found")) })?; - let block_body = client.body(block_hash)?.ok_or_else(|| { + let substrate_block = client.block(block_hash)?.ok_or_else(|| { sp_blockchain::Error::Backend(format!( - "Body for #{block_number},{block_hash} not found" + "Block for #{block_number},{block_hash} not found" )) })?; - let txdata = block_body - .iter() - .map(|xt| { - >::extrinsic_to_bitcoin_transaction(xt) - }) - .collect::>(); + let btc_block = subcoin_primitives::convert_to_bitcoin_block::< + subcoin_runtime::interface::OpaqueBlock, + subcoin_service::TransactionAdapter, + >(substrate_block.block) + .expect("Failed to convert to Bitcoin Block"); + + println!( + "block_size: {}", + bitcoin::consensus::serialize(&btc_block).len() + ); let mut num_op_return = 0; - for (i, tx) in txdata.into_iter().enumerate() { + + for (i, tx) in btc_block.txdata.into_iter().enumerate() { for (j, output) in tx.output.into_iter().enumerate() { let is_op_return = output.script_pubkey.is_op_return(); println!("{i}:{j}: {is_op_return:?}");