From 762e2df9a44eff47c5a8c32674d12b46849a7402 Mon Sep 17 00:00:00 2001 From: jjy Date: Tue, 29 Nov 2022 21:10:39 +0800 Subject: [PATCH 1/4] feat: support non-x86 build --- Cargo.lock | 963 +++++++++++++++--- crates/block-producer/Cargo.toml | 8 +- crates/chain/Cargo.toml | 2 +- crates/challenge/Cargo.toml | 10 +- crates/common/Cargo.toml | 2 +- crates/config/Cargo.toml | 2 +- crates/dynamic-config/Cargo.toml | 2 +- crates/generator/Cargo.toml | 5 +- crates/generator/src/backend_manage.rs | 2 +- crates/generator/src/generator.rs | 4 +- crates/generator/src/types/vm.rs | 2 +- crates/godwoken-bin/Cargo.toml | 2 +- crates/jsonrpc-types/Cargo.toml | 4 +- crates/replay-chain/Cargo.toml | 4 +- crates/rpc-client/Cargo.toml | 6 +- crates/rpc-client/src/ckb_client.rs | 37 +- crates/rpc-client/src/rpc_client.rs | 2 +- crates/rpc-server/Cargo.toml | 6 +- crates/tests/Cargo.toml | 17 +- crates/tools/Cargo.toml | 29 +- crates/tools/src/account.rs | 2 +- crates/tools/src/deploy_genesis.rs | 10 +- crates/tools/src/deploy_scripts.rs | 2 +- crates/tools/src/deposit_ckb.rs | 2 +- crates/tools/src/generate_config.rs | 2 +- crates/tools/src/main.rs | 4 +- crates/tools/src/update_cell.rs | 13 +- crates/tools/src/utils/mod.rs | 1 + crates/tools/src/utils/sdk/constants.rs | 78 ++ crates/tools/src/utils/sdk/mod.rs | 15 + crates/tools/src/utils/sdk/rpc/ckb.rs | 81 ++ crates/tools/src/utils/sdk/rpc/ckb_indexer.rs | 174 ++++ .../src/utils/sdk/rpc/ckb_light_client.rs | 117 +++ crates/tools/src/utils/sdk/rpc/mod.rs | 93 ++ crates/tools/src/utils/sdk/test_utils.rs | 534 ++++++++++ .../src/utils/sdk/traits/default_impls.rs | 585 +++++++++++ .../tools/src/utils/sdk/traits/dummy_impls.rs | 1 + .../utils/sdk/traits/light_client_impls.rs | 268 +++++ crates/tools/src/utils/sdk/traits/mod.rs | 455 +++++++++ .../src/utils/sdk/traits/offchain_impls.rs | 182 ++++ crates/tools/src/utils/sdk/tx_fee.rs | 100 ++ crates/tools/src/utils/sdk/types/address.rs | 784 ++++++++++++++ .../src/utils/sdk/types/human_capacity.rs | 122 +++ crates/tools/src/utils/sdk/types/mod.rs | 13 + .../tools/src/utils/sdk/types/network_type.rs | 59 ++ .../tools/src/utils/sdk/types/script_group.rs | 67 ++ crates/tools/src/utils/sdk/types/script_id.rs | 60 ++ crates/tools/src/utils/sdk/types/since.rs | 74 ++ crates/tools/src/utils/sdk/unlock/mod.rs | 11 + crates/tools/src/utils/sdk/unlock/signer.rs | 478 +++++++++ crates/tools/src/utils/sdk/unlock/unlocker.rs | 592 +++++++++++ crates/tools/src/utils/sdk/util.rs | 382 +++++++ crates/tools/src/utils/transaction.rs | 4 +- crates/tools/src/withdraw.rs | 2 +- crates/types/Cargo.toml | 4 +- crates/utils/Cargo.toml | 4 +- 56 files changed, 6253 insertions(+), 231 deletions(-) create mode 100644 crates/tools/src/utils/sdk/constants.rs create mode 100644 crates/tools/src/utils/sdk/mod.rs create mode 100644 crates/tools/src/utils/sdk/rpc/ckb.rs create mode 100644 crates/tools/src/utils/sdk/rpc/ckb_indexer.rs create mode 100644 crates/tools/src/utils/sdk/rpc/ckb_light_client.rs create mode 100644 crates/tools/src/utils/sdk/rpc/mod.rs create mode 100644 crates/tools/src/utils/sdk/test_utils.rs create mode 100644 crates/tools/src/utils/sdk/traits/default_impls.rs create mode 100644 crates/tools/src/utils/sdk/traits/dummy_impls.rs create mode 100644 crates/tools/src/utils/sdk/traits/light_client_impls.rs create mode 100644 crates/tools/src/utils/sdk/traits/mod.rs create mode 100644 crates/tools/src/utils/sdk/traits/offchain_impls.rs create mode 100644 crates/tools/src/utils/sdk/tx_fee.rs create mode 100644 crates/tools/src/utils/sdk/types/address.rs create mode 100644 crates/tools/src/utils/sdk/types/human_capacity.rs create mode 100644 crates/tools/src/utils/sdk/types/mod.rs create mode 100644 crates/tools/src/utils/sdk/types/network_type.rs create mode 100644 crates/tools/src/utils/sdk/types/script_group.rs create mode 100644 crates/tools/src/utils/sdk/types/script_id.rs create mode 100644 crates/tools/src/utils/sdk/types/since.rs create mode 100644 crates/tools/src/utils/sdk/unlock/mod.rs create mode 100644 crates/tools/src/utils/sdk/unlock/signer.rs create mode 100644 crates/tools/src/utils/sdk/unlock/unlocker.rs create mode 100644 crates/tools/src/utils/sdk/util.rs diff --git a/Cargo.lock b/Cargo.lock index b568de6a3..cc8cf45cd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -48,9 +48,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.60" +version = "1.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c794e162a5eff65c72ef524dfe393eb923c354e350bb78b9c7383df13f3bc142" +checksum = "216261ddc8289130e551ddcd5ce8a064710c0d064a4d2895c67151c92b5443f6" [[package]] name = "arc-swap" @@ -73,17 +73,85 @@ version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" +[[package]] +name = "ascii-canvas" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8824ecca2e851cec16968d54a01dd372ef8f95b244fb84b84e70128be347c3c6" +dependencies = [ + "term", +] + +[[package]] +name = "assert-json-diff" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47e4f2b81832e72834d7518d8487a0396a28cc408186a2e8854c0f98011faf12" +dependencies = [ + "serde", + "serde_json", +] + [[package]] name = "async-channel" version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4b31b87a3367ed04dbcbc252bce3f2a8172fef861d47177524c503c908dff2c6" dependencies = [ - "concurrent-queue", + "concurrent-queue 1.2.4", "event-listener", "futures-core", ] +[[package]] +name = "async-executor" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17adb73da160dfb475c183343c8cccd80721ea5a605d3eb57125f0a7b7a92d0b" +dependencies = [ + "async-lock", + "async-task", + "concurrent-queue 2.0.0", + "fastrand", + "futures-lite", + "slab", +] + +[[package]] +name = "async-global-executor" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1b6f5d7df27bd294849f8eec66ecfc63d11814df7a4f5d74168a2394467b776" +dependencies = [ + "async-channel", + "async-executor", + "async-io", + "async-lock", + "blocking", + "futures-lite", + "once_cell", +] + +[[package]] +name = "async-io" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c374dda1ed3e7d8f0d9ba58715f924862c63eae6849c92d3a18e7fbde9e2794" +dependencies = [ + "async-lock", + "autocfg 1.1.0", + "concurrent-queue 2.0.0", + "futures-lite", + "libc", + "log", + "parking", + "polling", + "slab", + "socket2", + "waker-fn", + "windows-sys 0.42.0", +] + [[package]] name = "async-jsonrpc-client" version = "0.3.0" @@ -103,6 +171,70 @@ dependencies = [ "tokio", ] +[[package]] +name = "async-lock" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8101efe8695a6c17e02911402145357e718ac92d3ff88ae8419e84b1707b685" +dependencies = [ + "event-listener", + "futures-lite", +] + +[[package]] +name = "async-object-pool" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aeb901c30ebc2fc4ab46395bbfbdba9542c16559d853645d75190c3056caf3bc" +dependencies = [ + "async-std", +] + +[[package]] +name = "async-process" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6381ead98388605d0d9ff86371043b5aa922a3905824244de40dc263a14fcba4" +dependencies = [ + "async-io", + "async-lock", + "autocfg 1.1.0", + "blocking", + "cfg-if 1.0.0", + "event-listener", + "futures-lite", + "libc", + "signal-hook", + "windows-sys 0.42.0", +] + +[[package]] +name = "async-std" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62565bb4402e926b29953c785397c6dc0391b7b446e45008b0049eb43cec6f5d" +dependencies = [ + "async-channel", + "async-global-executor", + "async-io", + "async-lock", + "async-process", + "crossbeam-utils", + "futures-channel", + "futures-core", + "futures-io", + "futures-lite", + "gloo-timers", + "kv-log-macro", + "log", + "memchr", + "once_cell", + "pin-project-lite", + "pin-utils", + "slab", + "wasm-bindgen-futures", +] + [[package]] name = "async-stream" version = "0.3.3" @@ -124,6 +256,12 @@ dependencies = [ "syn", ] +[[package]] +name = "async-task" +version = "4.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a40729d2133846d9ed0ea60a8b9541bccddab49cd30f0715a1da672fe9a2524" + [[package]] name = "async-trait" version = "0.1.57" @@ -135,6 +273,12 @@ dependencies = [ "syn", ] +[[package]] +name = "atomic-waker" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "065374052e7df7ee4047b1160cca5e1467a12351a40b3da123c870ba0b8eda2a" + [[package]] name = "atty" version = "0.2.14" @@ -228,10 +372,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" [[package]] -name = "bech32" -version = "0.6.0" +name = "basic-cookies" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58946044516aa9dc922182e0d6e9d124a31aafe6b421614654eb27cf90cec09c" +checksum = "cb53b6b315f924c7f113b162e53b3901c05fc9966baf84d201dfcc7432a4bb38" +dependencies = [ + "lalrpop", + "lalrpop-util", + "regex", +] [[package]] name = "bech32" @@ -258,6 +407,15 @@ dependencies = [ "shlex", ] +[[package]] +name = "bit-set" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0700ddab506f33b20a03b13996eccd309a48e5ff77d0d95926aa0210fb4e95f1" +dependencies = [ + "bit-vec", +] + [[package]] name = "bit-vec" version = "0.6.3" @@ -338,6 +496,20 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8d696c370c750c948ada61c69a0ee2cbbb9c50b1019ddb86d9317157a99c2cae" +[[package]] +name = "blocking" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c67b173a56acffd6d2326fb7ab938ba0b00a71480e14902b2591c87bc5741e8" +dependencies = [ + "async-channel", + "async-lock", + "async-task", + "atomic-waker", + "fastrand", + "futures-lite", +] + [[package]] name = "bs58" version = "0.4.0" @@ -401,6 +573,12 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" +[[package]] +name = "castaway" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2698f953def977c68f935bb0dfa959375ad4638570e969e2f1e9f433cbf1af6" + [[package]] name = "cc" version = "1.0.73" @@ -467,9 +645,9 @@ dependencies = [ [[package]] name = "ckb-chain-spec" -version = "0.104.0" +version = "0.105.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9d7c40f6ede10a33d07bee585cf30b1d16588e60ccccc2ad134b6ce00ef10d8" +checksum = "2f0f0606bce9ccbde520465890486807a0ac2fcba3e60d37df54a2d0be071725" dependencies = [ "ckb-constant", "ckb-crypto", @@ -482,44 +660,45 @@ dependencies = [ "ckb-resource", "ckb-traits", "ckb-types", + "ckb-util", "serde", "toml", ] [[package]] name = "ckb-channel" -version = "0.104.0" +version = "0.105.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fe17832858b599109ac9cee6d9dcde419dad958a1982d6e37eb97fedb0ef5e6" +checksum = "5f0da1f4e474de48b05e30ad603da4da3b410344b619c7cf35d444e406c0bb6e" dependencies = [ "crossbeam-channel", ] [[package]] name = "ckb-constant" -version = "0.104.0" +version = "0.105.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92a4ba4a395a9e50a7179e08252276b183310c32c24dfc8b521925fdf8a9afa0" +checksum = "8a6df9fd997d58f1e5f12a683a00d98158a82c07a422e6f81ff390607f19c493" [[package]] name = "ckb-crypto" -version = "0.104.0" +version = "0.105.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a600bb463e6d72acb85c0ba821b106a1710855a52737b434a4afd6fcbab0e55" +checksum = "1650275e0f5a59e8ebbd747d835e10b9179d8ab4941b96100d5b7e48fada695e" dependencies = [ "ckb-fixed-hash", "faster-hex 0.6.1", "lazy_static", "rand 0.7.3", - "secp256k1 0.20.3", + "secp256k1 0.24.1", "thiserror", ] [[package]] name = "ckb-dao-utils" -version = "0.104.0" +version = "0.105.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac8bee17950819b550031c81b4200e1e6eddc364c5aab16d5fc9407d2035c775" +checksum = "b294c46e06c315900c9eb4e5719311902d68fcad6c802f43ebc658902715b5ea" dependencies = [ "byteorder", "ckb-error", @@ -528,9 +707,9 @@ dependencies = [ [[package]] name = "ckb-error" -version = "0.104.0" +version = "0.105.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73dc4bb1f4c889f42edc9509005aa593ca1b88b6f43f9cfbd59c6d4897994783" +checksum = "51748ac5e08dce6c685cf4b43e27dcbcfc98e21442c4001c9f06509a04a400ed" dependencies = [ "anyhow", "ckb-occupied-capacity", @@ -540,9 +719,9 @@ dependencies = [ [[package]] name = "ckb-fixed-hash" -version = "0.104.0" +version = "0.105.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8183ed12fd0fff3abfb142d3dde7b501f211519e2b77972c64815e00d38c8ed3" +checksum = "b3d665013dbb8ff2df8e67c4add67db703ae3b642679f1a2962f76399703eee1" dependencies = [ "ckb-fixed-hash-core", "ckb-fixed-hash-macros", @@ -550,9 +729,9 @@ dependencies = [ [[package]] name = "ckb-fixed-hash-core" -version = "0.104.0" +version = "0.105.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01e9a8f69f7174ce9f9b6045a82aafb2ceafc2aa6eedffa0562e0d6defaa4732" +checksum = "dd92b9d691bbfd11a900ee17ad1010a553ae0b5d3a120e0c8094afcd30f9b15e" dependencies = [ "faster-hex 0.6.1", "serde", @@ -561,9 +740,9 @@ dependencies = [ [[package]] name = "ckb-fixed-hash-macros" -version = "0.104.0" +version = "0.105.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f73281677e79cd8cbd873b86701209d560038549823e915cb3505d1b348f0a6" +checksum = "f24e42b82da4d891ac8b5b19de2807cae360c5377138a7cde377b60edc6ec953" dependencies = [ "ckb-fixed-hash-core", "proc-macro2", @@ -573,9 +752,9 @@ dependencies = [ [[package]] name = "ckb-hash" -version = "0.104.0" +version = "0.105.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac70ef20b9dac406f06bead70c0a2e4742205234f58051885e6ae1f50786e6be" +checksum = "c6b64eff869839aff45741515540e81a0447926d79262a439b5e9d0a5c98ac95" dependencies = [ "blake2b-ref 0.2.1", "blake2b-rs", @@ -583,9 +762,9 @@ dependencies = [ [[package]] name = "ckb-jsonrpc-types" -version = "0.104.0" +version = "0.105.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "520d1cc13b7d5ea93a2b9a28362555410e6621e8141eb1289a0547e0c5ef6e46" +checksum = "82268ddea09f95324496d6def1b37d6bdc3a4841fecc185388e7a2bb6451687f" dependencies = [ "ckb-types", "faster-hex 0.6.1", @@ -609,18 +788,40 @@ dependencies = [ [[package]] name = "ckb-logger" -version = "0.104.0" +version = "0.105.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6839e2ab382fa92f3d3cb71d18d55a0c65965d54674dd5e375854bf07248ae6" +checksum = "8a312280df7ba55dc99cf8584ac4d3c9e3b85297a896202c76a21dfd43ffb0ea" dependencies = [ "log", ] +[[package]] +name = "ckb-merkle-mountain-range" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56ccb671c5921be8a84686e6212ca184cb1d7c51cadcdbfcbd1cc3f042f5dfb8" +dependencies = [ + "cfg-if 1.0.0", +] + +[[package]] +name = "ckb-mock-tx-types" +version = "0.105.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c73574949df81ecd84b5366992f1ab61d2a4e8dc905dabb58468b785fa90b22d" +dependencies = [ + "ckb-jsonrpc-types", + "ckb-traits", + "ckb-types", + "serde", + "serde_derive", +] + [[package]] name = "ckb-occupied-capacity" -version = "0.104.0" +version = "0.105.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f0e4ccbc2b6af791b589a09db77518fb2b0fa79a72ba568e6a7dade7e935721" +checksum = "a11e010c034a98b734074a79655c738c40501e9113426173132856a35c6e71c6" dependencies = [ "ckb-occupied-capacity-core", "ckb-occupied-capacity-macros", @@ -628,18 +829,18 @@ dependencies = [ [[package]] name = "ckb-occupied-capacity-core" -version = "0.104.0" +version = "0.105.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "773a03d5c3cf71d5f9b0e620b193fdd82a3e1f3434022792a32a8b4037550fa1" +checksum = "03e48f0306a3fe072711e0342b71335898ac6d0a82b897ca3ae13e43770ce0e0" dependencies = [ "serde", ] [[package]] name = "ckb-occupied-capacity-macros" -version = "0.104.0" +version = "0.105.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfcfb1f9f3812fd5e306d88f0a3683cdf9e8350f5a79c3288e835b8355425635" +checksum = "656db5615c791b8d7b31a38e024f98fb497be5e2cb120b38be48eb4d9d1d0f6d" dependencies = [ "ckb-occupied-capacity-core", "quote", @@ -648,9 +849,9 @@ dependencies = [ [[package]] name = "ckb-pow" -version = "0.104.0" +version = "0.105.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4c09ed8c7588b6722bfba5c1df618943bccab49904fd2e0f4a8b7b978f55731" +checksum = "9708f81c8c9058bf3dab834be2be68d14dcd9fa41bd793727428a2cf6b1ddf59" dependencies = [ "byteorder", "ckb-hash", @@ -662,9 +863,9 @@ dependencies = [ [[package]] name = "ckb-rational" -version = "0.104.0" +version = "0.105.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a70041296dc87341c1993ff3c12268937bb998145b49afc5c299a764dc9ed12a" +checksum = "444926bc5a9ad789b2b98e75f90330bcfe741bab517ca45d8f084449fe35efd8" dependencies = [ "numext-fixed-uint", "serde", @@ -672,9 +873,9 @@ dependencies = [ [[package]] name = "ckb-resource" -version = "0.104.0" +version = "0.105.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c45669446b51b6336f407044c1940cb31d709c09638fe4c2b34d6910d7d55f13" +checksum = "95464c0e69e20553f34c132789f6275a1e06468362226cf5a986719f6da96161" dependencies = [ "ckb-system-scripts", "ckb-types", @@ -698,9 +899,9 @@ dependencies = [ [[package]] name = "ckb-script" -version = "0.104.0" +version = "0.105.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b75232e549f5b4eba2442eaca5232ab87a9deee54bfb1c9761f00b9978f17365" +checksum = "2f06c44207d8e90b86f2b29f2341188a6d1a3520f6b657eb2ba662b3a772abfc" dependencies = [ "byteorder", "ckb-chain-spec", @@ -714,36 +915,6 @@ dependencies = [ "serde", ] -[[package]] -name = "ckb-sdk" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e73cd1e12195e22b169321c650ea06ec430583894224ab4661de5f082d7026f" -dependencies = [ - "bech32 0.8.1", - "bytes", - "ckb-crypto", - "ckb-dao-utils", - "ckb-hash", - "ckb-jsonrpc-types", - "ckb-resource", - "ckb-traits", - "ckb-types", - "futures", - "jsonrpc-core 18.0.0", - "log", - "lru", - "parking_lot 0.12.1", - "reqwest", - "secp256k1 0.20.3", - "serde", - "serde_derive", - "serde_json", - "thiserror", - "tokio", - "tokio-util 0.6.10", -] - [[package]] name = "ckb-system-scripts" version = "0.5.4" @@ -759,18 +930,18 @@ dependencies = [ [[package]] name = "ckb-traits" -version = "0.104.0" +version = "0.105.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50acf0a06a8d1f32e1c5cf4638ad97e0d94a61ae2ca4dab797b40cb602e2260a" +checksum = "6d54a03a03af9857264cc252060f4274e11858956a4985793b04047117828329" dependencies = [ "ckb-types", ] [[package]] name = "ckb-types" -version = "0.104.0" +version = "0.105.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9ba3e13c93900267bc9670b3ea4379eab1a234c7cb470fcd6856640f165e2af" +checksum = "f06812497491fa58cea1c93dda2de074e0c5d51cf7d70d93dd50c862c661494c" dependencies = [ "bit-vec", "bytes", @@ -778,6 +949,7 @@ dependencies = [ "ckb-error", "ckb-fixed-hash", "ckb-hash", + "ckb-merkle-mountain-range", "ckb-occupied-capacity", "ckb-rational", "derive_more", @@ -787,11 +959,23 @@ dependencies = [ "once_cell", ] +[[package]] +name = "ckb-util" +version = "0.105.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c0f4f5647372cc1c2fdc7122e062984754e062edbcc654436a1af7f5b1382a0" +dependencies = [ + "linked-hash-map", + "once_cell", + "parking_lot 0.12.1", + "regex", +] + [[package]] name = "ckb-vm" -version = "0.21.3" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc81aeacb7eaa4981e4c4f8285e30bca92f8d7346937cbcfc0b77f26b21da2de" +checksum = "0f1126bf0240d100234bc06efa7020f0d50ca35fe90e5ac7cac1b7721e1bacb7" dependencies = [ "byteorder", "bytes", @@ -800,18 +984,33 @@ dependencies = [ "derive_more", "goblin 0.2.3", "goblin 0.4.0", - "libc", - "mapr", "rand 0.7.3", "scroll", "serde", ] +[[package]] +name = "ckb-vm-aot" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97d90662540a6a3b0d71e58d789016efe817d2cd0c4ec6b26bcaf7f9b18fe7cf" +dependencies = [ + "cc", + "ckb-vm", + "ckb-vm-definitions", + "derive_more", + "goblin 0.2.3", + "goblin 0.4.0", + "libc", + "memmap2", + "scroll", +] + [[package]] name = "ckb-vm-definitions" -version = "0.21.3" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7968c559498b68833791364e87182fdd1a3aba803e8a16c34b1aa45fc08add1c" +checksum = "14739bf59648c169de9257ec7dd6aba1aeb6a41725d636005f1c91853df58fcc" [[package]] name = "clang-sys" @@ -892,6 +1091,15 @@ dependencies = [ "cache-padded", ] +[[package]] +name = "concurrent-queue" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd7bef69dc86e3c610e4e7aed41035e2a7ed12e72dd7530f61327a6579a4390b" +dependencies = [ + "crossbeam-utils", +] + [[package]] name = "console" version = "0.15.1" @@ -1109,12 +1317,53 @@ dependencies = [ "memchr", ] +[[package]] +name = "ctor" +version = "0.1.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d2301688392eb071b0bf1a37be05c469d3cc4dbbd95df672fe28ab021e6a096" +dependencies = [ + "quote", + "syn", +] + [[package]] name = "cty" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b365fabc795046672053e29c954733ec3b05e4be654ab130fe8f1f94d7051f35" +[[package]] +name = "curl" +version = "0.4.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "509bd11746c7ac09ebd19f0b17782eae80aadee26237658a6b4808afb5c11a22" +dependencies = [ + "curl-sys", + "libc", + "openssl-probe", + "openssl-sys", + "schannel", + "socket2", + "winapi", +] + +[[package]] +name = "curl-sys" +version = "0.4.59+curl-7.86.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6cfce34829f448b08f55b7db6d0009e23e2e86a34e8c2b366269bf5799b4a407" +dependencies = [ + "cc", + "libc", + "libnghttp2-sys", + "libz-sys", + "openssl-sys", + "pkg-config", + "vcpkg", + "winapi", +] + [[package]] name = "curve25519-dalek" version = "3.2.1" @@ -1128,6 +1377,19 @@ dependencies = [ "zeroize", ] +[[package]] +name = "dashmap" +version = "5.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "907076dfda823b0b36d2a1bb5f90c96660a5bbcd7729e10727f07858f22c4edc" +dependencies = [ + "cfg-if 1.0.0", + "hashbrown", + "lock_api", + "once_cell", + "parking_lot_core 0.9.3", +] + [[package]] name = "debugid" version = "0.7.3" @@ -1150,6 +1412,12 @@ dependencies = [ "syn", ] +[[package]] +name = "diff" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56254986775e3233ffa9c4d7d3faaf6d36a2c09d30b20687e9f88bc8bafc16c8" + [[package]] name = "digest" version = "0.9.0" @@ -1170,6 +1438,27 @@ dependencies = [ "subtle", ] +[[package]] +name = "dirs-next" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b98cf8ebf19c3d1b223e151f99a4f9f0690dca41414773390fc824184ac833e1" +dependencies = [ + "cfg-if 1.0.0", + "dirs-sys-next", +] + +[[package]] +name = "dirs-sys-next" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d" +dependencies = [ + "libc", + "redox_users", + "winapi", +] + [[package]] name = "dlv-list" version = "0.3.0" @@ -1188,6 +1477,15 @@ version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f107b87b6afc2a64fd13cac55fe06d6c8859f12d4b14cbcdd2c67d0976781be" +[[package]] +name = "ena" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7402b94a93c24e742487327a7cd839dc9d36fec9de9fb25b09f2dae459f36c3" +dependencies = [ + "log", +] + [[package]] name = "encode_unicode" version = "0.3.6" @@ -1467,6 +1765,21 @@ version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc4045962a5a5e935ee2fdedaa4e08284547402885ab326734432bed5d12966b" +[[package]] +name = "futures-lite" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7694489acd39452c77daa48516b894c153f192c3578d5a839b62c58099fcbf48" +dependencies = [ + "fastrand", + "futures-core", + "futures-io", + "memchr", + "parking", + "pin-project-lite", + "waker-fn", +] + [[package]] name = "futures-macro" version = "0.3.21" @@ -1563,6 +1876,18 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" +[[package]] +name = "gloo-timers" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98c4a8d6391675c6b2ee1a6c8d06e8e2d03605c44cec1270675985a4c2a5500b" +dependencies = [ + "futures-channel", + "futures-core", + "js-sys", + "wasm-bindgen", +] + [[package]] name = "goblin" version = "0.2.3" @@ -1797,6 +2122,7 @@ dependencies = [ "arc-swap", "blake2b-rs", "ckb-vm", + "ckb-vm-aot", "ethabi", "gw-common", "gw-config", @@ -1998,7 +2324,7 @@ dependencies = [ "hyper", "jsonrpc-v2", "log", - "lru", + "lru 0.7.8", "once_cell", "pprof", "serde", @@ -2042,7 +2368,6 @@ dependencies = [ "ckb-traits", "ckb-types", "ckb-vm", - "ckb-vm-definitions", "env_logger", "godwoken-bin", "gw-block-producer", @@ -2079,16 +2404,21 @@ name = "gw-tools" version = "1.7.3" dependencies = [ "anyhow", - "bech32 0.6.0", + "bech32", + "ckb-chain-spec", "ckb-crypto", + "ckb-dao-utils", "ckb-fixed-hash", "ckb-hash", "ckb-jsonrpc-types", + "ckb-mock-tx-types", "ckb-resource", - "ckb-sdk", + "ckb-script", + "ckb-traits", "ckb-types", "clap 3.2.22", "csv", + "dashmap", "faster-hex 0.5.0", "gw-common", "gw-config", @@ -2100,16 +2430,20 @@ dependencies = [ "gw-utils", "gw-version", "hex", - "jsonrpc-core 17.1.0", + "httpmock", + "jsonrpc-core", "lazy_static", "log", + "lru 0.8.1", + "parking_lot 0.12.1", "rand 0.8.5", "reqwest", - "secp256k1 0.20.3", + "secp256k1 0.24.1", "serde", "serde_json", "sha3", "tempfile", + "thiserror", "tokio", "toml", "tracing-subscriber", @@ -2195,7 +2529,7 @@ dependencies = [ "indexmap", "slab", "tokio", - "tokio-util 0.7.3", + "tokio-util", "tracing", ] @@ -2315,6 +2649,34 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" +[[package]] +name = "httpmock" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c159c4fc205e6c1a9b325cb7ec135d13b5f47188ce175dabb76ec847f331d9bd" +dependencies = [ + "assert-json-diff", + "async-object-pool", + "async-trait", + "base64", + "basic-cookies", + "crossbeam-utils", + "form_urlencoded", + "futures-util", + "hyper", + "isahc", + "lazy_static", + "levenshtein", + "log", + "regex", + "serde", + "serde_json", + "serde_regex", + "similar", + "tokio", + "url", +] + [[package]] name = "humantime" version = "2.1.0" @@ -2515,6 +2877,33 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "879d54834c8c76457ef4293a689b2a8c59b076067ad77b15efafbb05f92a592b" +[[package]] +name = "isahc" +version = "1.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "334e04b4d781f436dc315cb1e7515bd96826426345d498149e4bde36b67f8ee9" +dependencies = [ + "async-channel", + "castaway", + "crossbeam-utils", + "curl", + "curl-sys", + "encoding_rs", + "event-listener", + "futures-lite", + "http", + "log", + "mime", + "once_cell", + "polling", + "slab", + "sluice", + "tracing", + "tracing-futures", + "url", + "waker-fn", +] + [[package]] name = "itertools" version = "0.10.3" @@ -2569,21 +2958,6 @@ dependencies = [ "serde_json", ] -[[package]] -name = "jsonrpc-core" -version = "18.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14f7f76aef2d054868398427f6c54943cf3d1caa9a7ec7d0c38d69df97a965eb" -dependencies = [ - "futures", - "futures-executor", - "futures-util", - "log", - "serde", - "serde_derive", - "serde_json", -] - [[package]] name = "jsonrpc-types" version = "0.3.3" @@ -2617,6 +2991,47 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f9b7d56ba4a8344d6be9729995e6b06f928af29998cdf79fe390cbf6b1fee838" +[[package]] +name = "kv-log-macro" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0de8b303297635ad57c9f5059fd9cee7a47f8e8daa09df0fcd07dd39fb22977f" +dependencies = [ + "log", +] + +[[package]] +name = "lalrpop" +version = "0.19.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b30455341b0e18f276fa64540aff54deafb54c589de6aca68659c63dd2d5d823" +dependencies = [ + "ascii-canvas", + "atty", + "bit-set", + "diff", + "ena", + "itertools", + "lalrpop-util", + "petgraph", + "pico-args", + "regex", + "regex-syntax", + "string_cache", + "term", + "tiny-keccak", + "unicode-xid", +] + +[[package]] +name = "lalrpop-util" +version = "0.19.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bcf796c978e9b4d983414f4caedc9273aa33ee214c5b887bd55fde84c85d2dc4" +dependencies = [ + "regex", +] + [[package]] name = "lazy_static" version = "1.4.0" @@ -2632,6 +3047,12 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" +[[package]] +name = "levenshtein" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db13adb97ab515a3691f56e4dbab09283d0b86cb45abd991d8634a9d6f501760" + [[package]] name = "libc" version = "0.2.127" @@ -2648,11 +3069,42 @@ dependencies = [ "winapi", ] +[[package]] +name = "libnghttp2-sys" +version = "0.1.7+1.45.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57ed28aba195b38d5ff02b9170cbff627e336a20925e43b4945390401c5dc93f" +dependencies = [ + "cc", + "libc", +] + +[[package]] +name = "libz-sys" +version = "1.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9702761c3935f8cc2f101793272e202c72b99da8f4224a19ddcf1279a6450bbf" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "linked-hash-map" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" +dependencies = [ + "serde", +] + [[package]] name = "lock_api" -version = "0.4.7" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "327fa5b6a6940e4699ec49a9beae1ea4845c6bab9314e4f84ac68742139d8c53" +checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" dependencies = [ "autocfg 1.1.0", "scopeguard", @@ -2665,6 +3117,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" dependencies = [ "cfg-if 1.0.0", + "value-bag", ] [[package]] @@ -2677,13 +3130,12 @@ dependencies = [ ] [[package]] -name = "mapr" -version = "0.8.0" +name = "lru" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46a28a55dbc005b2f6f123c4058933d57add373d362f6fd3a76aab4fe6973500" +checksum = "b6e8aaa3f231bb4bd57b84b2d5dc3ae7f350265df8aa96492e0bc394a1571909" dependencies = [ - "libc", - "winapi", + "hashbrown", ] [[package]] @@ -2770,7 +3222,7 @@ dependencies = [ "libc", "log", "wasi 0.11.0+wasi-snapshot-preview1", - "windows-sys", + "windows-sys 0.36.1", ] [[package]] @@ -2808,6 +3260,12 @@ dependencies = [ "tempfile", ] +[[package]] +name = "new_debug_unreachable" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4a24736216ec316047a1fc4252e27dabb04218aa4a3f37c6e7ddbf1f9782b54" + [[package]] name = "nix" version = "0.23.1" @@ -2935,9 +3393,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.13.0" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18a6dbe30758c9f83eb00cbea4ac95966305f5a7772f3f42ebfc7fc7eddbd8e1" +checksum = "86f0b0d4bf799edbc74508c1e8bf170ff5f41238e5f8225603ca7caaae2b7860" [[package]] name = "oorandom" @@ -3102,6 +3560,12 @@ dependencies = [ "syn", ] +[[package]] +name = "parking" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "427c3892f9e783d91cc128285287e70a59e206ca452770ece88a76f7a3eddd72" + [[package]] name = "parking_lot" version = "0.11.2" @@ -3147,7 +3611,7 @@ dependencies = [ "libc", "redox_syscall", "smallvec", - "windows-sys", + "windows-sys 0.36.1", ] [[package]] @@ -3184,7 +3648,7 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3dfb61232e34fcb633f43d12c58f83c1df82962dcdfa565a4e866ffc17dafe12" dependencies = [ - "phf_shared", + "phf_shared 0.8.0", ] [[package]] @@ -3194,7 +3658,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cbffee61585b0411840d3ece935cce9cb6321f01c45477d30066498cd5e1a815" dependencies = [ "phf_generator", - "phf_shared", + "phf_shared 0.8.0", ] [[package]] @@ -3203,7 +3667,7 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "17367f0cc86f2d25802b2c26ee58a7b23faeccf78a396094c13dced0d0182526" dependencies = [ - "phf_shared", + "phf_shared 0.8.0", "rand 0.7.3", ] @@ -3216,6 +3680,21 @@ dependencies = [ "siphasher", ] +[[package]] +name = "phf_shared" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6796ad771acdc0123d2a88dc428b5e38ef24456743ddb1744ed628f9815c096" +dependencies = [ + "siphasher", +] + +[[package]] +name = "pico-args" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db8bcd96cb740d03149cbad5518db9fd87126a10ab519c011893b1754134c468" + [[package]] name = "pin-project" version = "1.0.11" @@ -3288,6 +3767,20 @@ dependencies = [ "plotters-backend", ] +[[package]] +name = "polling" +version = "2.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "166ca89eb77fd403230b9c156612965a81e094ec6ec3aa13663d4c8b113fa748" +dependencies = [ + "autocfg 1.1.0", + "cfg-if 1.0.0", + "libc", + "log", + "wepoll-ffi", + "windows-sys 0.42.0", +] + [[package]] name = "poly1305" version = "0.7.2" @@ -3330,6 +3823,12 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" +[[package]] +name = "precomputed-hash" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" + [[package]] name = "primitive-types" version = "0.10.1" @@ -3735,6 +4234,17 @@ dependencies = [ "bitflags", ] +[[package]] +name = "redox_users" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" +dependencies = [ + "getrandom 0.2.7", + "redox_syscall", + "thiserror", +] + [[package]] name = "regex" version = "1.6.0" @@ -3878,6 +4388,12 @@ dependencies = [ "semver", ] +[[package]] +name = "rustversion" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97477e48b4cf8603ad5f7aaf897467cf42ab4218a38ef76fb14c2d6773a6d6a8" + [[package]] name = "ryu" version = "1.0.11" @@ -3900,7 +4416,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "88d6731146462ea25d9244b2ed5fd1d716d25c52e4d54aa4fb0f3c4e9854dbe2" dependencies = [ "lazy_static", - "windows-sys", + "windows-sys 0.36.1", ] [[package]] @@ -3935,7 +4451,7 @@ version = "0.20.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97d03ceae636d0fed5bae6a7f4f664354c5f4fcedf6eef053fef17e49f837d0a" dependencies = [ - "secp256k1-sys", + "secp256k1-sys 0.4.2", ] [[package]] @@ -3945,7 +4461,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c42e6f1735c5f00f51e43e28d6634141f2bcad10931b2609ddd74a86d751260" dependencies = [ "rand 0.6.5", - "secp256k1-sys", + "secp256k1-sys 0.4.2", +] + +[[package]] +name = "secp256k1" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff55dc09d460954e9ef2fa8a7ced735a964be9981fd50e870b2b3b0705e14964" +dependencies = [ + "secp256k1-sys 0.6.1", ] [[package]] @@ -3957,6 +4482,15 @@ dependencies = [ "cc", ] +[[package]] +name = "secp256k1-sys" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83080e2c2fc1006e625be82e5d1eb6a43b7fd9578b617fcc55814daf286bba4b" +dependencies = [ + "cc", +] + [[package]] name = "security-framework" version = "2.6.1" @@ -4027,6 +4561,16 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_regex" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8136f1a4ea815d7eac4101cfd0b16dc0cb5e1fe1b8609dfd728058656b7badf" +dependencies = [ + "regex", + "serde", +] + [[package]] name = "serde_urlencoded" version = "0.7.1" @@ -4077,6 +4621,16 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3" +[[package]] +name = "signal-hook" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a253b5e89e2698464fc26b545c9edceb338e18a89effeeecfea192c3025be29d" +dependencies = [ + "libc", + "signal-hook-registry", +] + [[package]] name = "signal-hook-registry" version = "1.4.0" @@ -4086,6 +4640,12 @@ dependencies = [ "libc", ] +[[package]] +name = "similar" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "420acb44afdae038210c99e69aae24109f32f15500aa708e81d46c9f29d55fcf" + [[package]] name = "siphasher" version = "0.3.10" @@ -4111,6 +4671,17 @@ dependencies = [ "autocfg 1.1.0", ] +[[package]] +name = "sluice" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d7400c0eff44aa2fcb5e31a5f24ba9716ed90138769e4977a2ba6014ae63eb5" +dependencies = [ + "async-channel", + "futures-core", + "futures-io", +] + [[package]] name = "smallvec" version = "1.9.0" @@ -4129,9 +4700,9 @@ dependencies = [ [[package]] name = "sparse-merkle-tree" -version = "0.5.3" +version = "0.5.2-rc1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f84214ec89cb9d304b5d54c7a266951c25bd396b2df5388420a9497a6896120a" +checksum = "73c8673a5932f28e2a4d229784c9382c423b5d1cf62321f66036eaf9921540ef" dependencies = [ "cfg-if 0.1.10", ] @@ -4160,6 +4731,19 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9091b6114800a5f2141aee1d1b9d6ca3592ac062dc5decb3764ec5895a47b4eb" +[[package]] +name = "string_cache" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "213494b7a2b503146286049378ce02b482200519accc31872ee8be91fa820a08" +dependencies = [ + "new_debug_unreachable", + "once_cell", + "parking_lot 0.12.1", + "phf_shared 0.10.0", + "precomputed-hash", +] + [[package]] name = "strsim" version = "0.10.0" @@ -4277,7 +4861,7 @@ dependencies = [ "tentacle-secio", "thiserror", "tokio", - "tokio-util 0.7.3", + "tokio-util", "tokio-yamux", "wasm-bindgen", "wasm-bindgen-futures", @@ -4319,11 +4903,22 @@ dependencies = [ "secp256k1 0.20.3", "sha2", "tokio", - "tokio-util 0.7.3", + "tokio-util", "unsigned-varint", "x25519-dalek", ] +[[package]] +name = "term" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c59df8ac95d96ff9bede18eb7300b0fda5e5d8d90960e76f8e14ae765eedbf1f" +dependencies = [ + "dirs-next", + "rustversion", + "winapi", +] + [[package]] name = "termcolor" version = "1.1.3" @@ -4550,20 +5145,6 @@ dependencies = [ "tokio", ] -[[package]] -name = "tokio-util" -version = "0.6.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36943ee01a6d67977dd3f84a5a1d2efeb4ada3a1ae771cadfaa535d9d9fc6507" -dependencies = [ - "bytes", - "futures-core", - "futures-sink", - "log", - "pin-project-lite", - "tokio", -] - [[package]] name = "tokio-util" version = "0.7.3" @@ -4589,7 +5170,7 @@ dependencies = [ "log", "nohash-hasher", "tokio", - "tokio-util 0.7.3", + "tokio-util", ] [[package]] @@ -4625,7 +5206,7 @@ dependencies = [ "prost-derive 0.10.1", "tokio", "tokio-stream", - "tokio-util 0.7.3", + "tokio-util", "tower", "tower-layer", "tower-service", @@ -4647,7 +5228,7 @@ dependencies = [ "rand 0.8.5", "slab", "tokio", - "tokio-util 0.7.3", + "tokio-util", "tower-layer", "tower-service", "tracing", @@ -4881,6 +5462,16 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" +[[package]] +name = "value-bag" +version = "1.0.0-alpha.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2209b78d1249f7e6f3293657c9779fe31ced465df091bbd433a1cf88e916ec55" +dependencies = [ + "ctor", + "version_check", +] + [[package]] name = "vcpkg" version = "0.2.15" @@ -4893,6 +5484,12 @@ version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +[[package]] +name = "waker-fn" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d5b2c62b4012a3e1eca5a7e077d13b3bf498c4073e33ccd58626607748ceeca" + [[package]] name = "walkdir" version = "2.3.2" @@ -5002,6 +5599,15 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "wepoll-ffi" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d743fdedc5c64377b5fc2bc036b01c7fd642205a0d96356034ae3404d49eb7fb" +dependencies = [ + "cc", +] + [[package]] name = "which" version = "4.2.5" @@ -5050,43 +5656,100 @@ version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ea04155a16a59f9eab786fe12a4a450e75cdb175f9e0d80da1e17db09f55b8d2" dependencies = [ - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_msvc", + "windows_aarch64_msvc 0.36.1", + "windows_i686_gnu 0.36.1", + "windows_i686_msvc 0.36.1", + "windows_x86_64_gnu 0.36.1", + "windows_x86_64_msvc 0.36.1", ] +[[package]] +name = "windows-sys" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc 0.42.0", + "windows_i686_gnu 0.42.0", + "windows_i686_msvc 0.42.0", + "windows_x86_64_gnu 0.42.0", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc 0.42.0", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d2aa71f6f0cbe00ae5167d90ef3cfe66527d6f613ca78ac8024c3ccab9a19e" + [[package]] name = "windows_aarch64_msvc" version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47" +[[package]] +name = "windows_aarch64_msvc" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd0f252f5a35cac83d6311b2e795981f5ee6e67eb1f9a7f64eb4500fbc4dcdb4" + [[package]] name = "windows_i686_gnu" version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6" +[[package]] +name = "windows_i686_gnu" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbeae19f6716841636c28d695375df17562ca208b2b7d0dc47635a50ae6c5de7" + [[package]] name = "windows_i686_msvc" version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024" +[[package]] +name = "windows_i686_msvc" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84c12f65daa39dd2babe6e442988fc329d6243fdce47d7d2d155b8d874862246" + [[package]] name = "windows_x86_64_gnu" version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1" +[[package]] +name = "windows_x86_64_gnu" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf7b1b21b5362cbc318f686150e5bcea75ecedc74dd157d874d754a2ca44b0ed" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09d525d2ba30eeb3297665bd434a54297e4170c7f1a44cad4ef58095b4cd2028" + [[package]] name = "windows_x86_64_msvc" version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" +[[package]] +name = "windows_x86_64_msvc" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f40009d85759725a34da6d89a94e63d7bdc50a862acf0dbc7c8e488f1edcb6f5" + [[package]] name = "winreg" version = "0.10.1" diff --git a/crates/block-producer/Cargo.toml b/crates/block-producer/Cargo.toml index 773796b7d..fa8557904 100644 --- a/crates/block-producer/Cargo.toml +++ b/crates/block-producer/Cargo.toml @@ -20,10 +20,10 @@ gw-rpc-client = { path = "../rpc-client" } gw-utils = { path = "../utils" } gw-dynamic-config = { path = "../dynamic-config"} gw-polyjuice-sender-recover = { path = "../polyjuice-sender-recover" } -ckb-crypto = "0.104.0" -ckb-fixed-hash = "0.104.0" -ckb-types = "0.104.0" -ckb-chain-spec = "0.104.0" +ckb-crypto = "0.105.1" +ckb-fixed-hash = "0.105.1" +ckb-types = "0.105.1" +ckb-chain-spec = "0.105.1" anyhow = "1.0" serde = { version = "1.0", features = ["derive"] } async-channel = "1.4.2" diff --git a/crates/chain/Cargo.toml b/crates/chain/Cargo.toml index 4262bc47e..af34e936f 100644 --- a/crates/chain/Cargo.toml +++ b/crates/chain/Cargo.toml @@ -17,7 +17,7 @@ gw-store = { path = "../store" } gw-traits = { path = "../traits" } gw-jsonrpc-types = { path = "../jsonrpc-types" } gw-utils = { path = "../utils" } -ckb-fixed-hash = "0.104.0" +ckb-fixed-hash = "0.105.1" anyhow = "1.0" thiserror = "1.0" lazy_static = "1.4" diff --git a/crates/challenge/Cargo.toml b/crates/challenge/Cargo.toml index 325a99f2c..efcd3a617 100644 --- a/crates/challenge/Cargo.toml +++ b/crates/challenge/Cargo.toml @@ -17,11 +17,11 @@ gw-jsonrpc-types = { path = "../jsonrpc-types" } gw-rpc-client = { path = "../rpc-client" } gw-traits = { path = "../traits" } gw-utils = { path = "../utils" } -ckb-fixed-hash = "0.104.0" -ckb-types = "0.104.0" -ckb-script = "0.104.0" -ckb-traits = "0.104.0" -ckb-chain-spec = "0.104.0" +ckb-fixed-hash = "0.105.1" +ckb-types = "0.105.1" +ckb-script = "0.105.1" +ckb-traits = "0.105.1" +ckb-chain-spec = "0.105.1" anyhow = "1.0" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" diff --git a/crates/common/Cargo.toml b/crates/common/Cargo.toml index 37e555c2c..b6ddbe90e 100644 --- a/crates/common/Cargo.toml +++ b/crates/common/Cargo.toml @@ -8,7 +8,7 @@ edition = "2018" [dependencies] cfg-if = "0.1" -sparse-merkle-tree = { version = "0.5.2-rc1", default-features = false } +sparse-merkle-tree = { version = "=0.5.2-rc1", default-features = false } merkle-cbt = { version = "0.3.0", default-features = false } gw-hash = { path = "../hash" } thiserror = { version = "1.0", optional = true } diff --git a/crates/config/Cargo.toml b/crates/config/Cargo.toml index fe7849710..2ae31acf0 100644 --- a/crates/config/Cargo.toml +++ b/crates/config/Cargo.toml @@ -8,7 +8,7 @@ edition = "2018" [dependencies] gw-jsonrpc-types = { path = "../jsonrpc-types" } -ckb-fixed-hash = "0.104.0" +ckb-fixed-hash = "0.105.1" serde = { version = "1.0", features = ["derive"] } reqwest = { version = "0.11", features = ["json", "blocking"] } diff --git a/crates/dynamic-config/Cargo.toml b/crates/dynamic-config/Cargo.toml index c7436aa26..a70f67254 100644 --- a/crates/dynamic-config/Cargo.toml +++ b/crates/dynamic-config/Cargo.toml @@ -10,7 +10,7 @@ edition = "2018" gw-jsonrpc-types = { path = "../jsonrpc-types" } gw-config = { path = "../config" } gw-tx-filter = { path = "../tx-filter"} -ckb-fixed-hash = "0.104.0" +ckb-fixed-hash = "0.105.1" serde = { version = "1.0", features = ["derive"] } reqwest = { version = "0.11", features = ["json"] } toml = "0.5" diff --git a/crates/generator/Cargo.toml b/crates/generator/Cargo.toml index 3eb31e4ff..0ab95b65d 100644 --- a/crates/generator/Cargo.toml +++ b/crates/generator/Cargo.toml @@ -8,7 +8,7 @@ edition = "2018" [features] default = ["detect-asm"] -detect-asm = ["ckb-vm/detect-asm", "ckb-vm/aot"] +detect-asm = ["ckb-vm/detect-asm", "ckb-vm-aot"] enable-always-success-lock = [] [dependencies] @@ -20,7 +20,8 @@ gw-traits = { path = "../traits" } gw-utils = { path = "../utils"} anyhow = "1.0" blake2b-rs = "0.2" -ckb-vm = { version = "=0.21.3", features = ["detect-asm"] } +ckb-vm = { version = "=0.22.0", default-features = false } +ckb-vm-aot = { version = "=0.22.0", optional = true } thiserror = "1.0" lazy_static = "1.4" rlp = "0.5.0" diff --git a/crates/generator/src/backend_manage.rs b/crates/generator/src/backend_manage.rs index 323648ebc..627bca105 100644 --- a/crates/generator/src/backend_manage.rs +++ b/crates/generator/src/backend_manage.rs @@ -192,7 +192,7 @@ impl BackendManage { #[cfg(has_asm)] fn aot_compile(&self, code_bytes: &Bytes) -> Result { let vm_version = crate::types::vm::VMVersion::V1; - let mut aot_machine = ckb_vm::machine::aot::AotCompilingMachine::load( + let mut aot_machine = ckb_vm_aot::AotCompilingMachine::load( code_bytes, Some(Box::new(crate::vm_cost_model::instruction_cycles)), vm_version.vm_isa(), diff --git a/crates/generator/src/generator.rs b/crates/generator/src/generator.rs index 8726b40b1..9f6bb3711 100644 --- a/crates/generator/src/generator.rs +++ b/crates/generator/src/generator.rs @@ -226,7 +226,7 @@ impl Generator { cycles_pool: &mut cycles_pool, context: &mut context, })) - .instruction_cycle_func(Box::new(instruction_cycles)); + .instruction_cycle_func(&instruction_cycles); let default_machine = machine_builder.build(); #[cfg(has_asm)] @@ -239,7 +239,7 @@ impl Generator { } #[cfg(has_asm)] - let mut machine = ckb_vm::machine::asm::AsmMachine::new(default_machine, aot_code_opt); + let mut machine = ckb_vm_aot::AotMachine::new(default_machine, aot_code_opt); #[cfg(not(has_asm))] let mut machine = TraceMachine::new(default_machine); diff --git a/crates/generator/src/types/vm.rs b/crates/generator/src/types/vm.rs index 9a3210b91..214dd2610 100644 --- a/crates/generator/src/types/vm.rs +++ b/crates/generator/src/types/vm.rs @@ -72,7 +72,7 @@ impl VMVersion { } #[cfg(has_asm)] -pub(crate) use ckb_vm::machine::asm::AotCode; +pub(crate) use ckb_vm_aot::AotCode; #[derive(Debug, Clone, Eq, PartialEq)] pub struct ChallengeContext { diff --git a/crates/godwoken-bin/Cargo.toml b/crates/godwoken-bin/Cargo.toml index 906490db0..54e421144 100644 --- a/crates/godwoken-bin/Cargo.toml +++ b/crates/godwoken-bin/Cargo.toml @@ -8,7 +8,7 @@ edition = "2021" [dependencies] anyhow = "1.0" -ckb-types = "0.104.0" +ckb-types = "0.105.1" clap = { version = "3", features = ["derive"] } indicatif = "0.16" gw-block-producer = { path = "../block-producer" } diff --git a/crates/jsonrpc-types/Cargo.toml b/crates/jsonrpc-types/Cargo.toml index 74541502c..ff50f2c56 100644 --- a/crates/jsonrpc-types/Cargo.toml +++ b/crates/jsonrpc-types/Cargo.toml @@ -11,6 +11,6 @@ serde = { version = "1.0", features = ["derive"] } faster-hex = "0.4" gw-types = { path = "../types" } gw-common = { path = "../common" } -ckb-jsonrpc-types = "0.104.0" -ckb-fixed-hash = "0.104.0" +ckb-jsonrpc-types = "0.105.1" +ckb-fixed-hash = "0.105.1" anyhow = "1.0" diff --git a/crates/replay-chain/Cargo.toml b/crates/replay-chain/Cargo.toml index 47375bc85..811b23fa0 100644 --- a/crates/replay-chain/Cargo.toml +++ b/crates/replay-chain/Cargo.toml @@ -21,8 +21,8 @@ gw-rpc-client = { path = "../rpc-client" } gw-utils = { path = "../utils" } async-jsonrpc-client = { version = "0.3.0", default-features = false, features = ["http-tokio"] } clap = "3" -ckb-fixed-hash = "0.104.0" -ckb-types = "0.104.0" +ckb-fixed-hash = "0.105.1" +ckb-types = "0.105.1" anyhow = "1.0" thiserror = "1.0" lazy_static = "1.4" diff --git a/crates/rpc-client/Cargo.toml b/crates/rpc-client/Cargo.toml index 156df4a05..478393a16 100644 --- a/crates/rpc-client/Cargo.toml +++ b/crates/rpc-client/Cargo.toml @@ -12,9 +12,9 @@ gw-config = { path = "../config" } gw-types = { path = "../types" } gw-jsonrpc-types = { path = "../jsonrpc-types" } faster-hex = "0.4" -ckb-crypto = "0.104.0" -ckb-fixed-hash = "0.104.0" -ckb-types = "0.104.0" +ckb-crypto = "0.105.1" +ckb-fixed-hash = "0.105.1" +ckb-types = "0.105.1" toml = "0.5" anyhow = "1.0" serde = { version = "1.0", features = ["derive"] } diff --git a/crates/rpc-client/src/ckb_client.rs b/crates/rpc-client/src/ckb_client.rs index 3afc940f5..c7f9e3dd5 100644 --- a/crates/rpc-client/src/ckb_client.rs +++ b/crates/rpc-client/src/ckb_client.rs @@ -7,7 +7,10 @@ use crate::{ use anyhow::{anyhow, bail, Context, Result}; use async_jsonrpc_client::{HttpClient, Params as ClientParams, Transport}; use gw_common::H256; -use gw_jsonrpc_types::{blockchain::CellDep, ckb_jsonrpc_types}; +use gw_jsonrpc_types::{ + blockchain::CellDep, + ckb_jsonrpc_types::{self, Either}, +}; use gw_types::{offchain::TxStatus, packed::Transaction, prelude::*}; use serde::de::DeserializeOwned; use serde_json::json; @@ -86,7 +89,7 @@ impl CKBClient { pub async fn get_transaction_with_status( &self, tx_hash: H256, - ) -> Result> { + ) -> Result> { self.request( "get_transaction", Some(ClientParams::Array(vec![json!(to_jsonh256(tx_hash))])), @@ -97,12 +100,17 @@ impl CKBClient { #[instrument(skip_all, fields(tx_hash = %tx_hash.pack()))] pub async fn get_transaction(&self, tx_hash: H256) -> Result> { let tx_with_status = self.get_transaction_with_status(tx_hash).await?; - Ok(tx_with_status + tx_with_status .and_then(|tx_with_status| tx_with_status.transaction) .map(|tv| { + let tv: ckb_jsonrpc_types::TransactionView = match tv.inner { + Either::Left(v) => v, + Either::Right(v) => serde_json::from_slice(v.as_bytes())?, + }; let tx: ckb_types::packed::Transaction = tv.inner.into(); - Transaction::new_unchecked(tx.as_bytes()) - })) + Ok(Transaction::new_unchecked(tx.as_bytes())) + }) + .transpose() } #[instrument(skip_all, fields(tx_hash = %tx_hash.pack()))] @@ -178,24 +186,31 @@ impl CKBClient { contract: &str, cell_dep: CellDep, ) -> Result { - use ckb_jsonrpc_types::TransactionWithStatus; + use ckb_jsonrpc_types::TransactionWithStatusResponse; let tx_hash = cell_dep.out_point.tx_hash; - let tx_with_status: Option = self + let tx_with_status: Option = self .request( "get_transaction", Some(ClientParams::Array(vec![json!(tx_hash)])), ) .await?; - let tx = match tx_with_status { - Some(TransactionWithStatus { + let tx: ckb_jsonrpc_types::TransactionView = match tx_with_status { + Some(TransactionWithStatusResponse { transaction: Some(tv), .. - }) => tv.inner, + }) => match tv.inner { + Either::Left(v) => v, + Either::Right(v) => serde_json::from_slice(v.as_bytes())?, + }, _ => bail!("{} {} tx not found", contract, tx_hash), }; - match tx.outputs.get(cell_dep.out_point.index.value() as usize) { + match tx + .inner + .outputs + .get(cell_dep.out_point.index.value() as usize) + { Some(output) => match output.type_.as_ref() { Some(script) => Ok(script.to_owned().into()), None => Err(anyhow!("{} {} tx hasn't type script", contract, tx_hash)), diff --git a/crates/rpc-client/src/rpc_client.rs b/crates/rpc-client/src/rpc_client.rs index 1166dc0c7..83ae0e9f3 100644 --- a/crates/rpc-client/src/rpc_client.rs +++ b/crates/rpc-client/src/rpc_client.rs @@ -1010,7 +1010,7 @@ impl RPCClient { let tx = ckb_types::packed::Transaction::new_unchecked(tx.as_bytes()); tx.into() }; - let dry_run_result: ckb_jsonrpc_types::DryRunResult = self + let dry_run_result: ckb_jsonrpc_types::EstimateCycles = self .ckb .request( "dry_run_transaction", diff --git a/crates/rpc-server/Cargo.toml b/crates/rpc-server/Cargo.toml index 4f7db0dd9..0608f0b77 100644 --- a/crates/rpc-server/Cargo.toml +++ b/crates/rpc-server/Cargo.toml @@ -24,9 +24,9 @@ gw-polyjuice-sender-recover = { path = "../polyjuice-sender-recover" } gw-rpc-client = { path = "../rpc-client" } gw-dynamic-config = { path = "../dynamic-config"} faster-hex = "0.4" -ckb-crypto = "0.104.0" -ckb-fixed-hash = "0.104.0" -ckb-types = "0.104.0" +ckb-crypto = "0.105.1" +ckb-fixed-hash = "0.105.1" +ckb-types = "0.105.1" anyhow = "1.0" serde = { version = "1.0", features = ["derive"] } futures = "0.3.13" diff --git a/crates/tests/Cargo.toml b/crates/tests/Cargo.toml index 6095449b8..85b08cb58 100644 --- a/crates/tests/Cargo.toml +++ b/crates/tests/Cargo.toml @@ -29,21 +29,20 @@ gw-polyjuice-sender-recover = { path = "../polyjuice-sender-recover" } godwoken-bin = { path = "../godwoken-bin" } anyhow = "1.0" blake2b-rs = "0.2" -ckb-vm = { version = "=0.21.3", features = ["detect-asm", "aot"] } -ckb-vm-definitions = "=0.21.3" +ckb-vm = { version = "=0.22.0", default-features = false } thiserror = "1.0" lazy_static = "1.4" secp256k1 = { version = "0.21", features = ["recovery", "rand-std"] } async-jsonrpc-client = { version = "0.3.0", default-features = false, features = ["http-tokio"] } sha3 = "0.9.1" hex = "0.4.2" -ckb-script = "0.104.0" -ckb-types = "0.104.0" -ckb-error = "0.104.0" -ckb-crypto = "0.104.0" -ckb-hash = "0.104.0" -ckb-traits = "0.104.0" -ckb-fixed-hash = "0.104.0" +ckb-script = "0.105.1" +ckb-types = "0.105.1" +ckb-error = "0.105.1" +ckb-crypto = "0.105.1" +ckb-hash = "0.105.1" +ckb-traits = "0.105.1" +ckb-fixed-hash = "0.105.1" rand = "0.8" serde = "1.0" serde_json = "1.0" diff --git a/crates/tools/Cargo.toml b/crates/tools/Cargo.toml index 0723968ff..c52425f50 100644 --- a/crates/tools/Cargo.toml +++ b/crates/tools/Cargo.toml @@ -12,20 +12,21 @@ clap = "3" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" anyhow = "1.0" +thiserror = "1.0" toml = "0.5" -bech32 = "0.6.0" tempfile = "3.1" lazy_static = "1.3" -secp256k1 = "0.20" +secp256k1 = "0.24" sha3 = "0.9.1" reqwest = { version = "0.11", features = ["json"] } -ckb-jsonrpc-types = "0.104.0" -ckb-types = "0.104.0" -ckb-resource = "0.104.0" -ckb-hash = "0.104.0" -ckb-fixed-hash = "0.104.0" -ckb-sdk = "1.1" -ckb-crypto = "0.104.0" +ckb-jsonrpc-types = "0.105.1" +ckb-types = "0.105.1" +ckb-resource = "0.105.1" +ckb-hash = "0.105.1" +ckb-fixed-hash = "0.105.1" +ckb-crypto = "0.105.1" +ckb-traits = "0.105.1" +ckb-dao-utils = "0.105.1" gw-db = { path = "../db" } gw-types = { path = "../types" } gw-config = { path = "../config" } @@ -42,4 +43,14 @@ hex = "0.4" tokio = { version = "1.15", features = ["full"] } jsonrpc-core = "17" csv = "1.1.6" +bech32 = "0.8.1" tracing-subscriber = { version = "0.3.11", default-features = false, features = ["tracing-log"] } +parking_lot = "0.12" +lru = "0.8" +dashmap = "5.4" + +[dev-dependencies] +ckb-chain-spec = "0.105.1" +ckb-script = "0.105.1" +httpmock = "0.6" +ckb-mock-tx-types = "0.105.1" diff --git a/crates/tools/src/account.rs b/crates/tools/src/account.rs index 82d2ab905..7191c6c46 100644 --- a/crates/tools/src/account.rs +++ b/crates/tools/src/account.rs @@ -3,8 +3,8 @@ use crate::hasher::CkbHasher; use crate::types::ScriptsDeploymentResult; use anyhow::{anyhow, Result}; use ckb_crypto::secp::Privkey; +use ckb_crypto::secp::SECP256K1; use ckb_fixed_hash::H256; -use ckb_sdk::SECP256K1; use ckb_types::{ bytes::Bytes as CKBBytes, core::ScriptHashType, prelude::Builder as CKBBuilder, prelude::Entity as CKBEntity, diff --git a/crates/tools/src/deploy_genesis.rs b/crates/tools/src/deploy_genesis.rs index 00a099e7c..d9aa87b5b 100644 --- a/crates/tools/src/deploy_genesis.rs +++ b/crates/tools/src/deploy_genesis.rs @@ -9,16 +9,16 @@ use ckb_types::bytes::{BufMut, BytesMut}; use gw_rpc_client::ckb_client::CKBClient; use tempfile::NamedTempFile; -use ckb_fixed_hash::H256; -use ckb_hash::new_blake2b; -use ckb_jsonrpc_types as rpc_types; -use ckb_resource::CODE_HASH_SECP256K1_DATA; -use ckb_sdk::{ +use crate::utils::sdk::{ constants::{MIN_SECP_CELL_CAPACITY, ONE_CKB}, traits::DefaultCellDepResolver, util::get_max_mature_number, Address, AddressPayload, CkbRpcClient, HumanCapacity, }; +use ckb_fixed_hash::H256; +use ckb_hash::new_blake2b; +use ckb_jsonrpc_types as rpc_types; +use ckb_resource::CODE_HASH_SECP256K1_DATA; use ckb_types::{ bytes::Bytes, core::{BlockView, Capacity, DepType, ScriptHashType, TransactionBuilder, TransactionView}, diff --git a/crates/tools/src/deploy_scripts.rs b/crates/tools/src/deploy_scripts.rs index 84f6fa1ae..6171e3288 100644 --- a/crates/tools/src/deploy_scripts.rs +++ b/crates/tools/src/deploy_scripts.rs @@ -1,3 +1,4 @@ +use crate::utils::sdk::{Address, AddressPayload, CkbRpcClient, HumanCapacity}; use crate::{ types::{BuildScriptsResult, DeployItem, Programs, ScriptsDeploymentResult}, utils::transaction::{get_network_type, run_cmd, TYPE_ID_CODE_HASH}, @@ -5,7 +6,6 @@ use crate::{ use anyhow::{anyhow, Result}; use ckb_fixed_hash::H256; use ckb_jsonrpc_types::{CellDep, DepType, OutPoint, Script}; -use ckb_sdk::{Address, AddressPayload, CkbRpcClient, HumanCapacity}; use ckb_types::{ bytes::Bytes, core::{Capacity, ScriptHashType}, diff --git a/crates/tools/src/deposit_ckb.rs b/crates/tools/src/deposit_ckb.rs index 3172341c0..1035a5d8c 100644 --- a/crates/tools/src/deposit_ckb.rs +++ b/crates/tools/src/deposit_ckb.rs @@ -2,10 +2,10 @@ use crate::account::{privkey_to_eth_address, read_privkey}; use crate::godwoken_rpc::GodwokenRpcClient; use crate::hasher::CkbHasher; use crate::types::ScriptsDeploymentResult; +use crate::utils::sdk::{Address, AddressPayload, CkbRpcClient, HumanCapacity, SECP256K1}; use crate::utils::transaction::{get_network_type, read_config, run_cmd}; use anyhow::{anyhow, Result}; use ckb_fixed_hash::H256; -use ckb_sdk::{Address, AddressPayload, CkbRpcClient, HumanCapacity, SECP256K1}; use ckb_types::{ bytes::Bytes as CKBBytes, core::ScriptHashType, packed::Script as CKBScript, prelude::Builder as CKBBuilder, prelude::Entity as CKBEntity, prelude::Pack as CKBPack, diff --git a/crates/tools/src/generate_config.rs b/crates/tools/src/generate_config.rs index 33ca44e55..4914525a7 100644 --- a/crates/tools/src/generate_config.rs +++ b/crates/tools/src/generate_config.rs @@ -4,9 +4,9 @@ use crate::types::{ BuildScriptsResult, OmniLockConfig, RollupDeploymentResult, ScriptsDeploymentResult, UserRollupConfig, }; +use crate::utils::sdk::CkbRpcClient; use anyhow::{anyhow, Result}; use ckb_jsonrpc_types::{CellDep, JsonBytes}; -use ckb_sdk::CkbRpcClient; use ckb_types::prelude::{Builder, Entity}; use gw_common::builtins::ETH_REGISTRY_ACCOUNT_ID; use gw_config::{ diff --git a/crates/tools/src/main.rs b/crates/tools/src/main.rs index 0097bb630..b0c97845a 100644 --- a/crates/tools/src/main.rs +++ b/crates/tools/src/main.rs @@ -22,9 +22,11 @@ mod update_cell; mod utils; mod withdraw; +pub use crate::utils::sdk; + +use crate::utils::sdk::constants::ONE_CKB; use account::read_privkey; use anyhow::{anyhow, Result}; -use ckb_sdk::constants::ONE_CKB; use ckb_types::prelude::Unpack; use clap::{value_t, App, Arg, SubCommand}; use deploy_genesis::DeployRollupCellArgs; diff --git a/crates/tools/src/update_cell.rs b/crates/tools/src/update_cell.rs index 315835073..3f57fb183 100644 --- a/crates/tools/src/update_cell.rs +++ b/crates/tools/src/update_cell.rs @@ -1,6 +1,6 @@ +use crate::utils::sdk::CkbRpcClient; use anyhow::{anyhow, Result}; -use ckb_jsonrpc_types::OutputsValidator; -use ckb_sdk::CkbRpcClient; +use ckb_jsonrpc_types::{Either, OutputsValidator}; use ckb_types::prelude::{Entity, Unpack as CKBUnpack}; use gw_config::WalletConfig; use gw_rpc_client::{ckb_client::CKBClient, indexer_client::CKBIndexerClient}; @@ -45,10 +45,15 @@ pub async fn update_cell>(args: UpdateCellArgs<'_, P>) -> Result< .get_transaction(tx_hash.into()) .map_err(|err| anyhow!("{}", err))? .ok_or_else(|| anyhow!("can't found transaction"))?; - let tx = tx_with_status + let tv = match tx_with_status .transaction .ok_or_else(|| anyhow!("tx {:x} not found", tx_hash.pack()))? - .inner; + .inner + { + Either::Left(v) => v, + Either::Right(v) => serde_json::from_slice(v.as_bytes())?, + }; + let tx = tv.inner; let existed_cell = tx .outputs .get(index as usize) diff --git a/crates/tools/src/utils/mod.rs b/crates/tools/src/utils/mod.rs index 04b20adcb..30b3edf44 100644 --- a/crates/tools/src/utils/mod.rs +++ b/crates/tools/src/utils/mod.rs @@ -1,3 +1,4 @@ pub mod cli_args; pub mod message; +pub mod sdk; pub mod transaction; diff --git a/crates/tools/src/utils/sdk/constants.rs b/crates/tools/src/utils/sdk/constants.rs new file mode 100644 index 000000000..0ed38ce32 --- /dev/null +++ b/crates/tools/src/utils/sdk/constants.rs @@ -0,0 +1,78 @@ +use ckb_types::{core::EpochNumberWithFraction, h256, H256}; + +pub const PREFIX_MAINNET: &str = "ckb"; +pub const PREFIX_TESTNET: &str = "ckt"; + +pub const NETWORK_MAINNET: &str = "ckb"; +pub const NETWORK_TESTNET: &str = "ckb_testnet"; +pub const NETWORK_STAGING: &str = "ckb_staging"; +pub const NETWORK_DEV: &str = "ckb_dev"; + +pub const SECP_SIGNATURE_SIZE: usize = 65; + +// Since relative mask +pub const LOCK_TYPE_FLAG: u64 = 1 << 63; +pub const METRIC_TYPE_FLAG_MASK: u64 = 0x6000_0000_0000_0000; +pub const VALUE_MASK: u64 = 0x00ff_ffff_ffff_ffff; +pub const REMAIN_FLAGS_BITS: u64 = 0x1f00_0000_0000_0000; + +// Special cells in genesis transactions: (transaction-index, output-index) +pub const SIGHASH_OUTPUT_LOC: (usize, usize) = (0, 1); +pub const MULTISIG_OUTPUT_LOC: (usize, usize) = (0, 4); +pub const DAO_OUTPUT_LOC: (usize, usize) = (0, 2); +pub const SIGHASH_GROUP_OUTPUT_LOC: (usize, usize) = (1, 0); +pub const MULTISIG_GROUP_OUTPUT_LOC: (usize, usize) = (1, 1); + +pub const ONE_CKB: u64 = 100_000_000; +pub const MIN_SECP_CELL_CAPACITY: u64 = 61 * ONE_CKB; +// mainnet,testnet cellbase maturity +pub const CELLBASE_MATURITY: EpochNumberWithFraction = + EpochNumberWithFraction::new_unchecked(4, 0, 1); + +/// "TYPE_ID" in hex (copied from ckb-chain-spec) +pub const TYPE_ID_CODE_HASH: H256 = h256!("0x545950455f4944"); + +pub const SIGHASH_TYPE_HASH: H256 = + h256!("0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8"); +pub const MULTISIG_TYPE_HASH: H256 = + h256!("0x5c5069eb0857efc65e1bca0c07df34c31663b3622fd3876c876320fc9634e2a8"); +pub const DAO_TYPE_HASH: H256 = + h256!("0x82d76d1b75fe2fd9a27dfbaa65a039221a380d76c926f378d3f81cf3e7e13f2e"); + +/// anyone can pay script mainnet code hash, see: +/// +pub const ACP_TYPE_HASH_LINA: H256 = + h256!("0xd369597ff47f29fbc0d47d2e3775370d1250b85140c670e4718af712983a2354"); +/// anyone can pay script testnet code hash +pub const ACP_TYPE_HASH_AGGRON: H256 = + h256!("0x3419a1c09eb2567f6552ee7a8ecffd64155cffe0f1796e6e61ec088d740c1356"); + +/// cheque withdraw since value +pub const CHEQUE_CELL_SINCE: u64 = 0xA000000000000006; + +#[cfg(test)] +mod test { + use super::*; + use ckb_types::{ + core::Capacity, + packed::{CellOutput, Script}, + prelude::*, + H160, + }; + + #[test] + fn test_min_capacity() { + let min_secp_cell_capacity = CellOutput::new_builder() + .lock( + Script::new_builder() + .args(H160::default().as_bytes().pack()) + .build(), + ) + .build() + .occupied_capacity(Capacity::zero()) + .unwrap() + .as_u64(); + + assert_eq!(min_secp_cell_capacity, MIN_SECP_CELL_CAPACITY); + } +} diff --git a/crates/tools/src/utils/sdk/mod.rs b/crates/tools/src/utils/sdk/mod.rs new file mode 100644 index 000000000..0b4f55174 --- /dev/null +++ b/crates/tools/src/utils/sdk/mod.rs @@ -0,0 +1,15 @@ +/// The `ckb-sdk` crate contains too many dependencies. +/// So we move some source code from https://github.com/nervosnetwork/ckb-sdk-rust +pub mod constants; +pub mod rpc; +#[cfg(test)] +pub mod test_utils; +pub mod traits; +pub mod tx_fee; +pub mod types; +pub mod unlock; +pub mod util; + +pub use ckb_crypto::secp::SECP256K1; +pub use rpc::CkbRpcClient; +pub use types::{Address, AddressPayload, HumanCapacity, NetworkType, ScriptId}; diff --git a/crates/tools/src/utils/sdk/rpc/ckb.rs b/crates/tools/src/utils/sdk/rpc/ckb.rs new file mode 100644 index 000000000..d7a8b1cf9 --- /dev/null +++ b/crates/tools/src/utils/sdk/rpc/ckb.rs @@ -0,0 +1,81 @@ +use ckb_jsonrpc_types::{ + Alert, BannedAddr, Block, BlockEconomicState, BlockNumber, BlockTemplate, BlockView, + CellWithStatus, ChainInfo, Consensus, EpochNumber, EpochView, ExtraLoggerConfig, HeaderView, + JsonBytes, LocalNode, MainLoggerConfig, OutPoint, OutputsValidator, RawTxPool, RemoteNode, + Script, SyncState, Timestamp, Transaction, TransactionProof, TransactionWithStatusResponse, + TxPoolInfo, Uint64, Version, +}; +use ckb_types::H256; + +crate::jsonrpc!(pub struct CkbRpcClient { + // Chain + pub fn get_block(&mut self, hash: H256) -> Option; + pub fn get_block_by_number(&mut self, number: BlockNumber) -> Option; + pub fn get_block_hash(&mut self, number: BlockNumber) -> Option; + pub fn get_current_epoch(&mut self) -> EpochView; + pub fn get_epoch_by_number(&mut self, number: EpochNumber) -> Option; + pub fn get_header(&mut self, hash: H256) -> Option; + pub fn get_header_by_number(&mut self, number: BlockNumber) -> Option; + pub fn get_live_cell(&mut self, out_point: OutPoint, with_data: bool) -> CellWithStatus; + pub fn get_tip_block_number(&mut self) -> BlockNumber; + pub fn get_tip_header(&mut self) -> HeaderView; + pub fn get_transaction(&mut self, hash: H256) -> Option; + pub fn get_transaction_proof( + &mut self, + tx_hashes: Vec, + block_hash: Option + ) -> TransactionProof; + pub fn verify_transaction_proof(&mut self, tx_proof: TransactionProof) -> Vec; + pub fn get_fork_block(&mut self, block_hash: H256) -> Option; + pub fn get_consensus(&mut self) -> Consensus; + pub fn get_block_median_time(&mut self, block_hash: H256) -> Option; + pub fn get_block_economic_state(&mut self, block_hash: H256) -> Option; + + // Net + pub fn get_banned_addresses(&mut self) -> Vec; + pub fn get_peers(&mut self) -> Vec; + pub fn local_node_info(&mut self) -> LocalNode; + pub fn set_ban( + &mut self, + address: String, + command: String, + ban_time: Option, + absolute: Option, + reason: Option + ) -> (); + pub fn sync_state(&mut self) -> SyncState; + pub fn set_network_active(&mut self, state: bool) -> (); + pub fn add_node(&mut self, peer_id: String, address: String) -> (); + pub fn remove_node(&mut self, peer_id: String) -> (); + pub fn clear_banned_addresses(&mut self) -> (); + pub fn ping_peers(&mut self) -> (); + + // Pool + pub fn send_transaction(&mut self, tx: Transaction, outputs_validator: Option) -> H256; + pub fn remove_transaction(&mut self, tx_hash: H256) -> bool; + pub fn tx_pool_info(&mut self) -> TxPoolInfo; + pub fn clear_tx_pool(&mut self) -> (); + pub fn get_raw_tx_pool(&mut self, verbose: Option) -> RawTxPool; + pub fn tx_pool_ready(&mut self) -> bool; + + // Stats + pub fn get_blockchain_info(&mut self) -> ChainInfo; + + // Miner + pub fn get_block_template(&mut self, bytes_limit: Option, proposals_limit: Option, max_version: Option) -> BlockTemplate; + pub fn submit_block(&mut self, _work_id: String, _data: Block) -> H256; + + // Alert + pub fn send_alert(&mut self, alert: Alert) -> (); + + // IntegrationTest + pub fn process_block_without_verify(&mut self, data: Block, broadcast: bool) -> Option; + pub fn truncate(&mut self, target_tip_hash: H256) -> (); + pub fn generate_block(&mut self, block_assembler_script: Option