diff --git a/Cargo.lock b/Cargo.lock index 5baee1039..bd904e22b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -17,38 +17,6 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" -[[package]] -name = "aes-ctr" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7729c3cde54d67063be556aeac75a81330d802f0259500ca40cb52967f975763" -dependencies = [ - "aes-soft", - "aesni", - "cipher", - "ctr", -] - -[[package]] -name = "aes-soft" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be14c7498ea50828a38d0e24a765ed2effe92a705885b57d029cd67d45744072" -dependencies = [ - "cipher", - "opaque-debug 0.3.0", -] - -[[package]] -name = "aesni" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea2e11f5e94c2f7d386164cc2aa1f97823fed6f259e486940a71c174dd01b0ce" -dependencies = [ - "cipher", - "opaque-debug 0.3.0", -] - [[package]] name = "ahash" version = "0.7.6" @@ -80,9 +48,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.53" +version = "1.0.71" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94a45b455c14666b85fc40a019e8ab9eb75e3a124e05494f5397122bc9eb06e0" +checksum = "9c7d0618f0e0b7e8ff11427422b64564d5fb0be1940354bfe2e0529b18a9d9b8" [[package]] name = "arc-swap" @@ -123,7 +91,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aed81bb36bcbe041406cceba4ba425726a783d26c0ae19547d51fe673d275975" dependencies = [ "async-trait", - "base64 0.13.0", + "base64", "futures", "http", "jsonrpc-types", @@ -143,7 +111,7 @@ checksum = "061a7acccaa286c011ddc30970520b98fa40e00c9d644633fb26b5fc63a265e3" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.86", ] [[package]] @@ -174,9 +142,9 @@ checksum = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2" [[package]] name = "autocfg" -version = "1.0.1" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "backtrace" @@ -192,16 +160,6 @@ dependencies = [ "rustc-demangle", ] -[[package]] -name = "base64" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "489d6c0ed21b11d038c31b6ceccca973e65d73ba3bd8ecb9a2babf5546164643" -dependencies = [ - "byteorder", - "safemem", -] - [[package]] name = "base64" version = "0.13.0" @@ -214,6 +172,12 @@ version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "58946044516aa9dc922182e0d6e9d124a31aafe6b421614654eb27cf90cec09c" +[[package]] +name = "bech32" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf9ff0bbfd639f15c74af777d81383cf53efb7c93613f6cab67c6c11e05bbf8b" + [[package]] name = "bindgen" version = "0.59.2" @@ -235,18 +199,9 @@ dependencies = [ [[package]] name = "bit-vec" -version = "0.5.1" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f59bbe95d4e52a6398ec21238d31577f2b28a9d86807f06ca59d191d8440d0bb" - -[[package]] -name = "bitcoin_hashes" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b7a2e9773ee7ae7f2560f0426c938f57902dcb9e39321b0cbd608f47ed579a4" -dependencies = [ - "byteorder", -] +checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" [[package]] name = "bitflags" @@ -268,18 +223,9 @@ dependencies = [ [[package]] name = "blake2b-ref" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95916998c798756098a4eb1b3f2cd510659705a9817bf203d61abd30fbec3e7b" - -[[package]] -name = "blake2b-rs" -version = "0.1.5" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e35e362830ef90ecea16f09b21b75d22d33a8562a679c74ab4f4fa49b4fcb87" -dependencies = [ - "cc", -] +checksum = "294d17c72e0ba59fad763caa112368d0672083779cdebbb97164f4bb4c1e339a" [[package]] name = "blake2b-rs" @@ -313,6 +259,15 @@ dependencies = [ "generic-array 0.14.5", ] +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array 0.14.5", +] + [[package]] name = "block-padding" version = "0.1.5" @@ -444,27 +399,17 @@ dependencies = [ "num-integer", "num-traits", "serde", - "time", "winapi 0.3.9", ] -[[package]] -name = "cipher" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12f8e7987cbd042a63249497f41aed09f8e65add917ea6566effbc56578d6801" -dependencies = [ - "generic-array 0.14.5", -] - [[package]] name = "ckb-chain-spec" -version = "0.100.0" +version = "0.111.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc92a4d0bdfb77f0f086d608b00a28cecca5bf61e223f7eee449ee90644ca602" +checksum = "dbd58081d4ac4f08d068b52c5a07f0b379d93aad0dfa8344c6890429a9b73c2b" dependencies = [ "ckb-constant", - "ckb-crypto 0.100.0", + "ckb-crypto 0.111.0", "ckb-dao-utils", "ckb-error", "ckb-hash", @@ -474,24 +419,25 @@ dependencies = [ "ckb-resource", "ckb-traits", "ckb-types", + "ckb-util", "serde", "toml", ] [[package]] name = "ckb-channel" -version = "0.100.0" +version = "0.111.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fd26969842dcb59b76f4094fcafed3d1eea7bd3423f9c1277877f216cf9337a" +checksum = "701e6829c3dcbae46dd2442de63d080046480a6c2bb4951dbf419ad092459402" dependencies = [ "crossbeam-channel", ] [[package]] name = "ckb-constant" -version = "0.100.0" +version = "0.111.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83f76e9b4af7840e31f786e13ac4e37848e92489c8f433e714b0e7af1aa2b94b" +checksum = "9d5c980d4724770f72a37bceffa26ea64dd914891e45e856e2a3792fdb4a5a18" [[package]] name = "ckb-crypto" @@ -509,23 +455,23 @@ dependencies = [ [[package]] name = "ckb-crypto" -version = "0.100.0" +version = "0.111.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f37962d1d4afd8ea29caa07cee90fde9866f0e854aafecbe705ffe0e2f858aec" +checksum = "df80db694e42b64a5774ae551daff3c8310cd99bb528643dbe0dd409abb298e7" dependencies = [ - "ckb-fixed-hash 0.100.0", + "ckb-fixed-hash 0.111.0", "faster-hex 0.6.1", "lazy_static", "rand 0.7.3", - "secp256k1 0.19.0", + "secp256k1 0.24.3", "thiserror", ] [[package]] name = "ckb-dao-utils" -version = "0.100.0" +version = "0.111.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3604a46acaaca3e217432653b1e05a92abc88b343a793680ed012755096ced63" +checksum = "5e158ce5a4e9d1fcd08d9dee87332474572c629c6273cca0aea80ba24892a403" dependencies = [ "byteorder", "ckb-error", @@ -534,9 +480,9 @@ dependencies = [ [[package]] name = "ckb-error" -version = "0.100.0" +version = "0.111.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d32d6ac3ea91f8a054299677626b88de06cb39c1693274a1f2b8ee9f56877ab7" +checksum = "34cfd733cabcb4262ee679c02733864b13c8fa879e3aabc078fe0ec727cd95d6" dependencies = [ "anyhow", "ckb-occupied-capacity", @@ -556,12 +502,12 @@ dependencies = [ [[package]] name = "ckb-fixed-hash" -version = "0.100.0" +version = "0.111.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ba28c5410970e02831bb78de4858d222e050bfdb2d1c3c1e6ea0bb98432f153" +checksum = "3b1dfab045fffa31cae9680d73e1f09833ca1abfb807dc4b9544739c94c23fd0" dependencies = [ - "ckb-fixed-hash-core 0.100.0", - "ckb-fixed-hash-macros 0.100.0", + "ckb-fixed-hash-core 0.111.0", + "ckb-fixed-hash-macros 0.111.0", ] [[package]] @@ -577,9 +523,9 @@ dependencies = [ [[package]] name = "ckb-fixed-hash-core" -version = "0.100.0" +version = "0.111.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e371bbd96d74520ee54d785576fc31a15c2f1abed0c934ede7f6288be6f0f721" +checksum = "bdd1727a6ecd4d0bcab604cb1ef707fe92e939fa6e9a438f9f25bf05208cb080" dependencies = [ "faster-hex 0.6.1", "serde", @@ -595,36 +541,51 @@ dependencies = [ "ckb-fixed-hash-core 0.38.0", "proc-macro2", "quote", - "syn", + "syn 1.0.86", ] [[package]] name = "ckb-fixed-hash-macros" -version = "0.100.0" +version = "0.111.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a08ca951545bf611d6ef7496464d0d06909f48f6c26ac2e52362f7a2891af857" +checksum = "7b5da34c32585c35715fcde4e3a1dd3b0346d7af43506c5e51c613f01483e4f9" dependencies = [ - "ckb-fixed-hash-core 0.100.0", + "ckb-fixed-hash-core 0.111.0", "proc-macro2", "quote", - "syn", + "syn 1.0.86", +] + +[[package]] +name = "ckb-gen-types" +version = "0.111.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3bc54ca99b09e1eb5fc6c49bb1156644ce57fce9c6f52b5c13110b9a3143f7e" +dependencies = [ + "cfg-if 1.0.0", + "ckb-error", + "ckb-fixed-hash 0.111.0", + "ckb-hash", + "ckb-occupied-capacity", + "molecule", + "numext-fixed-uint", ] [[package]] name = "ckb-hash" -version = "0.100.0" +version = "0.111.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df37898d25ee742d94857cb2b41090e59b270eeb1f3e4b8a7422f53ea0e98364" +checksum = "8c88e5e2d6454be488fa5cf8b49175879353c6af969ff210dd6416f315b53120" dependencies = [ "blake2b-ref", - "blake2b-rs 0.1.5", + "blake2b-rs", ] [[package]] name = "ckb-jsonrpc-types" -version = "0.100.0" +version = "0.111.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5190f0338984300cc4dbce29b41ada707a5c9a1a3e4c53064d141696827871f" +checksum = "d789a71538da07871c11aecbd28d6c632bb426bdfeed5fc2fa1b455e31152468" dependencies = [ "ckb-types", "faster-hex 0.6.1", @@ -646,18 +607,39 @@ dependencies = [ [[package]] name = "ckb-logger" -version = "0.100.0" +version = "0.111.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48a25f45be3d1ab1018df5d2c80227110eea80fc95cd1e8a5803d9bfb5a2a1e9" +checksum = "939fa09ca3534248d3d452552546f016fc7e11346644fbc5b55d2ad38d3e80e7" 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.111.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcd5b156c36f03ad6053e174e26a874088c8e9098c3a2e80ec93dc9831ecfac3" +dependencies = [ + "ckb-jsonrpc-types", + "ckb-traits", + "ckb-types", + "serde", +] + [[package]] name = "ckb-occupied-capacity" -version = "0.100.0" +version = "0.111.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9004516368e99d45a296e7345dd2ab26d7159b80d4abfdb69f942015ffb3c943" +checksum = "358ad364465a5a359575642c12952ba8735a148382789d65ddd5231cd21899fc" dependencies = [ "ckb-occupied-capacity-core", "ckb-occupied-capacity-macros", @@ -665,29 +647,29 @@ dependencies = [ [[package]] name = "ckb-occupied-capacity-core" -version = "0.100.0" +version = "0.111.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74a236d40948a50d35726c9f56651f961a5c3254ec871b71923b23dfa5da949d" +checksum = "de2dc06db98f8a995cb7145bc56dbd17bb0c8ab2e59a07aaa40f2c956c2451dd" dependencies = [ "serde", ] [[package]] name = "ckb-occupied-capacity-macros" -version = "0.100.0" +version = "0.111.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad3066524d728b5629ff4a7823cdb2b0c17867aa6fb4313a84f28879f4aba0db" +checksum = "b1709e0f101026c4ef29b1593692e480b03cdb4e0dace1e348494c6554d50d35" dependencies = [ "ckb-occupied-capacity-core", "quote", - "syn", + "syn 1.0.86", ] [[package]] name = "ckb-pow" -version = "0.100.0" +version = "0.111.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3798cc0becd65a6b058908abf958b28dac6989bc31494de608d7c40fc18bf6e6" +checksum = "481e76388993d7e6e0dd797e8532c60398901787e28d0638ca114254257b8813" dependencies = [ "byteorder", "ckb-hash", @@ -699,9 +681,9 @@ dependencies = [ [[package]] name = "ckb-rational" -version = "0.100.0" +version = "0.111.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "782866bcf4189f02d7cc2308fb6d2d8e94633f1589ca2924056567a7a769c636" +checksum = "bd3959391a4fb05d6a2578aa8db75732ada1ce381fb34d6eeaf09d395702e63c" dependencies = [ "numext-fixed-uint", "serde", @@ -709,9 +691,9 @@ dependencies = [ [[package]] name = "ckb-resource" -version = "0.100.0" +version = "0.111.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a7e3b6a53ea093fce15eaa212b961e4300d724efe1d2d1eda58d2324b192686" +checksum = "03222b0613cf3f55cb181471d7a84879b6fba5e920e2e1c7ba2c2315614bd387" dependencies = [ "ckb-system-scripts", "ckb-types", @@ -735,9 +717,9 @@ dependencies = [ [[package]] name = "ckb-script" -version = "0.100.0" +version = "0.111.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15b1429fcef051547ab7e7d240952b945ffdbefa28e1d25a77ebfb846f614e4f" +checksum = "8c9075ad901eae97925f491b6be675d7b19bf7b10eaa94a88f6e8070c0cd00ba" dependencies = [ "byteorder", "ckb-chain-spec", @@ -746,75 +728,60 @@ dependencies = [ "ckb-logger", "ckb-traits", "ckb-types", - "ckb-vm", - "ckb-vm-definitions", + "ckb-vm 0.24.6", "faster-hex 0.6.1", - "goblin 0.2.3", "serde", ] [[package]] name = "ckb-sdk" -version = "0.100.0" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15c74c28b02488f3f23dcafc04f3a7a8f4d66360d0835e9aec8cfbb0729e4d56" +checksum = "9ded3042867b04f20456f17a1f752f2604a24659f3aeec1928917d9ee6b659d4" dependencies = [ - "aes-ctr", - "bech32", - "bitcoin_hashes", - "byteorder", + "anyhow", + "bech32 0.8.1", + "bitflags", "bytes 1.1.0", - "chrono", "ckb-chain-spec", - "ckb-crypto 0.100.0", - "ckb-error", + "ckb-crypto 0.111.0", + "ckb-dao-utils", "ckb-hash", "ckb-jsonrpc-types", + "ckb-mock-tx-types", "ckb-resource", "ckb-script", - "ckb-sdk-types", + "ckb-traits", "ckb-types", - "failure", - "faster-hex 0.4.1", - "fnv", + "dashmap", + "derive-getters", + "dyn-clone", + "enum-repr-derive", "futures", "jsonrpc-core 18.0.0", + "lazy_static", "log", - "rand 0.7.3", + "lru", + "parking_lot 0.12.1", "reqwest", - "scrypt", - "secp256k1 0.19.0", + "secp256k1 0.24.3", "serde", "serde_derive", "serde_json", - "tiny-keccak 1.5.0", + "sha3 0.10.6", + "sparse-merkle-tree 0.6.1", + "thiserror", "tokio", - "tokio-util", - "uuid 0.7.4", -] - -[[package]] -name = "ckb-sdk-types" -version = "0.100.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb1909b93172ae706566697a4ce529601588eb77cee4e8f6346a507dfe589aae" -dependencies = [ - "ckb-error", - "ckb-hash", - "ckb-jsonrpc-types", - "ckb-traits", - "ckb-types", - "serde", - "serde_derive", + "tokio-util 0.7.8", ] [[package]] name = "ckb-system-scripts" -version = "0.5.3" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be7c2827ee5fe545ea15d52d0d3213c97db10e97a71eba302ff712ddb86c09c2" +checksum = "fa5c59063142de7a68cfad4449c6b3863563856219a2925dfb8c5f019ec2aa47" dependencies = [ - "blake2b-rs 0.1.5", + "blake2b-rs", "faster-hex 0.6.1", "includedir", "includedir_codegen", @@ -823,50 +790,81 @@ dependencies = [ [[package]] name = "ckb-traits" -version = "0.100.0" +version = "0.111.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be8d2bd9726a157aa5ce296e3c50099ed004f85dbf51608a8c8ceba4b86a1ee4" +checksum = "ca049aba2cb2d1208c6044accb497b17290ad56de629f6a4b95eded67a43fd40" dependencies = [ "ckb-types", ] [[package]] name = "ckb-types" -version = "0.100.0" +version = "0.111.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "048653106f001c8e0c4d26853d187fd9216d18ee64318dc7a0cda8676f95a31f" +checksum = "b6ec737e4957418bbd0f4091e8565a89bbd8f6fc37a20360820e44d1f1e44e58" dependencies = [ "bit-vec", - "bitflags", "bytes 1.1.0", "ckb-channel", + "ckb-constant", "ckb-error", - "ckb-fixed-hash 0.100.0", + "ckb-fixed-hash 0.111.0", + "ckb-gen-types", "ckb-hash", + "ckb-merkle-mountain-range", "ckb-occupied-capacity", "ckb-rational", "derive_more", + "golomb-coded-set", "merkle-cbt", "molecule", "numext-fixed-uint", "once_cell", + "paste", +] + +[[package]] +name = "ckb-util" +version = "0.111.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "011b907b18aa706fc224a1309f14eadd9cc14c42cf2258ca3010d1324bc20f10" +dependencies = [ + "linked-hash-map", + "once_cell", + "parking_lot 0.12.1", + "regex", +] + +[[package]] +name = "ckb-vm" +version = "0.24.1-l2" +source = "git+https://github.com/nervosnetwork/ckb-vm.git?branch=release-0.24-l2#3e3ebb67bed5411b6514c096da9475779f3393ce" +dependencies = [ + "byteorder", + "bytes 1.1.0", + "cc", + "ckb-vm-definitions 0.24.1-l2", + "derive_more", + "goblin 0.2.3", + "goblin 0.4.0", + "rand 0.7.3", + "scroll", + "serde", ] [[package]] name = "ckb-vm" -version = "0.20.0-rc5" +version = "0.24.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60dcf786d3e6424be300a84b65a35bafc8344de5350fa96500ed9f6cc370865f" +checksum = "0cc004a826b9bc9319ffae0b8415690e1b5f1482266d55fbd43843aa40ddcd63" dependencies = [ "byteorder", "bytes 1.1.0", "cc", - "ckb-vm-definitions", + "ckb-vm-definitions 0.24.6", "derive_more", "goblin 0.2.3", "goblin 0.4.0", - "libc", - "mapr", "rand 0.7.3", "scroll", "serde", @@ -874,9 +872,17 @@ dependencies = [ [[package]] name = "ckb-vm-definitions" -version = "0.20.0-rc5" +version = "0.24.1-l2" +source = "git+https://github.com/nervosnetwork/ckb-vm.git?branch=release-0.24-l2#3e3ebb67bed5411b6514c096da9475779f3393ce" + +[[package]] +name = "ckb-vm-definitions" +version = "0.24.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "deb44cd2753aaeb2dc8a3df7b293ddfc3cbaaf8232d819650c0fc365cacda34f" +checksum = "c4ced3ff9d79b53d93c106720f6c1f855694290e33581850e05c859500eee83f" +dependencies = [ + "paste", +] [[package]] name = "clang-sys" @@ -1083,13 +1089,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" [[package]] -name = "crypto-mac" -version = "0.7.0" +name = "crypto-common" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4434400df11d95d556bac068ddfedd482915eb18fe8bea89bc80b6e4b1c179e5" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" dependencies = [ - "generic-array 0.12.4", - "subtle 1.0.0", + "generic-array 0.14.5", + "typenum", ] [[package]] @@ -1099,7 +1105,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b1d1a86f49236c215f271d40892d5fc950490551400b02ef360692c29815c714" dependencies = [ "generic-array 0.14.5", - "subtle 2.4.1", + "subtle", ] [[package]] @@ -1124,21 +1130,25 @@ dependencies = [ "memchr", ] -[[package]] -name = "ctr" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb4a30d54f7443bf3d6191dcd486aca19e67cb3c49fa7a06a319966346707e7f" -dependencies = [ - "cipher", -] - [[package]] name = "cty" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b365fabc795046672053e29c954733ec3b05e4be654ab130fe8f1f94d7051f35" +[[package]] +name = "dashmap" +version = "5.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6943ae99c34386c84a470c499d3414f66502a41340aa895406e0d2e4a207b91d" +dependencies = [ + "cfg-if 1.0.0", + "hashbrown 0.14.0", + "lock_api", + "once_cell", + "parking_lot_core 0.9.8", +] + [[package]] name = "debugid" version = "0.7.2" @@ -1146,7 +1156,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f91cf5a8c2f2097e2a32627123508635d47ce10563d999ec1a95addf08b502ba" dependencies = [ "serde", - "uuid 0.8.2", + "uuid", +] + +[[package]] +name = "derive-getters" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0122f262bf9c9a367829da84f808d9fb128c10ef283bbe7b0922a77cf07b2747" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.86", ] [[package]] @@ -1159,7 +1180,7 @@ dependencies = [ "proc-macro2", "quote", "rustc_version", - "syn", + "syn 1.0.86", ] [[package]] @@ -1180,6 +1201,16 @@ dependencies = [ "generic-array 0.14.5", ] +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer 0.10.4", + "crypto-common", +] + [[package]] name = "dirs" version = "4.0.0" @@ -1206,6 +1237,12 @@ version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77c90badedccf4105eca100756a0b1289e191f6fcbdadd3cee1d2f614f97da8f" +[[package]] +name = "dyn-clone" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68b0cf012f1230e43cd00ebb729c6bb58707ecfa8ad08b52ef3a4ccd2697fc30" + [[package]] name = "eaglesong" version = "0.1.0" @@ -1227,6 +1264,18 @@ dependencies = [ "cfg-if 1.0.0", ] +[[package]] +name = "enum-repr-derive" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6f2936062c28214e84685742fa4affc52a39d036e8a3dcf98034810e449ec95" +dependencies = [ + "proc-macro-error", + "proc-macro2", + "quote", + "syn 1.0.86", +] + [[package]] name = "env_logger" version = "0.8.4" @@ -1281,7 +1330,7 @@ dependencies = [ "hex", "serde", "serde_json", - "sha3", + "sha3 0.9.1", "thiserror", "uint", ] @@ -1296,7 +1345,7 @@ dependencies = [ "fixed-hash", "impl-rlp", "impl-serde", - "tiny-keccak 2.0.2", + "tiny-keccak", ] [[package]] @@ -1346,7 +1395,7 @@ checksum = "aa4da3c766cd7a0db8242e326e9e4e081edd567072893ed320008189715366a4" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.86", "synstructure", ] @@ -1541,7 +1590,7 @@ checksum = "62007592ac46aa7c2b6416f7deb9a8a8f63a01e0f1d6e1787d5630170db2b63e" dependencies = [ "futures-core", "lock_api", - "parking_lot", + "parking_lot 0.11.2", ] [[package]] @@ -1558,7 +1607,7 @@ checksum = "6dbd947adfffb0efc70599b3ddcf7b5597bb5fa9e245eb99f62b3a5f7bb8bd3c" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.86", ] [[package]] @@ -1694,6 +1743,15 @@ dependencies = [ "scroll", ] +[[package]] +name = "golomb-coded-set" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c7076c0cd6257d84b785b0f22c36443dd47a5e86a1256d7ef82c8cb88ea9a7e" +dependencies = [ + "siphasher", +] + [[package]] name = "gw-benches" version = "0.1.0" @@ -1719,14 +1777,13 @@ dependencies = [ "async-jsonrpc-client", "async-trait", "ckb-chain-spec", - "ckb-crypto 0.100.0", - "ckb-fixed-hash 0.100.0", + "ckb-crypto 0.111.0", + "ckb-fixed-hash 0.111.0", "ckb-types", "clap", "futures", "gw-chain", "gw-challenge", - "gw-ckb-hardfork", "gw-common", "gw-config", "gw-db", @@ -1769,7 +1826,7 @@ name = "gw-chain" version = "0.1.0" dependencies = [ "anyhow", - "ckb-fixed-hash 0.100.0", + "ckb-fixed-hash 0.111.0", "crossbeam-channel", "gw-challenge", "gw-common", @@ -1796,11 +1853,10 @@ dependencies = [ "anyhow", "arc-swap", "ckb-chain-spec", - "ckb-fixed-hash 0.100.0", + "ckb-fixed-hash 0.111.0", "ckb-script", "ckb-traits", "ckb-types", - "gw-ckb-hardfork", "gw-common", "gw-config", "gw-db", @@ -1821,16 +1877,6 @@ dependencies = [ "tokio", ] -[[package]] -name = "gw-ckb-hardfork" -version = "0.1.0" -dependencies = [ - "arc-swap", - "ckb-types", - "lazy_static", - "tokio", -] - [[package]] name = "gw-common" version = "0.1.0" @@ -1838,7 +1884,7 @@ dependencies = [ "cfg-if 0.1.10", "gw-hash", "merkle-cbt", - "sparse-merkle-tree", + "sparse-merkle-tree 0.5.3", "thiserror", ] @@ -1846,7 +1892,7 @@ dependencies = [ name = "gw-config" version = "0.1.0" dependencies = [ - "ckb-fixed-hash 0.100.0", + "ckb-fixed-hash 0.111.0", "gw-jsonrpc-types", "reqwest", "serde", @@ -1872,7 +1918,7 @@ version = "0.1.0" dependencies = [ "anyhow", "arc-swap", - "ckb-fixed-hash 0.100.0", + "ckb-fixed-hash 0.111.0", "gw-config", "gw-jsonrpc-types", "gw-tx-filter", @@ -1887,9 +1933,8 @@ version = "0.2.0" dependencies = [ "anyhow", "arc-swap", - "blake2b-rs 0.2.0", - "ckb-vm", - "gw-ckb-hardfork", + "blake2b-rs", + "ckb-vm 0.24.1-l2", "gw-common", "gw-config", "gw-dynamic-config", @@ -1903,7 +1948,7 @@ dependencies = [ "log", "rlp", "secp256k1 0.20.3", - "sha3", + "sha3 0.9.1", "thiserror", "tokio", "tracing", @@ -1921,7 +1966,7 @@ name = "gw-jsonrpc-types" version = "0.1.0" dependencies = [ "anyhow", - "ckb-fixed-hash 0.100.0", + "ckb-fixed-hash 0.111.0", "ckb-jsonrpc-types", "faster-hex 0.4.1", "gw-common", @@ -1978,7 +2023,7 @@ version = "0.1.0" dependencies = [ "anyhow", "async-jsonrpc-client", - "ckb-fixed-hash 0.100.0", + "ckb-fixed-hash 0.111.0", "ckb-types", "clap", "crossbeam-channel", @@ -2012,8 +2057,8 @@ dependencies = [ "async-channel", "async-jsonrpc-client", "async-trait", - "ckb-crypto 0.100.0", - "ckb-fixed-hash 0.100.0", + "ckb-crypto 0.111.0", + "ckb-fixed-hash 0.111.0", "ckb-types", "env_logger", "faster-hex 0.4.1", @@ -2044,8 +2089,8 @@ dependencies = [ "async-jsonrpc-client", "async-trait", "bytes 1.1.0", - "ckb-crypto 0.100.0", - "ckb-fixed-hash 0.100.0", + "ckb-crypto 0.111.0", + "ckb-fixed-hash 0.111.0", "ckb-types", "clap", "env_logger", @@ -2129,21 +2174,19 @@ dependencies = [ "anyhow", "async-jsonrpc-client", "async-trait", - "blake2b-rs 0.2.0", + "blake2b-rs", "ckb-chain-spec", - "ckb-crypto 0.100.0", + "ckb-crypto 0.111.0", "ckb-error", - "ckb-fixed-hash 0.100.0", + "ckb-fixed-hash 0.111.0", "ckb-hash", "ckb-script", "ckb-traits", "ckb-types", - "ckb-vm", - "ckb-vm-definitions", + "ckb-vm 0.24.1-l2", "env_logger", "gw-block-producer", "gw-chain", - "gw-ckb-hardfork", "gw-common", "gw-config", "gw-db", @@ -2162,7 +2205,7 @@ dependencies = [ "secp256k1 0.20.3", "serde", "serde_json", - "sha3", + "sha3 0.9.1", "tempfile", "thiserror", "tokio", @@ -2174,9 +2217,9 @@ version = "0.1.0" dependencies = [ "anyhow", "async-jsonrpc-client", - "bech32", - "ckb-crypto 0.100.0", - "ckb-fixed-hash 0.100.0", + "bech32 0.6.0", + "ckb-crypto 0.111.0", + "ckb-fixed-hash 0.111.0", "ckb-hash", "ckb-jsonrpc-types", "ckb-resource", @@ -2201,10 +2244,10 @@ dependencies = [ "log", "rand 0.8.4", "reqwest", - "secp256k1 0.19.0", + "secp256k1 0.24.3", "serde", "serde_json", - "sha3", + "sha3 0.9.1", "tempfile", "tokio", "toml", @@ -2238,11 +2281,11 @@ name = "gw-types" version = "0.1.0" dependencies = [ "cfg-if 0.1.10", - "ckb-fixed-hash 0.100.0", + "ckb-fixed-hash 0.111.0", "ckb-types", "gw-hash", "molecule", - "sparse-merkle-tree", + "sparse-merkle-tree 0.5.3", ] [[package]] @@ -2288,7 +2331,7 @@ dependencies = [ "num-bigint 0.4.3", "rlp", "rust_decimal", - "sha3", + "sha3 0.9.1", "sqlx", "thiserror", "tokio", @@ -2310,7 +2353,7 @@ dependencies = [ "indexmap", "slab", "tokio", - "tokio-util", + "tokio-util 0.6.9", "tracing", ] @@ -2329,13 +2372,19 @@ dependencies = [ "ahash", ] +[[package]] +name = "hashbrown" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" + [[package]] name = "hashlink" version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7249a3129cbc1ffccd74857f81464a323a152173cdb134e0fd81bc803b29facf" dependencies = [ - "hashbrown", + "hashbrown 0.11.2", ] [[package]] @@ -2371,23 +2420,13 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" -[[package]] -name = "hmac" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dcb5e64cda4c23119ab41ba960d1e170a774c8e4b9d9e6a9bc18aabf5e59695" -dependencies = [ - "crypto-mac 0.7.0", - "digest 0.8.1", -] - [[package]] name = "hmac" version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2a2a2320eb7ec0ebe8da8f744d7812d9fc4cb4d09344ac01898dbcb6a20ae69b" dependencies = [ - "crypto-mac 0.11.1", + "crypto-mac", "digest 0.9.0", ] @@ -2525,7 +2564,7 @@ checksum = "d5dacb10c5b3bb92d46ba347505a9041e676bb20ad220101326bffb0c93031ee" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.86", ] [[package]] @@ -2555,8 +2594,8 @@ version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282a6247722caba404c065016bbfa522806e51714c34f5dfc3e4a3a46fcb4223" dependencies = [ - "autocfg 1.0.1", - "hashbrown", + "autocfg 1.1.0", + "hashbrown 0.11.2", ] [[package]] @@ -2676,7 +2715,7 @@ dependencies = [ "proc-macro-crate 0.1.5", "proc-macro2", "quote", - "syn", + "syn 1.0.86", ] [[package]] @@ -2689,7 +2728,7 @@ dependencies = [ "jsonrpc-core 18.0.0", "lazy_static", "log", - "parking_lot", + "parking_lot 0.11.2", "rand 0.7.3", "serde", ] @@ -2708,7 +2747,7 @@ dependencies = [ "log", "tokio", "tokio-stream", - "tokio-util", + "tokio-util 0.6.9", "unicase", ] @@ -2750,7 +2789,7 @@ dependencies = [ "jsonrpc-server-utils", "log", "parity-ws", - "parking_lot", + "parking_lot 0.11.2", "slab", ] @@ -2784,9 +2823,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.113" +version = "0.2.147" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eef78b64d87775463c549fbd80e19249ef436ea3bf1de2a1eb7e717ec7fab1e9" +checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" [[package]] name = "libloading" @@ -2809,12 +2848,22 @@ dependencies = [ "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.5" +version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712a4d093c9976e24e7dbca41db895dabcbac38eb5f4045393d17a95bdfb1109" +checksum = "c1cc9717a20b1bb222f333e6a92fd32f7d8a18ddc5a3191a11af45dcbf4dcd16" dependencies = [ + "autocfg 1.1.0", "scopeguard", ] @@ -2833,17 +2882,7 @@ version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "274353858935c992b13c0ca408752e2121da852d07dec7ce5f108c77dfa14d1f" dependencies = [ - "hashbrown", -] - -[[package]] -name = "mapr" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46a28a55dbc005b2f6f123c4058933d57add373d362f6fd3a76aab4fe6973500" -dependencies = [ - "libc", - "winapi 0.3.9", + "hashbrown 0.11.2", ] [[package]] @@ -2900,7 +2939,7 @@ version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" dependencies = [ - "autocfg 1.0.1", + "autocfg 1.1.0", ] [[package]] @@ -2931,7 +2970,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a92518e98c078586bc6c934028adcca4c92a53d6a958196de835170a01d84e4b" dependencies = [ "adler", - "autocfg 1.0.1", + "autocfg 1.1.0", ] [[package]] @@ -2947,7 +2986,7 @@ dependencies = [ "kernel32-sys", "libc", "log", - "miow 0.2.2", + "miow", "net2", "slab", "winapi 0.2.8", @@ -2955,15 +2994,13 @@ dependencies = [ [[package]] name = "mio" -version = "0.7.14" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8067b404fe97c70829f082dec8bcf4f71225d7eaea1d8645349cb76fa06205cc" +checksum = "927a765cd3fc26206e66b296465fa9d3e5ab003e651c1b3c060e7956d96b19d2" dependencies = [ "libc", - "log", - "miow 0.3.7", - "ntapi", - "winapi 0.3.9", + "wasi 0.11.0+wasi-snapshot-preview1", + "windows-sys", ] [[package]] @@ -2990,20 +3027,11 @@ dependencies = [ "ws2_32-sys", ] -[[package]] -name = "miow" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9f1c5b025cda876f66ef43a113f91ebc9f4ccef34843000e0adf6ebbab84e21" -dependencies = [ - "winapi 0.3.9", -] - [[package]] name = "molecule" -version = "0.7.2" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be5f63176422224eadd975789462a96cedaf339cd1009ef92fbdfaad39d35f5f" +checksum = "d4fd9767ab5e5f2ea40f71ff4c8bdb633c50509052e093c2fdd0e390a749dfa3" dependencies = [ "bytes 1.1.0", "cfg-if 1.0.0", @@ -3075,22 +3103,13 @@ dependencies = [ "version_check", ] -[[package]] -name = "ntapi" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f6bb902e437b6d86e03cce10a7e2af662292c5dfef23b65899ea3ac9354ad44" -dependencies = [ - "winapi 0.3.9", -] - [[package]] name = "num-bigint" version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f6f7833f2cbf2360a6cfd58cd41a53aa7a90bd4c202f5b1c7dd2ed73c57b2c3" dependencies = [ - "autocfg 1.0.1", + "autocfg 1.1.0", "num-integer", "num-traits", ] @@ -3101,7 +3120,7 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f93ab6289c7b344a8a9f60f88d80aa20032336fe78da341afc91c8a2341fc75f" dependencies = [ - "autocfg 1.0.1", + "autocfg 1.1.0", "num-integer", "num-traits", ] @@ -3122,7 +3141,7 @@ version = "0.1.44" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db" dependencies = [ - "autocfg 1.0.1", + "autocfg 1.1.0", "num-traits", ] @@ -3132,7 +3151,7 @@ version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" dependencies = [ - "autocfg 1.0.1", + "autocfg 1.1.0", ] [[package]] @@ -3163,7 +3182,7 @@ dependencies = [ "proc-macro-crate 1.1.0", "proc-macro2", "quote", - "syn", + "syn 1.0.86", ] [[package]] @@ -3174,7 +3193,7 @@ checksum = "621fe0f044729f810c6815cdd77e8f5e0cd803ce4f6a38380ebfc1322af98661" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.86", ] [[package]] @@ -3209,7 +3228,7 @@ dependencies = [ "numext-fixed-uint-core", "proc-macro2", "quote", - "syn", + "syn 1.0.86", ] [[package]] @@ -3220,9 +3239,9 @@ checksum = "a9a7ab5d64814df0fe4a4b5ead45ed6c5f181ee3ff04ba344313a6c80446c5d4" [[package]] name = "once_cell" -version = "1.9.0" +version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da32515d9f6e6e489d7bc9d84c71b060db7247dc035bbe44eac88cf87486d8d5" +checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" [[package]] name = "oorandom" @@ -3268,7 +3287,7 @@ version = "0.9.72" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7e46109c383602735fa0a2e48dd2b7c892b048e1bf69e5c3b1d804b7d9c203cb" dependencies = [ - "autocfg 1.0.1", + "autocfg 1.1.0", "cc", "libc", "pkg-config", @@ -3350,7 +3369,7 @@ dependencies = [ "proc-macro-crate 1.1.0", "proc-macro2", "quote", - "syn", + "syn 1.0.86", ] [[package]] @@ -3379,7 +3398,17 @@ checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" dependencies = [ "instant", "lock_api", - "parking_lot_core", + "parking_lot_core 0.8.5", +] + +[[package]] +name = "parking_lot" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +dependencies = [ + "lock_api", + "parking_lot_core 0.9.8", ] [[package]] @@ -3391,26 +3420,29 @@ dependencies = [ "cfg-if 1.0.0", "instant", "libc", - "redox_syscall", + "redox_syscall 0.2.10", "smallvec", "winapi 0.3.9", ] [[package]] -name = "paste" -version = "1.0.6" +name = "parking_lot_core" +version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0744126afe1a6dd7f394cb50a716dbe086cb06e255e53d8d0185d82828358fb5" +checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447" +dependencies = [ + "cfg-if 1.0.0", + "libc", + "redox_syscall 0.3.5", + "smallvec", + "windows-targets", +] [[package]] -name = "pbkdf2" -version = "0.3.0" +name = "paste" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "006c038a43a45995a9670da19e67600114740e8511d4333bf97a56e66a7542d9" -dependencies = [ - "byteorder", - "crypto-mac 0.7.0", -] +checksum = "0744126afe1a6dd7f394cb50a716dbe086cb06e255e53d8d0185d82828358fb5" [[package]] name = "peeking_take_while" @@ -3489,7 +3521,7 @@ checksum = "744b6f092ba29c3650faf274db506afd39944f48420f6c86b17cfe0ee1cb36bb" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.86", ] [[package]] @@ -3557,7 +3589,7 @@ dependencies = [ "libc", "log", "nix", - "parking_lot", + "parking_lot 0.11.2", "prost", "prost-build", "prost-derive", @@ -3604,13 +3636,37 @@ dependencies = [ "toml", ] +[[package]] +name = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" +dependencies = [ + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn 1.0.86", + "version_check", +] + +[[package]] +name = "proc-macro-error-attr" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +dependencies = [ + "proc-macro2", + "quote", + "version_check", +] + [[package]] name = "proc-macro2" -version = "1.0.36" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7342d5883fbccae1cc37a2353b09c87c9b0f3afd73f5fb9bba687a1f733b029" +checksum = "78803b62cbf1f46fde80d7c0e803111524b9877184cfe7c3033659490ac7a7da" dependencies = [ - "unicode-xid", + "unicode-ident", ] [[package]] @@ -3653,7 +3709,7 @@ dependencies = [ "itertools", "proc-macro2", "quote", - "syn", + "syn 1.0.86", ] [[package]] @@ -3677,9 +3733,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.15" +version = "1.0.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "864d3e96a899863136fc6e99f3d7cae289dafe43bf2c5ac19b70df7210c0a145" +checksum = "573015e8ab27661678357f27dc26460738fd2b6c86e46f386fde94cb5d913105" dependencies = [ "proc-macro2", ] @@ -3690,19 +3746,6 @@ version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "643f8f41a8ebc4c5dc4515c82bb8abd397b527fc20fd681b7c011c2aee5d44fb" -[[package]] -name = "rand" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c618c47cd3ebd209790115ab837de41425723956ad3ce2e6a7f09890947cacb9" -dependencies = [ - "cloudabi", - "fuchsia-cprng", - "libc", - "rand_core 0.3.1", - "winapi 0.3.9", -] - [[package]] name = "rand" version = "0.6.5" @@ -3906,7 +3949,7 @@ version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c06aca804d41dbc8ba42dfd964f0d01334eceb64314b9ecf7c5fad5188a06d90" dependencies = [ - "autocfg 1.0.1", + "autocfg 1.1.0", "crossbeam-deque", "either", "rayon-core", @@ -3970,6 +4013,15 @@ dependencies = [ "bitflags", ] +[[package]] +name = "redox_syscall" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" +dependencies = [ + "bitflags", +] + [[package]] name = "redox_users" version = "0.4.0" @@ -3977,7 +4029,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "528532f3d801c87aec9def2add9ca802fe569e44a544afe633765267840abe64" dependencies = [ "getrandom 0.2.4", - "redox_syscall", + "redox_syscall 0.2.10", ] [[package]] @@ -4021,7 +4073,7 @@ version = "0.11.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "87f242f1488a539a79bac6dbe7c8609ae43b7914b7736210f239a37cccb32525" dependencies = [ - "base64 0.13.0", + "base64", "bytes 1.1.0", "encoding_rs", "futures-core", @@ -4114,12 +4166,6 @@ version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73b4b750c782965c211b42f022f59af1fbceabdd026623714f104152f1ec149f" -[[package]] -name = "safemem" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef703b7cb59335eae2eb93ceb664c0eb7ea6bf567079d843e09420219668e072" - [[package]] name = "same-file" version = "1.0.6" @@ -4162,23 +4208,7 @@ checksum = "aaaae8f38bb311444cfb7f1979af0bc9240d95795f75f9ceddf6a59b79ceffa0" dependencies = [ "proc-macro2", "quote", - "syn", -] - -[[package]] -name = "scrypt" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "656c79d0e90d0ab28ac86bf3c3d10bfbbac91450d3f190113b4e76d9fec3cfdd" -dependencies = [ - "base64 0.9.3", - "byte-tools", - "byteorder", - "hmac 0.7.1", - "pbkdf2", - "rand 0.5.6", - "sha2 0.8.2", - "subtle 1.0.0", + "syn 1.0.86", ] [[package]] @@ -4192,20 +4222,20 @@ dependencies = [ [[package]] name = "secp256k1" -version = "0.19.0" +version = "0.20.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6179428c22c73ac0fbb7b5579a56353ce78ba29759b3b8575183336ea74cdfb" +checksum = "97d03ceae636d0fed5bae6a7f4f664354c5f4fcedf6eef053fef17e49f837d0a" dependencies = [ - "secp256k1-sys 0.3.0", + "secp256k1-sys 0.4.2", ] [[package]] name = "secp256k1" -version = "0.20.3" +version = "0.24.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97d03ceae636d0fed5bae6a7f4f664354c5f4fcedf6eef053fef17e49f837d0a" +checksum = "6b1629c9c557ef9b293568b338dddfc8208c98a18c59d722a9d53f859d9c9b62" dependencies = [ - "secp256k1-sys 0.4.2", + "secp256k1-sys 0.6.1", ] [[package]] @@ -4219,18 +4249,18 @@ dependencies = [ [[package]] name = "secp256k1-sys" -version = "0.3.0" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11553d210db090930f4432bea123b31f70bbf693ace14504ea2a35e796c28dd2" +checksum = "957da2573cde917463ece3570eab4a0b3f19de6f1646cde62e6fd3868f566036" dependencies = [ "cc", ] [[package]] name = "secp256k1-sys" -version = "0.4.2" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "957da2573cde917463ece3570eab4a0b3f19de6f1646cde62e6fd3868f566036" +checksum = "83080e2c2fc1006e625be82e5d1eb6a43b7fd9578b617fcc55814daf286bba4b" dependencies = [ "cc", ] @@ -4346,7 +4376,7 @@ dependencies = [ "serde_json", "thiserror", "url", - "uuid 0.8.2", + "uuid", ] [[package]] @@ -4376,7 +4406,7 @@ checksum = "8dcde03d87d4c973c04be249e7d8f0b35db1c848c487bd43032808e59dd8328d" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.86", ] [[package]] @@ -4436,18 +4466,6 @@ dependencies = [ "opaque-debug 0.3.0", ] -[[package]] -name = "sha2" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a256f46ea78a0c0d9ff00077504903ac881a1dafdc20da66545699e7776b3e69" -dependencies = [ - "block-buffer 0.7.3", - "digest 0.8.1", - "fake-simd", - "opaque-debug 0.2.3", -] - [[package]] name = "sha2" version = "0.9.9" @@ -4473,6 +4491,16 @@ dependencies = [ "opaque-debug 0.3.0", ] +[[package]] +name = "sha3" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bdf0c33fae925bdc080598b84bc15c55e7b9a4a43b3c704da051f977469691c9" +dependencies = [ + "digest 0.10.7", + "keccak", +] + [[package]] name = "sharded-slab" version = "0.1.4" @@ -4517,9 +4545,9 @@ checksum = "f2dd574626839106c320a323308629dcb1acfc96e32a8cba364ddc61ac23ee83" [[package]] name = "socket2" -version = "0.4.3" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f82496b90c36d70af5fcd482edaa2e0bd16fade569de1330405fecbbdac736b" +checksum = "64a4a911eed85daf18834cfaa86a79b7d266ff93ff5ba14005426219480ed662" dependencies = [ "libc", "winapi 0.3.9", @@ -4534,6 +4562,17 @@ dependencies = [ "cfg-if 0.1.10", ] +[[package]] +name = "sparse-merkle-tree" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8851f6c92491ebe5528eabc1244292175a739eb0162974f9f9670a7dc748748b" +dependencies = [ + "blake2b-rs", + "cc", + "cfg-if 0.1.10", +] + [[package]] name = "spin" version = "0.9.2" @@ -4572,7 +4611,7 @@ checksum = "518be6f6fff5ca76f985d434f9c37f3662af279642acf730388f271dff7b9016" dependencies = [ "ahash", "atoi", - "base64 0.13.0", + "base64", "bitflags", "byteorder", "bytes 1.1.0", @@ -4591,7 +4630,7 @@ dependencies = [ "futures-util", "hashlink", "hex", - "hmac 0.11.0", + "hmac", "indexmap", "itoa 1.0.1", "libc", @@ -4601,14 +4640,14 @@ dependencies = [ "memchr", "num-bigint 0.3.3", "once_cell", - "parking_lot", + "parking_lot 0.11.2", "percent-encoding", "rand 0.8.4", "rust_decimal", "serde", "serde_json", "sha-1 0.9.8", - "sha2 0.9.9", + "sha2", "smallvec", "sqlformat", "sqlx-rt", @@ -4631,10 +4670,10 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "sha2 0.9.9", + "sha2", "sqlx-core", "sqlx-rt", - "syn", + "syn 1.0.86", "url", ] @@ -4684,12 +4723,6 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" -[[package]] -name = "subtle" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d67a5a62ba6e01cb2192ff309324cb4875d0c451d55fe2319433abe7a05a8ee" - [[package]] name = "subtle" version = "2.4.1" @@ -4705,7 +4738,7 @@ dependencies = [ "debugid", "memmap", "stable_deref_trait", - "uuid 0.8.2", + "uuid", ] [[package]] @@ -4730,6 +4763,17 @@ dependencies = [ "unicode-xid", ] +[[package]] +name = "syn" +version = "2.0.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15e3fc8c0c74267e2df136e5e5fb656a464158aa57624053375eb9c8c6e25ae2" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + [[package]] name = "synstructure" version = "0.12.6" @@ -4738,7 +4782,7 @@ checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.86", "unicode-xid", ] @@ -4757,7 +4801,7 @@ dependencies = [ "cfg-if 1.0.0", "fastrand", "libc", - "redox_syscall", + "redox_syscall 0.2.10", "remove_dir_all", "winapi 0.3.9", ] @@ -4797,7 +4841,7 @@ checksum = "aa32fd3f627f367fe16f893e2597ae3c05020f8bba2666a4e6ea73d377e5714b" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.86", ] [[package]] @@ -4863,25 +4907,6 @@ dependencies = [ "tikv-jemalloc-sys", ] -[[package]] -name = "time" -version = "0.1.43" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca8a50ef2360fbd1eeb0ecd46795a87a19024eb4b53c5dc916ca1fd95fe62438" -dependencies = [ - "libc", - "winapi 0.3.9", -] - -[[package]] -name = "tiny-keccak" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d8a021c69bb74a44ccedb824a046447e2c84a01df9e5c20779750acb38e11b2" -dependencies = [ - "crunchy", -] - [[package]] name = "tiny-keccak" version = "2.0.2" @@ -4918,32 +4943,32 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" [[package]] name = "tokio" -version = "1.15.0" +version = "1.28.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbbf1c778ec206785635ce8ad57fe52b3009ae9e0c9f574a728f3049d3e55838" +checksum = "94d7b1cfd2aa4011f2de74c2c4c63665e27a71006b0a192dcd2710272e73dfa2" dependencies = [ + "autocfg 1.1.0", "bytes 1.1.0", "libc", - "memchr", - "mio 0.7.14", + "mio 0.8.8", "num_cpus", - "once_cell", - "parking_lot", + "parking_lot 0.12.1", "pin-project-lite", "signal-hook-registry", + "socket2", "tokio-macros", - "winapi 0.3.9", + "windows-sys", ] [[package]] name = "tokio-macros" -version = "1.7.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b557f72f448c511a979e2564e55d74e6c4432fc96ff4f6241bc6bded342643b7" +checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.25", ] [[package]] @@ -4981,6 +5006,20 @@ dependencies = [ "tokio", ] +[[package]] +name = "tokio-util" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "806fe8c2c87eccc8b3267cbae29ed3ab2d0bd37fca70ab622e46aaa9375ddb7d" +dependencies = [ + "bytes 1.1.0", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", + "tracing", +] + [[package]] name = "toml" version = "0.5.8" @@ -5016,7 +5055,7 @@ checksum = "f4f480b8f81512e825f337ad51e94c1eb5d3bbdf2b363dcd01e2b19a9ffe3f8e" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.86", ] [[package]] @@ -5061,7 +5100,7 @@ dependencies = [ "ansi_term", "lazy_static", "matchers", - "parking_lot", + "parking_lot 0.11.2", "regex", "sharded-slab", "smallvec", @@ -5119,6 +5158,12 @@ version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1a01404663e3db436ed2746d9fefef640d868edae3cceb81c3b8d5732fda678f" +[[package]] +name = "unicode-ident" +version = "1.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22049a19f4a68748a168c0fc439f9516686aa045927ff767eca0a85101fb6e73" + [[package]] name = "unicode-normalization" version = "0.1.19" @@ -5165,15 +5210,6 @@ dependencies = [ "serde", ] -[[package]] -name = "uuid" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90dbc611eb48397705a6b0f6e917da23ae517e4d127123d2cf7674206627d32a" -dependencies = [ - "rand 0.6.5", -] - [[package]] name = "uuid" version = "0.8.2" @@ -5235,6 +5271,12 @@ version = "0.10.2+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + [[package]] name = "wasm-bindgen" version = "0.2.79" @@ -5256,7 +5298,7 @@ dependencies = [ "log", "proc-macro2", "quote", - "syn", + "syn 1.0.86", "wasm-bindgen-shared", ] @@ -5290,7 +5332,7 @@ checksum = "bfa8a30d46208db204854cadbb5d4baf5fcf8071ba5bf48190c3e59937962ebc" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.86", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -5375,6 +5417,72 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.48.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05d4b17490f70499f20b9e791dcf6a299785ce8af4d709018206dc5b4953e95f" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" + +[[package]] +name = "windows_i686_gnu" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" + +[[package]] +name = "windows_i686_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" + [[package]] name = "winreg" version = "0.7.0" diff --git a/Cargo.toml b/Cargo.toml index 057ea791f..cb4890ce0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,7 +22,6 @@ members = [ "crates/benches", "crates/version", "crates/utils", - "crates/ckb-hardfork", "crates/tx-filter", "crates/replay-chain", "crates/dynamic-config", diff --git a/crates/block-producer/Cargo.toml b/crates/block-producer/Cargo.toml index 757146d7e..cef478546 100644 --- a/crates/block-producer/Cargo.toml +++ b/crates/block-producer/Cargo.toml @@ -29,12 +29,11 @@ gw-web3-indexer = { path = "../web3-indexer" } gw-poa = { path = "../poa" } gw-utils = { path = "../utils" } gw-version = { path = "../version" } -gw-ckb-hardfork = { path = "../ckb-hardfork" } gw-dynamic-config = { path = "../dynamic-config"} -ckb-crypto = "0.100.0" -ckb-fixed-hash = "0.100.0" -ckb-types = "0.100.0" -ckb-chain-spec = "0.100.0" +ckb-crypto = "0.111.0" +ckb-fixed-hash = "0.111.0" +ckb-types = "0.111.0" +ckb-chain-spec = "0.111.0" toml = "0.5" anyhow = "1.0" serde = { version = "1.0", features = ["derive"] } diff --git a/crates/block-producer/src/block_producer.rs b/crates/block-producer/src/block_producer.rs index 327575b99..471ac211d 100644 --- a/crates/block-producer/src/block_producer.rs +++ b/crates/block-producer/src/block_producer.rs @@ -804,8 +804,10 @@ impl BlockProducer { let dep_cell_by_data: HashMap<[u8; 32], OutPoint> = dep_cells .iter() .map(|cell| { - let data_hash = - ckb_types::packed::CellOutput::calc_data_hash(&cell.data).unpack(); + let data_hash: [u8; 32] = + ckb_types::packed::CellOutput::calc_data_hash(&cell.data) + .unpack() + .into(); (data_hash, cell.out_point.clone()) }) .collect(); @@ -902,7 +904,6 @@ impl BlockProducer { if input_len != witness_len { // append dummy witness args to align our reverted deposit witness args let dummy_witness_argses = (0..input_len - witness_len) - .into_iter() .map(|_| WitnessArgs::default()) .collect::>(); tx_skeleton.witnesses_mut().extend(dummy_witness_argses); @@ -930,7 +931,6 @@ impl BlockProducer { if input_len != witness_len { // append dummy witness args to align our reverted withdrawal witness args let dummy_witness_argses = (0..input_len - witness_len) - .into_iter() .map(|_| WitnessArgs::default()) .collect::>(); tx_skeleton.witnesses_mut().extend(dummy_witness_argses); diff --git a/crates/block-producer/src/challenger.rs b/crates/block-producer/src/challenger.rs index 0dd99b5d7..64084cf4a 100644 --- a/crates/block-producer/src/challenger.rs +++ b/crates/block-producer/src/challenger.rs @@ -25,9 +25,7 @@ use gw_rpc_client::contract::ContractsCellDepManager; use gw_rpc_client::rpc_client::RPCClient; use gw_types::bytes::Bytes; use gw_types::core::{ChallengeTargetType, Status}; -use gw_types::offchain::{ - global_state_from_slice, CellInfo, InputCellInfo, RollupContext, TxStatus, -}; +use gw_types::offchain::{global_state_from_slice, CellInfo, InputCellInfo, RollupContext}; use gw_types::packed::{ CellDep, CellInput, CellOutput, ChallengeLockArgs, ChallengeLockArgsReader, ChallengeTarget, GlobalState, OutPoint, Script, Transaction, WitnessArgs, @@ -407,7 +405,10 @@ impl Challenger { let challenge_tx_block_number = { let tx_hash: H256 = challenge_cell.out_point.tx_hash().unpack(); let tx_status = self.rpc_client.get_transaction_status(tx_hash).await?; - if !matches!(tx_status, Some(TxStatus::Committed)) { + if !matches!( + tx_status, + Some(gw_jsonrpc_types::ckb_jsonrpc_types::Status::Committed) + ) { log::debug!("challenge tx isn't committed"); return Ok(()); } @@ -604,7 +605,6 @@ impl Challenger { if input_len != witness_len { // append dummy witness args to align our reverted deposit witness args let dummy_witness_argses = (0..input_len - witness_len) - .into_iter() .map(|_| WitnessArgs::default()) .collect::>(); tx_skeleton.witnesses_mut().extend(dummy_witness_argses); @@ -677,14 +677,19 @@ impl Challenger { } async fn wait_tx_proposed(&self, tx_hash: H256) -> Result<()> { + use gw_jsonrpc_types::ckb_jsonrpc_types::Status; + let timeout = Duration::new(30, 0); let now = Instant::now(); loop { match self.rpc_client.get_transaction_status(tx_hash).await? { - Some(TxStatus::Proposed) | Some(TxStatus::Committed) => return Ok(()), - Some(TxStatus::Pending) => (), - None => return Err(anyhow!("tx hash {} not found", to_hex(&tx_hash))), + Some(Status::Proposed) | Some(Status::Committed) => return Ok(()), + Some(Status::Pending) => (), + Some(Status::Rejected) => bail!("tx hash {} rejected", to_hex(&tx_hash)), + Some(Status::Unknown) | None => { + return Err(anyhow!("tx hash {} not found", to_hex(&tx_hash))) + } } if now.elapsed() >= timeout { @@ -696,14 +701,19 @@ impl Challenger { } async fn wait_tx_committed(&self, tx_hash: H256) -> Result<()> { + use gw_jsonrpc_types::ckb_jsonrpc_types::Status; + let timeout = Duration::new(30, 0); let now = Instant::now(); loop { match self.rpc_client.get_transaction_status(tx_hash).await? { - Some(TxStatus::Committed) => return Ok(()), - Some(TxStatus::Proposed) | Some(TxStatus::Pending) => (), - None => return Err(anyhow!("tx hash {} not found", to_hex(&tx_hash))), + Some(Status::Committed) => return Ok(()), + Some(Status::Proposed) | Some(Status::Pending) => (), + Some(Status::Rejected) => bail!("tx {} rejected", to_hex(&tx_hash)), + Some(Status::Unknown) | None => { + return Err(anyhow!("tx hash {} not found", to_hex(&tx_hash))) + } } if now.elapsed() >= timeout { diff --git a/crates/block-producer/src/cleaner.rs b/crates/block-producer/src/cleaner.rs index 4569de2ca..33daf5a6e 100644 --- a/crates/block-producer/src/cleaner.rs +++ b/crates/block-producer/src/cleaner.rs @@ -9,7 +9,7 @@ use gw_challenge::cancel_challenge::RecoverAccountsContext; use gw_common::H256; use gw_rpc_client::rpc_client::RPCClient; use gw_types::core::Status; -use gw_types::offchain::{global_state_from_slice, CellInfo, InputCellInfo, TxStatus}; +use gw_types::offchain::{global_state_from_slice, CellInfo, InputCellInfo}; use gw_types::packed::{CellDep, CellInput, Transaction, WitnessArgs}; use gw_types::prelude::Unpack; @@ -104,7 +104,10 @@ impl Cleaner { let tip_l1_block_number = rpc_client.get_tip().await?.number().unpack(); for tx_hash in consumed_txs { let tx_status = rpc_client.get_transaction_status(tx_hash).await?; - if !matches!(tx_status, Some(TxStatus::Committed)) { + if !matches!( + tx_status, + Some(gw_jsonrpc_types::ckb_jsonrpc_types::Status::Committed) + ) { continue; } @@ -154,7 +157,10 @@ impl Cleaner { let verifier_status = rpc_client .get_transaction_status(verifier.tx_hash()) .await?; - if !matches!(verifier_status, Some(TxStatus::Committed)) { + if !matches!( + verifier_status, + Some(gw_jsonrpc_types::ckb_jsonrpc_types::Status::Committed) + ) { continue; } diff --git a/crates/block-producer/src/db_block_validator.rs b/crates/block-producer/src/db_block_validator.rs index f7fc3376a..52ffb2633 100644 --- a/crates/block-producer/src/db_block_validator.rs +++ b/crates/block-producer/src/db_block_validator.rs @@ -109,9 +109,7 @@ impl DBBlockCancelChallengeValidator { .into_par_iter() .try_for_each(|block_number| self.verify_block(block_number))?; } else { - (from_block..=to_block) - .into_iter() - .try_for_each(|block_number| self.verify_block(block_number))?; + (from_block..=to_block).try_for_each(|block_number| self.verify_block(block_number))?; } Ok(()) @@ -316,7 +314,7 @@ impl DBBlockCancelChallengeValidator { let dump = || -> Result<_> { let debug_config = &self.debug_config; let dir = debug_config.debug_tx_dump_path.as_path(); - create_dir_all(&dir)?; + create_dir_all(dir)?; let mut dump_path = PathBuf::new(); dump_path.push(dir); diff --git a/crates/block-producer/src/debugger.rs b/crates/block-producer/src/debugger.rs index 57d3923e9..09eacddbf 100644 --- a/crates/block-producer/src/debugger.rs +++ b/crates/block-producer/src/debugger.rs @@ -13,7 +13,6 @@ use gw_jsonrpc_types::{ use gw_rpc_client::rpc_client::RPCClient; use gw_types::{ core::DepType, - offchain::TxStatus, packed::{CellDep, OutPointVec, Transaction}, prelude::*, }; @@ -31,11 +30,10 @@ pub async fn dump_transaction>( let mut dump_path = PathBuf::new(); dump_path.push(dir); - let json_content; - match build_mock_transaction(rpc_client, tx).await { + let json_content = match build_mock_transaction(rpc_client, tx).await { Ok(mock_tx) => { dump_path.push(format!("{}-mock-tx.json", tx_hash)); - json_content = serde_json::to_string_pretty(&mock_tx)?; + serde_json::to_string_pretty(&mock_tx)? } Err(err) => { log::error!( @@ -47,9 +45,9 @@ pub async fn dump_transaction>( dump_path.push(format!("{}-raw-tx.json", tx_hash)); let json_tx: ckb_jsonrpc_types::Transaction = { ckb_types::packed::Transaction::new_unchecked(tx.as_bytes()).into() }; - json_content = serde_json::to_string_pretty(&json_tx)?; + serde_json::to_string_pretty(&json_tx)? } - } + }; log::info!("Dump transaction {} to {:?}", tx_hash, dump_path); write(dump_path, json_content)?; Ok(()) @@ -111,7 +109,7 @@ pub async fn build_mock_transaction( let input_tx_hash = input.previous_output().tx_hash().unpack(); let input_block_hash = match rpc_client.get_transaction_status(input_tx_hash).await? { - Some(TxStatus::Committed) => { + Some(ckb_jsonrpc_types::Status::Committed) => { let block_hash = rpc_client.get_transaction_block_hash(input_tx_hash).await?; Some(block_hash.ok_or_else(|| anyhow!("not found input cell tx hash"))?) } @@ -161,7 +159,7 @@ pub async fn build_mock_transaction( .ok_or_else(|| anyhow!("can't find dep cell"))?; let dep_cell_tx_hash = cell_dep.out_point().tx_hash().unpack(); let dep_cell_block_hash = match rpc_client.get_transaction_status(dep_cell_tx_hash).await? { - Some(TxStatus::Committed) => { + Some(ckb_jsonrpc_types::Status::Committed) => { let query = rpc_client .get_transaction_block_hash(dep_cell_tx_hash) .await?; diff --git a/crates/block-producer/src/main.rs b/crates/block-producer/src/main.rs index b8288efaa..4d1b86553 100644 --- a/crates/block-producer/src/main.rs +++ b/crates/block-producer/src/main.rs @@ -101,7 +101,7 @@ async fn run_cli() -> Result<()> { match matches.subcommand() { (COMMAND_RUN, Some(m)) => { let config_path = m.value_of(ARG_CONFIG).unwrap(); - let config = read_config(&config_path)?; + let config = read_config(config_path)?; let _guard = trace::init(config.trace)?; runner::run(config, m.is_present(ARG_SKIP_CONFIG_CHECK)).await?; } @@ -112,7 +112,7 @@ async fn run_cli() -> Result<()> { } (COMMAND_VERIFY_DB_BLOCK, Some(m)) => { let config_path = m.value_of(ARG_CONFIG).unwrap(); - let config = read_config(&config_path)?; + let config = read_config(config_path)?; let _guard = trace::init(None)?; let from_block: Option = m.value_of(ARG_FROM_BLOCK).map(str::parse).transpose()?; let to_block: Option = m.value_of(ARG_TO_BLOCK).map(str::parse).transpose()?; @@ -121,7 +121,7 @@ async fn run_cli() -> Result<()> { _ => { // default command: start a Godwoken node let config_path = "./config.toml"; - let config = read_config(&config_path)?; + let config = read_config(config_path)?; let _guard = trace::init(config.trace)?; runner::run(config, false).await?; } diff --git a/crates/block-producer/src/poller.rs b/crates/block-producer/src/poller.rs index f8b5fb1d3..351a9ad1b 100644 --- a/crates/block-producer/src/poller.rs +++ b/crates/block-producer/src/poller.rs @@ -1,14 +1,14 @@ #![allow(clippy::mutable_key_type)] use crate::types::ChainEvent; -use anyhow::{anyhow, Result}; +use anyhow::{anyhow, Context, Result}; use async_jsonrpc_client::Params as ClientParams; use ckb_fixed_hash::H256; use gw_chain::chain::{ Chain, ChallengeCell, L1Action, L1ActionContext, RevertL1ActionContext, RevertedL1Action, SyncParam, }; -use gw_jsonrpc_types::ckb_jsonrpc_types::{BlockNumber, HeaderView, TransactionWithStatus, Uint32}; +use gw_jsonrpc_types::ckb_jsonrpc_types::{BlockNumber, HeaderView, Status, Uint32}; use gw_rpc_client::{ indexer_types::{Order, Pagination, ScriptType, SearchKey, SearchKeyFilter, Tx}, rpc_client::RPCClient, @@ -17,7 +17,7 @@ use gw_store::traits::chain_store::ChainStore; use gw_types::{ bytes::Bytes, core::ScriptHashType, - offchain::{RollupContext, TxStatus}, + offchain::RollupContext, packed::{ CellInput, CellOutput, ChallengeLockArgs, ChallengeLockArgsReader, DepositLockArgs, DepositRequest, L2BlockCommittedInfo, OutPoint, RollupAction, RollupActionUnion, Script, @@ -217,18 +217,12 @@ impl ChainUpdater { } } - let tx: Option = self - .rpc_client - .ckb - .request( - "get_transaction", - Some(ClientParams::Array(vec![json!(tx_hash)])), - ) - .await?; - let tx_with_status = - tx.ok_or_else(|| QueryL1TxError::new(tx_hash, anyhow!("cannot locate tx")))?; + let tx_with_status = self.rpc_client.ckb.get_transaction(tx_hash).await?; + let tx = tx_with_status + .transaction + .ok_or_else(|| QueryL1TxError::new(tx_hash, anyhow!("cannot locate tx")))?; let tx = { - let tx: ckb_types::packed::Transaction = tx_with_status.transaction.inner.into(); + let tx: ckb_types::packed::Transaction = tx.inner.into(); Transaction::new_unchecked(tx.as_bytes()) }; let block_hash = tx_with_status.tx_status.block_hash.ok_or_else(|| { @@ -317,7 +311,7 @@ impl ChainUpdater { let tx_hash: gw_common::H256 = From::<[u8; 32]>::from(committed_info.transaction_hash().unpack()); let tx_status = rpc_client.get_transaction_status(tx_hash).await?; - if !matches!(tx_status, Some(TxStatus::Committed)) { + if !matches!(tx_status, Some(Status::Committed)) { return Ok(false); } @@ -415,7 +409,7 @@ impl ChainUpdater { fn extract_rollup_action(&self, tx: &Transaction) -> Result { let rollup_type_hash: [u8; 32] = { let hash = self.rollup_type_script.calc_script_hash(); - ckb_types::prelude::Unpack::unpack(&hash) + ckb_types::prelude::Unpack::unpack(&hash).into() }; // find rollup state cell from outputs @@ -505,20 +499,11 @@ impl ChainUpdater { // Load cell denoted by the transaction input let tx_hash: H256 = input.previous_output().tx_hash().unpack(); let index = input.previous_output().index().unpack(); - let tx: Option = self + let tx = self .rpc_client - .ckb - .request( - "get_transaction", - Some(ClientParams::Array(vec![json!(tx_hash)])), - ) - .await?; - let tx_with_status = - tx.ok_or_else(|| QueryL1TxError::new(&tx_hash, anyhow!("cannot locate tx")))?; - let tx = { - let tx: ckb_types::packed::Transaction = tx_with_status.transaction.inner.into(); - Transaction::new_unchecked(tx.as_bytes()) - }; + .get_transaction(tx_hash.0.into()) + .await? + .with_context(move || QueryL1TxError::new(&tx_hash, anyhow!("")))?; let cell_output = tx .raw() .outputs() diff --git a/crates/block-producer/src/runner.rs b/crates/block-producer/src/runner.rs index c3d3af4a5..40ec097a4 100644 --- a/crates/block-producer/src/runner.rs +++ b/crates/block-producer/src/runner.rs @@ -8,10 +8,8 @@ use crate::{ withdrawal_unlocker::FinalizedWithdrawalUnlocker, }; use anyhow::{anyhow, bail, Context, Result}; -use ckb_types::core::hardfork::HardForkSwitch; use gw_chain::chain::Chain; use gw_challenge::offchain::{OffChainMockContext, OffChainMockContextBuildArgs}; -use gw_ckb_hardfork::{GLOBAL_CURRENT_EPOCH_NUMBER, GLOBAL_HARDFORK_SWITCH, GLOBAL_VM_VERSION}; use gw_common::{blake2b::new_blake2b, H256}; use gw_config::{BlockProducerConfig, Config, NodeMode}; use gw_db::migrate::open_or_create_db; @@ -48,7 +46,7 @@ use gw_types::{ packed::{Byte32, CellDep, NumberHash, RollupConfig, Script}, prelude::*, }; -use gw_utils::{genesis_info::CKBGenesisInfo, since::EpochNumberWithFraction, wallet::Wallet}; +use gw_utils::{genesis_info::CKBGenesisInfo, wallet::Wallet}; use gw_web3_indexer::{ErrorReceiptIndexer, Web3Indexer}; use semver::Version; use sqlx::{ @@ -58,7 +56,7 @@ use sqlx::{ use std::{ collections::HashMap, net::{SocketAddr, ToSocketAddrs}, - sync::{atomic::Ordering, Arc}, + sync::Arc, time::{Duration, Instant}, }; use tokio::{ @@ -230,28 +228,6 @@ impl ChainTask { tip_number = new_block_number; tip_hash = block.header().hash().into(); - // update global hardfork info - let hardfork_switch = self.rpc_client.get_hardfork_switch().await?; - let rfc0032_epoch_number = hardfork_switch.rfc_0032(); - let global_hardfork_switch = GLOBAL_HARDFORK_SWITCH.load(); - if !is_hardfork_switch_eq(&*global_hardfork_switch, &hardfork_switch) { - GLOBAL_HARDFORK_SWITCH.store(Arc::new(hardfork_switch)); - } - - // when switching the epoch, update the tip epoch number and VM version - let tip_epoch = { - let tip_epoch: u64 = block.header().raw().epoch().unpack(); - EpochNumberWithFraction::from_full_value(tip_epoch) - }; - if tip_epoch.index() == 0 || tip_epoch.index() == tip_epoch.length() - 1 { - let vm_version: u32 = if tip_epoch.number() >= rfc0032_epoch_number { - 1 - } else { - 0 - }; - GLOBAL_CURRENT_EPOCH_NUMBER.store(tip_epoch.number(), Ordering::SeqCst); - GLOBAL_VM_VERSION.store(vm_version, Ordering::SeqCst); - } last_event_time = Instant::now(); } else { log::debug!( @@ -304,7 +280,7 @@ impl BaseInitComponents { }; let rollup_type_script: Script = config.chain.rollup_type_script.clone().into(); let rpc_client = { - let indexer_client = CKBIndexerClient::with_url(&config.rpc_client.indexer_url)?; + let indexer_client = CKBIndexerClient::with_url(&config.rpc_client.ckb_url)?; let ckb_client = CKBClient::with_url(&config.rpc_client.ckb_url)?; let rollup_type_script = ckb_types::packed::Script::new_unchecked(rollup_type_script.as_bytes()); @@ -399,12 +375,12 @@ impl BaseInitComponents { .ok_or_else(|| anyhow!("Eth: No allowed EoA type hashes in the rollup config"))?; account_lock_manage.register_lock_algorithm( eth_lock_script_type_hash.unpack(), - Box::new(Secp256k1Eth::default()), + Box::::default(), ); let tron_lock_script_type_hash = rollup_config.allowed_eoa_type_hashes().get(1); if let Some(code_hash) = tron_lock_script_type_hash { account_lock_manage - .register_lock_algorithm(code_hash.unpack(), Box::new(Secp256k1Tron::default())) + .register_lock_algorithm(code_hash.unpack(), Box::::default()) } Arc::new(Generator::new( backend_manage, @@ -952,7 +928,7 @@ async fn check_rollup_config_cell( .await? .and_then(|cell_with_status| cell_with_status.cell) .ok_or_else(|| anyhow!("can't find rollup config cell"))?; - let cell_data = RollupConfig::from_slice(&rollup_config_cell.data.to_vec())?; + let cell_data = RollupConfig::from_slice(&rollup_config_cell.data)?; let eoa_set = rollup_config .allowed_eoa_type_hashes() .into_iter() @@ -1037,16 +1013,6 @@ fn check_locks( Ok(()) } -fn is_hardfork_switch_eq(l: &HardForkSwitch, r: &HardForkSwitch) -> bool { - l.rfc_0028() == r.rfc_0028() - && l.rfc_0029() == r.rfc_0029() - && l.rfc_0030() == r.rfc_0030() - && l.rfc_0031() == r.rfc_0031() - && l.rfc_0032() == r.rfc_0032() - && l.rfc_0036() == r.rfc_0036() - && l.rfc_0038() == r.rfc_0038() -} - fn is_l1_query_error(err: &anyhow::Error) -> bool { use crate::poller::QueryL1TxError; use gw_rpc_client::error::RPCRequestError; diff --git a/crates/block-producer/src/utils.rs b/crates/block-producer/src/utils.rs index 90561e641..8d1e64a3c 100644 --- a/crates/block-producer/src/utils.rs +++ b/crates/block-producer/src/utils.rs @@ -7,7 +7,7 @@ pub async fn dump_transaction>(dir: P, rpc_client: &RPCClient, tx if let Err(err) = debugger::dump_transaction(dir, rpc_client, tx).await { log::error!( "Failed to dump transaction {} error: {}", - hex::encode(&tx.hash()), + hex::encode(tx.hash()), err ); } diff --git a/crates/block-producer/src/withdrawal.rs b/crates/block-producer/src/withdrawal.rs index 29fcb888c..aa2eb7277 100644 --- a/crates/block-producer/src/withdrawal.rs +++ b/crates/block-producer/src/withdrawal.rs @@ -24,13 +24,6 @@ use std::{ time::{SystemTime, UNIX_EPOCH}, }; -#[derive(Clone)] -struct CkbCustodian { - capacity: u128, - balance: u128, - min_capacity: u64, -} - pub struct GeneratedWithdrawals { pub deps: Vec, pub inputs: Vec, diff --git a/crates/block-producer/src/withdrawal_unlocker.rs b/crates/block-producer/src/withdrawal_unlocker.rs index 52c8afa8d..f8a57a1ec 100644 --- a/crates/block-producer/src/withdrawal_unlocker.rs +++ b/crates/block-producer/src/withdrawal_unlocker.rs @@ -7,9 +7,10 @@ use anyhow::{bail, Result}; use async_trait::async_trait; use gw_common::H256; use gw_config::{ContractsCellDep, DebugConfig}; +use gw_jsonrpc_types::ckb_jsonrpc_types::Status; use gw_rpc_client::contract::ContractsCellDepManager; use gw_rpc_client::rpc_client::RPCClient; -use gw_types::offchain::{global_state_from_slice, CellInfo, RollupContext, TxStatus}; +use gw_types::offchain::{global_state_from_slice, CellInfo, RollupContext}; use gw_types::packed::{OutPoint, Transaction}; use gw_types::prelude::{Pack, Unpack}; use gw_utils::fee::fill_tx_fee; @@ -92,7 +93,7 @@ impl FinalizedWithdrawalUnlocker { log::info!("[unlock withdrawal] dropped unlock tx {}", tx_hash.pack()); drop_txs.push(*tx_hash); } - Ok(Some(tx_status)) if matches!(tx_status, TxStatus::Committed) => { + Ok(Some(tx_status)) if matches!(tx_status, Status::Committed) => { log::info!( "[unlock withdrawal] unlock {} withdrawals in tx {}", withdrawal_to_unlock.len(), diff --git a/crates/chain/Cargo.toml b/crates/chain/Cargo.toml index a319a2e94..cd1bfb2c1 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.100.0" +ckb-fixed-hash = "0.111.0" anyhow = "1.0" thiserror = "1.0" lazy_static = "1.4" diff --git a/crates/challenge/Cargo.toml b/crates/challenge/Cargo.toml index 87a0b40f5..c7be12643 100644 --- a/crates/challenge/Cargo.toml +++ b/crates/challenge/Cargo.toml @@ -18,12 +18,11 @@ gw-rpc-client = { path = "../rpc-client" } gw-poa = { path = "../poa" } gw-traits = { path = "../traits" } gw-utils = { path = "../utils" } -gw-ckb-hardfork = { path = "../ckb-hardfork" } -ckb-fixed-hash = "0.100.0" -ckb-types = "0.100.0" -ckb-script = "0.100.0" -ckb-traits = "0.100.0" -ckb-chain-spec = "0.100.0" +ckb-fixed-hash = "0.111.0" +ckb-types = "0.111.0" +ckb-script = "0.111.0" +ckb-traits = "0.111.0" +ckb-chain-spec = "0.111.0" anyhow = "1.0" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" diff --git a/crates/challenge/src/cancel_challenge.rs b/crates/challenge/src/cancel_challenge.rs index cdf9ec8a1..543c61101 100644 --- a/crates/challenge/src/cancel_challenge.rs +++ b/crates/challenge/src/cancel_challenge.rs @@ -102,18 +102,13 @@ impl CancelChallengeOutput { } } -#[derive(Debug, Clone, Copy)] +#[derive(Debug, Clone, Copy, Default)] pub enum LoadDataStrategy { + #[default] Witness, CellDep, } -impl Default for LoadDataStrategy { - fn default() -> Self { - LoadDataStrategy::Witness - } -} - #[allow(clippy::too_many_arguments)] pub fn build_output( rollup_context: &RollupContext, @@ -195,7 +190,7 @@ pub fn build_output( load_builtin.iter().map(to_dep).collect() }; - let load_data: Vec = load_data.into_iter().map(|(_, v)| v.unpack()).collect(); + let load_data: Vec = load_data.into_values().map(|v| v.unpack()).collect(); let (witness, load_data_cells) = match load_data_strategy.unwrap_or_default() { LoadDataStrategy::Witness => { let context = { diff --git a/crates/challenge/src/offchain.rs b/crates/challenge/src/offchain.rs index e4d3cd878..51c97f40c 100644 --- a/crates/challenge/src/offchain.rs +++ b/crates/challenge/src/offchain.rs @@ -645,7 +645,7 @@ fn dump_tx_to_file( let dump = || -> Result<_> { let debug_config = &validator_context.debug_config; let dir = debug_config.debug_tx_dump_path.as_path(); - create_dir_all(&dir)?; + create_dir_all(dir)?; let mut dump_path = PathBuf::new(); dump_path.push(dir); diff --git a/crates/challenge/src/offchain/mock_block.rs b/crates/challenge/src/offchain/mock_block.rs index 11607d65e..066b54958 100644 --- a/crates/challenge/src/offchain/mock_block.rs +++ b/crates/challenge/src/offchain/mock_block.rs @@ -488,7 +488,7 @@ impl MockBlockParam { kv_state.insert(key.to_owned(), value); } - let touched_keys = kv_state.iter().map(|(key, _)| key.to_owned()).collect(); + let touched_keys = kv_state.keys().copied().collect(); let kv_state: Vec<(H256, H256)> = kv_state.into_iter().collect(); let kv_state_proof = { let smt = mem_tree.smt(); diff --git a/crates/challenge/src/offchain/mock_tx.rs b/crates/challenge/src/offchain/mock_tx.rs index aa27fe74a..bbc146d99 100644 --- a/crates/challenge/src/offchain/mock_tx.rs +++ b/crates/challenge/src/offchain/mock_tx.rs @@ -143,7 +143,6 @@ pub fn mock_cancel_challenge_tx( if input_len != witness_len { // append dummy witness args to align our reverted deposit witness args let dummy_witness_argses = (0..input_len - witness_len) - .into_iter() .map(|_| WitnessArgs::default()) .collect::>(); tx_skeleton.witnesses_mut().extend(dummy_witness_argses); diff --git a/crates/challenge/src/offchain/verify_tx.rs b/crates/challenge/src/offchain/verify_tx.rs index 06b87c002..fda83a07c 100644 --- a/crates/challenge/src/offchain/verify_tx.rs +++ b/crates/challenge/src/offchain/verify_tx.rs @@ -1,19 +1,17 @@ use anyhow::{anyhow, bail, Result}; -use ckb_chain_spec::consensus::ConsensusBuilder; +use ckb_chain_spec::consensus::Consensus; use ckb_fixed_hash::H256; use ckb_script::{TransactionScriptsVerifier, TxVerifyEnv}; -use ckb_traits::{CellDataProvider, HeaderProvider}; +use ckb_traits::{CellDataProvider, ExtensionProvider, HeaderProvider}; use ckb_types::{ bytes::Bytes, core::{ cell::{CellMeta, CellMetaBuilder, ResolvedTransaction}, - hardfork::HardForkSwitch, DepType, HeaderView, }, packed::{Byte32, CellDep, CellInput, CellOutput, OutPoint, OutPointVec, Transaction}, - prelude::{Builder, Entity, Pack, Unpack}, + prelude::*, }; -use gw_ckb_hardfork::{GLOBAL_CURRENT_EPOCH_NUMBER, GLOBAL_HARDFORK_SWITCH}; use gw_jsonrpc_types::{ ckb_jsonrpc_types, debugger::{ReprMockCellDep, ReprMockInfo, ReprMockInput, ReprMockTransaction}, @@ -22,9 +20,9 @@ use gw_types::offchain::InputCellInfo; use std::{ collections::{HashMap, HashSet}, - sync::atomic::Ordering, + sync::Arc, }; -use std::{convert::TryFrom, fs::read, path::PathBuf, sync::Arc}; +use std::{convert::TryFrom, fs::read, path::PathBuf}; pub struct TxWithContext { pub cell_deps: Vec, @@ -91,33 +89,21 @@ pub fn verify_tx( let resolved_tx = data_loader.resolve_tx(&tx_with_context.tx)?; - let hardfork_switch = { - let switch = GLOBAL_HARDFORK_SWITCH.load(); - HardForkSwitch::new_without_any_enabled() - .as_builder() - .rfc_0028(switch.rfc_0028()) - .rfc_0029(switch.rfc_0029()) - .rfc_0030(switch.rfc_0030()) - .rfc_0031(switch.rfc_0031()) - .rfc_0032(switch.rfc_0032()) - .rfc_0036(switch.rfc_0036()) - .rfc_0038(switch.rfc_0038()) - .build() - .map_err(|err| anyhow!(err))? - }; - let consensus = ConsensusBuilder::default() - .hardfork_switch(hardfork_switch) - .build(); - let current_epoch_number = GLOBAL_CURRENT_EPOCH_NUMBER.load(Ordering::SeqCst); + // Default is ckb2021. + let consensus = Consensus::default(); let tx_verify_env = TxVerifyEnv::new_submit( &HeaderView::new_advanced_builder() - .epoch(current_epoch_number.pack()) + // TODO: epoch. .build(), ); - let cycles = - TransactionScriptsVerifier::new(&resolved_tx, &consensus, &data_loader, &tx_verify_env) - .verify(max_cycles) - .map_err(|err| anyhow!("verify tx failed: {}", err))?; + let cycles = TransactionScriptsVerifier::new( + Arc::new(resolved_tx), + data_loader, + Arc::new(consensus), + Arc::new(tx_verify_env), + ) + .verify(max_cycles) + .map_err(|err| anyhow!("verify tx failed: {}", err))?; Ok(cycles) } @@ -178,6 +164,7 @@ pub fn dump_tx( Ok(mock_tx) } +#[derive(Clone)] struct TxDataLoader { rollup_cell_deps: Arc>, headers: HashMap, @@ -289,6 +276,12 @@ impl HeaderProvider for TxDataLoader { } } +impl ExtensionProvider for TxDataLoader { + fn get_block_extension(&self, _hash: &Byte32) -> Option { + None + } +} + #[derive(Clone)] struct CellInfo { output: CellOutput, diff --git a/crates/challenge/src/revert.rs b/crates/challenge/src/revert.rs index cfac0a868..53da6e39b 100644 --- a/crates/challenge/src/revert.rs +++ b/crates/challenge/src/revert.rs @@ -85,7 +85,7 @@ impl<'a> Revert<'a> { let reverted_blocks = self.revert_witness.reverted_blocks.clone(); reverted_blocks.into_iter().map(to_leave) }; - let block_merkle_proof = self.revert_witness.block_proof.clone(); + let block_merkle_proof = &self.revert_witness.block_proof; let block_root = block_merkle_proof.compute_root::(leaves.collect())?; let block_count = first_reverted_block.number(); diff --git a/crates/ckb-hardfork/Cargo.toml b/crates/ckb-hardfork/Cargo.toml deleted file mode 100644 index 98e6dd5ca..000000000 --- a/crates/ckb-hardfork/Cargo.toml +++ /dev/null @@ -1,13 +0,0 @@ -[package] -name = "gw-ckb-hardfork" -version = "0.1.0" -authors = ["Nervos Network"] -edition = "2018" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -lazy_static = "1.4" -tokio = "1.15" -ckb-types = "0.100.0" -arc-swap = "1.5" diff --git a/crates/ckb-hardfork/src/lib.rs b/crates/ckb-hardfork/src/lib.rs deleted file mode 100644 index 1f8b5163c..000000000 --- a/crates/ckb-hardfork/src/lib.rs +++ /dev/null @@ -1,12 +0,0 @@ -use std::sync::atomic::{AtomicU32, AtomicU64}; - -use arc_swap::ArcSwap; -use ckb_types::core::hardfork::HardForkSwitch; - -lazy_static::lazy_static! { - pub static ref GLOBAL_VM_VERSION: AtomicU32 = AtomicU32::new(0); - pub static ref GLOBAL_HARDFORK_SWITCH: ArcSwap = ArcSwap::from_pointee( - HardForkSwitch::new_without_any_enabled() - ); - pub static ref GLOBAL_CURRENT_EPOCH_NUMBER: AtomicU64 = AtomicU64::new(0); -} diff --git a/crates/common/src/merkle_utils.rs b/crates/common/src/merkle_utils.rs index 0d73ea450..817ce06b8 100644 --- a/crates/common/src/merkle_utils.rs +++ b/crates/common/src/merkle_utils.rs @@ -88,8 +88,8 @@ mod tests { //rebuild proof let proof = crate::merkle_utils::CBMTMerkleProof::new( - proof.indices().iter().copied().collect(), - proof.lemmas().iter().copied().collect(), + proof.indices().to_vec(), + proof.lemmas().to_vec(), ); let proof_leaves: Vec = vec![[0u8; 32].into(), [4u8; 32].into()]; diff --git a/crates/config/Cargo.toml b/crates/config/Cargo.toml index 292b80a80..3aeb18b77 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.100.0" +ckb-fixed-hash = "0.111.0" serde = { version = "1.0", features = ["derive"] } reqwest = { version = "0.11", features = ["json", "blocking"] } diff --git a/crates/config/src/config.rs b/crates/config/src/config.rs index 731874f09..84d86c754 100644 --- a/crates/config/src/config.rs +++ b/crates/config/src/config.rs @@ -66,7 +66,6 @@ pub struct RPCServerConfig { #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct RPCClientConfig { - pub indexer_url: String, pub ckb_url: String, } @@ -214,20 +213,15 @@ fn default_withdrawal_unlocker_wallet() -> Option { None } -#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Default)] pub enum BackendType { Meta, Sudt, Polyjuice, + #[default] Unknown, } -impl Default for BackendType { - fn default() -> Self { - BackendType::Unknown - } -} - #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct BackendConfig { pub validator_path: PathBuf, @@ -333,20 +327,15 @@ impl Default for MemPoolConfig { } } -#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize, Default)] #[serde(rename_all = "lowercase")] pub enum NodeMode { FullNode, Test, + #[default] ReadOnly, } -impl Default for NodeMode { - fn default() -> Self { - NodeMode::ReadOnly - } -} - #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct DBBlockValidatorConfig { pub verify_max_cycles: u64, diff --git a/crates/db/src/db.rs b/crates/db/src/db.rs index 10e5c3329..78ead2c3c 100644 --- a/crates/db/src/db.rs +++ b/crates/db/src/db.rs @@ -130,11 +130,11 @@ impl RocksDB { pub fn get_pinned(&self, col: Col, key: &[u8]) -> Result> { let cf = cf_handle(&self.inner, col)?; - self.inner.get_pinned_cf(cf, &key).map_err(internal_error) + self.inner.get_pinned_cf(cf, key).map_err(internal_error) } pub fn get_pinned_default(&self, key: &[u8]) -> Result> { - self.inner.get_pinned(&key).map_err(internal_error) + self.inner.get_pinned(key).map_err(internal_error) } pub fn put_default(&self, key: K, value: V) -> Result<()> diff --git a/crates/db/src/read_only_db.rs b/crates/db/src/read_only_db.rs index 3c3dc69d4..7842daea0 100644 --- a/crates/db/src/read_only_db.rs +++ b/crates/db/src/read_only_db.rs @@ -58,7 +58,7 @@ impl ReadOnlyDB { /// Return the value associated with a key using RocksDB's PinnableSlice from the default column /// so as to avoid unnecessary memory copy. pub fn get_pinned_default(&self, key: &[u8]) -> Result> { - self.inner.get_pinned(&key).map_err(internal_error) + self.inner.get_pinned(key).map_err(internal_error) } /// Return the value associated with a key using RocksDB's PinnableSlice from the given column @@ -68,6 +68,6 @@ impl ReadOnlyDB { .inner .cf_handle(&col.to_string()) .ok_or_else(|| internal_error(format!("column {} not found", col)))?; - self.inner.get_pinned_cf(cf, &key).map_err(internal_error) + self.inner.get_pinned_cf(cf, key).map_err(internal_error) } } diff --git a/crates/db/src/snapshot.rs b/crates/db/src/snapshot.rs index d4474c1f2..69f8d7924 100644 --- a/crates/db/src/snapshot.rs +++ b/crates/db/src/snapshot.rs @@ -36,7 +36,7 @@ impl RocksDBSnapshot { /// TODO(doc): @quake pub fn get_pinned(&self, col: Col, key: &[u8]) -> Result> { let cf = cf_handle(&self.db, col)?; - self.get_pinned_cf_full(Some(cf), &key, None) + self.get_pinned_cf_full(Some(cf), key, None) .map_err(internal_error) } } diff --git a/crates/db/src/transaction.rs b/crates/db/src/transaction.rs index 10558e55a..337c516c2 100644 --- a/crates/db/src/transaction.rs +++ b/crates/db/src/transaction.rs @@ -29,11 +29,11 @@ impl RocksDBTransaction { self.inner.delete_cf(cf, key).map_err(internal_error) } - pub fn get_for_update<'a>( + pub fn get_for_update( &self, col: Col, key: &[u8], - snapshot: &RocksDBTransactionSnapshot<'a>, + snapshot: &RocksDBTransactionSnapshot<'_>, ) -> Result> { let cf = cf_handle(&self.db, col)?; let mut opts = ReadOptions::default(); diff --git a/crates/dynamic-config/Cargo.toml b/crates/dynamic-config/Cargo.toml index 2da78a2a8..dcdb25476 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.100.0" +ckb-fixed-hash = "0.111.0" 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 359cba53f..0d54b92ab 100644 --- a/crates/generator/Cargo.toml +++ b/crates/generator/Cargo.toml @@ -18,12 +18,11 @@ gw-common = { path = "../common" } gw-config = { path = "../config" } gw-store = { path = "../store" } gw-traits = { path = "../traits" } -gw-ckb-hardfork = { path = "../ckb-hardfork" } gw-tx-filter = { path = "../tx-filter" } gw-dynamic-config = { path = "../dynamic-config"} anyhow = "1.0" blake2b-rs = "0.2" -ckb-vm = { version = "=0.20.0-rc5", features = ["detect-asm"] } +ckb-vm = { git = "https://github.com/nervosnetwork/ckb-vm.git", branch = "release-0.24-l2" } thiserror = "1.0" lazy_static = "1.4" rlp = "0.5.0" diff --git a/crates/generator/src/account_lock_manage/mod.rs b/crates/generator/src/account_lock_manage/mod.rs index 77310f161..32df9d157 100644 --- a/crates/generator/src/account_lock_manage/mod.rs +++ b/crates/generator/src/account_lock_manage/mod.rs @@ -32,18 +32,11 @@ pub trait LockAlgorithm { ) -> Result; } +#[derive(Default)] pub struct AccountLockManage { locks: HashMap>, } -impl Default for AccountLockManage { - fn default() -> Self { - AccountLockManage { - locks: Default::default(), - } - } -} - impl AccountLockManage { pub fn register_lock_algorithm( &mut self, diff --git a/crates/generator/src/backend_manage.rs b/crates/generator/src/backend_manage.rs index 427201e17..add4dd40c 100644 --- a/crates/generator/src/backend_manage.rs +++ b/crates/generator/src/backend_manage.rs @@ -4,9 +4,6 @@ use gw_config::{BackendConfig, BackendType}; use gw_types::bytes::Bytes; use std::{collections::HashMap, fs}; -#[cfg(has_asm)] -use crate::AotCode; - #[derive(Clone)] pub struct Backend { pub validator: Bytes, @@ -18,10 +15,6 @@ pub struct Backend { #[derive(Default)] pub struct BackendManage { backends: HashMap, - /// define here not in backends, - /// so we don't need to implement the trait `Clone` of AotCode - #[cfg(has_asm)] - aot_codes: (HashMap, HashMap), } impl BackendManage { @@ -59,20 +52,6 @@ impl BackendManage { } pub fn register_backend(&mut self, backend: Backend) { - #[cfg(feature = "aot")] - { - self.aot_codes.0.insert( - backend.validator_script_type_hash, - self.aot_compile(&backend.generator, 0) - .expect("Ahead-of-time compile"), - ); - self.aot_codes.1.insert( - backend.validator_script_type_hash, - self.aot_compile(&backend.generator, 1) - .expect("Ahead-of-time compile"), - ); - } - self.backends .insert(backend.validator_script_type_hash, backend); } @@ -81,36 +60,6 @@ impl BackendManage { self.backends.get(code_hash) } - #[cfg(feature = "aot")] - fn aot_compile(&self, code_bytes: &Bytes, vm_version: u32) -> Result { - log::info!("Compile AotCode with VMVersion::V{}", vm_version); - let vm_version = match vm_version { - 0 => crate::VMVersion::V0, - 1 => crate::VMVersion::V1, - ver => panic!("Unsupport VMVersion: {}", ver), - }; - let mut aot_machine = ckb_vm::machine::aot::AotCompilingMachine::load( - code_bytes, - Some(Box::new(crate::vm_cost_model::instruction_cycles)), - vm_version.vm_isa(), - vm_version.vm_version(), - )?; - aot_machine.compile() - } - - /// get aot_code according to special VM version - #[cfg(has_asm)] - pub(crate) fn get_aot_code(&self, code_hash: &H256, vm_version: u32) -> Option<&AotCode> { - match vm_version { - 0 => self.aot_codes.0.get(code_hash), - 1 => self.aot_codes.1.get(code_hash), - ver => { - log::error!("Unsupport VMVersion: {}", ver); - None - } - } - } - pub fn get_backends(&self) -> &HashMap { &self.backends } diff --git a/crates/generator/src/error.rs b/crates/generator/src/error.rs index 4e9cb4ee4..7d09ea636 100644 --- a/crates/generator/src/error.rs +++ b/crates/generator/src/error.rs @@ -131,7 +131,7 @@ pub enum TransactionError { ExceededMaxWriteData { max_bytes: usize, used_bytes: usize }, #[error("Cannot create sUDT proxy contract from account id: {account_id}.")] InvalidSUDTProxyCreatorAccount { account_id: u32 }, - #[error("Cannot create backend {} contract from account id: {account_id}")] + #[error("Cannot create backend {backend} contract from account id: {account_id}")] InvalidContractCreatorAccount { backend: &'static str, account_id: u32, diff --git a/crates/generator/src/generator.rs b/crates/generator/src/generator.rs index dbf751fd6..5feb5dfba 100644 --- a/crates/generator/src/generator.rs +++ b/crates/generator/src/generator.rs @@ -1,6 +1,6 @@ use std::{ collections::{HashMap, HashSet}, - sync::{atomic::Ordering::SeqCst, Arc}, + sync::Arc, time::Instant, }; @@ -20,7 +20,6 @@ use crate::{ use crate::{error::AccountError, syscalls::L2Syscalls}; use crate::{error::LockAlgorithmError, traits::StateExt}; use arc_swap::ArcSwap; -use gw_ckb_hardfork::GLOBAL_VM_VERSION; use gw_common::{ builtins::CKB_SUDT_ACCOUNT_ID, error::Error as StateError, @@ -168,15 +167,11 @@ impl Generator { { let t = Instant::now(); - let global_vm_version = GLOBAL_VM_VERSION.load(SeqCst); - let vm_version = match global_vm_version { - 0 => VMVersion::V0, - 1 => VMVersion::V1, - ver => panic!("Unsupport VMVersion: {}", ver), - }; + // Always use V1 for now. + let vm_version = VMVersion::V1; let core_machine = vm_version.init_core_machine(max_cycles); let machine_builder = DefaultMachineBuilder::new(core_machine) - .syscall(Box::new(L2Syscalls { + .syscall(L2Syscalls { chain, state, block_info, @@ -185,21 +180,12 @@ impl Generator { account_lock_manage: &self.account_lock_manage, result: &mut run_result, code_store: state, - })) - .instruction_cycle_func(Box::new(instruction_cycles)); + }) + .instruction_cycle_func(instruction_cycles); let default_machine = machine_builder.build(); #[cfg(has_asm)] - let aot_code_opt = self - .backend_manage - .get_aot_code(&backend.validator_script_type_hash, global_vm_version); - #[cfg(feature = "aot")] - if aot_code_opt.is_none() { - log::warn!("[machine_run] Not AOT mode!"); - } - - #[cfg(has_asm)] - let mut machine = ckb_vm::machine::asm::AsmMachine::new(default_machine, aot_code_opt); + let mut machine = ckb_vm::machine::asm::AsmMachine::new(default_machine); #[cfg(not(has_asm))] let mut machine = TraceMachine::new(default_machine); @@ -510,7 +496,7 @@ impl Generator { log::warn!( "skip the checkpoint check of block: #{} {}", block_number, - hex::encode(&block_hash) + hex::encode(block_hash) ); } for (tx_index, tx) in args.l2block.transactions().into_iter().enumerate() { @@ -1025,7 +1011,7 @@ mod test { ); assert!(!parsed_args.withdraw_to_v1); - let lock_args = parsed_args.lock_args.clone(); + let lock_args = &parsed_args.lock_args; assert_eq!( lock_args.account_script_hash(), req.raw().account_script_hash() diff --git a/crates/generator/src/syscalls/mod.rs b/crates/generator/src/syscalls/mod.rs index 4cfe90685..defcf6e13 100644 --- a/crates/generator/src/syscalls/mod.rs +++ b/crates/generator/src/syscalls/mod.rs @@ -156,7 +156,7 @@ impl<'a, S: State, C: ChainView, Mac: SupportMachine> Syscalls for L2Syscal let data_addr = machine.registers()[A0].to_u64(); let len = machine.registers()[A1].to_u64(); if len > MAX_SET_RETURN_DATA_SIZE { - return Err(VMError::Unexpected); + return Err(VMError::Unexpected("return data too large".into())); } let data = load_bytes(machine, data_addr, len as usize)?; self.result.return_data = data; @@ -294,8 +294,9 @@ impl<'a, S: State, C: ChainView, Mac: SupportMachine> Syscalls for L2Syscal SYS_LOAD_ACCOUNT_SCRIPT => { let account_id = machine.registers()[A3].to_u32(); let script_hash = self.get_script_hash(account_id).map_err(|err| { - log::error!("syscall error: get script hash by account id: {:?}", err); - VMError::Unexpected + VMError::Unexpected(format!( + "syscall error: get script hash by account id: {err}" + )) })?; // return not found if script_hash is zero, otherwise we search the script from DB if script_hash.is_zero() { @@ -303,11 +304,9 @@ impl<'a, S: State, C: ChainView, Mac: SupportMachine> Syscalls for L2Syscal return Ok(true); } let script = self.get_script(&script_hash).ok_or_else(|| { - log::error!( - "syscall error: script not found by script hash: {:?}", - script_hash - ); - VMError::Unexpected + VMError::Unexpected(format!( + "syscall error: script not found by script hash: {script_hash:?}" + )) })?; let data = script.as_slice(); store_data(machine, data)?; @@ -354,12 +353,10 @@ impl<'a, S: State, C: ChainView, Mac: SupportMachine> Syscalls for L2Syscal let block_hash_opt = self.chain.get_block_hash_by_number(number).map_err(|err| { - log::error!( + VMError::Unexpected(format!( "syscall error: get block hash by number: {}, error: {:?}", - number, - err - ); - VMError::Unexpected + number, err + )) })?; if let Some(hash) = block_hash_opt { machine @@ -457,8 +454,10 @@ impl<'a, S: State, C: ChainView, Mac: SupportMachine> Syscalls for L2Syscal let short_address_len = machine.registers()[A1].to_u64(); // check short address len if short_address_len != DEFAULT_SHORT_SCRIPT_HASH_LEN as u64 { - log::error!("unexpected script hash short length: {}", short_address_len); - return Err(VMError::Unexpected); + return Err(VMError::Unexpected(format!( + "unexpected script hash short length: {}", + short_address_len + ))); } load_bytes(machine, short_address_addr, short_address_len as usize)? }; @@ -471,7 +470,7 @@ impl<'a, S: State, C: ChainView, Mac: SupportMachine> Syscalls for L2Syscal // TODO record fee payment in the generator context log::debug!( "[contract syscall: SYS_PAY_FEE] payer: {}, sudt_id: {}, amount: {}", - hex::encode(&short_address), + hex::encode(short_address), sudt_id, amount ); @@ -492,7 +491,10 @@ impl<'a, S: State, C: ChainView> L2Syscalls<'a, S, C> { let value = match self.result.write_values.get(key) { Some(value) => *value, None => { - let tree_value = self.state.get_raw(key).map_err(|_| VMError::Unexpected)?; + let tree_value = self + .state + .get_raw(key) + .map_err(|e| VMError::Unexpected(e.to_string()))?; self.result.read_values.insert(*key, tree_value); tree_value } @@ -504,8 +506,7 @@ impl<'a, S: State, C: ChainView> L2Syscalls<'a, S, C> { Ok(id) } else { self.state.get_account_count().map_err(|err| { - log::error!("syscall error: get account count : {:?}", err); - VMError::Unexpected + VMError::Unexpected(format!("syscall error: get account count : {:?}", err)) }) } } @@ -537,8 +538,9 @@ impl<'a, S: State, C: ChainView> L2Syscalls<'a, S, C> { let value = self .get_raw(&build_account_field_key(id, GW_ACCOUNT_SCRIPT_HASH_TYPE)) .map_err(|err| { - log::error!("syscall error: get script hash by account id : {:?}", err); - VMError::Unexpected + VMError::Unexpected(format!( + "syscall error: get script hash by account id : {err}" + )) })?; Ok(value) } @@ -549,8 +551,9 @@ impl<'a, S: State, C: ChainView> L2Syscalls<'a, S, C> { let value = self .get_raw(&build_script_hash_to_account_id_key(script_hash.as_slice())) .map_err(|err| { - log::error!("syscall error: get account id by script hash : {:?}", err); - VMError::Unexpected + VMError::Unexpected(format!( + "syscall error: get account id by script hash : {err}" + )) })?; if value.is_zero() { return Ok(None); @@ -575,7 +578,7 @@ impl<'a, S: State, C: ChainView> L2Syscalls<'a, S, C> { addr += 1; } - let s = String::from_utf8(buffer).map_err(|_| VMError::ParseError)?; + let s = String::from_utf8(buffer).map_err(|e| VMError::Unexpected(e.to_string()))?; log::debug!("[contract debug]: {}", s); Ok(()) } diff --git a/crates/generator/src/traits.rs b/crates/generator/src/traits.rs index e1f286939..fec5e7d06 100644 --- a/crates/generator/src/traits.rs +++ b/crates/generator/src/traits.rs @@ -118,8 +118,8 @@ impl StateExt for S { ) -> Result<(), Error> { log::debug!( "account: 0x{} pay fee to block_producer: 0x{}, sudt_id: {}, amount: {}", - hex::encode(&payer_short_address), - hex::encode(&block_producer_short_address), + hex::encode(payer_short_address), + hex::encode(block_producer_short_address), sudt_id, &amount ); diff --git a/crates/generator/src/types.rs b/crates/generator/src/types.rs index 6d351af84..2bab25b92 100644 --- a/crates/generator/src/types.rs +++ b/crates/generator/src/types.rs @@ -74,9 +74,6 @@ impl VMVersion { } } -#[cfg(has_asm)] -pub(crate) use ckb_vm::machine::aot::AotCode; - #[derive(Debug, Clone, Eq, PartialEq)] pub struct ChallengeContext { pub target: ChallengeTarget, diff --git a/crates/generator/src/vm_cost_model.rs b/crates/generator/src/vm_cost_model.rs index 9172e62c2..fedb4eee4 100644 --- a/crates/generator/src/vm_cost_model.rs +++ b/crates/generator/src/vm_cost_model.rs @@ -21,14 +21,14 @@ pub fn transferred_byte_cycles(bytes: u64) -> u64 { pub fn instruction_cycles(i: Instruction) -> u64 { match extract_opcode(i) { // IMC - insts::OP_JALR => 3, - insts::OP_LD => 2, - insts::OP_LW => 3, - insts::OP_LH => 3, - insts::OP_LB => 3, - insts::OP_LWU => 3, - insts::OP_LHU => 3, - insts::OP_LBU => 3, + insts::OP_JALR_VERSION1 => 3, + insts::OP_LD_VERSION1 => 2, + insts::OP_LW_VERSION1 => 3, + insts::OP_LH_VERSION1 => 3, + insts::OP_LB_VERSION1 => 3, + insts::OP_LWU_VERSION1 => 3, + insts::OP_LHU_VERSION1 => 3, + insts::OP_LBU_VERSION1 => 3, insts::OP_SB => 3, insts::OP_SH => 3, insts::OP_SW => 3, diff --git a/crates/hash/Cargo.toml b/crates/hash/Cargo.toml index 263e4579a..aaf61bffb 100644 --- a/crates/hash/Cargo.toml +++ b/crates/hash/Cargo.toml @@ -7,4 +7,4 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -blake2b-ref = { version = "0.2", default-features = false } \ No newline at end of file +blake2b-ref = { version = "0.3", default-features = false } diff --git a/crates/jsonrpc-types/Cargo.toml b/crates/jsonrpc-types/Cargo.toml index cf7594a7e..e08c39a32 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.100.0" -ckb-fixed-hash = "0.100.0" +ckb-jsonrpc-types = "0.111.0" +ckb-fixed-hash = "0.111.0" anyhow = "1.0" diff --git a/crates/jsonrpc-types/src/blockchain.rs b/crates/jsonrpc-types/src/blockchain.rs index a59bea3a8..2cf3f931e 100644 --- a/crates/jsonrpc-types/src/blockchain.rs +++ b/crates/jsonrpc-types/src/blockchain.rs @@ -5,21 +5,17 @@ use gw_types::{packed, prelude::*}; use serde::{Deserialize, Serialize}; use std::convert::{TryFrom, TryInto}; -#[derive(Clone, Serialize, Deserialize, PartialEq, Eq, Hash, Debug)] +#[derive(Clone, Serialize, Deserialize, PartialEq, Eq, Hash, Debug, Default)] #[serde(rename_all = "snake_case")] pub enum ScriptHashType { /// Type "data" matches script code via cell data hash. + #[default] Data, /// Type "type" matches script code via cell type script hash. Type, /// Type "data" matches script code via cell data hash, and run the script code in v1 CKB VM. Data1, -} - -impl Default for ScriptHashType { - fn default() -> Self { - ScriptHashType::Data - } + Data2, } impl From for packed::Byte { @@ -28,6 +24,7 @@ impl From for packed::Byte { ScriptHashType::Data => packed::Byte::new(0), ScriptHashType::Type => packed::Byte::new(1), ScriptHashType::Data1 => packed::Byte::new(2), + ScriptHashType::Data2 => packed::Byte::new(4), } } } @@ -38,6 +35,7 @@ impl From for ScriptHashType { ckb_jsonrpc_types::ScriptHashType::Data => ScriptHashType::Data, ckb_jsonrpc_types::ScriptHashType::Type => ScriptHashType::Type, ckb_jsonrpc_types::ScriptHashType::Data1 => ScriptHashType::Data1, + ckb_jsonrpc_types::ScriptHashType::Data2 => ScriptHashType::Data2, } } } @@ -48,6 +46,7 @@ impl From for ckb_jsonrpc_types::ScriptHashType { ScriptHashType::Data => ckb_jsonrpc_types::ScriptHashType::Data, ScriptHashType::Type => ckb_jsonrpc_types::ScriptHashType::Type, ScriptHashType::Data1 => ckb_jsonrpc_types::ScriptHashType::Data1, + ScriptHashType::Data2 => ckb_jsonrpc_types::ScriptHashType::Data2, } } } @@ -276,12 +275,13 @@ impl From for OutPoint { } } -#[derive(Clone, Serialize, Deserialize, PartialEq, Eq, Hash, Debug)] +#[derive(Clone, Serialize, Deserialize, PartialEq, Eq, Hash, Debug, Default)] #[serde(rename_all = "snake_case")] pub enum DepType { /// Type "code". /// /// Use the cell itself as the dep cell. + #[default] Code, /// Type "dep_group". /// @@ -321,12 +321,6 @@ impl From for DepType { } } -impl Default for DepType { - fn default() -> Self { - DepType::Code - } -} - pub type Capacity = Uint64; #[derive(Clone, Serialize, Deserialize, PartialEq, Eq, Hash, Debug, Default)] diff --git a/crates/mem-pool/src/custodian.rs b/crates/mem-pool/src/custodian.rs index bd611fe5a..bf908a26e 100644 --- a/crates/mem-pool/src/custodian.rs +++ b/crates/mem-pool/src/custodian.rs @@ -68,21 +68,12 @@ pub fn to_custodian_cell( Ok((output, data)) } -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Default)] pub struct AvailableCustodians { pub capacity: u128, pub sudt: HashMap<[u8; 32], (u128, Script)>, } -impl Default for AvailableCustodians { - fn default() -> Self { - AvailableCustodians { - capacity: 0, - sudt: Default::default(), - } - } -} - impl<'a> From<&'a CollectedCustodianCells> for AvailableCustodians { fn from(collected: &'a CollectedCustodianCells) -> Self { AvailableCustodians { @@ -198,7 +189,7 @@ fn sum_change_capacity( change.capacity().unpack() as u128 } _ => { - let hex = hex::encode(&sudt_script_hash); + let hex = hex::encode(sudt_script_hash); log::warn!("unknown sudt script hash {:?}", hex); 0 } diff --git a/crates/mem-pool/src/fee/queue.rs b/crates/mem-pool/src/fee/queue.rs index d1c830a93..843da6c37 100644 --- a/crates/mem-pool/src/fee/queue.rs +++ b/crates/mem-pool/src/fee/queue.rs @@ -71,7 +71,7 @@ impl FeeQueue { #[instrument(skip_all, fields(count = count))] pub fn fetch(&mut self, state: &impl State, count: usize) -> Result> { // sorted fee items - let mut fetched_items = Vec::with_capacity(count as usize); + let mut fetched_items = Vec::with_capacity(count); let mut fetched_senders: HashMap = Default::default(); // future items, we will push back this queue let mut future_queue = Vec::default(); diff --git a/crates/mem-pool/src/pool.rs b/crates/mem-pool/src/pool.rs index 5b3fff010..ce0312896 100644 --- a/crates/mem-pool/src/pool.rs +++ b/crates/mem-pool/src/pool.rs @@ -58,7 +58,7 @@ use crate::{ withdrawal::Generator as WithdrawalGenerator, }; -#[derive(Debug)] +#[derive(Debug, Default)] pub struct OutputParam { pub retry_count: usize, } @@ -69,12 +69,6 @@ impl OutputParam { } } -impl Default for OutputParam { - fn default() -> Self { - OutputParam { retry_count: 0 } - } -} - /// MemPool pub struct MemPool { /// store @@ -749,7 +743,7 @@ impl MemPool { let tx_hash = tx.hash(); log::info!( "[mem pool] fail to re-inject tx {}, error: {}", - hex::encode(&tx_hash), + hex::encode(tx_hash), err ); } @@ -1324,7 +1318,7 @@ mod test { expected.push_withdrawal(hash, state.clone(), touched_keys); post_states.push(state); } - let deposits = deposits.iter().cloned().take(deposits_count).collect(); + let deposits = deposits.iter().take(deposits_count).cloned().collect(); let deposit_states: Vec<_> = { deposits_state.clone().into_iter().take(deposits_count) }.collect(); let deposit_touched_keys = diff --git a/crates/mem-pool/src/sync/subscribe.rs b/crates/mem-pool/src/sync/subscribe.rs index 77fe57376..0c5d0e0c1 100644 --- a/crates/mem-pool/src/sync/subscribe.rs +++ b/crates/mem-pool/src/sync/subscribe.rs @@ -25,7 +25,7 @@ impl SubscribeMemPoolService { let tx_hash = tx.raw().hash(); log::info!( "Add tx: {} from block: {} to mem block", - hex::encode(&tx_hash), + hex::encode(tx_hash), block_number ); let mut mem_pool = self.mem_pool.lock().await; diff --git a/crates/replay-chain/Cargo.toml b/crates/replay-chain/Cargo.toml index 0e2fc47f1..c73e528a0 100644 --- a/crates/replay-chain/Cargo.toml +++ b/crates/replay-chain/Cargo.toml @@ -20,8 +20,8 @@ gw-jsonrpc-types = { path = "../jsonrpc-types" } gw-rpc-client = { path = "../rpc-client" } async-jsonrpc-client = { version = "0.3.0", default-features = false, features = ["http-tokio"] } clap = "2.33.3" -ckb-fixed-hash = "0.100.0" -ckb-types = "0.100.0" +ckb-fixed-hash = "0.111.0" +ckb-types = "0.111.0" anyhow = "1.0" thiserror = "1.0" lazy_static = "1.4" diff --git a/crates/replay-chain/src/main.rs b/crates/replay-chain/src/main.rs index c3f7b88b7..46943d69d 100644 --- a/crates/replay-chain/src/main.rs +++ b/crates/replay-chain/src/main.rs @@ -91,7 +91,7 @@ async fn run_cli() -> Result<()> { match matches.subcommand() { ("replay", Some(m)) => { let config_path = m.value_of(ARG_CONFIG).unwrap(); - let config = read_config(&config_path)?; + let config = read_config(config_path)?; let from_db_store = m.value_of("from-db-store").unwrap().into(); let from_db_columns = m .value_of("from-db-columns") @@ -110,7 +110,7 @@ async fn run_cli() -> Result<()> { } ("detach", Some(m)) => { let config_path = m.value_of(ARG_CONFIG).unwrap(); - let config = read_config(&config_path)?; + let config = read_config(config_path)?; let from_db_store = m.value_of("from-db-store").unwrap().into(); let from_db_columns = m .value_of("from-db-columns") diff --git a/crates/replay-chain/src/setup.rs b/crates/replay-chain/src/setup.rs index 203635c6d..0cefcc8f4 100644 --- a/crates/replay-chain/src/setup.rs +++ b/crates/replay-chain/src/setup.rs @@ -62,7 +62,7 @@ pub async fn setup(args: SetupArgs) -> Result { }; let secp_data: Bytes = { let rpc_client = { - let indexer_client = CKBIndexerClient::with_url(&config.rpc_client.indexer_url)?; + let indexer_client = CKBIndexerClient::with_url(&config.rpc_client.ckb_url)?; let ckb_client = CKBClient::with_url(&config.rpc_client.ckb_url)?; let rollup_type_script = ckb_types::packed::Script::new_unchecked(rollup_type_script.as_bytes()); @@ -102,12 +102,12 @@ pub async fn setup(args: SetupArgs) -> Result { .ok_or_else(|| anyhow!("Eth: No allowed EoA type hashes in the rollup config"))?; account_lock_manage.register_lock_algorithm( eth_lock_script_type_hash.unpack(), - Box::new(Secp256k1Eth::default()), + Box::::default(), ); let tron_lock_script_type_hash = rollup_config.allowed_eoa_type_hashes().get(1); if let Some(code_hash) = tron_lock_script_type_hash { account_lock_manage - .register_lock_algorithm(code_hash.unpack(), Box::new(Secp256k1Tron::default())) + .register_lock_algorithm(code_hash.unpack(), Box::::default()) } Arc::new(Generator::new( backend_manage, diff --git a/crates/rpc-client/Cargo.toml b/crates/rpc-client/Cargo.toml index 0fdf58c3b..40fceec99 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.100.0" -ckb-fixed-hash = "0.100.0" -ckb-types = "0.100.0" +ckb-crypto = "0.111.0" +ckb-fixed-hash = "0.111.0" +ckb-types = "0.111.0" 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 2cdf33f71..7b49a56e9 100644 --- a/crates/rpc-client/src/ckb_client.rs +++ b/crates/rpc-client/src/ckb_client.rs @@ -2,16 +2,24 @@ use crate::{ error::RPCRequestError, utils::{to_result, DEFAULT_HTTP_TIMEOUT}, }; -use anyhow::{anyhow, bail, Result}; +use anyhow::{Context, Result}; use async_jsonrpc_client::{HttpClient, Params as ClientParams, Transport}; +use ckb_fixed_hash::H256; use gw_jsonrpc_types::blockchain::CellDep; -use serde::de::DeserializeOwned; +use gw_jsonrpc_types::ckb_jsonrpc_types::{TransactionView, TxStatus}; +use serde::{de::DeserializeOwned, Deserialize}; use serde_json::json; use tracing::instrument; #[derive(Clone)] pub struct CKBClient(HttpClient); +#[derive(Deserialize)] +pub struct TransactionWithStatus { + pub transaction: Option, + pub tx_status: TxStatus, +} + impl CKBClient { pub fn new(ckb_client: HttpClient) -> Self { Self(ckb_client) @@ -53,32 +61,38 @@ impl CKBClient { } } + pub async fn get_transaction(&self, tx_hash: &H256) -> Result { + self.request( + "get_transaction", + Some(ClientParams::Array(vec![json!(tx_hash)])), + ) + .await + } + #[instrument(skip_all)] pub async fn query_type_script( &self, contract: &str, cell_dep: CellDep, ) -> Result { - use gw_jsonrpc_types::ckb_jsonrpc_types::TransactionWithStatus; - - let tx_hash = cell_dep.out_point.tx_hash; - let tx_with_status: Option = self - .request( - "get_transaction", - Some(ClientParams::Array(vec![json!(tx_hash)])), - ) - .await?; - let tx = match tx_with_status { - Some(tx_with_status) => tx_with_status.transaction.inner, - None => bail!("{} {} tx not found", contract, tx_hash), - }; - - match tx.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)), - }, - None => Err(anyhow!("{} {} tx index not found", contract, tx_hash)), - } + let tx_hash = &cell_dep.out_point.tx_hash; + let tx = self.get_transaction(tx_hash).await?; + let type_script = tx + .transaction + .with_context(|| { + format!("transaction not found, contract={contract}, tx_hash={tx_hash}") + })? + .inner + .outputs + .get(cell_dep.out_point.index.value() as usize) + .cloned() + .with_context(|| { + format!("output index not found, contract={contract}, cell_dep={cell_dep:?}") + })? + .type_ + .with_context(|| { + format!("type script not found, contract={contract}, cell_dep={cell_dep:?}") + })?; + Ok(type_script.into()) } } diff --git a/crates/rpc-client/src/rpc_client.rs b/crates/rpc-client/src/rpc_client.rs index c4f1fa3e8..db48d60b0 100644 --- a/crates/rpc-client/src/rpc_client.rs +++ b/crates/rpc-client/src/rpc_client.rs @@ -7,12 +7,11 @@ use crate::traits::IndexedCells; use crate::utils::{to_h256, to_jsonh256, DEFAULT_QUERY_LIMIT, TYPE_ID_CODE_HASH}; use anyhow::{anyhow, Result}; use async_jsonrpc_client::Params as ClientParams; -use ckb_types::core::hardfork::HardForkSwitch; use ckb_types::prelude::Entity; use gw_common::{CKB_SUDT_SCRIPT_ARGS, H256}; -use gw_jsonrpc_types::ckb_jsonrpc_types::{self, BlockNumber, Consensus, Uint32}; +use gw_jsonrpc_types::ckb_jsonrpc_types::{self, BlockNumber, Status, Uint32}; use gw_types::offchain::{ - CellStatus, CellWithStatus, CollectedCustodianCells, DepositInfo, RollupContext, TxStatus, + CellStatus, CellWithStatus, CollectedCustodianCells, DepositInfo, RollupContext, WithdrawalsAmount, }; use gw_types::{ @@ -216,22 +215,26 @@ impl RPCClient { cells.objects.len() <= 1, "Never returns more than 1 identity cells" ); - cell = cells.objects.into_iter().find_map(|cell| { - let out_point = { - let out_point: ckb_types::packed::OutPoint = cell.out_point.into(); - OutPoint::new_unchecked(out_point.as_bytes()) - }; - let output = { - let output: ckb_types::packed::CellOutput = cell.output.into(); - CellOutput::new_unchecked(output.as_bytes()) - }; - let data = cell.output_data.into_bytes(); - Some(CellInfo { - out_point, - output, - data, + cell = cells + .objects + .into_iter() + .map(|cell| { + let out_point = { + let out_point: ckb_types::packed::OutPoint = cell.out_point.into(); + OutPoint::new_unchecked(out_point.as_bytes()) + }; + let output = { + let output: ckb_types::packed::CellOutput = cell.output.into(); + CellOutput::new_unchecked(output.as_bytes()) + }; + let data = cell.output_data.into_bytes(); + CellInfo { + out_point, + output, + data, + } }) - }); + .next(); } Ok(cell) } @@ -369,7 +372,7 @@ impl RPCClient { #[instrument(skip_all)] pub async fn get_tip(&self) -> Result { let number_hash: gw_jsonrpc_types::blockchain::NumberHash = - self.indexer.request("get_tip", None).await?; + self.indexer.request("get_indexer_tip", None).await?; Ok(number_hash.into()) } @@ -1512,24 +1515,9 @@ impl RPCClient { #[instrument(skip_all, fields(tx_hash = %tx_hash.pack()))] pub async fn get_transaction_block_hash(&self, tx_hash: H256) -> Result> { - let tx_with_status: Option = self - .ckb - .request( - "get_transaction", - Some(ClientParams::Array(vec![json!(to_jsonh256(tx_hash))])), - ) - .await?; - - match tx_with_status { - Some(tx_with_status) => { - let block_hash: ckb_fixed_hash::H256 = { - let status = tx_with_status.tx_status; - status.block_hash.ok_or_else(|| anyhow!("no tx block hash")) - }?; - Ok(Some(block_hash.into())) - } - None => Ok(None), - } + let hash: [u8; 32] = tx_hash.into(); + let tx_with_status = self.ckb.get_transaction(&hash.into()).await?; + Ok(tx_with_status.tx_status.block_hash.map(|x| x.into())) } #[instrument(skip_all, fields(tx_hash = %tx_hash.pack()))] @@ -1545,42 +1533,21 @@ impl RPCClient { #[instrument(skip_all, fields(tx_hash = %tx_hash.pack()))] pub async fn get_transaction(&self, tx_hash: H256) -> Result> { - let tx_with_status: Option = self - .ckb - .request( - "get_transaction", - Some(ClientParams::Array(vec![json!(to_jsonh256(tx_hash))])), - ) - .await?; - Ok(tx_with_status.map(|tx_with_status| { - let tx: ckb_types::packed::Transaction = tx_with_status.transaction.inner.into(); - Transaction::new_unchecked(tx.as_bytes()) - })) + let hash: [u8; 32] = tx_hash.into(); + let tx_with_status = self.ckb.get_transaction(&hash.into()).await?; + if let Some(tx) = tx_with_status.transaction { + let tx = ckb_types::packed::Transaction::from(tx.inner); + Ok(Some(Transaction::new_unchecked(tx.as_bytes()))) + } else { + Ok(None) + } } #[instrument(skip_all, fields(tx_hash = %tx_hash.pack()))] - pub async fn get_transaction_status(&self, tx_hash: H256) -> Result> { - let get_tx = self.ckb.request::>( - "get_transaction", - Some(ClientParams::Array(vec![json!(to_jsonh256(tx_hash))])), - ); - - let tx_with_status: ckb_jsonrpc_types::TransactionWithStatus = match get_tx.await? { - Some(ret) if ret["transaction"] == serde_json::Value::Null => { - log::debug!("get_transaction_status: tx {:x} {:?}", tx_hash.pack(), ret); - return Ok(None); - } - Some(ret) => serde_json::from_value(ret)?, - None => return Ok(None), - }; - - let status = match tx_with_status.tx_status.status { - ckb_jsonrpc_types::Status::Pending => TxStatus::Pending, - ckb_jsonrpc_types::Status::Committed => TxStatus::Committed, - ckb_jsonrpc_types::Status::Proposed => TxStatus::Proposed, - }; - - Ok(Some(status)) + pub async fn get_transaction_status(&self, tx_hash: H256) -> Result> { + let hash: [u8; 32] = tx_hash.into(); + let tx_with_status = self.ckb.get_transaction(&hash.into()).await?; + Ok(Some(tx_with_status.tx_status.status)) } #[instrument(skip_all, fields(tx_hash = %tx.hash().pack()))] @@ -1611,10 +1578,10 @@ 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", + "estimate_cycles", Some(ClientParams::Array(vec![json!(tx)])), ) .await?; @@ -1629,44 +1596,6 @@ impl RPCClient { Ok(epoch_number) } - #[instrument(skip_all)] - pub async fn get_hardfork_switch(&self) -> Result { - let consensus: Consensus = self.ckb.request("get_consensus", None).await?; - let rfc_0028 = self.get_hardfork_feature_epoch_number(&consensus, "0028")?; - let rfc_0029 = self.get_hardfork_feature_epoch_number(&consensus, "0029")?; - let rfc_0030 = self.get_hardfork_feature_epoch_number(&consensus, "0030")?; - let rfc_0031 = self.get_hardfork_feature_epoch_number(&consensus, "0031")?; - let rfc_0032 = self.get_hardfork_feature_epoch_number(&consensus, "0032")?; - let rfc_0036 = self.get_hardfork_feature_epoch_number(&consensus, "0036")?; - let rfc_0038 = self.get_hardfork_feature_epoch_number(&consensus, "0038")?; - let hardfork_switch = HardForkSwitch::new_without_any_enabled() - .as_builder() - .rfc_0028(rfc_0028) - .rfc_0029(rfc_0029) - .rfc_0030(rfc_0030) - .rfc_0031(rfc_0031) - .rfc_0032(rfc_0032) - .rfc_0036(rfc_0036) - .rfc_0038(rfc_0038) - .build() - .map_err(|err| anyhow!(err))?; - - Ok(hardfork_switch) - } - - #[instrument(skip_all)] - fn get_hardfork_feature_epoch_number(&self, consensus: &Consensus, rfc: &str) -> Result { - let rfc_info = consensus - .hardfork_features - .iter() - .find(|f| f.rfc == rfc) - .ok_or_else(|| anyhow!("rfc {} hardfork feature not found!", rfc))?; - - // if epoch_number is null, which means the fork will never going to happen - let epoch_number: u64 = rfc_info.epoch_number.map(Into::into).unwrap_or(u64::MAX); - Ok(epoch_number) - } - #[instrument(skip(self))] async fn query_random_sudt_type_script( &self, diff --git a/crates/rpc-client/src/withdrawal.rs b/crates/rpc-client/src/withdrawal.rs index c3268b2f7..8a6b9f35a 100644 --- a/crates/rpc-client/src/withdrawal.rs +++ b/crates/rpc-client/src/withdrawal.rs @@ -257,7 +257,7 @@ mod test { let mut args = rollup_type_hash.to_vec(); args.extend_from_slice(&lock_args.as_bytes()); args.extend_from_slice(&(owner_lock.as_bytes().len() as u32).to_be_bytes()); - args.extend_from_slice(&vec![1u8; owner_lock.as_bytes().len() as usize]); + args.extend_from_slice(&vec![1u8; owner_lock.as_bytes().len()]); let lock = Script::new_builder().args(args.pack()).build(); let info = CellInfo { diff --git a/crates/rpc-server/Cargo.toml b/crates/rpc-server/Cargo.toml index 01115e288..d06d3245f 100644 --- a/crates/rpc-server/Cargo.toml +++ b/crates/rpc-server/Cargo.toml @@ -23,9 +23,9 @@ gw-rpc-ws-server = { path = "../rpc-ws-server" } gw-dynamic-config = { path = "../dynamic-config"} gw-utils = { path = "../utils" } faster-hex = "0.4" -ckb-crypto = "0.100.0" -ckb-fixed-hash = "0.100.0" -ckb-types = "0.100.0" +ckb-crypto = "0.111.0" +ckb-fixed-hash = "0.111.0" +ckb-types = "0.111.0" toml = "0.5" anyhow = "1.0" serde = { version = "1.0", features = ["derive"] } diff --git a/crates/rpc-ws-server/Cargo.toml b/crates/rpc-ws-server/Cargo.toml index a03d4c295..f475ae3bf 100644 --- a/crates/rpc-ws-server/Cargo.toml +++ b/crates/rpc-ws-server/Cargo.toml @@ -7,7 +7,7 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -ckb-types = "0.100.0" +ckb-types = "0.111.0" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" serde_plain = "0.3.0" diff --git a/crates/tests/Cargo.toml b/crates/tests/Cargo.toml index 0d1fe55af..3155f1153 100644 --- a/crates/tests/Cargo.toml +++ b/crates/tests/Cargo.toml @@ -20,26 +20,24 @@ gw-utils = { path = "../utils" } gw-block-producer = { path = "../block-producer" } gw-rpc-server = { path = "../rpc-server" } gw-rpc-client = { path = "../rpc-client" } -gw-ckb-hardfork = { path = "../ckb-hardfork" } gw-dynamic-config = { path = "../dynamic-config"} anyhow = "1.0" blake2b-rs = "0.2" -ckb-vm = { version = "=0.20.0-rc5", features = ["detect-asm"] } -ckb-vm-definitions = "=0.20.0-rc5" +ckb-vm = { git = "https://github.com/nervosnetwork/ckb-vm.git", branch = "release-0.24-l2" } thiserror = "1.0" lazy_static = "1.4" secp256k1 = { version = "0.20", features = ["recovery"] } async-jsonrpc-client = { version = "0.3.0", default-features = false, features = ["http-tokio"] } sha3 = "0.9.1" hex = "0.4.2" -ckb-script = "0.100.0" -ckb-types = "0.100.0" -ckb-error = "0.100.0" -ckb-crypto = "0.100.0" -ckb-hash = "0.100.0" -ckb-traits = "0.100.0" -ckb-fixed-hash = "0.100.0" -ckb-chain-spec = "0.100.0" +ckb-script = "0.111.0" +ckb-types = "0.111.0" +ckb-error = "0.111.0" +ckb-crypto = "0.111.0" +ckb-hash = "0.111.0" +ckb-traits = "0.111.0" +ckb-fixed-hash = "0.111.0" +ckb-chain-spec = "0.111.0" rand = "0.8" serde = "1.0" serde_json = "1.0" diff --git a/crates/tests/src/testing_tool/chain.rs b/crates/tests/src/testing_tool/chain.rs index f72157ce4..5b5a1bd60 100644 --- a/crates/tests/src/testing_tool/chain.rs +++ b/crates/tests/src/testing_tool/chain.rs @@ -45,8 +45,8 @@ lazy_static! { pub static ref ALWAYS_SUCCESS_PROGRAM: Bytes = { let mut buf = Vec::new(); let mut path = PathBuf::new(); - path.push(&SCRIPT_DIR); - path.push(&ALWAYS_SUCCESS_PATH); + path.push(SCRIPT_DIR); + path.push(ALWAYS_SUCCESS_PATH); let mut f = fs::File::open(&path).expect("load program"); f.read_to_end(&mut buf).expect("read program"); Bytes::from(buf.to_vec()) @@ -61,8 +61,8 @@ lazy_static! { pub static ref WITHDRAWAL_LOCK_PROGRAM: Bytes = { let mut buf = Vec::new(); let mut path = PathBuf::new(); - path.push(&SCRIPT_DIR); - path.push(&WITHDRAWAL_LOCK_PATH); + path.push(SCRIPT_DIR); + path.push(WITHDRAWAL_LOCK_PATH); let mut f = fs::File::open(&path).expect("load withdrawal lock program"); f.read_to_end(&mut buf) .expect("read withdrawal lock program"); @@ -78,8 +78,8 @@ lazy_static! { pub static ref STATE_VALIDATOR_TYPE_PROGRAM: Bytes = { let mut buf = Vec::new(); let mut path = PathBuf::new(); - path.push(&SCRIPT_DIR); - path.push(&STATE_VALIDATOR_TYPE_PATH); + path.push(SCRIPT_DIR); + path.push(STATE_VALIDATOR_TYPE_PATH); let mut f = fs::File::open(&path).expect("load state validator type program"); f.read_to_end(&mut buf) .expect("read state validator type program"); @@ -95,8 +95,8 @@ lazy_static! { pub static ref STAKE_LOCK_PROGRAM: Bytes = { let mut buf = Vec::new(); let mut path = PathBuf::new(); - path.push(&SCRIPT_DIR); - path.push(&STAKE_LOCK_PATH); + path.push(SCRIPT_DIR); + path.push(STAKE_LOCK_PATH); let mut f = fs::File::open(&path).expect("load stake lock program"); f.read_to_end(&mut buf).expect("read stake lock program"); Bytes::from(buf.to_vec()) @@ -111,8 +111,8 @@ lazy_static! { pub static ref CUSTODIAN_LOCK_PROGRAM: Bytes = { let mut buf = Vec::new(); let mut path = PathBuf::new(); - path.push(&SCRIPT_DIR); - path.push(&CUSTODIAN_LOCK_PATH); + path.push(SCRIPT_DIR); + path.push(CUSTODIAN_LOCK_PATH); let mut f = fs::File::open(&path).expect("load custodian lock program"); f.read_to_end(&mut buf) .expect("read custodian lock program"); diff --git a/crates/tests/src/testing_tool/verify_tx.rs b/crates/tests/src/testing_tool/verify_tx.rs index 4f5dc1035..af5eb5e01 100644 --- a/crates/tests/src/testing_tool/verify_tx.rs +++ b/crates/tests/src/testing_tool/verify_tx.rs @@ -1,20 +1,19 @@ -use std::{collections::HashMap, convert::TryFrom, sync::atomic::Ordering::SeqCst}; +use std::{collections::HashMap, convert::TryFrom, sync::Arc}; use anyhow::{anyhow, Result}; use ckb_chain_spec::consensus::ConsensusBuilder; use ckb_script::{TransactionScriptsVerifier, TxVerifyEnv}; -use ckb_traits::{CellDataProvider, HeaderProvider}; +use ckb_traits::{CellDataProvider, ExtensionProvider, HeaderProvider}; use ckb_types::core::{ cell::{CellMeta, CellMetaBuilder, ResolvedTransaction}, - hardfork::HardForkSwitch, - DepType, HeaderView, + hardfork::{HardForks, CKB2021, CKB2023}, + DepType, HeaderBuilder, HeaderView, }; use ckb_types::{ bytes::Bytes, packed::{Byte32, CellOutput, OutPoint, OutPointVec, Transaction}, - prelude::{Entity, Pack}, + prelude::*, }; -use gw_ckb_hardfork::{GLOBAL_CURRENT_EPOCH_NUMBER, GLOBAL_HARDFORK_SWITCH}; use gw_types::offchain::InputCellInfo; pub struct TxWithContext { @@ -30,38 +29,28 @@ pub fn verify_tx(tx_with_context: TxWithContext, max_cycles: u64) -> Result data_loader.extend_inputs(tx_with_context.inputs); let resolved_tx = data_loader.resolve_tx(&tx_with_context.tx)?; - - let hardfork_switch = { - let switch = GLOBAL_HARDFORK_SWITCH.load(); - HardForkSwitch::new_without_any_enabled() - .as_builder() - .rfc_0028(switch.rfc_0028()) - .rfc_0029(switch.rfc_0029()) - .rfc_0030(switch.rfc_0030()) - .rfc_0031(switch.rfc_0031()) - .rfc_0032(switch.rfc_0032()) - .rfc_0036(switch.rfc_0036()) - .rfc_0038(switch.rfc_0038()) - .build() - .map_err(|err| anyhow!(err))? - }; + // Use ckb2023 for testing. let consensus = ConsensusBuilder::default() - .hardfork_switch(hardfork_switch) + .hardfork_switch(HardForks { + ckb2021: CKB2021::new_dev_default(), + ckb2023: CKB2023::new_dev_default(), + }) .build(); - let current_epoch_number = GLOBAL_CURRENT_EPOCH_NUMBER.load(SeqCst); - let tx_verify_env = TxVerifyEnv::new_submit( - &HeaderView::new_advanced_builder() - .epoch(current_epoch_number.pack()) - .build(), - ); - let cycles = - TransactionScriptsVerifier::new(&resolved_tx, &consensus, &data_loader, &tx_verify_env) - .verify(max_cycles) - .map_err(|err| anyhow!("verify tx failed: {}", err))?; + let tip = HeaderBuilder::default().build(); + let tx_verify_env = TxVerifyEnv::new_submit(&tip); + let cycles = TransactionScriptsVerifier::new( + Arc::new(resolved_tx), + data_loader, + Arc::new(consensus), + Arc::new(tx_verify_env), + ) + .verify(max_cycles) + .map_err(|err| anyhow!("verify tx failed: {}", err))?; Ok(cycles) } +#[derive(Clone)] struct TxDataLoader { headers: HashMap, cell_deps: HashMap, @@ -166,6 +155,15 @@ impl HeaderProvider for TxDataLoader { } } +impl ExtensionProvider for TxDataLoader { + fn get_block_extension( + &self, + _hash: &ckb_types::packed::Byte32, + ) -> Option { + None + } +} + #[derive(Clone)] struct CellInfo { output: CellOutput, diff --git a/crates/tests/src/tests/deposit_withdrawal.rs b/crates/tests/src/tests/deposit_withdrawal.rs index 9cf3567da..789ac6f10 100644 --- a/crates/tests/src/tests/deposit_withdrawal.rs +++ b/crates/tests/src/tests/deposit_withdrawal.rs @@ -109,7 +109,6 @@ async fn withdrawal_from_chain( #[tokio::test] async fn test_deposit_and_withdrawal() { - env_logger::init(); let rollup_type_script = Script::default(); let rollup_script_hash = rollup_type_script.hash(); let mut chain = setup_chain(rollup_type_script.clone()).await; diff --git a/crates/tests/src/tests/restore_mem_block.rs b/crates/tests/src/tests/restore_mem_block.rs index 6ca08a6c0..cca35d3ce 100644 --- a/crates/tests/src/tests/restore_mem_block.rs +++ b/crates/tests/src/tests/restore_mem_block.rs @@ -210,7 +210,7 @@ async fn test_restore_mem_block() { let rollup_context = generator.rollup_context().to_owned(); let rpc_client = { let indexer_client = - CKBIndexerClient::with_url(&RPCClientConfig::default().indexer_url).unwrap(); + CKBIndexerClient::with_url(&RPCClientConfig::default().ckb_url).unwrap(); let ckb_client = CKBClient::with_url(&RPCClientConfig::default().ckb_url).unwrap(); let rollup_type_script = ckb_types::packed::Script::new_unchecked(rollup_type_script.as_bytes()); diff --git a/crates/tools/Cargo.toml b/crates/tools/Cargo.toml index c7ad4dc49..8726de7d9 100644 --- a/crates/tools/Cargo.toml +++ b/crates/tools/Cargo.toml @@ -17,16 +17,16 @@ toml = "0.5" bech32 = "0.6.0" tempfile = "3.1" lazy_static = "1.3" -secp256k1 = "0.19" +secp256k1 = "0.24" sha3 = "0.9.1" reqwest = { version = "0.11", features = ["json", "blocking"] } -ckb-jsonrpc-types = "0.100.0" -ckb-types = "0.100.0" -ckb-resource = "0.100.0" -ckb-hash = "0.100.0" -ckb-fixed-hash = "0.100.0" -ckb-sdk = "0.100.0" -ckb-crypto = "0.100.0" +ckb-jsonrpc-types = "0.111.0" +ckb-types = "0.111.0" +ckb-resource = "0.111.0" +ckb-hash = "0.111.0" +ckb-fixed-hash = "0.111.0" +ckb-sdk = "3.0.0" +ckb-crypto = "0.111.0" gw-db = { path = "../db" } gw-types = { path = "../types" } gw-config = { path = "../config" } diff --git a/crates/tools/src/account.rs b/crates/tools/src/account.rs index 917508e14..7205c131e 100644 --- a/crates/tools/src/account.rs +++ b/crates/tools/src/account.rs @@ -111,7 +111,7 @@ pub async fn short_address_to_account_id( None => { return Err(anyhow!( "script hash by short address: 0x{} not found", - hex::encode(short_address.to_vec()), + hex::encode(short_address), )) } }; @@ -139,7 +139,7 @@ pub async fn parse_account_short_address( Err(_) => return Err(anyhow!("account id parse error!")), }; let script_hash = godwoken.get_script_hash(account_id).await?; - let short_address = GwBytes::from((&script_hash.as_bytes()[..20]).to_vec()); + let short_address = GwBytes::copy_from_slice(&script_hash.as_bytes()[..20]); Ok(short_address) } diff --git a/crates/tools/src/address.rs b/crates/tools/src/address.rs index 990136797..cde99ffe6 100644 --- a/crates/tools/src/address.rs +++ b/crates/tools/src/address.rs @@ -25,7 +25,7 @@ pub fn to_godwoken_short_address( eth_eoa_address.trim_start_matches("0x").as_bytes(), )?); - let config = read_config(&config_path)?; + let config = read_config(config_path)?; let rollup_type_hash = &config.genesis.rollup_type_hash; let scripts_deployment_content = std::fs::read_to_string(scripts_deployment_path)?; diff --git a/crates/tools/src/deploy_genesis.rs b/crates/tools/src/deploy_genesis.rs index c0e405484..44cdf56e8 100644 --- a/crates/tools/src/deploy_genesis.rs +++ b/crates/tools/src/deploy_genesis.rs @@ -1,25 +1,22 @@ +use std::iter::FromIterator; use std::ops::{Deref, Sub}; use std::path::Path; use std::str::FromStr; +use std::time::{SystemTime, UNIX_EPOCH}; -use anyhow::{anyhow, Result}; -use tempfile::NamedTempFile; - +use anyhow::{anyhow, Context, Result}; 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::{ - calc_max_mature_number, - constants::{CELLBASE_MATURITY, MIN_SECP_CELL_CAPACITY, ONE_CKB}, - Address, AddressPayload, GenesisInfo, HttpRpcClient, HumanCapacity, SECP256K1, + constants::{MIN_SECP_CELL_CAPACITY, ONE_CKB}, + traits::{CellCollector, CellQueryOptions, DefaultCellCollector, DefaultCellDepResolver}, + Address, AddressPayload, CkbRpcClient, SECP256K1, }; use ckb_types::{ bytes::{Bytes, BytesMut}, - core::{ - BlockView, Capacity, DepType, EpochNumberWithFraction, ScriptHashType, TransactionBuilder, - TransactionView, - }, + core::{BlockView, Capacity, DepType, ScriptHashType, TransactionBuilder, TransactionView}, packed as ckb_packed, prelude::Builder as CKBBuilder, prelude::Pack as CKBPack, @@ -31,14 +28,13 @@ use gw_types::{ packed as gw_packed, packed::RollupConfig, prelude::Entity as GwEntity, prelude::Pack as GwPack, prelude::PackVec as GwPackVec, }; +use tempfile::NamedTempFile; use crate::types::{ PoAConfig, PoASetup, RollupDeploymentResult, ScriptsDeploymentResult, UserRollupConfig, }; use crate::utils::transaction::{get_network_type, run_cmd, wait_for_tx, TYPE_ID_CODE_HASH}; -use std::time::{SystemTime, UNIX_EPOCH}; - pub fn serialize_poa_setup(setup: &PoASetup) -> Bytes { let mut buffer = BytesMut::new(); if setup.round_interval_uses_seconds { @@ -84,14 +80,14 @@ pub fn serialize_poa_data(data: &PoAData) -> Bytes { struct DeployContext<'a> { privkey_path: &'a Path, owner_address: &'a Address, - genesis_info: &'a GenesisInfo, + cell_dep_resolver: DefaultCellDepResolver, deployment_result: &'a ScriptsDeploymentResult, } impl<'a> DeployContext<'a> { fn deploy( &mut self, - rpc_client: &mut HttpRpcClient, + rpc_client: &CkbRpcClient, mut outputs: Vec, mut outputs_data: Vec, mut deps: Vec, @@ -107,22 +103,25 @@ impl<'a> DeployContext<'a> { }) .sum(); let total_capacity = total_output_capacity + tx_fee; - let tip_number = rpc_client - .get_tip_block_number() - .map_err(|err| anyhow!(err))?; - let max_mature_number = get_max_mature_number(rpc_client)?; - let (inputs, total_input_capacity) = collect_live_cells( - rpc_client.url(), - self.owner_address.to_string().as_str(), - max_mature_number, - tip_number, - total_capacity, - )?; + + let (inputs, total_input_capacity) = { + let mut collector = DefaultCellCollector::new(rpc_client.url.as_str()); + let mut query = CellQueryOptions::new_lock(self.owner_address.payload().into()); + query.min_total_capacity = total_capacity; + collector.collect_live_cells(&query, false)? + }; + if let Some(first_input) = first_cell_input { - if inputs[0].as_slice() != first_input.as_slice() { + if inputs[0].out_point.as_slice() != first_input.previous_output().as_slice() { return Err(anyhow!("first input cell changed")); } } + let inputs = Vec::from_iter( + inputs + .into_iter() + .map(|i| ckb_packed::CellInput::new(i.out_point, 0)), + ); + // collect_live_cells will ensure `total_input_capacity >= total_capacity`. let rest_capacity = total_input_capacity - total_capacity; let max_tx_fee_str = if rest_capacity >= MIN_SECP_CELL_CAPACITY { @@ -137,17 +136,15 @@ impl<'a> DeployContext<'a> { } else { "62.0" }; - let outputs_data: Vec = outputs_data - .iter() - .map(|data| CKBPack::pack(data)) - .collect(); + let outputs_data: Vec = outputs_data.iter().map(CKBPack::pack).collect(); + let sighash_dep = self.cell_dep_resolver.sighash_dep().unwrap().0.clone(); deps.extend_from_slice(&[ self.deployment_result .state_validator .cell_dep .clone() .into(), - self.genesis_info.sighash_dep(), + sighash_dep, ]); let tx: TransactionView = TransactionBuilder::default() .cell_deps(deps) @@ -160,9 +157,9 @@ impl<'a> DeployContext<'a> { // 7. build ckb-cli tx and sign let tx_file = NamedTempFile::new()?; let tx_path_str = tx_file.path().to_str().unwrap(); - let _output = run_cmd(&[ + let _output = run_cmd([ "--url", - rpc_client.url(), + rpc_client.url.as_str(), "tx", "init", "--tx-file", @@ -175,9 +172,9 @@ impl<'a> DeployContext<'a> { cli_tx["transaction"] = tx_body; let cli_tx_content = serde_json::to_string_pretty(&cli_tx).unwrap(); std::fs::write(tx_path_str, cli_tx_content.as_bytes())?; - let _output = run_cmd(&[ + let _output = run_cmd([ "--url", - rpc_client.url(), + rpc_client.url.as_str(), "tx", "sign-inputs", "--privkey-path", @@ -188,9 +185,9 @@ impl<'a> DeployContext<'a> { ])?; // 8. send and then wait for tx - let send_output = run_cmd(&[ + let send_output = run_cmd([ "--url", - rpc_client.url(), + rpc_client.url.as_str(), "tx", "send", "--tx-file", @@ -231,7 +228,7 @@ pub fn deploy_rollup_cell(args: DeployRollupCellArgs) -> Result Result Result Result = vec![ @@ -322,11 +317,11 @@ pub fn deploy_rollup_cell(args: DeployRollupCellArgs) -> Result Result Result Result Result ckb_ .build() } -fn collect_live_cells( - rpc_client_url: &str, - owner_address_str: &str, - max_mature_number: u64, - tip_number: u64, - total_capacity: u64, -) -> Result<(Vec, u64)> { - let number_step = 10000; - let limit = Some(usize::max_value()); - let mut from_number = 0; - let mut to_number = from_number + number_step - 1; - let mut total_input_capacity = 0; - let mut inputs = Vec::new(); - while total_input_capacity < total_capacity { - if from_number > tip_number { - return Err(anyhow!( - "not enough capacity from {}, expected: {}, found: {}", - owner_address_str, - HumanCapacity(total_capacity), - HumanCapacity(total_input_capacity), - )); - } - let new_cells = get_live_cells( - rpc_client_url, - owner_address_str, - max_mature_number, - Some(from_number), - Some(to_number), - limit, - )?; - for (new_input, new_capacity) in new_cells { - total_input_capacity += new_capacity; - inputs.push(new_input); - if total_input_capacity >= total_capacity { - break; - } - } - from_number += number_step; - to_number += number_step; - } - Ok((inputs, total_input_capacity)) -} - -// NOTE: This is an inefficient way to collect cells -fn get_live_cells( - rpc_client_url: &str, - owner_address_str: &str, - max_mature_number: u64, - from_number: Option, - to_number: Option, - limit: Option, -) -> Result> { - let from_number_string = from_number.map(|value| value.to_string()); - let to_number_string = to_number.map(|value| value.to_string()); - let mut actual_limit = limit.unwrap_or(20); - let mut cells = Vec::new(); - while cells.is_empty() { - let limit_string = actual_limit.to_string(); - // wallet get-live-cells --address {address} --fast-mode --limit {limit} --from {from-number} --to {to-number} - let mut args: Vec<&str> = vec![ - "--output-format", - "json", - "--url", - rpc_client_url, - "wallet", - "get-live-cells", - "--address", - owner_address_str, - "--fast-mode", - ]; - if let Some(from_number) = from_number_string.as_ref() { - args.push("--from"); - args.push(from_number.as_str()); - }; - if let Some(to_number) = to_number_string.as_ref() { - args.push("--to"); - args.push(to_number.as_str()); - }; - args.push("--limit"); - args.push(limit_string.as_str()); - - let live_cells_output = run_cmd(args)?; - let live_cells: serde_json::Value = serde_json::from_str(&live_cells_output)?; - cells = live_cells["live_cells"] - .as_array() - .expect("josn live cells") - .iter() - .filter_map(|live_cell| { - /* - { - "capacity": "1200.0 (CKB)", - "data_bytes": 968, - "index": { - "output_index": 0, - "tx_index": 1 - }, - "lock_hash": "0x1cdeae55a5768fe14b628001c6247ae84c70310a7ddcfdc73ac68494251e46ec", - "mature": true, - "number": 6617, - "output_index": 0, - "tx_hash": "0x0d0d63184973ccdaf2c972783e1ed5f984a3e31b971e3294b092e54fe1d86961", - "type_hashes": null - } - */ - let tx_index = live_cell["index"]["tx_index"] - .as_u64() - .expect("live cell tx_index"); - let number = live_cell["number"].as_u64().expect("live cell number"); - let data_bytes = live_cell["data_bytes"] - .as_u64() - .expect("live cell data_bytes"); - let type_is_null = live_cell["type_hashes"].is_null(); - if !type_is_null - || data_bytes > 0 - || !is_mature(number, tx_index, max_mature_number) - { - log::debug!( - "has type: {}, data not empty: {}, immature: {}, number: {}, tx_index: {}", - !type_is_null, - data_bytes > 0, - !is_mature(number, tx_index, max_mature_number), - number, - tx_index, - ); - return None; - } - - let input_tx_hash = H256::from_str( - live_cell["tx_hash"] - .as_str() - .expect("live cell tx hash") - .trim_start_matches("0x"), - ) - .expect("convert to h256"); - let input_index = live_cell["output_index"] - .as_u64() - .expect("live cell output index") as u32; - let capacity = HumanCapacity::from_str( - live_cell["capacity"] - .as_str() - .expect("live cell capacity") - .split(' ') - .next() - .expect("capacity"), - ) - .map(|human_capacity| human_capacity.0) - .expect("parse capacity"); - let out_point = - ckb_packed::OutPoint::new(CKBPack::pack(&input_tx_hash), input_index); - let input = ckb_packed::CellInput::new(out_point, 0); - Some((input, capacity)) - }) - .collect(); - if actual_limit > u32::max_value() as usize / 2 { - log::debug!("Can not find live cells for {}", owner_address_str); - break; - } - actual_limit *= 2; - } - Ok(cells) -} - -// Get max mature block number -pub fn get_max_mature_number(rpc_client: &mut HttpRpcClient) -> Result { - let tip_epoch = rpc_client - .get_tip_header() - .map(|header| EpochNumberWithFraction::from_full_value(header.inner.epoch.0)) - .map_err(|err| anyhow!(err))?; - let tip_epoch_number = tip_epoch.number(); - if tip_epoch_number < 4 { - // No cellbase live cell is mature - Ok(0) - } else { - let max_mature_epoch = rpc_client - .get_epoch_by_number(tip_epoch_number - 4) - .map_err(|err| anyhow!(err))? - .ok_or_else(|| anyhow!("Can not get epoch less than current epoch number"))?; - let start_number = max_mature_epoch.start_number; - let length = max_mature_epoch.length; - Ok(calc_max_mature_number( - tip_epoch, - Some((start_number, length)), - CELLBASE_MATURITY, - )) - } -} - -pub fn is_mature(number: u64, tx_index: u64, max_mature_number: u64) -> bool { - // Not cellbase cell - tx_index > 0 - // Live cells in genesis are all mature - || number == 0 - || number <= max_mature_number -} - pub fn get_secp_data( - rpc_client: &mut HttpRpcClient, + rpc_client: &CkbRpcClient, ) -> Result<(Bytes, gw_jsonrpc_types::blockchain::CellDep)> { let mut cell_dep = None; rpc_client - .get_block_by_number(0) - .map_err(|err| anyhow!(err))? + .get_block_by_number(0.into())? .expect("get CKB genesis block") .transactions .iter() diff --git a/crates/tools/src/deploy_scripts.rs b/crates/tools/src/deploy_scripts.rs index 9468b9d1e..72703c201 100644 --- a/crates/tools/src/deploy_scripts.rs +++ b/crates/tools/src/deploy_scripts.rs @@ -5,7 +5,7 @@ use crate::{ use anyhow::{anyhow, Result}; use ckb_fixed_hash::H256; use ckb_jsonrpc_types::{CellDep, DepType, OutPoint, Script}; -use ckb_sdk::{Address, AddressPayload, HttpRpcClient, HumanCapacity}; +use ckb_sdk::{Address, AddressPayload, CkbRpcClient, HumanCapacity}; use ckb_types::{ bytes::Bytes, core::{Capacity, ScriptHashType}, @@ -25,7 +25,7 @@ struct DeploymentIndex { pub fn deploy_program( privkey_path: &Path, - rpc_client: &mut HttpRpcClient, + rpc_client: &CkbRpcClient, binary_path: &Path, target_lock: &packed::Script, target_address: &Address, @@ -49,17 +49,6 @@ pub fn deploy_program( let target_address_string = target_address.to_string(); let tx_fee_str = "0.1"; - /* ckb-cli - --url {ckb_rpc_url} - wallet transfer - --privkey-path {privkey_path} - --to-address {target_address} - --to-data-path {binary_path} - --capacity {capacity?} - --tx-fee {fee?} - --type-id - --skip-check-to-address - */ log::info!( "file_size: {} bytes, output cell capacity: {} CKB", file_size, @@ -67,7 +56,7 @@ pub fn deploy_program( ); let output = run_cmd(vec![ "--url", - rpc_client.url(), + rpc_client.url.as_str(), "wallet", "transfer", "--privkey-path", @@ -78,7 +67,7 @@ pub fn deploy_program( binary_path.to_str().expect("non-utf8 file path"), "--capacity", capacity_string.as_str(), - "--tx-fee", + "--max-tx-fee", tx_fee_str, "--type-id", "--skip-check-to-address", @@ -116,11 +105,11 @@ pub fn deploy_scripts( )); } - let mut rpc_client = HttpRpcClient::new(ckb_rpc_url.to_string()); - let network_type = get_network_type(&mut rpc_client)?; + let rpc_client = CkbRpcClient::new(ckb_rpc_url); + let network_type = get_network_type(&rpc_client)?; let target_lock = packed::Script::from(scripts_result.lock.clone()); let address_payload = AddressPayload::from(target_lock.clone()); - let target_address = Address::new(network_type, address_payload); + let target_address = Address::new(network_type, address_payload, true); let mut total_file_size = 0; for path in &[ @@ -155,70 +144,70 @@ pub fn deploy_scripts( let custodian_lock = deploy_program( privkey_path, - &mut rpc_client, + &rpc_client, &scripts_result.programs.custodian_lock, &target_lock, &target_address, )?; let deposit_lock = deploy_program( privkey_path, - &mut rpc_client, + &rpc_client, &scripts_result.programs.deposit_lock, &target_lock, &target_address, )?; let withdrawal_lock = deploy_program( privkey_path, - &mut rpc_client, + &rpc_client, &scripts_result.programs.withdrawal_lock, &target_lock, &target_address, )?; let challenge_lock = deploy_program( privkey_path, - &mut rpc_client, + &rpc_client, &scripts_result.programs.challenge_lock, &target_lock, &target_address, )?; let stake_lock = deploy_program( privkey_path, - &mut rpc_client, + &rpc_client, &scripts_result.programs.stake_lock, &target_lock, &target_address, )?; let state_validator = deploy_program( privkey_path, - &mut rpc_client, + &rpc_client, &scripts_result.programs.state_validator, &target_lock, &target_address, )?; let l2_sudt_validator = deploy_program( privkey_path, - &mut rpc_client, + &rpc_client, &scripts_result.programs.l2_sudt_validator, &target_lock, &target_address, )?; let meta_contract_validator = deploy_program( privkey_path, - &mut rpc_client, + &rpc_client, &scripts_result.programs.meta_contract_validator, &target_lock, &target_address, )?; let eth_account_lock = deploy_program( privkey_path, - &mut rpc_client, + &rpc_client, &scripts_result.programs.eth_account_lock, &target_lock, &target_address, )?; let tron_account_lock = deploy_program( privkey_path, - &mut rpc_client, + &rpc_client, &scripts_result.programs.tron_account_lock, &target_lock, &target_address, @@ -226,21 +215,21 @@ pub fn deploy_scripts( // FIXME: write godwoken-polyjuice binary to named temp file then use the path let polyjuice_validator = deploy_program( privkey_path, - &mut rpc_client, + &rpc_client, &scripts_result.programs.polyjuice_validator, &target_lock, &target_address, )?; let state_validator_lock = deploy_program( privkey_path, - &mut rpc_client, + &rpc_client, &scripts_result.programs.state_validator_lock, &target_lock, &target_address, )?; let poa_state = deploy_program( privkey_path, - &mut rpc_client, + &rpc_client, &scripts_result.programs.poa_state, &target_lock, &target_address, diff --git a/crates/tools/src/deposit_ckb.rs b/crates/tools/src/deposit_ckb.rs index eb2638980..60fd342a3 100644 --- a/crates/tools/src/deposit_ckb.rs +++ b/crates/tools/src/deposit_ckb.rs @@ -6,7 +6,7 @@ use crate::utils::transaction::{get_network_type, read_config, run_cmd, wait_for use anyhow::{anyhow, Result}; use ckb_fixed_hash::H256; use ckb_jsonrpc_types::JsonBytes; -use ckb_sdk::{Address, AddressPayload, HttpRpcClient, HumanCapacity, SECP256K1}; +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, @@ -38,14 +38,14 @@ pub async fn deposit_ckb( let scripts_deployment: ScriptsDeploymentResult = serde_json::from_str(&scripts_deployment_content)?; - let config = read_config(&config_path)?; + let config = read_config(config_path)?; let privkey = read_privkey(privkey_path)?; // Using private key to calculate eth address when eth_address not provided. let eth_address_bytes = match eth_address { Some(addr) => { - let addr_vec = hex::decode(&addr.trim_start_matches("0x").as_bytes())?; + let addr_vec = hex::decode(addr.trim_start_matches("0x").as_bytes())?; CKBBytes::from(addr_vec) } None => privkey_to_eth_address(&privkey)?, @@ -97,13 +97,14 @@ pub async fn deposit_ckb( let deposit_lock_code_hash = &scripts_deployment.deposit_lock.script_type_hash; - let mut rpc_client = HttpRpcClient::new(ckb_rpc_url.to_string()); - let network_type = get_network_type(&mut rpc_client)?; - let address_payload = AddressPayload::new_full_type( + let rpc_client = CkbRpcClient::new(ckb_rpc_url); + let network_type = get_network_type(&rpc_client)?; + let address_payload = AddressPayload::new_full( + ScriptHashType::Type, CKBPack::pack(deposit_lock_code_hash), GwBytes::from(l1_lock_args), ); - let address: Address = Address::new(network_type, address_payload); + let address: Address = Address::new(network_type, address_payload, true); let mut godwoken_rpc_client = GodwokenRpcClient::new(godwoken_rpc_url); @@ -115,7 +116,7 @@ pub async fn deposit_ckb( let output = run_cmd(vec![ "--url", - rpc_client.url(), + rpc_client.url.as_str(), "wallet", "transfer", "--privkey-path", @@ -124,14 +125,14 @@ pub async fn deposit_ckb( address.to_string().as_str(), "--capacity", capacity, - "--tx-fee", + "--max-tx-fee", fee, "--skip-check-to-address", ])?; let tx_hash = H256::from_str(output.trim().trim_start_matches("0x"))?; log::info!("tx_hash: {:#x}", tx_hash); - wait_for_tx(&mut rpc_client, &tx_hash, 180u64)?; + wait_for_tx(&rpc_client, &tx_hash, 180u64)?; wait_for_balance_change( &mut godwoken_rpc_client, diff --git a/crates/tools/src/generate_config.rs b/crates/tools/src/generate_config.rs index 166d96432..d4c3a0a87 100644 --- a/crates/tools/src/generate_config.rs +++ b/crates/tools/src/generate_config.rs @@ -4,7 +4,7 @@ use crate::types::{ BuildScriptsResult, RollupDeploymentResult, ScriptsDeploymentResult, UserRollupConfig, }; use anyhow::{anyhow, Result}; -use ckb_sdk::HttpRpcClient; +use ckb_sdk::CkbRpcClient; use ckb_types::prelude::{Builder, Entity}; use gw_config::{ BackendConfig, BlockProducerConfig, ChainConfig, ChallengerConfig, Config, ConsensusConfig, @@ -23,7 +23,6 @@ pub struct GenerateNodeConfigArgs<'a> { pub scripts_deployment: &'a ScriptsDeploymentResult, pub privkey_path: &'a Path, pub ckb_url: String, - pub indexer_url: String, pub database_url: Option<&'a str>, pub build_scripts_result: &'a BuildScriptsResult, pub server_url: String, @@ -37,7 +36,6 @@ pub async fn generate_node_config(args: GenerateNodeConfigArgs<'_>) -> Result) -> Result) -> Result) -> Result) -> Result Result<()> { .takes_value(true) .default_value("http://127.0.0.1:8114") .help("CKB jsonrpc rpc sever URL"); - let arg_indexer_rpc = Arg::with_name("indexer-rpc-url") - .long("ckb-indexer-rpc") - .takes_value(true) - .default_value("http://127.0.0.1:8116") - .required(true) - .help("The URL of ckb indexer"); let arg_deployment_results_path = Arg::with_name("scripts-deployment-path") .long("scripts-deployment-path") .takes_value(true) @@ -161,9 +155,6 @@ async fn run_cli() -> Result<()> { SubCommand::with_name("generate-config") .about("Generate configure") .arg(arg_ckb_rpc.clone()) - .arg( - arg_indexer_rpc.clone() - ) .arg( arg_deployment_results_path.clone() ) @@ -258,7 +249,6 @@ async fn run_cli() -> Result<()> { SubCommand::with_name("update-cell") .about("Update an existed cell") .arg(arg_ckb_rpc.clone()) - .arg(arg_indexer_rpc.clone()) .arg(Arg::with_name("tx-hash").long("tx-hash").takes_value(true).required(true).help("The tx-hash of the exist cell")) .arg(Arg::with_name("index").long("index").takes_value(true).required(true).help("The index of the exist cell")) .arg(Arg::with_name("type-id").long("type-id").takes_value(true).required(true).help("The type-id of the exist cell")) @@ -402,9 +392,6 @@ async fn run_cli() -> Result<()> { SubCommand::with_name("setup") .about("Prepare scripts, deploy scripts, setup nodes, deploy genesis and generate configs") .arg(arg_ckb_rpc.clone()) - .arg( - arg_indexer_rpc.clone() - ) .arg( Arg::with_name("mode") .long("build-mode") @@ -838,7 +825,7 @@ async fn run_cli() -> Result<()> { .subcommand( SubCommand::with_name("stat-custodian-ckb") .about("Output amount of layer2 custodian CKB") - .arg(arg_indexer_rpc.clone()) + .arg(arg_ckb_rpc) .arg( Arg::with_name("rollup-type-hash") .long("rollup-type-hash") @@ -948,7 +935,6 @@ async fn run_cli() -> Result<()> { } ("generate-config", Some(m)) => { let ckb_url = m.value_of("ckb-rpc-url").unwrap().to_string(); - let indexer_url = m.value_of("indexer-rpc-url").unwrap().to_string(); let scripts_results_path = Path::new(m.value_of("scripts-deployment-path").unwrap()); let genesis_path = Path::new(m.value_of("genesis-deployment-path").unwrap()); let user_rollup_config_path = Path::new(m.value_of("user-rollup-config-path").unwrap()); @@ -982,7 +968,6 @@ async fn run_cli() -> Result<()> { build_scripts_result: &build_scripts_result, privkey_path, ckb_url, - indexer_url, database_url, server_url, user_rollup_config: &user_rollup_config, @@ -1025,7 +1010,6 @@ async fn run_cli() -> Result<()> { } ("update-cell", Some(m)) => { let ckb_rpc_url = m.value_of("ckb-rpc-url").unwrap(); - let indexer_rpc_url = m.value_of("indexer-rpc-url").unwrap(); let tx_hash = cli_args::to_h256(m.value_of("tx-hash").unwrap())?; let index: u32 = m.value_of("index").unwrap().parse()?; let type_id = cli_args::to_h256(m.value_of("type-id").unwrap())?; @@ -1038,7 +1022,6 @@ async fn run_cli() -> Result<()> { }; update_cell::update_cell( ckb_rpc_url, - indexer_rpc_url, tx_hash, index, type_id, @@ -1131,7 +1114,6 @@ async fn run_cli() -> Result<()> { } ("setup", Some(m)) => { let ckb_rpc_url = m.value_of("ckb-rpc-url").unwrap(); - let indexer_url = m.value_of("indexer-rpc-url").unwrap(); let setup_config_path = Path::new(m.value_of("setup-config-path").unwrap()); let mode = value_t!(m, "mode", prepare_scripts::ScriptsBuildMode).unwrap(); let wallet_network = value_t!(m, "network", setup::WalletNetwork).unwrap(); @@ -1145,7 +1127,6 @@ async fn run_cli() -> Result<()> { let output_dir = Path::new(m.value_of("output-dir-path").unwrap()); let args = SetupArgs { ckb_rpc_url, - indexer_url, mode, wallet_network, build_scripts_config_path: scripts_path, @@ -1461,14 +1442,14 @@ async fn run_cli() -> Result<()> { }; } ("stat-custodian-ckb", Some(m)) => { - let indexer_rpc_url = m.value_of("indexer-rpc-url").unwrap(); let rollup_type_hash = cli_args::to_h256(m.value_of("rollup-type-hash").unwrap())?; + let ckb_rpc_url = m.value_of("ckb-rpc-url").unwrap(); let custodian_script_type_hash = cli_args::to_h256(m.value_of("custodian-script-type-hash").unwrap())?; let min_capacity: u64 = m.value_of("min-capacity").unwrap_or_default().parse()?; let tip_block_number: u64 = m.value_of("tip-block-number").unwrap_or_default().parse()?; - let rpc_client = CKBIndexerClient::new(HttpClient::new(indexer_rpc_url)?); + let rpc_client = CKBIndexerClient::new(HttpClient::new(ckb_rpc_url)?); let alias: HashMap = [ ( @@ -1494,10 +1475,7 @@ async fn run_cli() -> Result<()> { ] .iter() .map(|(symbol, script_args)| { - ( - hex::decode(&script_args).unwrap().into(), - symbol.to_string(), - ) + (hex::decode(script_args).unwrap().into(), symbol.to_string()) }) .collect(); @@ -1547,7 +1525,7 @@ async fn run_cli() -> Result<()> { let input_path: PathBuf = m.value_of("input").unwrap().into(); let input = std::fs::read_to_string(input_path)?; - let input_data = hex::decode(&input.trim().trim_start_matches("0x"))?; + let input_data = hex::decode(input.trim().trim_start_matches("0x"))?; if input_data.len() <= 32 { return Err(anyhow::anyhow!( "expect input at least 32 bytes length, got: {}", @@ -1587,7 +1565,7 @@ where let output_content = serde_json::to_string_pretty(content).expect("serde json to string pretty"); let output_dir = output_path.parent().expect("get output dir"); - std::fs::create_dir_all(&output_dir).expect("create output dir"); + std::fs::create_dir_all(output_dir).expect("create output dir"); std::fs::write(output_path, output_content.as_bytes()).expect("generate json file"); println!("Generate file {:?}", output_path); } diff --git a/crates/tools/src/prepare_scripts.rs b/crates/tools/src/prepare_scripts.rs index d8d7e4891..7acc1f0ac 100644 --- a/crates/tools/src/prepare_scripts.rs +++ b/crates/tools/src/prepare_scripts.rs @@ -354,7 +354,7 @@ fn collect_scripts_to_target( scripts_info.iter().for_each(|(_, v)| { let target_path = v.target_script_path(target_dir); let source_path = v.source_script_path(repos_dir); - fs::create_dir_all(&target_path.parent().expect("get dir")).expect("create scripts dir"); + fs::create_dir_all(target_path.parent().expect("get dir")).expect("create scripts dir"); log::debug!("copy {:?} to {:?}", source_path, target_path); fs::copy(source_path, target_path).expect("copy script"); }); diff --git a/crates/tools/src/setup.rs b/crates/tools/src/setup.rs index 9913c95e8..ce1d27cac 100644 --- a/crates/tools/src/setup.rs +++ b/crates/tools/src/setup.rs @@ -44,7 +44,6 @@ impl NodeWalletInfo { pub struct SetupArgs<'a> { pub ckb_rpc_url: &'a str, - pub indexer_url: &'a str, pub mode: ScriptsBuildMode, pub build_scripts_config_path: &'a Path, pub privkey_path: &'a Path, @@ -58,7 +57,6 @@ pub struct SetupArgs<'a> { pub async fn setup(args: SetupArgs<'_>) { let SetupArgs { ckb_rpc_url, - indexer_url, mode, build_scripts_config_path, privkey_path, @@ -89,7 +87,7 @@ pub async fn setup(args: SetupArgs<'_>) { let output_content = serde_json::to_string_pretty(&build_scripts_result) .expect("serde json to string pretty"); let output_dir = output_path.parent().expect("get output dir"); - fs::create_dir_all(&output_dir).expect("create output dir"); + fs::create_dir_all(output_dir).expect("create output dir"); fs::write(output_path, output_content.as_bytes()).expect("output config"); build_scripts_result }; @@ -162,7 +160,7 @@ pub async fn setup(args: SetupArgs<'_>) { // generate node config for (index, (node_name, _node_wallet)) in nodes.iter().enumerate() { - let privkey_path = output_dir.join(&node_name).join("pk"); + let privkey_path = output_dir.join(node_name).join("pk"); let output_file_path = output_dir.join(node_name).join("config.toml"); // set the first node to fullnode let node_mode = if index == 0 { @@ -175,7 +173,6 @@ pub async fn setup(args: SetupArgs<'_>) { scripts_deployment: &deploy_scripts_result, privkey_path: &privkey_path, ckb_url: ckb_rpc_url.to_string(), - indexer_url: indexer_url.to_string(), database_url: None, build_scripts_result: &build_scripts_result, server_url: server_url.to_string(), @@ -199,7 +196,7 @@ fn setup_nodes( ) -> Vec<(String, NodeWalletInfo)> { (0..nodes_count) .map(|i| { - let node_name = format!("node{}", (i + 1).to_string()); + let node_name = format!("node{}", i + 1); let node_dir = output_dir.join(&node_name); log::info!("Generate privkey file for {}...", &node_name); let node_pk_path = prepare_privkey(&node_dir); @@ -212,7 +209,7 @@ fn setup_nodes( } fn prepare_privkey(node_dir: &Path) -> PathBuf { - fs::create_dir_all(&node_dir).expect("create node dir"); + fs::create_dir_all(node_dir).expect("create node dir"); let privkey_file = node_dir.join("pk"); generate_privkey_file(&privkey_file); privkey_file @@ -244,7 +241,7 @@ fn generate_poa_config(nodes: &[(String, NodeWalletInfo)]) -> PoAConfig { let identities: Vec<_> = nodes .iter() .map(|(_, node)| { - let lock_hash = hex::decode(&node.lock_hash.trim_start_matches("0x")).unwrap(); + let lock_hash = hex::decode(node.lock_hash.trim_start_matches("0x")).unwrap(); ckb_jsonrpc_types::JsonBytes::from_vec(lock_hash) }) .collect(); @@ -279,7 +276,7 @@ fn generate_rollup_config(setup_config: &SetupConfig) -> Result(); let privkey = format!("0x{}", hex::encode(key)); - fs::write(&privkey_file_path, &privkey).expect("create pk file"); + fs::write(privkey_file_path, privkey).expect("create pk file"); } pub fn get_wallet_info(privkey_path: &Path) -> NodeWalletInfo { @@ -330,7 +327,7 @@ fn transfer_ckb( node_wallet.address(network), "--capacity", &ckb_amount.to_string(), - "--tx-fee", + "--max-tx-fee", "0.1", "--privkey-path", &payer_privkey_path.display().to_string(), diff --git a/crates/tools/src/update_cell.rs b/crates/tools/src/update_cell.rs index 44ca18edd..c00704b77 100644 --- a/crates/tools/src/update_cell.rs +++ b/crates/tools/src/update_cell.rs @@ -1,7 +1,7 @@ -use anyhow::{anyhow, Result}; +use anyhow::{anyhow, Context, Result}; use ckb_jsonrpc_types::OutputsValidator; -use ckb_sdk::HttpRpcClient; -use ckb_types::prelude::{Entity, Unpack as CKBUnpack}; +use ckb_sdk::CkbRpcClient; +use ckb_types::prelude::{Entity, Unpack}; use gw_config::WalletConfig; use gw_rpc_client::indexer_client::CKBIndexerClient; use gw_types::{ @@ -15,25 +15,24 @@ use gw_utils::{ }; use std::path::{Path, PathBuf}; -use crate::utils::transaction::wait_for_tx; +use crate::utils::transaction::{get_transaction, wait_for_tx}; pub async fn update_cell>( ckb_rpc_url: &str, - indexer_rpc_url: &str, tx_hash: [u8; 32], index: u32, type_id: [u8; 32], cell_data_path: P, pk_path: PathBuf, ) -> Result<()> { - let mut rpc_client = HttpRpcClient::new(ckb_rpc_url.to_string()); - let indexer_client = CKBIndexerClient::with_url(indexer_rpc_url)?; + let rpc_client = CkbRpcClient::new(ckb_rpc_url); + let indexer_client = CKBIndexerClient::with_url(ckb_rpc_url)?; // check existed_cell - let tx_with_status = rpc_client - .get_transaction(tx_hash.into()) - .map_err(|err| anyhow!("{}", err))? - .ok_or_else(|| anyhow!("can't found transaction"))?; - let tx = tx_with_status.transaction.inner; + let tx_with_status = get_transaction(&rpc_client, &tx_hash.into())?; + let tx = tx_with_status + .transaction + .context("can't find transaction")? + .inner; let existed_cell = tx .outputs .get(index as usize) @@ -48,7 +47,7 @@ pub async fn update_cell>( .type_ .ok_or_else(|| anyhow!("can't found type_id from existed cell"))? .into(); - let existed_cell_type_id: [u8; 32] = type_.calc_script_hash().unpack(); + let existed_cell_type_id: [u8; 32] = type_.calc_script_hash().unpack().into(); assert_eq!( hex::encode(existed_cell_type_id), hex::encode(type_id), @@ -70,7 +69,7 @@ pub async fn update_cell>( // get genesis info let ckb_genesis_info = { let ckb_genesis = rpc_client - .get_block_by_number(0u64) + .get_block_by_number(0u64.into()) .map_err(|err| anyhow!("{}", err))? .ok_or_else(|| anyhow!("can't found CKB genesis block"))?; let block: ckb_types::core::BlockView = ckb_genesis.into(); @@ -121,12 +120,12 @@ pub async fn update_cell>( println!("Unlock cell {}", existed_cell.lock()); let tx_hash = rpc_client .send_transaction( - ckb_types::packed::Transaction::new_unchecked(tx.as_bytes()), + ckb_types::packed::Transaction::new_unchecked(tx.as_bytes()).into(), Some(OutputsValidator::Passthrough), ) .map_err(|err| anyhow!("{}", err))?; println!("Send tx..."); - wait_for_tx(&mut rpc_client, &tx_hash, 180).map_err(|err| anyhow!("{}", err))?; + wait_for_tx(&rpc_client, &tx_hash, 180).map_err(|err| anyhow!("{}", err))?; println!("{}", update_message); println!("Cell is updated!"); Ok(()) diff --git a/crates/tools/src/utils/transaction.rs b/crates/tools/src/utils/transaction.rs index a6a31addc..b8338f027 100644 --- a/crates/tools/src/utils/transaction.rs +++ b/crates/tools/src/utils/transaction.rs @@ -4,12 +4,11 @@ use anyhow::anyhow; use anyhow::Result; use ckb_fixed_hash::{h256, H256}; -use ckb_jsonrpc_types::Status; -use ckb_sdk::rpc::TransactionView; -use ckb_sdk::HttpRpcClient; -use ckb_sdk::NetworkType; +use ckb_jsonrpc_types::{Status, TransactionView}; +use ckb_sdk::{CkbRpcClient, NetworkType}; use gw_config::Config; use gw_jsonrpc_types::godwoken::TxReceipt; +use gw_rpc_client::ckb_client::TransactionWithStatus; use std::fs; use std::path::Path; use std::time::{Duration, Instant}; @@ -26,9 +25,9 @@ where S: AsRef, { let working_dir = env::current_dir().expect("get working dir"); - env::set_current_dir(&target_dir).expect("set target dir"); + env::set_current_dir(target_dir).expect("set target dir"); let result = run(bin, args); - env::set_current_dir(&working_dir).expect("set working dir"); + env::set_current_dir(working_dir).expect("set working dir"); result } @@ -38,7 +37,7 @@ where S: AsRef, { log::debug!("[Execute]: {} {:?}", bin, args); - let status = Command::new(bin.to_owned()) + let status = Command::new(bin) .env("RUST_BACKTRACE", "full") .args(args) .status() @@ -60,7 +59,7 @@ where { let bin = "ckb-cli"; log::debug!("[Execute]: {} {:?}", bin, args); - let init_output = Command::new(bin.to_owned()) + let init_output = Command::new(bin) .env("RUST_BACKTRACE", "full") .args(args) .output() @@ -79,38 +78,40 @@ where } pub fn wait_for_tx( - rpc_client: &mut HttpRpcClient, + rpc_client: &CkbRpcClient, tx_hash: &H256, timeout_secs: u64, ) -> Result { - log::info!("waiting tx {}", hex::encode(&tx_hash)); + log::info!("waiting tx {}", hex::encode(tx_hash)); let retry_timeout = Duration::from_secs(timeout_secs); let start_time = Instant::now(); while start_time.elapsed() < retry_timeout { std::thread::sleep(Duration::from_secs(5)); - match rpc_client.get_transaction(tx_hash.clone()) { - Ok(Some(tx_with_status)) if tx_with_status.tx_status.status == Status::Pending => { + let tx = get_transaction(rpc_client, tx_hash)?; + match tx.tx_status.status { + Status::Pending => { log::info!("tx pending"); } - Ok(Some(tx_with_status)) if tx_with_status.tx_status.status == Status::Proposed => { + Status::Proposed => { log::info!("tx proposed"); } - Ok(Some(tx_with_status)) if tx_with_status.tx_status.status == Status::Committed => { - log::info!("tx commited"); - return Ok(tx_with_status.transaction); + Status::Unknown => { + log::info!("tx unknown"); + } + Status::Rejected => { + anyhow::bail!("transaction rejected"); } - res => { - log::error!("unexpected response of get_transaction: {:?}", res) + Status::Committed => { + log::info!("tx commited"); + return Ok(tx.transaction.unwrap()); } } } Err(anyhow!("Timeout: {:?}", retry_timeout)) } -pub fn get_network_type(rpc_client: &mut HttpRpcClient) -> Result { - let chain_info = rpc_client - .get_blockchain_info() - .map_err(|err| anyhow!(err))?; +pub fn get_network_type(rpc_client: &CkbRpcClient) -> Result { + let chain_info = rpc_client.get_blockchain_info()?; NetworkType::from_raw_str(chain_info.chain.as_str()) .ok_or_else(|| anyhow!("Unexpected network type: {}", chain_info.chain)) } @@ -121,7 +122,7 @@ where S: AsRef, { log::debug!("[Execute]: {} {:?}", bin, args); - let init_output = Command::new(bin.to_owned()) + let init_output = Command::new(bin) .env("RUST_BACKTRACE", "full") .args(args) .output() @@ -178,3 +179,9 @@ pub fn wait_for_l2_tx( } Err(anyhow!("Timeout: {:?}", retry_timeout)) } + +/// Wrapper for get_transaction that asserts the right type. +pub fn get_transaction(rpc_client: &CkbRpcClient, tx_hash: &H256) -> Result { + let tx = rpc_client.post("get_transaction", [tx_hash])?; + Ok(tx) +} diff --git a/crates/tools/src/withdraw.rs b/crates/tools/src/withdraw.rs index c12ed8fdf..1c6160ad8 100644 --- a/crates/tools/src/withdraw.rs +++ b/crates/tools/src/withdraw.rs @@ -46,7 +46,7 @@ pub async fn withdraw( let mut godwoken_rpc_client = GodwokenRpcClient::new(godwoken_rpc_url); let sell_capacity = u64::MAX; - let config = read_config(&config_path)?; + let config = read_config(config_path)?; let rollup_type_hash = &config.genesis.rollup_type_hash; let is_sudt = sudt_script_hash != H256([0u8; 32]); diff --git a/crates/tools/src/withdraw_to_v1.rs b/crates/tools/src/withdraw_to_v1.rs index 3128a0c28..8f2b4f2e7 100644 --- a/crates/tools/src/withdraw_to_v1.rs +++ b/crates/tools/src/withdraw_to_v1.rs @@ -43,7 +43,7 @@ pub async fn withdraw( config_path: &Path, scripts_deployment_path: &Path, ) -> Result<()> { - let config = read_config(&config_path)?; + let config = read_config(config_path)?; if config.withdrawal_to_v1_config.is_none() { bail!("withdrawal to v1 is disabled"); } @@ -79,7 +79,7 @@ pub async fn withdraw( // v1 l2 lock let v1_l2_lock = { - let eth_address = hex::decode(ð_address.trim_start_matches("0x").as_bytes())?; + let eth_address = hex::decode(eth_address.trim_start_matches("0x").as_bytes())?; let args = { let mut args = v1_config.v1_rollup_type_hash.0.to_vec(); args.extend_from_slice(ð_address); diff --git a/crates/tx-filter/src/erc20_creator_allowlist.rs b/crates/tx-filter/src/erc20_creator_allowlist.rs index 12d3616ee..fbdec661e 100644 --- a/crates/tx-filter/src/erc20_creator_allowlist.rs +++ b/crates/tx-filter/src/erc20_creator_allowlist.rs @@ -2,7 +2,7 @@ use gw_common::H256; use gw_types::offchain::RunResult; use log::debug; -#[derive(Clone)] +#[derive(Clone, Default)] pub struct SUDTProxyAccountAllowlist { allowed_sudt_proxy_creator_account_id: Vec, sudt_proxy_code_hashes: Vec, @@ -53,12 +53,3 @@ impl SUDTProxyAccountAllowlist { true } } - -impl Default for SUDTProxyAccountAllowlist { - fn default() -> Self { - Self { - allowed_sudt_proxy_creator_account_id: vec![], - sudt_proxy_code_hashes: vec![], - } - } -} diff --git a/crates/types/Cargo.toml b/crates/types/Cargo.toml index fa1da7bf5..0195ba922 100644 --- a/crates/types/Cargo.toml +++ b/crates/types/Cargo.toml @@ -14,6 +14,6 @@ std = ["molecule/std", "sparse-merkle-tree/std", "ckb-fixed-hash", "ckb-types"] molecule = { version = "0.7.2", default-features = false } cfg-if = "0.1" gw-hash = { path = "../hash", default-features = false } -ckb-fixed-hash = { version = "0.100.0", optional = true } +ckb-fixed-hash = { version = "0.111.0", optional = true } sparse-merkle-tree = { version = "0.5.2-rc1", default-features = false } -ckb-types = { version = "0.100.0", default-features = false, optional = true } +ckb-types = { version = "0.111.0", default-features = false, optional = true } diff --git a/crates/types/src/conversion/primitive.rs b/crates/types/src/conversion/primitive.rs index a4e8ae66f..9f8a0b66b 100644 --- a/crates/types/src/conversion/primitive.rs +++ b/crates/types/src/conversion/primitive.rs @@ -1,3 +1,5 @@ +use core::convert::TryInto; + use crate::{borrow::ToOwned, str, string::String, vec::Vec}; use crate::{bytes::Bytes, packed, prelude::*}; @@ -32,37 +34,29 @@ impl Pack for usize { } impl<'r> Unpack for packed::Uint16Reader<'r> { - #[allow(clippy::cast_ptr_alignment)] fn unpack(&self) -> u16 { - let le = self.as_slice().as_ptr() as *const u16; - u16::from_le(unsafe { *le }) + u16::from_le_bytes(self.as_slice().try_into().unwrap()) } } impl_conversion_for_entity_unpack!(u16, Uint16); impl<'r> Unpack for packed::Uint32Reader<'r> { - #[allow(clippy::cast_ptr_alignment)] fn unpack(&self) -> u32 { - let le = self.as_slice().as_ptr() as *const u32; - u32::from_le(unsafe { *le }) + u32::from_le_bytes(self.as_slice().try_into().unwrap()) } } impl_conversion_for_entity_unpack!(u32, Uint32); impl<'r> Unpack for packed::Uint64Reader<'r> { - #[allow(clippy::cast_ptr_alignment)] fn unpack(&self) -> u64 { - let le = self.as_slice().as_ptr() as *const u64; - u64::from_le(unsafe { *le }) + u64::from_le_bytes(self.as_slice().try_into().unwrap()) } } impl_conversion_for_entity_unpack!(u64, Uint64); impl<'r> Unpack for packed::Uint128Reader<'r> { - #[allow(clippy::cast_ptr_alignment)] fn unpack(&self) -> u128 { - let le = self.as_slice().as_ptr() as *const u128; - u128::from_le(unsafe { *le }) + u128::from_le_bytes(self.as_slice().try_into().unwrap()) } } impl_conversion_for_entity_unpack!(u128, Uint128); diff --git a/crates/types/src/core.rs b/crates/types/src/core.rs index 987853dd1..42e331443 100644 --- a/crates/types/src/core.rs +++ b/crates/types/src/core.rs @@ -118,18 +118,13 @@ impl TryFrom for ChallengeTargetType { } } -#[derive(Clone, Copy, PartialEq, Eq, Hash)] +#[derive(Clone, Copy, PartialEq, Eq, Hash, Default)] pub enum DepType { + #[default] Code = 0, DepGroup = 1, } -impl Default for DepType { - fn default() -> Self { - DepType::Code - } -} - impl TryFrom for DepType { type Error = u8; diff --git a/crates/types/src/offchain/extension.rs b/crates/types/src/offchain/extension.rs index 8fa615eb4..6a04b951c 100644 --- a/crates/types/src/offchain/extension.rs +++ b/crates/types/src/offchain/extension.rs @@ -41,8 +41,8 @@ impl TxReceipt { .read_data_hashes( run_result .read_data - .into_iter() - .map(|(hash, _)| hash.pack()) + .keys() + .map(|hash| hash.pack()) .collect::>() .pack(), ) diff --git a/crates/types/src/offchain/rpc.rs b/crates/types/src/offchain/rpc.rs index 04253d8a4..433344a5d 100644 --- a/crates/types/src/offchain/rpc.rs +++ b/crates/types/src/offchain/rpc.rs @@ -37,48 +37,19 @@ pub struct InputCellInfo { pub cell: CellInfo, } -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Default)] pub struct CollectedCustodianCells { pub cells_info: Vec, pub capacity: u128, pub sudt: HashMap<[u8; 32], (u128, Script)>, } -impl Default for CollectedCustodianCells { - fn default() -> Self { - CollectedCustodianCells { - cells_info: Default::default(), - capacity: 0, - sudt: Default::default(), - } - } -} - -#[derive(Debug)] +#[derive(Debug, Default)] pub struct WithdrawalsAmount { pub capacity: u128, pub sudt: HashMap<[u8; 32], u128>, } -impl Default for WithdrawalsAmount { - fn default() -> Self { - WithdrawalsAmount { - capacity: 0, - sudt: Default::default(), - } - } -} - -#[derive(Debug, Clone)] -pub enum TxStatus { - /// Status "pending". The transaction is in the pool, and not proposed yet. - Pending, - /// Status "proposed". The transaction is in the pool and has been proposed. - Proposed, - /// Status "committed". The transaction has been committed to the canonical chain. - Committed, -} - #[derive(Debug, Clone, Default)] pub struct DepositInfo { pub request: DepositRequest, diff --git a/crates/version/build.rs b/crates/version/build.rs index 2ea39a0a4..f3e0f8b1a 100644 --- a/crates/version/build.rs +++ b/crates/version/build.rs @@ -1,7 +1,7 @@ fn main() { // get commit id if let Some(commit_id) = std::process::Command::new("git") - .args(&[ + .args([ "describe", "--always", "--match", diff --git a/crates/web3-indexer/Cargo.toml b/crates/web3-indexer/Cargo.toml index 31d59448c..2b317bb7f 100644 --- a/crates/web3-indexer/Cargo.toml +++ b/crates/web3-indexer/Cargo.toml @@ -17,8 +17,8 @@ gw-generator = { path = "../generator" } gw-traits = { path = "../traits" } gw-mem-pool = { path = "../mem-pool" } tokio = "1.15" -ckb-hash = "0.100.0" -ckb-types = "0.100.0" +ckb-hash = "0.111.0" +ckb-types = "0.111.0" anyhow = "1.0" thiserror = "1.0" sqlx = { version = "0.5", features = [ "runtime-tokio-native-tls", "postgres", "sqlite", "chrono", "decimal" ] } diff --git a/crates/web3-indexer/src/types.rs b/crates/web3-indexer/src/types.rs index 5a115ad7d..d0705fe37 100644 --- a/crates/web3-indexer/src/types.rs +++ b/crates/web3-indexer/src/types.rs @@ -90,7 +90,7 @@ impl Transaction { } fn add_chain_replay_protection(&self) -> u64 { - self.v as u64 + self.v + if let Some(n) = self.chain_id { 35 + n * 2 } else { diff --git a/devtools/fetch-binaries.sh b/devtools/fetch-binaries.sh index 19e74076b..20bd3f4d5 100755 --- a/devtools/fetch-binaries.sh +++ b/devtools/fetch-binaries.sh @@ -1,13 +1,8 @@ #!/bin/bash dir_name='.tmp/binaries' -GODWOKEN_TAG=v0.10.3 -docker pull nervos/godwoken-prebuilds:$GODWOKEN_TAG +IMAGE=ghcr.io/nervosnetwork/godwoken-prebuilds:v0.10.7 +docker pull $IMAGE [ -d $dir_name ] && rm -rf $dir_name && echo "Delete old dir" mkdir -p $dir_name && echo "Create dir" -docker run --rm -v $(pwd)/$dir_name:/tmp nervos/godwoken-prebuilds:$GODWOKEN_TAG cp -r /scripts/godwoken-scripts /tmp && echo "Copy scripts" -# TODO: Wait prebuilds update -docker pull ghcr.io/zeroqn/godwoken-prebuilds:dev-feat-fast-withdrawal-to-v1 -docker run --rm -v $(pwd)/$dir_name:/tmp ghcr.io/zeroqn/godwoken-prebuilds:dev-feat-fast-withdrawal-to-v1 cp /scripts/godwoken-scripts/withdrawal-lock /tmp/godwoken-scripts/withdrawal-lock && echo "Override withdrawal-lock" -docker run --rm -v $(pwd)/$dir_name:/tmp ghcr.io/zeroqn/godwoken-prebuilds:dev-feat-fast-withdrawal-to-v1 cp /scripts/godwoken-scripts/state-validator /tmp/godwoken-scripts/state-validator && echo "Override state-validator" +docker run --rm -v $(pwd)/$dir_name:/tmp $IMAGE cp -r /scripts/godwoken-scripts /tmp && echo "Copy scripts" echo "Done" - diff --git a/rust-toolchain b/rust-toolchain index b7921ae87..bfe79d0bd 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -1.54.0 +1.70