mirror of
https://github.com/darkrenaissance/darkfi.git
synced 2026-01-10 07:08:05 -05:00
get wasm code compiling with wasmer3.0.0-beta. doesn't work yet
This commit is contained in:
@@ -121,9 +121,9 @@ sha2 = {version = "0.10.6", optional = true}
|
||||
|
||||
# Smart contract runtime
|
||||
darkfi-sdk = {path = "src/sdk", optional = true}
|
||||
wasmer = {version = "2.3.0", optional = true}
|
||||
wasmer-compiler-singlepass = {version = "2.3.0", optional = true}
|
||||
wasmer-middlewares = {version = "2.3.0", optional = true}
|
||||
wasmer = {version = "3.0.0-beta", optional = true}
|
||||
wasmer-compiler-singlepass = {version = "3.0.0-beta", optional = true}
|
||||
wasmer-middlewares = {version = "3.0.0-beta", optional = true}
|
||||
|
||||
# Wallet management
|
||||
libsqlite3-sys = {version = "0.24.2", features = ["bundled-sqlcipher"], optional = true }
|
||||
|
||||
319
example/smart-contract/Cargo.lock
generated
319
example/smart-contract/Cargo.lock
generated
@@ -285,7 +285,7 @@ dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"miniz_oxide",
|
||||
"object 0.29.0",
|
||||
"object",
|
||||
"rustc-demangle",
|
||||
]
|
||||
|
||||
@@ -570,56 +570,57 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "cranelift-bforest"
|
||||
version = "0.82.3"
|
||||
version = "0.86.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "38faa2a16616c8e78a18d37b4726b98bfd2de192f2fdc8a39ddf568a408a0f75"
|
||||
checksum = "529ffacce2249ac60edba2941672dfedf3d96558b415d0d8083cd007456e0f55"
|
||||
dependencies = [
|
||||
"cranelift-entity",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cranelift-codegen"
|
||||
version = "0.82.3"
|
||||
version = "0.86.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "26f192472a3ba23860afd07d2b0217dc628f21fcc72617aa1336d98e1671f33b"
|
||||
checksum = "427d105f617efc8cb55f8d036a7fded2e227892d8780b4985e5551f8d27c4a92"
|
||||
dependencies = [
|
||||
"cranelift-bforest",
|
||||
"cranelift-codegen-meta",
|
||||
"cranelift-codegen-shared",
|
||||
"cranelift-entity",
|
||||
"cranelift-isle",
|
||||
"gimli",
|
||||
"log",
|
||||
"regalloc",
|
||||
"regalloc2",
|
||||
"smallvec",
|
||||
"target-lexicon",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cranelift-codegen-meta"
|
||||
version = "0.82.3"
|
||||
version = "0.86.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0f32ddb89e9b89d3d9b36a5b7d7ea3261c98235a76ac95ba46826b8ec40b1a24"
|
||||
checksum = "551674bed85b838d45358e3eab4f0ffaa6790c70dc08184204b9a54b41cdb7d1"
|
||||
dependencies = [
|
||||
"cranelift-codegen-shared",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cranelift-codegen-shared"
|
||||
version = "0.82.3"
|
||||
version = "0.86.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "01fd0d9f288cc1b42d9333b7a776b17e278fc888c28e6a0f09b5573d45a150bc"
|
||||
checksum = "2b3a63ae57498c3eb495360944a33571754241e15e47e3bcae6082f40fec5866"
|
||||
|
||||
[[package]]
|
||||
name = "cranelift-entity"
|
||||
version = "0.82.3"
|
||||
version = "0.86.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9e3bfe172b83167604601faf9dc60453e0d0a93415b57a9c4d1a7ae6849185cf"
|
||||
checksum = "11aa8aa624c72cc1c94ea3d0739fa61248260b5b14d3646f51593a88d67f3e6e"
|
||||
|
||||
[[package]]
|
||||
name = "cranelift-frontend"
|
||||
version = "0.82.3"
|
||||
version = "0.86.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a006e3e32d80ce0e4ba7f1f9ddf66066d052a8c884a110b91d05404d6ce26dce"
|
||||
checksum = "544ee8f4d1c9559c9aa6d46e7aaeac4a13856d620561094f35527356c7d21bd0"
|
||||
dependencies = [
|
||||
"cranelift-codegen",
|
||||
"log",
|
||||
@@ -627,6 +628,12 @@ dependencies = [
|
||||
"target-lexicon",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cranelift-isle"
|
||||
version = "0.86.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ed16b14363d929b8c37e3c557d0a7396791b383ecc302141643c054343170aad"
|
||||
|
||||
[[package]]
|
||||
name = "crc"
|
||||
version = "3.0.0"
|
||||
@@ -1454,15 +1461,6 @@ dependencies = [
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.11.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e"
|
||||
dependencies = [
|
||||
"ahash",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.12.3"
|
||||
@@ -1478,7 +1476,7 @@ version = "0.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "69fe1fcf8b4278d860ad0548329f892a3631fb63f82574df68275f34cdbe0ffa"
|
||||
dependencies = [
|
||||
"hashbrown 0.12.3",
|
||||
"hashbrown",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1570,8 +1568,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "10a35a97730320ffe8e2d410b5d3b69279b98d2c14bdb8b70ea89ecf7888d41e"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"hashbrown 0.12.3",
|
||||
"serde",
|
||||
"hashbrown",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1666,16 +1663,6 @@ version = "0.2.135"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "68783febc7782c6c5cb401fbda4de5a9898be1762314da0bb2c10ced61f18b0c"
|
||||
|
||||
[[package]]
|
||||
name = "libloading"
|
||||
version = "0.7.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "efbc0f03f9a775e9f6aed295c6a1ba2253c5757a9e03d55c6caa46a681abcddd"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libsqlite3-sys"
|
||||
version = "0.24.2"
|
||||
@@ -1716,27 +1703,6 @@ dependencies = [
|
||||
"value-bag",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "loupe"
|
||||
version = "0.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9b6a72dfa44fe15b5e76b94307eeb2ff995a8c5b283b55008940c02e0c5b634d"
|
||||
dependencies = [
|
||||
"indexmap",
|
||||
"loupe-derive",
|
||||
"rustversion",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "loupe-derive"
|
||||
version = "0.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c0fbfc88337168279f2e9ae06e157cfed4efd3316e14dc96ed074d4f2e6c5952"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "mach"
|
||||
version = "0.3.2"
|
||||
@@ -1880,18 +1846,6 @@ version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b8f8bdf33df195859076e54ab11ee78a1b208382d3a26ec40d142ffc1ecc49ef"
|
||||
|
||||
[[package]]
|
||||
name = "object"
|
||||
version = "0.28.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e42c982f2d955fac81dd7e1d0e1426a7d702acd9c98d19ab01083a6a0328c424"
|
||||
dependencies = [
|
||||
"crc32fast",
|
||||
"hashbrown 0.11.2",
|
||||
"indexmap",
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "object"
|
||||
version = "0.29.0"
|
||||
@@ -2263,13 +2217,14 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regalloc"
|
||||
version = "0.0.34"
|
||||
name = "regalloc2"
|
||||
version = "0.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "62446b1d3ebf980bdc68837700af1d77b37bc430e524bf95319c6eada2a4cc02"
|
||||
checksum = "d43a209257d978ef079f3d446331d0f1794f5e0fc19b306a199983857833a779"
|
||||
dependencies = [
|
||||
"fxhash",
|
||||
"log",
|
||||
"rustc-hash",
|
||||
"slice-group-by",
|
||||
"smallvec",
|
||||
]
|
||||
|
||||
@@ -2325,7 +2280,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cec2b3485b07d96ddfd3134767b8a447b45ea4eb91448d0a35180ec0ffd5ed15"
|
||||
dependencies = [
|
||||
"bytecheck",
|
||||
"hashbrown 0.12.3",
|
||||
"hashbrown",
|
||||
"indexmap",
|
||||
"ptr_meta",
|
||||
"rend",
|
||||
"rkyv_derive",
|
||||
@@ -2349,12 +2305,6 @@ version = "0.1.21"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342"
|
||||
|
||||
[[package]]
|
||||
name = "rustc-hash"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
|
||||
|
||||
[[package]]
|
||||
name = "rustls"
|
||||
version = "0.20.6"
|
||||
@@ -2376,12 +2326,6 @@ dependencies = [
|
||||
"base64",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustversion"
|
||||
version = "1.0.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "97477e48b4cf8603ad5f7aaf897467cf42ab4218a38ef76fb14c2d6773a6d6a8"
|
||||
|
||||
[[package]]
|
||||
name = "ryu"
|
||||
version = "1.0.11"
|
||||
@@ -2476,15 +2420,6 @@ dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_bytes"
|
||||
version = "0.11.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cfc50e8183eeeb6178dcb167ae34a8051d63535023ae38b5d8d12beae193d37b"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.145"
|
||||
@@ -2588,6 +2523,12 @@ dependencies = [
|
||||
"parking_lot",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "slice-group-by"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "03b634d87b960ab1a38c4fe143b508576f075e7c978bfad18217645ebfdfa2ec"
|
||||
|
||||
[[package]]
|
||||
name = "smallvec"
|
||||
version = "1.10.0"
|
||||
@@ -2984,7 +2925,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"log",
|
||||
"pin-project-lite",
|
||||
"tracing-attributes",
|
||||
"tracing-core",
|
||||
@@ -3228,73 +3168,61 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasmer"
|
||||
version = "2.3.0"
|
||||
version = "3.0.0-beta.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ea8d8361c9d006ea3d7797de7bd6b1492ffd0f91a22430cfda6c1658ad57bedf"
|
||||
checksum = "01fc47a9d4ebb42b3a9a3d802e809bbdb5afaf3028373a82b989e51f4e400903"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"cfg-if",
|
||||
"indexmap",
|
||||
"js-sys",
|
||||
"loupe",
|
||||
"more-asserts",
|
||||
"target-lexicon",
|
||||
"thiserror",
|
||||
"wasm-bindgen",
|
||||
"wasmer-artifact",
|
||||
"wasmer-compiler",
|
||||
"wasmer-compiler-cranelift",
|
||||
"wasmer-derive",
|
||||
"wasmer-engine",
|
||||
"wasmer-engine-dylib",
|
||||
"wasmer-engine-universal",
|
||||
"wasmer-types",
|
||||
"wasmer-vm",
|
||||
"wat",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasmer-artifact"
|
||||
version = "2.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7aaf9428c29c1d8ad2ac0e45889ba8a568a835e33fd058964e5e500f2f7ce325"
|
||||
dependencies = [
|
||||
"enumset",
|
||||
"loupe",
|
||||
"thiserror",
|
||||
"wasmer-compiler",
|
||||
"wasmer-types",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasmer-compiler"
|
||||
version = "2.3.0"
|
||||
version = "3.0.0-beta.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e67a6cd866aed456656db2cfea96c18baabbd33f676578482b85c51e1ee19d2c"
|
||||
checksum = "54d7b5068f9ed673f0fc8513b4702067a0f5712d3ea226eb71fc4a9c6c4fe9c7"
|
||||
dependencies = [
|
||||
"backtrace",
|
||||
"cfg-if",
|
||||
"enum-iterator",
|
||||
"enumset",
|
||||
"loupe",
|
||||
"rkyv",
|
||||
"serde",
|
||||
"serde_bytes",
|
||||
"lazy_static",
|
||||
"leb128",
|
||||
"memmap2",
|
||||
"more-asserts",
|
||||
"region",
|
||||
"rustc-demangle",
|
||||
"smallvec",
|
||||
"target-lexicon",
|
||||
"thiserror",
|
||||
"wasmer-types",
|
||||
"wasmer-vm",
|
||||
"wasmparser",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasmer-compiler-cranelift"
|
||||
version = "2.3.0"
|
||||
version = "3.0.0-beta.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "48be2f9f6495f08649e4f8b946a2cbbe119faf5a654aa1457f9504a99d23dae0"
|
||||
checksum = "f0fac321e5d3dc4f157f28bf6001f06d2e821422ce60449da97d39af171b4169"
|
||||
dependencies = [
|
||||
"cranelift-codegen",
|
||||
"cranelift-entity",
|
||||
"cranelift-frontend",
|
||||
"gimli",
|
||||
"loupe",
|
||||
"more-asserts",
|
||||
"rayon",
|
||||
"smallvec",
|
||||
@@ -3306,16 +3234,15 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasmer-compiler-singlepass"
|
||||
version = "2.3.0"
|
||||
version = "3.0.0-beta.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "29ca2a35204d8befa85062bc7aac259a8db8070b801b8a783770ba58231d729e"
|
||||
checksum = "20ae0bafb36a7ab8e4125474ebf19e640820797181bc19682d056d0cba037e6f"
|
||||
dependencies = [
|
||||
"byteorder",
|
||||
"dynasm",
|
||||
"dynasmrt",
|
||||
"gimli",
|
||||
"lazy_static",
|
||||
"loupe",
|
||||
"more-asserts",
|
||||
"rayon",
|
||||
"smallvec",
|
||||
@@ -3325,9 +3252,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasmer-derive"
|
||||
version = "2.3.0"
|
||||
version = "3.0.0-beta.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "00e50405cc2a2f74ff574584710a5f2c1d5c93744acce2ca0866084739284b51"
|
||||
checksum = "02b38c7a442cffa5efb799631013bb30aeb1d553c50effa51905ea8b36ecc6c8"
|
||||
dependencies = [
|
||||
"proc-macro-error",
|
||||
"proc-macro2",
|
||||
@@ -3335,136 +3262,37 @@ dependencies = [
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasmer-engine"
|
||||
version = "2.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3f98f010978c244db431b392aeab0661df7ea0822343334f8f2a920763548e45"
|
||||
dependencies = [
|
||||
"backtrace",
|
||||
"enumset",
|
||||
"lazy_static",
|
||||
"loupe",
|
||||
"memmap2",
|
||||
"more-asserts",
|
||||
"rustc-demangle",
|
||||
"serde",
|
||||
"serde_bytes",
|
||||
"target-lexicon",
|
||||
"thiserror",
|
||||
"wasmer-artifact",
|
||||
"wasmer-compiler",
|
||||
"wasmer-types",
|
||||
"wasmer-vm",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasmer-engine-dylib"
|
||||
version = "2.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ad0358af9c154724587731175553805648d9acb8f6657880d165e378672b7e53"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"enum-iterator",
|
||||
"enumset",
|
||||
"leb128",
|
||||
"libloading",
|
||||
"loupe",
|
||||
"object 0.28.4",
|
||||
"rkyv",
|
||||
"serde",
|
||||
"tempfile",
|
||||
"tracing",
|
||||
"wasmer-artifact",
|
||||
"wasmer-compiler",
|
||||
"wasmer-engine",
|
||||
"wasmer-object",
|
||||
"wasmer-types",
|
||||
"wasmer-vm",
|
||||
"which",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasmer-engine-universal"
|
||||
version = "2.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "440dc3d93c9ca47865a4f4edd037ea81bf983b5796b59b3d712d844b32dbef15"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"enumset",
|
||||
"leb128",
|
||||
"loupe",
|
||||
"region",
|
||||
"rkyv",
|
||||
"wasmer-compiler",
|
||||
"wasmer-engine",
|
||||
"wasmer-engine-universal-artifact",
|
||||
"wasmer-types",
|
||||
"wasmer-vm",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasmer-engine-universal-artifact"
|
||||
version = "2.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "68f1db3f54152657eb6e86c44b66525ff7801dad8328fe677da48dd06af9ad41"
|
||||
dependencies = [
|
||||
"enum-iterator",
|
||||
"enumset",
|
||||
"loupe",
|
||||
"rkyv",
|
||||
"thiserror",
|
||||
"wasmer-artifact",
|
||||
"wasmer-compiler",
|
||||
"wasmer-types",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasmer-middlewares"
|
||||
version = "2.3.0"
|
||||
version = "3.0.0-beta.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d7812438ed2f37203a37007cdb5332b8475cb2b16e15d51299b2647894e9ed3a"
|
||||
checksum = "190f1fa6e3a5980c9a571af457cb810945d4cd11b674b3892db973220f87bb0f"
|
||||
dependencies = [
|
||||
"loupe",
|
||||
"wasmer",
|
||||
"wasmer-types",
|
||||
"wasmer-vm",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasmer-object"
|
||||
version = "2.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8d831335ff3a44ecf451303f6f891175c642488036b92ceceb24ac8623a8fa8b"
|
||||
dependencies = [
|
||||
"object 0.28.4",
|
||||
"thiserror",
|
||||
"wasmer-compiler",
|
||||
"wasmer-types",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasmer-types"
|
||||
version = "2.3.0"
|
||||
version = "3.0.0-beta.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "39df01ea05dc0a9bab67e054c7cb01521e53b35a7bb90bd02eca564ed0b2667f"
|
||||
checksum = "7d47fb87929c956693d68393d4778670ed1ce9733804b74bbd5fa6fa6d725250"
|
||||
dependencies = [
|
||||
"backtrace",
|
||||
"enum-iterator",
|
||||
"enumset",
|
||||
"indexmap",
|
||||
"loupe",
|
||||
"more-asserts",
|
||||
"rkyv",
|
||||
"serde",
|
||||
"target-lexicon",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasmer-vm"
|
||||
version = "2.3.0"
|
||||
version = "3.0.0-beta.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "30d965fa61f4dc4cdb35a54daaf7ecec3563fbb94154a6c35433f879466247dd"
|
||||
checksum = "6a72cac9f0ce7a9f3d0fe01604202270cdfe8d3dae9d84742b85c5d935cad74d"
|
||||
dependencies = [
|
||||
"backtrace",
|
||||
"cc",
|
||||
@@ -3474,16 +3302,12 @@ dependencies = [
|
||||
"indexmap",
|
||||
"lazy_static",
|
||||
"libc",
|
||||
"loupe",
|
||||
"mach",
|
||||
"memoffset",
|
||||
"more-asserts",
|
||||
"region",
|
||||
"rkyv",
|
||||
"scopeguard",
|
||||
"serde",
|
||||
"thiserror",
|
||||
"wasmer-artifact",
|
||||
"wasmer-types",
|
||||
"winapi",
|
||||
]
|
||||
@@ -3544,17 +3368,6 @@ dependencies = [
|
||||
"cc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "which"
|
||||
version = "4.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1c831fbbee9e129a8cf93e7747a82da9d95ba8e16621cae60ec2cdc849bacb7b"
|
||||
dependencies = [
|
||||
"either",
|
||||
"libc",
|
||||
"once_cell",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi"
|
||||
version = "0.3.9"
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use darkfi_serial::{deserialize, SerialDecodable, SerialEncodable};
|
||||
use darkfi_sdk::{
|
||||
crypto::Nullifier,
|
||||
entrypoint,
|
||||
@@ -25,6 +24,7 @@ use darkfi_sdk::{
|
||||
pasta::pallas,
|
||||
state::nullifier_exists,
|
||||
};
|
||||
use darkfi_serial::{deserialize, SerialDecodable, SerialEncodable};
|
||||
|
||||
// An example of deserializing the payload into a struct
|
||||
#[derive(SerialEncodable, SerialDecodable)]
|
||||
|
||||
@@ -16,13 +16,13 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use darkfi_serial::serialize;
|
||||
use darkfi::{
|
||||
node::{MemoryState, State},
|
||||
runtime::{util::serialize_payload, vm_runtime::Runtime},
|
||||
Result,
|
||||
};
|
||||
use darkfi_sdk::{pasta::pallas, crypto::nullifier::Nullifier};
|
||||
use darkfi_sdk::{crypto::nullifier::Nullifier, pasta::pallas};
|
||||
use darkfi_serial::serialize;
|
||||
|
||||
use smart_contract::Args;
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ use crate::node::state::ProgramState;
|
||||
/// Try to read a `Nullifier` from the given pointer and check if it's
|
||||
/// an existing nullifier in the blockchain state machine.
|
||||
pub fn nullifier_exists(env: &Env, ptr: u32, len: u32) -> i32 {
|
||||
/*
|
||||
if let Some(bytes) = env.memory.get_ref().unwrap().read(ptr, len as usize) {
|
||||
debug!(target: "wasm_runtime::nullifier_exists", "Read bytes: {:?}", bytes);
|
||||
|
||||
@@ -46,12 +47,14 @@ pub fn nullifier_exists(env: &Env, ptr: u32, len: u32) -> i32 {
|
||||
}
|
||||
|
||||
error!(target: "wasm_runtime::nullifier_exists", "Failed to read bytes from VM memory");
|
||||
*/
|
||||
-2
|
||||
}
|
||||
|
||||
/// Try to read a `MerkleNode` from the given pointer and check if it's
|
||||
/// a valid Merkle root in the chain's Merkle tree.
|
||||
pub fn is_valid_merkle(env: &Env, ptr: u32, len: u32) -> i32 {
|
||||
/*
|
||||
if let Some(bytes) = env.memory.get_ref().unwrap().read(ptr, len as usize) {
|
||||
debug!(target: "wasm_runtime::is_valid_merkle", "Read bytes: {:?}", bytes);
|
||||
|
||||
@@ -73,5 +76,6 @@ pub fn is_valid_merkle(env: &Env, ptr: u32, len: u32) -> i32 {
|
||||
}
|
||||
|
||||
error!(target: "wasm_runtime::is_valid_merkle", "Failed to read bytes from VM memory");
|
||||
*/
|
||||
-2
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use wasmer::{Array, Memory, WasmPtr};
|
||||
use wasmer::{Memory, WasmPtr};
|
||||
|
||||
use crate::{Error, Result};
|
||||
|
||||
@@ -27,6 +27,8 @@ pub trait MemoryManipulation {
|
||||
|
||||
impl MemoryManipulation for Memory {
|
||||
fn write(&self, mem_offset: u32, value_slice: &[u8]) -> Result<()> {
|
||||
// DISABLED
|
||||
/*
|
||||
// Prepare WasmPtr
|
||||
let target_ptr: WasmPtr<u8, Array> = WasmPtr::new(mem_offset);
|
||||
|
||||
@@ -44,11 +46,15 @@ impl MemoryManipulation for Memory {
|
||||
for i in 0..value_slice.len() {
|
||||
guest_value_slice[i].set(value_slice[i]);
|
||||
}
|
||||
*/
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn read(&self, mem_offset: u32, value_len: usize) -> Option<&[u8]> {
|
||||
// TODO: use data_size() ?
|
||||
// DISABLED
|
||||
/*
|
||||
let memory_size = self.size().bytes().0;
|
||||
|
||||
if mem_offset as usize + value_len > memory_size || mem_offset as usize >= memory_size {
|
||||
@@ -57,6 +63,8 @@ impl MemoryManipulation for Memory {
|
||||
|
||||
let ptr = unsafe { self.view::<u8>().as_ptr().add(mem_offset as usize) as *const u8 };
|
||||
unsafe { Some(std::slice::from_raw_parts(ptr, value_len)) }
|
||||
*/
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -36,6 +36,8 @@ pub fn serialize_payload(payload: &[u8]) -> Vec<u8> {
|
||||
/// Host function for logging strings.
|
||||
/// This is injected into the runtime with wasmer's `imports!` macro.
|
||||
pub(crate) fn drk_log(env: &Env, ptr: u32, len: u32) {
|
||||
// DISABLED
|
||||
/*
|
||||
if let Some(bytes) = env.memory.get_ref().unwrap().read(ptr, len as usize) {
|
||||
// Piece the string together
|
||||
let msg = match String::from_utf8(bytes.to_vec()) {
|
||||
@@ -53,4 +55,5 @@ pub(crate) fn drk_log(env: &Env, ptr: u32, len: u32) {
|
||||
}
|
||||
|
||||
error!(target: "wasm_runtime::drk_log", "Failed to read any bytes from VM memory");
|
||||
*/
|
||||
}
|
||||
|
||||
@@ -21,8 +21,8 @@ use std::sync::{Arc, Mutex};
|
||||
use darkfi_sdk::entrypoint;
|
||||
use log::{debug, info};
|
||||
use wasmer::{
|
||||
imports, wasmparser::Operator, CompilerConfig, Function, HostEnvInitError, Instance, LazyInit,
|
||||
Memory, Module, Store, Universal, Value, WasmerEnv,
|
||||
imports, wasmparser::Operator, CompilerConfig, Function, FunctionEnv, Instance,
|
||||
Memory, Module, Store, Value,
|
||||
};
|
||||
use wasmer_compiler_singlepass::Singlepass;
|
||||
use wasmer_middlewares::{
|
||||
@@ -55,13 +55,14 @@ pub struct Env {
|
||||
/// Logs produced by the contract
|
||||
pub logs: Arc<Mutex<Vec<String>>>,
|
||||
/// Direct memory access to the VM
|
||||
pub memory: LazyInit<Memory>,
|
||||
pub memory: Option<Memory>,
|
||||
/// Cloned state machine living in memory
|
||||
pub state_machine: Arc<MemoryState>,
|
||||
/// State updates produced by the contract
|
||||
pub state_updates: Arc<Mutex<Vec<StateUpdate>>>,
|
||||
}
|
||||
|
||||
/*
|
||||
impl WasmerEnv for Env {
|
||||
fn init_with_instance(
|
||||
&mut self,
|
||||
@@ -72,6 +73,7 @@ impl WasmerEnv for Env {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
/// The result of the VM execution
|
||||
pub struct ExecutionResult {
|
||||
@@ -85,7 +87,7 @@ pub struct ExecutionResult {
|
||||
|
||||
pub struct Runtime {
|
||||
pub instance: Instance,
|
||||
pub env: Env,
|
||||
//pub env: Env,
|
||||
}
|
||||
|
||||
impl Runtime {
|
||||
@@ -111,51 +113,56 @@ impl Runtime {
|
||||
let metering = Arc::new(Metering::new(GAS_LIMIT, cost_function));
|
||||
|
||||
// Define the compiler and middleware, engine, and store
|
||||
let mut compiler = Singlepass::new();
|
||||
compiler.push_middleware(metering);
|
||||
let store = Store::new(&Universal::new(compiler).engine());
|
||||
let mut compiler_config = Singlepass::new();
|
||||
compiler_config.push_middleware(metering);
|
||||
let mut store = Store::new(compiler_config);
|
||||
|
||||
debug!(target: "wasm_runtime::new", "Compiling module");
|
||||
let module = Module::new(&store, wasm_bytes)?;
|
||||
|
||||
debug!(target: "wasm_runtime::new", "Importing functions");
|
||||
let memory = LazyInit::new();
|
||||
let logs = Arc::new(Mutex::new(vec![]));
|
||||
let state_machine = Arc::new(state_machine);
|
||||
let state_updates = Arc::new(Mutex::new(vec![]));
|
||||
|
||||
let env = Env { logs, memory, state_machine, state_updates };
|
||||
let env = FunctionEnv::new(&mut store, Env { logs, memory: None, state_machine, state_updates });
|
||||
|
||||
let import_object = imports! {
|
||||
let imports = imports! {
|
||||
"env" => {
|
||||
"drk_log_" => Function::new_native_with_env(
|
||||
/*
|
||||
"drk_log_" => Function::new_typed_with_env(
|
||||
&store,
|
||||
env.clone(),
|
||||
drk_log,
|
||||
),
|
||||
|
||||
"nullifier_exists_" => Function::new_native_with_env(
|
||||
"nullifier_exists_" => Function::new_typed_with_env(
|
||||
&store,
|
||||
env.clone(),
|
||||
nullifier_exists,
|
||||
),
|
||||
|
||||
"is_valid_merkle_" => Function::new_native_with_env(
|
||||
"is_valid_merkle_" => Function::new_typed_with_env(
|
||||
&store,
|
||||
env.clone(),
|
||||
is_valid_merkle,
|
||||
),
|
||||
*/
|
||||
}
|
||||
};
|
||||
|
||||
debug!(target: "wasm_runtime::new", "Instantiating module");
|
||||
let instance = Instance::new(&module, &import_object)?;
|
||||
let instance = Instance::new(&mut store, &module, &imports)?;
|
||||
|
||||
Ok(Self { instance, env })
|
||||
//let mut env_mut = env.as_mut(&mut store);
|
||||
//env_mut.memory = Some(instance.exports.get_with_generics_weak(MEMORY)?);
|
||||
|
||||
Ok(Self { instance /*, env */ })
|
||||
}
|
||||
|
||||
/// Run the hardcoded `ENTRYPOINT` function with the given payload as input.
|
||||
pub fn run(&mut self, payload: &[u8]) -> Result<()> {
|
||||
/*
|
||||
// Get module linear memory
|
||||
let memory = self.memory()?;
|
||||
|
||||
@@ -193,16 +200,21 @@ impl Runtime {
|
||||
// _ => Err(ContractError(retval)),
|
||||
_ => todo!(),
|
||||
}
|
||||
*/
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn print_logs(&self) {
|
||||
let logs = self.env.logs.lock().unwrap();
|
||||
// DISABLED
|
||||
/*let logs = self.env.logs.lock().unwrap();
|
||||
for msg in logs.iter() {
|
||||
debug!(target: "wasm_runtime::run", "Contract log: {}", msg);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
fn gas_info(&self) -> String {
|
||||
// DISABLED
|
||||
/*
|
||||
let remaining_points = get_remaining_points(&self.instance);
|
||||
|
||||
match remaining_points {
|
||||
@@ -213,13 +225,17 @@ impl Runtime {
|
||||
format!("Gas fully exhausted: {}/{}", GAS_LIMIT + 1, GAS_LIMIT)
|
||||
}
|
||||
}
|
||||
*/
|
||||
"foo".to_string()
|
||||
}
|
||||
|
||||
/// Allocate some memory space on a wasm linear memory to allow direct rw.
|
||||
fn guest_mem_alloc(&self, size: usize) -> Result<u32> {
|
||||
let mem_alloc = self.instance.exports.get_function(WASM_MEM_ALLOC)?;
|
||||
let res_target_ptr = mem_alloc.call(&[Value::I32(size as i32)])?.to_vec();
|
||||
Ok(res_target_ptr[0].unwrap_i32() as u32)
|
||||
// DISABLED
|
||||
//let mem_alloc = self.instance.exports.get_function(WASM_MEM_ALLOC)?;
|
||||
//let res_target_ptr = mem_alloc.call(&[Value::I32(size as i32)])?.to_vec();
|
||||
//Ok(res_target_ptr[0].unwrap_i32() as u32)
|
||||
Ok(0)
|
||||
}
|
||||
|
||||
/// Retrieve linear memory from a wasm module and return its reference.
|
||||
|
||||
Reference in New Issue
Block a user