diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 02421eb00..c5da7eafe 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -124,7 +124,7 @@ jobs: fail-fast: false matrix: # We want newer versions than 'latest' here to have current wasm-opt - os: ["ubuntu-22.04", "macos-12"] + os: ["ubuntu-22.04", "macos-15"] runs-on: ${{ matrix.os }} env: RUST_BACKTRACE: full @@ -163,7 +163,7 @@ jobs: fail-fast: false matrix: # We want newer versions than 'latest' here to have current wasm-opt - os: ["ubuntu-22.04", "macos-12"] + os: ["ubuntu-22.04", "macos-15"] partition: [1, 2] runs-on: ${{ matrix.os }} env: @@ -207,7 +207,7 @@ jobs: fail-fast: false matrix: # We want newer versions than 'latest' here to have current wasm-opt - os: ["ubuntu-22.04", "macos-12"] + os: ["ubuntu-22.04", "macos-15"] partition: [1, 2] runs-on: ${{ matrix.os }} env: @@ -252,8 +252,8 @@ jobs: fi curl -L -o substrate-contracts-node.tar.gz "$CONTRACTS_NODE_URL$CONTRACTS_NODE_OS.tar.gz" tar xfzv substrate-contracts-node.tar.gz - chmod +x artifacts/substrate-contracts-node-*/substrate-contracts-node && - mv artifacts/substrate-contracts-node-*/substrate-contracts-node /usr/local/bin + chmod +x substrate-contracts-node-*/substrate-contracts-node && + mv substrate-contracts-node-*/substrate-contracts-node /usr/local/bin shell: bash - name: Run integration tests @@ -265,7 +265,7 @@ jobs: fail-fast: false matrix: # We want newer versions than 'latest' here to have current wasm-opt - os: ["ubuntu-22.04", "macos-12", "windows-2022"] + os: ["ubuntu-22.04", "macos-15", "windows-2022"] runs-on: ${{ matrix.os }} steps: - name: Checkout diff --git a/CHANGELOG.md b/CHANGELOG.md index 7804fdaa1..8cc7326b2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +[Unreleased] + +### Changed +- Target `pallet-revive` instead of `pallet-contracts` - [#1851](https://github.com/use-ink/cargo-contract/pull/1851) + ## [5.0.1] ### Changed diff --git a/Cargo.lock b/Cargo.lock index eb2bc8e9e..c61f887e2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -107,9 +107,9 @@ dependencies = [ [[package]] name = "allocator-api2" -version = "0.2.20" +version = "0.2.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45862d1c77f2228b9e10bc609d5bc203d86ebc9b87ad8d5d5167a6c9abf739d9" +checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" [[package]] name = "alloy-primitives" @@ -153,7 +153,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", "syn-solidity", "tiny-keccak", ] @@ -260,7 +260,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -828,7 +828,7 @@ checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -851,7 +851,7 @@ checksum = "3c87f3f15e7794432337fc718554eaa4dc8f04c9677a950ffe366f20a162ae42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -1159,7 +1159,7 @@ dependencies = [ "proc-macro-crate 3.2.0", "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -1541,9 +1541,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.8.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ac0150caa2ae65ca5bd83f25c7de183dea78d4d366469f148435e2acfbad0da" +checksum = "325918d6fe32f23b19878fe4b34794ae41fc19ddbe53b10571a4874d44ffd39b" [[package]] name = "camino" @@ -1594,9 +1594,9 @@ dependencies = [ [[package]] name = "cargo-platform" -version = "0.1.8" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24b1f0365a6c6bb4020cd05806fd0d33c44d38046b8bd7f0e40814b9763cabfc" +checksum = "e35af189006b9c0f00a064685c727031e3ed2d8020f7ba284d78cc2671bd36ea" dependencies = [ "serde", ] @@ -1631,9 +1631,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.2.1" +version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd9de9f2205d5ef3fd67e685b0df337994ddd4495e2a28d185500d0e1edfea47" +checksum = "f34d93e62b03caf570cccc334cbc6c2fceca82f39211051345108adcba3eebdc" dependencies = [ "jobserver", "libc", @@ -1733,7 +1733,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -1829,9 +1829,9 @@ dependencies = [ [[package]] name = "const-hex" -version = "1.13.2" +version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "487981fa1af147182687064d0a2c336586d337a606595ced9ffb0c685c250c73" +checksum = "4b0485bab839b018a8f1723fc5391819fea5f8f0f32288ef8a735fd096b6160c" dependencies = [ "cfg-if", "cpufeatures", @@ -1931,6 +1931,7 @@ dependencies = [ "hex", "impl-serde 0.5.0", "parity-scale-codec", + "polkavm-linker 0.17.1", "pretty_assertions", "regex", "rustc_version 0.4.1", @@ -2017,7 +2018,7 @@ dependencies = [ "contract-metadata", "escape8259", "hex", - "indexmap 2.6.0", + "indexmap 2.7.0", "ink", "ink_env", "ink_metadata", @@ -2387,7 +2388,7 @@ dependencies = [ "proc-macro-crate 3.2.0", "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -2638,16 +2639,17 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] name = "cxx" -version = "1.0.131" +version = "1.0.133" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2568d7d2cfc051e43414fe1ef80c712cbcd60c3624d1ad1cb4b2572324d0a5d9" +checksum = "05e1ec88093d2abd9cf1b09ffd979136b8e922bf31cad966a8fe0d73233112ef" dependencies = [ "cc", + "cxxbridge-cmd", "cxxbridge-flags", "cxxbridge-macro", "foldhash", @@ -2656,34 +2658,47 @@ dependencies = [ [[package]] name = "cxx-build" -version = "1.0.131" +version = "1.0.133" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1674a8b80cdcce32512a75975d85d569b160f612ee1d31645bc46771f7c220a1" +checksum = "9afa390d956ee7ccb41aeed7ed7856ab3ffb4fc587e7216be7e0f83e949b4e6c" dependencies = [ "cc", "codespan-reporting", "proc-macro2", "quote", "scratch", - "syn 2.0.89", + "syn 2.0.90", +] + +[[package]] +name = "cxxbridge-cmd" +version = "1.0.133" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c23bfff654d6227cbc83de8e059d2f8678ede5fc3a6c5a35d5c379983cc61e6" +dependencies = [ + "clap", + "codespan-reporting", + "proc-macro2", + "quote", + "syn 2.0.90", ] [[package]] name = "cxxbridge-flags" -version = "1.0.131" +version = "1.0.133" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c710c27f23b7fa00c23aaee9e6fd3e79a6dffc5f5c6217487ec5213f51296b7" +checksum = "f7c01b36e22051bc6928a78583f1621abaaf7621561c2ada1b00f7878fbe2caa" [[package]] name = "cxxbridge-macro" -version = "1.0.131" +version = "1.0.133" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0aa53ef9fc54b986272efe83e257bbb417d1c3ceab1b732411d8c634fda572be" +checksum = "f6e14013136fac689345d17b9a6df55977251f11d333c0a571e8d963b55e1f95" dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -2731,7 +2746,7 @@ dependencies = [ "proc-macro2", "quote", "strsim 0.11.1", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -2753,7 +2768,7 @@ checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core 0.20.10", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -2795,7 +2810,7 @@ checksum = "d65d7ce8132b7c0e54497a4d9a55a1c2a0912a0d786cf894472ba818fba45762" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -2806,7 +2821,7 @@ checksum = "62d671cc41a825ebabc75757b62d3d168c577f9149b2d49ece1dad1f72119d25" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -2817,7 +2832,7 @@ checksum = "30542c1ad912e0e3d22a1935c290e12e8a29d704a420177a31faad4a601a0800" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -2830,7 +2845,7 @@ dependencies = [ "proc-macro2", "quote", "rustc_version 0.4.1", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -2850,7 +2865,7 @@ checksum = "cb7330aeadfbe296029522e6c40f315320aba36fc43a5b3632f3795348f3bd22" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", "unicode-xid", ] @@ -2897,6 +2912,27 @@ dependencies = [ "dirs-sys-next", ] +[[package]] +name = "dirs" +version = "5.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225" +dependencies = [ + "dirs-sys", +] + +[[package]] +name = "dirs-sys" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c" +dependencies = [ + "libc", + "option-ext", + "redox_users", + "windows-sys 0.48.0", +] + [[package]] name = "dirs-sys-next" version = "0.1.2" @@ -2916,7 +2952,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -2946,7 +2982,7 @@ dependencies = [ "proc-macro2", "quote", "regex", - "syn 2.0.89", + "syn 2.0.90", "termcolor", "toml 0.8.19", "walkdir", @@ -3129,7 +3165,7 @@ checksum = "de0d48a183585823424a4ce1aa132d174a6a81bd540895822eb4c8373a8e49e8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -3140,7 +3176,7 @@ checksum = "2f9ed6b3789237c8a0c1c505af1c7eb2c560df6186f01b098c3a1064ea532f38" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -3170,12 +3206,12 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.9" +version = "0.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" +checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d" dependencies = [ "libc", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -3238,9 +3274,9 @@ dependencies = [ [[package]] name = "event-listener-strategy" -version = "0.5.2" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f214dc438f977e6d4e3500aaa277f5ad94ca83fbbd9b1a15713ce2344ccc5a1" +checksum = "3c3e4e0dd3673c1139bf041f3008816d9cf2946bbfac2945c09e523b8d7b05b2" dependencies = [ "event-listener", "pin-project-lite", @@ -3258,7 +3294,7 @@ dependencies = [ "prettyplease", "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -3491,7 +3527,7 @@ dependencies = [ "proc-macro-crate 3.2.0", "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -3629,7 +3665,7 @@ dependencies = [ "proc-macro2", "quote", "sp-crypto-hashing", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -3642,7 +3678,7 @@ dependencies = [ "proc-macro-crate 3.2.0", "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -3653,7 +3689,7 @@ checksum = "ed971c6435503a099bdac99fe4c5bea08981709e5b5a0a8535a1856f48561191" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -3800,7 +3836,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -3916,6 +3952,10 @@ name = "gimli" version = "0.31.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" +dependencies = [ + "fallible-iterator 0.3.0", + "stable_deref_trait", +] [[package]] name = "glob" @@ -4347,7 +4387,7 @@ checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -4430,7 +4470,7 @@ checksum = "a0eb5a3343abf848c0984fe4604b2b105da9539376e24fc0a3b0007411ae4fd9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -4471,9 +4511,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.6.0" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" +checksum = "62f822373a4fe84d4bb149bf54e584a7f4abec90e072ed49cda0edea5b95471f" dependencies = [ "equivalent", "hashbrown 0.15.2", @@ -4533,7 +4573,7 @@ dependencies = [ "quote", "serde", "serde_json", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -4596,7 +4636,7 @@ dependencies = [ "itertools 0.12.1", "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -4611,7 +4651,7 @@ dependencies = [ "parity-scale-codec", "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", "synstructure 0.13.1", ] @@ -4819,10 +4859,11 @@ checksum = "72167d68f5fce3b8655487b8038691a3c9984ee769590f93f2a631f4ad64e4f5" [[package]] name = "js-sys" -version = "0.3.72" +version = "0.3.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a88f1bda2bd75b0452a14784937d796722fdebfe50df998aeb3f0b7603019a9" +checksum = "a865e038f7f6ed956f788f0d7d60c541fff74c7bd74272c5d4cf15c63743e705" dependencies = [ + "once_cell", "wasm-bindgen", ] @@ -4872,7 +4913,7 @@ dependencies = [ "futures-util", "jsonrpsee-types", "pin-project", - "rustc-hash 2.0.0", + "rustc-hash 2.1.0", "serde", "serde_json", "thiserror 1.0.69", @@ -4978,9 +5019,9 @@ checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" [[package]] name = "libc" -version = "0.2.166" +version = "0.2.167" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2ccc108bbc0b1331bd061864e7cd823c0cab660bbe6970e66e2c0614decde36" +checksum = "09d6582e104315a817dff97f75133544b2e094ee22447d2acf4a74e189ba06fc" [[package]] name = "libm" @@ -5073,7 +5114,7 @@ checksum = "edbe595006d355eaf9ae11db92707d4338cd2384d16866131cc1afdbdd35d8d9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -5155,7 +5196,7 @@ dependencies = [ "macro_magic_core", "macro_magic_macros", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -5169,7 +5210,7 @@ dependencies = [ "macro_magic_core_macros", "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -5180,7 +5221,7 @@ checksum = "b02abfe41815b5bd98dbd4260173db2c116dda171dc0fe7838cb206333b83308" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -5191,7 +5232,7 @@ checksum = "73ea28ee64b88876bf45277ed9a5817c1817df061a74f2b988971a12570e5869" dependencies = [ "macro_magic_core", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -5281,11 +5322,10 @@ dependencies = [ [[package]] name = "mio" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80e04d1dcff3aae0704555fe5fee3bcfaf3d1fdf8a7e521d5b9d2b42acb52cec" +checksum = "2886843bf800fba2e3377cff24abf6379b4c4d5c6681eaf9ea5b0d15090450bd" dependencies = [ - "hermit-abi 0.3.9", "libc", "log", "wasi", @@ -5417,7 +5457,7 @@ checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -5529,6 +5569,12 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" +[[package]] +name = "option-ext" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" + [[package]] name = "os_pipe" version = "1.2.1" @@ -6131,7 +6177,7 @@ checksum = "94226cbd48516b7c310eb5dae8d50798c1ce73a7421dc0977c55b7fc2237a283" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -6961,7 +7007,7 @@ checksum = "0cc16d1f7cee6a1ee6e8cd710e16230d59fb4935316c1704cf770e4d2335f8d4" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -7598,9 +7644,9 @@ checksum = "16b56e3a2420138bdb970f84dfb9c774aea80fa0e7371549eedec0d80c209c67" [[package]] name = "parity-scale-codec" -version = "3.7.0" +version = "3.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8be4817d39f3272f69c59fe05d0535ae6456c2dc2fa1ba02910296c7e0a5c590" +checksum = "306800abfa29c7f16596b5970a588435e3d5b3149683d00c12b699cc19f895ee" dependencies = [ "arrayvec 0.7.6", "bitvec", @@ -7608,20 +7654,19 @@ dependencies = [ "bytes", "impl-trait-for-tuples", "parity-scale-codec-derive", - "rustversion", "serde", ] [[package]] name = "parity-scale-codec-derive" -version = "3.7.0" +version = "3.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8781a75c6205af67215f382092b6e0a4ff3734798523e69073d4bcd294ec767b" +checksum = "d830939c76d294956402033aee57a6da7b438f2294eb94864c37b0569053a42c" dependencies = [ "proc-macro-crate 3.2.0", "proc-macro2", "quote", - "syn 2.0.89", + "syn 1.0.109", ] [[package]] @@ -7750,7 +7795,7 @@ checksum = "3c0f5fad0874fc7abcd4d750e76917eaebbecaa2c20bde22e1dbeeba8beb758c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -8331,6 +8376,12 @@ dependencies = [ "polkavm-assembler 0.10.0", ] +[[package]] +name = "polkavm-common" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f0dbafef4ab6ceecb4982ac3b550df430ef4f9fdbf07c108b7d4f91a0682fce" + [[package]] name = "polkavm-derive" version = "0.5.0" @@ -8338,7 +8389,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6380dbe1fb03ecc74ad55d841cfc75480222d153ba69ddcb00977866cbdabdb8" dependencies = [ "polkavm-derive-impl 0.5.0", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -8368,7 +8419,7 @@ dependencies = [ "polkavm-common 0.5.0", "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -8380,7 +8431,7 @@ dependencies = [ "polkavm-common 0.9.0", "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -8392,7 +8443,7 @@ dependencies = [ "polkavm-common 0.10.0", "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -8402,7 +8453,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ba81f7b5faac81e528eb6158a6f3c9e0bb1008e0ffa19653bc8dea925ecb429" dependencies = [ "polkavm-derive-impl 0.9.0", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -8412,7 +8463,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9324fe036de37c17829af233b46ef6b5562d4a0c09bb7fdb9f8378856dee30cf" dependencies = [ "polkavm-derive-impl 0.10.0", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -8445,6 +8496,22 @@ dependencies = [ "rustc-demangle", ] +[[package]] +name = "polkavm-linker" +version = "0.17.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0422ead3030d5cde69e2206dbc7d65da872b121876507cd5363f6c6e6aa45157" +dependencies = [ + "dirs", + "gimli 0.31.1", + "hashbrown 0.14.5", + "log", + "object 0.36.5", + "polkavm-common 0.17.0", + "regalloc2 0.9.3", + "rustc-demangle", +] + [[package]] name = "polkavm-linux-raw" version = "0.9.0" @@ -8557,7 +8624,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "64d1ec885c64d0457d564db4ec299b2dae3f9c02808b8ad9c3a089c591b18033" dependencies = [ "proc-macro2", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -8649,7 +8716,7 @@ dependencies = [ "proc-macro-error-attr2", "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -8660,7 +8727,7 @@ checksum = "834da187cfe638ae8abb0203f0b33e5ccdb02a28e7199f2f47b3e2754f50edca" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -8850,7 +8917,7 @@ checksum = "bcc303e793d3734489387d205e9b186fac9c6cfacedd98cbb2e8a5943595f3e6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -9127,9 +9194,9 @@ checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" [[package]] name = "rustc-hash" -version = "2.0.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "583034fd73374156e66797ed8e5b0d5690409c9226b22d87cb7f19821c05d152" +checksum = "c7fb8039b3032c191086b10f11f319a6e99e1e82889c5cc6046f515c9db1d497" [[package]] name = "rustc-hex" @@ -9495,7 +9562,7 @@ dependencies = [ "darling 0.20.10", "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -9549,7 +9616,7 @@ dependencies = [ "proc-macro-crate 3.2.0", "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -9576,7 +9643,7 @@ dependencies = [ "proc-macro-crate 3.2.0", "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -9607,7 +9674,7 @@ dependencies = [ "proc-macro2", "quote", "scale-info", - "syn 2.0.89", + "syn 2.0.90", "thiserror 1.0.69", ] @@ -9661,7 +9728,7 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -9905,7 +9972,7 @@ checksum = "ad1e866f866923f252f05c889987993144fb74e722403468a4ebd70c3cd756c0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -9916,7 +9983,7 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -9939,7 +10006,7 @@ checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -9973,7 +10040,7 @@ dependencies = [ "chrono", "hex", "indexmap 1.9.3", - "indexmap 2.6.0", + "indexmap 2.7.0", "serde", "serde_derive", "serde_json", @@ -10607,9 +10674,9 @@ dependencies = [ [[package]] name = "soketto" -version = "0.8.0" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37468c595637c10857701c990f93a40ce0e357cedb0953d1c26c8d8027f9bb53" +checksum = "2e859df029d160cb88608f5d7df7fb4753fd20fdfb4de5644f3d8b8440841721" dependencies = [ "base64 0.22.1", "bytes", @@ -10655,7 +10722,7 @@ dependencies = [ "proc-macro-crate 3.2.0", "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -10971,7 +11038,7 @@ checksum = "b85d0f1f1e44bd8617eb2a48203ee854981229e3e79e6f468c7175d5fd37489b" dependencies = [ "quote", "sp-crypto-hashing", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -10982,7 +11049,7 @@ checksum = "48d09fa0a5f7299fb81ee25ae3853d26200f7a348148aed6de76be905c007dbe" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -11324,7 +11391,7 @@ dependencies = [ "proc-macro-crate 3.2.0", "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -11581,7 +11648,7 @@ dependencies = [ "parity-scale-codec", "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -11836,7 +11903,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -11935,7 +12002,7 @@ dependencies = [ "scale-info", "scale-typegen", "subxt-metadata", - "syn 2.0.89", + "syn 2.0.90", "thiserror 1.0.69", ] @@ -11998,7 +12065,7 @@ dependencies = [ "scale-typegen", "subxt-codegen", "subxt-utils-fetchmetadata", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -12066,9 +12133,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.89" +version = "2.0.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44d46482f1c1c87acd84dea20c1bf5ebff4c757009ed6bf19cfd36fb10e92c4e" +checksum = "919d3b74a5dd0ccd15aeb8f93e7006bd9e14c295087c9896a110f490752bcf31" dependencies = [ "proc-macro2", "quote", @@ -12084,7 +12151,7 @@ dependencies = [ "paste", "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -12116,7 +12183,7 @@ checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -12211,7 +12278,7 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -12222,7 +12289,7 @@ checksum = "8381894bb3efe0c4acac3ded651301ceee58a15d47c2e34885ed1908ad667061" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -12237,9 +12304,9 @@ dependencies = [ [[package]] name = "time" -version = "0.3.36" +version = "0.3.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" +checksum = "35e7868883861bd0e56d9ac6efcaaca0d6d5d82a2a7ec8209ff492c07cf37b21" dependencies = [ "deranged", "itoa", @@ -12258,9 +12325,9 @@ checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" [[package]] name = "time-macros" -version = "0.2.18" +version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf" +checksum = "2834e6017e3e5e4b9834939793b282bc03b37a3336245fa820e35e233e2a85de" dependencies = [ "num-conv", "time-core", @@ -12302,9 +12369,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.41.1" +version = "1.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22cfb5bee7a6a52939ca9224d6ac897bb669134078daa8735560897f69de4d33" +checksum = "5cec9b21b0450273377fc97bd4c33a8acffc8c996c987a7c5b319a0083707551" dependencies = [ "backtrace", "bytes", @@ -12324,7 +12391,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -12399,7 +12466,7 @@ version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ - "indexmap 2.6.0", + "indexmap 2.7.0", "toml_datetime", "winnow 0.5.40", ] @@ -12410,7 +12477,7 @@ version = "0.22.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ae48d6208a266e853d946088ed816055e556cc6028c5e8e2b84d9fa5dd7c7f5" dependencies = [ - "indexmap 2.6.0", + "indexmap 2.7.0", "serde", "serde_spanned", "toml_datetime", @@ -12443,7 +12510,7 @@ checksum = "395ae124c09f9e6918a2310af6038fba074bcf474ac352496d5910dd59a2226d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -12799,9 +12866,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.95" +version = "0.2.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "128d1e363af62632b8eb57219c8fd7877144af57558fb2ef0368d0087bddeb2e" +checksum = "d15e63b4482863c109d70a7b8706c1e364eb6ea449b201a76c5b89cedcec2d5c" dependencies = [ "cfg-if", "once_cell", @@ -12810,36 +12877,37 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.95" +version = "0.2.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb6dd4d3ca0ddffd1dd1c9c04f94b868c37ff5fac97c30b97cff2d74fce3a358" +checksum = "8d36ef12e3aaca16ddd3f67922bc63e48e953f126de60bd33ccc0101ef9998cd" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.45" +version = "0.4.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc7ec4f8827a71586374db3e87abdb5a2bb3a15afed140221307c3ec06b1f63b" +checksum = "9dfaf8f50e5f293737ee323940c7d8b08a66a95a419223d9f41610ca08b0833d" dependencies = [ "cfg-if", "js-sys", + "once_cell", "wasm-bindgen", "web-sys", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.95" +version = "0.2.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e79384be7f8f5a9dd5d7167216f022090cf1f9ec128e6e6a482a2cb5c5422c56" +checksum = "705440e08b42d3e4b36de7d66c944be628d579796b8090bfa3471478a2260051" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -12847,22 +12915,22 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.95" +version = "0.2.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68" +checksum = "98c9ae5a76e46f4deecd0f0255cc223cfa18dc9b261213b8aa0c7b36f61b3f1d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.95" +version = "0.2.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65fc09f10666a9f147042251e0dda9c18f166ff7de300607007e96bdebc1068d" +checksum = "6ee99da9c5ba11bd675621338ef6fa52296b76b83305e9b6e5c77d4c286d6d49" [[package]] name = "wasm-encoder" @@ -12992,7 +13060,7 @@ dependencies = [ "ahash 0.8.11", "bitflags 2.6.0", "hashbrown 0.14.5", - "indexmap 2.6.0", + "indexmap 2.7.0", "semver 1.0.23", "serde", ] @@ -13004,7 +13072,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9845c470a2e10b61dd42c385839cdd6496363ed63b5c9e420b5488b77bd22083" dependencies = [ "bitflags 2.6.0", - "indexmap 2.6.0", + "indexmap 2.7.0", "semver 1.0.23", ] @@ -13236,9 +13304,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.72" +version = "0.3.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6488b90108c040df0fe62fa815cbdee25124641df01814dd7282749234c6112" +checksum = "a98bc3c33f0fe7e59ad7cd041b89034fa82a7c2d4365ca538dda6cdaf513863c" dependencies = [ "js-sys", "wasm-bindgen", @@ -13652,7 +13720,7 @@ dependencies = [ "Inflector", "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -13664,7 +13732,7 @@ dependencies = [ "Inflector", "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -13743,7 +13811,7 @@ checksum = "2380878cad4ac9aac1e2435f3eb4020e8374b5f13c296cb75b4620ff8e229154" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", "synstructure 0.13.1", ] @@ -13765,7 +13833,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -13785,7 +13853,7 @@ checksum = "595eed982f7d355beb85837f651fa22e90b3c044842dc7f2c2842c086f295808" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", "synstructure 0.13.1", ] @@ -13806,7 +13874,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -13828,7 +13896,7 @@ checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -13841,7 +13909,7 @@ dependencies = [ "crc32fast", "crossbeam-utils", "displaydoc", - "indexmap 2.6.0", + "indexmap 2.7.0", "memchr", "thiserror 2.0.4", ] diff --git a/crates/build/Cargo.toml b/crates/build/Cargo.toml index 364426749..4d2e0df40 100644 --- a/crates/build/Cargo.toml +++ b/crates/build/Cargo.toml @@ -47,6 +47,8 @@ tokio-stream = "0.1" bollard = "0.18" crossterm = "0.28.1" +polkavm-linker = "0.17.1" + contract-metadata = { version = "5.0.1", path = "../metadata" } [target.'cfg(unix)'.dependencies] diff --git a/crates/build/riscv32emac-unknown-none-polkavm.json b/crates/build/riscv32emac-unknown-none-polkavm.json new file mode 100644 index 000000000..fa362ce5d --- /dev/null +++ b/crates/build/riscv32emac-unknown-none-polkavm.json @@ -0,0 +1,26 @@ +{ + "arch": "riscv32", + "cpu": "generic-rv32", + "crt-objects-fallback": "false", + "data-layout": "e-m:e-p:32:32-i64:64-n32-S32", + "eh-frame-header": false, + "emit-debug-gdb-scripts": false, + "features": "+e,+m,+a,+c,+lui-addi-fusion,+fast-unaligned-access,+xtheadcondmov", + "linker": "rust-lld", + "linker-flavor": "ld.lld", + "llvm-abiname": "ilp32e", + "llvm-target": "riscv32", + "max-atomic-width": 32, + "panic-strategy": "abort", + "relocation-model": "pie", + "target-pointer-width": "32", + "singlethread": true, + "pre-link-args": { + "ld": [ + "--emit-relocs", + "--unique", + "--relocatable" + ] + }, + "env": "polkavm" +} diff --git a/crates/build/riscv_memory_layout.ld b/crates/build/riscv_memory_layout.ld deleted file mode 100644 index 702e9b3af..000000000 --- a/crates/build/riscv_memory_layout.ld +++ /dev/null @@ -1,17 +0,0 @@ -MEMORY { - RAM : ORIGIN = 0x00000000, LENGTH = 2M -} - -SECTIONS { - . = ORIGIN(RAM); - .text : { *(.init) *(.text .text.*) } > REGION_TEXT - .rodata : { *(.rodata) *(.rodata.*) } > REGION_RODATA - .bss : { *(.sbss) *(.bss) *(.bss.*) } > REGION_DATA - .data : { *(.data) } > REGION_DATA - /DISCARD/ : { *(.eh_frame) } - . = ALIGN(4); -} - -REGION_ALIAS("REGION_TEXT", RAM); -REGION_ALIAS("REGION_RODATA", RAM); -REGION_ALIAS("REGION_DATA", RAM); diff --git a/crates/build/src/args.rs b/crates/build/src/args.rs index a494c205d..0545f4b4b 100644 --- a/crates/build/src/args.rs +++ b/crates/build/src/args.rs @@ -14,11 +14,16 @@ // You should have received a copy of the GNU General Public License // along with cargo-contract. If not, see . +use crate::CrateMetadata; use anyhow::Result; use clap::Args; use std::{ convert::TryFrom, fmt, + fs, + fs::File, + io::Write, + path::Path, }; #[derive(Default, Clone, Debug, Args)] @@ -154,10 +159,39 @@ pub enum Target { impl Target { /// The target string to be passed to rustc in order to build for this target. - pub fn llvm_target(&self) -> &'static str { + pub fn llvm_target(&self, crate_metadata: &CrateMetadata) -> String { + match self { + Self::Wasm => "wasm32-unknown-unknown".to_string(), + Self::RiscV => { + // Instead of a target literal we use a JSON file with a more complex + // target configuration here. The path to the file is passed for the + // `rustc --target` argument. We write this file to the `target/` folder. + let target_dir = crate_metadata.target_directory.to_string_lossy(); + let path = + format!("{}/riscv32emac-unknown-none-polkavm.json", target_dir); + if !Path::exists(Path::new(&path)) { + fs::create_dir_all(&crate_metadata.target_directory).unwrap_or_else( + |e| { + panic!( + "unable to create target dir {:?}: {:?}", + target_dir, e + ) + }, + ); + let mut file = File::create(&path).unwrap(); + let config = include_str!("../riscv32emac-unknown-none-polkavm.json"); + file.write_all(config.as_bytes()).unwrap(); + } + path + } + } + } + + /// The name used for the target folder inside the `target/` folder. + pub fn llvm_target_alias(&self) -> &'static str { match self { Self::Wasm => "wasm32-unknown-unknown", - Self::RiscV => "riscv32i-unknown-none-elf", + Self::RiscV => "riscv32emac-unknown-none-polkavm", } } @@ -165,7 +199,9 @@ impl Target { pub fn rustflags(&self) -> Option<&'static str> { match self { Self::Wasm => Some("-Clink-arg=-zstack-size=65536\x1f-Clink-arg=--import-memory\x1f-Ctarget-cpu=mvp"), - Self::RiscV => None, + // Substrate has the `cfg` `substrate_runtime` to distinguish if e.g. `sp-io` + // is being build for `std` or for a Wasm/RISC-V runtime. + Self::RiscV => Some("--cfg\x1fsubstrate_runtime"), } } diff --git a/crates/build/src/crate_metadata.rs b/crates/build/src/crate_metadata.rs index 704993abb..3f40aab9c 100644 --- a/crates/build/src/crate_metadata.rs +++ b/crates/build/src/crate_metadata.rs @@ -104,7 +104,7 @@ impl CrateMetadata { // {target_dir}/{target}/release/{contract_artifact_name}.{extension} let mut original_code = target_directory.clone(); - original_code.push(target.llvm_target()); + original_code.push(target.llvm_target_alias()); original_code.push("release"); original_code.push(root_package.name.clone()); original_code.set_extension(target.source_extension()); @@ -164,6 +164,15 @@ impl CrateMetadata { let fname_bundle = format!("{}.contract", self.contract_artifact_name); target_directory.join(fname_bundle) } + + /// Returns `true` if `ink_e2e` is a dependency of the project. + pub fn depends_on_ink_e2e(&self) -> bool { + let (metadata, _root_package) = get_cargo_metadata(&self.manifest_path).unwrap(); + metadata + .packages + .iter() + .any(|package| package.name == "ink_e2e") + } } /// Get the result of `cargo metadata`, together with the root package id. diff --git a/crates/build/src/lib.rs b/crates/build/src/lib.rs index cb35ad290..d1b0c3086 100644 --- a/crates/build/src/lib.rs +++ b/crates/build/src/lib.rs @@ -86,12 +86,14 @@ pub use docker::{ }; use anyhow::{ + bail, Context, Result, }; use colored::Colorize; use semver::Version; use std::{ + cmp::PartialEq, fs, path::{ Path, @@ -298,8 +300,13 @@ fn exec_cargo_for_onchain_target( "--target-dir={}", crate_metadata.target_directory.to_string_lossy() ); - let mut args = vec![target_dir, "--release".to_owned()]; - args.extend(onchain_cargo_options(target)); + + let mut args = vec![ + format!("--target={}", target.llvm_target(crate_metadata)), + "--release".to_owned(), + target_dir, + ]; + args.extend(onchain_cargo_options(target, crate_metadata)); network.append_to_args(&mut args); let mut features = features.clone(); @@ -308,6 +315,12 @@ fn exec_cargo_for_onchain_target( } else { args.push("-Zbuild-std-features=panic_immediate_abort".to_owned()); } + if *target == Target::RiscV { + features.push("ink/revive"); + if crate_metadata.depends_on_ink_e2e() { + features.push("ink_e2e/revive"); + } + } features.append_to_args(&mut args); let mut env = Vec::new(); if rustc_version::version_meta()?.channel == rustc_version::Channel::Stable { @@ -331,21 +344,8 @@ fn exec_cargo_for_onchain_target( } }; - // the linker needs our linker script as file - if matches!(target, Target::RiscV) { - fs::create_dir_all(&crate_metadata.target_directory)?; - let path = crate_metadata - .target_directory - .join(".riscv_memory_layout.ld"); - fs::write(&path, include_bytes!("../riscv_memory_layout.ld"))?; - let path = path.display(); - env.push(( - "CARGO_ENCODED_RUSTFLAGS", - Some(format!("{rustflags}\x1f-Clink-arg=-T{path}",)), - )); - } else { - env.push(("CARGO_ENCODED_RUSTFLAGS", Some(rustflags))); - }; + fs::create_dir_all(&crate_metadata.target_directory)?; + env.push(("CARGO_ENCODED_RUSTFLAGS", Some(rustflags))); execute_cargo(util::cargo_cmd( command, @@ -519,9 +519,9 @@ fn exec_cargo_clippy(crate_metadata: &CrateMetadata, verbosity: Verbosity) -> Re } /// Returns a list of cargo options used for on-chain builds -fn onchain_cargo_options(target: &Target) -> Vec { +fn onchain_cargo_options(target: &Target, crate_metadata: &CrateMetadata) -> Vec { vec![ - format!("--target={}", target.llvm_target()), + format!("--target={}", target.llvm_target(crate_metadata)), "-Zbuild-std=core,alloc".to_owned(), "--no-default-features".to_owned(), ] @@ -556,7 +556,7 @@ fn exec_cargo_dylint( args.push("--".to_owned()); // Pass on-chain build options to ensure the linter expands all conditional `cfg_attr` // macros, as it does for the release build. - args.extend(onchain_cargo_options(target)); + args.extend(onchain_cargo_options(target, crate_metadata)); let target_dir = &crate_metadata.target_directory.to_string_lossy(); let env = vec![ @@ -572,6 +572,9 @@ fn exec_cargo_dylint( // there is this bug: https://github.com/mozilla/sccache/issues/1000. // Until we have a justification for leaving the wrapper we should unset it. ("RUSTC_WRAPPER", None), + // Substrate has the `cfg` `substrate_runtime` to distinguish if e.g. `sp-io` + // is being build for `std` or for a Wasm/RISC-V runtime. + ("RUSTFLAGS", Some("--cfg\x1fsubstrate_runtime".to_string())), ]; Workspace::new(&crate_metadata.cargo_meta, &crate_metadata.root_package.id)? @@ -856,7 +859,10 @@ fn local_build( )?; // We persist the latest target we used so we trigger a rebuild when we switch - fs::write(&crate_metadata.target_file_path, target.llvm_target())?; + fs::write( + &crate_metadata.target_file_path, + target.llvm_target(crate_metadata), + )?; let cargo_contract_version = if let Ok(version) = Version::parse(VERSION) { version @@ -929,7 +935,17 @@ fn local_build( )?; } Target::RiscV => { - fs::copy(&crate_metadata.original_code, &crate_metadata.dest_code)?; + let mut config = polkavm_linker::Config::default(); + config.set_strip(!keep_debug_symbols); + if *build_mode != BuildMode::Debug { + config.set_optimize(true); + } + let orig = fs::read(&crate_metadata.original_code)?; + let linked = match polkavm_linker::program_from_elf(config, orig.as_ref()) { + Ok(linked) => linked, + Err(err) => bail!("Failed to link polkavm program: {}", err), + }; + fs::write(&crate_metadata.dest_code, linked)?; } } diff --git a/crates/build/templates/new/_Cargo.toml b/crates/build/templates/new/_Cargo.toml index 8db418de8..1298b5e46 100644 --- a/crates/build/templates/new/_Cargo.toml +++ b/crates/build/templates/new/_Cargo.toml @@ -5,10 +5,10 @@ authors = ["[your_name] <[your_email]>"] edition = "2021" [dependencies] -ink = { version = "5.1.0", default-features = false } +ink = { git = "https://github.com/use-ink/ink", default-features = false } [dev-dependencies] -ink_e2e = { version = "5.1.0" } +ink_e2e = { git = "https://github.com/use-ink/ink", default-features = false } [lib] path = "lib.rs" diff --git a/crates/cargo-contract/src/cmd/instantiate.rs b/crates/cargo-contract/src/cmd/instantiate.rs index 21d4eec02..71a2787f3 100644 --- a/crates/cargo-contract/src/cmd/instantiate.rs +++ b/crates/cargo-contract/src/cmd/instantiate.rs @@ -72,6 +72,7 @@ use subxt::{ scale_decode::IntoVisitor, scale_encode::EncodeAsType, }, + utils::H160, Config, }; @@ -313,7 +314,7 @@ where /// events, and optional code hash. pub async fn display_result>( instantiate_exec: &InstantiateExec, - instantiate_exec_result: InstantiateExecResult, + instantiate_exec_result: InstantiateExecResult, token_metadata: &TokenMetadata, output_json: bool, verbosity: Verbosity, diff --git a/crates/extrinsics/src/call.rs b/crates/extrinsics/src/call.rs index cce52576e..ad2f8025b 100644 --- a/crates/extrinsics/src/call.rs +++ b/crates/extrinsics/src/call.rs @@ -50,13 +50,14 @@ use subxt::{ scale_encode::EncodeAsType, }, tx, + utils::H160, Config, OnlineClient, }; /// A builder for the call command. pub struct CallCommandBuilder { - contract: C::AccountId, + contract: H160, message: String, args: Vec, extrinsic_opts: ExtrinsicOpts, @@ -72,7 +73,7 @@ where { /// Returns a clean builder for [`CallExec`]. pub fn new( - contract: C::AccountId, + contract: H160, message: &str, extrinsic_opts: ExtrinsicOpts, ) -> CallCommandBuilder { @@ -154,7 +155,7 @@ where } pub struct CallExec { - contract: C::AccountId, + contract: H160, message: String, args: Vec, opts: ExtrinsicOpts, @@ -188,13 +189,13 @@ where let storage_deposit_limit = self.opts.storage_deposit_limit(); let call_request = CallRequest { origin: self.opts.signer().account_id(), - dest: self.contract.clone(), + dest: self.contract, value: self.value, gas_limit: None, storage_deposit_limit, input_data: self.call_data.clone(), }; - state_call(&self.rpc, "ContractsApi_call", call_request).await + state_call(&self.rpc, "ReviveApi_call", call_request).await } /// Calls a contract on the blockchain with a specified gas limit. @@ -235,10 +236,10 @@ where let storage_deposit_limit = self.opts.storage_deposit_limit(); let call = Call::new( - self.contract.clone().into(), + self.contract, self.value, gas_limit, - storage_deposit_limit, + storage_deposit_limit.expect("no storage deposit limit available"), self.call_data.clone(), ) .build(); @@ -289,7 +290,7 @@ where } /// Returns the address of the the contract to call. - pub fn contract(&self) -> &C::AccountId { + pub fn contract(&self) -> &subxt::utils::H160 { &self.contract } @@ -345,7 +346,7 @@ where #[derive(Encode)] struct CallRequest { origin: AccountId, - dest: AccountId, + dest: subxt::utils::H160, value: Balance, gas_limit: Option, storage_deposit_limit: Option, diff --git a/crates/extrinsics/src/events.rs b/crates/extrinsics/src/events.rs index 6fa1e8f9a..71a2904cc 100644 --- a/crates/extrinsics/src/events.rs +++ b/crates/extrinsics/src/events.rs @@ -49,6 +49,7 @@ use subxt::{ }, scale_encode, }, + utils::H160, Config, }; @@ -96,7 +97,7 @@ impl StaticEvent for ContractInstantiated where AccountId: IntoVisitor, { - const PALLET: &'static str = "Contracts"; + const PALLET: &'static str = "Revive"; const EVENT: &'static str = "Instantiated"; } @@ -311,6 +312,22 @@ impl DisplayEvents { .to_string(); } } + if field.type_name == Some("H160".to_string()) { + // Value is in the format `H160([bytes])`. + // Extract the byte array between the brackets and convert it to a + // hexadecimal string. + if let (Some(start), Some(end)) = + (value.find('['), value.find(']')) + { + let byte_str = &value[start + 1..end]; + let bytes: Vec = byte_str + .split(", ") + .filter_map(|s| s.parse::().ok()) + .collect(); + let h160_value = H160::from_slice(&bytes); + value = format!("0x{}", hex::encode(h160_value.as_bytes())); + } + } let _ = writeln!( out, "{:width$}{}: {}", diff --git a/crates/extrinsics/src/extrinsic_calls.rs b/crates/extrinsics/src/extrinsic_calls.rs index 3330b3d33..15218f34f 100644 --- a/crates/extrinsics/src/extrinsic_calls.rs +++ b/crates/extrinsics/src/extrinsic_calls.rs @@ -14,16 +14,13 @@ // You should have received a copy of the GNU General Public License // along with cargo-contract. If not, see . -use crate::{ - upload::Determinism, - WasmCode, -}; +use crate::WasmCode; use subxt::{ ext::{ codec::Compact, scale_encode::EncodeAsType, }, - utils::MultiAddress, + utils::H160, }; /// Copied from `sp_weight` to additionally implement `scale_encode::EncodeAsType`. @@ -70,7 +67,7 @@ impl RemoveCode { } pub fn build(self) -> subxt::tx::DefaultPayload { - subxt::tx::DefaultPayload::new("Contracts", "remove_code", self) + subxt::tx::DefaultPayload::new("Revive", "remove_code", self) } } @@ -79,25 +76,19 @@ impl RemoveCode { #[encode_as_type(crate_path = "subxt::ext::scale_encode")] pub(crate) struct UploadCode { code: Vec, - storage_deposit_limit: Option>, - determinism: Determinism, + storage_deposit_limit: Balance, } impl UploadCode { - pub fn new( - code: WasmCode, - storage_deposit_limit: Option, - determinism: Determinism, - ) -> Self { + pub fn new(code: WasmCode, storage_deposit_limit: Balance) -> Self { Self { code: code.0, - storage_deposit_limit: storage_deposit_limit.map(Into::into), - determinism, + storage_deposit_limit, } } pub fn build(self) -> subxt::tx::DefaultPayload { - subxt::tx::DefaultPayload::new("Contracts", "upload_code", self) + subxt::tx::DefaultPayload::new("Revive", "upload_code", self) } } @@ -108,25 +99,25 @@ pub(crate) struct InstantiateWithCode { #[codec(compact)] value: Balance, gas_limit: Weight, - storage_deposit_limit: Option>, + storage_deposit_limit: Balance, code: Vec, data: Vec, - salt: Vec, + salt: Option>, } impl InstantiateWithCode { pub fn new( value: Balance, gas_limit: sp_weights::Weight, - storage_deposit_limit: Option, + storage_deposit_limit: Balance, code: Vec, data: Vec, - salt: Vec, + salt: Option>, ) -> Self { Self { value, gas_limit: gas_limit.into(), - storage_deposit_limit: storage_deposit_limit.map(Into::into), + storage_deposit_limit, code, data, salt, @@ -134,7 +125,7 @@ impl InstantiateWithCode { } pub fn build(self) -> subxt::tx::DefaultPayload { - subxt::tx::DefaultPayload::new("Contracts", "instantiate_with_code", self) + subxt::tx::DefaultPayload::new("Revive", "instantiate_with_code", self) } } @@ -177,40 +168,40 @@ where } pub fn build(self) -> subxt::tx::DefaultPayload { - subxt::tx::DefaultPayload::new("Contracts", "instantiate", self) + subxt::tx::DefaultPayload::new("Revive", "instantiate", self) } } /// A raw call to `pallet-contracts`'s `call`. #[derive(EncodeAsType)] #[encode_as_type(crate_path = "subxt::ext::scale_encode")] -pub(crate) struct Call { - dest: MultiAddress, +pub(crate) struct Call { + dest: H160, #[codec(compact)] value: Balance, gas_limit: Weight, - storage_deposit_limit: Option>, + storage_deposit_limit: Balance, data: Vec, } -impl Call { +impl Call { pub fn new( - dest: MultiAddress, + dest: H160, value: Balance, gas_limit: sp_weights::Weight, - storage_deposit_limit: Option, + storage_deposit_limit: Balance, data: Vec, ) -> Self { Self { dest, value, gas_limit: gas_limit.into(), - storage_deposit_limit: storage_deposit_limit.map(Into::into), + storage_deposit_limit, data, } } pub fn build(self) -> subxt::tx::DefaultPayload { - subxt::tx::DefaultPayload::new("Contracts", "call", self) + subxt::tx::DefaultPayload::new("Revive", "call", self) } } diff --git a/crates/extrinsics/src/extrinsic_opts.rs b/crates/extrinsics/src/extrinsic_opts.rs index b02c74f6f..7bec5ecb6 100644 --- a/crates/extrinsics/src/extrinsic_opts.rs +++ b/crates/extrinsics/src/extrinsic_opts.rs @@ -28,6 +28,7 @@ use crate::{ url_to_string, ContractArtifacts, }; +use scale::Encode; use std::{ marker::PhantomData, option::Option, @@ -58,13 +59,16 @@ where { /// Returns a clean builder for [`ExtrinsicOpts`]. pub fn new(signer: Signer) -> ExtrinsicOptsBuilder { + let storage_deposit_limit = 10000000000u128.encode(); + let storage_deposit_limit: E::Balance = + crate::Decode::decode(&mut &storage_deposit_limit[..]).unwrap(); ExtrinsicOptsBuilder { opts: ExtrinsicOpts { file: None, manifest_path: None, url: url::Url::parse("ws://localhost:9944").unwrap(), signer, - storage_deposit_limit: None, + storage_deposit_limit: Some(storage_deposit_limit), verbosity: Verbosity::Default, _marker: PhantomData, }, diff --git a/crates/extrinsics/src/instantiate.rs b/crates/extrinsics/src/instantiate.rs index 1b7b31fe5..a6666c429 100644 --- a/crates/extrinsics/src/instantiate.rs +++ b/crates/extrinsics/src/instantiate.rs @@ -67,6 +67,7 @@ use subxt::{ scale_encode::EncodeAsType, }, tx, + utils::H160, Config, OnlineClient, }; @@ -330,21 +331,23 @@ where data: self.args.data.clone(), salt: self.args.salt.clone(), }; - state_call(&self.rpc, "ContractsApi_instantiate", &call_request).await + state_call(&self.rpc, "ReviveApi_instantiate", &call_request).await } async fn instantiate_with_code( &self, code: Vec, gas_limit: Weight, - ) -> Result, ErrorVariant> { + ) -> Result, ErrorVariant> { let call = InstantiateWithCode::new( self.args.value, gas_limit, - self.args.storage_deposit_limit, + self.args + .storage_deposit_limit + .expect("no storage deposit limit available"), code, self.args.data.clone(), - self.args.salt.clone(), + None, ) .build(); @@ -358,7 +361,7 @@ where .map(|code_stored| code_stored.code_hash); let instantiated = events - .find_last::>()? + .find_last::>()? .ok_or_else(|| anyhow!("Failed to find Instantiated event"))?; Ok(InstantiateExecResult { @@ -372,7 +375,7 @@ where &self, code_hash: C::Hash, gas_limit: Weight, - ) -> Result, ErrorVariant> { + ) -> Result, ErrorVariant> { let call = Instantiate::::new( self.args.value, gas_limit, @@ -387,7 +390,7 @@ where submit_extrinsic(&self.client, &self.rpc, &call, self.opts.signer()).await?; let instantiated = events - .find_first::>()? + .find_first::>()? .ok_or_else(|| anyhow!("Failed to find Instantiated event"))?; Ok(InstantiateExecResult { @@ -410,7 +413,7 @@ where pub async fn instantiate( &self, gas_limit: Option, - ) -> Result, ErrorVariant> { + ) -> Result, ErrorVariant> { // use user specified values where provided, otherwise estimate let gas_limit = match gas_limit { Some(gas_limit) => gas_limit, @@ -485,10 +488,10 @@ where } /// A struct representing the result of an instantiate command execution. -pub struct InstantiateExecResult { +pub struct InstantiateExecResult { pub events: ExtrinsicEvents, pub code_hash: Option, - pub contract_address: C::AccountId, + pub contract_address: AccountId, } /// Result of the contract call diff --git a/crates/extrinsics/src/integration_tests.rs b/crates/extrinsics/src/integration_tests.rs index 7c62ffd00..5fca264eb 100644 --- a/crates/extrinsics/src/integration_tests.rs +++ b/crates/extrinsics/src/integration_tests.rs @@ -39,6 +39,7 @@ use std::{ time, }; use subxt::{ + utils::H160, OnlineClient, PolkadotConfig as DefaultConfig, }; @@ -193,6 +194,8 @@ async fn build_upload_instantiate_call() { cargo_contract(project_path.as_path()) .arg("build") + .arg("--target") + .arg("riscv") .assert() .success(); @@ -338,6 +341,8 @@ async fn build_upload_instantiate_info() { cargo_contract(project_path.as_path()) .arg("build") + .arg("--target") + .arg("riscv") .assert() .success(); @@ -461,6 +466,8 @@ async fn api_build_upload_instantiate_call() { cargo_contract(project_path.as_path()) .arg("build") + .arg("--target") + .arg("riscv") .assert() .success(); @@ -495,7 +502,7 @@ async fn api_build_upload_instantiate_call() { .unwrap(); let instantiate_result = instantiate.instantiate(None).await; assert!(instantiate_result.is_ok(), "instantiate code failed"); - let instantiate_result: InstantiateExecResult = + let instantiate_result: InstantiateExecResult = instantiate_result.unwrap(); let contract_account = instantiate_result.contract_address.to_string(); assert_eq!(48, contract_account.len(), "{contract_account:?}"); @@ -503,14 +510,10 @@ async fn api_build_upload_instantiate_call() { // call the contract // the value should be true let call: CallExec = - CallCommandBuilder::new( - instantiate_result.contract_address.clone(), - "get", - opts.clone(), - ) - .done() - .await - .unwrap(); + CallCommandBuilder::new(instantiate_result.contract_address, "get", opts.clone()) + .done() + .await + .unwrap(); let result = call.call_dry_run().await; assert!(result.is_ok(), "call failed"); let result = result.unwrap(); @@ -533,7 +536,7 @@ async fn api_build_upload_instantiate_call() { // flip the value let call: CallExec = CallCommandBuilder::new( - instantiate_result.contract_address.clone(), + instantiate_result.contract_address, "flip", opts.clone(), ) @@ -556,14 +559,10 @@ async fn api_build_upload_instantiate_call() { // call the contract // make sure the value has been flipped let call: CallExec = - CallCommandBuilder::new( - instantiate_result.contract_address.clone(), - "get", - opts.clone(), - ) - .done() - .await - .unwrap(); + CallCommandBuilder::new(instantiate_result.contract_address, "get", opts.clone()) + .done() + .await + .unwrap(); let result = call.call_dry_run().await; assert!(result.is_ok(), "call failed"); let result = result.unwrap(); @@ -601,6 +600,8 @@ async fn api_build_upload_remove() { cargo_contract(project_path.as_path()) .arg("build") + .arg("--target") + .arg("riscv") .assert() .success(); @@ -717,6 +718,8 @@ async fn build_upload_instantiate_storage() { cargo_contract(project_path.as_path()) .arg("build") + .arg("--target") + .arg("riscv") .assert() .success(); diff --git a/crates/extrinsics/src/upload.rs b/crates/extrinsics/src/upload.rs index 699227a67..231ba7af8 100644 --- a/crates/extrinsics/src/upload.rs +++ b/crates/extrinsics/src/upload.rs @@ -132,9 +132,8 @@ where origin: self.opts.signer().account_id(), code: self.code.0.clone(), storage_deposit_limit, - determinism: Determinism::Enforced, }; - state_call(&self.rpc, "ContractsApi_upload_code", call_request).await + state_call(&self.rpc, "ReviveApi_upload_code", call_request).await } /// Uploads contract code to the blockchain with specified options. @@ -148,8 +147,7 @@ where let call = UploadCode::new( self.code.clone(), - storage_deposit_limit, - Determinism::Enforced, + storage_deposit_limit.expect("no storage deposit limit available"), ) .build(); @@ -190,7 +188,6 @@ struct CodeUploadRequest { origin: AccountId, code: Vec, storage_deposit_limit: Option, - determinism: Determinism, } /// A struct representing the result of an upload command execution.