diff --git a/Cargo.lock b/Cargo.lock index 3ee8bca38b..7d7d3e19f7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -14,7 +14,7 @@ dependencies = [ [[package]] name = "accumulator" -version = "0.8.0" +version = "0.8.1" dependencies = [ "anyhow 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)", "bcs-ext", @@ -1206,6 +1206,21 @@ dependencies = [ "serde 1.0.215", ] +[[package]] +name = "bitcoin-client" +version = "0.8.0" +dependencies = [ + "anyhow 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)", + "async-trait", + "bitcoin 0.32.3", + "bitcoincore-rpc", + "coerce", + "serde 1.0.215", + "serde_json", + "tokio", + "tracing", +] + [[package]] name = "bitcoin-internals" version = "0.3.0" @@ -1223,7 +1238,7 @@ checksum = "340e09e8399c7bd8912f495af6aa58bea0c9214773417ffaa8f6460f93aaee56" [[package]] name = "bitcoin-move" -version = "0.8.0" +version = "0.8.1" dependencies = [ "anyhow 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)", "axum", @@ -2827,12 +2842,12 @@ dependencies = [ [[package]] name = "darling" -version = "0.20.9" +version = "0.20.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83b2eb4d90d12bdda5ed17de686c2acb4c57914f8f921b8da7e112b5a36f3fe1" +checksum = "6f63b86c8a8826a49b8c21f08a2d07338eec8d900540f8630dc76284be802989" dependencies = [ - "darling_core 0.20.9", - "darling_macro 0.20.9", + "darling_core 0.20.10", + "darling_macro 0.20.10", ] [[package]] @@ -2865,9 +2880,9 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.20.9" +version = "0.20.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "622687fe0bac72a04e5599029151f5796111b90f1baaa9b544d807a5e31cd120" +checksum = "95133861a8032aaea082871032f5815eb9e98cef03fa916ab4500513994df9e5" dependencies = [ "fnv", "ident_case", @@ -2901,11 +2916,11 @@ dependencies = [ [[package]] name = "darling_macro" -version = "0.20.9" +version = "0.20.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "733cabb43482b1a1b53eee8583c2b9e8684d592215ea83efd305dd31bc2f0178" +checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ - "darling_core 0.20.9", + "darling_core 0.20.10", "quote 1.0.37", "syn 2.0.87", ] @@ -2966,7 +2981,7 @@ dependencies = [ [[package]] name = "data-verify" -version = "0.8.0" +version = "0.8.1" dependencies = [ "anyhow 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)", "rooch-rpc-api", @@ -3081,11 +3096,11 @@ dependencies = [ [[package]] name = "derive_builder" -version = "0.20.1" +version = "0.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd33f37ee6a119146a1781d3356a7c26028f83d779b2e04ecd45fdc75c76877b" +checksum = "507dfb09ea8b7fa618fcf76e953f4f5e192547945816d5358edffe39f6f94947" dependencies = [ - "derive_builder_macro 0.20.1", + "derive_builder_macro 0.20.2", ] [[package]] @@ -3102,11 +3117,11 @@ dependencies = [ [[package]] name = "derive_builder_core" -version = "0.20.1" +version = "0.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7431fa049613920234f22c47fdc33e6cf3ee83067091ea4277a3f8c4587aae38" +checksum = "2d5bcf7b024d6835cfb3d473887cd966994907effbe9227e8c8219824d06c4e8" dependencies = [ - "darling 0.20.9", + "darling 0.20.10", "proc-macro2 1.0.92", "quote 1.0.37", "syn 2.0.87", @@ -3124,11 +3139,11 @@ dependencies = [ [[package]] name = "derive_builder_macro" -version = "0.20.1" +version = "0.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4abae7035bf79b9877b779505d8cf3749285b80c43941eda66604841889451dc" +checksum = "ab63b0e2bf4d5928aff72e83a7dace85d7bba5fe12dcc3c5a572d78caffd3f3c" dependencies = [ - "derive_builder_core 0.20.1", + "derive_builder_core 0.20.2", "syn 2.0.87", ] @@ -3356,7 +3371,7 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0892a17df262a24294c382f0d5997571006e7a4348b4327557c4ff1cd4a8bccc" dependencies = [ - "darling 0.20.9", + "darling 0.20.10", "either", "heck 0.5.0", "proc-macro2 1.0.92", @@ -3619,7 +3634,7 @@ version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e08b6c6ab82d70f08844964ba10c7babb716de2ecaeab9be5717918a5177d3af" dependencies = [ - "darling 0.20.9", + "darling 0.20.10", "proc-macro2 1.0.92", "quote 1.0.37", "syn 2.0.87", @@ -4544,7 +4559,7 @@ dependencies = [ [[package]] name = "framework-builder" -version = "0.8.0" +version = "0.8.1" dependencies = [ "anyhow 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)", "bcs", @@ -4568,7 +4583,7 @@ dependencies = [ [[package]] name = "framework-release" -version = "0.8.0" +version = "0.8.1" dependencies = [ "anyhow 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)", "bcs", @@ -4584,7 +4599,7 @@ dependencies = [ [[package]] name = "framework-types" -version = "0.8.0" +version = "0.8.1" dependencies = [ "move-core-types", "moveos-stdlib", @@ -6677,7 +6692,7 @@ dependencies = [ [[package]] name = "metrics" -version = "0.8.0" +version = "0.8.1" dependencies = [ "anyhow 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)", "async-trait", @@ -7524,7 +7539,7 @@ dependencies = [ [[package]] name = "moveos" -version = "0.8.0" +version = "0.8.1" dependencies = [ "anyhow 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)", "clap 4.5.17", @@ -7563,7 +7578,7 @@ dependencies = [ [[package]] name = "moveos-common" -version = "0.8.0" +version = "0.8.1" dependencies = [ "anyhow 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)", "bcs", @@ -7578,7 +7593,7 @@ dependencies = [ [[package]] name = "moveos-compiler" -version = "0.8.0" +version = "0.8.1" dependencies = [ "anyhow 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)", "move-binary-format", @@ -7587,7 +7602,7 @@ dependencies = [ [[package]] name = "moveos-config" -version = "0.8.0" +version = "0.8.1" dependencies = [ "clap 4.5.17", "serde 1.0.215", @@ -7596,7 +7611,7 @@ dependencies = [ [[package]] name = "moveos-eventbus" -version = "0.8.0" +version = "0.8.1" dependencies = [ "anyhow 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)", "coerce", @@ -7607,7 +7622,7 @@ dependencies = [ [[package]] name = "moveos-gas-profiling" -version = "0.8.0" +version = "0.8.1" dependencies = [ "anyhow 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)", "handlebars", @@ -7624,7 +7639,7 @@ dependencies = [ [[package]] name = "moveos-object-runtime" -version = "0.8.0" +version = "0.8.1" dependencies = [ "bcs", "better_any", @@ -7640,7 +7655,7 @@ dependencies = [ [[package]] name = "moveos-stdlib" -version = "0.8.0" +version = "0.8.1" dependencies = [ "anyhow 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)", "base64 0.22.1", @@ -7673,7 +7688,7 @@ dependencies = [ [[package]] name = "moveos-store" -version = "0.8.0" +version = "0.8.1" dependencies = [ "accumulator", "anyhow 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)", @@ -7686,6 +7701,7 @@ dependencies = [ "moveos-types", "once_cell", "prometheus", + "quick_cache", "rand 0.8.5", "raw-store", "smt", @@ -7695,7 +7711,7 @@ dependencies = [ [[package]] name = "moveos-types" -version = "0.8.0" +version = "0.8.1" dependencies = [ "anyhow 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)", "bcs", @@ -7722,7 +7738,7 @@ dependencies = [ [[package]] name = "moveos-verifier" -version = "0.8.0" +version = "0.8.1" dependencies = [ "anyhow 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)", "bcs", @@ -7747,7 +7763,7 @@ dependencies = [ [[package]] name = "moveos-wasm" -version = "0.8.0" +version = "0.8.1" dependencies = [ "anyhow 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)", "once_cell", @@ -9372,6 +9388,18 @@ dependencies = [ "serde 1.0.215", ] +[[package]] +name = "quick_cache" +version = "0.6.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d7c94f8935a9df96bb6380e8592c70edf497a643f94bd23b2f76b399385dbf4" +dependencies = [ + "ahash 0.8.11", + "equivalent", + "hashbrown 0.14.5", + "parking_lot 0.12.3", +] + [[package]] name = "quinn" version = "0.11.5" @@ -9561,7 +9589,7 @@ dependencies = [ [[package]] name = "raw-store" -version = "0.8.0" +version = "0.8.1" dependencies = [ "anyhow 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)", "metrics", @@ -10031,7 +10059,7 @@ dependencies = [ [[package]] name = "rooch" -version = "0.8.0" +version = "0.8.1" dependencies = [ "anyhow 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)", "async-trait", @@ -10118,7 +10146,7 @@ dependencies = [ [[package]] name = "rooch-benchmarks" -version = "0.8.0" +version = "0.8.1" dependencies = [ "anyhow 1.0.76", "anyhow 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)", @@ -10173,14 +10201,14 @@ dependencies = [ [[package]] name = "rooch-common" -version = "0.8.0" +version = "0.8.1" dependencies = [ "libc", ] [[package]] name = "rooch-config" -version = "0.8.0" +version = "0.8.1" dependencies = [ "anyhow 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)", "clap 4.5.17", @@ -10199,7 +10227,7 @@ dependencies = [ [[package]] name = "rooch-cosmwasm-vm" -version = "0.8.0" +version = "0.8.1" dependencies = [ "cosmwasm-std", "cosmwasm-vm", @@ -10211,7 +10239,7 @@ dependencies = [ [[package]] name = "rooch-da" -version = "0.8.0" +version = "0.8.1" dependencies = [ "anyhow 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)", "async-trait", @@ -10234,7 +10262,7 @@ dependencies = [ [[package]] name = "rooch-db" -version = "0.8.0" +version = "0.8.1" dependencies = [ "accumulator", "anyhow 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)", @@ -10252,7 +10280,7 @@ dependencies = [ [[package]] name = "rooch-event" -version = "0.8.0" +version = "0.8.1" dependencies = [ "anyhow 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)", "async-trait", @@ -10264,7 +10292,7 @@ dependencies = [ [[package]] name = "rooch-executor" -version = "0.8.0" +version = "0.8.1" dependencies = [ "anyhow 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)", "async-trait", @@ -10289,7 +10317,7 @@ dependencies = [ [[package]] name = "rooch-faucet" -version = "0.8.0" +version = "0.8.1" dependencies = [ "anyhow 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)", "async-trait", @@ -10316,7 +10344,7 @@ dependencies = [ [[package]] name = "rooch-framework" -version = "0.8.0" +version = "0.8.1" dependencies = [ "bitcoin 0.32.3", "fastcrypto 0.1.8 (git+https://github.com/MystenLabs/fastcrypto?rev=56f6223b84ada922b6cb2c672c69db2ea3dc6a13)", @@ -10336,11 +10364,12 @@ dependencies = [ [[package]] name = "rooch-framework-tests" -version = "0.8.0" +version = "0.8.1" dependencies = [ "anyhow 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)", "bcs", "bitcoin 0.32.3", + "bitcoin-client", "clap 4.5.17", "coerce", "csv", @@ -10362,7 +10391,6 @@ dependencies = [ "rooch-integration-test-runner", "rooch-key", "rooch-ord", - "rooch-relayer", "rooch-types", "serde 1.0.215", "serde_json", @@ -10374,7 +10402,7 @@ dependencies = [ [[package]] name = "rooch-genesis" -version = "0.8.0" +version = "0.8.1" dependencies = [ "accumulator", "anyhow 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)", @@ -10405,7 +10433,7 @@ dependencies = [ [[package]] name = "rooch-indexer" -version = "0.8.0" +version = "0.8.1" dependencies = [ "anyhow 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)", "async-trait", @@ -10432,7 +10460,7 @@ dependencies = [ [[package]] name = "rooch-integration-test-runner" -version = "0.8.0" +version = "0.8.1" dependencies = [ "anyhow 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)", "bcs", @@ -10465,7 +10493,7 @@ dependencies = [ [[package]] name = "rooch-key" -version = "0.8.0" +version = "0.8.1" dependencies = [ "anyhow 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)", "argon2", @@ -10484,7 +10512,7 @@ dependencies = [ [[package]] name = "rooch-nursery" -version = "0.8.0" +version = "0.8.1" dependencies = [ "ciborium", "cosmwasm-std", @@ -10509,7 +10537,7 @@ dependencies = [ [[package]] name = "rooch-open-rpc" -version = "0.8.0" +version = "0.8.1" dependencies = [ "anyhow 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)", "clap 4.5.17", @@ -10524,7 +10552,7 @@ dependencies = [ [[package]] name = "rooch-open-rpc-macros" -version = "0.8.0" +version = "0.8.1" dependencies = [ "derive-syn-parse", "itertools 0.13.0", @@ -10536,7 +10564,7 @@ dependencies = [ [[package]] name = "rooch-open-rpc-spec" -version = "0.8.0" +version = "0.8.1" dependencies = [ "clap 4.5.17", "pretty_assertions", @@ -10547,7 +10575,7 @@ dependencies = [ [[package]] name = "rooch-open-rpc-spec-builder" -version = "0.8.0" +version = "0.8.1" dependencies = [ "anyhow 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)", "clap 4.5.17", @@ -10585,7 +10613,7 @@ dependencies = [ [[package]] name = "rooch-ord" -version = "0.8.0" +version = "0.8.1" dependencies = [ "anyhow 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)", "ordinals", @@ -10599,11 +10627,13 @@ dependencies = [ [[package]] name = "rooch-pipeline-processor" -version = "0.8.0" +version = "0.8.1" dependencies = [ "anyhow 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)", "async-trait", "bcs", + "bitcoin 0.32.3", + "bitcoin-client", "coerce", "function_name", "hex", @@ -10623,7 +10653,7 @@ dependencies = [ [[package]] name = "rooch-proposer" -version = "0.8.0" +version = "0.8.1" dependencies = [ "anyhow 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)", "async-trait", @@ -10640,11 +10670,12 @@ dependencies = [ [[package]] name = "rooch-relayer" -version = "0.8.0" +version = "0.8.1" dependencies = [ "anyhow 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)", "async-trait", "bitcoin 0.32.3", + "bitcoin-client", "bitcoincore-rpc", "chrono", "coerce", @@ -10660,15 +10691,12 @@ dependencies = [ "rooch-executor", "rooch-pipeline-processor", "rooch-types", - "serde 1.0.215", - "serde_json", - "tokio", "tracing", ] [[package]] name = "rooch-rpc-api" -version = "0.8.0" +version = "0.8.1" dependencies = [ "accumulator", "anyhow 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)", @@ -10693,7 +10721,7 @@ dependencies = [ [[package]] name = "rooch-rpc-client" -version = "0.8.0" +version = "0.8.1" dependencies = [ "anyhow 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)", "bcs", @@ -10715,11 +10743,12 @@ dependencies = [ [[package]] name = "rooch-rpc-server" -version = "0.8.0" +version = "0.8.1" dependencies = [ "anyhow 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)", "axum", "bcs", + "bitcoin-client", "bitcoincore-rpc", "coerce", "dashmap 6.0.1", @@ -10762,7 +10791,7 @@ dependencies = [ [[package]] name = "rooch-sequencer" -version = "0.8.0" +version = "0.8.1" dependencies = [ "accumulator", "anyhow 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)", @@ -10787,7 +10816,7 @@ dependencies = [ [[package]] name = "rooch-store" -version = "0.8.0" +version = "0.8.1" dependencies = [ "accumulator", "anyhow 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)", @@ -10804,7 +10833,7 @@ dependencies = [ [[package]] name = "rooch-test-transaction-builder" -version = "0.8.0" +version = "0.8.1" dependencies = [ "anyhow 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)", "bcs", @@ -10818,7 +10847,7 @@ dependencies = [ [[package]] name = "rooch-types" -version = "0.8.0" +version = "0.8.1" dependencies = [ "accumulator", "anyhow 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)", @@ -11163,9 +11192,9 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.17" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "955d28af4278de8121b7ebeb796b6a45735dc01436d898801014aced2773a3d6" +checksum = "0e819f2bc632f285be6d7cd36e25940d45b2391dd6d9b939e79de557f7014248" [[package]] name = "rusty-fork" @@ -11721,7 +11750,7 @@ version = "2.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "881b6f881b17d13214e5d494c939ebab463d01264ce1811e9d4ac3a882e7695f" dependencies = [ - "darling 0.20.9", + "darling 0.20.10", "proc-macro2 1.0.92", "quote 1.0.37", "syn 2.0.87", @@ -11733,7 +11762,7 @@ version = "3.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8fee4991ef4f274617a51ad4af30519438dacb2f56ac773b08a1922ff743350" dependencies = [ - "darling 0.20.9", + "darling 0.20.10", "proc-macro2 1.0.92", "quote 1.0.37", "syn 2.0.87", @@ -12068,7 +12097,7 @@ checksum = "b7c388c1b5e93756d0c740965c41e8822f866621d41acbdf6336a6a168f8840c" [[package]] name = "smt" -version = "0.8.0" +version = "0.8.1" dependencies = [ "anyhow 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)", "backtrace", @@ -12635,7 +12664,7 @@ dependencies = [ [[package]] name = "testsuite" -version = "0.8.0" +version = "0.8.1" dependencies = [ "anyhow 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)", "assert_cmd", @@ -12746,7 +12775,7 @@ dependencies = [ [[package]] name = "timeout-join-handler" -version = "0.8.0" +version = "0.8.1" dependencies = [ "anyhow 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)", "thiserror", @@ -13636,7 +13665,7 @@ checksum = "c32e7318e93a9ac53693b6caccfb05ff22e04a44c7cf8a279051f24c09da286f" dependencies = [ "anyhow 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)", "cargo_metadata", - "derive_builder 0.20.1", + "derive_builder 0.20.2", "getset", "regex", "rustc_version 0.4.0", @@ -13652,7 +13681,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a62c52cd2b2b8b7ec75fc20111b3022ac3ff83e4fc14b9497cfcfd39c54f9c67" dependencies = [ "anyhow 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)", - "derive_builder 0.20.1", + "derive_builder 0.20.2", "git2", "rustversion", "time", @@ -13667,20 +13696,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e06bee42361e43b60f363bad49d63798d0f42fb1768091812270eca00c784720" dependencies = [ "anyhow 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)", - "derive_builder 0.20.1", + "derive_builder 0.20.2", "getset", "rustversion", ] [[package]] name = "vergen-pretty" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9579e7d75e528471646aa8c9bf11392154f3f8e0b02d94211bc5d57701d010f0" +checksum = "69f0cedcb598e15120e748b19e97426e376be2ec27987570e11bbd350d0bdb09" dependencies = [ "anyhow 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)", "convert_case 0.6.0", - "derive_builder 0.20.1", + "derive_builder 0.20.2", "rustversion", ] diff --git a/Cargo.toml b/Cargo.toml index a2677ac56b..bfa060bd93 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,6 +20,7 @@ members = [ "moveos/smt", "moveos/moveos-eventbus", "moveos/moveos-gas-profiling", + "crates/bitcoin-client", "crates/data_verify", "crates/rooch", "crates/rooch-benchmarks", @@ -59,7 +60,7 @@ members = [ "frameworks/framework-types", "frameworks/moveos-stdlib", "frameworks/rooch-framework", - "frameworks/rooch-nursery", + "frameworks/rooch-nursery", "crates/bitcoin-client", "third_party/move/language/move-compiler-v2" ] @@ -85,7 +86,7 @@ license = "Apache-2.0" publish = false repository = "https://github.com/rooch-network/rooch" rust-version = "1.82.0" -version = "0.8.0" +version = "0.8.1" [workspace.dependencies] # Internal crate dependencies. @@ -109,6 +110,8 @@ accumulator = { path = "moveos/moveos-commons/accumulator" } moveos-gas-profiling = { path = "moveos/moveos-gas-profiling" } # crates for Rooch +bitcoin-client = { path = "crates/bitcoin-client" } +data-verify = { path = "crates/data_verify" } rooch = { path = "crates/rooch" } rooch-common = { path = "crates/rooch-common" } rooch-key = { path = "crates/rooch-key" } @@ -136,7 +139,6 @@ rooch-da = { path = "crates/rooch-da" } rooch-benchmarks = { path = "crates/rooch-benchmarks" } rooch-faucet = { path = "crates/rooch-faucet" } rooch-test-transaction-builder = { path = "crates/rooch-test-transaction-builder" } -data-verify = { path = "crates/data_verify" } rooch-db = { path = "crates/rooch-db" } rooch-event = { path = "crates/rooch-event" } rooch-ord = { path = "crates/rooch-ord" } @@ -267,6 +269,7 @@ tower_governor = { version = "0.4.3", features = ["tracing"] } pin-project = "1.1.7" mirai-annotations = "1.12.0" lru = "0.11.0" +quick_cache = "0.6.9" bs58 = "0.5.1" dirs-next = "2.0.0" anstream = { version = "0.3" } @@ -351,7 +354,7 @@ function_name = { version = "0.3.0" } rustc-hash = { version = "2.0.0" } xorf = { version = "0.11.0" } vergen-git2 = { version = "1.0.0", features = ["build", "cargo", "rustc"] } -vergen-pretty = "0.3.5" +vergen-pretty = "0.3.6" crossbeam-channel = "0.5.13" inferno = "0.11.21" handlebars = "4.2.2" diff --git a/crates/bitcoin-client/Cargo.toml b/crates/bitcoin-client/Cargo.toml new file mode 100644 index 0000000000..8657195511 --- /dev/null +++ b/crates/bitcoin-client/Cargo.toml @@ -0,0 +1,21 @@ +[package] +name = "bitcoin-client" +authors.workspace = true +edition.workspace = true +homepage.workspace = true +license.workspace = true +publish.workspace = true +repository.workspace = true +rust-version.workspace = true +version.workspace = true + +[dependencies] +anyhow = { workspace = true } +async-trait = { workspace = true } +bitcoin = { workspace = true } +bitcoincore-rpc = { workspace = true } +coerce = { workspace = true } +serde = { workspace = true } +serde_json = { workspace = true } +tokio = { features = ["full"], workspace = true } +tracing = { workspace = true } \ No newline at end of file diff --git a/crates/rooch-relayer/src/actor/bitcoin_client.rs b/crates/bitcoin-client/src/actor/client.rs similarity index 92% rename from crates/rooch-relayer/src/actor/bitcoin_client.rs rename to crates/bitcoin-client/src/actor/client.rs index df2e722737..da14b4b72f 100644 --- a/crates/rooch-relayer/src/actor/bitcoin_client.rs +++ b/crates/bitcoin-client/src/actor/client.rs @@ -1,10 +1,10 @@ // Copyright (c) RoochNetwork // SPDX-License-Identifier: Apache-2.0 -use super::messages::{GetChainTipsMessage, GetRawTransactionMessage, GetTxOutMessage}; use crate::actor::messages::{ BroadcastTransactionMessage, GetBestBlockHashMessage, GetBlockHashMessage, - GetBlockHeaderInfoMessage, GetBlockMessage, + GetBlockHeaderInfoMessage, GetBlockMessage, GetChainTipsMessage, GetRawTransactionMessage, + GetTxOutMessage, }; use anyhow::Result; use async_trait::async_trait; @@ -20,6 +20,22 @@ pub struct BitcoinClientActor { retry_delay: Duration, } +pub struct BitcoinClientConfig { + pub btc_rpc_url: String, + pub btc_rpc_user_name: String, + pub btc_rpc_password: String, +} + +impl BitcoinClientConfig { + pub fn build(&self) -> Result { + BitcoinClientActor::new( + &self.btc_rpc_url, + &self.btc_rpc_user_name, + &self.btc_rpc_password, + ) + } +} + impl BitcoinClientActor { pub fn new(btc_rpc_url: &str, btc_rpc_user_name: &str, btc_rpc_password: &str) -> Result { let rpc_client = Client::new( diff --git a/crates/bitcoin-client/src/actor/messages.rs b/crates/bitcoin-client/src/actor/messages.rs new file mode 100644 index 0000000000..42a1f7ce5a --- /dev/null +++ b/crates/bitcoin-client/src/actor/messages.rs @@ -0,0 +1,91 @@ +// Copyright (c) RoochNetwork +// SPDX-License-Identifier: Apache-2.0 + +use anyhow::Result; +use bitcoin::Transaction; +use bitcoincore_rpc::bitcoin::Txid; +use bitcoincore_rpc::json; +use coerce::actor::message::Message; +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Serialize, Deserialize)] +pub struct GetBlockMessage { + pub hash: bitcoin::BlockHash, +} + +impl Message for GetBlockMessage { + type Result = Result; +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct GetBestBlockHashMessage {} + +impl Message for GetBestBlockHashMessage { + type Result = Result; +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct GetBlockHashMessage { + pub height: u64, +} + +impl Message for GetBlockHashMessage { + type Result = Result; +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct GetBlockHeaderInfoMessage { + pub hash: bitcoin::BlockHash, +} + +impl Message for GetBlockHeaderInfoMessage { + type Result = Result; +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct GetChainTipsMessage {} + +impl Message for GetChainTipsMessage { + type Result = Result; +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct BroadcastTransactionMessage { + pub hex: String, + pub maxfeerate: Option, + pub maxburnamount: Option, +} + +impl Message for BroadcastTransactionMessage { + type Result = Result; +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct GetTxOutMessage { + pub txid: Txid, + pub vout: u32, + pub include_mempool: Option, +} + +impl GetTxOutMessage { + pub fn new(txid: Txid, vout: u32) -> Self { + Self { + txid, + vout, + include_mempool: Some(false), + } + } +} + +impl Message for GetTxOutMessage { + type Result = Result>; +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct GetRawTransactionMessage { + pub txid: Txid, +} + +impl Message for GetRawTransactionMessage { + type Result = Result; +} diff --git a/crates/bitcoin-client/src/actor/mod.rs b/crates/bitcoin-client/src/actor/mod.rs new file mode 100644 index 0000000000..5a5fd5db41 --- /dev/null +++ b/crates/bitcoin-client/src/actor/mod.rs @@ -0,0 +1,5 @@ +// Copyright (c) RoochNetwork +// SPDX-License-Identifier: Apache-2.0 + +pub mod client; +pub mod messages; diff --git a/crates/bitcoin-client/src/lib.rs b/crates/bitcoin-client/src/lib.rs new file mode 100644 index 0000000000..c6dbf6b1fd --- /dev/null +++ b/crates/bitcoin-client/src/lib.rs @@ -0,0 +1,5 @@ +// Copyright (c) RoochNetwork +// SPDX-License-Identifier: Apache-2.0 + +pub mod actor; +pub mod proxy; diff --git a/crates/rooch-relayer/src/actor/bitcoin_client_proxy.rs b/crates/bitcoin-client/src/proxy/mod.rs similarity index 91% rename from crates/rooch-relayer/src/actor/bitcoin_client_proxy.rs rename to crates/bitcoin-client/src/proxy/mod.rs index 4f63850ab6..8816fa806a 100644 --- a/crates/rooch-relayer/src/actor/bitcoin_client_proxy.rs +++ b/crates/bitcoin-client/src/proxy/mod.rs @@ -1,10 +1,11 @@ // Copyright (c) RoochNetwork // SPDX-License-Identifier: Apache-2.0 -use crate::actor::bitcoin_client::BitcoinClientActor; +use crate::actor::client::BitcoinClientActor; use crate::actor::messages::{ BroadcastTransactionMessage, GetBestBlockHashMessage, GetBlockHashMessage, - GetBlockHeaderInfoMessage, GetBlockMessage, + GetBlockHeaderInfoMessage, GetBlockMessage, GetChainTipsMessage, GetRawTransactionMessage, + GetTxOutMessage, }; use anyhow::Result; use bitcoin::Transaction; @@ -12,8 +13,6 @@ use bitcoincore_rpc::bitcoin::Txid; use bitcoincore_rpc::json; use coerce::actor::ActorRef; -use super::messages::{GetChainTipsMessage, GetRawTransactionMessage, GetTxOutMessage}; - #[derive(Clone)] pub struct BitcoinClientProxy { pub actor: ActorRef, diff --git a/crates/rooch-common/Cargo.toml b/crates/rooch-common/Cargo.toml index 95a50aa419..55bf3f4208 100644 --- a/crates/rooch-common/Cargo.toml +++ b/crates/rooch-common/Cargo.toml @@ -12,4 +12,4 @@ repository = { workspace = true } rust-version = { workspace = true } [dependencies] -libc = { workspace = true } \ No newline at end of file +libc = { workspace = true } diff --git a/crates/rooch-framework-tests/Cargo.toml b/crates/rooch-framework-tests/Cargo.toml index 50bc89b1ba..4f7203c83f 100644 --- a/crates/rooch-framework-tests/Cargo.toml +++ b/crates/rooch-framework-tests/Cargo.toml @@ -37,13 +37,13 @@ moveos-store = { workspace = true } moveos-config = { workspace = true } metrics = { workspace = true } +bitcoin-client = { workspace = true } rooch-genesis = { workspace = true } rooch-types = { workspace = true } rooch-key = { workspace = true } rooch-executor = { workspace = true } rooch-config = { workspace = true } rooch-db = { workspace = true } -rooch-relayer = { workspace = true } rooch-ord = { workspace = true } framework-builder = { workspace = true } diff --git a/crates/rooch-framework-tests/src/bitcoin_block_tester.rs b/crates/rooch-framework-tests/src/bitcoin_block_tester.rs index 4bd413a352..091658544d 100644 --- a/crates/rooch-framework-tests/src/bitcoin_block_tester.rs +++ b/crates/rooch-framework-tests/src/bitcoin_block_tester.rs @@ -4,6 +4,7 @@ use crate::{bbn_tx_loader::BBNStakingTxRecord, binding_test::RustBindingTest}; use anyhow::{anyhow, bail, ensure, Result}; use bitcoin::{hashes::Hash, Block, OutPoint, TxOut, Txid}; +use bitcoin_client::proxy::BitcoinClientProxy; use framework_builder::stdlib_version::StdlibVersion; use move_core_types::{account_address::AccountAddress, u256::U256, vm_status::KeptVMStatus}; use moveos_types::{ @@ -16,7 +17,6 @@ use moveos_types::{ state_resolver::StateResolver, }; use rooch_ord::ord_client::Charm; -use rooch_relayer::actor::bitcoin_client_proxy::BitcoinClientProxy; use rooch_types::{ bitcoin::{ bbn::{ diff --git a/crates/rooch-framework-tests/src/main.rs b/crates/rooch-framework-tests/src/main.rs index fb63c1e195..b841a48a5b 100644 --- a/crates/rooch-framework-tests/src/main.rs +++ b/crates/rooch-framework-tests/src/main.rs @@ -4,12 +4,11 @@ use std::path::PathBuf; use anyhow::Result; +use bitcoin_client::actor::client::BitcoinClientActor; +use bitcoin_client::proxy::BitcoinClientProxy; use clap::Parser; use coerce::actor::{system::ActorSystem, IntoActor}; use rooch_framework_tests::bitcoin_block_tester::TesterGenesisBuilder; -use rooch_relayer::actor::{ - bitcoin_client::BitcoinClientActor, bitcoin_client_proxy::BitcoinClientProxy, -}; #[derive(Parser)] #[clap(name = "test_builder", author = "The Rooch Core Contributors")] diff --git a/crates/rooch-open-rpc-spec/schemas/openrpc.json b/crates/rooch-open-rpc-spec/schemas/openrpc.json index abc6d7a470..294364d4f1 100644 --- a/crates/rooch-open-rpc-spec/schemas/openrpc.json +++ b/crates/rooch-open-rpc-spec/schemas/openrpc.json @@ -12,7 +12,7 @@ "name": "Apache-2.0", "url": "https://raw.githubusercontent.com/rooch-network/rooch/main/LICENSE" }, - "version": "0.8.0" + "version": "0.8.1" }, "methods": [ { diff --git a/crates/rooch-pipeline-processor/Cargo.toml b/crates/rooch-pipeline-processor/Cargo.toml index f56cdc6e57..c85bb145e8 100644 --- a/crates/rooch-pipeline-processor/Cargo.toml +++ b/crates/rooch-pipeline-processor/Cargo.toml @@ -15,6 +15,7 @@ rust-version = { workspace = true } anyhow = { workspace = true } async-trait = { workspace = true } bcs = { workspace = true } +bitcoin = { workspace = true } coerce = { workspace = true } function_name = { workspace = true } hex = { workspace = true } @@ -25,10 +26,11 @@ moveos = { workspace = true } metrics = { workspace = true } moveos-types = { workspace = true } +bitcoin-client = { workspace = true } rooch-da = { workspace = true } -rooch-types = { workspace = true } -rooch-sequencer = { workspace = true } +rooch-db = { workspace = true } rooch-executor = { workspace = true } -rooch-indexer = { workspace = true } rooch-event = { workspace = true } -rooch-db = { workspace = true } +rooch-indexer = { workspace = true } +rooch-sequencer = { workspace = true } +rooch-types = { workspace = true } diff --git a/crates/rooch-pipeline-processor/src/actor/processor.rs b/crates/rooch-pipeline-processor/src/actor/processor.rs index c700d6ca9c..12681cb099 100644 --- a/crates/rooch-pipeline-processor/src/actor/processor.rs +++ b/crates/rooch-pipeline-processor/src/actor/processor.rs @@ -7,6 +7,8 @@ use super::messages::{ use crate::metrics::PipelineProcessorMetrics; use anyhow::{Error, Result}; use async_trait::async_trait; +use bitcoin::hashes::Hash; +use bitcoin_client::proxy::BitcoinClientProxy; use coerce::actor::{context::ActorContext, message::Handler, Actor, LocalActorRef}; use function_name::named; use moveos::moveos::VMPanicError; @@ -20,6 +22,7 @@ use rooch_event::actor::{EventActor, UpdateServiceStatusMessage}; use rooch_executor::proxy::ExecutorProxy; use rooch_indexer::proxy::IndexerProxy; use rooch_sequencer::proxy::SequencerProxy; +use rooch_types::bitcoin::types::Block as BitcoinBlock; use rooch_types::{ service_status::ServiceStatus, transaction::{ @@ -40,6 +43,7 @@ pub struct PipelineProcessorActor { pub(crate) metrics: Arc, event_actor: Option>, rooch_db: RoochDB, + bitcoin_client_proxy: Option, } impl PipelineProcessorActor { @@ -52,6 +56,7 @@ impl PipelineProcessorActor { registry: &Registry, event_actor: Option>, rooch_db: RoochDB, + bitcoin_client_proxy: Option, ) -> Self { Self { executor, @@ -62,6 +67,7 @@ impl PipelineProcessorActor { metrics: Arc::new(PipelineProcessorMetrics::new(registry)), event_actor, rooch_db, + bitcoin_client_proxy, } } @@ -109,9 +115,30 @@ impl PipelineProcessorActor { .await? .ok_or_else(|| anyhow::anyhow!("The tx with hash {} should exists", tx_hash))?; match &ledger_tx.data { - LedgerTxData::L1Block(_block) => { - //TODO how to get the L1BlockWithBody - unimplemented!("L1Block tx not support") + LedgerTxData::L1Block(block) => { + debug!("process_sequenced_tx_on_startup l1_block_tx: {:?}", block); + match &self.bitcoin_client_proxy { + Some(bitcoin_client_proxy) => { + let block_hash_vec = block.block_hash.clone(); + let block_hash = + bitcoin::block::BlockHash::from_slice(&block_hash_vec)?; + let btc_block = bitcoin_client_proxy.get_block(block_hash).await?; + let block_body = BitcoinBlock::from(btc_block); + let moveos_tx = self + .executor + .validate_l1_block(L1BlockWithBody::new( + block.clone(), + block_body.encode(), + )) + .await?; + self.execute_tx(ledger_tx.clone(), moveos_tx).await?; + } + None => { + return Err(anyhow::anyhow!( + "The bitcoin client proxy should be initialized before processing the sequenced l1_block_tx(block: {:?} on startup", block + )); + } + } } LedgerTxData::L1Tx(l1_tx) => { debug!("process_sequenced_tx_on_startup l1_tx: {:?}", l1_tx); diff --git a/crates/rooch-relayer/Cargo.toml b/crates/rooch-relayer/Cargo.toml index a230a1b274..7af4c3d902 100644 --- a/crates/rooch-relayer/Cargo.toml +++ b/crates/rooch-relayer/Cargo.toml @@ -17,9 +17,6 @@ async-trait = { workspace = true } chrono = { workspace = true } coerce = { workspace = true } ethers = { workspace = true } -serde = { workspace = true } -serde_json = { workspace = true } -tokio = { features = ["full"], workspace = true } tracing = { workspace = true } bitcoin = { workspace = true } bitcoincore-rpc = { workspace = true } @@ -33,6 +30,7 @@ moveos-eventbus = { workspace = true } metrics = { workspace = true } rooch-types = { workspace = true } +bitcoin-client = { workspace = true } rooch-config = { workspace = true } rooch-executor = { workspace = true } rooch-pipeline-processor = { workspace = true } diff --git a/crates/rooch-relayer/src/actor/bitcoin_relayer.rs b/crates/rooch-relayer/src/actor/bitcoin_relayer.rs index 684da6e5d6..a4ce88f878 100644 --- a/crates/rooch-relayer/src/actor/bitcoin_relayer.rs +++ b/crates/rooch-relayer/src/actor/bitcoin_relayer.rs @@ -1,11 +1,11 @@ // Copyright (c) RoochNetwork // SPDX-License-Identifier: Apache-2.0 -use super::messages::{GetReadyL1BlockMessage, GetReadyL1TxsMessage, SyncTick}; -use crate::actor::bitcoin_client_proxy::BitcoinClientProxy; +use crate::actor::messages::{GetReadyL1BlockMessage, GetReadyL1TxsMessage, SyncTick}; use anyhow::Result; use async_trait::async_trait; use bitcoin::{Block, BlockHash}; +use bitcoin_client::proxy::BitcoinClientProxy; use bitcoincore_rpc::bitcoincore_rpc_json::GetBlockHeaderResult; use coerce::actor::{context::ActorContext, message::Handler, Actor}; use moveos_types::module_binding::MoveFunctionCaller; diff --git a/crates/rooch-relayer/src/actor/ethereum_relayer.rs b/crates/rooch-relayer/src/actor/ethereum_relayer.rs index 85f54f3ac0..1b701d3ff9 100644 --- a/crates/rooch-relayer/src/actor/ethereum_relayer.rs +++ b/crates/rooch-relayer/src/actor/ethereum_relayer.rs @@ -1,6 +1,7 @@ // Copyright (c) RoochNetwork // SPDX-License-Identifier: Apache-2.0 +use super::messages::{GetReadyL1BlockMessage, GetReadyL1TxsMessage, SyncTick}; use anyhow::Result; use async_trait::async_trait; use coerce::actor::{context::ActorContext, message::Handler, Actor}; @@ -14,8 +15,6 @@ use rooch_types::{ use std::collections::HashSet; use tracing::info; -use super::messages::{GetReadyL1BlockMessage, GetReadyL1TxsMessage, SyncTick}; - pub struct EthereumRelayer { rpc_client: Provider, processed_blocks: HashSet, diff --git a/crates/rooch-relayer/src/actor/messages.rs b/crates/rooch-relayer/src/actor/messages.rs index 4a97d8bd9b..f9a3b6a561 100644 --- a/crates/rooch-relayer/src/actor/messages.rs +++ b/crates/rooch-relayer/src/actor/messages.rs @@ -1,13 +1,9 @@ // Copyright (c) RoochNetwork // SPDX-License-Identifier: Apache-2.0 -use anyhow::Result; -use bitcoin::Transaction; -use bitcoincore_rpc::bitcoin::Txid; -use bitcoincore_rpc::json; -use coerce::actor::{message::Message, scheduler::timer::TimerTick}; +use coerce::actor::message::Message; +use coerce::actor::scheduler::timer::TimerTick; use rooch_types::transaction::{L1BlockWithBody, L1Transaction}; -use serde::{Deserialize, Serialize}; #[derive(Clone)] pub struct RelayTick {} @@ -18,59 +14,6 @@ impl Message for RelayTick { impl TimerTick for RelayTick {} -#[derive(Debug, Serialize, Deserialize)] -pub struct GetBlockMessage { - pub hash: bitcoin::BlockHash, -} - -impl Message for GetBlockMessage { - type Result = Result; -} - -#[derive(Debug, Serialize, Deserialize)] -pub struct GetBestBlockHashMessage {} - -impl Message for GetBestBlockHashMessage { - type Result = Result; -} - -#[derive(Debug, Serialize, Deserialize)] -pub struct GetBlockHashMessage { - pub height: u64, -} - -impl Message for GetBlockHashMessage { - type Result = Result; -} - -#[derive(Debug, Serialize, Deserialize)] -pub struct GetBlockHeaderInfoMessage { - pub hash: bitcoin::BlockHash, -} - -impl Message for GetBlockHeaderInfoMessage { - type Result = Result; -} - -#[derive(Debug, Serialize, Deserialize)] -pub struct GetChainTipsMessage {} - -impl Message for GetChainTipsMessage { - type Result = Result; -} - -pub struct GetReadyL1BlockMessage {} - -impl Message for GetReadyL1BlockMessage { - type Result = Result>; -} - -pub struct GetReadyL1TxsMessage {} - -impl Message for GetReadyL1TxsMessage { - type Result = Result>; -} - #[derive(Clone)] pub struct SyncTick {} @@ -78,43 +21,14 @@ impl Message for SyncTick { type Result = (); } -#[derive(Debug, Serialize, Deserialize)] -pub struct BroadcastTransactionMessage { - pub hex: String, - pub maxfeerate: Option, - pub maxburnamount: Option, -} - -impl Message for BroadcastTransactionMessage { - type Result = Result; -} - -#[derive(Debug, Serialize, Deserialize)] -pub struct GetTxOutMessage { - pub txid: Txid, - pub vout: u32, - pub include_mempool: Option, -} - -impl GetTxOutMessage { - pub fn new(txid: Txid, vout: u32) -> Self { - Self { - txid, - vout, - include_mempool: Some(false), - } - } -} +pub struct GetReadyL1BlockMessage {} -impl Message for GetTxOutMessage { - type Result = Result>; +impl Message for GetReadyL1BlockMessage { + type Result = anyhow::Result>; } -#[derive(Debug, Serialize, Deserialize)] -pub struct GetRawTransactionMessage { - pub txid: Txid, -} +pub struct GetReadyL1TxsMessage {} -impl Message for GetRawTransactionMessage { - type Result = Result; +impl Message for GetReadyL1TxsMessage { + type Result = anyhow::Result>; } diff --git a/crates/rooch-relayer/src/actor/mod.rs b/crates/rooch-relayer/src/actor/mod.rs index d00aca309c..89e62d4068 100644 --- a/crates/rooch-relayer/src/actor/mod.rs +++ b/crates/rooch-relayer/src/actor/mod.rs @@ -1,8 +1,6 @@ // Copyright (c) RoochNetwork // SPDX-License-Identifier: Apache-2.0 -pub mod bitcoin_client; -pub mod bitcoin_client_proxy; pub mod bitcoin_relayer; pub mod ethereum_relayer; pub mod messages; diff --git a/crates/rooch-relayer/src/actor/relayer.rs b/crates/rooch-relayer/src/actor/relayer.rs index 8ffe13ab0d..eef782c86e 100644 --- a/crates/rooch-relayer/src/actor/relayer.rs +++ b/crates/rooch-relayer/src/actor/relayer.rs @@ -3,12 +3,12 @@ use super::bitcoin_relayer::BitcoinRelayer; use super::ethereum_relayer::EthereumRelayer; -use super::messages::RelayTick; -use crate::actor::bitcoin_client::BitcoinClientActor; -use crate::actor::bitcoin_client_proxy::BitcoinClientProxy; +use crate::actor::messages::RelayTick; use crate::actor::relayer_proxy::RelayerProxy; use anyhow::Result; use async_trait::async_trait; +use bitcoin_client::actor::client::BitcoinClientActor; +use bitcoin_client::proxy::BitcoinClientProxy; use coerce::actor::{context::ActorContext, message::Handler, Actor, LocalActorRef}; use move_core_types::vm_status::KeptVMStatus; use moveos_eventbus::bus::EventData; diff --git a/crates/rooch-rpc-server/Cargo.toml b/crates/rooch-rpc-server/Cargo.toml index f728f2f159..a33492b121 100644 --- a/crates/rooch-rpc-server/Cargo.toml +++ b/crates/rooch-rpc-server/Cargo.toml @@ -39,6 +39,7 @@ moveos-eventbus = { workspace = true } raw-store = { workspace = true } metrics = { workspace = true } +bitcoin-client = { workspace = true } rooch-config = { workspace = true } rooch-types = { workspace = true } rooch-executor = { workspace = true } diff --git a/crates/rooch-rpc-server/src/lib.rs b/crates/rooch-rpc-server/src/lib.rs index 1e90c5680e..758ee00a47 100644 --- a/crates/rooch-rpc-server/src/lib.rs +++ b/crates/rooch-rpc-server/src/lib.rs @@ -11,6 +11,8 @@ use crate::service::metrics::ServiceMetrics; use crate::service::rpc_service::RpcService; use anyhow::{ensure, Error, Result}; use axum::http::{HeaderValue, Method}; +use bitcoin_client::actor::client::BitcoinClientConfig; +use bitcoin_client::proxy::BitcoinClientProxy; use coerce::actor::scheduler::timer::Timer; use coerce::actor::{system::ActorSystem, IntoActor}; use jsonrpsee::RpcModule; @@ -35,8 +37,6 @@ use rooch_pipeline_processor::actor::processor::PipelineProcessorActor; use rooch_pipeline_processor::proxy::PipelineProcessorProxy; use rooch_proposer::actor::messages::ProposeBlock; use rooch_proposer::actor::proposer::ProposerActor; -use rooch_relayer::actor::bitcoin_client::BitcoinClientActor; -use rooch_relayer::actor::bitcoin_client_proxy::BitcoinClientProxy; use rooch_relayer::actor::messages::RelayTick; use rooch_relayer::actor::relayer::RelayerActor; use rooch_rpc_api::api::RoochRpcModule; @@ -346,6 +346,24 @@ pub async fn run_start_server(opt: RoochOpt, server_opt: ServerOpt) -> Result Result Result Result Self { + Self { + state_cache_size: 10_000, + } + } +} diff --git a/moveos/moveos-store/Cargo.toml b/moveos/moveos-store/Cargo.toml index 9da87fc0f0..605f6856b8 100644 --- a/moveos/moveos-store/Cargo.toml +++ b/moveos/moveos-store/Cargo.toml @@ -31,4 +31,5 @@ moveos-types = { workspace = true } raw-store = { workspace = true } moveos-config = { workspace = true } accumulator = { workspace = true } -metrics = { workspace = true } \ No newline at end of file +metrics = { workspace = true } +quick_cache = { workspace = true } \ No newline at end of file diff --git a/moveos/moveos-store/src/lib.rs b/moveos/moveos-store/src/lib.rs index 56acf68823..82a06892ba 100644 --- a/moveos/moveos-store/src/lib.rs +++ b/moveos/moveos-store/src/lib.rs @@ -13,7 +13,7 @@ use accumulator::inmemory::InMemoryAccumulator; use anyhow::{Error, Result}; use bcs::to_bytes; use move_core_types::language_storage::StructTag; -use moveos_config::store_config::RocksdbConfig; +use moveos_config::store_config::{MoveOSStoreConfig, RocksdbConfig}; use moveos_config::DataDirPath; use moveos_types::genesis_info::GenesisInfo; use moveos_types::h256::H256; @@ -100,8 +100,10 @@ impl MoveOSStore { } pub fn new_with_instance(instance: StoreInstance, registry: &Registry) -> Result { + let store_config = MoveOSStoreConfig::default(); let node_store = NodeDBStore::new(instance.clone()); - let state_store = StateDBStore::new(node_store.clone(), registry); + let state_store = + StateDBStore::new(node_store.clone(), registry, store_config.state_cache_size); let store = Self { node_store, diff --git a/moveos/moveos-store/src/state_store/statedb.rs b/moveos/moveos-store/src/state_store/statedb.rs index 88a5fbccbc..56ff5e0532 100644 --- a/moveos/moveos-store/src/state_store/statedb.rs +++ b/moveos/moveos-store/src/state_store/statedb.rs @@ -18,6 +18,7 @@ use moveos_types::state_resolver::StateKV; use moveos_types::state_resolver::StateResolver; use moveos_types::state_resolver::StatelessResolver; use prometheus::Registry; +use quick_cache::sync::Cache; use smt::{SMTIterator, TreeChangeSet}; use smt::{SMTree, UpdateSet}; use std::collections::BTreeMap; @@ -31,14 +32,16 @@ pub struct StateDBStore { pub node_store: NodeDBStore, smt: SMTree, metrics: Arc, + cache: Arc>>, } impl StateDBStore { - pub fn new(node_store: NodeDBStore, registry: &Registry) -> Self { + pub fn new(node_store: NodeDBStore, registry: &Registry, cache_size: usize) -> Self { Self { node_store: node_store.clone(), smt: SMTree::new(node_store, registry), metrics: Arc::new(StateDBMetrics::new(registry)), + cache: Arc::new(Cache::new(cache_size)), } } @@ -97,6 +100,8 @@ impl StateDBStore { Op::Delete => { //TODO clean up the removed object fields update_set.remove(field_key); + let pre_state_root = obj_change.metadata.state_root(); + self.cache.remove(&(pre_state_root, field_key)); return Ok(()); } }, @@ -126,7 +131,8 @@ impl StateDBStore { let new_state_root = tree_change_set.state_root; obj.update_state_root(new_state_root); obj_change.update_state_root(new_state_root); - update_set.put(field_key, obj); + update_set.put(field_key, obj.clone()); + self.cache.insert((new_state_root, field_key), Some(obj)); Ok(()) } @@ -225,7 +231,14 @@ impl StatelessResolver for StateDBStore { if state_root == *GENESIS_STATE_ROOT { return Ok(None); } - let result = self.smt.get(state_root, *key)?; + + let result = if let Some(state) = self.cache.get(&(state_root, *key)) { + state + } else { + let state = self.smt.get(state_root, *key)?; + self.cache.insert((state_root, *key), state.clone()); + state + }; if tracing::enabled!(tracing::Level::TRACE) { let result_info = match &result { Some(state) => format!("Some({})", state.metadata.object_type), @@ -261,6 +274,9 @@ impl StatelessResolver for StateDBStore { .with_label_values(&[fn_name]) .start_timer(); let result = self.smt.list(state_root, cursor, limit)?; + for (key, state) in &result { + self.cache.insert((state_root, *key), Some(state.clone())); + } // Only statistics object value bytes to avoid performance loss caused by serialization let size = result diff --git a/sdk/typescript/rooch-sdk/src/version.ts b/sdk/typescript/rooch-sdk/src/version.ts index 3e74e4c115..6f647ca2a8 100644 --- a/sdk/typescript/rooch-sdk/src/version.ts +++ b/sdk/typescript/rooch-sdk/src/version.ts @@ -4,4 +4,4 @@ // This file is generated by genversion.mjs. Do not edit it directly. export const PACKAGE_VERSION = '0.2.8' -export const TARGETED_RPC_VERSION = '0.8.0' +export const TARGETED_RPC_VERSION = '0.8.1'