diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index 9fd96f0e..20773195 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -14,33 +14,38 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - name: Install latest nightly + - name: Set up toolchain uses: actions-rs/toolchain@v1 with: - toolchain: nightly + profile: minimal + toolchain: stable override: true - - name: Build & test + components: rustfmt, llvm-tools-preview + - name: Build uses: actions-rs/cargo@v1 with: - command: test - args: --workspace --all-features --no-fail-fast + command: build + args: --release env: - CARGO_INCREMENTAL: '0' - RUSTFLAGS: '-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off' - RUSTDOCFLAGS: '-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off' - - id: coverage - name: Generate coverage - uses: actions-rs/grcov@0.2-proto + CARGO_INCREMENTAL: "0" + RUSTFLAGS: "-Cinstrument-coverage" + RUSTDOCFLAGS: "-Cinstrument-coverage" + - name: Test + uses: actions-rs/cargo@v1 with: - args: > - -t lcov - --llvm - --ignore-not-existing - --ignore "/*" - -o ./target/lcov.info - ./target/debug/ + command: test + args: --all-features --no-fail-fast + env: + CARGO_INCREMENTAL: "0" + RUSTFLAGS: "-Cinstrument-coverage" + RUSTDOCFLAGS: "-Cinstrument-coverage" + - name: Install grcov + run: if [[ ! -e ~/.cargo/bin/grcov ]]; then cargo install grcov; fi + - name: Generate coverage + run: grcov . --binary-path target/debug/deps/ -s . -t lcov --branch --ignore-not-existing --ignore '../**' --ignore '/*' -o coverage.lcov - name: Upload coverage to Codecov - uses: codecov/codecov-action@v1 + uses: codecov/codecov-action@v3 with: - file: ${{ steps.coverage.outputs.report }} - directory: ./coverage/reports/ + files: ./coverage.lcov + flags: rust + fail_ci_if_error: true diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index b8979f05..3f51bde0 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -39,7 +39,7 @@ jobs: name: Clippy with: command: clippy - args: --workspace --all-features --all-targets + args: --workspace --all-features --all-targets -- -D warnings doc: runs-on: ubuntu-latest steps: diff --git a/Cargo.lock b/Cargo.lock index 8d97f667..fe600df1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,9 +4,9 @@ version = 3 [[package]] name = "aluvm" -version = "0.10.5" +version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49fd60657e5d59425e897145c167b2250238aaeaa825a6741249d120b87871bf" +checksum = "e624a600eaf54f24da48e42604ffb0fbd543808a078e5081a9441243077233df" dependencies = [ "amplify", "baid58", @@ -23,12 +23,12 @@ dependencies = [ [[package]] name = "amplify" -version = "4.0.0" +version = "4.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26966af46e0d200e8bf2b7f16230997c1c3f2d141bc27ccc091c012ed527b58" +checksum = "8629db306c0bbeb0a402e2918bdcf0026b5ddb24c46460f3bf5410b350d98710" dependencies = [ "amplify_apfloat", - "amplify_derive 3.0.1", + "amplify_derive", "amplify_num", "amplify_syn", "ascii", @@ -36,7 +36,7 @@ dependencies = [ "serde_json", "serde_yaml", "stringly_conversions", - "toml 0.5.11", + "toml", "wasm-bindgen", ] @@ -52,21 +52,9 @@ dependencies = [ [[package]] name = "amplify_derive" -version = "3.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c87df0f28e6eb1f2d355f29ba6793fa9ca643967528609608d5cbd70bd68f9d1" -dependencies = [ - "amplify_syn", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "amplify_derive" -version = "4.0.0-alpha.6" +version = "4.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01c4835e964725149d7961ec5af2ca1302f6f68c8c738b4acb06185f596c3333" +checksum = "759dcbfaf94d838367a86d493ec34ccc8aa6fe365cb7880d6bf89006de24d9c1" dependencies = [ "amplify_syn", "proc-macro2", @@ -156,21 +144,18 @@ checksum = "6107fe1be6682a68940da878d9e9f5e90ca5745b3dec9fd1bb393c8777d4f581" [[package]] name = "base64" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" - -[[package]] -name = "base64" -version = "0.21.2" +version = "0.21.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "604178f6c5c21f02dc555784810edfb88d34ac2c73b2eae109655649ee73ce3d" +checksum = "9ba43ea6f343b788c8764558649e08df62f86c6ef251fdaeb1ffd010a9ae50a2" [[package]] name = "base85" -version = "1.1.1" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88b68cde48c539cf9db81c5598e215dc32d0401a167f899cf26e35f61815eb9e" +checksum = "36915bbaca237c626689b5bd14d02f2ba7a5a359d30a2a08be697392e3718079" +dependencies = [ + "thiserror", +] [[package]] name = "bitcoin-private" @@ -186,16 +171,15 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "blake3" -version = "1.4.1" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "199c42ab6972d92c9f8995f086273d25c42fc0f7b2a1fcefba465c1352d25ba5" +checksum = "0231f06152bf547e9c2b5194f247cd97aacf6dcd8b15d8e5ec0663f64580da87" dependencies = [ "arrayref", "arrayvec", "cc", "cfg-if", "constant_time_eq", - "digest", ] [[package]] @@ -208,61 +192,58 @@ dependencies = [ ] [[package]] -name = "bp-core" -version = "0.10.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ad89567d378fb0bf06e1d3370b12c17b587563fa3ea075d22a6a3d7e3b77f2b" +name = "bp-consensus" +version = "0.10.10" +source = "git+https://github.com/BP-WG/bp-core?branch=consensus#48d79c9f210772dbd836aba258fa836169e8c36d" dependencies = [ "amplify", - "bp-dbc", - "bp-primitives", - "bp-seals", + "chrono", "commit_verify", + "secp256k1", "serde", - "single_use_seals", "strict_encoding", "strict_types", ] [[package]] -name = "bp-dbc" -version = "0.10.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac8b9fa8ce5e85c3b052f2857eb14b710e893052f2680584f48959627e78148b" +name = "bp-core" +version = "0.10.10" +source = "git+https://github.com/BP-WG/bp-core?branch=consensus#48d79c9f210772dbd836aba258fa836169e8c36d" dependencies = [ "amplify", - "base85", - "bp-primitives", + "bp-consensus", + "bp-dbc", + "bp-seals", "commit_verify", - "secp256k1", "serde", + "single_use_seals", "strict_encoding", + "strict_types", ] [[package]] -name = "bp-primitives" -version = "0.10.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "608a06488cc9909ed80b1b1dc0acedd655cfe94df60bdb6af80546b993e252e7" +name = "bp-dbc" +version = "0.10.10" +source = "git+https://github.com/BP-WG/bp-core?branch=consensus#48d79c9f210772dbd836aba258fa836169e8c36d" dependencies = [ "amplify", + "base85", + "bp-consensus", "commit_verify", "secp256k1", "serde", "strict_encoding", - "strict_types", ] [[package]] name = "bp-seals" -version = "0.10.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f02ea90eaca184fda85230cfac2457fd352c3d81bd28f67254185d0b199eb6f" +version = "0.10.10" +source = "git+https://github.com/BP-WG/bp-core?branch=consensus#48d79c9f210772dbd836aba258fa836169e8c36d" dependencies = [ "amplify", "baid58", + "bp-consensus", "bp-dbc", - "bp-primitives", "commit_verify", "rand", "serde", @@ -272,21 +253,24 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.13.0" +version = "3.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3e2c3daef883ecc1b5d58c15adae93470a91d425f3532ba1695849656af3fc1" +checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" [[package]] name = "byteorder" -version = "1.4.3" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "cc" -version = "1.0.79" +version = "1.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" +checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" +dependencies = [ + "libc", +] [[package]] name = "cfg-if" @@ -296,15 +280,16 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.26" +version = "0.4.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec837a71355b28f6556dbd569b37b3f363091c0bd4b2e735674521b4c5fd9bc5" +checksum = "7f2c685bad3eb3d45a01354cedb7d5faa66194d1d58ba6e267a8de788f79db38" dependencies = [ "android-tzdata", "iana-time-zone", + "js-sys", "num-traits", - "serde", - "winapi", + "wasm-bindgen", + "windows-targets", ] [[package]] @@ -322,13 +307,14 @@ dependencies = [ [[package]] name = "commit_verify" -version = "0.10.5" +version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "caa8114b3ff20947176c8cbfd1e84e56649501eed4e33ba9205c70374b2615ae" +checksum = "91d9d6e86f6cec8d4af19a0e418bac9cb266a6dc70660bcdcdac1e0fa924e0d1" dependencies = [ "amplify", "commit_encoding_derive", "rand", + "ripemd", "serde", "sha2", "strict_encoding", @@ -382,41 +368,6 @@ dependencies = [ "typenum", ] -[[package]] -name = "darling" -version = "0.20.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0209d94da627ab5605dcccf08bb18afa5009cfbef48d8a8b7d7bdbc79be25c5e" -dependencies = [ - "darling_core", - "darling_macro", -] - -[[package]] -name = "darling_core" -version = "0.20.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "177e3443818124b357d8e76f53be906d60937f0d3a90773a664fa63fa253e621" -dependencies = [ - "fnv", - "ident_case", - "proc-macro2", - "quote", - "strsim", - "syn 2.0.27", -] - -[[package]] -name = "darling_macro" -version = "0.20.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5" -dependencies = [ - "darling_core", - "quote", - "syn 2.0.27", -] - [[package]] name = "digest" version = "0.10.7" @@ -425,7 +376,6 @@ checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer", "crypto-common", - "subtle", ] [[package]] @@ -434,12 +384,6 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" -[[package]] -name = "fnv" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" - [[package]] name = "generic-array" version = "0.14.7" @@ -474,15 +418,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" - -[[package]] -name = "hashbrown" -version = "0.14.0" +version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" +checksum = "7dfda62a12f55daeae5015f81b0baea145391cb4520f86c248fc615d72640d12" [[package]] name = "heck" @@ -490,12 +428,6 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" -[[package]] -name = "hex" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" - [[package]] name = "iana-time-zone" version = "0.1.57" @@ -519,31 +451,14 @@ dependencies = [ "cc", ] -[[package]] -name = "ident_case" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" - -[[package]] -name = "indexmap" -version = "1.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" -dependencies = [ - "autocfg", - "hashbrown 0.12.3", - "serde", -] - [[package]] name = "indexmap" -version = "2.0.0" +version = "2.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d" +checksum = "8adf3ddd720272c6ea8bf59463c04e0f93d0bbf7c5439b691bca2987e0270897" dependencies = [ "equivalent", - "hashbrown 0.14.0", + "hashbrown", ] [[package]] @@ -569,21 +484,21 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.147" +version = "0.2.149" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" +checksum = "a08173bc88b7955d1b3145aa561539096c421ac8debde8cbc3612ec635fee29b" [[package]] name = "log" -version = "0.4.19" +version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4" +checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" [[package]] name = "memchr" -version = "2.5.0" +version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" +checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" [[package]] name = "mime" @@ -603,9 +518,9 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.16" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f30b0abd723be7e2ffca1272140fac1a2f084c77ec3e123c192b66af1ee9e6c2" +checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" dependencies = [ "autocfg", ] @@ -630,18 +545,18 @@ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "proc-macro2" -version = "1.0.66" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" +checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.32" +version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50f3b39ccfb720540debaa0164757101c08ecb8d326b15358ce76a62c7e85965" +checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" dependencies = [ "proc-macro2", ] @@ -740,9 +655,9 @@ dependencies = [ [[package]] name = "secp256k1-zkp" -version = "0.8.0" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c07a95044ad86d2bfde4bb9bc99728aad3b311aa4fabea9db3b670846224186" +checksum = "026efcdacb95ee6aae5cc19144dc1549973eac36a4972700c28493de1ee5d69f" dependencies = [ "bitcoin-private", "rand", @@ -763,29 +678,29 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.174" +version = "1.0.188" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b88756493a5bd5e5395d53baa70b194b05764ab85b59e43e4b8f4e1192fa9b1" +checksum = "cf9e0fcba69a370eed61bcf2b728575f726b50b55cba78064753d708ddc7549e" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.174" +version = "1.0.188" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e5c3a298c7f978e53536f95a63bdc4c4a64550582f31a0359a9afda6aede62e" +checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.27", + "syn 2.0.38", ] [[package]] name = "serde_json" -version = "1.0.103" +version = "1.0.107" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d03b412469450d4404fe8499a268edd7f8b79fecb074b0d812ad64ca21f4031b" +checksum = "6b420ce6e3d8bd882e9b243c6eed35dbc9a6110c9769e74b584e0d68d1f20c65" dependencies = [ "itoa", "ryu", @@ -811,41 +726,13 @@ dependencies = [ "serde_derive", ] -[[package]] -name = "serde_with" -version = "2.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07ff71d2c147a7b57362cead5e22f772cd52f6ab31cfcd9edcd7f6aeb2a0afbe" -dependencies = [ - "base64 0.13.1", - "chrono", - "hex", - "indexmap 1.9.3", - "serde", - "serde_json", - "serde_with_macros", - "time", -] - -[[package]] -name = "serde_with_macros" -version = "2.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "881b6f881b17d13214e5d494c939ebab463d01264ce1811e9d4ac3a882e7695f" -dependencies = [ - "darling", - "proc-macro2", - "quote", - "syn 2.0.27", -] - [[package]] name = "serde_yaml" version = "0.9.25" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1a49e178e4452f45cb61d0cd8cebc1b0fafd3e41929e996cef79aa3aca91f574" dependencies = [ - "indexmap 2.0.0", + "indexmap", "itoa", "ryu", "serde", @@ -854,9 +741,9 @@ dependencies = [ [[package]] name = "sha2" -version = "0.10.7" +version = "0.10.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "479fb9d862239e610720565ca91403019f2f00410f1864c5aa7479b950a76ed8" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" dependencies = [ "cfg-if", "cpufeatures", @@ -865,18 +752,18 @@ dependencies = [ [[package]] name = "single_use_seals" -version = "0.10.0" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ae7f7cb6a68cfc99674a70a47ab790c6ede965107cd0823ed814b5e73b3bee2" +checksum = "ed7655b4b597fca10d2cf7579d3dfee1987a45342bdeecf90cab5affec1c7197" dependencies = [ - "amplify_derive 4.0.0-alpha.6", + "amplify_derive", ] [[package]] name = "strict_encoding" -version = "2.5.0" +version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23b1c91b79e62afc09025d828fa0b8dbf4105513de38f126a017919c09bca472" +checksum = "ab7b75b4af0aff9dd97b68df262bf0e807b7d007cc860fa217943f898a05a5ab" dependencies = [ "amplify", "half", @@ -886,9 +773,9 @@ dependencies = [ [[package]] name = "strict_encoding_derive" -version = "2.0.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f5adae55367464f5a229bfd539682c94f870b98a220be6e61dc43f85d612e7e" +checksum = "37064ec285e2a633465eb525c8698eea51373dee889fe310e0d32df8343e7f4f" dependencies = [ "amplify_syn", "heck", @@ -899,22 +786,21 @@ dependencies = [ [[package]] name = "strict_types" -version = "1.6.0" +version = "1.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8a6654c43ed02891b249730856ad6b866fd85d1008aad51b30bd68812798427" +checksum = "d10cc45e67d452cfe0d87d4714c3250190d97479af3502bbd823651bfe0f505f" dependencies = [ "amplify", "baid58", - "base64 0.21.2", + "base64", "half", - "indexmap 1.9.3", + "indexmap", "serde", "serde_json", - "serde_with", "serde_yaml", "sha2", "strict_encoding", - "toml 0.7.6", + "toml", ] [[package]] @@ -927,18 +813,6 @@ dependencies = [ "serde_str_helpers", ] -[[package]] -name = "strsim" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" - -[[package]] -name = "subtle" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" - [[package]] name = "syn" version = "1.0.109" @@ -952,9 +826,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.27" +version = "2.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b60f673f44a8255b9c8c657daf66a596d435f2da81a555b06dc644d080ba45e0" +checksum = "e96b79aaa137db8f61e26363a0c9b47d8b4ec75da28b7d1d614c2303e232408b" dependencies = [ "proc-macro2", "quote", @@ -962,46 +836,30 @@ dependencies = [ ] [[package]] -name = "time" -version = "0.3.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59e399c068f43a5d116fedaf73b203fa4f9c519f17e2b34f63221d3792f81446" -dependencies = [ - "itoa", - "serde", - "time-core", - "time-macros", -] - -[[package]] -name = "time-core" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb" - -[[package]] -name = "time-macros" -version = "0.2.10" +name = "thiserror" +version = "1.0.49" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96ba15a897f3c86766b757e5ac7221554c6750054d74d5b28844fce5fb36a6c4" +checksum = "1177e8c6d7ede7afde3585fd2513e611227efd6481bd78d2e82ba1ce16557ed4" dependencies = [ - "time-core", + "thiserror-impl", ] [[package]] -name = "toml" -version = "0.5.11" +name = "thiserror-impl" +version = "1.0.49" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" +checksum = "10712f02019e9288794769fba95cd6847df9874d49d871d062172f9dd41bc4cc" dependencies = [ - "serde", + "proc-macro2", + "quote", + "syn 2.0.38", ] [[package]] name = "toml" -version = "0.7.6" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c17e963a819c331dcacd7ab957d80bc2b9a9c1e71c804826d2f283dd65306542" +checksum = "185d8ab0dfbb35cf1399a6344d8484209c088f75f8f68230da55d48d95d43e3d" dependencies = [ "serde", "serde_spanned", @@ -1020,11 +878,11 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.19.14" +version = "0.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8123f27e969974a3dfba720fdb560be359f57b44302d280ba72e76a74480e8a" +checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" dependencies = [ - "indexmap 2.0.0", + "indexmap", "serde", "serde_spanned", "toml_datetime", @@ -1033,15 +891,15 @@ dependencies = [ [[package]] name = "typenum" -version = "1.16.0" +version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] name = "unicode-ident" -version = "1.0.11" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "unsafe-libyaml" @@ -1082,7 +940,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.27", + "syn 2.0.38", "wasm-bindgen-shared", ] @@ -1116,7 +974,7 @@ checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.27", + "syn 2.0.38", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -1161,28 +1019,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - [[package]] name = "windows" version = "0.48.0" @@ -1194,9 +1030,9 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.48.1" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05d4b17490f70499f20b9e791dcf6a299785ce8af4d709018206dc5b4953e95f" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" dependencies = [ "windows_aarch64_gnullvm", "windows_aarch64_msvc", @@ -1209,51 +1045,51 @@ dependencies = [ [[package]] name = "windows_aarch64_gnullvm" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_msvc" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_i686_gnu" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_msvc" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_x86_64_gnu" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnullvm" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_msvc" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "winnow" -version = "0.5.0" +version = "0.5.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81fac9742fd1ad1bd9643b991319f72dd031016d44b77039a26977eb667141e7" +checksum = "037711d82167854aff2018dfd193aa0fef5370f456732f0d5a0c59b0f1b4b907" dependencies = [ "memchr", ] diff --git a/Cargo.toml b/Cargo.toml index c29f5010..63d93646 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,16 +22,16 @@ name = "rgbcore-stl" required-features = ["stl"] [dependencies] -amplify = "~4.0.0" -strict_encoding = "~2.5.0" -strict_types = "~1.6.0" -aluvm = { version = "~0.10.5", features = ["std"] } -commit_verify = { version = "~0.10.5", features = ["rand", "derive"] } -single_use_seals = "~0.10.0" -bp-core = { version = "~0.10.7" } -secp256k1-zkp = { version = "0.8.0", features = ["use-rand", "rand-std", "global-context"] } +amplify = "~4.5.0" +strict_encoding = "~2.6.1" +strict_types = "~1.6.3" +aluvm = { version = "~0.10.6", features = ["std"] } +commit_verify = { version = "~0.10.6", features = ["rand", "derive"] } +single_use_seals = "~0.10.1" +bp-core = { version = "~0.10.10" } +secp256k1-zkp = { version = "0.9.2", features = ["rand", "rand-std", "global-context"] } baid58 = "~0.4.4" -mime = "~0.3.16" +mime = "~0.3.17" serde_crate = { package = "serde", version = "1", features = ["derive"], optional = true } [features] @@ -46,7 +46,7 @@ serde = [ "commit_verify/serde", "bp-core/serde", "aluvm/serde", - "secp256k1-zkp/use-serde" + "secp256k1-zkp/serde" ] [target.'cfg(target_arch = "wasm32")'.dependencies] @@ -59,3 +59,9 @@ wasm-bindgen-test = "0.3" [package.metadata.docs.rs] features = [ "all" ] + +[patch.crates-io] +bp-consensus = { git = "https://github.com/BP-WG/bp-core", branch = "consensus" } +bp-dbc = { git = "https://github.com/BP-WG/bp-core", branch = "consensus" } +bp-seals = { git = "https://github.com/BP-WG/bp-core", branch = "consensus" } +bp-core = { git = "https://github.com/BP-WG/bp-core", branch = "consensus" } diff --git a/src/contract/assignments.rs b/src/contract/assignments.rs index e736ad2c..a397306f 100644 --- a/src/contract/assignments.rs +++ b/src/contract/assignments.rs @@ -91,10 +91,7 @@ pub enum Assign { // here we use deterministic ordering based on hash values of the concealed // seal data contained within the assignment impl PartialOrd for Assign { - fn partial_cmp(&self, other: &Self) -> Option { - self.to_confidential_seal() - .partial_cmp(&other.to_confidential_seal()) - } + fn partial_cmp(&self, other: &Self) -> Option { Some(self.cmp(other)) } } impl Ord for Assign { @@ -128,7 +125,7 @@ impl Assign { Assign::Confidential { seal: _, state } | Assign::ConfidentialState { seal: _, state } => Assign::ConfidentialState { seal, - state: state.clone(), + state: *state, }, Assign::ConfidentialSeal { seal: _, state } | Assign::Revealed { seal: _, state } => { Assign::Revealed { @@ -160,9 +157,7 @@ impl Assign { Assign::Revealed { state, .. } | Assign::ConfidentialSeal { state, .. } => { state.conceal() } - Assign::Confidential { state, .. } | Assign::ConfidentialState { state, .. } => { - state.clone() - } + Assign::Confidential { state, .. } | Assign::ConfidentialState { state, .. } => *state, } } @@ -212,7 +207,7 @@ where Self: Clone Assign::Confidential { .. } => self.clone(), Assign::ConfidentialState { seal, state } => Self::Confidential { seal: seal.conceal(), - state: state.clone(), + state: *state, }, Assign::Revealed { seal, state } => Self::Confidential { seal: seal.conceal(), @@ -265,7 +260,7 @@ impl Assign { match self { Assign::Confidential { seal, state } => Assign::Confidential { seal: *seal, - state: state.clone(), + state: *state, }, Assign::ConfidentialSeal { seal, state } => Assign::ConfidentialSeal { seal: *seal, @@ -277,7 +272,7 @@ impl Assign { }, Assign::ConfidentialState { seal, state } => Assign::ConfidentialState { seal: seal.transmutate(), - state: state.clone(), + state: *state, }, } } diff --git a/src/contract/attachment.rs b/src/contract/attachment.rs index 4f3d1121..1545f1e1 100644 --- a/src/contract/attachment.rs +++ b/src/contract/attachment.rs @@ -22,7 +22,7 @@ use std::str::FromStr; -use amplify::{Bytes32, RawArray}; +use amplify::{ByteArray, Bytes32}; use baid58::{Baid58ParseError, Chunking, FromBaid58, ToBaid58, CHUNKING_32}; use bp::secp256k1::rand::{thread_rng, RngCore}; use commit_verify::{CommitVerify, Conceal, StrictEncodedProtocol}; @@ -51,7 +51,7 @@ pub struct AttachId( impl ToBaid58<32> for AttachId { const HRI: &'static str = "stashfs"; const CHUNKING: Option = CHUNKING_32; - fn to_baid58_payload(&self) -> [u8; 32] { self.to_raw_array() } + fn to_baid58_payload(&self) -> [u8; 32] { self.to_byte_array() } fn to_baid58_string(&self) -> String { self.to_string() } } impl FromBaid58<32> for AttachId {} @@ -143,7 +143,7 @@ mod test { fn attach_id_display() { const ID: &str = "stashfs:8JEvTX-J6sD5U4n-1p7GEERY-MPN9ijjs-9ZM4ysJ3-qhgyqM#juice-empty-joker"; - let id = AttachId::from_raw_array([0x6c; 32]); + let id = AttachId::from_byte_array([0x6c; 32]); assert_eq!(ID, id.to_string()); assert_eq!(ID, id.to_baid58_string()); assert_eq!("juice-empty-joker", id.to_mnemonic()); @@ -151,7 +151,7 @@ mod test { #[test] fn attach_id_from_str() { - let id = AttachId::from_raw_array([0x6c; 32]); + let id = AttachId::from_byte_array([0x6c; 32]); assert_eq!( Ok(id), AttachId::from_str( diff --git a/src/contract/contract.rs b/src/contract/contract.rs index 59715120..45b8fc86 100644 --- a/src/contract/contract.rs +++ b/src/contract/contract.rs @@ -112,19 +112,19 @@ pub struct OutputAssignment { impl PartialEq for OutputAssignment { fn eq(&self, other: &Self) -> bool { - if self.opout == other.opout { - if self.seal != other.seal || self.witness != other.witness || self.state != other.state - { - panic!( - "RGB was provided with an updated operation using different witness \ - transaction. This may happen for instance when some ephemeral state (like a \ - commitment or HTLC transactions in the lightning channels) is added to the \ - stash.\nThis error means the software uses RGB stash in an invalid way and \ - has business logic bug which has to be fixed.\nOperation in stash: {:?}\nNew \ - operation: {:?}\n", - self, other - ) - } + if self.opout == other.opout && + (self.seal != other.seal || + self.witness != other.witness || + self.state != other.state) + { + panic!( + "RGB was provided with an updated operation using different witness transaction. \ + This may happen for instance when some ephemeral state (like a commitment or \ + HTLC transactions in the lightning channels) is added to the stash.\nThis error \ + means the software uses RGB stash in an invalid way and has business logic bug \ + which has to be fixed.\nOperation in stash: {:?}\nNew operation: {:?}\n", + self, other + ) } self.opout == other.opout } @@ -521,19 +521,14 @@ impl ContractHistory { .filter_map(|(n, a)| a.to_revealed().map(|(seal, state)| (n, seal, state))) { let assigned_state = match witness { - SealWitness::Present(txid) => OutputAssignment::with_witness( - seal, - txid, - state.into(), - opid, - ty, - no as u16, - ), + SealWitness::Present(txid) => { + OutputAssignment::with_witness(seal, txid, state, opid, ty, no as u16) + } SealWitness::Genesis => { - OutputAssignment::with_genesis(seal, state.into(), opid, ty, no as u16) + OutputAssignment::with_genesis(seal, state, opid, ty, no as u16) } SealWitness::Extension => { - OutputAssignment::with_extension(seal, state.into(), opid, ty, no as u16) + OutputAssignment::with_extension(seal, state, opid, ty, no as u16) } }; contract_state @@ -545,16 +540,16 @@ impl ContractHistory { for (ty, assignments) in assignments.iter() { match assignments { TypedAssigns::Declarative(assignments) => { - process(&mut self.rights, &assignments, opid, *ty, witness) + process(&mut self.rights, assignments, opid, *ty, witness) } TypedAssigns::Fungible(assignments) => { - process(&mut self.fungibles, &assignments, opid, *ty, witness) + process(&mut self.fungibles, assignments, opid, *ty, witness) } TypedAssigns::Structured(assignments) => { - process(&mut self.data, &assignments, opid, *ty, witness) + process(&mut self.data, assignments, opid, *ty, witness) } TypedAssigns::Attachment(assignments) => { - process(&mut self.attach, &assignments, opid, *ty, witness) + process(&mut self.attach, assignments, opid, *ty, witness) } } } @@ -586,7 +581,7 @@ impl DerefMut for ContractState { } impl ContractState { - /// # Panics + /// # Safety /// /// If the specified state type is not part of the schema. pub unsafe fn global_unchecked(&self, state_type: GlobalStateType) -> SmallVec<&RevealedData> { diff --git a/src/contract/fungible.rs b/src/contract/fungible.rs index bd3d8a43..8bd79005 100644 --- a/src/contract/fungible.rs +++ b/src/contract/fungible.rs @@ -225,13 +225,7 @@ impl CommitEncode for RevealedValue { } impl PartialOrd for RevealedValue { - fn partial_cmp(&self, other: &Self) -> Option { - match self.value.partial_cmp(&other.value) { - None => None, - Some(Ordering::Equal) => self.blinding.0.partial_cmp(&other.blinding.0), - other => other, - } - } + fn partial_cmp(&self, other: &Self) -> Option { Some(self.cmp(other)) } } impl Ord for RevealedValue { @@ -296,7 +290,7 @@ impl CommitVerify for PedersenCommitment { let one_key = secp256k1_zkp::SecretKey::from_slice(&secp256k1_zkp::constants::ONE) .expect("secret key from a constant"); let g = secp256k1_zkp::PublicKey::from_secret_key(SECP256K1, &one_key); - let h: [u8; 32] = Sha256::digest(&g.serialize_uncompressed()).into(); + let h: [u8; 32] = Sha256::digest(g.serialize_uncompressed()).into(); let tag = Tag::from(h); let generator = Generator::new_unblinded(SECP256K1, tag); @@ -433,7 +427,6 @@ mod test { let value = RevealedValue::new(15, &mut thread_rng()); let generators = (0..10) - .into_iter() .map(|_| { let mut val = vec![]; value.commit_encode(&mut val); diff --git a/src/contract/mod.rs b/src/contract/mod.rs index 81692edc..5ec6aaf9 100644 --- a/src/contract/mod.rs +++ b/src/contract/mod.rs @@ -29,6 +29,7 @@ pub mod seal; pub mod assignments; mod operations; mod bundle; +#[allow(clippy::module_inception)] mod contract; pub use assignments::{ diff --git a/src/contract/operations.rs b/src/contract/operations.rs index c8f6797c..861465a8 100644 --- a/src/contract/operations.rs +++ b/src/contract/operations.rs @@ -28,7 +28,7 @@ use std::str::FromStr; use amplify::confinement::{SmallBlob, TinyOrdMap, TinyOrdSet}; use amplify::hex::{FromHex, ToHex}; -use amplify::{hex, Bytes32, RawArray, Wrapper}; +use amplify::{hex, ByteArray, Bytes32, Wrapper}; use baid58::{Baid58ParseError, Chunking, FromBaid58, ToBaid58, CHUNKING_32CHECKSUM}; use bp::Chain; use commit_verify::{mpc, CommitmentId, Conceal}; @@ -150,8 +150,9 @@ impl FromStr for OpId { } impl OpId { + // TODO: Add failable version pub fn from_slice(slice: impl AsRef<[u8]>) -> Option { - Bytes32::from_slice(slice).map(Self) + Bytes32::copy_from_slice(slice).ok().map(Self) } } @@ -172,22 +173,23 @@ pub struct ContractId( ); impl PartialEq for ContractId { - fn eq(&self, other: &OpId) -> bool { self.to_raw_array() == other.to_raw_array() } + fn eq(&self, other: &OpId) -> bool { self.to_byte_array() == other.to_byte_array() } } impl PartialEq for OpId { - fn eq(&self, other: &ContractId) -> bool { self.to_raw_array() == other.to_raw_array() } + fn eq(&self, other: &ContractId) -> bool { self.to_byte_array() == other.to_byte_array() } } impl ContractId { + // TODO: Add failable version pub fn from_slice(slice: impl AsRef<[u8]>) -> Option { - Bytes32::from_slice(slice).map(Self) + Bytes32::copy_from_slice(slice).ok().map(Self) } } impl ToBaid58<32> for ContractId { const HRI: &'static str = "rgb"; const CHUNKING: Option = CHUNKING_32CHECKSUM; - fn to_baid58_payload(&self) -> [u8; 32] { self.to_raw_array() } + fn to_baid58_payload(&self) -> [u8; 32] { self.to_byte_array() } fn to_baid58_string(&self) -> String { self.to_string() } } impl FromBaid58<32> for ContractId {} @@ -646,7 +648,7 @@ mod test { #[test] fn contract_id_display() { const ID: &str = "rgb:pkXwpsb-aemTWhtSg-VDGF25hEi-jtTAnPjzh-B63ZwSehE-WvfhF9"; - let id = ContractId::from_raw_array([0x6c; 32]); + let id = ContractId::from_byte_array([0x6c; 32]); assert_eq!(ID.len(), 58); assert_eq!(ID.replace('-', ""), format!("{id:#}")); assert_eq!(ID, id.to_string()); @@ -655,7 +657,7 @@ mod test { #[test] fn contract_id_from_str() { - let id = ContractId::from_raw_array([0x6c; 32]); + let id = ContractId::from_byte_array([0x6c; 32]); assert_eq!( Ok(id), ContractId::from_str("rgb:pkXwpsb-aemTWhtSg-VDGF25hEi-jtTAnPjzh-B63ZwSehE-WvfhF9") diff --git a/src/contract/state.rs b/src/contract/state.rs index 5710c019..82b60c34 100644 --- a/src/contract/state.rs +++ b/src/contract/state.rs @@ -135,6 +135,7 @@ impl Conceal for StateData { derive(Serialize, Deserialize), serde(crate = "serde_crate", rename_all = "camelCase") )] +#[allow(clippy::large_enum_variant)] pub enum StateCommitment { #[strict_type(tag = 0x00, dumb)] Void, diff --git a/src/schema/schema.rs b/src/schema/schema.rs index e12c7831..31613431 100644 --- a/src/schema/schema.rs +++ b/src/schema/schema.rs @@ -25,7 +25,7 @@ use std::fmt::{self, Display, Formatter}; use std::str::FromStr; use amplify::confinement::{TinyOrdMap, TinyOrdSet}; -use amplify::{Bytes32, RawArray}; +use amplify::{ByteArray, Bytes32}; use baid58::{Baid58ParseError, Chunking, FromBaid58, ToBaid58, CHUNKING_32}; use commit_verify::{CommitStrategy, CommitmentId}; use strict_encoding::{StrictDecode, StrictDeserialize, StrictEncode, StrictSerialize, StrictType}; @@ -69,7 +69,7 @@ pub struct SchemaId( impl ToBaid58<32> for SchemaId { const HRI: &'static str = "sc"; const CHUNKING: Option = CHUNKING_32; - fn to_baid58_payload(&self) -> [u8; 32] { self.to_raw_array() } + fn to_baid58_payload(&self) -> [u8; 32] { self.to_byte_array() } fn to_baid58_string(&self) -> String { self.to_string() } } impl FromBaid58<32> for SchemaId {} @@ -179,7 +179,7 @@ mod test { ); assert_eq!(&format!("{dumb:-}"), "urn:lnp-bp:sc:111111-11111111-11111111-11111111-11"); - let less_dumb = SchemaId::from_raw_array(*b"EV4350-'4vwj'4;v-w94w'e'vFVVDhpq"); + let less_dumb = SchemaId::from_byte_array(*b"EV4350-'4vwj'4;v-w94w'e'vFVVDhpq"); assert_eq!( less_dumb.to_string(), "urn:lnp-bp:sc:5ffNUk-MTVSnWqu-PLT6xKb7-VmAxUbw8-CUNqCkUW-sZfkwz#\ diff --git a/src/stl.rs b/src/stl.rs index ed4cff02..d4380454 100644 --- a/src/stl.rs +++ b/src/stl.rs @@ -21,7 +21,7 @@ // limitations under the License. pub use aluvm::stl::aluvm_stl; -pub use bp::bc::stl::bitcoin_stl; +pub use bp::bc::stl::bp_tx_stl; pub use bp::stl::bp_core_stl; use strict_types::stl::{std_stl, strict_types_stl}; use strict_types::typelib::LibBuilder; @@ -37,7 +37,7 @@ fn _rgb_core_stl() -> Result { LibBuilder::new(libname!(LIB_NAME_RGB), tiny_bset! { std_stl().to_dependency(), strict_types_stl().to_dependency(), - bitcoin_stl().to_dependency(), + bp_tx_stl().to_dependency(), bp_core_stl().to_dependency(), aluvm_stl().to_dependency() }) diff --git a/src/validation/model.rs b/src/validation/model.rs index 0b075657..49da1897 100644 --- a/src/validation/model.rs +++ b/src/validation/model.rs @@ -35,7 +35,7 @@ use crate::{ }; impl Schema { - pub fn validate<'script, C: ConsignmentApi>( + pub fn validate( &self, consignment: &C, op: OpRef, @@ -139,14 +139,14 @@ impl Schema { status += self.validate_type_system(); status += self.validate_metadata(id, *metadata_schema, op.metadata()); status += self.validate_global_state(id, op.globals(), global_schema); - let prev_state = if let OpRef::Transition(ref transition) = op { + let prev_state = if let OpRef::Transition(transition) = op { let prev_state = extract_prev_state(consignment, id, &transition.inputs, &mut status); status += self.validate_prev_state(id, &prev_state, owned_schema); prev_state } else { Assignments::default() }; - let redeemed = if let OpRef::Extension(ref extension) = op { + let redeemed = if let OpRef::Extension(extension) = op { let redeemed = extract_redeemed_valencies(consignment, &extension.redeemed, &mut status); status += self.validate_redeemed(id, &redeemed, redeem_schema); @@ -292,7 +292,7 @@ impl Schema { .unwrap_or(0); // Checking number of ancestor's assignment occurrences - if let Err(err) = occ.check(len as u16) { + if let Err(err) = occ.check(len) { status.add_failure(validation::Failure::SchemaInputOccurrences( id, *owned_type_id, @@ -350,7 +350,7 @@ impl Schema { .unwrap_or(0); // Checking number of assignment occurrences - if let Err(err) = occ.check(len as u16) { + if let Err(err) = occ.check(len) { status.add_failure(validation::Failure::SchemaAssignmentOccurrences( id, *state_id, err, )); diff --git a/src/validation/script.rs b/src/validation/script.rs index db504915..8a6fb322 100644 --- a/src/validation/script.rs +++ b/src/validation/script.rs @@ -28,6 +28,7 @@ use crate::{validation, Script}; /// RGB schema validation routines. pub trait VirtualMachine { /// Validates state change in a contract operation. + #[allow(clippy::result_large_err)] fn validate(&self, info: OpInfo) -> Result<(), validation::Failure>; } diff --git a/src/validation/state.rs b/src/validation/state.rs index 11efeccf..df5d8473 100644 --- a/src/validation/state.rs +++ b/src/validation/state.rs @@ -81,7 +81,7 @@ impl StateSchema { status.add_failure(validation::Failure::MediaTypeMismatch { opid: *opid, state_type, - expected: media_type.clone(), + expected: *media_type, found: attach.media_type, }); } diff --git a/src/validation/validator.rs b/src/validation/validator.rs index 896b0897..416c5477 100644 --- a/src/validation/validator.rs +++ b/src/validation/validator.rs @@ -275,7 +275,7 @@ impl<'consignment, 'resolver, C: ConsignmentApi, R: ResolveTx> OpRef::Genesis(_) => { // nothing to add to the queue here } - OpRef::Transition(ref transition) => { + OpRef::Transition(transition) => { // Making sure we do have a corresponding anchor; otherwise reporting failure // (see below) - with the except of genesis and extension nodes, which does not // have a corresponding anchor @@ -315,7 +315,7 @@ impl<'consignment, 'resolver, C: ConsignmentApi, R: ResolveTx> queue.extend(parent_nodes); } - OpRef::Extension(ref extension) => { + OpRef::Extension(extension) => { for (valency, prev_id) in &extension.redeemed { let Some(prev_op) = self.consignment.operation(*prev_id) else { self.status.add_failure(Failure::ValencyNoParent {