diff --git a/.github/workflows/gwos-scripts.yml b/.github/workflows/gwos-scripts.yml new file mode 100644 index 000000000..4b4759b50 --- /dev/null +++ b/.github/workflows/gwos-scripts.yml @@ -0,0 +1,93 @@ +name: Scripts test + +on: + merge_group: + types: [checks_requested] + push: + # TODO: remove this comment + # paths: + # - 'gwos/**' + # - 'crates/tests/src/script_tests/**' + pull_request: + paths: + - 'gwos/**' + - 'crates/tests/src/script_tests/**' + +jobs: + check-c-format: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + # Note: cargo fmt is done in .github/workflows/rust.yml + - name: Check format of gwos/c + working-directory: gwos/c + run: make fmt + + build-gwos-and-test-scripts: + runs-on: ubuntu-22.04 + + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Cache of Cargo + uses: actions/cache@v3 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-${{ runner.arch }}-cargo-gwos-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-${{ runner.arch }}-cargo-gwos + + - name: Install moleculec + run: | + test "$(moleculec --version)" = "Moleculec 0.7.2" \ + || cargo install moleculec --version 0.7.2 --force + - name: Install capsule + env: + CAPSULE_VERSION: v0.7.0 + run: | + (which capsule && test "$(capsule --version)" = "Capsule 0.7.0") \ + || curl -OL https://github.com/nervosnetwork/capsule/releases/download/${CAPSULE_VERSION}/capsule_${CAPSULE_VERSION}_x86_64-linux.tar.gz \ + && tar xf capsule_${CAPSULE_VERSION}_x86_64-linux.tar.gz \ + && mv capsule_${CAPSULE_VERSION}_x86_64-linux/capsule ~/.cargo/bin/ \ + && rm capsule_${CAPSULE_VERSION}_x86_64-linux.tar.gz \ + && rm -rf capsule_${CAPSULE_VERSION}_x86_64-linux/ + capsule --version + + - name: Compile C contracts of gwos + working-directory: gwos/c + run: make + + - uses: actions/cache@v3 + id: fetch-capsule-cache + with: + path: | + gwos/.tmp/capsule-cache.tar + key: ${{ runner.os }}-capsule-cache-${{ hashFiles('contracts/Cargo.lock') }} + + - name: Restore capsule cache + if: steps.fetch-capsule-cache.outputs.cache-hit == 'true' + working-directory: gwos + run: tools/restore-capsule-cache.sh + + - name: Build Rust contracts + working-directory: gwos + run: capsule build + + - name: Backup capsule cache + if: steps.fetch-capsule-cache.outputs.cache-hit != 'true' + working-directory: gwos + run: tools/backup-capsule-cache.sh + + - name: Test C Uint256 + run: cargo test -p c-uint256-tests + - name: Script tests + run: cargo test --features scripts --features gw-config/no-builtin script_tests diff --git a/.github/workflows/scripts.yml b/.github/workflows/scripts.yml deleted file mode 100644 index aaef03518..000000000 --- a/.github/workflows/scripts.yml +++ /dev/null @@ -1,78 +0,0 @@ -name: Scripts test - -on: - merge_group: - types: [checks_requested] - push: - paths: - - 'gwos/**' - - 'crates/tests/src/script_tests/**' - pull_request: - paths: - - 'gwos/**' - - 'crates/tests/src/script_tests/**' - -jobs: - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v1 - - name: Install Rust components - run: rustup component add rustfmt && rustup component add clippy - - uses: actions/cache@v3 - with: - path: | - ~/.cargo/registry - ~/.cargo/git - target - key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }} - - name: Install moleculec - working-directory: gwos - run: CARGO_TARGET_DIR=target/ cargo install moleculec --version 0.7.2 - - name: Install capsule - env: - CAPSULE_VERSION: v0.7.0 - run: curl -OL https://github.com/nervosnetwork/capsule/releases/download/${CAPSULE_VERSION}/capsule_${CAPSULE_VERSION}_x86_64-linux.tar.gz && tar xf capsule_${CAPSULE_VERSION}_x86_64-linux.tar.gz && echo `pwd`/capsule_${CAPSULE_VERSION}_x86_64-linux >> $GITHUB_PATH - - name: Check Tests format - run: cargo fmt --all -- --check - # - name: Check Rust format - # working-directory: gwos/contracts - # run: cargo fmt -- --check - - name: Check C format - working-directory: gwos/c - run: make fmt - - name: Init submodules - run: git submodule init && git submodule update -r - - name: Compile C contracts - working-directory: gwos/c - run: make - #- name: Cargo clippy check - # env: - # RUSTFLAGS: -D warnings - # run: cd contracts && cargo clippy - - uses: actions/cache@v3 - id: fetch-capsule-cache - with: - path: | - gwos/.tmp/capsule-cache.tar - key: ${{ runner.os }}-capsule-cache-${{ hashFiles('contracts/Cargo.lock') }} - - name: Restore capsule cache - if: steps.fetch-capsule-cache.outputs.cache-hit == 'true' - working-directory: gwos - run: tools/restore-capsule-cache.sh - - name: Build Rust contracts - working-directory: gwos - run: capsule build - - name: Backup capsule cache - if: steps.fetch-capsule-cache.outputs.cache-hit != 'true' - working-directory: gwos - run: tools/backup-capsule-cache.sh - # TODO: remove this - - name: Copy contracts from prebuild docker images - run: devtools/fetch-binaries.sh - - name: Test C Uint256 - run: cargo test -p c-uint256-tests - - name: Script tests - run: cargo test --features scripts --features gw-config/no-builtin script_tests diff --git a/Cargo.lock b/Cargo.lock index 99327e601..1df37544f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -386,12 +386,6 @@ dependencies = [ "wyz", ] -[[package]] -name = "blake2b-ref" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95916998c798756098a4eb1b3f2cd510659705a9817bf203d61abd30fbec3e7b" - [[package]] name = "blake2b-ref" version = "0.3.1" @@ -461,9 +455,9 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] name = "bytes" -version = "1.2.1" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec8a7b6a70fde80372154c65702f00a0f56f3e1c36abbc6c440484be248856db" +checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" dependencies = [ "serde", ] @@ -577,9 +571,9 @@ dependencies = [ [[package]] name = "ckb-chain-spec" -version = "0.106.0" +version = "0.111.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fccca15bb20b37f213bda1ff673fc25af8ee2e97f506ffc70de296d068034d63" +checksum = "dbd58081d4ac4f08d068b52c5a07f0b379d93aad0dfa8344c6890429a9b73c2b" dependencies = [ "ckb-constant", "ckb-crypto", @@ -599,24 +593,24 @@ dependencies = [ [[package]] name = "ckb-channel" -version = "0.106.0" +version = "0.111.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e718dfa7098b0bcce95c7fa573d96aad2f4c3ac886b6f35053f40c5e4894156" +checksum = "701e6829c3dcbae46dd2442de63d080046480a6c2bb4951dbf419ad092459402" dependencies = [ "crossbeam-channel", ] [[package]] name = "ckb-constant" -version = "0.106.0" +version = "0.111.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ddc317ee0521b2a176f7197bd1922ee5e757b1c454150cf392baec49c8f31f4" +checksum = "9d5c980d4724770f72a37bceffa26ea64dd914891e45e856e2a3792fdb4a5a18" [[package]] name = "ckb-crypto" -version = "0.106.0" +version = "0.111.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "105a3a011f3d29070d137ea1336d8761951281b39cb90db07b5b752c741b1d0f" +checksum = "df80db694e42b64a5774ae551daff3c8310cd99bb528643dbe0dd409abb298e7" dependencies = [ "ckb-fixed-hash", "faster-hex 0.6.1", @@ -628,9 +622,9 @@ dependencies = [ [[package]] name = "ckb-dao-utils" -version = "0.106.0" +version = "0.111.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "970872ecd2bfe4072051b020b78061c97dfc07e2e8797e73e7b17c238891b91e" +checksum = "5e158ce5a4e9d1fcd08d9dee87332474572c629c6273cca0aea80ba24892a403" dependencies = [ "byteorder", "ckb-error", @@ -639,9 +633,9 @@ dependencies = [ [[package]] name = "ckb-error" -version = "0.106.0" +version = "0.111.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd512b729186e6fa991b588647646e230db7728f71ba16087af21bded12ceb09" +checksum = "34cfd733cabcb4262ee679c02733864b13c8fa879e3aabc078fe0ec727cd95d6" dependencies = [ "anyhow", "ckb-occupied-capacity", @@ -651,9 +645,9 @@ dependencies = [ [[package]] name = "ckb-fixed-hash" -version = "0.106.0" +version = "0.111.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8eba8f7006a63ad0945412012c89af6ad09d9b2b02962a869d0158a298fa8eca" +checksum = "3b1dfab045fffa31cae9680d73e1f09833ca1abfb807dc4b9544739c94c23fd0" dependencies = [ "ckb-fixed-hash-core", "ckb-fixed-hash-macros", @@ -661,9 +655,9 @@ dependencies = [ [[package]] name = "ckb-fixed-hash-core" -version = "0.106.0" +version = "0.111.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44b15b464d37d8deeb66046011b3e01e642103b27d4752db4e74740ded732c73" +checksum = "bdd1727a6ecd4d0bcab604cb1ef707fe92e939fa6e9a438f9f25bf05208cb080" dependencies = [ "faster-hex 0.6.1", "serde", @@ -672,9 +666,9 @@ dependencies = [ [[package]] name = "ckb-fixed-hash-macros" -version = "0.106.0" +version = "0.111.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61e86358f6eb595a0e6a2a5ef96d54d4c56e0a4bf822934d7b1fe9904b7208e4" +checksum = "7b5da34c32585c35715fcde4e3a1dd3b0346d7af43506c5e51c613f01483e4f9" dependencies = [ "ckb-fixed-hash-core", "proc-macro2", @@ -682,21 +676,36 @@ dependencies = [ "syn 1.0.107", ] +[[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", + "ckb-hash", + "ckb-occupied-capacity", + "molecule", + "numext-fixed-uint", +] + [[package]] name = "ckb-hash" -version = "0.106.0" +version = "0.111.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "038ad6840c4a89f4cd76b50621c4e6d82ca5f0d09fba707b1025016218d4a2d8" +checksum = "8c88e5e2d6454be488fa5cf8b49175879353c6af969ff210dd6416f315b53120" dependencies = [ - "blake2b-ref 0.2.1", + "blake2b-ref", "blake2b-rs", ] [[package]] name = "ckb-jsonrpc-types" -version = "0.106.0" +version = "0.111.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eca123e0b725e487cd49f202097c38c73c2a4d7e1c80d89549c492f058e84f29" +checksum = "d789a71538da07871c11aecbd28d6c632bb426bdfeed5fc2fa1b455e31152468" dependencies = [ "ckb-types", "faster-hex 0.6.1", @@ -706,9 +715,9 @@ dependencies = [ [[package]] name = "ckb-logger" -version = "0.106.0" +version = "0.111.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe1d406dd67f086bb64d17af697a4d42c3d7d85e2a677bfd8c04aea4b48510cf" +checksum = "939fa09ca3534248d3d452552546f016fc7e11346644fbc5b55d2ad38d3e80e7" dependencies = [ "log", ] @@ -722,24 +731,11 @@ dependencies = [ "cfg-if 1.0.0", ] -[[package]] -name = "ckb-mock-tx-types" -version = "0.106.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67ac724a6c26076ea122129ed8428730e212a2166cbbe149e1b3112a88798401" -dependencies = [ - "ckb-jsonrpc-types", - "ckb-traits", - "ckb-types", - "serde", - "serde_derive", -] - [[package]] name = "ckb-occupied-capacity" -version = "0.106.0" +version = "0.111.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94f6c146d51b1b7f65511e6f16ef21b0d852aececc4ae87f78c3099c03e246a9" +checksum = "358ad364465a5a359575642c12952ba8735a148382789d65ddd5231cd21899fc" dependencies = [ "ckb-occupied-capacity-core", "ckb-occupied-capacity-macros", @@ -747,18 +743,18 @@ dependencies = [ [[package]] name = "ckb-occupied-capacity-core" -version = "0.106.0" +version = "0.111.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "507187824418c845b519c64521b34578570b5851d170ff0101bc477ed0cdee2b" +checksum = "de2dc06db98f8a995cb7145bc56dbd17bb0c8ab2e59a07aaa40f2c956c2451dd" dependencies = [ "serde", ] [[package]] name = "ckb-occupied-capacity-macros" -version = "0.106.0" +version = "0.111.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17825cb1ec37c5ad2f2c6690aa4cbfeb9a6d2af02463a66b1fa013e4f9e762aa" +checksum = "b1709e0f101026c4ef29b1593692e480b03cdb4e0dace1e348494c6554d50d35" dependencies = [ "ckb-occupied-capacity-core", "quote", @@ -767,9 +763,9 @@ dependencies = [ [[package]] name = "ckb-pow" -version = "0.106.0" +version = "0.111.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3ea66fa0ac3dc84cada2d2696903afb28dbea1211d05f04b0ed444874ee8623" +checksum = "481e76388993d7e6e0dd797e8532c60398901787e28d0638ca114254257b8813" dependencies = [ "byteorder", "ckb-hash", @@ -781,9 +777,9 @@ dependencies = [ [[package]] name = "ckb-rational" -version = "0.106.0" +version = "0.111.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa5edf5377138c9457015a450b1a263996d100a5b6e21566157f410e1a5b95b3" +checksum = "bd3959391a4fb05d6a2578aa8db75732ada1ce381fb34d6eeaf09d395702e63c" dependencies = [ "numext-fixed-uint", "serde", @@ -791,9 +787,9 @@ dependencies = [ [[package]] name = "ckb-resource" -version = "0.106.0" +version = "0.111.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06cd89bd6c5bafeadc363cf0a479516355f16bd5758af4d7dace464d8756892b" +checksum = "03222b0613cf3f55cb181471d7a84879b6fba5e920e2e1c7ba2c2315614bd387" dependencies = [ "ckb-system-scripts", "ckb-types", @@ -806,9 +802,9 @@ dependencies = [ [[package]] name = "ckb-script" -version = "0.106.0" +version = "0.111.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9da7feb35e8997b29f1c987d441a89fb13ba8e429b64e09e1d35dff7b9290a8" +checksum = "8c9075ad901eae97925f491b6be675d7b19bf7b10eaa94a88f6e8070c0cd00ba" dependencies = [ "byteorder", "ckb-chain-spec", @@ -817,7 +813,7 @@ dependencies = [ "ckb-logger", "ckb-traits", "ckb-types", - "ckb-vm", + "ckb-vm 0.24.6", "faster-hex 0.6.1", "serde", ] @@ -837,40 +833,44 @@ dependencies = [ [[package]] name = "ckb-traits" -version = "0.106.0" +version = "0.111.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4697c0acbf62b2994f1c26868cfc005e0ec4fc506849acfb9dc52f10af2a6df2" +checksum = "ca049aba2cb2d1208c6044accb497b17290ad56de629f6a4b95eded67a43fd40" dependencies = [ "ckb-types", ] [[package]] name = "ckb-types" -version = "0.106.0" +version = "0.111.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f9f918d7f04fed733c528ec98ba8bdee31a885bd082e6ff263ca21d58e01378" +checksum = "b6ec737e4957418bbd0f4091e8565a89bbd8f6fc37a20360820e44d1f1e44e58" dependencies = [ "bit-vec", "bytes", "ckb-channel", + "ckb-constant", "ckb-error", "ckb-fixed-hash", + "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.106.0" +version = "0.111.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d60a55b4ad918828bdbf700f1b9949d74768b710c927e19f15282a2320a7ec71" +checksum = "011b907b18aa706fc224a1309f14eadd9cc14c42cf2258ca3010d1324bc20f10" dependencies = [ "linked-hash-map", "once_cell", @@ -880,14 +880,13 @@ dependencies = [ [[package]] name = "ckb-vm" -version = "0.22.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8e8f7ba49aa55d08f8a575b69bc535cad65fdba75fea90856cee1fd3822a7a9" +version = "0.24.1-l2" +source = "git+https://github.com/nervosnetwork/ckb-vm.git?branch=release-0.24-l2#00d1b1852a2cc0f84ac4f2999b3257e8211d539b" dependencies = [ "byteorder", "bytes", "cc", - "ckb-vm-definitions", + "ckb-vm-definitions 0.24.1-l2", "derive_more", "goblin 0.2.3", "goblin 0.4.0", @@ -897,27 +896,36 @@ dependencies = [ ] [[package]] -name = "ckb-vm-aot" -version = "0.22.0" +name = "ckb-vm" +version = "0.24.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97d90662540a6a3b0d71e58d789016efe817d2cd0c4ec6b26bcaf7f9b18fe7cf" +checksum = "0cc004a826b9bc9319ffae0b8415690e1b5f1482266d55fbd43843aa40ddcd63" dependencies = [ + "byteorder", + "bytes", "cc", - "ckb-vm", - "ckb-vm-definitions", + "ckb-vm-definitions 0.24.6", "derive_more", "goblin 0.2.3", "goblin 0.4.0", - "libc", - "memmap2", + "rand 0.7.3", "scroll", + "serde", ] [[package]] name = "ckb-vm-definitions" -version = "0.22.1" +version = "0.24.1-l2" +source = "git+https://github.com/nervosnetwork/ckb-vm.git?branch=release-0.24-l2#00d1b1852a2cc0f84ac4f2999b3257e8211d539b" + +[[package]] +name = "ckb-vm-definitions" +version = "0.24.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5445b62604e7ab2bf5abb37bf6cca7ac26b2e4a76fddb27ceb61850f24864d58" +checksum = "c4ced3ff9d79b53d93c106720f6c1f855694290e33581850e05c859500eee83f" +dependencies = [ + "paste", +] [[package]] name = "clang-sys" @@ -1720,6 +1728,15 @@ dependencies = [ "toml 0.5.9", ] +[[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 = "1.14.0" @@ -1889,8 +1906,7 @@ dependencies = [ "arc-swap", "blake2b-rs", "ckb-types", - "ckb-vm", - "ckb-vm-aot", + "ckb-vm 0.24.1-l2", "ethabi", "goblin 0.4.0", "gw-builtin-binaries", @@ -1919,7 +1935,7 @@ dependencies = [ name = "gw-hash" version = "1.14.0" dependencies = [ - "blake2b-ref 0.3.1", + "blake2b-ref", ] [[package]] @@ -2175,6 +2191,8 @@ dependencies = [ "anyhow", "async-trait", "blake2b-rs", + "bytes", + "ckb-chain-spec", "ckb-crypto", "ckb-error", "ckb-fixed-hash", @@ -2182,7 +2200,6 @@ dependencies = [ "ckb-script", "ckb-traits", "ckb-types", - "ckb-vm", "env_logger", "godwoken-bin", "gw-block-producer", @@ -2226,7 +2243,6 @@ dependencies = [ "ckb-fixed-hash", "ckb-hash", "ckb-jsonrpc-types", - "ckb-mock-tx-types", "ckb-resource", "ckb-script", "ckb-traits", @@ -2968,9 +2984,9 @@ dependencies = [ [[package]] name = "molecule" -version = "0.7.3" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edc8276c02a006bddad7d1c28c1a88f30421e1b5f0ba0ca96ceb8077c7d20c01" +checksum = "d4fd9767ab5e5f2ea40f71ff4c8bdb633c50509052e093c2fdd0e390a749dfa3" dependencies = [ "bytes", "cfg-if 1.0.0", @@ -2979,9 +2995,9 @@ dependencies = [ [[package]] name = "molecule-codegen" -version = "0.7.3" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f57a142d0c94604531998022664c7aebe9d5a8b3ef3806c40fa971acc911678b" +checksum = "1f4e977c547ac5f302a213a2a44daf4748532bf4f2b4fc332c60052b3b72e788" dependencies = [ "case", "molecule", @@ -3430,9 +3446,9 @@ dependencies = [ [[package]] name = "paste" -version = "1.0.8" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9423e2b32f7a043629287a536f21951e8c6a82482d0acb1eeebfc90bc2225b22" +checksum = "b4b27ab7be369122c218afc2079489cdcb4b517c0a3fc386ff11e1fedfcc2b35" [[package]] name = "peeking_take_while" diff --git a/crates/autorocks/rust-toolchain b/crates/autorocks/rust-toolchain index 5deab586f..22d6771a4 100644 --- a/crates/autorocks/rust-toolchain +++ b/crates/autorocks/rust-toolchain @@ -1 +1 @@ -1.68.2 +1.72.1 diff --git a/crates/block-producer/Cargo.toml b/crates/block-producer/Cargo.toml index 1b8e87a6f..319c74cb9 100644 --- a/crates/block-producer/Cargo.toml +++ b/crates/block-producer/Cargo.toml @@ -21,10 +21,10 @@ gw-utils = { path = "../utils" } gw-polyjuice-sender-recover = { path = "../polyjuice-sender-recover" } gw-telemetry = { path = "../telemetry" } gw-metrics = { path = "../metrics" } -ckb-crypto = "0.106" -ckb-fixed-hash = "0.106" -ckb-types = "0.106" -ckb-chain-spec = "0.106" +ckb-crypto = "0.111.0" +ckb-fixed-hash = "0.111.0" +ckb-types = "0.111.0" +ckb-chain-spec = "0.111.0" anyhow = "1.0" serde = { version = "1.0", features = ["derive"] } async-channel = "1.4.2" diff --git a/crates/block-producer/src/cleaner.rs b/crates/block-producer/src/cleaner.rs index 7888d5cfc..0de959705 100644 --- a/crates/block-producer/src/cleaner.rs +++ b/crates/block-producer/src/cleaner.rs @@ -152,9 +152,11 @@ impl Cleaner { let rpc_client = &self.rpc_client; for (idx, tx_hash) in consumed_txs { let consumed = match tx_hash { - Some(tx_hash) => { - !matches!(rpc_client.ckb.get_transaction_status(tx_hash).await?, None) - } + Some(tx_hash) => rpc_client + .ckb + .get_transaction_status(tx_hash) + .await? + .is_some(), None => false, }; if consumed { diff --git a/crates/block-producer/src/runner.rs b/crates/block-producer/src/runner.rs index 8a2962725..650f808de 100644 --- a/crates/block-producer/src/runner.rs +++ b/crates/block-producer/src/runner.rs @@ -374,7 +374,7 @@ 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.hash().unpack(), - Arc::new(Secp256k1Eth::default()), + Arc::new(Secp256k1Eth), ); let mut gen = Generator::new( backend_manage, diff --git a/crates/block-producer/src/withdrawal.rs b/crates/block-producer/src/withdrawal.rs index 6ebb3a450..255044374 100644 --- a/crates/block-producer/src/withdrawal.rs +++ b/crates/block-producer/src/withdrawal.rs @@ -347,7 +347,7 @@ mod test { let sudt_script = Script::new_builder() .code_hash(H256::from_u32(2).pack()) .hash_type(ScriptHashType::Type.into()) - .args(vec![3u8; 32].pack()) + .args([3u8; 32][..].pack()) .build(); let finalized_custodians = CollectedCustodianCells { @@ -358,7 +358,7 @@ mod test { let owner_lock = Script::new_builder() .code_hash(H256::from_u32(4).pack()) - .args(vec![5; 32].pack()) + .args([5; 32][..].pack()) .build(); let withdrawal = { @@ -374,7 +374,7 @@ mod test { .build(); WithdrawalRequest::new_builder() .raw(raw) - .signature(vec![6u8; 65].pack()) + .signature([6u8; 65][..].pack()) .build() }; @@ -460,7 +460,7 @@ mod test { let sudt_script = Script::new_builder() .code_hash(H256::from_u32(3).pack()) .hash_type(ScriptHashType::Type.into()) - .args(vec![4u8; 32].pack()) + .args([4u8; 32][..].pack()) .build(); let rollup_context = RollupContext { @@ -497,7 +497,7 @@ mod test { let owner_lock = Script::new_builder() .code_hash(H256::from_u32(8).pack()) .hash_type(ScriptHashType::Type.into()) - .args(vec![9u8; 32].pack()) + .args([9u8; 32][..].pack()) .build(); let withdrawal_without_owner_lock = { @@ -722,7 +722,7 @@ mod test { let sudt_script = Script::new_builder() .code_hash(H256::from_u32(3).pack()) .hash_type(ScriptHashType::Type.into()) - .args(vec![4u8; 32].pack()) + .args([4u8; 32][..].pack()) .build(); let rollup_config = RollupConfig::new_builder() .l1_sudt_script_type_hash(sudt_script.code_hash()) @@ -793,7 +793,7 @@ mod test { let owner_lock_script = Script::new_builder() .code_hash(H256::from_u32(8).pack()) .hash_type(ScriptHashType::Type.into()) - .args(vec![9u8; 32].pack()) + .args([9u8; 32][..].pack()) .build(); let withdrawal_lock_args = WithdrawalLockArgs::new_builder() .owner_lock_hash(owner_lock_script.hash().pack()) diff --git a/crates/builtin-binaries/Cargo.toml b/crates/builtin-binaries/Cargo.toml index 1ab1e6274..26b5fcc36 100644 --- a/crates/builtin-binaries/Cargo.toml +++ b/crates/builtin-binaries/Cargo.toml @@ -23,6 +23,6 @@ sha2 = "0.10.6" [build-dependencies] includedir_codegen = "0.6.0" -ckb-fixed-hash = "0.106" +ckb-fixed-hash = "0.111.0" anyhow = "1.0" sha2 = "0.10.6" diff --git a/crates/chain/Cargo.toml b/crates/chain/Cargo.toml index eae7d7bac..a6b19f9b3 100644 --- a/crates/chain/Cargo.toml +++ b/crates/chain/Cargo.toml @@ -20,7 +20,7 @@ gw-jsonrpc-types = { path = "../jsonrpc-types" } gw-utils = { path = "../utils" } gw-telemetry = { path = "../telemetry" } gw-metrics = { path = "../metrics" } -ckb-fixed-hash = "0.106" +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 0f51a45ac..991a0942f 100644 --- a/crates/challenge/Cargo.toml +++ b/crates/challenge/Cargo.toml @@ -17,11 +17,11 @@ gw-jsonrpc-types = { path = "../jsonrpc-types" } gw-rpc-client = { path = "../rpc-client" } gw-traits = { path = "../traits" } gw-utils = { path = "../utils" } -ckb-fixed-hash = "0.106" -ckb-types = "0.106" -ckb-script = "0.106" -ckb-traits = "0.106" -ckb-chain-spec = "0.106" +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/offchain/verify_tx.rs b/crates/challenge/src/offchain/verify_tx.rs index 0cef4d3aa..c3631f2a3 100644 --- a/crates/challenge/src/offchain/verify_tx.rs +++ b/crates/challenge/src/offchain/verify_tx.rs @@ -1,12 +1,12 @@ use anyhow::{anyhow, bail, Result}; use ckb_fixed_hash::H256; -use ckb_script::TransactionScriptsVerifier; -use ckb_traits::{CellDataProvider, HeaderProvider}; +use ckb_script::{TransactionScriptsVerifier, TxVerifyEnv}; +use ckb_traits::{CellDataProvider, ExtensionProvider, HeaderProvider}; use ckb_types::{ bytes::Bytes, core::{ cell::{CellMeta, CellMetaBuilder, ResolvedTransaction}, - DepType, HeaderView, + DepType, EpochNumberWithFraction, HeaderView, }, packed::{Byte32, CellDep, CellOutput, OutPoint, OutPointVec}, prelude::*, @@ -17,8 +17,12 @@ use gw_jsonrpc_types::{ }; use gw_types::offchain::InputCellInfo; -use std::collections::{HashMap, HashSet}; -use std::{convert::TryFrom, fs::read, path::PathBuf, sync::Arc}; +use std::{ + collections::{HashMap, HashSet}, + fs::read, + path::PathBuf, + sync::Arc, +}; pub struct TxWithContext { pub cell_deps: Vec, @@ -84,9 +88,20 @@ pub fn verify_tx( data_loader.extend_inputs(tx_with_context.inputs); let resolved_tx = data_loader.resolve_tx(&tx_with_context.tx)?; - let cycles = TransactionScriptsVerifier::new(&resolved_tx, &data_loader) - .verify(max_cycles) - .map_err(|err| anyhow!("verify tx failed: {}", err))?; + let cycles = TransactionScriptsVerifier::new( + Arc::new(resolved_tx), + data_loader, + // Default consensus uses mirana hardfork. + Default::default(), + Arc::new(TxVerifyEnv::new_submit( + &HeaderView::new_advanced_builder() + .number(10000u64.pack()) + .epoch(EpochNumberWithFraction::new(100, 0, 100).pack()) + .build(), + )), + ) + .verify(max_cycles) + .map_err(|err| anyhow!("verify tx failed: {}", err))?; Ok(cycles) } @@ -147,6 +162,7 @@ pub fn dump_tx( Ok(mock_tx) } +#[derive(Clone)] struct TxDataLoader { rollup_cell_deps: Arc>, headers: HashMap, @@ -257,6 +273,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/config/Cargo.toml b/crates/config/Cargo.toml index 9064eb804..9109f0aa8 100644 --- a/crates/config/Cargo.toml +++ b/crates/config/Cargo.toml @@ -13,7 +13,7 @@ no-builtin = ["gw-builtin-binaries/no-builtin"] [dependencies] gw-jsonrpc-types = { path = "../jsonrpc-types" } gw-builtin-binaries = { path = "../builtin-binaries" } -ckb-fixed-hash = "0.106" +ckb-fixed-hash = "0.111.0" serde = { version = "1.0", features = ["derive"] } hex = "0.4" lazy_static = "1.4" diff --git a/crates/generator/Cargo.toml b/crates/generator/Cargo.toml index 147509a50..dbb04b32d 100644 --- a/crates/generator/Cargo.toml +++ b/crates/generator/Cargo.toml @@ -8,7 +8,7 @@ edition = "2021" [features] default = ["detect-asm"] -detect-asm = ["ckb-vm/detect-asm", "ckb-vm-aot"] +detect-asm = ["ckb-vm/detect-asm"] enable-always-success-lock = [] [dependencies] @@ -20,11 +20,11 @@ gw-store = { path = "../store" } gw-traits = { path = "../traits" } gw-utils = { path = "../utils"} gw-jsonrpc-types = { path = "../jsonrpc-types" } -ckb-types = "0.106" +ckb-types = "0.111.0" anyhow = "1.0" blake2b-rs = "0.2" -ckb-vm = { version = "=0.22.1", default-features = false } -ckb-vm-aot = { version = "=0.22", optional = true } +# Use crates.io version if our changes are merged. +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/build.rs b/crates/generator/build.rs index daba3ea17..f0e03b960 100644 --- a/crates/generator/build.rs +++ b/crates/generator/build.rs @@ -6,7 +6,10 @@ fn main() { let is_windows = target_family == "windows"; let is_unix = target_family == "unix"; let is_x86_64 = target_arch == "x86_64"; - let can_enable_asm = is_x86_64 && (is_windows || is_unix); + let is_aarch64 = target_arch == "aarch64"; + let x64_asm = is_x86_64 && (is_windows || is_unix); + let aarch64_asm = is_aarch64 && is_unix; + let can_enable_asm = x64_asm || aarch64_asm; if cfg!(feature = "asm") && (!can_enable_asm) { panic!("asm feature can only be enabled on x86_64 Linux, macOS and Windows platforms!"); diff --git a/crates/generator/src/account_lock_manage/always_success.rs b/crates/generator/src/account_lock_manage/always_success.rs index a232f4e9b..57496b491 100644 --- a/crates/generator/src/account_lock_manage/always_success.rs +++ b/crates/generator/src/account_lock_manage/always_success.rs @@ -16,7 +16,7 @@ pub struct AlwaysSuccess; /// Usage /// register AlwaysSuccess to AccountLockManage /// -/// manage.register_lock_algorithm(code_hash, Box::new(AlwaysSuccess::default())); +/// manage.register_lock_algorithm(code_hash, Box::new(AlwaysSuccess)); impl LockAlgorithm for AlwaysSuccess { fn recover(&self, _message: H256, _signature: &[u8]) -> Result { Ok(Default::default()) diff --git a/crates/generator/src/account_lock_manage/eip712/types.rs b/crates/generator/src/account_lock_manage/eip712/types.rs index 23ba65e96..0b618ef1d 100644 --- a/crates/generator/src/account_lock_manage/eip712/types.rs +++ b/crates/generator/src/account_lock_manage/eip712/types.rs @@ -243,6 +243,7 @@ impl Withdrawal { { ScriptHashType::Data => "data", ScriptHashType::Data1 => "data1", + ScriptHashType::Data2 => "data2", ScriptHashType::Type => "type", }; let address = RegistryAddress::from_address(address)?; @@ -465,9 +466,7 @@ mod tests { buf[64] = v; buf }; - let pubkey_hash = Secp256k1Eth::default() - .recover(message, &signature) - .unwrap(); + let pubkey_hash = Secp256k1Eth.recover(message, &signature).unwrap(); assert_eq!(hex::encode(mail.from.wallet), hex::encode(pubkey_hash)); } @@ -516,9 +515,7 @@ mod tests { }; let message = withdrawal.eip712_message(domain_seperator.hash_struct()); let signature: [u8; 65] = hex::decode("22cae59f1bfaf58f423d1a414cbcaefd45a89dd54c9142fccbb2473c74f4741b45f77f1f3680b8c0b6362957c8d79f96a683a859ccbf22a6cfc1ebc311b936d301").unwrap().try_into().unwrap(); - let pubkey_hash = Secp256k1Eth::default() - .recover(message, &signature) - .unwrap(); + let pubkey_hash = Secp256k1Eth.recover(message, &signature).unwrap(); assert_eq!( "cc3e7fb0176a0e22a7f675306ceeb61d26eb0dc4".to_string(), hex::encode(pubkey_hash) @@ -554,9 +551,7 @@ mod tests { }; let message = tx.eip712_message(domain_seperator.hash_struct()); let signature: [u8; 65] = hex::decode("64b164f5303000c283119974d7ba8f050cc7429984af904134d5cda6d3ce045934cc6b6f513ec939c2ae4cfb9cbee249ba8ae86f6274e4035c150f9c8e634a3a1b").unwrap().try_into().unwrap(); - let pubkey_hash = Secp256k1Eth::default() - .recover(message, &signature) - .unwrap(); + let pubkey_hash = Secp256k1Eth.recover(message, &signature).unwrap(); assert_eq!( "e8ae579256c3b84efb76bbb69cb6bcbef1375f00".to_string(), hex::encode(pubkey_hash) diff --git a/crates/generator/src/account_lock_manage/secp256k1.rs b/crates/generator/src/account_lock_manage/secp256k1.rs index 61a6dfcf0..95a39e154 100644 --- a/crates/generator/src/account_lock_manage/secp256k1.rs +++ b/crates/generator/src/account_lock_manage/secp256k1.rs @@ -107,7 +107,7 @@ impl Secp256k1Eth { /// Usage /// register AlwaysSuccess to AccountLockManage /// -/// manage.register_lock_algorithm(code_hash, Box::new(AlwaysSuccess::default())); +/// manage.register_lock_algorithm(code_hash, Box::new(AlwaysSuccess)); impl LockAlgorithm for Secp256k1Eth { fn recover(&self, message: H256, signature: &[u8]) -> Result { // extract rec_id @@ -319,7 +319,7 @@ mod tests { .raw(raw_tx) .signature(signature.to_vec().pack()) .build(); - let eth = Secp256k1Eth::default(); + let eth = Secp256k1Eth; let rollup_type_hash = vec![0u8; 32]; @@ -354,7 +354,7 @@ mod tests { #[test] fn test_secp256k1_eth_polyjuice_native_token_transfer() { let chain_id = 42; - let mut polyjuice_args = vec![0u8; 72]; + let mut polyjuice_args = [0u8; 72]; polyjuice_args[0..7].copy_from_slice(b"\xFF\xFF\xFFPOLY"); polyjuice_args[7] = 0; let gas_limit: u64 = 21000; @@ -410,7 +410,7 @@ mod tests { .build(), ..Default::default() }; - let eth = Secp256k1Eth::default(); + let eth = Secp256k1Eth; eth.verify_tx(&ctx, sender_reg_addr, sender_script, receive_script, tx) .expect("verify signature"); } @@ -442,7 +442,7 @@ mod tests { .raw(raw_tx) .signature(signature.to_vec().pack()) .build(); - let eth = Secp256k1Eth::default(); + let eth = Secp256k1Eth; // This rollup type hash is used, so the receiver script hash is: // 00002b003de527c1d67f2a2a348683ecc9598647c30884c89c5dcf6da1afbddd, @@ -510,7 +510,7 @@ mod tests { .raw(raw_tx) .signature(signature.to_vec().pack()) .build(); - let eth = Secp256k1Eth::default(); + let eth = Secp256k1Eth; let rollup_type_hash = vec![0u8; 32]; @@ -555,7 +555,7 @@ mod tests { .raw(raw_tx) .signature(signature.to_vec().pack()) .build(); - let eth = Secp256k1Eth::default(); + let eth = Secp256k1Eth; let rollup_type_hash = vec![0u8; 32]; @@ -644,7 +644,7 @@ mod tests { rollup_config: RollupConfig::new_builder().chain_id(0.pack()).build(), ..Default::default() }; - let eth = Secp256k1Eth::default(); + let eth = Secp256k1Eth; eth.verify_tx(&ctx, sender_address, sender_script, receiver_script, tx) .expect("verify signature"); } diff --git a/crates/generator/src/backend_manage.rs b/crates/generator/src/backend_manage.rs index 7dd1f9731..e89001bf0 100644 --- a/crates/generator/src/backend_manage.rs +++ b/crates/generator/src/backend_manage.rs @@ -4,9 +4,6 @@ use anyhow::{bail, Context, Result}; use gw_config::{content_checksum, BackendConfig, BackendForkConfig, BackendType}; use gw_types::{bytes::Bytes, h256::*}; -#[cfg(has_asm)] -use crate::types::vm::AotCode; - #[derive(Clone)] pub struct Backend { pub generator: Bytes, @@ -91,10 +88,6 @@ pub struct BlockConsensus { #[derive(Default)] pub struct BackendManage { backend_forks: Vec<(u64, BlockConsensus)>, - /// define here not in backends, - /// so we don't need to implement the trait `Clone` of AotCode - #[cfg(has_asm)] - aot_codes: HashMap, } impl BackendManage { @@ -188,10 +181,6 @@ impl BackendManage { generator_checksum.into(), generator_debug, )?; - #[cfg(has_asm)] - if compile { - self.compile_backend(&backend); - } log::debug!( "registry backend {:?}({}) at height {}", @@ -210,15 +199,6 @@ impl BackendManage { Ok(()) } - #[cfg(has_asm)] - fn compile_backend(&mut self, backend: &Backend) { - self.aot_codes.insert( - backend.generator_checksum, - self.aot_compile(&backend.generator) - .expect("Ahead-of-time compile"), - ); - } - pub fn get_block_consensus_at_height( &self, block_number: u64, @@ -252,25 +232,6 @@ impl BackendManage { backend }) } - - #[cfg(has_asm)] - fn aot_compile(&self, code_bytes: &Bytes) -> Result { - let vm_version = crate::types::vm::VMVersion::V1; - let mut aot_machine = ckb_vm_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) -> Option<&AotCode> { - log::debug!("get_aot_code hash: {}", hex::encode(code_hash.as_slice()),); - self.aot_codes.get(code_hash) - } } #[cfg(test)] diff --git a/crates/generator/src/generator.rs b/crates/generator/src/generator.rs index e8d9fe9d6..d8f2fc482 100644 --- a/crates/generator/src/generator.rs +++ b/crates/generator/src/generator.rs @@ -262,7 +262,7 @@ impl Generator { let t = Instant::now(); let core_machine = VMVersion::V1.init_core_machine(max_cycles); let machine_builder = DefaultMachineBuilder::new(core_machine) - .syscall(Box::new(L2Syscalls { + .context(L2Syscalls { chain, state, block_info, @@ -272,21 +272,12 @@ impl Generator { account_lock_manage: &self.account_lock_manage, cycles_pool: &mut cycles_pool, context: &mut context, - })) - .instruction_cycle_func(&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.generator_checksum); - #[cfg(has_asm)] - if aot_code_opt.is_none() { - log::warn!("[machine_run] Not AOT mode!"); - } - - #[cfg(has_asm)] - let mut machine = ckb_vm_aot::AotMachine::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); @@ -464,7 +455,7 @@ impl Generator { /// Apply l2 state transition #[instrument(skip_all, fields(block = args.l2block.raw().number().unpack(), deposits_count = args.deposit_info_vec.len()))] - pub fn verify_and_apply_block( + pub fn verify_and_apply_block( &self, db: &mut StoreTransaction, chain: &C, diff --git a/crates/generator/src/syscalls/mod.rs b/crates/generator/src/syscalls/mod.rs index e7705e904..426c8e083 100644 --- a/crates/generator/src/syscalls/mod.rs +++ b/crates/generator/src/syscalls/mod.rs @@ -9,7 +9,7 @@ use crate::{ use ckb_vm::{ memory::Memory, registers::{A0, A1, A2, A3, A4, A5, A7}, - Error as VMError, Register, SupportMachine, Syscalls, + Error as VMError, ExecutionContext, Register, SupportMachine, }; use gw_common::{ blake2b::new_blake2b, @@ -166,13 +166,9 @@ pub fn store_data(machine: &mut Mac, data: &[u8]) -> Result Ok(real_size) } -impl<'a, 'b, S: State + CodeStore + JournalDB, C: ChainView, Mac: SupportMachine> Syscalls - for L2Syscalls<'a, 'b, S, C> +impl<'a, 'b, S: State + CodeStore + JournalDB, C: ChainView, Mac: SupportMachine> + ExecutionContext for L2Syscalls<'a, 'b, S, C> { - fn initialize(&mut self, _machine: &mut Mac) -> Result<(), VMError> { - Ok(()) - } - fn ecall(&mut self, machine: &mut Mac) -> Result { let code = machine.registers()[A7].to_u64(); diff --git a/crates/generator/src/types/vm.rs b/crates/generator/src/types/vm.rs index 214dd2610..82088acd9 100644 --- a/crates/generator/src/types/vm.rs +++ b/crates/generator/src/types/vm.rs @@ -71,9 +71,6 @@ impl VMVersion { } } -#[cfg(has_asm)] -pub(crate) use ckb_vm_aot::AotCode; - #[derive(Debug, Clone, Eq, PartialEq)] pub struct ChallengeContext { pub target: ChallengeTarget, diff --git a/crates/generator/src/utils.rs b/crates/generator/src/utils.rs index 41b4ed0f8..9a904c43f 100644 --- a/crates/generator/src/utils.rs +++ b/crates/generator/src/utils.rs @@ -166,11 +166,11 @@ mod test { }; let sudt_script = Script::new_builder() .code_hash(H256::from_u32(1).pack()) - .args(vec![3; 32].pack()) + .args([3; 32][..].pack()) .build(); let owner_lock = Script::new_builder() .code_hash(H256::from_u32(4).pack()) - .args(vec![5; 32].pack()) + .args([5; 32][..].pack()) .build(); // ## Fulfill withdrawal request @@ -187,7 +187,7 @@ mod test { .build(); WithdrawalRequest::new_builder() .raw(raw) - .signature(vec![6u8; 65].pack()) + .signature([6u8; 65][..].pack()) .build() }; let withdrawal = WithdrawalRequestExtra::new_builder() @@ -291,7 +291,7 @@ mod test { let err_owner_lock = Script::new_builder() .code_hash([100u8; 32].pack()) .hash_type(ScriptHashType::Data.into()) - .args(vec![99u8; 32].pack()) + .args([99u8; 32][..].pack()) .build(); let err = build_withdrawal_cell_output( &rollup_context, diff --git a/crates/generator/src/vm_cost_model.rs b/crates/generator/src/vm_cost_model.rs index 9172e62c2..fe2ad8f26 100644 --- a/crates/generator/src/vm_cost_model.rs +++ b/crates/generator/src/vm_cost_model.rs @@ -21,14 +21,15 @@ 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, + // We are only using version 1 VM. + 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/godwoken-bin/Cargo.toml b/crates/godwoken-bin/Cargo.toml index 16d16b806..00a4f077b 100644 --- a/crates/godwoken-bin/Cargo.toml +++ b/crates/godwoken-bin/Cargo.toml @@ -8,7 +8,7 @@ edition = "2021" [dependencies] anyhow = "1.0" -ckb-types = "0.106" +ckb-types = "0.111.0" clap = { version = "3", features = ["derive"] } indicatif = "0.16" gw-block-producer = { path = "../block-producer" } diff --git a/crates/jsonrpc-types/Cargo.toml b/crates/jsonrpc-types/Cargo.toml index 34a0d1e54..e2c2deb6f 100644 --- a/crates/jsonrpc-types/Cargo.toml +++ b/crates/jsonrpc-types/Cargo.toml @@ -11,8 +11,8 @@ serde = { version = "1.0", features = ["derive"] } faster-hex = "0.4" gw-types = { path = "../../gwos/crates/types" } gw-common = { path = "../../gwos/crates/common" } -ckb-jsonrpc-types = "0.106" -ckb-fixed-hash = "0.106" +ckb-jsonrpc-types = "0.111.0" +ckb-fixed-hash = "0.111.0" anyhow = "1.0" serde_repr = "0.1.10" serde_json = "1.0.94" diff --git a/crates/mem-pool/src/block_sync_server.rs b/crates/mem-pool/src/block_sync_server.rs index eeb1e0e61..5be37c897 100644 --- a/crates/mem-pool/src/block_sync_server.rs +++ b/crates/mem-pool/src/block_sync_server.rs @@ -106,7 +106,7 @@ impl BlockSyncServerState { .transaction(tx) .build(); let msg = BlockSync::new_builder().set(msg).build(); - if let Some((_, messages)) = self.buffer.iter_mut().rev().next() { + if let Some((_, messages)) = self.buffer.iter_mut().next_back() { // The first message is either a LocalBlock or a NextMemBlock. We // only need to buffer it for NextMemBlock. if matches!( diff --git a/crates/mem-pool/src/restore_manager.rs b/crates/mem-pool/src/restore_manager.rs index 8c60a63d8..77c521455 100644 --- a/crates/mem-pool/src/restore_manager.rs +++ b/crates/mem-pool/src/restore_manager.rs @@ -265,10 +265,10 @@ mod tests { // Should able to restore from deprecated compact mem block let deprecated = DeprecatedCompactMemBlock::new_builder() - .txs(vec![[1u8; 32]].pack()) + .txs([[1u8; 32]][..].pack()) .build(); let expected = CompactMemBlock::new_builder() - .txs(vec![[1u8; 32]].pack()) + .txs([[1u8; 32]][..].pack()) .build(); let latest_timestamp = SystemTime::now() diff --git a/crates/mem-pool/src/withdrawal.rs b/crates/mem-pool/src/withdrawal.rs index 87bdabe76..472166d21 100644 --- a/crates/mem-pool/src/withdrawal.rs +++ b/crates/mem-pool/src/withdrawal.rs @@ -341,7 +341,7 @@ mod test { let sudt_script = Script::new_builder() .code_hash(H256::from_u32(2).pack()) - .args(vec![3u8; 32].pack()) + .args([3u8; 32][..].pack()) .build(); let available_custodians = FinalizedCustodianCapacity { @@ -353,7 +353,7 @@ mod test { let owner_lock = Script::new_builder() .code_hash(H256::from_u32(4).pack()) - .args(vec![5; 32].pack()) + .args([5; 32][..].pack()) .build(); let req = { @@ -369,7 +369,7 @@ mod test { .build(); WithdrawalRequest::new_builder() .raw(raw) - .signature(vec![6u8; 65].pack()) + .signature([6u8; 65][..].pack()) .build() }; @@ -415,7 +415,7 @@ mod test { let err_req_extra = { let err_owner_lock = Script::new_builder() .code_hash([100u8; 32].pack()) - .args(vec![99u8; 32].pack()) + .args([99u8; 32][..].pack()) .build(); req_extra .clone() diff --git a/crates/polyjuice-sender-recover/src/recover/eth_sender.rs b/crates/polyjuice-sender-recover/src/recover/eth_sender.rs index 1cd8530b8..59f64201c 100644 --- a/crates/polyjuice-sender-recover/src/recover/eth_sender.rs +++ b/crates/polyjuice-sender-recover/src/recover/eth_sender.rs @@ -107,7 +107,7 @@ fn recover_registry_address( let message = Secp256k1Eth::polyjuice_tx_signing_message(ctx.chain_id, raw_tx, &to_script) .map_err(PolyjuiceTxSenderRecoverError::InvalidSignature)?; - let eth_address = Secp256k1Eth::default() + let eth_address = Secp256k1Eth .recover(message, signature) .map_err(|err| PolyjuiceTxSenderRecoverError::InvalidSignature(err.into()))?; let registry_address = RegistryAddress::new(ETH_REGISTRY_ACCOUNT_ID, eth_address.to_vec()); diff --git a/crates/replay-chain/Cargo.toml b/crates/replay-chain/Cargo.toml index 2c15b64ed..9a0e9349c 100644 --- a/crates/replay-chain/Cargo.toml +++ b/crates/replay-chain/Cargo.toml @@ -19,8 +19,8 @@ gw-jsonrpc-types = { path = "../jsonrpc-types" } gw-rpc-client = { path = "../rpc-client" } gw-utils = { path = "../utils" } clap = "3" -ckb-fixed-hash = "0.106" -ckb-types = "0.106" +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/setup.rs b/crates/replay-chain/src/setup.rs index fb2a59dbc..3e7f4b4b9 100644 --- a/crates/replay-chain/src/setup.rs +++ b/crates/replay-chain/src/setup.rs @@ -108,7 +108,7 @@ 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.hash().unpack(), - Arc::new(Secp256k1Eth::default()), + Arc::new(Secp256k1Eth), ); Arc::new(Generator::new( backend_manage, diff --git a/crates/rpc-client/Cargo.toml b/crates/rpc-client/Cargo.toml index 534dd423f..c73b50b31 100644 --- a/crates/rpc-client/Cargo.toml +++ b/crates/rpc-client/Cargo.toml @@ -11,8 +11,8 @@ gw-common = { path = "../../gwos/crates/common" } gw-config = { path = "../config" } gw-types = { path = "../../gwos/crates/types" } gw-jsonrpc-types = { path = "../jsonrpc-types" } -ckb-fixed-hash = "0.106" -ckb-types = "0.106" +ckb-fixed-hash = "0.111.0" +ckb-types = "0.111.0" anyhow = "1.0" serde = { version = "1.0", features = ["derive"] } log = "0.4.14" diff --git a/crates/rpc-client/src/withdrawal.rs b/crates/rpc-client/src/withdrawal.rs index 11b9a6b2f..218ca8d70 100644 --- a/crates/rpc-client/src/withdrawal.rs +++ b/crates/rpc-client/src/withdrawal.rs @@ -92,7 +92,7 @@ mod test { let owner_lock = Script::new_builder() .code_hash(H256::from_u32(1).pack()) .hash_type(ScriptHashType::Type.into()) - .args(vec![2u8; 32].pack()) + .args([2u8; 32][..].pack()) .build(); let rollup_type_hash = [3u8; 32]; @@ -186,7 +186,7 @@ mod test { // # owner lock not match let err_owner_lock = Script::new_builder() .code_hash(H256::from_u32(5).pack()) - .args(vec![7u8; 32].pack()) + .args([7u8; 32][..].pack()) .build(); let mut args = rollup_type_hash.to_vec(); args.extend_from_slice(&lock_args.as_bytes()); @@ -209,13 +209,13 @@ mod test { let owner_lock = Script::new_builder() .code_hash(H256::from_u32(1).pack()) .hash_type(ScriptHashType::Type.into()) - .args(vec![2u8; 32].pack()) + .args([2u8; 32][..].pack()) .build(); let l1_sudt = Script::new_builder() .code_hash(H256::from_u32(3).pack()) .hash_type(ScriptHashType::Type.into()) - .args(vec![4u8; 32].pack()) + .args([4u8; 32][..].pack()) .build(); let last_finalized_timepoint = Timepoint::from_block_number(100); diff --git a/crates/rpc-server/Cargo.toml b/crates/rpc-server/Cargo.toml index a8ee4ea56..38dfc1953 100644 --- a/crates/rpc-server/Cargo.toml +++ b/crates/rpc-server/Cargo.toml @@ -25,9 +25,9 @@ gw-rpc-client = { path = "../rpc-client" } gw-telemetry = { path = "../telemetry" } gw-metrics = { path = "../metrics" } faster-hex = "0.4" -ckb-crypto = "0.106" -ckb-fixed-hash = "0.106" -ckb-types = "0.106" +ckb-crypto = "0.111.0" +ckb-fixed-hash = "0.111.0" +ckb-types = "0.111.0" anyhow = "1.0" serde = { version = "1.0", features = ["derive"] } futures = "0.3.13" diff --git a/crates/store/src/state/overlay/mem_store.rs b/crates/store/src/state/overlay/mem_store.rs index dd171cbe9..28e3e6600 100644 --- a/crates/store/src/state/overlay/mem_store.rs +++ b/crates/store/src/state/overlay/mem_store.rs @@ -105,7 +105,7 @@ impl HistoryStateStore for MemStore { .collect(), None => HashSet::new(), }; - list.extend(self.inner.iter_block_state_record(block_number).into_iter()); + list.extend(self.inner.iter_block_state_record(block_number)); list } diff --git a/crates/tests/Cargo.toml b/crates/tests/Cargo.toml index d762e24fb..97895a9a8 100644 --- a/crates/tests/Cargo.toml +++ b/crates/tests/Cargo.toml @@ -29,19 +29,19 @@ gw-builtin-binaries = { path = "../builtin-binaries" } godwoken-bin = { path = "../godwoken-bin" } anyhow = "1.0" blake2b-rs = "0.2" -ckb-vm = { version = "=0.22.1", default-features = false } thiserror = "1.0" lazy_static = "1.4" secp256k1 = { version = "0.24", features = ["recovery", "rand-std"] } sha3 = "0.10.6" hex = "0.4.2" -ckb-script = "0.106" -ckb-types = "0.106" -ckb-error = "0.106" -ckb-crypto = "0.106" -ckb-hash = "0.106" -ckb-traits = "0.106" -ckb-fixed-hash = "0.106" +ckb-script = "0.111.0" +ckb-chain-spec = "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" rand = "0.8" serde = "1.0" serde_json = "1.0" @@ -50,3 +50,4 @@ env_logger = "0.9" tempfile = "3" async-trait = "0.1" jsonrpc-core = "18.0.0" +bytes = "1.4.0" diff --git a/crates/tests/src/script_tests/account_lock_scripts/eth_account_lock.rs b/crates/tests/src/script_tests/account_lock_scripts/eth_account_lock.rs index 238cd6c49..8a36582be 100644 --- a/crates/tests/src/script_tests/account_lock_scripts/eth_account_lock.rs +++ b/crates/tests/src/script_tests/account_lock_scripts/eth_account_lock.rs @@ -5,7 +5,7 @@ use crate::script_tests::utils::layer1::*; use crate::testing_tool::chain::{ALWAYS_SUCCESS_CODE_HASH, ALWAYS_SUCCESS_PROGRAM}; use ckb_crypto::secp::{Generator, Privkey, Pubkey}; use ckb_error::assert_error_eq; -use ckb_script::{ScriptError, TransactionScriptsVerifier}; +use ckb_script::ScriptError; use ckb_types::{ bytes::Bytes, core::{Capacity, DepType, ScriptHashType, TransactionBuilder, TransactionView}, @@ -16,8 +16,6 @@ use gw_types::core::SigningType; use rand::{thread_rng, Rng}; use sha3::{Digest, Keccak256}; -use std::convert::TryInto; - const ERROR_WRONG_SIGNATURE: i8 = 41; fn gen_tx( @@ -227,11 +225,7 @@ fn test_sign_eth_message() { .as_bytes() .pack()]) .build(); - let resolved_tx = build_resolved_tx(&data_loader, &tx); - let mut verifier = TransactionScriptsVerifier::new(&resolved_tx, &data_loader); - verifier.set_debug_printer(|_script, msg| println!("[script debug] {}", msg)); - let verify_result = verifier.verify(MAX_CYCLES); - verify_result.expect("pass verification"); + data_loader.verify_tx(&tx).expect("pass verification"); } #[test] @@ -271,11 +265,8 @@ fn test_submit_signing_eth_message() { .as_bytes() .pack()]) .build(); - let resolved_tx = build_resolved_tx(&data_loader, &tx); - let mut verifier = TransactionScriptsVerifier::new(&resolved_tx, &data_loader); - verifier.set_debug_printer(|_script, msg| println!("[script debug] {}", msg)); - let verify_result = verifier.verify(MAX_CYCLES); - verify_result.expect("pass verification"); + + data_loader.verify_tx(&tx).expect("pass verification"); } #[test] @@ -312,10 +303,7 @@ fn test_wrong_signature() { .as_bytes() .pack()]) .build(); - let resolved_tx = build_resolved_tx(&data_loader, &tx); - let mut verifier = TransactionScriptsVerifier::new(&resolved_tx, &data_loader); - verifier.set_debug_printer(|_script, msg| println!("[script debug] {}", msg)); - let verify_result = verifier.verify(MAX_CYCLES); + let verify_result = data_loader.verify_tx(&tx); let script_cell_index = 0; assert_error_eq!( verify_result.unwrap_err(), diff --git a/crates/tests/src/script_tests/delegate_cell_lock.rs b/crates/tests/src/script_tests/delegate_cell_lock.rs index fc214e9e1..2163e01ad 100644 --- a/crates/tests/src/script_tests/delegate_cell_lock.rs +++ b/crates/tests/src/script_tests/delegate_cell_lock.rs @@ -96,8 +96,7 @@ fn test_delegate_cell_lock_case(case: Case) { }; let witness = witness_args.as_bytes().pack(); - let mut tx = ckb_types::packed::Transaction::default() - .as_advanced_builder() + let mut tx = ckb_types::core::TransactionView::new_advanced_builder() .input(CellInput::new_builder().previous_output(input).build()) .witness(witness) .cell_dep( diff --git a/crates/tests/src/script_tests/l2_scripts/examples.rs b/crates/tests/src/script_tests/l2_scripts/examples.rs index 25841de82..af80c084b 100644 --- a/crates/tests/src/script_tests/l2_scripts/examples.rs +++ b/crates/tests/src/script_tests/l2_scripts/examples.rs @@ -98,8 +98,7 @@ fn test_example_sum() { }]) .unwrap(); let mut account_lock_manage = AccountLockManage::default(); - account_lock_manage - .register_lock_algorithm(H256::zero(), Arc::new(AlwaysSuccess::default())); + account_lock_manage.register_lock_algorithm(H256::zero(), Arc::new(AlwaysSuccess)); let rollup_context = RollupContext { rollup_config: Default::default(), rollup_script_hash: [42u8; 32], @@ -238,7 +237,7 @@ fn test_example_account_operation() { }]) .unwrap(); let mut account_lock_manage = AccountLockManage::default(); - account_lock_manage.register_lock_algorithm(H256::zero(), Arc::new(AlwaysSuccess::default())); + account_lock_manage.register_lock_algorithm(H256::zero(), Arc::new(AlwaysSuccess)); let rollup_context = RollupContext { rollup_config: RollupConfig::new_builder() .allowed_contract_type_hashes( @@ -478,8 +477,7 @@ fn test_example_recover_account() { .unwrap(); let mut account_lock_manage = AccountLockManage::default(); let secp256k1_code_hash = H256::from_u32(11); - account_lock_manage - .register_lock_algorithm(secp256k1_code_hash, Arc::new(Secp256k1Eth::default())); + account_lock_manage.register_lock_algorithm(secp256k1_code_hash, Arc::new(Secp256k1Eth)); let rollup_script_hash: H256 = [42u8; 32]; let rollup_context = RollupContext { rollup_config: RollupConfig::new_builder() @@ -661,10 +659,8 @@ fn test_sudt_total_supply() { }]) .unwrap(); let mut account_lock_manage = AccountLockManage::default(); - account_lock_manage.register_lock_algorithm( - *ALWAYS_SUCCESS_CODE_HASH, - Arc::new(AlwaysSuccess::default()), - ); + account_lock_manage + .register_lock_algorithm(*ALWAYS_SUCCESS_CODE_HASH, Arc::new(AlwaysSuccess)); let rollup_context = RollupContext { rollup_config, rollup_script_hash: [42u8; 32], diff --git a/crates/tests/src/script_tests/l2_scripts/meta_contract.rs b/crates/tests/src/script_tests/l2_scripts/meta_contract.rs index d0e123650..39e069a63 100644 --- a/crates/tests/src/script_tests/l2_scripts/meta_contract.rs +++ b/crates/tests/src/script_tests/l2_scripts/meta_contract.rs @@ -116,7 +116,7 @@ fn test_duplicated_script_hash() { // create contract let contract_script = Script::new_builder() .code_hash([0u8; 32].pack()) - .args(vec![42].pack()) + .args([42][..].pack()) .hash_type(ScriptHashType::Type.into()) .build(); diff --git a/crates/tests/src/script_tests/l2_scripts/sudt.rs b/crates/tests/src/script_tests/l2_scripts/sudt.rs index 372057305..e17a6e9ee 100644 --- a/crates/tests/src/script_tests/l2_scripts/sudt.rs +++ b/crates/tests/src/script_tests/l2_scripts/sudt.rs @@ -3,7 +3,7 @@ use crate::script_tests::utils::context::TestingContext; use crate::testing_tool::chain::SUDT_VALIDATOR_SCRIPT_TYPE_HASH; use super::{check_transfer_logs, new_block_info, run_contract, run_contract_get_result}; -use ckb_vm::Bytes; +use bytes::Bytes; use gw_common::builtins::CKB_SUDT_ACCOUNT_ID; use gw_common::registry_address::RegistryAddress; use gw_common::state::State; diff --git a/crates/tests/src/script_tests/l2_scripts_validator/consume_challenge_resolve_cell.rs b/crates/tests/src/script_tests/l2_scripts_validator/consume_challenge_resolve_cell.rs index 1d711e812..3d5e3215b 100644 --- a/crates/tests/src/script_tests/l2_scripts_validator/consume_challenge_resolve_cell.rs +++ b/crates/tests/src/script_tests/l2_scripts_validator/consume_challenge_resolve_cell.rs @@ -4,7 +4,6 @@ //! once the challenge gets resolved, others need to be able to consume thier //! challenge resolve cell and get CKB back. -use ckb_script::TransactionScriptsVerifier; use gw_types::{ bytes::Bytes, packed::{CellDep, CellInput, CellOutput}, @@ -14,10 +13,7 @@ use gw_types::{ use crate::{ script_tests::{ programs::{META_CONTRACT_CODE_HASH, META_CONTRACT_VALIDATOR_PROGRAM}, - utils::layer1::{ - build_resolved_tx, build_simple_tx_with_out_point, random_out_point, DummyDataLoader, - MAX_CYCLES, - }, + utils::layer1::{build_simple_tx_with_out_point, random_out_point, DummyDataLoader}, }, testing_tool::chain::{ALWAYS_SUCCESS_CODE_HASH, ALWAYS_SUCCESS_PROGRAM}, }; @@ -93,8 +89,5 @@ fn test_consume_challenge_resolve_cell() { .cell_dep(CellDep::new_builder().out_point(script_out_point).build()) .cell_dep(CellDep::new_builder().out_point(lock_out_point).build()) .build(); - let resolved_tx = build_resolved_tx(&ctx, &tx); - let mut verifier = TransactionScriptsVerifier::new(&resolved_tx, &ctx); - verifier.set_debug_printer(|_script, msg| println!("[script debug] {}", msg)); - verifier.verify(MAX_CYCLES).expect("success"); + ctx.verify_tx(&tx).expect("success"); } diff --git a/crates/tests/src/script_tests/state_validator/cancel_challenge/tx_signature.rs b/crates/tests/src/script_tests/state_validator/cancel_challenge/tx_signature.rs index 03e09743b..425600605 100644 --- a/crates/tests/src/script_tests/state_validator/cancel_challenge/tx_signature.rs +++ b/crates/tests/src/script_tests/state_validator/cancel_challenge/tx_signature.rs @@ -371,7 +371,7 @@ async fn test_cancel_tx_signature() { .lock(sender_script) .capacity(CKBPack::pack(&42u64)) .build(); - let owner_lock_hash = vec![42u8; 32]; + let owner_lock_hash = [42u8; 32]; let message = { let typed_tx = eip712::types::L2Transaction::from_raw( &tx.raw(), diff --git a/crates/tests/src/script_tests/state_validator/submit_block.rs b/crates/tests/src/script_tests/state_validator/submit_block.rs index 727afb104..b8b212f76 100644 --- a/crates/tests/src/script_tests/state_validator/submit_block.rs +++ b/crates/tests/src/script_tests/state_validator/submit_block.rs @@ -1281,7 +1281,7 @@ async fn test_withdrawal_cell_lock_args_with_owner_lock_in_submit_block() { construct_block_with_timestamp( &chain, &mut mem_pool, - vec![deposit.clone()].pack(), + [deposit.clone()].pack(), timestamp_now(), true, ) @@ -1291,7 +1291,7 @@ async fn test_withdrawal_cell_lock_args_with_owner_lock_in_submit_block() { let apply_deposits = L1Action { context: L1ActionContext::SubmitBlock { l2block: block_result.block.clone(), - deposit_info_vec: vec![deposit].pack(), + deposit_info_vec: [deposit].pack(), deposit_asset_scripts: Default::default(), withdrawals: Default::default(), }, diff --git a/crates/tests/src/script_tests/utils/layer1.rs b/crates/tests/src/script_tests/utils/layer1.rs index 024e1867f..67662e4ce 100644 --- a/crates/tests/src/script_tests/utils/layer1.rs +++ b/crates/tests/src/script_tests/utils/layer1.rs @@ -1,15 +1,19 @@ -use ckb_traits::{CellDataProvider, HeaderProvider}; +use std::{collections::HashMap, sync::Arc, time::Duration}; + +use ckb_chain_spec::consensus::ConsensusBuilder; +use ckb_script::{TransactionScriptsVerifier, TxVerifyEnv}; +use ckb_traits::{CellDataProvider, ExtensionProvider, HeaderProvider}; use ckb_types::{ bytes::Bytes, core::{ cell::{CellMetaBuilder, ResolvedTransaction}, - EpochExt, HeaderView, ScriptHashType, TransactionView, + hardfork::HardForks, + EpochExt, EpochNumberWithFraction, HeaderView, ScriptHashType, TransactionView, }, packed::{Byte32, CellInput, CellOutput, OutPoint, Script, Transaction, Uint64}, prelude::*, }; use rand::{thread_rng, Rng}; -use std::{collections::HashMap, time::Duration}; use crate::testing_tool::chain::ALWAYS_SUCCESS_CODE_HASH; @@ -17,7 +21,7 @@ use crate::testing_tool::chain::ALWAYS_SUCCESS_CODE_HASH; pub const SINCE_BLOCK_TIMESTAMP_FLAG: u64 = 0x4000_0000_0000_0000; pub const MAX_CYCLES: u64 = std::u64::MAX; -#[derive(Default)] +#[derive(Default, Clone)] pub struct DummyDataLoader { pub cells: HashMap, pub headers: HashMap, @@ -43,6 +47,15 @@ impl HeaderProvider for DummyDataLoader { } } +impl ExtensionProvider for DummyDataLoader { + fn get_block_extension( + &self, + _hash: &ckb_types::packed::Byte32, + ) -> Option { + None + } +} + pub fn always_success_script() -> Script { Script::new_builder() .code_hash(ALWAYS_SUCCESS_CODE_HASH.pack()) @@ -153,3 +166,27 @@ pub fn build_resolved_tx( resolved_dep_groups: vec![], } } + +impl DummyDataLoader { + pub fn verify_tx(self, tx: &TransactionView) -> Result { + let resolved_tx = build_resolved_tx(&self, tx); + // Test with ckb 2023. + let consensus = ConsensusBuilder::default() + .hardfork_switch(HardForks::new_dev()) + .build(); + let tx_env = TxVerifyEnv::new_submit( + &HeaderView::new_advanced_builder() + .number(10000u64.pack()) + .epoch(EpochNumberWithFraction::new(100, 0, 100).pack()) + .build(), + ); + let mut verifier = TransactionScriptsVerifier::new( + Arc::new(resolved_tx), + self, + Arc::new(consensus), + Arc::new(tx_env), + ); + verifier.set_debug_printer(|_script, msg| println!("[script debug] {}", msg)); + verifier.verify(MAX_CYCLES) + } +} diff --git a/crates/tests/src/script_tests/utils/rollup.rs b/crates/tests/src/script_tests/utils/rollup.rs index 4eafb24aa..6cd4706dd 100644 --- a/crates/tests/src/script_tests/utils/rollup.rs +++ b/crates/tests/src/script_tests/utils/rollup.rs @@ -2,10 +2,9 @@ use crate::script_tests::programs::{ CHALLENGE_LOCK_PROGRAM, ETH_ACCOUNT_LOCK_PROGRAM, SECP256K1_DATA, STATE_VALIDATOR_PROGRAM, }; use crate::script_tests::utils::layer1::{ - always_success_script, build_resolved_tx, random_out_point, DummyDataLoader, MAX_CYCLES, + always_success_script, random_out_point, DummyDataLoader, }; use crate::testing_tool::chain::{ALWAYS_SUCCESS_CODE_HASH, ALWAYS_SUCCESS_PROGRAM}; -use ckb_script::TransactionScriptsVerifier; use ckb_traits::CellDataProvider; use ckb_types::{ packed::{CellDep, CellOutput}, @@ -267,10 +266,7 @@ impl CellContext { &self, tx: ckb_types::core::TransactionView, ) -> Result { - let resolved_tx = build_resolved_tx(&self.inner, &tx); - let mut verifier = TransactionScriptsVerifier::new(&resolved_tx, &self.inner); - verifier.set_debug_printer(|_script, msg| println!("[script debug] {}", msg)); - verifier.verify(MAX_CYCLES) + self.inner.clone().verify_tx(&tx) } pub fn rollup_config(&self) -> RollupConfig { diff --git a/crates/tests/src/testing_tool/chain.rs b/crates/tests/src/testing_tool/chain.rs index 8014812a7..0fb774610 100644 --- a/crates/tests/src/testing_tool/chain.rs +++ b/crates/tests/src/testing_tool/chain.rs @@ -222,10 +222,8 @@ impl TestChain { let mut account_lock_manage = AccountLockManage::default(); account_lock_manage .register_lock_algorithm(*ALWAYS_SUCCESS_CODE_HASH, Arc::new(AlwaysSuccess)); - account_lock_manage.register_lock_algorithm( - *ETH_ACCOUNT_LOCK_CODE_HASH, - Arc::new(Secp256k1Eth::default()), - ); + account_lock_manage + .register_lock_algorithm(*ETH_ACCOUNT_LOCK_CODE_HASH, Arc::new(Secp256k1Eth)); let restore_path = { let mem_pool = chain.mem_pool().as_ref().unwrap(); @@ -392,10 +390,8 @@ pub async fn setup_chain(rollup_type_script: Script) -> Chain { .chain_id(TEST_CHAIN_ID.pack()) .build(); account_lock_manage.register_lock_algorithm(*ALWAYS_SUCCESS_CODE_HASH, Arc::new(AlwaysSuccess)); - account_lock_manage.register_lock_algorithm( - *ETH_ACCOUNT_LOCK_CODE_HASH, - Arc::new(Secp256k1Eth::default()), - ); + account_lock_manage + .register_lock_algorithm(*ETH_ACCOUNT_LOCK_CODE_HASH, Arc::new(Secp256k1Eth)); let chain = setup_chain_with_account_lock_manage( rollup_type_script, rollup_config, @@ -415,10 +411,8 @@ pub async fn setup_chain_with_config( ) -> Chain { let mut account_lock_manage = AccountLockManage::default(); account_lock_manage.register_lock_algorithm(*ALWAYS_SUCCESS_CODE_HASH, Arc::new(AlwaysSuccess)); - account_lock_manage.register_lock_algorithm( - *ETH_ACCOUNT_LOCK_CODE_HASH, - Arc::new(Secp256k1Eth::default()), - ); + account_lock_manage + .register_lock_algorithm(*ETH_ACCOUNT_LOCK_CODE_HASH, Arc::new(Secp256k1Eth)); setup_chain_with_account_lock_manage( rollup_type_script, rollup_config, @@ -439,10 +433,8 @@ pub async fn restart_chain( let mut account_lock_manage = AccountLockManage::default(); let rollup_config = chain.generator().rollup_context().rollup_config.to_owned(); account_lock_manage.register_lock_algorithm(*ALWAYS_SUCCESS_CODE_HASH, Arc::new(AlwaysSuccess)); - account_lock_manage.register_lock_algorithm( - *ETH_ACCOUNT_LOCK_CODE_HASH, - Arc::new(Secp256k1Eth::default()), - ); + account_lock_manage + .register_lock_algorithm(*ETH_ACCOUNT_LOCK_CODE_HASH, Arc::new(Secp256k1Eth)); let restore_path = { let mem_pool = chain.mem_pool().as_ref().unwrap(); let mem_pool = mem_pool.lock().await; @@ -467,10 +459,8 @@ pub fn chain_generator(chain: &Chain, rollup_type_script: Script) -> Arc Result data_loader.extend_inputs(tx_with_context.inputs); let resolved_tx = data_loader.resolve_tx(&tx_with_context.tx)?; - let cycles = TransactionScriptsVerifier::new(&resolved_tx, &data_loader) - .verify(max_cycles) - .map_err(|err| anyhow!("verify tx failed: {}", err))?; + // Test with ckb 2023. + let consensus = ConsensusBuilder::default() + .hardfork_switch(HardForks::new_dev()) + .build(); + let tx_env = TxVerifyEnv::new_submit( + &HeaderView::new_advanced_builder() + .number(10000u64.pack()) + .epoch(EpochNumberWithFraction::new(100, 0, 100).pack()) + .build(), + ); + let cycles = TransactionScriptsVerifier::new( + Arc::new(resolved_tx), + data_loader, + Arc::new(consensus), + Arc::new(tx_env), + ) + .verify(max_cycles) + .map_err(|err| anyhow!("verify tx failed: {}", err))?; Ok(cycles) } +#[derive(Clone)] struct TxDataLoader { headers: HashMap, cell_deps: HashMap, @@ -138,6 +156,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/export_import_block.rs b/crates/tests/src/tests/export_import_block.rs index 5f66989d0..11c7aaf01 100644 --- a/crates/tests/src/tests/export_import_block.rs +++ b/crates/tests/src/tests/export_import_block.rs @@ -46,7 +46,7 @@ async fn test_export_import_block() { let sudt_script = Script::new_builder() .code_hash(always_type.hash().pack()) .hash_type(ScriptHashType::Type.into()) - .args(vec![rand::random::(), 32].pack()) + .args([rand::random::(), 32][..].pack()) .build(); let withdrawal_lock_type = random_always_success_script(None); @@ -76,7 +76,7 @@ async fn test_export_import_block() { let rollup_type_script = Script::new_builder() .code_hash(state_validator_type.hash().pack()) .hash_type(ScriptHashType::Type.into()) - .args(vec![1u8; 32].pack()) + .args([1u8; 32][..].pack()) .build(); let rollup_script_hash: H256 = rollup_type_script.hash(); @@ -102,10 +102,8 @@ async fn test_export_import_block() { let mut account_lock_manage = AccountLockManage::default(); account_lock_manage .register_lock_algorithm(*ALWAYS_SUCCESS_CODE_HASH, Arc::new(AlwaysSuccess)); - account_lock_manage.register_lock_algorithm( - *ETH_ACCOUNT_LOCK_CODE_HASH, - Arc::new(Secp256k1Eth::default()), - ); + account_lock_manage + .register_lock_algorithm(*ETH_ACCOUNT_LOCK_CODE_HASH, Arc::new(Secp256k1Eth)); setup_chain_with_account_lock_manage( rollup_type_script.clone(), rollup_config.clone(), @@ -154,7 +152,7 @@ async fn test_export_import_block() { context: L1ActionContext::SubmitBlock { l2block: deposit_block_result.block.clone(), deposit_info_vec, - deposit_asset_scripts: HashSet::from_iter(vec![sudt_script.clone()].into_iter()), + deposit_asset_scripts: HashSet::from_iter([sudt_script.clone()]), withdrawals: Default::default(), }, transaction: build_sync_tx(rollup_cell.output.clone(), deposit_block_result.clone()), @@ -202,10 +200,8 @@ async fn test_export_import_block() { let mut account_lock_manage = AccountLockManage::default(); account_lock_manage .register_lock_algorithm(*ALWAYS_SUCCESS_CODE_HASH, Arc::new(AlwaysSuccess)); - account_lock_manage.register_lock_algorithm( - *ETH_ACCOUNT_LOCK_CODE_HASH, - Arc::new(Secp256k1Eth::default()), - ); + account_lock_manage + .register_lock_algorithm(*ETH_ACCOUNT_LOCK_CODE_HASH, Arc::new(Secp256k1Eth)); setup_chain_with_account_lock_manage( rollup_type_script.clone(), rollup_config.clone(), @@ -282,10 +278,8 @@ async fn test_export_import_block() { let mut account_lock_manage = AccountLockManage::default(); account_lock_manage .register_lock_algorithm(*ALWAYS_SUCCESS_CODE_HASH, Arc::new(AlwaysSuccess)); - account_lock_manage.register_lock_algorithm( - *ETH_ACCOUNT_LOCK_CODE_HASH, - Arc::new(Secp256k1Eth::default()), - ); + account_lock_manage + .register_lock_algorithm(*ETH_ACCOUNT_LOCK_CODE_HASH, Arc::new(Secp256k1Eth)); setup_chain_with_account_lock_manage( rollup_type_script.clone(), rollup_config.clone(), diff --git a/crates/tests/src/tests/restore_mem_block.rs b/crates/tests/src/tests/restore_mem_block.rs index 2fc43b235..11a77e1a7 100644 --- a/crates/tests/src/tests/restore_mem_block.rs +++ b/crates/tests/src/tests/restore_mem_block.rs @@ -8,7 +8,7 @@ use crate::testing_tool::common::random_always_success_script; use crate::testing_tool::mem_pool_provider::DummyMemPoolProvider; use crate::testing_tool::rpc_server::RPCServer; -use ckb_vm::Bytes; +use bytes::Bytes; use gw_common::builtins::ETH_REGISTRY_ACCOUNT_ID; use gw_common::registry_address::RegistryAddress; use gw_common::state::State; diff --git a/crates/tests/src/tests/unlock_withdrawal_to_owner.rs b/crates/tests/src/tests/unlock_withdrawal_to_owner.rs index e60b09459..40a2eff83 100644 --- a/crates/tests/src/tests/unlock_withdrawal_to_owner.rs +++ b/crates/tests/src/tests/unlock_withdrawal_to_owner.rs @@ -63,7 +63,7 @@ async fn test_build_unlock_to_owner_tx() { let sudt_script = Script::new_builder() .code_hash(always_type.hash().pack()) .hash_type(ScriptHashType::Type.into()) - .args(vec![rand::random::(), 32].pack()) + .args([rand::random::(), 32][..].pack()) .build(); let withdrawal_lock_type = random_always_success_script(None); @@ -161,7 +161,7 @@ async fn test_build_unlock_to_owner_tx() { let rollup_type_script = Script::new_builder() .code_hash(state_validator_type.hash().pack()) .hash_type(ScriptHashType::Type.into()) - .args(vec![1u8; 32].pack()) + .args([1u8; 32][..].pack()) .build(); let rollup_script_hash: H256 = rollup_type_script.hash(); let rollup_cell = CellInfo { diff --git a/crates/tools/Cargo.toml b/crates/tools/Cargo.toml index a26e36889..32e91d11c 100644 --- a/crates/tools/Cargo.toml +++ b/crates/tools/Cargo.toml @@ -18,14 +18,14 @@ lazy_static = "1.4" secp256k1 = "0.24" sha3 = "0.10.6" reqwest = { version = "0.11", features = ["json", "blocking"] } -ckb-jsonrpc-types = "0.106" -ckb-types = "0.106" -ckb-resource = "0.106" -ckb-hash = "0.106" -ckb-fixed-hash = "0.106" -ckb-crypto = "0.106" -ckb-traits = "0.106" -ckb-dao-utils = "0.106" +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-crypto = "0.111.0" +ckb-traits = "0.111.0" +ckb-dao-utils = "0.111.0" gw-types = { path = "../../gwos/crates/types" } gw-config = { path = "../config" } gw-common = { path = "../../gwos/crates/common" } @@ -48,8 +48,7 @@ parking_lot = "0.12" toml = "0.7.1" [dev-dependencies] -ckb-chain-spec = "0.106" -ckb-script = "0.106" -ckb-mock-tx-types = "0.106" +ckb-chain-spec = "0.111.0" +ckb-script = "0.111.0" [features] diff --git a/crates/tools/src/deploy_genesis.rs b/crates/tools/src/deploy_genesis.rs index 5aee75ebb..c6ac3e856 100644 --- a/crates/tools/src/deploy_genesis.rs +++ b/crates/tools/src/deploy_genesis.rs @@ -97,7 +97,7 @@ pub async fn deploy_rollup_cell(args: DeployRollupCellArgs<'_>) -> Result) -> Result = HashSet::from_iter(&user_rollup_config.allowed_eoa_type_hashes); diff --git a/crates/tools/src/prepare_scripts.rs b/crates/tools/src/prepare_scripts.rs index 16ae3f77f..11d04de5e 100644 --- a/crates/tools/src/prepare_scripts.rs +++ b/crates/tools/src/prepare_scripts.rs @@ -1,3 +1,6 @@ +// Useless vec is from the arg_enum macro. +#![allow(clippy::useless_vec)] + use std::{ collections::HashMap, fs, diff --git a/crates/tools/src/setup.rs b/crates/tools/src/setup.rs index 9d38557e7..9f0c9428f 100644 --- a/crates/tools/src/setup.rs +++ b/crates/tools/src/setup.rs @@ -1,3 +1,6 @@ +// Useless vec is from the arg_enum macro. +#![allow(clippy::useless_vec)] + use std::{ fs, path::{Path, PathBuf}, @@ -104,6 +107,7 @@ pub async fn setup(args: SetupArgs<'_>) { let scripts_deploy_result = output_dir.join("scripts-result.json"); let deploy_result = deploy_scripts( // TODO. + #[allow(clippy::unnecessary_literal_unwrap)] None.unwrap(), &build_scripts_result, ) @@ -170,6 +174,7 @@ pub async fn setup(args: SetupArgs<'_>) { NodeMode::ReadOnly }; // TODO. + #[allow(clippy::unnecessary_literal_unwrap)] let args = None.unwrap(); generate_node_config(args).await.expect("generate_config"); } diff --git a/crates/tools/src/utils/sdk/types/address.rs b/crates/tools/src/utils/sdk/types/address.rs index 007e7601a..77ee510db 100644 --- a/crates/tools/src/utils/sdk/types/address.rs +++ b/crates/tools/src/utils/sdk/types/address.rs @@ -109,6 +109,7 @@ impl AddressPayload { (ScriptHashType::Data, true) => AddressType::Full, (ScriptHashType::Type, true) => AddressType::Full, (ScriptHashType::Data1, _) => AddressType::Full, + (ScriptHashType::Data2, _) => AddressType::Full, (ScriptHashType::Data, false) => AddressType::FullData, (ScriptHashType::Type, false) => AddressType::FullType, }, @@ -222,6 +223,7 @@ impl fmt::Debug for AddressPayload { ScriptHashType::Type => "type", ScriptHashType::Data => "data", ScriptHashType::Data1 => "data1", + ScriptHashType::Data2 => "data2", }; f.debug_struct("AddressPayload") .field("hash_type", &hash_type) @@ -317,6 +319,7 @@ impl fmt::Debug for Address { ScriptHashType::Type => "type", ScriptHashType::Data => "data", ScriptHashType::Data1 => "data1", + ScriptHashType::Data2 => "data2", }; f.debug_struct("Address") .field("network", &self.network) diff --git a/crates/utils/Cargo.toml b/crates/utils/Cargo.toml index a3aa64b86..c0b11c7dd 100644 --- a/crates/utils/Cargo.toml +++ b/crates/utils/Cargo.toml @@ -15,14 +15,14 @@ gw-jsonrpc-types = { path = "../jsonrpc-types" } gw-store = { path = "../store" } anyhow = "1.0" faster-hex = "0.4" -ckb-crypto = "0.106" +ckb-crypto = "0.111.0" sha2 = "0.10.6" sha3 = "0.10.6" secp256k1 = "0.24" log = "0.4" rand = { version = "0.8.5", features = ["min_const_gen"] } -ckb-types = "0.106" -ckb-chain-spec = "0.106" +ckb-types = "0.111.0" +ckb-chain-spec = "0.111.0" tokio = "1" zstd = "0.11.2" ethabi = { version = "18.0.0", default-features = false, features = ["thiserror", "std"] } diff --git a/crates/utils/src/genesis_info.rs b/crates/utils/src/genesis_info.rs index 6c8354cc9..610ac53f9 100644 --- a/crates/utils/src/genesis_info.rs +++ b/crates/utils/src/genesis_info.rs @@ -59,7 +59,7 @@ impl CKBGenesisInfo { raw_tx .outputs() .into_iter() - .zip(raw_tx.outputs_data().into_iter()) + .zip(raw_tx.outputs_data()) .enumerate() .map(|(index, (output, data))| { let data_hash: H256 = { diff --git a/gwos-evm/polyjuice-tests/Cargo.toml b/gwos-evm/polyjuice-tests/Cargo.toml index bf14a825c..fb4fd7216 100644 --- a/gwos-evm/polyjuice-tests/Cargo.toml +++ b/gwos-evm/polyjuice-tests/Cargo.toml @@ -22,8 +22,7 @@ gw-builtin-binaries = { path = "../../crates/builtin-binaries" } #### #Sync patch version with godwoken core. tracing = { version = "0.1.36", features = ["attributes"] } -ckb-vm = { version = "=0.22.1", default-features = false } -ckb-vm-aot = { version = "=0.22" } +ckb-vm = { git = "https://github.com/nervosnetwork/ckb-vm.git", branch = "release-0.24-l2" } #### lazy_static = "1.4" diff --git a/gwos-evm/polyjuice-tests/fuzz/gw-syscall-simulator/Cargo.toml b/gwos-evm/polyjuice-tests/fuzz/gw-syscall-simulator/Cargo.toml index cc84f7c11..a9729f716 100644 --- a/gwos-evm/polyjuice-tests/fuzz/gw-syscall-simulator/Cargo.toml +++ b/gwos-evm/polyjuice-tests/fuzz/gw-syscall-simulator/Cargo.toml @@ -16,9 +16,6 @@ gw-store = { path = "../../../../crates/store/" } gw-utils = { path = "../../../../crates/utils/" } gw-config = { path = "../../../../crates/config/", features = ["no-builtin"] } gw-traits = { path = "../../../../crates/traits/" } - -ckb-vm = { version = "=0.22.1", default-features = false } -ckb-vm-aot = { version = "=0.22" } once_cell = "1.14.0" anyhow = "1.0" hex = "0.4" diff --git a/gwos-evm/polyjuice-tests/src/ctx.rs b/gwos-evm/polyjuice-tests/src/ctx.rs index 1c673787b..4c3a18e3e 100644 --- a/gwos-evm/polyjuice-tests/src/ctx.rs +++ b/gwos-evm/polyjuice-tests/src/ctx.rs @@ -80,7 +80,7 @@ fn load_code_hash(path: &Path) -> [u8; 32] { fn set_mapping(state: &mut DummyState, eth_address: &[u8; 20], script_hash: &[u8; 32]) { let address = RegistryAddress::new(ETH_REGISTRY_ACCOUNT_ID, eth_address.to_vec()); state - .mapping_registry_address_to_script_hash(address, (*script_hash).into()) + .mapping_registry_address_to_script_hash(address, *script_hash) .expect("map reg addr to script hash"); } @@ -159,7 +159,7 @@ impl MockChain { code: &[u8], storage: HashMap, ) -> anyhow::Result { - let mut new_script_args = vec![0u8; 32 + 4 + 20]; + let mut new_script_args = [0u8; 32 + 4 + 20]; new_script_args[0..32].copy_from_slice(&ROLLUP_SCRIPT_HASH); new_script_args[32..36].copy_from_slice(&CREATOR_ACCOUNT_ID.to_le_bytes()[..]); new_script_args[36..36 + 20].copy_from_slice(eth_address); @@ -400,7 +400,7 @@ impl Context { .expect("create creator_account"); assert_eq!(creator_account_id, CREATOR_ACCOUNT_ID); - state.insert_data(config.secp_data_hash.into(), config.secp_data.clone()); + state.insert_data(config.secp_data_hash, config.secp_data.clone()); state .update_raw( build_data_hash_key(config.secp_data_hash.as_slice()), @@ -413,11 +413,11 @@ impl Context { // NOTICE in this test we won't need SUM validator let mut account_lock_manage = AccountLockManage::default(); account_lock_manage.register_lock_algorithm( - SECP_LOCK_CODE_HASH.into(), - Arc::new(Secp256k1Eth::default()), + SECP_LOCK_CODE_HASH, + Arc::new(Secp256k1Eth), ); let rollup_context = RollupContext { - rollup_script_hash: ROLLUP_SCRIPT_HASH.into(), + rollup_script_hash: ROLLUP_SCRIPT_HASH, rollup_config: config.rollup, fork_config: Default::default(), }; diff --git a/gwos-evm/polyjuice-tests/src/helper.rs b/gwos-evm/polyjuice-tests/src/helper.rs index daf3bdebb..b1e9d7d64 100644 --- a/gwos-evm/polyjuice-tests/src/helper.rs +++ b/gwos-evm/polyjuice-tests/src/helper.rs @@ -92,7 +92,7 @@ lazy_static::lazy_static! { let mut hasher = new_blake2b(); hasher.update(SECP_DATA); hasher.finalize(&mut buf); - buf.into() + buf }; pub static ref POLYJUICE_GENERATOR_PROGRAM: Bytes @@ -292,7 +292,7 @@ pub fn new_contract_account_script_with_nonce(from_addr: &[u8; 20], from_nonce: // ); let data_hash = tiny_keccak::keccak256(stream.as_raw()); - let mut new_script_args = vec![0u8; 32 + 4 + 20]; + let mut new_script_args = [0u8; 32 + 4 + 20]; new_script_args[0..32].copy_from_slice(&ROLLUP_SCRIPT_HASH); new_script_args[32..36].copy_from_slice(&CREATOR_ACCOUNT_ID.to_le_bytes()[..]); new_script_args[36..36 + 20].copy_from_slice(&data_hash[12..]); @@ -480,8 +480,8 @@ pub fn setup() -> (Store, DummyState, Generator) { // NOTICE in this test we won't need SUM validator let mut account_lock_manage = AccountLockManage::default(); account_lock_manage.register_lock_algorithm( - SECP_LOCK_CODE_HASH.into(), - Arc::new(Secp256k1Eth::default()), + SECP_LOCK_CODE_HASH, + Arc::new(Secp256k1Eth), ); let rollup_config = RollupConfig::new_builder() .chain_id(CHAIN_ID.pack()) @@ -513,7 +513,7 @@ pub fn setup() -> (Store, DummyState, Generator) { ..Default::default() }; let rollup_context = RollupContext { - rollup_script_hash: ROLLUP_SCRIPT_HASH.into(), + rollup_script_hash: ROLLUP_SCRIPT_HASH, rollup_config, fork_config, }; @@ -605,7 +605,7 @@ pub fn compute_create2_script( data[1 + 20 + 32..1 + 20 + 32 + 32].copy_from_slice(&init_code_hash[..]); let data_hash = tiny_keccak::keccak256(&data); - let mut script_args = vec![0u8; 32 + 4 + 20]; + let mut script_args = [0u8; 32 + 4 + 20]; script_args[0..32].copy_from_slice(&ROLLUP_SCRIPT_HASH[..]); script_args[32..32 + 4].copy_from_slice(&CREATOR_ACCOUNT_ID.to_le_bytes()[..]); script_args[32 + 4..32 + 4 + 20].copy_from_slice(&data_hash[12..]); @@ -794,7 +794,7 @@ pub(crate) fn register_eoa_account( ) { let address = RegistryAddress::new(ETH_REGISTRY_ACCOUNT_ID, eth_address.to_vec()); state - .mapping_registry_address_to_script_hash(address, (*script_hash).into()) + .mapping_registry_address_to_script_hash(address, *script_hash) .expect("map reg addr to script hash"); } diff --git a/gwos-evm/polyjuice-tests/src/test_cases/address_collision.rs b/gwos-evm/polyjuice-tests/src/test_cases/address_collision.rs index 2e2d4a66c..8a9490979 100644 --- a/gwos-evm/polyjuice-tests/src/test_cases/address_collision.rs +++ b/gwos-evm/polyjuice-tests/src/test_cases/address_collision.rs @@ -210,7 +210,7 @@ fn create2_address_collision_overwrite() -> Result<()> { let script_hash = state.get_script_hash_by_registry_address(&create2_eth_reg_addr)?; assert!(script_hash.is_some()); - let create_account_id = state.get_account_id_by_script_hash(&create2_script_hash.into())?; + let create_account_id = state.get_account_id_by_script_hash(&create2_script_hash)?; assert_eq!(create_account_id, Some(8)); Ok(()) } diff --git a/gwos-evm/polyjuice-tests/src/test_cases/call_multiple_times.rs b/gwos-evm/polyjuice-tests/src/test_cases/call_multiple_times.rs index a20a74401..887aa8049 100644 --- a/gwos-evm/polyjuice-tests/src/test_cases/call_multiple_times.rs +++ b/gwos-evm/polyjuice-tests/src/test_cases/call_multiple_times.rs @@ -120,7 +120,7 @@ fn test_call_multiple_times() { // let ss2_contract_ethabi_addr = contract_script_to_eth_addr(&ss2_account_script, true); let input = hex::decode(format!( "bca0b9c2{}{}", - hex::encode(&ss2_contract_eth_abi_addr), + hex::encode(ss2_contract_eth_abi_addr), "0000000000000000000000000000000000000000000000000000000000000014", )) .unwrap(); diff --git a/gwos-evm/polyjuice-tests/src/test_cases/contract_call_contract.rs b/gwos-evm/polyjuice-tests/src/test_cases/contract_call_contract.rs index 616c6ae13..03d41d1c9 100644 --- a/gwos-evm/polyjuice-tests/src/test_cases/contract_call_contract.rs +++ b/gwos-evm/polyjuice-tests/src/test_cases/contract_call_contract.rs @@ -49,7 +49,7 @@ fn test_contract_call_contract() { // Deploy CallContract block_number += 1; - let input = format!("{}{}", INIT_CODE, hex::encode(&ss_eth_abi_addr)); + let input = format!("{}{}", INIT_CODE, hex::encode(ss_eth_abi_addr)); let run_result = deploy( &generator, &store, diff --git a/gwos-evm/polyjuice-tests/src/test_cases/contract_create_contract.rs b/gwos-evm/polyjuice-tests/src/test_cases/contract_create_contract.rs index d03498954..30403096c 100644 --- a/gwos-evm/polyjuice-tests/src/test_cases/contract_create_contract.rs +++ b/gwos-evm/polyjuice-tests/src/test_cases/contract_create_contract.rs @@ -49,7 +49,7 @@ fn test_contract_create_contract() { new_contract_account_script(&state, from_id, &from_eth_address, false); let mom_contract_script_hash = mom_contract_script.hash(); let mom_contract_id = state - .get_account_id_by_script_hash(&mom_contract_script_hash.into()) + .get_account_id_by_script_hash(&mom_contract_script_hash) .unwrap() .unwrap(); // mom_contract_id = 6 let mom_contract_nonce = state.get_nonce(mom_contract_id).unwrap(); diff --git a/gwos-evm/polyjuice-tests/src/test_cases/create2.rs b/gwos-evm/polyjuice-tests/src/test_cases/create2.rs index 55838ae38..e275f5302 100644 --- a/gwos-evm/polyjuice-tests/src/test_cases/create2.rs +++ b/gwos-evm/polyjuice-tests/src/test_cases/create2.rs @@ -126,11 +126,11 @@ fn test_create2() { ); assert_eq!(run_result.return_data, create2_ethabi_addr); let create2_account_id = state - .get_account_id_by_script_hash(&create2_script_hash.into()) + .get_account_id_by_script_hash(&create2_script_hash) .unwrap() .unwrap(); let address = state - .get_registry_address_by_script_hash(ETH_REGISTRY_ACCOUNT_ID, &create2_script_hash.into()) + .get_registry_address_by_script_hash(ETH_REGISTRY_ACCOUNT_ID, &create2_script_hash) .unwrap() .unwrap(); let create2_account_balance = state @@ -148,8 +148,8 @@ fn test_create2() { } => { println!( "transfer from: {}, to: {}, amount: {}", - hex::encode(&from_addr.address), - hex::encode(&to_addr.address), + hex::encode(from_addr.address), + hex::encode(to_addr.address), amount ); Some(amount) diff --git a/gwos-evm/polyjuice-tests/src/test_cases/delegatecall.rs b/gwos-evm/polyjuice-tests/src/test_cases/delegatecall.rs index 6df4bc107..18bd7709d 100644 --- a/gwos-evm/polyjuice-tests/src/test_cases/delegatecall.rs +++ b/gwos-evm/polyjuice-tests/src/test_cases/delegatecall.rs @@ -39,7 +39,7 @@ fn test_delegatecall() { ); let ss_account_script = new_contract_account_script_with_nonce(&from_eth_address, 0); let ss_account_id = state - .get_account_id_by_script_hash(&ss_account_script.hash().into()) + .get_account_id_by_script_hash(&ss_account_script.hash()) .unwrap() .unwrap(); diff --git a/gwos-evm/polyjuice-tests/src/test_cases/eth_addr_reg.rs b/gwos-evm/polyjuice-tests/src/test_cases/eth_addr_reg.rs index 3f2aae7ae..83bd7905b 100644 --- a/gwos-evm/polyjuice-tests/src/test_cases/eth_addr_reg.rs +++ b/gwos-evm/polyjuice-tests/src/test_cases/eth_addr_reg.rs @@ -94,7 +94,7 @@ fn test_update_eth_addr_reg_by_contract() { &generator, eth_eoa_account_id, new_block_info(block_producer_id.clone(), 1, 1), - crate::helper::SetMappingArgs::One(eth_eoa_account_script_hash.into()), + crate::helper::SetMappingArgs::One(eth_eoa_account_script_hash), ) .expect("execute the MSG_SET_MAPPING method of `ETH Address Registry` layer2 contract"); assert_eq!(run_result.exit_code, crate::constant::EVMC_SUCCESS); @@ -116,7 +116,7 @@ fn test_update_eth_addr_reg_by_contract() { &generator, eth_eoa_account_id, new_block_info(block_producer_id.clone(), 2, 2), - crate::helper::SetMappingArgs::One(eth_eoa_account_script_hash.into()), + crate::helper::SetMappingArgs::One(eth_eoa_account_script_hash), ) .unwrap(); assert_eq!( @@ -206,7 +206,7 @@ fn test_batch_set_mapping_by_contract() { for address in eth_eoa_addresses.iter() { let account_script = build_eth_l2_script(address); let account_script_hash = account_script.hash(); - eth_eoa_script_hashes.push(account_script_hash.into()); + eth_eoa_script_hashes.push(account_script_hash); state.create_account_from_script(account_script).unwrap(); let address = RegistryAddress::new(ETH_REGISTRY_ACCOUNT_ID, address.to_vec()); @@ -243,7 +243,7 @@ fn test_batch_set_mapping_by_contract() { for (eth_eoa_address, eth_eoa_account_script_hash) in eth_eoa_addresses.into_iter().zip(eth_eoa_script_hashes) { - let eth_eoa_account_script_hash: [u8; 32] = eth_eoa_account_script_hash.into(); + let eth_eoa_account_script_hash: [u8; 32] = eth_eoa_account_script_hash; // check result: eth_address -> gw_script_hash let args = EthToGwArgsBuilder::default() diff --git a/gwos-evm/polyjuice-tests/src/test_cases/gas_price.rs b/gwos-evm/polyjuice-tests/src/test_cases/gas_price.rs index 4b94955d0..be7fa5550 100644 --- a/gwos-evm/polyjuice-tests/src/test_cases/gas_price.rs +++ b/gwos-evm/polyjuice-tests/src/test_cases/gas_price.rs @@ -70,6 +70,6 @@ fn gas_price_test() -> anyhow::Result<()> { let mut arr = [0u8; 16]; arr.copy_from_slice(&run_result.return_data[16..]); let tx_gas_price = u128::from_be_bytes(arr); - assert_eq!(tx_gas_price as u128, gas_price); + assert_eq!({ tx_gas_price }, gas_price); Ok(()) } diff --git a/gwos-evm/polyjuice-tests/src/test_cases/get_block_info.rs b/gwos-evm/polyjuice-tests/src/test_cases/get_block_info.rs index 1c8bf8f03..f05bcc0e7 100644 --- a/gwos-evm/polyjuice-tests/src/test_cases/get_block_info.rs +++ b/gwos-evm/polyjuice-tests/src/test_cases/get_block_info.rs @@ -81,7 +81,7 @@ fn test_get_block_info() { let contract_account_script = new_contract_account_script(&state, from_id, &from_eth_address, false); let new_account_id = state - .get_account_id_by_script_hash(&contract_account_script.hash().into()) + .get_account_id_by_script_hash(&contract_account_script.hash()) .unwrap() .unwrap(); diff --git a/gwos-evm/polyjuice-tests/src/test_cases/get_chain_id.rs b/gwos-evm/polyjuice-tests/src/test_cases/get_chain_id.rs index 29be94bb2..be416a0db 100644 --- a/gwos-evm/polyjuice-tests/src/test_cases/get_chain_id.rs +++ b/gwos-evm/polyjuice-tests/src/test_cases/get_chain_id.rs @@ -21,7 +21,7 @@ fn test_get_chain_id() { let (from_id, from_script_hash) = crate::helper::create_eth_eoa_account(&mut state, &from_eth_address, 200000u64.into()); let address = state - .get_registry_address_by_script_hash(ETH_REGISTRY_ACCOUNT_ID, &from_script_hash.into()) + .get_registry_address_by_script_hash(ETH_REGISTRY_ACCOUNT_ID, &from_script_hash) .unwrap() .unwrap(); diff --git a/gwos-evm/polyjuice-tests/src/test_cases/heap_memory.rs b/gwos-evm/polyjuice-tests/src/test_cases/heap_memory.rs index a831f2d3a..847449a32 100644 --- a/gwos-evm/polyjuice-tests/src/test_cases/heap_memory.rs +++ b/gwos-evm/polyjuice-tests/src/test_cases/heap_memory.rs @@ -39,7 +39,7 @@ fn test_heap_momory() { ); let account_script = new_contract_account_script(&state, from_id, &from_eth_address, false); let contract_account_id = state - .get_account_id_by_script_hash(&account_script.hash().into()) + .get_account_id_by_script_hash(&account_script.hash()) .unwrap() .unwrap(); diff --git a/gwos-evm/polyjuice-tests/src/test_cases/invalid_sudt_erc20_proxy.rs b/gwos-evm/polyjuice-tests/src/test_cases/invalid_sudt_erc20_proxy.rs index 0559849a6..2110162cb 100644 --- a/gwos-evm/polyjuice-tests/src/test_cases/invalid_sudt_erc20_proxy.rs +++ b/gwos-evm/polyjuice-tests/src/test_cases/invalid_sudt_erc20_proxy.rs @@ -26,7 +26,7 @@ fn test_invalid_sudt_erc20_proxy() { let (from_id1, from_script_hash1) = helper::create_eth_eoa_account(&mut state, &from_eth_address1, 2000000u64.into()); let address1 = state - .get_registry_address_by_script_hash(ETH_REGISTRY_ACCOUNT_ID, &from_script_hash1.into()) + .get_registry_address_by_script_hash(ETH_REGISTRY_ACCOUNT_ID, &from_script_hash1) .unwrap() .unwrap(); @@ -34,7 +34,7 @@ fn test_invalid_sudt_erc20_proxy() { let (_from_id2, from_script_hash2) = helper::create_eth_eoa_account(&mut state, &from_eth_address2, 2000000u64.into()); let address2 = state - .get_registry_address_by_script_hash(ETH_REGISTRY_ACCOUNT_ID, &from_script_hash2.into()) + .get_registry_address_by_script_hash(ETH_REGISTRY_ACCOUNT_ID, &from_script_hash2) .unwrap() .unwrap(); @@ -65,7 +65,7 @@ fn test_invalid_sudt_erc20_proxy() { let contract_account_script = new_contract_account_script(&state, from_id1, &from_eth_address1, false); let invalid_proxy_account_id = state - .get_account_id_by_script_hash(&contract_account_script.hash().into()) + .get_account_id_by_script_hash(&contract_account_script.hash()) .unwrap() .unwrap(); diff --git a/gwos-evm/polyjuice-tests/src/test_cases/multicall3.rs b/gwos-evm/polyjuice-tests/src/test_cases/multicall3.rs index d4b8b73d1..115739f88 100644 --- a/gwos-evm/polyjuice-tests/src/test_cases/multicall3.rs +++ b/gwos-evm/polyjuice-tests/src/test_cases/multicall3.rs @@ -19,7 +19,7 @@ fn multicall3_test() -> anyhow::Result<()> { .get_account_id_by_eth_address(&contract_eth_addr)? .expect("contract account id"); - let eth_addr = hex::encode(&contract_eth_addr); + let eth_addr = hex::encode(contract_eth_addr); const OLD_ADDR: &str = "ca11bde05977b3631167028862be2a173976ca11"; let input = MULTICALL3_INPUT.trim_end_matches('\n'); let input = input.replace(OLD_ADDR, ð_addr); diff --git a/gwos-evm/polyjuice-tests/src/test_cases/parse_log_event.rs b/gwos-evm/polyjuice-tests/src/test_cases/parse_log_event.rs index 2440dc541..40f2c9b9e 100644 --- a/gwos-evm/polyjuice-tests/src/test_cases/parse_log_event.rs +++ b/gwos-evm/polyjuice-tests/src/test_cases/parse_log_event.rs @@ -21,7 +21,7 @@ fn test_parse_log_event() { let (from_id, from_script_hash) = crate::helper::create_eth_eoa_account(&mut state, &from_eth_addr, 200000u64.into()); let address = state - .get_registry_address_by_script_hash(ETH_REGISTRY_ACCOUNT_ID, &from_script_hash.into()) + .get_registry_address_by_script_hash(ETH_REGISTRY_ACCOUNT_ID, &from_script_hash) .unwrap() .unwrap(); @@ -48,12 +48,12 @@ fn test_parse_log_event() { let contract_addr = state .get_registry_address_by_script_hash( ETH_REGISTRY_ACCOUNT_ID, - &contract_script.hash().into(), + &contract_script.hash(), ) .unwrap() .unwrap(); let contract_id = state - .get_account_id_by_script_hash(&contract_script.hash().into()) + .get_account_id_by_script_hash(&contract_script.hash()) .unwrap() .unwrap(); assert_eq!(run_result.logs.len(), 4); diff --git a/gwos-evm/polyjuice-tests/src/test_cases/pre_compiled_contracts.rs b/gwos-evm/polyjuice-tests/src/test_cases/pre_compiled_contracts.rs index 0a7a476e0..0f99625b0 100644 --- a/gwos-evm/polyjuice-tests/src/test_cases/pre_compiled_contracts.rs +++ b/gwos-evm/polyjuice-tests/src/test_cases/pre_compiled_contracts.rs @@ -9,7 +9,7 @@ use ckb_vm::{ machine::asm::AsmCoreMachine, memory::Memory, registers::{A0, A1, A3, A7}, - DefaultMachineBuilder, Error as VMError, Register, SupportMachine, Syscalls, + DefaultMachineBuilder, Error as VMError, ExecutionContext, Register, SupportMachine, }; use gw_common::state::{build_data_hash_key, State}; use gw_config::SyscallCyclesConfig; @@ -47,11 +47,7 @@ fn load_data_h256(machine: &mut Mac, addr: u64) -> Result Syscalls for L2Syscalls { - fn initialize(&mut self, _machine: &mut Mac) -> Result<(), VMError> { - Ok(()) - } - +impl ExecutionContext for L2Syscalls { fn ecall(&mut self, machine: &mut Mac) -> Result { let code = machine.registers()[A7].to_u64(); @@ -155,9 +151,9 @@ fn test_contracts() { let core_machine = AsmCoreMachine::new(params.vm_isa, params.vm_version, 7000_0000); let machine_builder = - DefaultMachineBuilder::new(core_machine).syscall(Box::new(L2Syscalls { data, tree })); + DefaultMachineBuilder::new(core_machine).context(L2Syscalls { data, tree }); - let mut machine = ckb_vm_aot::AotMachine::new(machine_builder.build(), None); + let mut machine = machine_builder.build(); machine.load_program(&binary, &[]).unwrap(); let code = machine.run().unwrap(); assert_eq!(code, 0); diff --git a/gwos-evm/polyjuice-tests/src/test_cases/recover_account.rs b/gwos-evm/polyjuice-tests/src/test_cases/recover_account.rs index ebc2aa158..722be52ee 100644 --- a/gwos-evm/polyjuice-tests/src/test_cases/recover_account.rs +++ b/gwos-evm/polyjuice-tests/src/test_cases/recover_account.rs @@ -48,7 +48,7 @@ fn test_recover_account() { let contract_account_script = new_contract_account_script(&state, from_id, &from_eth_address, false); let new_account_id = state - .get_account_id_by_script_hash(&contract_account_script.hash().into()) + .get_account_id_by_script_hash(&contract_account_script.hash()) .unwrap() .unwrap(); @@ -58,13 +58,13 @@ fn test_recover_account() { let message_hex = "1cdeae55a5768fe14b628001c6247ae84c70310a7ddcfdc73ac68494251e46ec"; let signature_hex = "28aa0c394487edf2211f445c47fb5f4fb5e3023920f62124d309f5bdf70d95045a934f278cec717300a5417313d1cdc390e761e37c0964b940c0a6f07b7361ed01"; - let secp256k1 = Secp256k1Eth::default(); - let message = hex::decode(&message_hex).unwrap(); + let secp256k1 = Secp256k1Eth; + let message = hex::decode(message_hex).unwrap(); let msg: [u8; 32] = message.try_into().unwrap(); - let signature = hex::decode(&signature_hex).unwrap(); + let signature = hex::decode(signature_hex).unwrap(); let lock_args = secp256k1 - .recover(msg.into(), &signature) + .recover(msg, &signature) .expect("get lock args"); let lock_args_hex = hex::encode(&lock_args); println!("lock args: {}", &lock_args_hex); @@ -75,7 +75,7 @@ fn test_recover_account() { let input = hex::decode(format!( "7d7b0255{}0000000000000000000000000000000000000000000000000000000000000060{}0000000000000000000000000000000000000000000000000000000000000041{}00000000000000000000000000000000000000000000000000000000000000", message_hex, - hex::encode(&SECP_LOCK_CODE_HASH), + hex::encode(SECP_LOCK_CODE_HASH), signature_hex, )) .unwrap(); @@ -130,7 +130,7 @@ fn test_recover_account() { let input = hex::decode(format!( "7d7b0255{}0000000000000000000000000000000000000000000000000000000000000060{}0000000000000000000000000000000000000000000000000000000000000041{}00000000000000000000000000000000000000000000000000000000000000", message_hex, - hex::encode(&SECP_LOCK_CODE_HASH), + hex::encode(SECP_LOCK_CODE_HASH), signature_hex, )) .unwrap(); @@ -170,7 +170,7 @@ fn test_recover_account() { let input = hex::decode(format!( "7d7b0255{}0000000000000000000000000000000000000000000000000000000000000060{}0000000000000000000000000000000000000000000000000000000000000041{}00000000000000000000000000000000000000000000000000000000000000", message_hex, - hex::encode(&[1u8; 32]), + hex::encode([1u8; 32]), signature_hex, )) .unwrap(); diff --git a/gwos-evm/polyjuice-tests/src/test_cases/recursion_contract.rs b/gwos-evm/polyjuice-tests/src/test_cases/recursion_contract.rs index 4fdf25e2f..1762aa4f0 100644 --- a/gwos-evm/polyjuice-tests/src/test_cases/recursion_contract.rs +++ b/gwos-evm/polyjuice-tests/src/test_cases/recursion_contract.rs @@ -39,7 +39,7 @@ fn test_recursion_contract_call() { let recur_account_script = new_contract_account_script(&state, from_id, &from_eth_address, false); let recur_account_id = state - .get_account_id_by_script_hash(&recur_account_script.hash().into()) + .get_account_id_by_script_hash(&recur_account_script.hash()) .unwrap() .unwrap(); diff --git a/gwos-evm/polyjuice-tests/src/test_cases/revert.rs b/gwos-evm/polyjuice-tests/src/test_cases/revert.rs index 6ef0825e5..96cf8e91f 100644 --- a/gwos-evm/polyjuice-tests/src/test_cases/revert.rs +++ b/gwos-evm/polyjuice-tests/src/test_cases/revert.rs @@ -41,7 +41,7 @@ fn revert_in_try_test() -> anyhow::Result<()> { //call CallRevertWithTryCatch.test(Revert) let args_str = format!( "bb29998e000000000000000000000000{}", - hex::encode(&revert_eth_addr) + hex::encode(revert_eth_addr) ); let code = hex::decode(args_str)?; let run_result = chain.execute(from_id, call_revert_id, &code, gas_limit, gas_price, value)?; @@ -102,8 +102,8 @@ fn revert_in_deep_try_test() -> anyhow::Result<()> { //CallRevertWithTryCatchInDepth.test(CallRevertWithTryCatch, Revert) let args_str = format!( "2b6d0ceb000000000000000000000000{}000000000000000000000000{}", - hex::encode(&call_revert_eth_addr), - hex::encode(&revert_eth_addr) + hex::encode(call_revert_eth_addr), + hex::encode(revert_eth_addr) ); let code = hex::decode(args_str)?; let run_result = chain.execute( @@ -165,7 +165,7 @@ fn revert_contructor_try_test() -> anyhow::Result<()> { .expect("to id"); assert_eq!(run_result.exit_code, 0); - let deploy_args = format!("000000000000000000000000{}", hex::encode(&revert_eth_addr)); + let deploy_args = format!("000000000000000000000000{}", hex::encode(revert_eth_addr)); let code = format!("{}{}", CONSTRUCTOR_REVERT_CODE, deploy_args); let code = hex::decode(code).expect("decode code"); let run_result = chain.deploy(from_id, &code, gas_limit, gas_price, value)?; @@ -233,7 +233,7 @@ fn revert_test() -> anyhow::Result<()> { //call CallRevertWithoutTryCatch.test(Revert) let args_str = format!( "bb29998e000000000000000000000000{}", - hex::encode(&revert_eth_addr) + hex::encode(revert_eth_addr) ); let code = hex::decode(args_str)?; let run_result = chain.execute(from_id, call_revert_id, &code, gas_limit, gas_price, value)?; diff --git a/gwos-evm/polyjuice-tests/src/test_cases/rlp.rs b/gwos-evm/polyjuice-tests/src/test_cases/rlp.rs index 9a4d06269..838031cd1 100644 --- a/gwos-evm/polyjuice-tests/src/test_cases/rlp.rs +++ b/gwos-evm/polyjuice-tests/src/test_cases/rlp.rs @@ -2,20 +2,15 @@ use ckb_vm::{ machine::asm::AsmCoreMachine, memory::Memory, registers::{A0, A7}, - DefaultMachineBuilder, Error as VMError, Register, SupportMachine, Syscalls, + DefaultMachineBuilder, Error as VMError, ExecutionContext, Register, SupportMachine, }; -use ckb_vm_aot::AotMachine; const BINARY: &[u8] = include_bytes!("../../../build/test_rlp"); const DEBUG_PRINT_SYSCALL_NUMBER: u64 = 2177; pub struct L2Syscalls; -impl Syscalls for L2Syscalls { - fn initialize(&mut self, _machine: &mut Mac) -> Result<(), VMError> { - Ok(()) - } - +impl ExecutionContext for L2Syscalls { fn ecall(&mut self, machine: &mut Mac) -> Result { let code = machine.registers()[A7].to_u64(); if code != DEBUG_PRINT_SYSCALL_NUMBER { @@ -85,8 +80,8 @@ fn test_rlp() { let params = AsmCoreMachineParams::with_version(1).unwrap(); let core_machine = AsmCoreMachine::new(params.vm_isa, params.vm_version, 7000_0000); - let machine_builder = DefaultMachineBuilder::new(core_machine).syscall(Box::new(L2Syscalls)); - let mut machine = AotMachine::new(machine_builder.build(), None); + let machine_builder = DefaultMachineBuilder::new(core_machine).context(L2Syscalls); + let mut machine = machine_builder.build(); machine.load_program(&binary, &[]).unwrap(); let code = machine.run().unwrap(); assert_eq!(code, 0); diff --git a/gwos-evm/polyjuice-tests/src/test_cases/selfdestruct.rs b/gwos-evm/polyjuice-tests/src/test_cases/selfdestruct.rs index 8878455ba..5179dcbfb 100644 --- a/gwos-evm/polyjuice-tests/src/test_cases/selfdestruct.rs +++ b/gwos-evm/polyjuice-tests/src/test_cases/selfdestruct.rs @@ -75,11 +75,11 @@ fn test_selfdestruct() { new_contract_account_script(&state, from_id, &from_eth_address, false); let new_script_hash = contract_account_script.hash(); let contract_reg_addr = state - .get_registry_address_by_script_hash(ETH_REGISTRY_ACCOUNT_ID, &new_script_hash.into()) + .get_registry_address_by_script_hash(ETH_REGISTRY_ACCOUNT_ID, &new_script_hash) .unwrap() .unwrap(); let new_account_id = state - .get_account_id_by_script_hash(&contract_account_script.hash().into()) + .get_account_id_by_script_hash(&contract_account_script.hash()) .unwrap() .unwrap(); assert_eq!( diff --git a/gwos-evm/polyjuice-tests/src/test_cases/simple_storage.rs b/gwos-evm/polyjuice-tests/src/test_cases/simple_storage.rs index 2a713f378..b7aa5e27a 100644 --- a/gwos-evm/polyjuice-tests/src/test_cases/simple_storage.rs +++ b/gwos-evm/polyjuice-tests/src/test_cases/simple_storage.rs @@ -63,7 +63,7 @@ fn test_simple_storage() { let contract_account_script = new_contract_account_script(&state, from_id, &from_eth_address, false); let new_account_id = state - .get_account_id_by_script_hash(&contract_account_script.hash().into()) + .get_account_id_by_script_hash(&contract_account_script.hash()) .unwrap() .unwrap(); let from_balance2 = state diff --git a/gwos-evm/polyjuice-tests/src/test_cases/simple_transfer.rs b/gwos-evm/polyjuice-tests/src/test_cases/simple_transfer.rs index a4f021c06..36a56f9cc 100644 --- a/gwos-evm/polyjuice-tests/src/test_cases/simple_transfer.rs +++ b/gwos-evm/polyjuice-tests/src/test_cases/simple_transfer.rs @@ -68,11 +68,11 @@ fn test_simple_transfer() { .try_into() .unwrap(); let ss_reg_addr = state - .get_registry_address_by_script_hash(ETH_REGISTRY_ACCOUNT_ID, &ss_script_hash.into()) + .get_registry_address_by_script_hash(ETH_REGISTRY_ACCOUNT_ID, &ss_script_hash) .unwrap() .unwrap(); let ss_account_id = state - .get_account_id_by_script_hash(&ss_account_script.hash().into()) + .get_account_id_by_script_hash(&ss_account_script.hash()) .unwrap() .unwrap(); let ss_balance = state @@ -116,12 +116,12 @@ fn test_simple_transfer() { let st_contract_reg_addr = state .get_registry_address_by_script_hash( ETH_REGISTRY_ACCOUNT_ID, - &st_contract_script_hash.into(), + &st_contract_script_hash, ) .unwrap() .unwrap(); let st_contract_id = state - .get_account_id_by_script_hash(&st_contract_account_script.hash().into()) + .get_account_id_by_script_hash(&st_contract_account_script.hash()) .unwrap() .unwrap(); let st_contract_balance = state diff --git a/gwos-evm/polyjuice-tests/src/test_cases/sudt_erc20_proxy.rs b/gwos-evm/polyjuice-tests/src/test_cases/sudt_erc20_proxy.rs index d2d19340f..b23f5f211 100644 --- a/gwos-evm/polyjuice-tests/src/test_cases/sudt_erc20_proxy.rs +++ b/gwos-evm/polyjuice-tests/src/test_cases/sudt_erc20_proxy.rs @@ -70,7 +70,7 @@ fn test_sudt_erc20_proxy_inner( let contract_account_script = new_contract_account_script(state, from_id1, &from_eth_address1, false); - let script_hash = contract_account_script.hash().into(); + let script_hash = contract_account_script.hash(); let new_account_id = state .get_account_id_by_script_hash(&script_hash) .unwrap() @@ -128,7 +128,7 @@ fn test_sudt_erc20_proxy_inner( let mut buf = [0u8; 32]; let total_supply = state.get_sudt_total_supply(new_sudt_id).unwrap(); total_supply.to_big_endian(&mut buf); - hex::encode(&buf) + hex::encode(buf) }; for (idx, (action, from_id, args_str, return_data_str)) in [ // balanceOf(eoa1) diff --git a/gwos-evm/polyjuice-tests/src/test_cases/sudt_erc20_proxy_attack_allowance.rs b/gwos-evm/polyjuice-tests/src/test_cases/sudt_erc20_proxy_attack_allowance.rs index d5513ff8e..32727b58a 100644 --- a/gwos-evm/polyjuice-tests/src/test_cases/sudt_erc20_proxy_attack_allowance.rs +++ b/gwos-evm/polyjuice-tests/src/test_cases/sudt_erc20_proxy_attack_allowance.rs @@ -69,7 +69,7 @@ fn test_attack_allowance() { let proxy_eth_addr = { let contract_account_script = new_contract_account_script(&state, from_id, &from_eth_addr, false); - let script_hash = contract_account_script.hash().into(); + let script_hash = contract_account_script.hash(); let reg_addr = state .get_registry_address_by_script_hash(ETH_REGISTRY_ACCOUNT_ID, &script_hash) .unwrap() @@ -105,7 +105,7 @@ fn test_attack_allowance() { let attack_account_id = { let contract_account_script = new_contract_account_script(&state, from_id, &from_eth_addr, false); - let script_hash = contract_account_script.hash().into(); + let script_hash = contract_account_script.hash(); state .get_account_id_by_script_hash(&script_hash) .unwrap() diff --git a/gwos-evm/polyjuice-tests/src/test_cases/utils.rs b/gwos-evm/polyjuice-tests/src/test_cases/utils.rs index 09b6d5cc8..f435ae051 100644 --- a/gwos-evm/polyjuice-tests/src/test_cases/utils.rs +++ b/gwos-evm/polyjuice-tests/src/test_cases/utils.rs @@ -2,9 +2,8 @@ use ckb_vm::{ machine::asm::AsmCoreMachine, memory::Memory, registers::{A0, A7}, - DefaultMachineBuilder, Error as VMError, Register, SupportMachine, Syscalls, + DefaultMachineBuilder, Error as VMError, ExecutionContext, Register, SupportMachine, }; -use ckb_vm_aot::AotMachine; use gw_types::bytes::Bytes; const BINARY: &[u8] = include_bytes!("../../../build/test_calc_fee"); @@ -12,11 +11,7 @@ const DEBUG_PRINT_SYSCALL_NUMBER: u64 = 2177; pub struct L2Syscalls; -impl Syscalls for L2Syscalls { - fn initialize(&mut self, _machine: &mut Mac) -> Result<(), VMError> { - Ok(()) - } - +impl ExecutionContext for L2Syscalls { fn ecall(&mut self, machine: &mut Mac) -> Result { let code = machine.registers()[A7].to_u64(); if code != DEBUG_PRINT_SYSCALL_NUMBER { @@ -87,8 +82,8 @@ fn test_calc_fee() { let params = AsmCoreMachineParams::with_version(1).unwrap(); let cycles = 7000_0000; let core_machine = AsmCoreMachine::new(params.vm_isa, params.vm_version, cycles); - let machine_builder = DefaultMachineBuilder::new(core_machine).syscall(Box::new(L2Syscalls)); - let mut machine = AotMachine::new(machine_builder.build(), None); + let machine_builder = DefaultMachineBuilder::new(core_machine).context(L2Syscalls); + let mut machine = machine_builder.build(); machine.load_program(&binary, &[]).unwrap(); let code = machine.run().unwrap(); diff --git a/gwos-evm/polyjuice-tests/tests/ethereum_test.rs b/gwos-evm/polyjuice-tests/tests/ethereum_test.rs index f87a2b2b3..14184a7ee 100644 --- a/gwos-evm/polyjuice-tests/tests/ethereum_test.rs +++ b/gwos-evm/polyjuice-tests/tests/ethereum_test.rs @@ -177,7 +177,7 @@ impl Filler { let label = format!("{} {}", LABEL_PREFIX, label); self.expect.iter().find(|ex| match &ex.indexes.data { LabelIndex::Single(l) => l == &label, - LabelIndex::Sequence(l) => l.iter().find(|data| **data == label).is_some(), + LabelIndex::Sequence(l) => l.iter().any(|data| *data == label), _ => false, }) } @@ -212,7 +212,7 @@ impl TestRunner { let eth_addr: [u8; 20] = eth_addr.try_into().unwrap(); if account.code != "0x" { - let code = hex::decode(&account.code.trim_start_matches("0x"))?; + let code = hex::decode(account.code.trim_start_matches("0x"))?; let mut storage = HashMap::with_capacity(account.storage.len()); for (k, v) in &account.storage { let k = hex_to_h256(k)?; @@ -235,7 +235,7 @@ impl TestRunner { for hardfork in HARD_FORKS { if let Some(posts) = self.testcase.post.get(&hardfork.to_string()) { println!("Prepare tx, hardfork: {}", hardfork); - for (_idx, post) in posts.into_iter().enumerate() { + for (_idx, post) in posts.iter().enumerate() { // init ctx for each `post` let mut chain = self.init()?; let label = self @@ -274,7 +274,7 @@ impl TestRunner { Some(gas_price) => U256::from_str_radix(gas_price, 16)?, None => U256::zero(), }; - let from_eth_addr = hex_to_eth_address(&transaction.sender.as_ref().expect("sender"))?; + let from_eth_addr = hex_to_eth_address(transaction.sender.as_ref().expect("sender"))?; let to_eth_addr = hex_to_eth_address(&transaction.to)?; let from_id = chain .get_account_id_by_eth_address(&from_eth_addr)? @@ -295,7 +295,7 @@ impl TestRunner { let run_result = sub_test_case.run()?; let logs_hash = rlp_log_hash(&run_result); let expect_logs_hash = hex::decode(post.logs.trim_start_matches("0x"))?; - if logs_hash.as_slice() != &expect_logs_hash { + if logs_hash.as_slice() != expect_logs_hash { return Err(anyhow::anyhow!( "Compare logs hash failed: expect: {}, actual: {}", hex::encode(&expect_logs_hash), @@ -330,15 +330,15 @@ impl TestRunner { let mut buf = [0u8; 32]; buf[24..].copy_from_slice(&k.to_be_bytes()); let actual = chain - .get_storage(account_id, &buf.into()) + .get_storage(account_id, &buf) .expect("get value"); - let expect = decode_storage_value(&v).expect("decode value"); + let expect = decode_storage_value(v).expect("decode value"); if expect.as_slice() != actual.as_slice() { return Err(anyhow::anyhow!( "State validate failed for key: {:x}, expect value: {}, actual value: {}", k, - &hex::encode(&expect.as_slice()), - &hex::encode(&actual.as_slice()), + &hex::encode(expect.as_slice()), + &hex::encode(actual.as_slice()), )); } } @@ -404,8 +404,7 @@ fn rlp_log_hash(run_result: &RunResult) -> H256 { } }); stream.finalize_unbounded_list(); - let log_hash = tiny_keccak::keccak256(&stream.out().freeze()); - log_hash.into() + tiny_keccak::keccak256(&stream.out().freeze()) } fn hex_to_h256(hex_str: &str) -> anyhow::Result { @@ -470,6 +469,7 @@ fn decode_storage_value(v: &str) -> anyhow::Result { #[test] fn ethereum_test() -> anyhow::Result<()> { + #[allow(clippy::manual_flatten)] for dir in fs::read_dir(TEST_CASE_DIR)? { if let Ok(dir) = dir { let subdir = dir.path(); @@ -565,10 +565,10 @@ fn ethereum_vmtest_test() -> anyhow::Result<()> { #[test] fn ethereum_single_test() -> anyhow::Result<()> { let path = "../integration-test/ethereum-tests/GeneralStateTests/VMTests/vmLogTest/log0.json"; - let content = fs::read_to_string(&path)?; + let content = fs::read_to_string(path)?; let test_cases: HashMap = serde_json::from_str(&content)?; let path = "../integration-test/ethereum-tests/src/GeneralStateTestsFiller/VMTests/vmLogTest/log0Filler.yml"; - let content = fs::read_to_string(&path)?; + let content = fs::read_to_string(path)?; let mut fillers: HashMap = serde_yaml::from_str(&content)?; for (k, test_case) in test_cases.into_iter() { let filler = fillers.remove(&k).expect("get filler"); diff --git a/gwos/contracts/eth-account-lock/src/entry.rs b/gwos/contracts/eth-account-lock/src/entry.rs index c30829f6b..4408b8645 100644 --- a/gwos/contracts/eth-account-lock/src/entry.rs +++ b/gwos/contracts/eth-account-lock/src/entry.rs @@ -78,7 +78,7 @@ fn verify_message_signature( // load signature let signature = load_signature_from_witness()?; // verify message - let secp256k1_eth = Secp256k1Eth::default(); + let secp256k1_eth = Secp256k1Eth; let valid = match signing_type { SigningType::WithPrefix => secp256k1_eth.verify_message(eth_address, signature, message)?, SigningType::Raw => secp256k1_eth.verify_alone(eth_address, signature, message)?, diff --git a/gwos/crates/types/Cargo.toml b/gwos/crates/types/Cargo.toml index 6878d0310..aa051694f 100644 --- a/gwos/crates/types/Cargo.toml +++ b/gwos/crates/types/Cargo.toml @@ -15,8 +15,8 @@ deprecated = [] molecule = { version = "0.7.3", default-features = false } cfg-if = "1" gw-hash = { path = "../hash", default-features = false } -ckb-fixed-hash = { version = "0.106", optional = true } -ckb-types = { version = "0.106", default-features = false, optional = true } +ckb-fixed-hash = { version = "0.111.0", optional = true } +ckb-types = { version = "0.111.0", default-features = false, optional = true } primitive-types = { version = "0.12", default-features = false, features = [ "impl-serde", "impl-rlp" ] } [build-dependencies] diff --git a/rust-toolchain b/rust-toolchain index 5deab586f..22d6771a4 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -1.68.2 +1.72.1 diff --git a/web3/Cargo.lock b/web3/Cargo.lock index 3df3c161e..4f1c5aac8 100644 --- a/web3/Cargo.lock +++ b/web3/Cargo.lock @@ -393,12 +393,6 @@ dependencies = [ "wyz", ] -[[package]] -name = "blake2b-ref" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95916998c798756098a4eb1b3f2cd510659705a9817bf203d61abd30fbec3e7b" - [[package]] name = "blake2b-ref" version = "0.3.1" @@ -535,18 +529,24 @@ dependencies = [ [[package]] name = "ckb-channel" -version = "0.106.0" +version = "0.111.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e718dfa7098b0bcce95c7fa573d96aad2f4c3ac886b6f35053f40c5e4894156" +checksum = "701e6829c3dcbae46dd2442de63d080046480a6c2bb4951dbf419ad092459402" dependencies = [ "crossbeam-channel", ] +[[package]] +name = "ckb-constant" +version = "0.111.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d5c980d4724770f72a37bceffa26ea64dd914891e45e856e2a3792fdb4a5a18" + [[package]] name = "ckb-error" -version = "0.106.0" +version = "0.111.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd512b729186e6fa991b588647646e230db7728f71ba16087af21bded12ceb09" +checksum = "34cfd733cabcb4262ee679c02733864b13c8fa879e3aabc078fe0ec727cd95d6" dependencies = [ "anyhow", "ckb-occupied-capacity", @@ -556,9 +556,9 @@ dependencies = [ [[package]] name = "ckb-fixed-hash" -version = "0.106.0" +version = "0.111.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8eba8f7006a63ad0945412012c89af6ad09d9b2b02962a869d0158a298fa8eca" +checksum = "3b1dfab045fffa31cae9680d73e1f09833ca1abfb807dc4b9544739c94c23fd0" dependencies = [ "ckb-fixed-hash-core", "ckb-fixed-hash-macros", @@ -566,9 +566,9 @@ dependencies = [ [[package]] name = "ckb-fixed-hash-core" -version = "0.106.0" +version = "0.111.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44b15b464d37d8deeb66046011b3e01e642103b27d4752db4e74740ded732c73" +checksum = "bdd1727a6ecd4d0bcab604cb1ef707fe92e939fa6e9a438f9f25bf05208cb080" dependencies = [ "faster-hex 0.6.1", "serde", @@ -577,9 +577,9 @@ dependencies = [ [[package]] name = "ckb-fixed-hash-macros" -version = "0.106.0" +version = "0.111.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61e86358f6eb595a0e6a2a5ef96d54d4c56e0a4bf822934d7b1fe9904b7208e4" +checksum = "7b5da34c32585c35715fcde4e3a1dd3b0346d7af43506c5e51c613f01483e4f9" dependencies = [ "ckb-fixed-hash-core", "proc-macro2", @@ -587,21 +587,36 @@ dependencies = [ "syn", ] +[[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", + "ckb-hash", + "ckb-occupied-capacity", + "molecule", + "numext-fixed-uint", +] + [[package]] name = "ckb-hash" -version = "0.106.0" +version = "0.111.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "038ad6840c4a89f4cd76b50621c4e6d82ca5f0d09fba707b1025016218d4a2d8" +checksum = "8c88e5e2d6454be488fa5cf8b49175879353c6af969ff210dd6416f315b53120" dependencies = [ - "blake2b-ref 0.2.1", + "blake2b-ref", "blake2b-rs", ] [[package]] name = "ckb-jsonrpc-types" -version = "0.106.0" +version = "0.111.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eca123e0b725e487cd49f202097c38c73c2a4d7e1c80d89549c492f058e84f29" +checksum = "d789a71538da07871c11aecbd28d6c632bb426bdfeed5fc2fa1b455e31152468" dependencies = [ "ckb-types", "faster-hex 0.6.1", @@ -620,9 +635,9 @@ dependencies = [ [[package]] name = "ckb-occupied-capacity" -version = "0.106.0" +version = "0.111.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94f6c146d51b1b7f65511e6f16ef21b0d852aececc4ae87f78c3099c03e246a9" +checksum = "358ad364465a5a359575642c12952ba8735a148382789d65ddd5231cd21899fc" dependencies = [ "ckb-occupied-capacity-core", "ckb-occupied-capacity-macros", @@ -630,18 +645,18 @@ dependencies = [ [[package]] name = "ckb-occupied-capacity-core" -version = "0.106.0" +version = "0.111.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "507187824418c845b519c64521b34578570b5851d170ff0101bc477ed0cdee2b" +checksum = "de2dc06db98f8a995cb7145bc56dbd17bb0c8ab2e59a07aaa40f2c956c2451dd" dependencies = [ "serde", ] [[package]] name = "ckb-occupied-capacity-macros" -version = "0.106.0" +version = "0.111.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17825cb1ec37c5ad2f2c6690aa4cbfeb9a6d2af02463a66b1fa013e4f9e762aa" +checksum = "b1709e0f101026c4ef29b1593692e480b03cdb4e0dace1e348494c6554d50d35" dependencies = [ "ckb-occupied-capacity-core", "quote", @@ -650,9 +665,9 @@ dependencies = [ [[package]] name = "ckb-rational" -version = "0.106.0" +version = "0.111.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa5edf5377138c9457015a450b1a263996d100a5b6e21566157f410e1a5b95b3" +checksum = "bd3959391a4fb05d6a2578aa8db75732ada1ce381fb34d6eeaf09d395702e63c" dependencies = [ "numext-fixed-uint", "serde", @@ -660,24 +675,28 @@ dependencies = [ [[package]] name = "ckb-types" -version = "0.106.0" +version = "0.111.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f9f918d7f04fed733c528ec98ba8bdee31a885bd082e6ff263ca21d58e01378" +checksum = "b6ec737e4957418bbd0f4091e8565a89bbd8f6fc37a20360820e44d1f1e44e58" dependencies = [ "bit-vec", "bytes 1.1.0", "ckb-channel", + "ckb-constant", "ckb-error", "ckb-fixed-hash", + "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]] @@ -1309,6 +1328,15 @@ dependencies = [ "web-sys", ] +[[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-common" version = "1.14.0" @@ -1324,7 +1352,7 @@ dependencies = [ name = "gw-hash" version = "1.14.0" dependencies = [ - "blake2b-ref 0.3.1", + "blake2b-ref", ] [[package]] @@ -1968,9 +1996,9 @@ dependencies = [ [[package]] name = "molecule" -version = "0.7.3" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edc8276c02a006bddad7d1c28c1a88f30421e1b5f0ba0ca96ceb8077c7d20c01" +checksum = "d4fd9767ab5e5f2ea40f71ff4c8bdb633c50509052e093c2fdd0e390a749dfa3" dependencies = [ "bytes 1.1.0", "cfg-if 1.0.0", @@ -1979,9 +2007,9 @@ dependencies = [ [[package]] name = "molecule-codegen" -version = "0.7.3" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f57a142d0c94604531998022664c7aebe9d5a8b3ef3806c40fa971acc911678b" +checksum = "1f4e977c547ac5f302a213a2a44daf4748532bf4f2b4fc332c60052b3b72e788" dependencies = [ "case", "molecule", @@ -2984,6 +3012,12 @@ dependencies = [ "libc", ] +[[package]] +name = "siphasher" +version = "0.3.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7bd3e3206899af3f8b12af284fafc038cc1dc2b41d1b89dd17297221c5d225de" + [[package]] name = "slab" version = "0.4.5" diff --git a/web3/crates/indexer/Cargo.toml b/web3/crates/indexer/Cargo.toml index cd0fd1e5d..76c2d0165 100644 --- a/web3/crates/indexer/Cargo.toml +++ b/web3/crates/indexer/Cargo.toml @@ -10,8 +10,8 @@ edition = "2021" gw-types = { path = "../../../gwos/crates/types" } gw-common = { path = "../../../gwos/crates/common" } gw-jsonrpc-types = { path = "../../../crates/jsonrpc-types" } -ckb-hash = "0.106" -ckb-types = "0.106" +ckb-hash = "0.111.0" +ckb-types = "0.111.0" anyhow = { version = "1.0", features = ["backtrace"] } smol = "1.2.5" thiserror = "1.0" diff --git a/web3/crates/rpc-client/Cargo.toml b/web3/crates/rpc-client/Cargo.toml index 45e87866c..3ec6ad267 100644 --- a/web3/crates/rpc-client/Cargo.toml +++ b/web3/crates/rpc-client/Cargo.toml @@ -10,8 +10,8 @@ edition = "2021" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" reqwest = { version = "0.11", features = ["json", "blocking"] } -ckb-jsonrpc-types = "0.106" -ckb-types = "0.106" +ckb-jsonrpc-types = "0.111.0" +ckb-types = "0.111.0" gw-types = { path = "../../../gwos/crates/types" } gw-common = { path = "../../../gwos/crates/common" } gw-jsonrpc-types = { path = "../../../crates/jsonrpc-types" } diff --git a/web3/rust-toolchain b/web3/rust-toolchain index 5deab586f..22d6771a4 100644 --- a/web3/rust-toolchain +++ b/web3/rust-toolchain @@ -1 +1 @@ -1.68.2 +1.72.1