From 64c887d2ba27826737901ce5d98468af093aad0d Mon Sep 17 00:00:00 2001 From: Denys Zadorozhnyi Date: Fri, 25 Apr 2025 11:55:03 +0300 Subject: [PATCH 1/8] chore: add `examples/counter-contract` --- examples/counter-contract/Cargo.lock | 1791 +++++++++++++++++ examples/counter-contract/Cargo.toml | 45 + examples/counter-contract/src/lib.rs | 61 + examples/counter-contract/wit/counter.wit | 16 + .../integration/expected/examples/counter.hir | 804 ++++++++ .../expected/examples/counter.masm | 1234 ++++++++++++ .../integration/expected/examples/counter.wat | 509 +++++ .../src/rust_masm_tests/examples.rs | 31 + 8 files changed, 4491 insertions(+) create mode 100644 examples/counter-contract/Cargo.lock create mode 100644 examples/counter-contract/Cargo.toml create mode 100644 examples/counter-contract/src/lib.rs create mode 100644 examples/counter-contract/wit/counter.wit create mode 100644 tests/integration/expected/examples/counter.hir create mode 100644 tests/integration/expected/examples/counter.masm create mode 100644 tests/integration/expected/examples/counter.wat diff --git a/examples/counter-contract/Cargo.lock b/examples/counter-contract/Cargo.lock new file mode 100644 index 000000000..a3a790899 --- /dev/null +++ b/examples/counter-contract/Cargo.lock @@ -0,0 +1,1791 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "aho-corasick" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" +dependencies = [ + "memchr", +] + +[[package]] +name = "arrayref" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76a2e8124351fda1ef8aaaa3bbd7ebbcb486bbcd4225aca0aa0d84bb2db8fecb" + +[[package]] +name = "arrayvec" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" + +[[package]] +name = "ascii-canvas" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8824ecca2e851cec16968d54a01dd372ef8f95b244fb84b84e70128be347c3c6" +dependencies = [ + "term", +] + +[[package]] +name = "autocfg" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" + +[[package]] +name = "bech32" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d965446196e3b7decd44aa7ee49e31d630118f90ef12f97900f262eb915c951d" + +[[package]] +name = "bit-set" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0700ddab506f33b20a03b13996eccd309a48e5ff77d0d95926aa0210fb4e95f1" +dependencies = [ + "bit-vec", +] + +[[package]] +name = "bit-vec" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" + +[[package]] +name = "bitflags" +version = "2.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd" + +[[package]] +name = "blake3" +version = "1.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3888aaa89e4b2a40fca9848e400f6a658a5a3978de7be858e209cafa8be9a4a0" +dependencies = [ + "arrayref", + "arrayvec", + "cc", + "cfg-if", + "constant_time_eq", +] + +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] +name = "bumpalo" +version = "3.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1628fb46dfa0b37568d12e5edd512553eccf6a22a78e8bde00bb4aed84d5bdbf" + +[[package]] +name = "cc" +version = "1.2.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04da6a0d40b948dfc4fa8f5bbf402b0fc1a64a28dbf7d12ffd683550f2c1b63a" +dependencies = [ + "shlex", +] + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "constant_time_eq" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c74b8349d32d297c9134b8c88677813a227df8f779daa29bfc29c183fe3dca6" + +[[package]] +name = "counter-contract" +version = "0.1.0" +dependencies = [ + "miden", + "wit-bindgen-rt 0.28.0", +] + +[[package]] +name = "cpufeatures" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" +dependencies = [ + "libc", +] + +[[package]] +name = "crunchy" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43da5946c66ffcc7745f48db692ffbb10a83bfe0afd96235c5c2a4fb23994929" + +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer", + "crypto-common", +] + +[[package]] +name = "dirs-next" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b98cf8ebf19c3d1b223e151f99a4f9f0690dca41414773390fc824184ac833e1" +dependencies = [ + "cfg-if", + "dirs-sys-next", +] + +[[package]] +name = "dirs-sys-next" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d" +dependencies = [ + "libc", + "redox_users", + "winapi", +] + +[[package]] +name = "dissimilar" +version = "1.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8975ffdaa0ef3661bfe02dbdcc06c9f829dfafe6a3c474de366a8d5e44276921" + +[[package]] +name = "either" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" + +[[package]] +name = "ena" +version = "0.14.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d248bdd43ce613d87415282f69b9bb99d947d290b10962dd6c56233312c2ad5" +dependencies = [ + "log", +] + +[[package]] +name = "equivalent" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" + +[[package]] +name = "fixedbitset" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" + +[[package]] +name = "futures" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65bc07b1a8bc7c85c5f2e110c476c7389b4554ba72af57d8445ea63a576b0876" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" + +[[package]] +name = "futures-io" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" + +[[package]] +name = "futures-sink" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" + +[[package]] +name = "futures-task" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" + +[[package]] +name = "futures-util" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" +dependencies = [ + "futures-core", + "futures-sink", + "futures-task", + "pin-project-lite", + "pin-utils", +] + +[[package]] +name = "generator" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc6bd114ceda131d3b1d665eba35788690ad37f5916457286b32ab6fd3c438dd" +dependencies = [ + "cfg-if", + "libc", + "log", + "rustversion", + "windows", +] + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "335ff9f135e4384c8150d6f27c6daed433577f86b4750418338c01a1a2528592" +dependencies = [ + "cfg-if", + "libc", + "wasi 0.11.0+wasi-snapshot-preview1", +] + +[[package]] +name = "getrandom" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73fea8450eea4bac3940448fb7ae50d91f034f941199fcd9d909a5a07aa455f0" +dependencies = [ + "cfg-if", + "js-sys", + "libc", + "r-efi", + "wasi 0.14.2+wasi-0.2.4", + "wasm-bindgen", +] + +[[package]] +name = "glob" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8d1add55171497b4705a648c6b583acafb01d58050a51727785f0b2c8e0a2b2" + +[[package]] +name = "hashbrown" +version = "0.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" + +[[package]] +name = "indenter" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683" + +[[package]] +name = "indexmap" +version = "2.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cea70ddb795996207ad57735b50c5982d8844f38ba9ee5f1aedcfb708a2aa11e" +dependencies = [ + "equivalent", + "hashbrown", +] + +[[package]] +name = "itertools" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1c173a5686ce8bfa551b3563d0c2170bf24ca44da99c7ca4bfdab5418c3fe57" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" + +[[package]] +name = "js-sys" +version = "0.3.77" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cfaf33c695fc6e08064efbc1f72ec937429614f25eef83af942d0e227c3a28f" +dependencies = [ + "once_cell", + "wasm-bindgen", +] + +[[package]] +name = "keccak" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecc2af9a1119c51f12a14607e783cb977bde58bc069ff0c3da1095e635d70654" +dependencies = [ + "cpufeatures", +] + +[[package]] +name = "lalrpop" +version = "0.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55cb077ad656299f160924eb2912aa147d7339ea7d69e1b5517326fdcec3c1ca" +dependencies = [ + "ascii-canvas", + "bit-set", + "ena", + "itertools", + "lalrpop-util", + "petgraph", + "regex", + "regex-syntax 0.8.5", + "string_cache", + "term", + "tiny-keccak", + "unicode-xid", + "walkdir", +] + +[[package]] +name = "lalrpop-util" +version = "0.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "507460a910eb7b32ee961886ff48539633b788a36b65692b95f225b844c82553" + +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" + +[[package]] +name = "libc" +version = "0.2.172" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d750af042f7ef4f724306de029d18836c26c1765a54a6a3f094cbd23a7267ffa" + +[[package]] +name = "libm" +version = "0.2.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9627da5196e5d8ed0b0495e61e518847578da83483c37288316d9b2e03a7f72" + +[[package]] +name = "libredox" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" +dependencies = [ + "bitflags", + "libc", +] + +[[package]] +name = "lock_api" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" +dependencies = [ + "autocfg", + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94" + +[[package]] +name = "loom" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "419e0dc8046cb947daa77eb95ae174acfbddb7673b4151f56d1eed8e93fbfaca" +dependencies = [ + "cfg-if", + "generator", + "scoped-tls", + "tracing", + "tracing-subscriber", +] + +[[package]] +name = "matchers" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" +dependencies = [ + "regex-automata 0.1.10", +] + +[[package]] +name = "memchr" +version = "2.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" + +[[package]] +name = "miden" +version = "0.0.7" +dependencies = [ + "miden-base", + "miden-base-sys", + "miden-sdk-alloc", + "miden-stdlib-sys", +] + +[[package]] +name = "miden-air" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00e2e77c57ae798e02553af158c04d467f6479ab798a8c84459d343a89ff9c50" +dependencies = [ + "miden-core", + "thiserror 2.0.12", + "winter-air", + "winter-prover", +] + +[[package]] +name = "miden-assembly" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75d1cb02d807c2481f365feca966bedb74c66c765923d04c3c23ea678afaf148" +dependencies = [ + "aho-corasick", + "lalrpop", + "lalrpop-util", + "miden-core", + "miden-miette", + "rustc_version 0.4.1", + "smallvec", + "thiserror 2.0.12", + "tracing", + "unicode-width 0.2.0", +] + +[[package]] +name = "miden-base" +version = "0.0.7" +dependencies = [ + "miden-base-macros", + "miden-base-sys", + "miden-stdlib-sys", +] + +[[package]] +name = "miden-base-macros" +version = "0.0.7" +dependencies = [ + "miden-objects", + "proc-macro2", + "quote", + "semver 1.0.26", + "syn", + "toml", +] + +[[package]] +name = "miden-base-sys" +version = "0.0.7" +dependencies = [ + "miden-stdlib-sys", +] + +[[package]] +name = "miden-core" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7d408e01421b5df2e4cfaf1a91efefe3fb5b729f1c99b668d3a69eec0044a6b" +dependencies = [ + "lock_api", + "loom", + "memchr", + "miden-crypto", + "miden-formatting", + "miden-miette", + "num-derive", + "num-traits", + "thiserror 2.0.12", + "winter-math", + "winter-utils", +] + +[[package]] +name = "miden-crypto" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d521a9d5fa949d60e4029e55ff1da892561b298ed636afb5f71d0dde0925bf57" +dependencies = [ + "blake3", + "glob", + "num", + "num-complex", + "rand", + "rand_core", + "sha3", + "thiserror 2.0.12", + "winter-crypto", + "winter-math", + "winter-utils", +] + +[[package]] +name = "miden-formatting" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e392e0a8c34b32671012b439de35fa8987bf14f0f8aac279b97f8b8cc6e263b" +dependencies = [ + "unicode-width 0.1.14", +] + +[[package]] +name = "miden-miette" +version = "8.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eef536978f24a179d94fa2a41e4f92b28e7d8aab14b8d23df28ad2a3d7098b20" +dependencies = [ + "cfg-if", + "futures", + "indenter", + "lazy_static", + "miden-miette-derive", + "owo-colors", + "regex", + "rustc_version 0.2.3", + "rustversion", + "serde_json", + "spin", + "strip-ansi-escapes", + "syn", + "textwrap", + "thiserror 2.0.12", + "trybuild", + "unicode-width 0.1.14", +] + +[[package]] +name = "miden-miette-derive" +version = "8.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86a905f3ea65634dd4d1041a4f0fd0a3e77aa4118341d265af1a94339182222f" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "miden-objects" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ea350fdd6d025d2e4791ac0769bfbc04afca404fbb20f918354dcc758debd4c" +dependencies = [ + "bech32", + "getrandom 0.3.2", + "miden-assembly", + "miden-core", + "miden-crypto", + "miden-processor", + "miden-verifier", + "semver 1.0.26", + "thiserror 2.0.12", +] + +[[package]] +name = "miden-processor" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4e70b053c587014396d06be3502e3952777923bee11729b7514c060fdc0d2c8" +dependencies = [ + "miden-air", + "miden-core", + "thiserror 2.0.12", + "tracing", + "winter-prover", +] + +[[package]] +name = "miden-sdk-alloc" +version = "0.0.7" + +[[package]] +name = "miden-stdlib-sys" +version = "0.0.7" + +[[package]] +name = "miden-verifier" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20ae024b022569d7117891a83cf51ccd5bceeda248f30690b394a6dfc4607061" +dependencies = [ + "miden-air", + "miden-core", + "thiserror 2.0.12", + "tracing", + "winter-verifier", +] + +[[package]] +name = "new_debug_unreachable" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086" + +[[package]] +name = "nu-ansi-term" +version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" +dependencies = [ + "overload", + "winapi", +] + +[[package]] +name = "num" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23" +dependencies = [ + "num-bigint", + "num-complex", + "num-integer", + "num-iter", + "num-rational", + "num-traits", +] + +[[package]] +name = "num-bigint" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" +dependencies = [ + "num-integer", + "num-traits", +] + +[[package]] +name = "num-complex" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-derive" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "num-integer" +version = "0.1.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-iter" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-rational" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" +dependencies = [ + "num-bigint", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", + "libm", +] + +[[package]] +name = "once_cell" +version = "1.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" + +[[package]] +name = "overload" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" + +[[package]] +name = "owo-colors" +version = "4.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1036865bb9422d3300cf723f657c2851d0e9ab12567854b1f4eba3d77decf564" + +[[package]] +name = "parking_lot" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-targets", +] + +[[package]] +name = "petgraph" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4c5cc86750666a3ed20bdaf5ca2a0344f9c67674cae0515bec2da16fbaa47db" +dependencies = [ + "fixedbitset", + "indexmap", +] + +[[package]] +name = "phf_shared" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67eabc2ef2a60eb7faa00097bd1ffdb5bd28e62bf39990626a582201b7a754e5" +dependencies = [ + "siphasher", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "precomputed-hash" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" + +[[package]] +name = "proc-macro2" +version = "1.0.95" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "r-efi" +version = "5.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74765f6d916ee2faa39bc8e68e4f3ed8949b48cccdac59983d287a7cb71ce9c5" + +[[package]] +name = "rand" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fbfd9d094a40bf3ae768db9361049ace4c0e04a4fd6b359518bd7b73a73dd97" +dependencies = [ + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38" + +[[package]] +name = "redox_syscall" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2f103c6d277498fbceb16e84d317e2a400f160f46904d5f5410848c829511a3" +dependencies = [ + "bitflags", +] + +[[package]] +name = "redox_users" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43" +dependencies = [ + "getrandom 0.2.16", + "libredox", + "thiserror 1.0.69", +] + +[[package]] +name = "regex" +version = "1.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata 0.4.9", + "regex-syntax 0.8.5", +] + +[[package]] +name = "regex-automata" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" +dependencies = [ + "regex-syntax 0.6.29", +] + +[[package]] +name = "regex-automata" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax 0.8.5", +] + +[[package]] +name = "regex-syntax" +version = "0.6.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" + +[[package]] +name = "regex-syntax" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" + +[[package]] +name = "rustc_version" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" +dependencies = [ + "semver 0.9.0", +] + +[[package]] +name = "rustc_version" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" +dependencies = [ + "semver 1.0.26", +] + +[[package]] +name = "rustversion" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eded382c5f5f786b989652c49544c4877d9f015cc22e145a5ea8ea66c2921cd2" + +[[package]] +name = "ryu" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" + +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "scoped-tls" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "semver" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" +dependencies = [ + "semver-parser", +] + +[[package]] +name = "semver" +version = "1.0.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56e6fa9c48d24d85fb3de5ad847117517440f6beceb7798af16b4a87d616b8d0" +dependencies = [ + "serde", +] + +[[package]] +name = "semver-parser" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" + +[[package]] +name = "serde" +version = "1.0.219" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.219" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.140" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20068b6e96dc6c9bd23e01df8827e6c7e1f2fddd43c21810382803c136b99373" +dependencies = [ + "itoa", + "memchr", + "ryu", + "serde", +] + +[[package]] +name = "serde_spanned" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87607cb1398ed59d48732e575a4c28a7a8ebf2454b964fe3f224f2afc07909e1" +dependencies = [ + "serde", +] + +[[package]] +name = "sha3" +version = "0.10.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75872d278a8f37ef87fa0ddbda7802605cb18344497949862c0d4dcb291eba60" +dependencies = [ + "digest", + "keccak", +] + +[[package]] +name = "sharded-slab" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" +dependencies = [ + "lazy_static", +] + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "siphasher" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56199f7ddabf13fe5074ce809e7d3f42b42ae711800501b5b16ea82ad029c39d" + +[[package]] +name = "smallvec" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8917285742e9f3e1683f0a9c4e6b57960b7314d0b08d30d1ecd426713ee2eee9" + +[[package]] +name = "smawk" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7c388c1b5e93756d0c740965c41e8822f866621d41acbdf6336a6a168f8840c" + +[[package]] +name = "spin" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" + +[[package]] +name = "string_cache" +version = "0.8.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf776ba3fa74f83bf4b63c3dcbbf82173db2632ed8452cb2d891d33f459de70f" +dependencies = [ + "new_debug_unreachable", + "parking_lot", + "phf_shared", + "precomputed-hash", +] + +[[package]] +name = "strip-ansi-escapes" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a8f8038e7e7969abb3f1b7c2a811225e9296da208539e0f79c5251d6cac0025" +dependencies = [ + "vte", +] + +[[package]] +name = "syn" +version = "2.0.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b09a44accad81e1ba1cd74a32461ba89dee89095ba17b32f5d03683b1b1fc2a0" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "target-triple" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ac9aa371f599d22256307c24a9d748c041e548cbf599f35d890f9d365361790" + +[[package]] +name = "term" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c59df8ac95d96ff9bede18eb7300b0fda5e5d8d90960e76f8e14ae765eedbf1f" +dependencies = [ + "dirs-next", + "rustversion", + "winapi", +] + +[[package]] +name = "termcolor" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "textwrap" +version = "0.16.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c13547615a44dc9c452a8a534638acdf07120d4b6847c8178705da06306a3057" +dependencies = [ + "smawk", + "unicode-linebreak", + "unicode-width 0.2.0", +] + +[[package]] +name = "thiserror" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" +dependencies = [ + "thiserror-impl 1.0.69", +] + +[[package]] +name = "thiserror" +version = "2.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "567b8a2dae586314f7be2a752ec7474332959c6460e02bde30d702a66d488708" +dependencies = [ + "thiserror-impl 2.0.12", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "thiserror-impl" +version = "2.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f7cf42b4507d8ea322120659672cf1b9dbb93f8f2d4ecfd6e51350ff5b17a1d" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "thread_local" +version = "1.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b9ef9bad013ada3808854ceac7b46812a6465ba368859a37e2100283d2d719c" +dependencies = [ + "cfg-if", + "once_cell", +] + +[[package]] +name = "tiny-keccak" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237" +dependencies = [ + "crunchy", +] + +[[package]] +name = "toml" +version = "0.8.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd87a5cdd6ffab733b2f74bc4fd7ee5fff6634124999ac278c35fc78c6120148" +dependencies = [ + "indexmap", + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit", +] + +[[package]] +name = "toml_datetime" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" +dependencies = [ + "serde", +] + +[[package]] +name = "toml_edit" +version = "0.22.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17b4795ff5edd201c7cd6dca065ae59972ce77d1b80fa0a84d94950ece7d1474" +dependencies = [ + "indexmap", + "serde", + "serde_spanned", + "toml_datetime", + "winnow", +] + +[[package]] +name = "tracing" +version = "0.1.41" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0" +dependencies = [ + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "395ae124c09f9e6918a2310af6038fba074bcf474ac352496d5910dd59a2226d" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tracing-core" +version = "0.1.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e672c95779cf947c5311f83787af4fa8fffd12fb27e4993211a84bdfd9610f9c" +dependencies = [ + "once_cell", + "valuable", +] + +[[package]] +name = "tracing-log" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" +dependencies = [ + "log", + "once_cell", + "tracing-core", +] + +[[package]] +name = "tracing-subscriber" +version = "0.3.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8189decb5ac0fa7bc8b96b7cb9b2701d60d48805aca84a238004d665fcc4008" +dependencies = [ + "matchers", + "nu-ansi-term", + "once_cell", + "regex", + "sharded-slab", + "smallvec", + "thread_local", + "tracing", + "tracing-core", + "tracing-log", +] + +[[package]] +name = "trybuild" +version = "1.0.104" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ae08be68c056db96f0e6c6dd820727cca756ced9e1f4cc7fdd20e2a55e23898" +dependencies = [ + "dissimilar", + "glob", + "serde", + "serde_derive", + "serde_json", + "target-triple", + "termcolor", + "toml", +] + +[[package]] +name = "typenum" +version = "1.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1dccffe3ce07af9386bfd29e80c0ab1a8205a2fc34e4bcd40364df902cfa8f3f" + +[[package]] +name = "unicode-ident" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" + +[[package]] +name = "unicode-linebreak" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b09c83c3c29d37506a3e260c08c03743a6bb66a9cd432c6934ab501a190571f" + +[[package]] +name = "unicode-width" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" + +[[package]] +name = "unicode-width" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fc81956842c57dac11422a97c3b8195a1ff727f06e85c84ed2e8aa277c9a0fd" + +[[package]] +name = "unicode-xid" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" + +[[package]] +name = "valuable" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65" + +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "vte" +version = "0.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "231fdcd7ef3037e8330d8e17e61011a2c244126acc0a982f4040ac3f9f0bc077" +dependencies = [ + "memchr", +] + +[[package]] +name = "walkdir" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" +dependencies = [ + "same-file", + "winapi-util", +] + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "wasi" +version = "0.14.2+wasi-0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9683f9a5a998d873c0d21fcbe3c083009670149a8fab228644b8bd36b2c48cb3" +dependencies = [ + "wit-bindgen-rt 0.39.0", +] + +[[package]] +name = "wasm-bindgen" +version = "0.2.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1edc8929d7499fc4e8f0be2262a241556cfc54a0bea223790e71446f2aab1ef5" +dependencies = [ + "cfg-if", + "once_cell", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f0a0651a5c2bc21487bde11ee802ccaf4c51935d0d3d42a6101f98161700bc6" +dependencies = [ + "bumpalo", + "log", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fe63fc6d09ed3792bd0897b314f53de8e16568c2b3f7982f468c0bf9bd0b407" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a05d73b933a847d6cccdda8f838a22ff101ad9bf93e33684f39c1f5f0eece3d" +dependencies = [ + "unicode-ident", +] + +[[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-util" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" +dependencies = [ + "windows-sys", +] + +[[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.58.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd04d41d93c4992d421894c18c8b43496aa748dd4c081bac0dc93eb0489272b6" +dependencies = [ + "windows-core", + "windows-targets", +] + +[[package]] +name = "windows-core" +version = "0.58.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ba6d44ec8c2591c134257ce647b7ea6b20335bf6379a27dac5f1641fcf59f99" +dependencies = [ + "windows-implement", + "windows-interface", + "windows-result", + "windows-strings", + "windows-targets", +] + +[[package]] +name = "windows-implement" +version = "0.58.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bbd5b46c938e506ecbce286b6628a02171d56153ba733b6c741fc627ec9579b" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "windows-interface" +version = "0.58.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "053c4c462dc91d3b1504c6fe5a726dd15e216ba718e84a0e46a88fbe5ded3515" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "windows-result" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d1043d8214f791817bab27572aaa8af63732e11bf84aa21a45a78d6c317ae0e" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-strings" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cd9b125c486025df0eabcb585e62173c6c9eddcec5d117d3b6e8c30e2ee4d10" +dependencies = [ + "windows-result", + "windows-targets", +] + +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "winnow" +version = "0.7.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6cb8234a863ea0e8cd7284fcdd4f145233eb00fee02bbdd9861aec44e6477bc5" +dependencies = [ + "memchr", +] + +[[package]] +name = "winter-air" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d7fbdcaa53d220b84811199790c1dda77c025533cdd27715cf1625af2b4027a" +dependencies = [ + "libm", + "winter-crypto", + "winter-fri", + "winter-math", + "winter-utils", +] + +[[package]] +name = "winter-crypto" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32247cde9f43e5bbd05362caa7274608790ea69b14f7c81cd509aae7127c5ff2" +dependencies = [ + "blake3", + "sha3", + "winter-math", + "winter-utils", +] + +[[package]] +name = "winter-fri" +version = "0.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32b346b0eea2292986a1193bfc70dd2dbcdbb6adb3e5110b71d18c6f1077df10" +dependencies = [ + "winter-crypto", + "winter-math", + "winter-utils", +] + +[[package]] +name = "winter-math" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "326dfe4bfa4072b7c909133a88f8807820d3e49e5dfd246f67981771f74a0ed3" +dependencies = [ + "winter-utils", +] + +[[package]] +name = "winter-maybe-async" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eaa132be74e602b707f1dab5a69c38496445e54ee940e7c281c02b15007241bd" +dependencies = [ + "quote", + "syn", +] + +[[package]] +name = "winter-prover" +version = "0.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "426be0767a25150af20a241a6ae46bad1bf2f7da86393d897e5ec9967124f760" +dependencies = [ + "tracing", + "winter-air", + "winter-crypto", + "winter-fri", + "winter-math", + "winter-maybe-async", + "winter-utils", +] + +[[package]] +name = "winter-utils" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d47518e6931955dcac73a584cacb04550b82ab2f45c72880cbbbdbe13adb63c" + +[[package]] +name = "winter-verifier" +version = "0.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e340716f24960b7ff3713029149fe5e52f9c0dae152101528ec5847d92d73e4" +dependencies = [ + "winter-air", + "winter-crypto", + "winter-fri", + "winter-math", + "winter-utils", +] + +[[package]] +name = "wit-bindgen-rt" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7a37bd9274cb2d4754b915d624447ec0dce9105d174361841c0826efc79ceb9" + +[[package]] +name = "wit-bindgen-rt" +version = "0.39.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1" +dependencies = [ + "bitflags", +] diff --git a/examples/counter-contract/Cargo.toml b/examples/counter-contract/Cargo.toml new file mode 100644 index 000000000..e5d68ed93 --- /dev/null +++ b/examples/counter-contract/Cargo.toml @@ -0,0 +1,45 @@ +[package] +name = "counter-contract" +description = "A simple example of a Miden counter contract using the Account Storage API" +version = "0.1.0" +edition = "2021" + +[lib] +# Build this crate as a self-contained, C-style dynamic library +# This is required to emit the proper Wasm module type +crate-type = ["cdylib"] + +[dependencies] +miden = { path = "../../sdk/sdk" } +wit-bindgen-rt = "0.28" + +[package.metadata.component] +package = "miden:counter-contract" + +[package.metadata.miden] +supported-types = ["RegularAccountUpdatableCode"] + +[package.metadata.component.target.dependencies] +"miden:base" = { path = "../../tests/rust-apps-wasm/rust-sdk/wit-sdk/miden.wit" } +"miden:core-import" = { path = "../../tests/rust-apps-wasm/rust-sdk/wit-sdk/miden-core-import.wit" } + + +[profile.release] +# optimize the output for size +opt-level = "z" +# Explicitly disable panic infrastructure on Wasm, as +# there is no proper support for them anyway, and it +# ensures that panics do not pull in a bunch of standard +# library code unintentionally +panic = "abort" + +[profile.dev] +# Explicitly disable panic infrastructure on Wasm, as +# there is no proper support for them anyway, and it +# ensures that panics do not pull in a bunch of standard +# library code unintentionally +panic = "abort" +opt-level = 1 +debug-assertions = true +overflow-checks = false +debug = true diff --git a/examples/counter-contract/src/lib.rs b/examples/counter-contract/src/lib.rs new file mode 100644 index 000000000..48c503b35 --- /dev/null +++ b/examples/counter-contract/src/lib.rs @@ -0,0 +1,61 @@ +// Do not link against libstd (i.e. anything defined in `std::`) +#![no_std] + +// However, we could still use some standard library types while +// remaining no-std compatible, if we uncommented the following lines: +// +extern crate alloc; + +// Global allocator to use heap memory in no-std environment +#[global_allocator] +static ALLOC: miden::BumpAlloc = miden::BumpAlloc::new(); + +// Define a panic handler as required by the `no_std` environment +#[cfg(not(test))] +#[panic_handler] +fn panic(_info: &core::panic::PanicInfo) -> ! { + // For now, just loop indefinitely + loop {} +} + +mod bindings; + +use bindings::exports::miden::counter_contract::counter::Guest; +use miden::{component, felt, Felt, StorageMap, StorageMapAccess, Word}; + +// Define the main contract struct +#[component] +struct CounterContract { + // Define the storage field for the counter value + #[storage(slot(0), description = "counter contract storage map")] + count_map: StorageMap, +} + +bindings::export!(CounterContract with_types_in bindings); + +impl Guest for CounterContract { + // Function to retrieve the current counter value + fn get_count() -> Felt { + // Get the instance of the contract + let contract = CounterContract::default(); + // Define a fixed key for the counter value within the map + let key = Word::from([felt!(0); 4]); + // Read the value associated with the key from the storage map + contract.count_map.get(&key) + } + + // Function to increment the counter value + fn increment_count() -> Felt { + // Get the instance of the contract + let contract = CounterContract::default(); + // Define the same fixed key + let key = Word::from([felt!(0); 4]); + // Read the current value + let current_value: Felt = contract.count_map.get(&key); + // Increment the value by one + let new_value = current_value + felt!(1); + // Write the new value back to the storage map + contract.count_map.set(key, new_value); + new_value + } +} diff --git a/examples/counter-contract/wit/counter.wit b/examples/counter-contract/wit/counter.wit new file mode 100644 index 000000000..0cdc4ec0f --- /dev/null +++ b/examples/counter-contract/wit/counter.wit @@ -0,0 +1,16 @@ +package miden:counter-contract@0.1.0; + +use miden:base/core-types@1.0.0; + +interface counter { + use core-types.{felt}; + + get-count: func() -> felt; + increment-count: func() -> felt; +} + +world counter-world { + include miden:core-import/all@1.0.0; + + export counter; +} diff --git a/tests/integration/expected/examples/counter.hir b/tests/integration/expected/examples/counter.hir new file mode 100644 index 000000000..5da298a7d --- /dev/null +++ b/tests/integration/expected/examples/counter.hir @@ -0,0 +1,804 @@ +builtin.component miden:counter-contract/counter@0.1.0 { + builtin.module public @counter_contract { + private builtin.function @miden_base_sys::bindings::storage::extern_get_storage_map_item(v0: felt, v1: felt, v2: felt, v3: felt, v4: felt, v5: i32) { + ^block5(v0: felt, v1: felt, v2: felt, v3: felt, v4: felt, v5: i32): + v6, v7, v8, v9 = hir.exec @miden/account/get_map_item(v0, v1, v2, v3, v4) : felt, felt, felt, felt + v10 = hir.bitcast v5 : u32; + v11 = hir.int_to_ptr v10 : ptr; + hir.store v11, v6; + v12 = arith.constant 4 : u32; + v13 = arith.add v10, v12 : u32 #[overflow = checked]; + v14 = hir.int_to_ptr v13 : ptr; + hir.store v14, v7; + v15 = arith.constant 8 : u32; + v16 = arith.add v10, v15 : u32 #[overflow = checked]; + v17 = hir.int_to_ptr v16 : ptr; + hir.store v17, v8; + v18 = arith.constant 12 : u32; + v19 = arith.add v10, v18 : u32 #[overflow = checked]; + v20 = hir.int_to_ptr v19 : ptr; + hir.store v20, v9; + builtin.ret ; + }; + + private builtin.function @miden_base_sys::bindings::storage::extern_set_storage_map_item(v21: felt, v22: felt, v23: felt, v24: felt, v25: felt, v26: felt, v27: felt, v28: felt, v29: felt, v30: i32) { + ^block9(v21: felt, v22: felt, v23: felt, v24: felt, v25: felt, v26: felt, v27: felt, v28: felt, v29: felt, v30: i32): + v31, v32, v33, v34, v35, v36, v37, v38 = hir.exec @miden/account/set_map_item(v21, v22, v23, v24, v25, v26, v27, v28, v29) : felt, felt, felt, felt, felt, felt, felt, felt + v39 = hir.bitcast v30 : u32; + v40 = hir.int_to_ptr v39 : ptr; + hir.store v40, v31; + v41 = arith.constant 4 : u32; + v42 = arith.add v39, v41 : u32 #[overflow = checked]; + v43 = hir.int_to_ptr v42 : ptr; + hir.store v43, v32; + v44 = arith.constant 8 : u32; + v45 = arith.add v39, v44 : u32 #[overflow = checked]; + v46 = hir.int_to_ptr v45 : ptr; + hir.store v46, v33; + v47 = arith.constant 12 : u32; + v48 = arith.add v39, v47 : u32 #[overflow = checked]; + v49 = hir.int_to_ptr v48 : ptr; + hir.store v49, v34; + v50 = arith.constant 16 : u32; + v51 = arith.add v39, v50 : u32 #[overflow = checked]; + v52 = hir.int_to_ptr v51 : ptr; + hir.store v52, v35; + v53 = arith.constant 20 : u32; + v54 = arith.add v39, v53 : u32 #[overflow = checked]; + v55 = hir.int_to_ptr v54 : ptr; + hir.store v55, v36; + v56 = arith.constant 24 : u32; + v57 = arith.add v39, v56 : u32 #[overflow = checked]; + v58 = hir.int_to_ptr v57 : ptr; + hir.store v58, v37; + v59 = arith.constant 28 : u32; + v60 = arith.add v39, v59 : u32 #[overflow = checked]; + v61 = hir.int_to_ptr v60 : ptr; + hir.store v61, v38; + builtin.ret ; + }; + + private builtin.function @__wasm_call_ctors() { + ^block12: + builtin.ret ; + }; + + private builtin.function @counter_contract::bindings::__link_custom_section_describing_imports() { + ^block14: + builtin.ret ; + }; + + private builtin.function @__rustc::__rust_alloc(v62: i32, v63: i32) -> i32 { + ^block16(v62: i32, v63: i32): + v65 = arith.constant 1048612 : i32; + v66 = hir.exec @miden:counter-contract/counter@0.1.0/counter_contract/::alloc(v65, v63, v62) : i32 + builtin.ret v66; + }; + + private builtin.function @__rustc::__rust_realloc(v67: i32, v68: i32, v69: i32, v70: i32) -> i32 { + ^block18(v67: i32, v68: i32, v69: i32, v70: i32): + v72 = arith.constant 1048612 : i32; + v73 = hir.exec @miden:counter-contract/counter@0.1.0/counter_contract/::alloc(v72, v69, v70) : i32 + v581 = arith.constant 0 : i32; + v74 = arith.constant 0 : i32; + v75 = arith.eq v73, v74 : i1; + v76 = arith.zext v75 : u32; + v77 = hir.bitcast v76 : i32; + v79 = arith.neq v77, v581 : i1; + v576 = scf.if v79 : i32 { + ^block20: + scf.yield v73; + } else { + ^block21: + v580 = arith.constant 0 : i32; + v81 = hir.bitcast v68 : u32; + v80 = hir.bitcast v70 : u32; + v82 = arith.lt v80, v81 : i1; + v83 = arith.zext v82 : u32; + v84 = hir.bitcast v83 : i32; + v86 = arith.neq v84, v580 : i1; + v87 = cf.select v86, v70, v68 : i32; + v578 = arith.constant 0 : i32; + v579 = arith.constant 0 : i32; + v89 = arith.eq v87, v579 : i1; + v90 = arith.zext v89 : u32; + v91 = hir.bitcast v90 : i32; + v93 = arith.neq v91, v578 : i1; + v577 = scf.if v93 : i32 { + ^block72: + scf.yield v73; + } else { + ^block22: + v94 = hir.bitcast v87 : u32; + v95 = hir.bitcast v73 : u32; + v96 = hir.int_to_ptr v95 : ptr; + v97 = hir.bitcast v67 : u32; + v98 = hir.int_to_ptr v97 : ptr; + hir.mem_cpy v98, v96, v94; + scf.yield v73; + }; + scf.yield v577; + }; + builtin.ret v576; + }; + + public builtin.function @miden:counter-contract/counter@0.1.0#get-count() -> felt { + ^block23: + v103 = builtin.global_symbol @miden:counter-contract/counter@0.1.0/counter_contract/__stack_pointer : ptr + v104 = hir.bitcast v103 : ptr; + v105 = hir.load v104 : i32; + v108 = arith.constant -32 : i32; + v106 = arith.constant 64 : i32; + v107 = arith.sub v105, v106 : i32 #[overflow = wrapping]; + v109 = arith.band v107, v108 : i32; + v110 = builtin.global_symbol @miden:counter-contract/counter@0.1.0/counter_contract/__stack_pointer : ptr + v111 = hir.bitcast v110 : ptr; + hir.store v111, v109; + hir.exec @miden:counter-contract/counter@0.1.0/counter_contract/wit_bindgen_rt::run_ctors_once() + v592 = ub.poison i32 : i32; + v582 = arith.constant 0 : felt; + v101 = arith.constant 0 : i32; + v608, v609, v610, v611, v612, v613 = scf.while v101, v109, v582, v105, v592, v592 : i32, i32, felt, i32, i32, i32 { + ^block26(v115: i32, v122: i32, v126: felt, v167: i32, v599: i32, v601: i32): + v643 = arith.constant 0 : i32; + v116 = arith.constant 16 : i32; + v117 = arith.eq v115, v116 : i1; + v118 = arith.zext v117 : u32; + v119 = hir.bitcast v118 : i32; + v121 = arith.neq v119, v643 : i1; + v627, v628, v629, v630, v631, v632 = scf.if v121 : i32, i32, felt, i32, u32, u32 { + ^block81: + v584 = arith.constant 0 : u32; + v591 = arith.constant 1 : u32; + v642 = ub.poison i32 : i32; + v593 = ub.poison felt : felt; + scf.yield v642, v642, v593, v642, v591, v584; + } else { + ^block28: + v157 = arith.constant 32 : i32; + v124 = arith.add v122, v157 : i32 #[overflow = wrapping]; + v125 = arith.add v124, v115 : i32 #[overflow = wrapping]; + v127 = hir.bitcast v125 : u32; + v136 = arith.constant 4 : u32; + v129 = arith.mod v127, v136 : u32; + hir.assertz v129 #[code = 250]; + v130 = hir.int_to_ptr v127 : ptr; + hir.store v130, v126; + v640 = arith.constant 1 : u32; + v641 = arith.constant 0 : u32; + v131 = arith.constant 4 : i32; + v132 = arith.add v115, v131 : i32 #[overflow = wrapping]; + scf.yield v132, v122, v126, v167, v641, v640; + }; + v626 = arith.trunc v632 : i1; + scf.condition v626, v627, v628, v629, v630, v122, v167; + } do { + ^block80(v620: i32, v621: i32, v622: felt, v623: i32, v624: i32, v625: i32): + scf.yield v620, v621, v622, v623, v624, v625; + }; + v134 = arith.constant 40 : u32; + v133 = hir.bitcast v612 : u32; + v135 = arith.add v133, v134 : u32 #[overflow = checked]; + v639 = arith.constant 4 : u32; + v137 = arith.mod v135, v639 : u32; + hir.assertz v137 #[code = 250]; + v138 = hir.int_to_ptr v135 : ptr; + v139 = hir.load v138 : i64; + v141 = arith.constant 8 : u32; + v140 = hir.bitcast v612 : u32; + v142 = arith.add v140, v141 : u32 #[overflow = checked]; + v638 = arith.constant 8 : u32; + v144 = arith.mod v142, v638 : u32; + hir.assertz v144 #[code = 250]; + v145 = hir.int_to_ptr v142 : ptr; + hir.store v145, v139; + v147 = arith.constant 32 : u32; + v146 = hir.bitcast v612 : u32; + v148 = arith.add v146, v147 : u32 #[overflow = checked]; + v637 = arith.constant 4 : u32; + v150 = arith.mod v148, v637 : u32; + hir.assertz v150 #[code = 250]; + v151 = hir.int_to_ptr v148 : ptr; + v152 = hir.load v151 : i64; + v153 = hir.bitcast v612 : u32; + v636 = arith.constant 8 : u32; + v155 = arith.mod v153, v636 : u32; + hir.assertz v155 #[code = 250]; + v156 = hir.int_to_ptr v153 : ptr; + hir.store v156, v152; + v634 = arith.constant 0 : i32; + v635 = arith.constant 32 : i32; + v158 = arith.add v612, v635 : i32 #[overflow = wrapping]; + hir.exec @miden:counter-contract/counter@0.1.0/counter_contract/miden_base_sys::bindings::storage::get_map_item(v158, v634, v612) + v161 = arith.constant 44 : u32; + v160 = hir.bitcast v612 : u32; + v162 = arith.add v160, v161 : u32 #[overflow = checked]; + v633 = arith.constant 4 : u32; + v164 = arith.mod v162, v633 : u32; + hir.assertz v164 #[code = 250]; + v165 = hir.int_to_ptr v162 : ptr; + v166 = hir.load v165 : felt; + v168 = builtin.global_symbol @miden:counter-contract/counter@0.1.0/counter_contract/__stack_pointer : ptr + v169 = hir.bitcast v168 : ptr; + hir.store v169, v613; + builtin.ret v166; + }; + + public builtin.function @miden:counter-contract/counter@0.1.0#increment-count() -> felt { + ^block29: + v173 = builtin.global_symbol @miden:counter-contract/counter@0.1.0/counter_contract/__stack_pointer : ptr + v174 = hir.bitcast v173 : ptr; + v175 = hir.load v174 : i32; + v178 = arith.constant -32 : i32; + v176 = arith.constant 160 : i32; + v177 = arith.sub v175, v176 : i32 #[overflow = wrapping]; + v179 = arith.band v177, v178 : i32; + v180 = builtin.global_symbol @miden:counter-contract/counter@0.1.0/counter_contract/__stack_pointer : ptr + v181 = hir.bitcast v180 : ptr; + hir.store v181, v179; + hir.exec @miden:counter-contract/counter@0.1.0/counter_contract/wit_bindgen_rt::run_ctors_once() + v655 = ub.poison i32 : i32; + v645 = arith.constant 0 : felt; + v171 = arith.constant 0 : i32; + v671, v672, v673, v674, v675, v676 = scf.while v171, v179, v645, v175, v655, v655 : i32, i32, felt, i32, i32, i32 { + ^block32(v185: i32, v192: i32, v196: felt, v299: i32, v662: i32, v664: i32): + v718 = arith.constant 0 : i32; + v186 = arith.constant 16 : i32; + v187 = arith.eq v185, v186 : i1; + v188 = arith.zext v187 : u32; + v189 = hir.bitcast v188 : i32; + v191 = arith.neq v189, v718 : i1; + v690, v691, v692, v693, v694, v695 = scf.if v191 : i32, i32, felt, i32, u32, u32 { + ^block88: + v647 = arith.constant 0 : u32; + v654 = arith.constant 1 : u32; + v717 = ub.poison i32 : i32; + v656 = ub.poison felt : felt; + scf.yield v717, v717, v656, v717, v654, v647; + } else { + ^block34: + v227 = arith.constant 32 : i32; + v194 = arith.add v192, v227 : i32 #[overflow = wrapping]; + v195 = arith.add v194, v185 : i32 #[overflow = wrapping]; + v197 = hir.bitcast v195 : u32; + v206 = arith.constant 4 : u32; + v199 = arith.mod v197, v206 : u32; + hir.assertz v199 #[code = 250]; + v200 = hir.int_to_ptr v197 : ptr; + hir.store v200, v196; + v715 = arith.constant 1 : u32; + v716 = arith.constant 0 : u32; + v201 = arith.constant 4 : i32; + v202 = arith.add v185, v201 : i32 #[overflow = wrapping]; + scf.yield v202, v192, v196, v299, v716, v715; + }; + v689 = arith.trunc v695 : i1; + scf.condition v689, v690, v691, v692, v693, v192, v299; + } do { + ^block87(v683: i32, v684: i32, v685: felt, v686: i32, v687: i32, v688: i32): + scf.yield v683, v684, v685, v686, v687, v688; + }; + v204 = arith.constant 40 : u32; + v203 = hir.bitcast v675 : u32; + v205 = arith.add v203, v204 : u32 #[overflow = checked]; + v714 = arith.constant 4 : u32; + v207 = arith.mod v205, v714 : u32; + hir.assertz v207 #[code = 250]; + v208 = hir.int_to_ptr v205 : ptr; + v209 = hir.load v208 : i64; + v211 = arith.constant 8 : u32; + v210 = hir.bitcast v675 : u32; + v212 = arith.add v210, v211 : u32 #[overflow = checked]; + v713 = arith.constant 8 : u32; + v214 = arith.mod v212, v713 : u32; + hir.assertz v214 #[code = 250]; + v215 = hir.int_to_ptr v212 : ptr; + hir.store v215, v209; + v217 = arith.constant 32 : u32; + v216 = hir.bitcast v675 : u32; + v218 = arith.add v216, v217 : u32 #[overflow = checked]; + v712 = arith.constant 4 : u32; + v220 = arith.mod v218, v712 : u32; + hir.assertz v220 #[code = 250]; + v221 = hir.int_to_ptr v218 : ptr; + v222 = hir.load v221 : i64; + v223 = hir.bitcast v675 : u32; + v711 = arith.constant 8 : u32; + v225 = arith.mod v223, v711 : u32; + hir.assertz v225 #[code = 250]; + v226 = hir.int_to_ptr v223 : ptr; + hir.store v226, v222; + v709 = arith.constant 0 : i32; + v710 = arith.constant 32 : i32; + v228 = arith.add v675, v710 : i32 #[overflow = wrapping]; + hir.exec @miden:counter-contract/counter@0.1.0/counter_contract/miden_base_sys::bindings::storage::get_map_item(v228, v709, v675) + v231 = arith.constant 44 : u32; + v230 = hir.bitcast v675 : u32; + v232 = arith.add v230, v231 : u32 #[overflow = checked]; + v708 = arith.constant 4 : u32; + v234 = arith.mod v232, v708 : u32; + hir.assertz v234 #[code = 250]; + v235 = hir.int_to_ptr v232 : ptr; + v236 = hir.load v235 : felt; + v644 = arith.constant 1 : felt; + v239 = arith.add v236, v644 : felt #[overflow = unchecked]; + v241 = arith.constant 24 : u32; + v240 = hir.bitcast v675 : u32; + v242 = arith.add v240, v241 : u32 #[overflow = checked]; + v707 = arith.constant 8 : u32; + v244 = arith.mod v242, v707 : u32; + hir.assertz v244 #[code = 250]; + v245 = hir.int_to_ptr v242 : ptr; + v246 = hir.load v245 : i64; + v248 = arith.constant 120 : u32; + v247 = hir.bitcast v675 : u32; + v249 = arith.add v247, v248 : u32 #[overflow = checked]; + v706 = arith.constant 8 : u32; + v251 = arith.mod v249, v706 : u32; + hir.assertz v251 #[code = 250]; + v252 = hir.int_to_ptr v249 : ptr; + hir.store v252, v246; + v254 = arith.constant 16 : u32; + v253 = hir.bitcast v675 : u32; + v255 = arith.add v253, v254 : u32 #[overflow = checked]; + v705 = arith.constant 8 : u32; + v257 = arith.mod v255, v705 : u32; + hir.assertz v257 #[code = 250]; + v258 = hir.int_to_ptr v255 : ptr; + v259 = hir.load v258 : i64; + v261 = arith.constant 112 : u32; + v260 = hir.bitcast v675 : u32; + v262 = arith.add v260, v261 : u32 #[overflow = checked]; + v704 = arith.constant 8 : u32; + v264 = arith.mod v262, v704 : u32; + hir.assertz v264 #[code = 250]; + v265 = hir.int_to_ptr v262 : ptr; + hir.store v265, v259; + v703 = arith.constant 8 : u32; + v266 = hir.bitcast v675 : u32; + v268 = arith.add v266, v703 : u32 #[overflow = checked]; + v702 = arith.constant 8 : u32; + v270 = arith.mod v268, v702 : u32; + hir.assertz v270 #[code = 250]; + v271 = hir.int_to_ptr v268 : ptr; + v272 = hir.load v271 : i64; + v274 = arith.constant 104 : u32; + v273 = hir.bitcast v675 : u32; + v275 = arith.add v273, v274 : u32 #[overflow = checked]; + v701 = arith.constant 8 : u32; + v277 = arith.mod v275, v701 : u32; + hir.assertz v277 #[code = 250]; + v278 = hir.int_to_ptr v275 : ptr; + hir.store v278, v272; + v279 = hir.bitcast v675 : u32; + v700 = arith.constant 8 : u32; + v281 = arith.mod v279, v700 : u32; + hir.assertz v281 #[code = 250]; + v282 = hir.int_to_ptr v279 : ptr; + v283 = hir.load v282 : i64; + v285 = arith.constant 96 : u32; + v284 = hir.bitcast v675 : u32; + v286 = arith.add v284, v285 : u32 #[overflow = checked]; + v699 = arith.constant 8 : u32; + v288 = arith.mod v286, v699 : u32; + hir.assertz v288 #[code = 250]; + v289 = hir.int_to_ptr v286 : ptr; + hir.store v289, v283; + v290 = arith.constant 128 : i32; + v291 = arith.add v675, v290 : i32 #[overflow = wrapping]; + hir.exec @miden:counter-contract/counter@0.1.0/counter_contract/>::from(v291, v239) + v696 = arith.constant 128 : i32; + v298 = arith.add v675, v696 : i32 #[overflow = wrapping]; + v295 = arith.constant 96 : i32; + v296 = arith.add v675, v295 : i32 #[overflow = wrapping]; + v697 = arith.constant 0 : i32; + v698 = arith.constant 32 : i32; + v293 = arith.add v675, v698 : i32 #[overflow = wrapping]; + hir.exec @miden:counter-contract/counter@0.1.0/counter_contract/miden_base_sys::bindings::storage::set_map_item(v293, v697, v296, v298) + v300 = builtin.global_symbol @miden:counter-contract/counter@0.1.0/counter_contract/__stack_pointer : ptr + v301 = hir.bitcast v300 : ptr; + hir.store v301, v676; + builtin.ret v239; + }; + + public builtin.function @cabi_realloc_wit_bindgen_0_28_0(v302: i32, v303: i32, v304: i32, v305: i32) -> i32 { + ^block35(v302: i32, v303: i32, v304: i32, v305: i32): + v307 = hir.exec @miden:counter-contract/counter@0.1.0/counter_contract/wit_bindgen_rt::cabi_realloc(v302, v303, v304, v305) : i32 + builtin.ret v307; + }; + + private builtin.function @wit_bindgen_rt::cabi_realloc(v308: i32, v309: i32, v310: i32, v311: i32) -> i32 { + ^block37(v308: i32, v309: i32, v310: i32, v311: i32): + v313 = arith.constant 0 : i32; + v314 = arith.neq v309, v313 : i1; + v729, v730, v731 = scf.if v314 : i32, i32, u32 { + ^block41: + v329 = hir.exec @miden:counter-contract/counter@0.1.0/counter_contract/__rustc::__rust_realloc(v308, v309, v310, v311) : i32 + v720 = arith.constant 0 : u32; + v724 = ub.poison i32 : i32; + scf.yield v329, v724, v720; + } else { + ^block42: + v754 = arith.constant 0 : i32; + v755 = arith.constant 0 : i32; + v316 = arith.eq v311, v755 : i1; + v317 = arith.zext v316 : u32; + v318 = hir.bitcast v317 : i32; + v320 = arith.neq v318, v754 : i1; + v740, v741, v742 = scf.if v320 : i32, i32, u32 { + ^block89: + v725 = arith.constant 1 : u32; + v753 = ub.poison i32 : i32; + scf.yield v753, v310, v725; + } else { + ^block43: + v328 = hir.exec @miden:counter-contract/counter@0.1.0/counter_contract/__rustc::__rust_alloc(v311, v310) : i32 + v751 = arith.constant 0 : u32; + v752 = ub.poison i32 : i32; + scf.yield v328, v752, v751; + }; + scf.yield v740, v741, v742; + }; + v736, v737 = scf.index_switch v731 : i32, u32 + case 0 { + ^block40: + v749 = arith.constant 0 : i32; + v332 = arith.neq v729, v749 : i1; + v738, v739 = scf.if v332 : i32, u32 { + ^block90: + v748 = arith.constant 0 : u32; + scf.yield v729, v748; + } else { + ^block44: + v746 = arith.constant 1 : u32; + v747 = ub.poison i32 : i32; + scf.yield v747, v746; + }; + scf.yield v738, v739; + } + default { + ^block96: + v750 = arith.constant 0 : u32; + scf.yield v730, v750; + }; + v745 = arith.constant 0 : u32; + v744 = arith.eq v737, v745 : i1; + cf.cond_br v744 ^block91, ^block92; + ^block91: + builtin.ret v736; + ^block92: + ub.unreachable ; + }; + + private builtin.function @wit_bindgen_rt::run_ctors_once() { + ^block45: + v336 = arith.constant 1048617 : u32; + v759 = arith.constant 0 : u32; + v337 = arith.add v759, v336 : u32 #[overflow = checked]; + v338 = hir.int_to_ptr v337 : ptr; + v339 = hir.load v338 : u8; + v334 = arith.constant 0 : i32; + v340 = arith.zext v339 : u32; + v341 = hir.bitcast v340 : i32; + v343 = arith.neq v341, v334 : i1; + scf.if v343{ + ^block47: + scf.yield ; + } else { + ^block48: + hir.exec @miden:counter-contract/counter@0.1.0/counter_contract/__wasm_call_ctors() + v757 = arith.constant 1 : u8; + v761 = arith.constant 1048617 : u32; + v762 = arith.constant 0 : u32; + v350 = arith.add v762, v761 : u32 #[overflow = checked]; + v351 = hir.int_to_ptr v350 : ptr; + hir.store v351, v757; + scf.yield ; + }; + builtin.ret ; + }; + + private builtin.function @::alloc(v352: i32, v353: i32, v354: i32) -> i32 { + ^block49(v352: i32, v353: i32, v354: i32): + v357 = arith.constant 32 : i32; + v356 = arith.constant 0 : i32; + v764 = arith.constant 32 : u32; + v359 = hir.bitcast v353 : u32; + v361 = arith.gt v359, v764 : i1; + v362 = arith.zext v361 : u32; + v363 = hir.bitcast v362 : i32; + v365 = arith.neq v363, v356 : i1; + v366 = cf.select v365, v353, v357 : i32; + v801 = arith.constant 0 : i32; + v367 = arith.constant -1 : i32; + v368 = arith.add v366, v367 : i32 #[overflow = wrapping]; + v369 = arith.band v366, v368 : i32; + v371 = arith.neq v369, v801 : i1; + v773, v774 = scf.if v371 : i32, u32 { + ^block101: + v765 = arith.constant 0 : u32; + v769 = ub.poison i32 : i32; + scf.yield v769, v765; + } else { + ^block52: + v373 = hir.exec @miden:counter-contract/counter@0.1.0/counter_contract/core::ptr::alignment::Alignment::max(v353, v366) : i32 + v800 = arith.constant 0 : i32; + v372 = arith.constant -2147483648 : i32; + v374 = arith.sub v372, v373 : i32 #[overflow = wrapping]; + v376 = hir.bitcast v374 : u32; + v375 = hir.bitcast v354 : u32; + v377 = arith.gt v375, v376 : i1; + v378 = arith.zext v377 : u32; + v379 = hir.bitcast v378 : i32; + v381 = arith.neq v379, v800 : i1; + v777, v778 = scf.if v381 : i32, u32 { + ^block100: + v798 = arith.constant 0 : u32; + v799 = ub.poison i32 : i32; + scf.yield v799, v798; + } else { + ^block53: + v796 = arith.constant 0 : i32; + v387 = arith.sub v796, v373 : i32 #[overflow = wrapping]; + v797 = arith.constant -1 : i32; + v383 = arith.add v354, v373 : i32 #[overflow = wrapping]; + v385 = arith.add v383, v797 : i32 #[overflow = wrapping]; + v388 = arith.band v385, v387 : i32; + v389 = hir.bitcast v352 : u32; + v390 = arith.constant 4 : u32; + v391 = arith.mod v389, v390 : u32; + hir.assertz v391 #[code = 250]; + v392 = hir.int_to_ptr v389 : ptr; + v393 = hir.load v392 : i32; + v795 = arith.constant 0 : i32; + v395 = arith.neq v393, v795 : i1; + v779, v780, v781, v782 = scf.if v395 : i32, i32, i32, i32 { + ^block99: + v794 = arith.constant 0 : i32; + scf.yield v352, v388, v373, v794; + } else { + ^block55: + v396 = hir.exec @intrinsics/mem/heap_base() : i32 + v397 = hir.mem_size : u32; + v403 = hir.bitcast v352 : u32; + v793 = arith.constant 4 : u32; + v405 = arith.mod v403, v793 : u32; + hir.assertz v405 #[code = 250]; + v763 = arith.constant 16 : u32; + v400 = arith.shl v397, v763 : u32; + v401 = hir.bitcast v400 : i32; + v402 = arith.add v396, v401 : i32 #[overflow = wrapping]; + v406 = hir.int_to_ptr v403 : ptr; + hir.store v406, v402; + v792 = arith.constant 0 : i32; + scf.yield v352, v388, v373, v792; + }; + v409 = hir.bitcast v779 : u32; + v791 = arith.constant 4 : u32; + v411 = arith.mod v409, v791 : u32; + hir.assertz v411 #[code = 250]; + v412 = hir.int_to_ptr v409 : ptr; + v413 = hir.load v412 : i32; + v790 = arith.constant 0 : i32; + v417 = hir.bitcast v780 : u32; + v407 = arith.constant 268435456 : i32; + v414 = arith.sub v407, v413 : i32 #[overflow = wrapping]; + v416 = hir.bitcast v414 : u32; + v418 = arith.lt v416, v417 : i1; + v419 = arith.zext v418 : u32; + v420 = hir.bitcast v419 : i32; + v422 = arith.neq v420, v790 : i1; + v783, v784 = scf.if v422 : i32, u32 { + ^block56: + v770 = arith.constant 1 : u32; + scf.yield v782, v770; + } else { + ^block57: + v424 = hir.bitcast v779 : u32; + v789 = arith.constant 4 : u32; + v426 = arith.mod v424, v789 : u32; + hir.assertz v426 #[code = 250]; + v423 = arith.add v413, v780 : i32 #[overflow = wrapping]; + v427 = hir.int_to_ptr v424 : ptr; + hir.store v427, v423; + v788 = arith.constant 1 : u32; + v429 = arith.add v413, v781 : i32 #[overflow = wrapping]; + scf.yield v429, v788; + }; + scf.yield v783, v784; + }; + scf.yield v777, v778; + }; + v787 = arith.constant 0 : u32; + v786 = arith.eq v774, v787 : i1; + cf.cond_br v786 ^block51, ^block103(v773); + ^block51: + ub.unreachable ; + ^block103(v766: i32): + builtin.ret v766; + }; + + private builtin.function @miden_base_sys::bindings::storage::get_map_item(v432: i32, v433: i32, v434: i32) { + ^block58(v432: i32, v433: i32, v434: i32): + v438 = hir.bitcast v434 : u32; + v439 = arith.constant 4 : u32; + v440 = arith.mod v438, v439 : u32; + hir.assertz v440 #[code = 250]; + v441 = hir.int_to_ptr v438 : ptr; + v442 = hir.load v441 : felt; + v805 = arith.constant 4 : u32; + v443 = hir.bitcast v434 : u32; + v445 = arith.add v443, v805 : u32 #[overflow = checked]; + v804 = arith.constant 4 : u32; + v447 = arith.mod v445, v804 : u32; + hir.assertz v447 #[code = 250]; + v448 = hir.int_to_ptr v445 : ptr; + v449 = hir.load v448 : felt; + v451 = arith.constant 8 : u32; + v450 = hir.bitcast v434 : u32; + v452 = arith.add v450, v451 : u32 #[overflow = checked]; + v803 = arith.constant 4 : u32; + v454 = arith.mod v452, v803 : u32; + hir.assertz v454 #[code = 250]; + v455 = hir.int_to_ptr v452 : ptr; + v456 = hir.load v455 : felt; + v458 = arith.constant 12 : u32; + v457 = hir.bitcast v434 : u32; + v459 = arith.add v457, v458 : u32 #[overflow = checked]; + v802 = arith.constant 4 : u32; + v461 = arith.mod v459, v802 : u32; + hir.assertz v461 #[code = 250]; + v462 = hir.int_to_ptr v459 : ptr; + v463 = hir.load v462 : felt; + v435 = arith.constant 255 : i32; + v436 = arith.band v433, v435 : i32; + v437 = hir.bitcast v436 : felt; + hir.exec @miden:counter-contract/counter@0.1.0/counter_contract/miden_base_sys::bindings::storage::extern_get_storage_map_item(v437, v442, v449, v456, v463, v432) + builtin.ret ; + }; + + private builtin.function @miden_base_sys::bindings::storage::set_map_item(v464: i32, v465: i32, v466: i32, v467: i32) { + ^block60(v464: i32, v465: i32, v466: i32, v467: i32): + v471 = hir.bitcast v466 : u32; + v472 = arith.constant 4 : u32; + v473 = arith.mod v471, v472 : u32; + hir.assertz v473 #[code = 250]; + v474 = hir.int_to_ptr v471 : ptr; + v475 = hir.load v474 : felt; + v816 = arith.constant 4 : u32; + v476 = hir.bitcast v466 : u32; + v478 = arith.add v476, v816 : u32 #[overflow = checked]; + v815 = arith.constant 4 : u32; + v480 = arith.mod v478, v815 : u32; + hir.assertz v480 #[code = 250]; + v481 = hir.int_to_ptr v478 : ptr; + v482 = hir.load v481 : felt; + v484 = arith.constant 8 : u32; + v483 = hir.bitcast v466 : u32; + v485 = arith.add v483, v484 : u32 #[overflow = checked]; + v814 = arith.constant 4 : u32; + v487 = arith.mod v485, v814 : u32; + hir.assertz v487 #[code = 250]; + v488 = hir.int_to_ptr v485 : ptr; + v489 = hir.load v488 : felt; + v491 = arith.constant 12 : u32; + v490 = hir.bitcast v466 : u32; + v492 = arith.add v490, v491 : u32 #[overflow = checked]; + v813 = arith.constant 4 : u32; + v494 = arith.mod v492, v813 : u32; + hir.assertz v494 #[code = 250]; + v495 = hir.int_to_ptr v492 : ptr; + v496 = hir.load v495 : felt; + v497 = hir.bitcast v467 : u32; + v812 = arith.constant 4 : u32; + v499 = arith.mod v497, v812 : u32; + hir.assertz v499 #[code = 250]; + v500 = hir.int_to_ptr v497 : ptr; + v501 = hir.load v500 : felt; + v811 = arith.constant 4 : u32; + v502 = hir.bitcast v467 : u32; + v504 = arith.add v502, v811 : u32 #[overflow = checked]; + v810 = arith.constant 4 : u32; + v506 = arith.mod v504, v810 : u32; + hir.assertz v506 #[code = 250]; + v507 = hir.int_to_ptr v504 : ptr; + v508 = hir.load v507 : felt; + v809 = arith.constant 8 : u32; + v509 = hir.bitcast v467 : u32; + v511 = arith.add v509, v809 : u32 #[overflow = checked]; + v808 = arith.constant 4 : u32; + v513 = arith.mod v511, v808 : u32; + hir.assertz v513 #[code = 250]; + v514 = hir.int_to_ptr v511 : ptr; + v515 = hir.load v514 : felt; + v807 = arith.constant 12 : u32; + v516 = hir.bitcast v467 : u32; + v518 = arith.add v516, v807 : u32 #[overflow = checked]; + v806 = arith.constant 4 : u32; + v520 = arith.mod v518, v806 : u32; + hir.assertz v520 #[code = 250]; + v521 = hir.int_to_ptr v518 : ptr; + v522 = hir.load v521 : felt; + v468 = arith.constant 255 : i32; + v469 = arith.band v465, v468 : i32; + v470 = hir.bitcast v469 : felt; + hir.exec @miden:counter-contract/counter@0.1.0/counter_contract/miden_base_sys::bindings::storage::extern_set_storage_map_item(v470, v475, v482, v489, v496, v501, v508, v515, v522, v464) + builtin.ret ; + }; + + private builtin.function @>::from(v523: i32, v524: felt) { + ^block62(v523: i32, v524: felt): + v533 = arith.constant 12 : u32; + v532 = hir.bitcast v523 : u32; + v534 = arith.add v532, v533 : u32 #[overflow = checked]; + v535 = arith.constant 4 : u32; + v536 = arith.mod v534, v535 : u32; + hir.assertz v536 #[code = 250]; + v537 = hir.int_to_ptr v534 : ptr; + hir.store v537, v524; + v539 = arith.constant 8 : u32; + v538 = hir.bitcast v523 : u32; + v540 = arith.add v538, v539 : u32 #[overflow = checked]; + v825 = arith.constant 4 : u32; + v542 = arith.mod v540, v825 : u32; + hir.assertz v542 #[code = 250]; + v819 = arith.constant 0 : felt; + v543 = hir.int_to_ptr v540 : ptr; + hir.store v543, v819; + v824 = arith.constant 4 : u32; + v544 = hir.bitcast v523 : u32; + v546 = arith.add v544, v824 : u32 #[overflow = checked]; + v823 = arith.constant 4 : u32; + v548 = arith.mod v546, v823 : u32; + hir.assertz v548 #[code = 250]; + v822 = arith.constant 0 : felt; + v549 = hir.int_to_ptr v546 : ptr; + hir.store v549, v822; + v550 = hir.bitcast v523 : u32; + v821 = arith.constant 4 : u32; + v552 = arith.mod v550, v821 : u32; + hir.assertz v552 #[code = 250]; + v820 = arith.constant 0 : felt; + v553 = hir.int_to_ptr v550 : ptr; + hir.store v553, v820; + builtin.ret ; + }; + + private builtin.function @core::ptr::alignment::Alignment::max(v554: i32, v555: i32) -> i32 { + ^block64(v554: i32, v555: i32): + v562 = arith.constant 0 : i32; + v558 = hir.bitcast v555 : u32; + v557 = hir.bitcast v554 : u32; + v559 = arith.gt v557, v558 : i1; + v560 = arith.zext v559 : u32; + v561 = hir.bitcast v560 : i32; + v563 = arith.neq v561, v562 : i1; + v564 = cf.select v563, v554, v555 : i32; + builtin.ret v564; + }; + + public builtin.function @cabi_realloc(v565: i32, v566: i32, v567: i32, v568: i32) -> i32 { + ^block66(v565: i32, v566: i32, v567: i32, v568: i32): + v570 = hir.exec @miden:counter-contract/counter@0.1.0/counter_contract/cabi_realloc_wit_bindgen_0_28_0(v565, v566, v567, v568) : i32 + builtin.ret v570; + }; + + builtin.global_variable private @#__stack_pointer : i32 { + builtin.ret_imm 1048576; + }; + + builtin.segment readonly @1048576 = 0x000000020000000100000001000000010000000100000001000000010000000100000001; + }; + + public builtin.function @get-count() -> felt { + ^block68: + v571 = hir.exec @miden:counter-contract/counter@0.1.0/counter_contract/miden:counter-contract/counter@0.1.0#get-count() : felt + builtin.ret v571; + }; + + public builtin.function @increment-count() -> felt { + ^block70: + v572 = hir.exec @miden:counter-contract/counter@0.1.0/counter_contract/miden:counter-contract/counter@0.1.0#increment-count() : felt + builtin.ret v572; + }; +}; \ No newline at end of file diff --git a/tests/integration/expected/examples/counter.masm b/tests/integration/expected/examples/counter.masm new file mode 100644 index 000000000..069b45d76 --- /dev/null +++ b/tests/integration/expected/examples/counter.masm @@ -0,0 +1,1234 @@ +# mod miden:counter-contract/counter@0.1.0 + +export.get-count + exec.::miden:counter-contract/counter@0.1.0::counter_contract::miden:counter-contract/counter@0.1.0#get-count +end + +export.increment-count + exec.::miden:counter-contract/counter@0.1.0::counter_contract::miden:counter-contract/counter@0.1.0#increment-count +end + +export.init + push.2162688 + exec.::intrinsics::mem::heap_init + push.5121323707957172480 + push.16385291266171272914 + push.3612753469884014922 + push.8597705872349702967 + adv.push_mapval + push.262144 + push.3 + exec.::std::mem::pipe_preimage_to_memory + drop + push.1048576 + u32assert + mem_store.262144 +end + +# mod miden:counter-contract/counter@0.1.0::counter_contract + +proc.miden_base_sys::bindings::storage::extern_get_storage_map_item + exec.::miden::account::get_map_item + movup.4 + dup.0 + movup.2 + swap.1 + u32divmod.4 + swap.1 + exec.::intrinsics::mem::store_felt + push.4 + dup.1 + swap.1 + add + u32assert + movup.2 + swap.1 + u32divmod.4 + swap.1 + exec.::intrinsics::mem::store_felt + push.8 + dup.1 + swap.1 + add + u32assert + movup.2 + swap.1 + u32divmod.4 + swap.1 + exec.::intrinsics::mem::store_felt + push.12 + add + u32assert + u32divmod.4 + swap.1 + exec.::intrinsics::mem::store_felt +end + +proc.miden_base_sys::bindings::storage::extern_set_storage_map_item + exec.::miden::account::set_map_item + movup.8 + dup.0 + movup.2 + swap.1 + u32divmod.4 + swap.1 + exec.::intrinsics::mem::store_felt + push.4 + dup.1 + swap.1 + add + u32assert + movup.2 + swap.1 + u32divmod.4 + swap.1 + exec.::intrinsics::mem::store_felt + push.8 + dup.1 + swap.1 + add + u32assert + movup.2 + swap.1 + u32divmod.4 + swap.1 + exec.::intrinsics::mem::store_felt + push.12 + dup.1 + swap.1 + add + u32assert + movup.2 + swap.1 + u32divmod.4 + swap.1 + exec.::intrinsics::mem::store_felt + push.16 + dup.1 + swap.1 + add + u32assert + movup.2 + swap.1 + u32divmod.4 + swap.1 + exec.::intrinsics::mem::store_felt + push.20 + dup.1 + swap.1 + add + u32assert + movup.2 + swap.1 + u32divmod.4 + swap.1 + exec.::intrinsics::mem::store_felt + push.24 + dup.1 + swap.1 + add + u32assert + movup.2 + swap.1 + u32divmod.4 + swap.1 + exec.::intrinsics::mem::store_felt + push.28 + add + u32assert + u32divmod.4 + swap.1 + exec.::intrinsics::mem::store_felt +end + +proc.__wasm_call_ctors + nop +end + +proc.counter_contract::bindings::__link_custom_section_describing_imports + nop +end + +proc.__rustc::__rust_alloc + push.1048612 + movup.2 + swap.1 + exec.::miden:counter-contract/counter@0.1.0::counter_contract::::alloc +end + +proc.__rustc::__rust_realloc + push.1048612 + dup.4 + swap.2 + swap.4 + swap.1 + exec.::miden:counter-contract/counter@0.1.0::counter_contract::::alloc + push.0 + push.0 + dup.2 + swap.1 + eq + neq + if.true + movdn.3 + drop + drop + drop + else + push.0 + dup.2 + dup.5 + swap.1 + u32lt + neq + swap.1 + swap.4 + swap.1 + cdrop + push.0 + push.0 + dup.2 + swap.1 + eq + neq + if.true + drop + drop + else + dup.2 + movup.2 + push.0 + dup.3 + push.0 + gte + while.true + dup.2 + dup.1 + push.1 + u32overflowing_madd + assertz + dup.2 + dup.2 + push.1 + u32overflowing_madd + assertz + u32divmod.4 + swap.1 + exec.::intrinsics::mem::load_sw + push.128 + u32and + swap.1 + u32divmod.4 + swap.1 + dup.2 + dup.2 + dup.2 + exec.::intrinsics::mem::load_sw + push.4294967040 + u32and + movup.5 + u32or + movdn.4 + exec.::intrinsics::mem::store_sw + u32wrapping_add.1 + dup.0 + dup.4 + u32gte + end + dropw + end + end +end + +export.miden:counter-contract/counter@0.1.0#get-count + push.1048576 + u32divmod.4 + swap.1 + exec.::intrinsics::mem::load_sw + push.4294967264 + push.64 + dup.2 + swap.1 + u32wrapping_sub + u32and + push.1048576 + dup.1 + swap.1 + u32divmod.4 + swap.1 + exec.::intrinsics::mem::store_sw + exec.::miden:counter-contract/counter@0.1.0::counter_contract::wit_bindgen_rt::run_ctors_once + push.3735929054 + push.0 + push.0 + dup.2 + swap.5 + swap.3 + swap.4 + swap.1 + push.1 + while.true + movup.4 + drop + movup.4 + drop + push.0 + push.16 + dup.2 + swap.1 + eq + neq + if.true + movup.2 + swap.1 + drop + drop + push.0 + push.1 + push.3735929054 + push.3735929054 + dup.1 + dup.2 + swap.3 + else + push.32 + dup.2 + swap.1 + u32wrapping_add + dup.1 + swap.1 + u32wrapping_add + push.4 + dup.1 + swap.1 + u32mod + u32assert + assertz.err=250 + dup.3 + swap.1 + u32divmod.4 + swap.1 + exec.::intrinsics::mem::store_felt + push.1 + push.0 + push.4 + movup.3 + swap.1 + u32wrapping_add + dup.3 + dup.6 + swap.3 + swap.4 + swap.5 + swap.6 + swap.2 + end + movup.4 + drop + movup.4 + push.1 + u32and + if.true + push.1 + else + push.0 + end + end + drop + drop + drop + drop + push.40 + dup.1 + add + u32assert + push.4 + dup.1 + swap.1 + u32mod + u32assert + assertz.err=250 + u32divmod.4 + swap.1 + exec.::intrinsics::mem::load_dw + push.8 + dup.3 + add + u32assert + push.8 + dup.1 + swap.1 + u32mod + u32assert + assertz.err=250 + u32divmod.4 + swap.1 + exec.::intrinsics::mem::store_dw + push.32 + dup.1 + add + u32assert + push.4 + dup.1 + swap.1 + u32mod + u32assert + assertz.err=250 + u32divmod.4 + swap.1 + exec.::intrinsics::mem::load_dw + dup.2 + push.8 + dup.1 + swap.1 + u32mod + u32assert + assertz.err=250 + u32divmod.4 + swap.1 + exec.::intrinsics::mem::store_dw + push.0 + push.32 + dup.2 + swap.1 + u32wrapping_add + dup.2 + swap.2 + swap.1 + exec.::miden:counter-contract/counter@0.1.0::counter_contract::miden_base_sys::bindings::storage::get_map_item + push.44 + swap.1 + add + u32assert + push.4 + dup.1 + swap.1 + u32mod + u32assert + assertz.err=250 + u32divmod.4 + swap.1 + exec.::intrinsics::mem::load_felt + push.1048576 + movup.2 + swap.1 + u32divmod.4 + swap.1 + exec.::intrinsics::mem::store_sw +end + +export.miden:counter-contract/counter@0.1.0#increment-count + push.1048576 + u32divmod.4 + swap.1 + exec.::intrinsics::mem::load_sw + push.4294967264 + push.160 + dup.2 + swap.1 + u32wrapping_sub + u32and + push.1048576 + dup.1 + swap.1 + u32divmod.4 + swap.1 + exec.::intrinsics::mem::store_sw + exec.::miden:counter-contract/counter@0.1.0::counter_contract::wit_bindgen_rt::run_ctors_once + push.3735929054 + push.0 + push.0 + dup.2 + swap.5 + swap.3 + swap.4 + swap.1 + push.1 + while.true + movup.4 + drop + movup.4 + drop + push.0 + push.16 + dup.2 + swap.1 + eq + neq + if.true + movup.2 + swap.1 + drop + drop + push.0 + push.1 + push.3735929054 + push.3735929054 + dup.1 + dup.2 + swap.3 + else + push.32 + dup.2 + swap.1 + u32wrapping_add + dup.1 + swap.1 + u32wrapping_add + push.4 + dup.1 + swap.1 + u32mod + u32assert + assertz.err=250 + dup.3 + swap.1 + u32divmod.4 + swap.1 + exec.::intrinsics::mem::store_felt + push.1 + push.0 + push.4 + movup.3 + swap.1 + u32wrapping_add + dup.3 + dup.6 + swap.3 + swap.4 + swap.5 + swap.6 + swap.2 + end + movup.4 + drop + movup.4 + push.1 + u32and + if.true + push.1 + else + push.0 + end + end + drop + drop + drop + drop + push.40 + dup.1 + add + u32assert + push.4 + dup.1 + swap.1 + u32mod + u32assert + assertz.err=250 + u32divmod.4 + swap.1 + exec.::intrinsics::mem::load_dw + push.8 + dup.3 + add + u32assert + push.8 + dup.1 + swap.1 + u32mod + u32assert + assertz.err=250 + u32divmod.4 + swap.1 + exec.::intrinsics::mem::store_dw + push.32 + dup.1 + add + u32assert + push.4 + dup.1 + swap.1 + u32mod + u32assert + assertz.err=250 + u32divmod.4 + swap.1 + exec.::intrinsics::mem::load_dw + dup.2 + push.8 + dup.1 + swap.1 + u32mod + u32assert + assertz.err=250 + u32divmod.4 + swap.1 + exec.::intrinsics::mem::store_dw + push.0 + push.32 + dup.2 + swap.1 + u32wrapping_add + dup.2 + swap.2 + swap.1 + exec.::miden:counter-contract/counter@0.1.0::counter_contract::miden_base_sys::bindings::storage::get_map_item + push.44 + dup.1 + add + u32assert + push.4 + dup.1 + swap.1 + u32mod + u32assert + assertz.err=250 + u32divmod.4 + swap.1 + exec.::intrinsics::mem::load_felt + push.1 + add + push.24 + dup.2 + add + u32assert + push.8 + dup.1 + swap.1 + u32mod + u32assert + assertz.err=250 + u32divmod.4 + swap.1 + exec.::intrinsics::mem::load_dw + push.120 + dup.4 + add + u32assert + push.8 + dup.1 + swap.1 + u32mod + u32assert + assertz.err=250 + u32divmod.4 + swap.1 + exec.::intrinsics::mem::store_dw + push.16 + dup.2 + add + u32assert + push.8 + dup.1 + swap.1 + u32mod + u32assert + assertz.err=250 + u32divmod.4 + swap.1 + exec.::intrinsics::mem::load_dw + push.112 + dup.4 + add + u32assert + push.8 + dup.1 + swap.1 + u32mod + u32assert + assertz.err=250 + u32divmod.4 + swap.1 + exec.::intrinsics::mem::store_dw + push.8 + dup.2 + add + u32assert + push.8 + dup.1 + swap.1 + u32mod + u32assert + assertz.err=250 + u32divmod.4 + swap.1 + exec.::intrinsics::mem::load_dw + push.104 + dup.4 + add + u32assert + push.8 + dup.1 + swap.1 + u32mod + u32assert + assertz.err=250 + u32divmod.4 + swap.1 + exec.::intrinsics::mem::store_dw + dup.1 + push.8 + dup.1 + swap.1 + u32mod + u32assert + assertz.err=250 + u32divmod.4 + swap.1 + exec.::intrinsics::mem::load_dw + push.96 + dup.4 + add + u32assert + push.8 + dup.1 + swap.1 + u32mod + u32assert + assertz.err=250 + u32divmod.4 + swap.1 + exec.::intrinsics::mem::store_dw + push.128 + dup.2 + swap.1 + u32wrapping_add + dup.1 + swap.1 + exec.::miden:counter-contract/counter@0.1.0::counter_contract::>::from + push.128 + dup.2 + swap.1 + u32wrapping_add + push.96 + dup.3 + swap.1 + u32wrapping_add + push.0 + push.32 + movup.5 + swap.1 + u32wrapping_add + exec.::miden:counter-contract/counter@0.1.0::counter_contract::miden_base_sys::bindings::storage::set_map_item + push.1048576 + movup.2 + swap.1 + u32divmod.4 + swap.1 + exec.::intrinsics::mem::store_sw +end + +export.cabi_realloc_wit_bindgen_0_28_0 + exec.::miden:counter-contract/counter@0.1.0::counter_contract::wit_bindgen_rt::cabi_realloc +end + +proc.wit_bindgen_rt::cabi_realloc + push.0 + dup.2 + swap.1 + neq + if.true + exec.::miden:counter-contract/counter@0.1.0::counter_contract::__rustc::__rust_realloc + push.0 + push.3735929054 + movup.2 + else + drop + drop + push.0 + push.0 + dup.3 + swap.1 + eq + neq + if.true + swap.1 + drop + push.1 + push.3735929054 + movup.2 + swap.1 + else + swap.1 + exec.::miden:counter-contract/counter@0.1.0::counter_contract::__rustc::__rust_alloc + push.0 + push.3735929054 + movup.2 + end + end + movup.2 + eq.0 + if.true + swap.1 + drop + push.0 + dup.1 + swap.1 + neq + if.true + push.0 + swap.1 + else + drop + push.1 + push.3735929054 + end + else + drop + push.0 + swap.1 + end + push.0 + movup.2 + swap.1 + eq + if.true + nop + else + drop + push.0 + assert + end +end + +proc.wit_bindgen_rt::run_ctors_once + push.1048617 + push.0 + add + u32assert + u32divmod.4 + swap.1 + exec.::intrinsics::mem::load_sw + push.128 + u32and + push.0 + swap.1 + neq + if.true + nop + else + exec.::miden:counter-contract/counter@0.1.0::counter_contract::__wasm_call_ctors + push.1 + push.1048617 + push.0 + add + u32assert + u32divmod.4 + swap.1 + dup.2 + dup.2 + dup.2 + exec.::intrinsics::mem::load_sw + push.4294967040 + u32and + movup.5 + u32or + movdn.4 + exec.::intrinsics::mem::store_sw + end +end + +proc.::alloc + push.32 + push.0 + push.32 + dup.4 + swap.1 + u32gt + neq + dup.3 + swap.1 + cdrop + push.0 + push.4294967295 + dup.2 + swap.1 + u32wrapping_add + dup.2 + swap.1 + u32and + neq + if.true + dropw + push.0 + push.3735929054 + else + movup.2 + exec.::miden:counter-contract/counter@0.1.0::counter_contract::core::ptr::alignment::Alignment::max + push.0 + push.2147483648 + dup.2 + u32wrapping_sub + dup.4 + swap.1 + u32gt + neq + if.true + drop + drop + drop + push.0 + push.3735929054 + else + push.0 + dup.1 + swap.1 + u32wrapping_sub + push.4294967295 + movup.4 + dup.3 + u32wrapping_add + u32wrapping_add + u32and + dup.2 + push.4 + dup.1 + swap.1 + u32mod + u32assert + assertz.err=250 + u32divmod.4 + swap.1 + exec.::intrinsics::mem::load_sw + push.0 + neq + if.true + push.0 + swap.3 + else + exec.::intrinsics::mem::heap_base + exec.::intrinsics::mem::memory_size + dup.4 + push.4 + dup.1 + swap.1 + u32mod + u32assert + assertz.err=250 + push.16 + movup.2 + swap.1 + u32shl + movup.2 + swap.1 + u32wrapping_add + swap.1 + u32divmod.4 + swap.1 + exec.::intrinsics::mem::store_sw + push.0 + swap.3 + end + dup.0 + push.4 + dup.1 + swap.1 + u32mod + u32assert + assertz.err=250 + u32divmod.4 + swap.1 + exec.::intrinsics::mem::load_sw + push.0 + dup.3 + push.268435456 + dup.3 + u32wrapping_sub + swap.1 + u32lt + neq + if.true + dropw + push.1 + swap.1 + else + movup.4 + drop + swap.1 + push.4 + dup.1 + swap.1 + u32mod + u32assert + assertz.err=250 + dup.1 + movup.3 + u32wrapping_add + swap.1 + u32divmod.4 + swap.1 + exec.::intrinsics::mem::store_sw + push.1 + swap.1 + movup.2 + u32wrapping_add + end + end + end + push.0 + movup.2 + swap.1 + eq + if.true + drop + push.0 + assert + else + nop + end +end + +proc.miden_base_sys::bindings::storage::get_map_item + dup.2 + push.4 + dup.1 + swap.1 + u32mod + u32assert + assertz.err=250 + u32divmod.4 + swap.1 + exec.::intrinsics::mem::load_felt + push.4 + dup.4 + add + u32assert + push.4 + dup.1 + swap.1 + u32mod + u32assert + assertz.err=250 + u32divmod.4 + swap.1 + exec.::intrinsics::mem::load_felt + push.8 + dup.5 + add + u32assert + push.4 + dup.1 + swap.1 + u32mod + u32assert + assertz.err=250 + u32divmod.4 + swap.1 + exec.::intrinsics::mem::load_felt + push.12 + movup.6 + add + u32assert + push.4 + dup.1 + swap.1 + u32mod + u32assert + assertz.err=250 + u32divmod.4 + swap.1 + exec.::intrinsics::mem::load_felt + push.255 + movup.6 + swap.1 + u32and + movup.2 + swap.3 + movdn.2 + swap.1 + swap.4 + swap.1 + exec.::miden:counter-contract/counter@0.1.0::counter_contract::miden_base_sys::bindings::storage::extern_get_storage_map_item +end + +proc.miden_base_sys::bindings::storage::set_map_item + dup.2 + push.4 + dup.1 + swap.1 + u32mod + u32assert + assertz.err=250 + u32divmod.4 + swap.1 + exec.::intrinsics::mem::load_felt + push.4 + dup.4 + add + u32assert + push.4 + dup.1 + swap.1 + u32mod + u32assert + assertz.err=250 + u32divmod.4 + swap.1 + exec.::intrinsics::mem::load_felt + push.8 + dup.5 + add + u32assert + push.4 + dup.1 + swap.1 + u32mod + u32assert + assertz.err=250 + u32divmod.4 + swap.1 + exec.::intrinsics::mem::load_felt + push.12 + movup.6 + add + u32assert + push.4 + dup.1 + swap.1 + u32mod + u32assert + assertz.err=250 + u32divmod.4 + swap.1 + exec.::intrinsics::mem::load_felt + dup.6 + push.4 + dup.1 + swap.1 + u32mod + u32assert + assertz.err=250 + u32divmod.4 + swap.1 + exec.::intrinsics::mem::load_felt + push.4 + dup.8 + add + u32assert + push.4 + dup.1 + swap.1 + u32mod + u32assert + assertz.err=250 + u32divmod.4 + swap.1 + exec.::intrinsics::mem::load_felt + push.8 + dup.9 + add + u32assert + push.4 + dup.1 + swap.1 + u32mod + u32assert + assertz.err=250 + u32divmod.4 + swap.1 + exec.::intrinsics::mem::load_felt + push.12 + movup.10 + add + u32assert + push.4 + dup.1 + swap.1 + u32mod + u32assert + assertz.err=250 + u32divmod.4 + swap.1 + exec.::intrinsics::mem::load_felt + push.255 + movup.10 + swap.1 + u32and + movup.4 + swap.5 + movdn.4 + movup.3 + swap.6 + movdn.3 + movup.2 + swap.7 + movdn.2 + swap.1 + swap.8 + swap.1 + exec.::miden:counter-contract/counter@0.1.0::counter_contract::miden_base_sys::bindings::storage::extern_set_storage_map_item +end + +proc.>::from + push.12 + dup.1 + add + u32assert + push.4 + dup.1 + swap.1 + u32mod + u32assert + assertz.err=250 + movup.2 + swap.1 + u32divmod.4 + swap.1 + exec.::intrinsics::mem::store_felt + push.8 + dup.1 + add + u32assert + push.4 + dup.1 + swap.1 + u32mod + u32assert + assertz.err=250 + push.0 + swap.1 + u32divmod.4 + swap.1 + exec.::intrinsics::mem::store_felt + push.4 + dup.1 + add + u32assert + push.4 + dup.1 + swap.1 + u32mod + u32assert + assertz.err=250 + push.0 + swap.1 + u32divmod.4 + swap.1 + exec.::intrinsics::mem::store_felt + push.4 + dup.1 + swap.1 + u32mod + u32assert + assertz.err=250 + push.0 + swap.1 + u32divmod.4 + swap.1 + exec.::intrinsics::mem::store_felt +end + +proc.core::ptr::alignment::Alignment::max + push.0 + dup.2 + dup.2 + swap.1 + u32gt + neq + cdrop +end + +export.cabi_realloc + exec.::miden:counter-contract/counter@0.1.0::counter_contract::cabi_realloc_wit_bindgen_0_28_0 +end + diff --git a/tests/integration/expected/examples/counter.wat b/tests/integration/expected/examples/counter.wat new file mode 100644 index 000000000..6edfd3bea --- /dev/null +++ b/tests/integration/expected/examples/counter.wat @@ -0,0 +1,509 @@ +(component $counter-contract + (type (;0;) + (instance + (type (;0;) (func (result s32))) + (export (;0;) "heap-base" (func (type 0))) + ) + ) + (import "miden:core-import/intrinsics-mem@1.0.0" (instance (;0;) (type 0))) + (type (;1;) + (instance + (type (;0;) (func (param "a" f32) (param "b" f32) (result f32))) + (export (;0;) "add" (func (type 0))) + (type (;1;) (func (param "a" u32) (result f32))) + (export (;1;) "from-u32" (func (type 1))) + ) + ) + (import "miden:core-import/intrinsics-felt@1.0.0" (instance (;1;) (type 1))) + (type (;2;) + (instance + (type (;0;) (func (param "index" f32) (param "key0" f32) (param "key1" f32) (param "key2" f32) (param "key3" f32) (param "result-ptr" s32))) + (export (;0;) "get-map-item" (func (type 0))) + (type (;1;) (func (param "index" f32) (param "key0" f32) (param "key1" f32) (param "key2" f32) (param "key3" f32) (param "value0" f32) (param "value1" f32) (param "value2" f32) (param "value3" f32) (param "result-ptr" s32))) + (export (;1;) "set-map-item" (func (type 1))) + ) + ) + (import "miden:core-import/account@1.0.0" (instance (;2;) (type 2))) + (type (;3;) + (instance + (type (;0;) (record (field "inner" f32))) + (export (;1;) "felt" (type (eq 0))) + ) + ) + (import "miden:base/core-types@1.0.0" (instance (;3;) (type 3))) + (core module (;0;) + (type (;0;) (func (param i32) (result f32))) + (type (;1;) (func (param f32 f32) (result f32))) + (type (;2;) (func (result i32))) + (type (;3;) (func (param f32 f32 f32 f32 f32 i32))) + (type (;4;) (func (param f32 f32 f32 f32 f32 f32 f32 f32 f32 i32))) + (type (;5;) (func)) + (type (;6;) (func (param i32 i32) (result i32))) + (type (;7;) (func (param i32 i32 i32 i32) (result i32))) + (type (;8;) (func (result f32))) + (type (;9;) (func (param i32 i32 i32) (result i32))) + (type (;10;) (func (param i32 i32 i32))) + (type (;11;) (func (param i32 i32 i32 i32))) + (type (;12;) (func (param i32 f32))) + (import "miden:core-import/intrinsics-felt@1.0.0" "from-u32" (func $miden_stdlib_sys::intrinsics::felt::extern_from_u32 (;0;) (type 0))) + (import "miden:core-import/intrinsics-felt@1.0.0" "add" (func $miden_stdlib_sys::intrinsics::felt::extern_add (;1;) (type 1))) + (import "miden:core-import/intrinsics-mem@1.0.0" "heap-base" (func $miden_sdk_alloc::heap_base (;2;) (type 2))) + (import "miden:core-import/account@1.0.0" "get-map-item" (func $miden_base_sys::bindings::storage::extern_get_storage_map_item (;3;) (type 3))) + (import "miden:core-import/account@1.0.0" "set-map-item" (func $miden_base_sys::bindings::storage::extern_set_storage_map_item (;4;) (type 4))) + (table (;0;) 3 3 funcref) + (memory (;0;) 17) + (global $__stack_pointer (;0;) (mut i32) i32.const 1048576) + (export "memory" (memory 0)) + (export "miden:counter-contract/counter@0.1.0#get-count" (func $miden:counter-contract/counter@0.1.0#get-count)) + (export "miden:counter-contract/counter@0.1.0#increment-count" (func $miden:counter-contract/counter@0.1.0#increment-count)) + (export "cabi_realloc_wit_bindgen_0_28_0" (func $cabi_realloc_wit_bindgen_0_28_0)) + (export "cabi_realloc" (func $cabi_realloc)) + (elem (;0;) (i32.const 1) func $counter_contract::bindings::__link_custom_section_describing_imports $cabi_realloc) + (func $__wasm_call_ctors (;5;) (type 5)) + (func $counter_contract::bindings::__link_custom_section_describing_imports (;6;) (type 5)) + (func $__rustc::__rust_alloc (;7;) (type 6) (param i32 i32) (result i32) + i32.const 1048612 + local.get 1 + local.get 0 + call $::alloc + ) + (func $__rustc::__rust_realloc (;8;) (type 7) (param i32 i32 i32 i32) (result i32) + block ;; label = @1 + i32.const 1048612 + local.get 2 + local.get 3 + call $::alloc + local.tee 2 + i32.eqz + br_if 0 (;@1;) + local.get 3 + local.get 1 + local.get 3 + local.get 1 + i32.lt_u + select + local.tee 3 + i32.eqz + br_if 0 (;@1;) + local.get 2 + local.get 0 + local.get 3 + memory.copy + end + local.get 2 + ) + (func $miden:counter-contract/counter@0.1.0#get-count (;9;) (type 8) (result f32) + (local i32 i32 i32 f32) + global.get $__stack_pointer + local.tee 0 + local.set 1 + local.get 0 + i32.const 64 + i32.sub + i32.const -32 + i32.and + local.tee 2 + global.set $__stack_pointer + call $wit_bindgen_rt::run_ctors_once + i32.const 0 + local.set 0 + i32.const 0 + call $miden_stdlib_sys::intrinsics::felt::extern_from_u32 + local.set 3 + block ;; label = @1 + loop ;; label = @2 + local.get 0 + i32.const 16 + i32.eq + br_if 1 (;@1;) + local.get 2 + i32.const 32 + i32.add + local.get 0 + i32.add + local.get 3 + f32.store + local.get 0 + i32.const 4 + i32.add + local.set 0 + br 0 (;@2;) + end + end + local.get 2 + local.get 2 + i64.load offset=40 align=4 + i64.store offset=8 + local.get 2 + local.get 2 + i64.load offset=32 align=4 + i64.store + local.get 2 + i32.const 32 + i32.add + i32.const 0 + local.get 2 + call $miden_base_sys::bindings::storage::get_map_item + local.get 2 + f32.load offset=44 + local.set 3 + local.get 1 + global.set $__stack_pointer + local.get 3 + ) + (func $miden:counter-contract/counter@0.1.0#increment-count (;10;) (type 8) (result f32) + (local i32 i32 i32 f32) + global.get $__stack_pointer + local.tee 0 + local.set 1 + local.get 0 + i32.const 160 + i32.sub + i32.const -32 + i32.and + local.tee 2 + global.set $__stack_pointer + call $wit_bindgen_rt::run_ctors_once + i32.const 0 + local.set 0 + i32.const 0 + call $miden_stdlib_sys::intrinsics::felt::extern_from_u32 + local.set 3 + block ;; label = @1 + loop ;; label = @2 + local.get 0 + i32.const 16 + i32.eq + br_if 1 (;@1;) + local.get 2 + i32.const 32 + i32.add + local.get 0 + i32.add + local.get 3 + f32.store + local.get 0 + i32.const 4 + i32.add + local.set 0 + br 0 (;@2;) + end + end + local.get 2 + local.get 2 + i64.load offset=40 align=4 + i64.store offset=8 + local.get 2 + local.get 2 + i64.load offset=32 align=4 + i64.store + local.get 2 + i32.const 32 + i32.add + i32.const 0 + local.get 2 + call $miden_base_sys::bindings::storage::get_map_item + local.get 2 + f32.load offset=44 + i32.const 1 + call $miden_stdlib_sys::intrinsics::felt::extern_from_u32 + call $miden_stdlib_sys::intrinsics::felt::extern_add + local.set 3 + local.get 2 + local.get 2 + i64.load offset=24 + i64.store offset=120 + local.get 2 + local.get 2 + i64.load offset=16 + i64.store offset=112 + local.get 2 + local.get 2 + i64.load offset=8 + i64.store offset=104 + local.get 2 + local.get 2 + i64.load + i64.store offset=96 + local.get 2 + i32.const 128 + i32.add + local.get 3 + call $>::from + local.get 2 + i32.const 32 + i32.add + i32.const 0 + local.get 2 + i32.const 96 + i32.add + local.get 2 + i32.const 128 + i32.add + call $miden_base_sys::bindings::storage::set_map_item + local.get 1 + global.set $__stack_pointer + local.get 3 + ) + (func $cabi_realloc_wit_bindgen_0_28_0 (;11;) (type 7) (param i32 i32 i32 i32) (result i32) + local.get 0 + local.get 1 + local.get 2 + local.get 3 + call $wit_bindgen_rt::cabi_realloc + ) + (func $wit_bindgen_rt::cabi_realloc (;12;) (type 7) (param i32 i32 i32 i32) (result i32) + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + local.get 1 + br_if 0 (;@3;) + local.get 3 + i32.eqz + br_if 2 (;@1;) + i32.const 0 + i32.load8_u offset=1048616 + drop + local.get 3 + local.get 2 + call $__rustc::__rust_alloc + local.set 2 + br 1 (;@2;) + end + local.get 0 + local.get 1 + local.get 2 + local.get 3 + call $__rustc::__rust_realloc + local.set 2 + end + local.get 2 + br_if 0 (;@1;) + unreachable + end + local.get 2 + ) + (func $wit_bindgen_rt::run_ctors_once (;13;) (type 5) + block ;; label = @1 + i32.const 0 + i32.load8_u offset=1048617 + br_if 0 (;@1;) + call $__wasm_call_ctors + i32.const 0 + i32.const 1 + i32.store8 offset=1048617 + end + ) + (func $::alloc (;14;) (type 9) (param i32 i32 i32) (result i32) + (local i32 i32) + block ;; label = @1 + local.get 1 + i32.const 32 + local.get 1 + i32.const 32 + i32.gt_u + select + local.tee 3 + local.get 3 + i32.const -1 + i32.add + i32.and + br_if 0 (;@1;) + local.get 2 + i32.const -2147483648 + local.get 1 + local.get 3 + call $core::ptr::alignment::Alignment::max + local.tee 1 + i32.sub + i32.gt_u + br_if 0 (;@1;) + i32.const 0 + local.set 3 + local.get 2 + local.get 1 + i32.add + i32.const -1 + i32.add + i32.const 0 + local.get 1 + i32.sub + i32.and + local.set 2 + block ;; label = @2 + local.get 0 + i32.load + br_if 0 (;@2;) + local.get 0 + call $miden_sdk_alloc::heap_base + memory.size + i32.const 16 + i32.shl + i32.add + i32.store + end + block ;; label = @2 + i32.const 268435456 + local.get 0 + i32.load + local.tee 4 + i32.sub + local.get 2 + i32.lt_u + br_if 0 (;@2;) + local.get 0 + local.get 4 + local.get 2 + i32.add + i32.store + local.get 4 + local.get 1 + i32.add + local.set 3 + end + local.get 3 + return + end + unreachable + ) + (func $miden_base_sys::bindings::storage::get_map_item (;15;) (type 10) (param i32 i32 i32) + local.get 1 + i32.const 255 + i32.and + f32.reinterpret_i32 + local.get 2 + f32.load + local.get 2 + f32.load offset=4 + local.get 2 + f32.load offset=8 + local.get 2 + f32.load offset=12 + local.get 0 + call $miden_base_sys::bindings::storage::extern_get_storage_map_item + ) + (func $miden_base_sys::bindings::storage::set_map_item (;16;) (type 11) (param i32 i32 i32 i32) + local.get 1 + i32.const 255 + i32.and + f32.reinterpret_i32 + local.get 2 + f32.load + local.get 2 + f32.load offset=4 + local.get 2 + f32.load offset=8 + local.get 2 + f32.load offset=12 + local.get 3 + f32.load + local.get 3 + f32.load offset=4 + local.get 3 + f32.load offset=8 + local.get 3 + f32.load offset=12 + local.get 0 + call $miden_base_sys::bindings::storage::extern_set_storage_map_item + ) + (func $>::from (;17;) (type 12) (param i32 f32) + (local f32 f32 f32) + i32.const 0 + call $miden_stdlib_sys::intrinsics::felt::extern_from_u32 + local.set 2 + i32.const 0 + call $miden_stdlib_sys::intrinsics::felt::extern_from_u32 + local.set 3 + i32.const 0 + call $miden_stdlib_sys::intrinsics::felt::extern_from_u32 + local.set 4 + local.get 0 + local.get 1 + f32.store offset=12 + local.get 0 + local.get 4 + f32.store offset=8 + local.get 0 + local.get 3 + f32.store offset=4 + local.get 0 + local.get 2 + f32.store + ) + (func $core::ptr::alignment::Alignment::max (;18;) (type 6) (param i32 i32) (result i32) + local.get 0 + local.get 1 + local.get 0 + local.get 1 + i32.gt_u + select + ) + (func $cabi_realloc (;19;) (type 7) (param i32 i32 i32 i32) (result i32) + local.get 0 + local.get 1 + local.get 2 + local.get 3 + call $cabi_realloc_wit_bindgen_0_28_0 + ) + (data $.rodata (;0;) (i32.const 1048576) "\01\00\00\00\01\00\00\00\01\00\00\00\01\00\00\00\01\00\00\00\01\00\00\00\01\00\00\00\01\00\00\00\02\00\00\00") + (@custom "rodata,miden_account" (after data) "!counter-contract\95A simple example of a Miden counter contract using the Account Storage API\0b0.1.0\03\01\03\01\00\01\13count_map\019counter contract storage map") + ) + (alias export 1 "from-u32" (func (;0;))) + (core func (;0;) (canon lower (func 0))) + (alias export 1 "add" (func (;1;))) + (core func (;1;) (canon lower (func 1))) + (core instance (;0;) + (export "from-u32" (func 0)) + (export "add" (func 1)) + ) + (alias export 0 "heap-base" (func (;2;))) + (core func (;2;) (canon lower (func 2))) + (core instance (;1;) + (export "heap-base" (func 2)) + ) + (alias export 2 "get-map-item" (func (;3;))) + (core func (;3;) (canon lower (func 3))) + (alias export 2 "set-map-item" (func (;4;))) + (core func (;4;) (canon lower (func 4))) + (core instance (;2;) + (export "get-map-item" (func 3)) + (export "set-map-item" (func 4)) + ) + (core instance (;3;) (instantiate 0 + (with "miden:core-import/intrinsics-felt@1.0.0" (instance 0)) + (with "miden:core-import/intrinsics-mem@1.0.0" (instance 1)) + (with "miden:core-import/account@1.0.0" (instance 2)) + ) + ) + (alias core export 3 "memory" (core memory (;0;))) + (alias export 3 "felt" (type (;4;))) + (type (;5;) (func (result 4))) + (alias core export 3 "miden:counter-contract/counter@0.1.0#get-count" (core func (;5;))) + (alias core export 3 "cabi_realloc" (core func (;6;))) + (func (;5;) (type 5) (canon lift (core func 5))) + (alias core export 3 "miden:counter-contract/counter@0.1.0#increment-count" (core func (;7;))) + (func (;6;) (type 5) (canon lift (core func 7))) + (alias export 3 "felt" (type (;6;))) + (component (;0;) + (type (;0;) (record (field "inner" f32))) + (import "import-type-felt" (type (;1;) (eq 0))) + (import "import-type-felt0" (type (;2;) (eq 1))) + (type (;3;) (func (result 2))) + (import "import-func-get-count" (func (;0;) (type 3))) + (import "import-func-increment-count" (func (;1;) (type 3))) + (export (;4;) "felt" (type 1)) + (type (;5;) (func (result 4))) + (export (;2;) "get-count" (func 0) (func (type 5))) + (export (;3;) "increment-count" (func 1) (func (type 5))) + ) + (instance (;4;) (instantiate 0 + (with "import-func-get-count" (func 5)) + (with "import-func-increment-count" (func 6)) + (with "import-type-felt" (type 6)) + (with "import-type-felt0" (type 4)) + ) + ) + (export (;5;) "miden:counter-contract/counter@0.1.0" (instance 4)) + (@custom "description" "A simple example of a Miden counter contract using the Account Storage API") + (@custom "version" "0.1.0") +) diff --git a/tests/integration/src/rust_masm_tests/examples.rs b/tests/integration/src/rust_masm_tests/examples.rs index 45b435fb6..6395a9088 100644 --- a/tests/integration/src/rust_masm_tests/examples.rs +++ b/tests/integration/src/rust_masm_tests/examples.rs @@ -219,3 +219,34 @@ fn is_prime() { panic!("{err}"); }); } + +#[test] +fn counter_contract() { + let config = WasmTranslationConfig::default(); + let mut test = + CompilerTest::rust_source_cargo_miden("../../examples/counter-contract", config, []); + + test.expect_wasm(expect_file!["../../expected/examples/counter.wat"]); + test.expect_ir(expect_file!["../../expected/examples/counter.hir"]); + test.expect_masm(expect_file!["../../expected/examples/counter.masm"]); + let package = test.compiled_package(); + let account_component_metadata_bytes = + package.as_ref().account_component_metadata_bytes.clone().unwrap(); + let toml = AccountComponentMetadata::read_from_bytes(&account_component_metadata_bytes) + .unwrap() + .as_toml() + .unwrap(); + expect![[r#" + name = "counter-contract" + description = "A simple example of a Miden counter contract using the Account Storage API" + version = "0.1.0" + supported-types = ["RegularAccountUpdatableCode"] + + [[storage]] + name = "count_map" + description = "counter contract storage map" + slot = 0 + values = [] + "#]] + .assert_eq(&toml); +} From c45777ea9e9ef5126b9d6d0e89b97b1e8fb43253 Mon Sep 17 00:00:00 2001 From: Denys Zadorozhnyi Date: Fri, 25 Apr 2025 12:32:48 +0300 Subject: [PATCH 2/8] feature(sdk): expose `incr_nonce` function in the Miden SDK (base) #491 Call it in the `example/counter-contract` --- examples/counter-contract/src/lib.rs | 4 +- frontend/wasm/src/miden_abi/transform.rs | 4 +- .../wasm/src/miden_abi/tx_kernel/account.rs | 2 + sdk/base-sys/masm/miden/account.masm | 5 + sdk/base-sys/src/bindings/account.rs | 12 + .../integration/expected/examples/counter.hir | 1394 +++++++++-------- .../expected/examples/counter.masm | 10 + .../integration/expected/examples/counter.wat | 89 +- .../rust-sdk/wit-sdk/miden-core-import.wit | 3 + 9 files changed, 793 insertions(+), 730 deletions(-) diff --git a/examples/counter-contract/src/lib.rs b/examples/counter-contract/src/lib.rs index 48c503b35..f6a90a7e3 100644 --- a/examples/counter-contract/src/lib.rs +++ b/examples/counter-contract/src/lib.rs @@ -21,7 +21,7 @@ fn panic(_info: &core::panic::PanicInfo) -> ! { mod bindings; use bindings::exports::miden::counter_contract::counter::Guest; -use miden::{component, felt, Felt, StorageMap, StorageMapAccess, Word}; +use miden::{account, component, felt, Felt, StorageMap, StorageMapAccess, Word}; // Define the main contract struct #[component] @@ -56,6 +56,8 @@ impl Guest for CounterContract { let new_value = current_value + felt!(1); // Write the new value back to the storage map contract.count_map.set(key, new_value); + // Increment the nonce of this Miden account + account::incr_nonce(1); new_value } } diff --git a/frontend/wasm/src/miden_abi/transform.rs b/frontend/wasm/src/miden_abi/transform.rs index f237af1b6..2e4023985 100644 --- a/frontend/wasm/src/miden_abi/transform.rs +++ b/frontend/wasm/src/miden_abi/transform.rs @@ -62,7 +62,9 @@ fn get_transform_strategy(path: &SymbolPath) -> Option { symbols::Miden => match components.next()?.as_symbol_name() { symbols::Account => { match components.next_if(|c| c.is_leaf())?.as_symbol_name().as_str() { - tx_kernel::account::GET_ID => Some(TransformStrategy::NoTransform), + tx_kernel::account::GET_ID | tx_kernel::account::INCR_NONCE => { + Some(TransformStrategy::NoTransform) + } tx_kernel::account::ADD_ASSET | tx_kernel::account::REMOVE_ASSET | tx_kernel::account::GET_STORAGE_ITEM diff --git a/frontend/wasm/src/miden_abi/tx_kernel/account.rs b/frontend/wasm/src/miden_abi/tx_kernel/account.rs index 9e42704f7..d0adebdef 100644 --- a/frontend/wasm/src/miden_abi/tx_kernel/account.rs +++ b/frontend/wasm/src/miden_abi/tx_kernel/account.rs @@ -20,6 +20,7 @@ pub const GET_STORAGE_ITEM: &str = "get_item"; pub const SET_STORAGE_ITEM: &str = "set_item"; pub const GET_STORAGE_MAP_ITEM: &str = "get_map_item"; pub const SET_STORAGE_MAP_ITEM: &str = "set_map_item"; +pub const INCR_NONCE: &str = "incr_nonce"; pub(crate) fn signatures() -> ModuleFunctionTypeMap { let mut m: ModuleFunctionTypeMap = Default::default(); @@ -57,6 +58,7 @@ pub(crate) fn signatures() -> ModuleFunctionTypeMap { [Felt, Felt, Felt, Felt, Felt, Felt, Felt, Felt], ), ); + account.insert(Symbol::from(INCR_NONCE), FunctionType::new(CallConv::Wasm, [I32], [])); m.insert(SymbolPath::from_iter(MODULE_PREFIX.iter().copied()), account); m } diff --git a/sdk/base-sys/masm/miden/account.masm b/sdk/base-sys/masm/miden/account.masm index 5e99756b1..aab445907 100644 --- a/sdk/base-sys/masm/miden/account.masm +++ b/sdk/base-sys/masm/miden/account.masm @@ -37,3 +37,8 @@ export.set_map_item end +export.incr_nonce + push.1 + assertz +end + diff --git a/sdk/base-sys/src/bindings/account.rs b/sdk/base-sys/src/bindings/account.rs index ff21c0c8a..6f9d541bb 100644 --- a/sdk/base-sys/src/bindings/account.rs +++ b/sdk/base-sys/src/bindings/account.rs @@ -11,6 +11,8 @@ extern "C" { pub fn extern_account_add_asset(_: Felt, _: Felt, _: Felt, _: Felt, ptr: *mut CoreAsset); #[link_name = "remove-asset"] pub fn extern_account_remove_asset(_: Felt, _: Felt, _: Felt, _: Felt, ptr: *mut CoreAsset); + #[link_name = "incr-nonce"] + pub fn extern_account_incr_nonce(value: i32); } /// Get the account ID of the currently executing note account. @@ -61,3 +63,13 @@ pub fn remove_asset(asset: CoreAsset) -> CoreAsset { ret_area.assume_init() } } + +/// Increments the account nonce by the provided value. +/// +/// Panics: +/// - If the underlying kernel procedure panics. +pub fn incr_nonce(value: u32) { + unsafe { + extern_account_incr_nonce(value as i32); + } +} diff --git a/tests/integration/expected/examples/counter.hir b/tests/integration/expected/examples/counter.hir index 5da298a7d..874c27d5b 100644 --- a/tests/integration/expected/examples/counter.hir +++ b/tests/integration/expected/examples/counter.hir @@ -1,786 +1,800 @@ builtin.component miden:counter-contract/counter@0.1.0 { builtin.module public @counter_contract { - private builtin.function @miden_base_sys::bindings::storage::extern_get_storage_map_item(v0: felt, v1: felt, v2: felt, v3: felt, v4: felt, v5: i32) { - ^block5(v0: felt, v1: felt, v2: felt, v3: felt, v4: felt, v5: i32): - v6, v7, v8, v9 = hir.exec @miden/account/get_map_item(v0, v1, v2, v3, v4) : felt, felt, felt, felt - v10 = hir.bitcast v5 : u32; - v11 = hir.int_to_ptr v10 : ptr; - hir.store v11, v6; - v12 = arith.constant 4 : u32; - v13 = arith.add v10, v12 : u32 #[overflow = checked]; - v14 = hir.int_to_ptr v13 : ptr; - hir.store v14, v7; - v15 = arith.constant 8 : u32; - v16 = arith.add v10, v15 : u32 #[overflow = checked]; - v17 = hir.int_to_ptr v16 : ptr; - hir.store v17, v8; - v18 = arith.constant 12 : u32; - v19 = arith.add v10, v18 : u32 #[overflow = checked]; - v20 = hir.int_to_ptr v19 : ptr; - hir.store v20, v9; + private builtin.function @miden_base_sys::bindings::account::extern_account_incr_nonce(v0: i32) { + ^block5(v0: i32): + hir.exec @miden/account/incr_nonce(v0) builtin.ret ; }; - private builtin.function @miden_base_sys::bindings::storage::extern_set_storage_map_item(v21: felt, v22: felt, v23: felt, v24: felt, v25: felt, v26: felt, v27: felt, v28: felt, v29: felt, v30: i32) { - ^block9(v21: felt, v22: felt, v23: felt, v24: felt, v25: felt, v26: felt, v27: felt, v28: felt, v29: felt, v30: i32): - v31, v32, v33, v34, v35, v36, v37, v38 = hir.exec @miden/account/set_map_item(v21, v22, v23, v24, v25, v26, v27, v28, v29) : felt, felt, felt, felt, felt, felt, felt, felt - v39 = hir.bitcast v30 : u32; - v40 = hir.int_to_ptr v39 : ptr; - hir.store v40, v31; - v41 = arith.constant 4 : u32; - v42 = arith.add v39, v41 : u32 #[overflow = checked]; - v43 = hir.int_to_ptr v42 : ptr; - hir.store v43, v32; - v44 = arith.constant 8 : u32; - v45 = arith.add v39, v44 : u32 #[overflow = checked]; - v46 = hir.int_to_ptr v45 : ptr; - hir.store v46, v33; - v47 = arith.constant 12 : u32; - v48 = arith.add v39, v47 : u32 #[overflow = checked]; - v49 = hir.int_to_ptr v48 : ptr; - hir.store v49, v34; - v50 = arith.constant 16 : u32; - v51 = arith.add v39, v50 : u32 #[overflow = checked]; - v52 = hir.int_to_ptr v51 : ptr; - hir.store v52, v35; - v53 = arith.constant 20 : u32; - v54 = arith.add v39, v53 : u32 #[overflow = checked]; - v55 = hir.int_to_ptr v54 : ptr; - hir.store v55, v36; - v56 = arith.constant 24 : u32; - v57 = arith.add v39, v56 : u32 #[overflow = checked]; - v58 = hir.int_to_ptr v57 : ptr; - hir.store v58, v37; - v59 = arith.constant 28 : u32; - v60 = arith.add v39, v59 : u32 #[overflow = checked]; - v61 = hir.int_to_ptr v60 : ptr; - hir.store v61, v38; + private builtin.function @miden_base_sys::bindings::storage::extern_get_storage_map_item(v1: felt, v2: felt, v3: felt, v4: felt, v5: felt, v6: i32) { + ^block9(v1: felt, v2: felt, v3: felt, v4: felt, v5: felt, v6: i32): + v7, v8, v9, v10 = hir.exec @miden/account/get_map_item(v1, v2, v3, v4, v5) : felt, felt, felt, felt + v11 = hir.bitcast v6 : u32; + v12 = hir.int_to_ptr v11 : ptr; + hir.store v12, v7; + v13 = arith.constant 4 : u32; + v14 = arith.add v11, v13 : u32 #[overflow = checked]; + v15 = hir.int_to_ptr v14 : ptr; + hir.store v15, v8; + v16 = arith.constant 8 : u32; + v17 = arith.add v11, v16 : u32 #[overflow = checked]; + v18 = hir.int_to_ptr v17 : ptr; + hir.store v18, v9; + v19 = arith.constant 12 : u32; + v20 = arith.add v11, v19 : u32 #[overflow = checked]; + v21 = hir.int_to_ptr v20 : ptr; + hir.store v21, v10; + builtin.ret ; + }; + + private builtin.function @miden_base_sys::bindings::storage::extern_set_storage_map_item(v22: felt, v23: felt, v24: felt, v25: felt, v26: felt, v27: felt, v28: felt, v29: felt, v30: felt, v31: i32) { + ^block11(v22: felt, v23: felt, v24: felt, v25: felt, v26: felt, v27: felt, v28: felt, v29: felt, v30: felt, v31: i32): + v32, v33, v34, v35, v36, v37, v38, v39 = hir.exec @miden/account/set_map_item(v22, v23, v24, v25, v26, v27, v28, v29, v30) : felt, felt, felt, felt, felt, felt, felt, felt + v40 = hir.bitcast v31 : u32; + v41 = hir.int_to_ptr v40 : ptr; + hir.store v41, v32; + v42 = arith.constant 4 : u32; + v43 = arith.add v40, v42 : u32 #[overflow = checked]; + v44 = hir.int_to_ptr v43 : ptr; + hir.store v44, v33; + v45 = arith.constant 8 : u32; + v46 = arith.add v40, v45 : u32 #[overflow = checked]; + v47 = hir.int_to_ptr v46 : ptr; + hir.store v47, v34; + v48 = arith.constant 12 : u32; + v49 = arith.add v40, v48 : u32 #[overflow = checked]; + v50 = hir.int_to_ptr v49 : ptr; + hir.store v50, v35; + v51 = arith.constant 16 : u32; + v52 = arith.add v40, v51 : u32 #[overflow = checked]; + v53 = hir.int_to_ptr v52 : ptr; + hir.store v53, v36; + v54 = arith.constant 20 : u32; + v55 = arith.add v40, v54 : u32 #[overflow = checked]; + v56 = hir.int_to_ptr v55 : ptr; + hir.store v56, v37; + v57 = arith.constant 24 : u32; + v58 = arith.add v40, v57 : u32 #[overflow = checked]; + v59 = hir.int_to_ptr v58 : ptr; + hir.store v59, v38; + v60 = arith.constant 28 : u32; + v61 = arith.add v40, v60 : u32 #[overflow = checked]; + v62 = hir.int_to_ptr v61 : ptr; + hir.store v62, v39; builtin.ret ; }; private builtin.function @__wasm_call_ctors() { - ^block12: + ^block14: builtin.ret ; }; private builtin.function @counter_contract::bindings::__link_custom_section_describing_imports() { - ^block14: + ^block16: builtin.ret ; }; - private builtin.function @__rustc::__rust_alloc(v62: i32, v63: i32) -> i32 { - ^block16(v62: i32, v63: i32): - v65 = arith.constant 1048612 : i32; - v66 = hir.exec @miden:counter-contract/counter@0.1.0/counter_contract/::alloc(v65, v63, v62) : i32 - builtin.ret v66; + private builtin.function @__rustc::__rust_alloc(v63: i32, v64: i32) -> i32 { + ^block18(v63: i32, v64: i32): + v66 = arith.constant 1048612 : i32; + v67 = hir.exec @miden:counter-contract/counter@0.1.0/counter_contract/::alloc(v66, v64, v63) : i32 + builtin.ret v67; }; - private builtin.function @__rustc::__rust_realloc(v67: i32, v68: i32, v69: i32, v70: i32) -> i32 { - ^block18(v67: i32, v68: i32, v69: i32, v70: i32): - v72 = arith.constant 1048612 : i32; - v73 = hir.exec @miden:counter-contract/counter@0.1.0/counter_contract/::alloc(v72, v69, v70) : i32 - v581 = arith.constant 0 : i32; - v74 = arith.constant 0 : i32; - v75 = arith.eq v73, v74 : i1; - v76 = arith.zext v75 : u32; - v77 = hir.bitcast v76 : i32; - v79 = arith.neq v77, v581 : i1; - v576 = scf.if v79 : i32 { - ^block20: - scf.yield v73; + private builtin.function @__rustc::__rust_realloc(v68: i32, v69: i32, v70: i32, v71: i32) -> i32 { + ^block20(v68: i32, v69: i32, v70: i32, v71: i32): + v73 = arith.constant 1048612 : i32; + v74 = hir.exec @miden:counter-contract/counter@0.1.0/counter_contract/::alloc(v73, v70, v71) : i32 + v584 = arith.constant 0 : i32; + v75 = arith.constant 0 : i32; + v76 = arith.eq v74, v75 : i1; + v77 = arith.zext v76 : u32; + v78 = hir.bitcast v77 : i32; + v80 = arith.neq v78, v584 : i1; + v579 = scf.if v80 : i32 { + ^block22: + scf.yield v74; } else { - ^block21: - v580 = arith.constant 0 : i32; - v81 = hir.bitcast v68 : u32; - v80 = hir.bitcast v70 : u32; - v82 = arith.lt v80, v81 : i1; - v83 = arith.zext v82 : u32; - v84 = hir.bitcast v83 : i32; - v86 = arith.neq v84, v580 : i1; - v87 = cf.select v86, v70, v68 : i32; - v578 = arith.constant 0 : i32; - v579 = arith.constant 0 : i32; - v89 = arith.eq v87, v579 : i1; - v90 = arith.zext v89 : u32; - v91 = hir.bitcast v90 : i32; - v93 = arith.neq v91, v578 : i1; - v577 = scf.if v93 : i32 { - ^block72: - scf.yield v73; + ^block23: + v583 = arith.constant 0 : i32; + v82 = hir.bitcast v69 : u32; + v81 = hir.bitcast v71 : u32; + v83 = arith.lt v81, v82 : i1; + v84 = arith.zext v83 : u32; + v85 = hir.bitcast v84 : i32; + v87 = arith.neq v85, v583 : i1; + v88 = cf.select v87, v71, v69 : i32; + v581 = arith.constant 0 : i32; + v582 = arith.constant 0 : i32; + v90 = arith.eq v88, v582 : i1; + v91 = arith.zext v90 : u32; + v92 = hir.bitcast v91 : i32; + v94 = arith.neq v92, v581 : i1; + v580 = scf.if v94 : i32 { + ^block76: + scf.yield v74; } else { - ^block22: - v94 = hir.bitcast v87 : u32; - v95 = hir.bitcast v73 : u32; - v96 = hir.int_to_ptr v95 : ptr; - v97 = hir.bitcast v67 : u32; - v98 = hir.int_to_ptr v97 : ptr; - hir.mem_cpy v98, v96, v94; - scf.yield v73; + ^block24: + v95 = hir.bitcast v88 : u32; + v96 = hir.bitcast v74 : u32; + v97 = hir.int_to_ptr v96 : ptr; + v98 = hir.bitcast v68 : u32; + v99 = hir.int_to_ptr v98 : ptr; + hir.mem_cpy v99, v97, v95; + scf.yield v74; }; - scf.yield v577; + scf.yield v580; }; - builtin.ret v576; + builtin.ret v579; }; public builtin.function @miden:counter-contract/counter@0.1.0#get-count() -> felt { - ^block23: - v103 = builtin.global_symbol @miden:counter-contract/counter@0.1.0/counter_contract/__stack_pointer : ptr - v104 = hir.bitcast v103 : ptr; - v105 = hir.load v104 : i32; - v108 = arith.constant -32 : i32; - v106 = arith.constant 64 : i32; - v107 = arith.sub v105, v106 : i32 #[overflow = wrapping]; - v109 = arith.band v107, v108 : i32; - v110 = builtin.global_symbol @miden:counter-contract/counter@0.1.0/counter_contract/__stack_pointer : ptr - v111 = hir.bitcast v110 : ptr; - hir.store v111, v109; + ^block25: + v104 = builtin.global_symbol @miden:counter-contract/counter@0.1.0/counter_contract/__stack_pointer : ptr + v105 = hir.bitcast v104 : ptr; + v106 = hir.load v105 : i32; + v109 = arith.constant -32 : i32; + v107 = arith.constant 64 : i32; + v108 = arith.sub v106, v107 : i32 #[overflow = wrapping]; + v110 = arith.band v108, v109 : i32; + v111 = builtin.global_symbol @miden:counter-contract/counter@0.1.0/counter_contract/__stack_pointer : ptr + v112 = hir.bitcast v111 : ptr; + hir.store v112, v110; hir.exec @miden:counter-contract/counter@0.1.0/counter_contract/wit_bindgen_rt::run_ctors_once() - v592 = ub.poison i32 : i32; - v582 = arith.constant 0 : felt; - v101 = arith.constant 0 : i32; - v608, v609, v610, v611, v612, v613 = scf.while v101, v109, v582, v105, v592, v592 : i32, i32, felt, i32, i32, i32 { - ^block26(v115: i32, v122: i32, v126: felt, v167: i32, v599: i32, v601: i32): - v643 = arith.constant 0 : i32; - v116 = arith.constant 16 : i32; - v117 = arith.eq v115, v116 : i1; - v118 = arith.zext v117 : u32; - v119 = hir.bitcast v118 : i32; - v121 = arith.neq v119, v643 : i1; - v627, v628, v629, v630, v631, v632 = scf.if v121 : i32, i32, felt, i32, u32, u32 { - ^block81: - v584 = arith.constant 0 : u32; - v591 = arith.constant 1 : u32; - v642 = ub.poison i32 : i32; - v593 = ub.poison felt : felt; - scf.yield v642, v642, v593, v642, v591, v584; + v595 = ub.poison i32 : i32; + v585 = arith.constant 0 : felt; + v102 = arith.constant 0 : i32; + v611, v612, v613, v614, v615, v616 = scf.while v102, v110, v585, v106, v595, v595 : i32, i32, felt, i32, i32, i32 { + ^block28(v116: i32, v123: i32, v127: felt, v168: i32, v602: i32, v604: i32): + v646 = arith.constant 0 : i32; + v117 = arith.constant 16 : i32; + v118 = arith.eq v116, v117 : i1; + v119 = arith.zext v118 : u32; + v120 = hir.bitcast v119 : i32; + v122 = arith.neq v120, v646 : i1; + v630, v631, v632, v633, v634, v635 = scf.if v122 : i32, i32, felt, i32, u32, u32 { + ^block85: + v587 = arith.constant 0 : u32; + v594 = arith.constant 1 : u32; + v645 = ub.poison i32 : i32; + v596 = ub.poison felt : felt; + scf.yield v645, v645, v596, v645, v594, v587; } else { - ^block28: - v157 = arith.constant 32 : i32; - v124 = arith.add v122, v157 : i32 #[overflow = wrapping]; - v125 = arith.add v124, v115 : i32 #[overflow = wrapping]; - v127 = hir.bitcast v125 : u32; - v136 = arith.constant 4 : u32; - v129 = arith.mod v127, v136 : u32; - hir.assertz v129 #[code = 250]; - v130 = hir.int_to_ptr v127 : ptr; - hir.store v130, v126; - v640 = arith.constant 1 : u32; - v641 = arith.constant 0 : u32; - v131 = arith.constant 4 : i32; - v132 = arith.add v115, v131 : i32 #[overflow = wrapping]; - scf.yield v132, v122, v126, v167, v641, v640; + ^block30: + v158 = arith.constant 32 : i32; + v125 = arith.add v123, v158 : i32 #[overflow = wrapping]; + v126 = arith.add v125, v116 : i32 #[overflow = wrapping]; + v128 = hir.bitcast v126 : u32; + v137 = arith.constant 4 : u32; + v130 = arith.mod v128, v137 : u32; + hir.assertz v130 #[code = 250]; + v131 = hir.int_to_ptr v128 : ptr; + hir.store v131, v127; + v643 = arith.constant 1 : u32; + v644 = arith.constant 0 : u32; + v132 = arith.constant 4 : i32; + v133 = arith.add v116, v132 : i32 #[overflow = wrapping]; + scf.yield v133, v123, v127, v168, v644, v643; }; - v626 = arith.trunc v632 : i1; - scf.condition v626, v627, v628, v629, v630, v122, v167; + v629 = arith.trunc v635 : i1; + scf.condition v629, v630, v631, v632, v633, v123, v168; } do { - ^block80(v620: i32, v621: i32, v622: felt, v623: i32, v624: i32, v625: i32): - scf.yield v620, v621, v622, v623, v624, v625; + ^block84(v623: i32, v624: i32, v625: felt, v626: i32, v627: i32, v628: i32): + scf.yield v623, v624, v625, v626, v627, v628; }; - v134 = arith.constant 40 : u32; - v133 = hir.bitcast v612 : u32; - v135 = arith.add v133, v134 : u32 #[overflow = checked]; - v639 = arith.constant 4 : u32; - v137 = arith.mod v135, v639 : u32; - hir.assertz v137 #[code = 250]; - v138 = hir.int_to_ptr v135 : ptr; - v139 = hir.load v138 : i64; - v141 = arith.constant 8 : u32; - v140 = hir.bitcast v612 : u32; - v142 = arith.add v140, v141 : u32 #[overflow = checked]; - v638 = arith.constant 8 : u32; - v144 = arith.mod v142, v638 : u32; - hir.assertz v144 #[code = 250]; - v145 = hir.int_to_ptr v142 : ptr; - hir.store v145, v139; - v147 = arith.constant 32 : u32; - v146 = hir.bitcast v612 : u32; - v148 = arith.add v146, v147 : u32 #[overflow = checked]; - v637 = arith.constant 4 : u32; - v150 = arith.mod v148, v637 : u32; - hir.assertz v150 #[code = 250]; - v151 = hir.int_to_ptr v148 : ptr; - v152 = hir.load v151 : i64; - v153 = hir.bitcast v612 : u32; - v636 = arith.constant 8 : u32; - v155 = arith.mod v153, v636 : u32; - hir.assertz v155 #[code = 250]; - v156 = hir.int_to_ptr v153 : ptr; - hir.store v156, v152; - v634 = arith.constant 0 : i32; - v635 = arith.constant 32 : i32; - v158 = arith.add v612, v635 : i32 #[overflow = wrapping]; - hir.exec @miden:counter-contract/counter@0.1.0/counter_contract/miden_base_sys::bindings::storage::get_map_item(v158, v634, v612) - v161 = arith.constant 44 : u32; - v160 = hir.bitcast v612 : u32; - v162 = arith.add v160, v161 : u32 #[overflow = checked]; - v633 = arith.constant 4 : u32; - v164 = arith.mod v162, v633 : u32; - hir.assertz v164 #[code = 250]; - v165 = hir.int_to_ptr v162 : ptr; - v166 = hir.load v165 : felt; - v168 = builtin.global_symbol @miden:counter-contract/counter@0.1.0/counter_contract/__stack_pointer : ptr - v169 = hir.bitcast v168 : ptr; - hir.store v169, v613; - builtin.ret v166; + v135 = arith.constant 40 : u32; + v134 = hir.bitcast v615 : u32; + v136 = arith.add v134, v135 : u32 #[overflow = checked]; + v642 = arith.constant 4 : u32; + v138 = arith.mod v136, v642 : u32; + hir.assertz v138 #[code = 250]; + v139 = hir.int_to_ptr v136 : ptr; + v140 = hir.load v139 : i64; + v142 = arith.constant 8 : u32; + v141 = hir.bitcast v615 : u32; + v143 = arith.add v141, v142 : u32 #[overflow = checked]; + v641 = arith.constant 8 : u32; + v145 = arith.mod v143, v641 : u32; + hir.assertz v145 #[code = 250]; + v146 = hir.int_to_ptr v143 : ptr; + hir.store v146, v140; + v148 = arith.constant 32 : u32; + v147 = hir.bitcast v615 : u32; + v149 = arith.add v147, v148 : u32 #[overflow = checked]; + v640 = arith.constant 4 : u32; + v151 = arith.mod v149, v640 : u32; + hir.assertz v151 #[code = 250]; + v152 = hir.int_to_ptr v149 : ptr; + v153 = hir.load v152 : i64; + v154 = hir.bitcast v615 : u32; + v639 = arith.constant 8 : u32; + v156 = arith.mod v154, v639 : u32; + hir.assertz v156 #[code = 250]; + v157 = hir.int_to_ptr v154 : ptr; + hir.store v157, v153; + v637 = arith.constant 0 : i32; + v638 = arith.constant 32 : i32; + v159 = arith.add v615, v638 : i32 #[overflow = wrapping]; + hir.exec @miden:counter-contract/counter@0.1.0/counter_contract/miden_base_sys::bindings::storage::get_map_item(v159, v637, v615) + v162 = arith.constant 44 : u32; + v161 = hir.bitcast v615 : u32; + v163 = arith.add v161, v162 : u32 #[overflow = checked]; + v636 = arith.constant 4 : u32; + v165 = arith.mod v163, v636 : u32; + hir.assertz v165 #[code = 250]; + v166 = hir.int_to_ptr v163 : ptr; + v167 = hir.load v166 : felt; + v169 = builtin.global_symbol @miden:counter-contract/counter@0.1.0/counter_contract/__stack_pointer : ptr + v170 = hir.bitcast v169 : ptr; + hir.store v170, v616; + builtin.ret v167; }; public builtin.function @miden:counter-contract/counter@0.1.0#increment-count() -> felt { - ^block29: - v173 = builtin.global_symbol @miden:counter-contract/counter@0.1.0/counter_contract/__stack_pointer : ptr - v174 = hir.bitcast v173 : ptr; - v175 = hir.load v174 : i32; - v178 = arith.constant -32 : i32; - v176 = arith.constant 160 : i32; - v177 = arith.sub v175, v176 : i32 #[overflow = wrapping]; - v179 = arith.band v177, v178 : i32; - v180 = builtin.global_symbol @miden:counter-contract/counter@0.1.0/counter_contract/__stack_pointer : ptr - v181 = hir.bitcast v180 : ptr; - hir.store v181, v179; + ^block31: + v174 = builtin.global_symbol @miden:counter-contract/counter@0.1.0/counter_contract/__stack_pointer : ptr + v175 = hir.bitcast v174 : ptr; + v176 = hir.load v175 : i32; + v179 = arith.constant -32 : i32; + v177 = arith.constant 160 : i32; + v178 = arith.sub v176, v177 : i32 #[overflow = wrapping]; + v180 = arith.band v178, v179 : i32; + v181 = builtin.global_symbol @miden:counter-contract/counter@0.1.0/counter_contract/__stack_pointer : ptr + v182 = hir.bitcast v181 : ptr; + hir.store v182, v180; hir.exec @miden:counter-contract/counter@0.1.0/counter_contract/wit_bindgen_rt::run_ctors_once() - v655 = ub.poison i32 : i32; - v645 = arith.constant 0 : felt; - v171 = arith.constant 0 : i32; - v671, v672, v673, v674, v675, v676 = scf.while v171, v179, v645, v175, v655, v655 : i32, i32, felt, i32, i32, i32 { - ^block32(v185: i32, v192: i32, v196: felt, v299: i32, v662: i32, v664: i32): - v718 = arith.constant 0 : i32; - v186 = arith.constant 16 : i32; - v187 = arith.eq v185, v186 : i1; - v188 = arith.zext v187 : u32; - v189 = hir.bitcast v188 : i32; - v191 = arith.neq v189, v718 : i1; - v690, v691, v692, v693, v694, v695 = scf.if v191 : i32, i32, felt, i32, u32, u32 { - ^block88: - v647 = arith.constant 0 : u32; - v654 = arith.constant 1 : u32; - v717 = ub.poison i32 : i32; - v656 = ub.poison felt : felt; - scf.yield v717, v717, v656, v717, v654, v647; + v658 = ub.poison i32 : i32; + v648 = arith.constant 0 : felt; + v172 = arith.constant 0 : i32; + v674, v675, v676, v677, v678, v679 = scf.while v172, v180, v648, v176, v658, v658 : i32, i32, felt, i32, i32, i32 { + ^block34(v186: i32, v193: i32, v197: felt, v301: i32, v665: i32, v667: i32): + v721 = arith.constant 0 : i32; + v187 = arith.constant 16 : i32; + v188 = arith.eq v186, v187 : i1; + v189 = arith.zext v188 : u32; + v190 = hir.bitcast v189 : i32; + v192 = arith.neq v190, v721 : i1; + v693, v694, v695, v696, v697, v698 = scf.if v192 : i32, i32, felt, i32, u32, u32 { + ^block92: + v650 = arith.constant 0 : u32; + v657 = arith.constant 1 : u32; + v720 = ub.poison i32 : i32; + v659 = ub.poison felt : felt; + scf.yield v720, v720, v659, v720, v657, v650; } else { - ^block34: - v227 = arith.constant 32 : i32; - v194 = arith.add v192, v227 : i32 #[overflow = wrapping]; - v195 = arith.add v194, v185 : i32 #[overflow = wrapping]; - v197 = hir.bitcast v195 : u32; - v206 = arith.constant 4 : u32; - v199 = arith.mod v197, v206 : u32; - hir.assertz v199 #[code = 250]; - v200 = hir.int_to_ptr v197 : ptr; - hir.store v200, v196; - v715 = arith.constant 1 : u32; - v716 = arith.constant 0 : u32; - v201 = arith.constant 4 : i32; - v202 = arith.add v185, v201 : i32 #[overflow = wrapping]; - scf.yield v202, v192, v196, v299, v716, v715; + ^block36: + v228 = arith.constant 32 : i32; + v195 = arith.add v193, v228 : i32 #[overflow = wrapping]; + v196 = arith.add v195, v186 : i32 #[overflow = wrapping]; + v198 = hir.bitcast v196 : u32; + v207 = arith.constant 4 : u32; + v200 = arith.mod v198, v207 : u32; + hir.assertz v200 #[code = 250]; + v201 = hir.int_to_ptr v198 : ptr; + hir.store v201, v197; + v718 = arith.constant 1 : u32; + v719 = arith.constant 0 : u32; + v202 = arith.constant 4 : i32; + v203 = arith.add v186, v202 : i32 #[overflow = wrapping]; + scf.yield v203, v193, v197, v301, v719, v718; }; - v689 = arith.trunc v695 : i1; - scf.condition v689, v690, v691, v692, v693, v192, v299; + v692 = arith.trunc v698 : i1; + scf.condition v692, v693, v694, v695, v696, v193, v301; } do { - ^block87(v683: i32, v684: i32, v685: felt, v686: i32, v687: i32, v688: i32): - scf.yield v683, v684, v685, v686, v687, v688; + ^block91(v686: i32, v687: i32, v688: felt, v689: i32, v690: i32, v691: i32): + scf.yield v686, v687, v688, v689, v690, v691; }; - v204 = arith.constant 40 : u32; - v203 = hir.bitcast v675 : u32; - v205 = arith.add v203, v204 : u32 #[overflow = checked]; - v714 = arith.constant 4 : u32; - v207 = arith.mod v205, v714 : u32; - hir.assertz v207 #[code = 250]; - v208 = hir.int_to_ptr v205 : ptr; - v209 = hir.load v208 : i64; - v211 = arith.constant 8 : u32; - v210 = hir.bitcast v675 : u32; - v212 = arith.add v210, v211 : u32 #[overflow = checked]; - v713 = arith.constant 8 : u32; - v214 = arith.mod v212, v713 : u32; - hir.assertz v214 #[code = 250]; - v215 = hir.int_to_ptr v212 : ptr; - hir.store v215, v209; - v217 = arith.constant 32 : u32; - v216 = hir.bitcast v675 : u32; - v218 = arith.add v216, v217 : u32 #[overflow = checked]; - v712 = arith.constant 4 : u32; - v220 = arith.mod v218, v712 : u32; - hir.assertz v220 #[code = 250]; - v221 = hir.int_to_ptr v218 : ptr; - v222 = hir.load v221 : i64; - v223 = hir.bitcast v675 : u32; - v711 = arith.constant 8 : u32; - v225 = arith.mod v223, v711 : u32; - hir.assertz v225 #[code = 250]; - v226 = hir.int_to_ptr v223 : ptr; - hir.store v226, v222; - v709 = arith.constant 0 : i32; - v710 = arith.constant 32 : i32; - v228 = arith.add v675, v710 : i32 #[overflow = wrapping]; - hir.exec @miden:counter-contract/counter@0.1.0/counter_contract/miden_base_sys::bindings::storage::get_map_item(v228, v709, v675) - v231 = arith.constant 44 : u32; - v230 = hir.bitcast v675 : u32; - v232 = arith.add v230, v231 : u32 #[overflow = checked]; - v708 = arith.constant 4 : u32; - v234 = arith.mod v232, v708 : u32; - hir.assertz v234 #[code = 250]; - v235 = hir.int_to_ptr v232 : ptr; - v236 = hir.load v235 : felt; - v644 = arith.constant 1 : felt; - v239 = arith.add v236, v644 : felt #[overflow = unchecked]; - v241 = arith.constant 24 : u32; - v240 = hir.bitcast v675 : u32; - v242 = arith.add v240, v241 : u32 #[overflow = checked]; + v205 = arith.constant 40 : u32; + v204 = hir.bitcast v678 : u32; + v206 = arith.add v204, v205 : u32 #[overflow = checked]; + v717 = arith.constant 4 : u32; + v208 = arith.mod v206, v717 : u32; + hir.assertz v208 #[code = 250]; + v209 = hir.int_to_ptr v206 : ptr; + v210 = hir.load v209 : i64; + v212 = arith.constant 8 : u32; + v211 = hir.bitcast v678 : u32; + v213 = arith.add v211, v212 : u32 #[overflow = checked]; + v716 = arith.constant 8 : u32; + v215 = arith.mod v213, v716 : u32; + hir.assertz v215 #[code = 250]; + v216 = hir.int_to_ptr v213 : ptr; + hir.store v216, v210; + v218 = arith.constant 32 : u32; + v217 = hir.bitcast v678 : u32; + v219 = arith.add v217, v218 : u32 #[overflow = checked]; + v715 = arith.constant 4 : u32; + v221 = arith.mod v219, v715 : u32; + hir.assertz v221 #[code = 250]; + v222 = hir.int_to_ptr v219 : ptr; + v223 = hir.load v222 : i64; + v224 = hir.bitcast v678 : u32; + v714 = arith.constant 8 : u32; + v226 = arith.mod v224, v714 : u32; + hir.assertz v226 #[code = 250]; + v227 = hir.int_to_ptr v224 : ptr; + hir.store v227, v223; + v712 = arith.constant 0 : i32; + v713 = arith.constant 32 : i32; + v229 = arith.add v678, v713 : i32 #[overflow = wrapping]; + hir.exec @miden:counter-contract/counter@0.1.0/counter_contract/miden_base_sys::bindings::storage::get_map_item(v229, v712, v678) + v232 = arith.constant 44 : u32; + v231 = hir.bitcast v678 : u32; + v233 = arith.add v231, v232 : u32 #[overflow = checked]; + v711 = arith.constant 4 : u32; + v235 = arith.mod v233, v711 : u32; + hir.assertz v235 #[code = 250]; + v236 = hir.int_to_ptr v233 : ptr; + v237 = hir.load v236 : felt; + v647 = arith.constant 1 : felt; + v240 = arith.add v237, v647 : felt #[overflow = unchecked]; + v242 = arith.constant 24 : u32; + v241 = hir.bitcast v678 : u32; + v243 = arith.add v241, v242 : u32 #[overflow = checked]; + v710 = arith.constant 8 : u32; + v245 = arith.mod v243, v710 : u32; + hir.assertz v245 #[code = 250]; + v246 = hir.int_to_ptr v243 : ptr; + v247 = hir.load v246 : i64; + v249 = arith.constant 120 : u32; + v248 = hir.bitcast v678 : u32; + v250 = arith.add v248, v249 : u32 #[overflow = checked]; + v709 = arith.constant 8 : u32; + v252 = arith.mod v250, v709 : u32; + hir.assertz v252 #[code = 250]; + v253 = hir.int_to_ptr v250 : ptr; + hir.store v253, v247; + v255 = arith.constant 16 : u32; + v254 = hir.bitcast v678 : u32; + v256 = arith.add v254, v255 : u32 #[overflow = checked]; + v708 = arith.constant 8 : u32; + v258 = arith.mod v256, v708 : u32; + hir.assertz v258 #[code = 250]; + v259 = hir.int_to_ptr v256 : ptr; + v260 = hir.load v259 : i64; + v262 = arith.constant 112 : u32; + v261 = hir.bitcast v678 : u32; + v263 = arith.add v261, v262 : u32 #[overflow = checked]; v707 = arith.constant 8 : u32; - v244 = arith.mod v242, v707 : u32; - hir.assertz v244 #[code = 250]; - v245 = hir.int_to_ptr v242 : ptr; - v246 = hir.load v245 : i64; - v248 = arith.constant 120 : u32; - v247 = hir.bitcast v675 : u32; - v249 = arith.add v247, v248 : u32 #[overflow = checked]; + v265 = arith.mod v263, v707 : u32; + hir.assertz v265 #[code = 250]; + v266 = hir.int_to_ptr v263 : ptr; + hir.store v266, v260; v706 = arith.constant 8 : u32; - v251 = arith.mod v249, v706 : u32; - hir.assertz v251 #[code = 250]; - v252 = hir.int_to_ptr v249 : ptr; - hir.store v252, v246; - v254 = arith.constant 16 : u32; - v253 = hir.bitcast v675 : u32; - v255 = arith.add v253, v254 : u32 #[overflow = checked]; + v267 = hir.bitcast v678 : u32; + v269 = arith.add v267, v706 : u32 #[overflow = checked]; v705 = arith.constant 8 : u32; - v257 = arith.mod v255, v705 : u32; - hir.assertz v257 #[code = 250]; - v258 = hir.int_to_ptr v255 : ptr; - v259 = hir.load v258 : i64; - v261 = arith.constant 112 : u32; - v260 = hir.bitcast v675 : u32; - v262 = arith.add v260, v261 : u32 #[overflow = checked]; + v271 = arith.mod v269, v705 : u32; + hir.assertz v271 #[code = 250]; + v272 = hir.int_to_ptr v269 : ptr; + v273 = hir.load v272 : i64; + v275 = arith.constant 104 : u32; + v274 = hir.bitcast v678 : u32; + v276 = arith.add v274, v275 : u32 #[overflow = checked]; v704 = arith.constant 8 : u32; - v264 = arith.mod v262, v704 : u32; - hir.assertz v264 #[code = 250]; - v265 = hir.int_to_ptr v262 : ptr; - hir.store v265, v259; + v278 = arith.mod v276, v704 : u32; + hir.assertz v278 #[code = 250]; + v279 = hir.int_to_ptr v276 : ptr; + hir.store v279, v273; + v280 = hir.bitcast v678 : u32; v703 = arith.constant 8 : u32; - v266 = hir.bitcast v675 : u32; - v268 = arith.add v266, v703 : u32 #[overflow = checked]; + v282 = arith.mod v280, v703 : u32; + hir.assertz v282 #[code = 250]; + v283 = hir.int_to_ptr v280 : ptr; + v284 = hir.load v283 : i64; + v286 = arith.constant 96 : u32; + v285 = hir.bitcast v678 : u32; + v287 = arith.add v285, v286 : u32 #[overflow = checked]; v702 = arith.constant 8 : u32; - v270 = arith.mod v268, v702 : u32; - hir.assertz v270 #[code = 250]; - v271 = hir.int_to_ptr v268 : ptr; - v272 = hir.load v271 : i64; - v274 = arith.constant 104 : u32; - v273 = hir.bitcast v675 : u32; - v275 = arith.add v273, v274 : u32 #[overflow = checked]; - v701 = arith.constant 8 : u32; - v277 = arith.mod v275, v701 : u32; - hir.assertz v277 #[code = 250]; - v278 = hir.int_to_ptr v275 : ptr; - hir.store v278, v272; - v279 = hir.bitcast v675 : u32; - v700 = arith.constant 8 : u32; - v281 = arith.mod v279, v700 : u32; - hir.assertz v281 #[code = 250]; - v282 = hir.int_to_ptr v279 : ptr; - v283 = hir.load v282 : i64; - v285 = arith.constant 96 : u32; - v284 = hir.bitcast v675 : u32; - v286 = arith.add v284, v285 : u32 #[overflow = checked]; - v699 = arith.constant 8 : u32; - v288 = arith.mod v286, v699 : u32; - hir.assertz v288 #[code = 250]; - v289 = hir.int_to_ptr v286 : ptr; - hir.store v289, v283; - v290 = arith.constant 128 : i32; - v291 = arith.add v675, v290 : i32 #[overflow = wrapping]; - hir.exec @miden:counter-contract/counter@0.1.0/counter_contract/>::from(v291, v239) - v696 = arith.constant 128 : i32; - v298 = arith.add v675, v696 : i32 #[overflow = wrapping]; - v295 = arith.constant 96 : i32; - v296 = arith.add v675, v295 : i32 #[overflow = wrapping]; - v697 = arith.constant 0 : i32; - v698 = arith.constant 32 : i32; - v293 = arith.add v675, v698 : i32 #[overflow = wrapping]; - hir.exec @miden:counter-contract/counter@0.1.0/counter_contract/miden_base_sys::bindings::storage::set_map_item(v293, v697, v296, v298) - v300 = builtin.global_symbol @miden:counter-contract/counter@0.1.0/counter_contract/__stack_pointer : ptr - v301 = hir.bitcast v300 : ptr; - hir.store v301, v676; - builtin.ret v239; + v289 = arith.mod v287, v702 : u32; + hir.assertz v289 #[code = 250]; + v290 = hir.int_to_ptr v287 : ptr; + hir.store v290, v284; + v291 = arith.constant 128 : i32; + v292 = arith.add v678, v291 : i32 #[overflow = wrapping]; + hir.exec @miden:counter-contract/counter@0.1.0/counter_contract/>::from(v292, v240) + v699 = arith.constant 128 : i32; + v299 = arith.add v678, v699 : i32 #[overflow = wrapping]; + v296 = arith.constant 96 : i32; + v297 = arith.add v678, v296 : i32 #[overflow = wrapping]; + v700 = arith.constant 0 : i32; + v701 = arith.constant 32 : i32; + v294 = arith.add v678, v701 : i32 #[overflow = wrapping]; + hir.exec @miden:counter-contract/counter@0.1.0/counter_contract/miden_base_sys::bindings::storage::set_map_item(v294, v700, v297, v299) + v238 = arith.constant 1 : i32; + hir.exec @miden:counter-contract/counter@0.1.0/counter_contract/miden_base_sys::bindings::account::incr_nonce(v238) + v302 = builtin.global_symbol @miden:counter-contract/counter@0.1.0/counter_contract/__stack_pointer : ptr + v303 = hir.bitcast v302 : ptr; + hir.store v303, v679; + builtin.ret v240; }; - public builtin.function @cabi_realloc_wit_bindgen_0_28_0(v302: i32, v303: i32, v304: i32, v305: i32) -> i32 { - ^block35(v302: i32, v303: i32, v304: i32, v305: i32): - v307 = hir.exec @miden:counter-contract/counter@0.1.0/counter_contract/wit_bindgen_rt::cabi_realloc(v302, v303, v304, v305) : i32 - builtin.ret v307; + public builtin.function @cabi_realloc_wit_bindgen_0_28_0(v304: i32, v305: i32, v306: i32, v307: i32) -> i32 { + ^block37(v304: i32, v305: i32, v306: i32, v307: i32): + v309 = hir.exec @miden:counter-contract/counter@0.1.0/counter_contract/wit_bindgen_rt::cabi_realloc(v304, v305, v306, v307) : i32 + builtin.ret v309; }; - private builtin.function @wit_bindgen_rt::cabi_realloc(v308: i32, v309: i32, v310: i32, v311: i32) -> i32 { - ^block37(v308: i32, v309: i32, v310: i32, v311: i32): - v313 = arith.constant 0 : i32; - v314 = arith.neq v309, v313 : i1; - v729, v730, v731 = scf.if v314 : i32, i32, u32 { - ^block41: - v329 = hir.exec @miden:counter-contract/counter@0.1.0/counter_contract/__rustc::__rust_realloc(v308, v309, v310, v311) : i32 - v720 = arith.constant 0 : u32; - v724 = ub.poison i32 : i32; - scf.yield v329, v724, v720; + private builtin.function @wit_bindgen_rt::cabi_realloc(v310: i32, v311: i32, v312: i32, v313: i32) -> i32 { + ^block39(v310: i32, v311: i32, v312: i32, v313: i32): + v315 = arith.constant 0 : i32; + v316 = arith.neq v311, v315 : i1; + v732, v733, v734 = scf.if v316 : i32, i32, u32 { + ^block43: + v331 = hir.exec @miden:counter-contract/counter@0.1.0/counter_contract/__rustc::__rust_realloc(v310, v311, v312, v313) : i32 + v723 = arith.constant 0 : u32; + v727 = ub.poison i32 : i32; + scf.yield v331, v727, v723; } else { - ^block42: - v754 = arith.constant 0 : i32; - v755 = arith.constant 0 : i32; - v316 = arith.eq v311, v755 : i1; - v317 = arith.zext v316 : u32; - v318 = hir.bitcast v317 : i32; - v320 = arith.neq v318, v754 : i1; - v740, v741, v742 = scf.if v320 : i32, i32, u32 { - ^block89: - v725 = arith.constant 1 : u32; - v753 = ub.poison i32 : i32; - scf.yield v753, v310, v725; + ^block44: + v757 = arith.constant 0 : i32; + v758 = arith.constant 0 : i32; + v318 = arith.eq v313, v758 : i1; + v319 = arith.zext v318 : u32; + v320 = hir.bitcast v319 : i32; + v322 = arith.neq v320, v757 : i1; + v743, v744, v745 = scf.if v322 : i32, i32, u32 { + ^block93: + v728 = arith.constant 1 : u32; + v756 = ub.poison i32 : i32; + scf.yield v756, v312, v728; } else { - ^block43: - v328 = hir.exec @miden:counter-contract/counter@0.1.0/counter_contract/__rustc::__rust_alloc(v311, v310) : i32 - v751 = arith.constant 0 : u32; - v752 = ub.poison i32 : i32; - scf.yield v328, v752, v751; + ^block45: + v330 = hir.exec @miden:counter-contract/counter@0.1.0/counter_contract/__rustc::__rust_alloc(v313, v312) : i32 + v754 = arith.constant 0 : u32; + v755 = ub.poison i32 : i32; + scf.yield v330, v755, v754; }; - scf.yield v740, v741, v742; + scf.yield v743, v744, v745; }; - v736, v737 = scf.index_switch v731 : i32, u32 + v739, v740 = scf.index_switch v734 : i32, u32 case 0 { - ^block40: - v749 = arith.constant 0 : i32; - v332 = arith.neq v729, v749 : i1; - v738, v739 = scf.if v332 : i32, u32 { - ^block90: - v748 = arith.constant 0 : u32; - scf.yield v729, v748; + ^block42: + v752 = arith.constant 0 : i32; + v334 = arith.neq v732, v752 : i1; + v741, v742 = scf.if v334 : i32, u32 { + ^block94: + v751 = arith.constant 0 : u32; + scf.yield v732, v751; } else { - ^block44: - v746 = arith.constant 1 : u32; - v747 = ub.poison i32 : i32; - scf.yield v747, v746; + ^block46: + v749 = arith.constant 1 : u32; + v750 = ub.poison i32 : i32; + scf.yield v750, v749; }; - scf.yield v738, v739; + scf.yield v741, v742; } default { - ^block96: - v750 = arith.constant 0 : u32; - scf.yield v730, v750; + ^block100: + v753 = arith.constant 0 : u32; + scf.yield v733, v753; }; - v745 = arith.constant 0 : u32; - v744 = arith.eq v737, v745 : i1; - cf.cond_br v744 ^block91, ^block92; - ^block91: - builtin.ret v736; - ^block92: + v748 = arith.constant 0 : u32; + v747 = arith.eq v740, v748 : i1; + cf.cond_br v747 ^block95, ^block96; + ^block95: + builtin.ret v739; + ^block96: ub.unreachable ; }; private builtin.function @wit_bindgen_rt::run_ctors_once() { - ^block45: - v336 = arith.constant 1048617 : u32; - v759 = arith.constant 0 : u32; - v337 = arith.add v759, v336 : u32 #[overflow = checked]; - v338 = hir.int_to_ptr v337 : ptr; - v339 = hir.load v338 : u8; - v334 = arith.constant 0 : i32; - v340 = arith.zext v339 : u32; - v341 = hir.bitcast v340 : i32; - v343 = arith.neq v341, v334 : i1; - scf.if v343{ - ^block47: + ^block47: + v338 = arith.constant 1048617 : u32; + v762 = arith.constant 0 : u32; + v339 = arith.add v762, v338 : u32 #[overflow = checked]; + v340 = hir.int_to_ptr v339 : ptr; + v341 = hir.load v340 : u8; + v336 = arith.constant 0 : i32; + v342 = arith.zext v341 : u32; + v343 = hir.bitcast v342 : i32; + v345 = arith.neq v343, v336 : i1; + scf.if v345{ + ^block49: scf.yield ; } else { - ^block48: + ^block50: hir.exec @miden:counter-contract/counter@0.1.0/counter_contract/__wasm_call_ctors() - v757 = arith.constant 1 : u8; - v761 = arith.constant 1048617 : u32; - v762 = arith.constant 0 : u32; - v350 = arith.add v762, v761 : u32 #[overflow = checked]; - v351 = hir.int_to_ptr v350 : ptr; - hir.store v351, v757; + v760 = arith.constant 1 : u8; + v764 = arith.constant 1048617 : u32; + v765 = arith.constant 0 : u32; + v352 = arith.add v765, v764 : u32 #[overflow = checked]; + v353 = hir.int_to_ptr v352 : ptr; + hir.store v353, v760; scf.yield ; }; builtin.ret ; }; - private builtin.function @::alloc(v352: i32, v353: i32, v354: i32) -> i32 { - ^block49(v352: i32, v353: i32, v354: i32): - v357 = arith.constant 32 : i32; - v356 = arith.constant 0 : i32; - v764 = arith.constant 32 : u32; - v359 = hir.bitcast v353 : u32; - v361 = arith.gt v359, v764 : i1; - v362 = arith.zext v361 : u32; - v363 = hir.bitcast v362 : i32; - v365 = arith.neq v363, v356 : i1; - v366 = cf.select v365, v353, v357 : i32; - v801 = arith.constant 0 : i32; - v367 = arith.constant -1 : i32; - v368 = arith.add v366, v367 : i32 #[overflow = wrapping]; - v369 = arith.band v366, v368 : i32; - v371 = arith.neq v369, v801 : i1; - v773, v774 = scf.if v371 : i32, u32 { - ^block101: - v765 = arith.constant 0 : u32; - v769 = ub.poison i32 : i32; - scf.yield v769, v765; + private builtin.function @::alloc(v354: i32, v355: i32, v356: i32) -> i32 { + ^block51(v354: i32, v355: i32, v356: i32): + v359 = arith.constant 32 : i32; + v358 = arith.constant 0 : i32; + v767 = arith.constant 32 : u32; + v361 = hir.bitcast v355 : u32; + v363 = arith.gt v361, v767 : i1; + v364 = arith.zext v363 : u32; + v365 = hir.bitcast v364 : i32; + v367 = arith.neq v365, v358 : i1; + v368 = cf.select v367, v355, v359 : i32; + v804 = arith.constant 0 : i32; + v369 = arith.constant -1 : i32; + v370 = arith.add v368, v369 : i32 #[overflow = wrapping]; + v371 = arith.band v368, v370 : i32; + v373 = arith.neq v371, v804 : i1; + v776, v777 = scf.if v373 : i32, u32 { + ^block105: + v768 = arith.constant 0 : u32; + v772 = ub.poison i32 : i32; + scf.yield v772, v768; } else { - ^block52: - v373 = hir.exec @miden:counter-contract/counter@0.1.0/counter_contract/core::ptr::alignment::Alignment::max(v353, v366) : i32 - v800 = arith.constant 0 : i32; - v372 = arith.constant -2147483648 : i32; - v374 = arith.sub v372, v373 : i32 #[overflow = wrapping]; - v376 = hir.bitcast v374 : u32; - v375 = hir.bitcast v354 : u32; - v377 = arith.gt v375, v376 : i1; - v378 = arith.zext v377 : u32; - v379 = hir.bitcast v378 : i32; - v381 = arith.neq v379, v800 : i1; - v777, v778 = scf.if v381 : i32, u32 { - ^block100: - v798 = arith.constant 0 : u32; - v799 = ub.poison i32 : i32; - scf.yield v799, v798; + ^block54: + v375 = hir.exec @miden:counter-contract/counter@0.1.0/counter_contract/core::ptr::alignment::Alignment::max(v355, v368) : i32 + v803 = arith.constant 0 : i32; + v374 = arith.constant -2147483648 : i32; + v376 = arith.sub v374, v375 : i32 #[overflow = wrapping]; + v378 = hir.bitcast v376 : u32; + v377 = hir.bitcast v356 : u32; + v379 = arith.gt v377, v378 : i1; + v380 = arith.zext v379 : u32; + v381 = hir.bitcast v380 : i32; + v383 = arith.neq v381, v803 : i1; + v780, v781 = scf.if v383 : i32, u32 { + ^block104: + v801 = arith.constant 0 : u32; + v802 = ub.poison i32 : i32; + scf.yield v802, v801; } else { - ^block53: - v796 = arith.constant 0 : i32; - v387 = arith.sub v796, v373 : i32 #[overflow = wrapping]; - v797 = arith.constant -1 : i32; - v383 = arith.add v354, v373 : i32 #[overflow = wrapping]; - v385 = arith.add v383, v797 : i32 #[overflow = wrapping]; - v388 = arith.band v385, v387 : i32; - v389 = hir.bitcast v352 : u32; - v390 = arith.constant 4 : u32; - v391 = arith.mod v389, v390 : u32; - hir.assertz v391 #[code = 250]; - v392 = hir.int_to_ptr v389 : ptr; - v393 = hir.load v392 : i32; - v795 = arith.constant 0 : i32; - v395 = arith.neq v393, v795 : i1; - v779, v780, v781, v782 = scf.if v395 : i32, i32, i32, i32 { - ^block99: - v794 = arith.constant 0 : i32; - scf.yield v352, v388, v373, v794; + ^block55: + v799 = arith.constant 0 : i32; + v389 = arith.sub v799, v375 : i32 #[overflow = wrapping]; + v800 = arith.constant -1 : i32; + v385 = arith.add v356, v375 : i32 #[overflow = wrapping]; + v387 = arith.add v385, v800 : i32 #[overflow = wrapping]; + v390 = arith.band v387, v389 : i32; + v391 = hir.bitcast v354 : u32; + v392 = arith.constant 4 : u32; + v393 = arith.mod v391, v392 : u32; + hir.assertz v393 #[code = 250]; + v394 = hir.int_to_ptr v391 : ptr; + v395 = hir.load v394 : i32; + v798 = arith.constant 0 : i32; + v397 = arith.neq v395, v798 : i1; + v782, v783, v784, v785 = scf.if v397 : i32, i32, i32, i32 { + ^block103: + v797 = arith.constant 0 : i32; + scf.yield v354, v390, v375, v797; } else { - ^block55: - v396 = hir.exec @intrinsics/mem/heap_base() : i32 - v397 = hir.mem_size : u32; - v403 = hir.bitcast v352 : u32; - v793 = arith.constant 4 : u32; - v405 = arith.mod v403, v793 : u32; - hir.assertz v405 #[code = 250]; - v763 = arith.constant 16 : u32; - v400 = arith.shl v397, v763 : u32; - v401 = hir.bitcast v400 : i32; - v402 = arith.add v396, v401 : i32 #[overflow = wrapping]; - v406 = hir.int_to_ptr v403 : ptr; - hir.store v406, v402; - v792 = arith.constant 0 : i32; - scf.yield v352, v388, v373, v792; + ^block57: + v398 = hir.exec @intrinsics/mem/heap_base() : i32 + v399 = hir.mem_size : u32; + v405 = hir.bitcast v354 : u32; + v796 = arith.constant 4 : u32; + v407 = arith.mod v405, v796 : u32; + hir.assertz v407 #[code = 250]; + v766 = arith.constant 16 : u32; + v402 = arith.shl v399, v766 : u32; + v403 = hir.bitcast v402 : i32; + v404 = arith.add v398, v403 : i32 #[overflow = wrapping]; + v408 = hir.int_to_ptr v405 : ptr; + hir.store v408, v404; + v795 = arith.constant 0 : i32; + scf.yield v354, v390, v375, v795; }; - v409 = hir.bitcast v779 : u32; - v791 = arith.constant 4 : u32; - v411 = arith.mod v409, v791 : u32; - hir.assertz v411 #[code = 250]; - v412 = hir.int_to_ptr v409 : ptr; - v413 = hir.load v412 : i32; - v790 = arith.constant 0 : i32; - v417 = hir.bitcast v780 : u32; - v407 = arith.constant 268435456 : i32; - v414 = arith.sub v407, v413 : i32 #[overflow = wrapping]; - v416 = hir.bitcast v414 : u32; - v418 = arith.lt v416, v417 : i1; - v419 = arith.zext v418 : u32; - v420 = hir.bitcast v419 : i32; - v422 = arith.neq v420, v790 : i1; - v783, v784 = scf.if v422 : i32, u32 { - ^block56: - v770 = arith.constant 1 : u32; - scf.yield v782, v770; + v411 = hir.bitcast v782 : u32; + v794 = arith.constant 4 : u32; + v413 = arith.mod v411, v794 : u32; + hir.assertz v413 #[code = 250]; + v414 = hir.int_to_ptr v411 : ptr; + v415 = hir.load v414 : i32; + v793 = arith.constant 0 : i32; + v419 = hir.bitcast v783 : u32; + v409 = arith.constant 268435456 : i32; + v416 = arith.sub v409, v415 : i32 #[overflow = wrapping]; + v418 = hir.bitcast v416 : u32; + v420 = arith.lt v418, v419 : i1; + v421 = arith.zext v420 : u32; + v422 = hir.bitcast v421 : i32; + v424 = arith.neq v422, v793 : i1; + v786, v787 = scf.if v424 : i32, u32 { + ^block58: + v773 = arith.constant 1 : u32; + scf.yield v785, v773; } else { - ^block57: - v424 = hir.bitcast v779 : u32; - v789 = arith.constant 4 : u32; - v426 = arith.mod v424, v789 : u32; - hir.assertz v426 #[code = 250]; - v423 = arith.add v413, v780 : i32 #[overflow = wrapping]; - v427 = hir.int_to_ptr v424 : ptr; - hir.store v427, v423; - v788 = arith.constant 1 : u32; - v429 = arith.add v413, v781 : i32 #[overflow = wrapping]; - scf.yield v429, v788; + ^block59: + v426 = hir.bitcast v782 : u32; + v792 = arith.constant 4 : u32; + v428 = arith.mod v426, v792 : u32; + hir.assertz v428 #[code = 250]; + v425 = arith.add v415, v783 : i32 #[overflow = wrapping]; + v429 = hir.int_to_ptr v426 : ptr; + hir.store v429, v425; + v791 = arith.constant 1 : u32; + v431 = arith.add v415, v784 : i32 #[overflow = wrapping]; + scf.yield v431, v791; }; - scf.yield v783, v784; + scf.yield v786, v787; }; - scf.yield v777, v778; + scf.yield v780, v781; }; - v787 = arith.constant 0 : u32; - v786 = arith.eq v774, v787 : i1; - cf.cond_br v786 ^block51, ^block103(v773); - ^block51: + v790 = arith.constant 0 : u32; + v789 = arith.eq v777, v790 : i1; + cf.cond_br v789 ^block53, ^block107(v776); + ^block53: ub.unreachable ; - ^block103(v766: i32): - builtin.ret v766; + ^block107(v769: i32): + builtin.ret v769; + }; + + private builtin.function @miden_base_sys::bindings::account::incr_nonce(v434: i32) { + ^block60(v434: i32): + hir.exec @miden:counter-contract/counter@0.1.0/counter_contract/miden_base_sys::bindings::account::extern_account_incr_nonce(v434) + builtin.ret ; }; - private builtin.function @miden_base_sys::bindings::storage::get_map_item(v432: i32, v433: i32, v434: i32) { - ^block58(v432: i32, v433: i32, v434: i32): - v438 = hir.bitcast v434 : u32; - v439 = arith.constant 4 : u32; - v440 = arith.mod v438, v439 : u32; - hir.assertz v440 #[code = 250]; - v441 = hir.int_to_ptr v438 : ptr; - v442 = hir.load v441 : felt; + private builtin.function @miden_base_sys::bindings::storage::get_map_item(v435: i32, v436: i32, v437: i32) { + ^block62(v435: i32, v436: i32, v437: i32): + v441 = hir.bitcast v437 : u32; + v442 = arith.constant 4 : u32; + v443 = arith.mod v441, v442 : u32; + hir.assertz v443 #[code = 250]; + v444 = hir.int_to_ptr v441 : ptr; + v445 = hir.load v444 : felt; + v808 = arith.constant 4 : u32; + v446 = hir.bitcast v437 : u32; + v448 = arith.add v446, v808 : u32 #[overflow = checked]; + v807 = arith.constant 4 : u32; + v450 = arith.mod v448, v807 : u32; + hir.assertz v450 #[code = 250]; + v451 = hir.int_to_ptr v448 : ptr; + v452 = hir.load v451 : felt; + v454 = arith.constant 8 : u32; + v453 = hir.bitcast v437 : u32; + v455 = arith.add v453, v454 : u32 #[overflow = checked]; + v806 = arith.constant 4 : u32; + v457 = arith.mod v455, v806 : u32; + hir.assertz v457 #[code = 250]; + v458 = hir.int_to_ptr v455 : ptr; + v459 = hir.load v458 : felt; + v461 = arith.constant 12 : u32; + v460 = hir.bitcast v437 : u32; + v462 = arith.add v460, v461 : u32 #[overflow = checked]; v805 = arith.constant 4 : u32; - v443 = hir.bitcast v434 : u32; - v445 = arith.add v443, v805 : u32 #[overflow = checked]; - v804 = arith.constant 4 : u32; - v447 = arith.mod v445, v804 : u32; - hir.assertz v447 #[code = 250]; - v448 = hir.int_to_ptr v445 : ptr; - v449 = hir.load v448 : felt; - v451 = arith.constant 8 : u32; - v450 = hir.bitcast v434 : u32; - v452 = arith.add v450, v451 : u32 #[overflow = checked]; - v803 = arith.constant 4 : u32; - v454 = arith.mod v452, v803 : u32; - hir.assertz v454 #[code = 250]; - v455 = hir.int_to_ptr v452 : ptr; - v456 = hir.load v455 : felt; - v458 = arith.constant 12 : u32; - v457 = hir.bitcast v434 : u32; - v459 = arith.add v457, v458 : u32 #[overflow = checked]; - v802 = arith.constant 4 : u32; - v461 = arith.mod v459, v802 : u32; - hir.assertz v461 #[code = 250]; - v462 = hir.int_to_ptr v459 : ptr; - v463 = hir.load v462 : felt; - v435 = arith.constant 255 : i32; - v436 = arith.band v433, v435 : i32; - v437 = hir.bitcast v436 : felt; - hir.exec @miden:counter-contract/counter@0.1.0/counter_contract/miden_base_sys::bindings::storage::extern_get_storage_map_item(v437, v442, v449, v456, v463, v432) + v464 = arith.mod v462, v805 : u32; + hir.assertz v464 #[code = 250]; + v465 = hir.int_to_ptr v462 : ptr; + v466 = hir.load v465 : felt; + v438 = arith.constant 255 : i32; + v439 = arith.band v436, v438 : i32; + v440 = hir.bitcast v439 : felt; + hir.exec @miden:counter-contract/counter@0.1.0/counter_contract/miden_base_sys::bindings::storage::extern_get_storage_map_item(v440, v445, v452, v459, v466, v435) builtin.ret ; }; - private builtin.function @miden_base_sys::bindings::storage::set_map_item(v464: i32, v465: i32, v466: i32, v467: i32) { - ^block60(v464: i32, v465: i32, v466: i32, v467: i32): - v471 = hir.bitcast v466 : u32; - v472 = arith.constant 4 : u32; - v473 = arith.mod v471, v472 : u32; - hir.assertz v473 #[code = 250]; - v474 = hir.int_to_ptr v471 : ptr; - v475 = hir.load v474 : felt; + private builtin.function @miden_base_sys::bindings::storage::set_map_item(v467: i32, v468: i32, v469: i32, v470: i32) { + ^block64(v467: i32, v468: i32, v469: i32, v470: i32): + v474 = hir.bitcast v469 : u32; + v475 = arith.constant 4 : u32; + v476 = arith.mod v474, v475 : u32; + hir.assertz v476 #[code = 250]; + v477 = hir.int_to_ptr v474 : ptr; + v478 = hir.load v477 : felt; + v819 = arith.constant 4 : u32; + v479 = hir.bitcast v469 : u32; + v481 = arith.add v479, v819 : u32 #[overflow = checked]; + v818 = arith.constant 4 : u32; + v483 = arith.mod v481, v818 : u32; + hir.assertz v483 #[code = 250]; + v484 = hir.int_to_ptr v481 : ptr; + v485 = hir.load v484 : felt; + v487 = arith.constant 8 : u32; + v486 = hir.bitcast v469 : u32; + v488 = arith.add v486, v487 : u32 #[overflow = checked]; + v817 = arith.constant 4 : u32; + v490 = arith.mod v488, v817 : u32; + hir.assertz v490 #[code = 250]; + v491 = hir.int_to_ptr v488 : ptr; + v492 = hir.load v491 : felt; + v494 = arith.constant 12 : u32; + v493 = hir.bitcast v469 : u32; + v495 = arith.add v493, v494 : u32 #[overflow = checked]; v816 = arith.constant 4 : u32; - v476 = hir.bitcast v466 : u32; - v478 = arith.add v476, v816 : u32 #[overflow = checked]; + v497 = arith.mod v495, v816 : u32; + hir.assertz v497 #[code = 250]; + v498 = hir.int_to_ptr v495 : ptr; + v499 = hir.load v498 : felt; + v500 = hir.bitcast v470 : u32; v815 = arith.constant 4 : u32; - v480 = arith.mod v478, v815 : u32; - hir.assertz v480 #[code = 250]; - v481 = hir.int_to_ptr v478 : ptr; - v482 = hir.load v481 : felt; - v484 = arith.constant 8 : u32; - v483 = hir.bitcast v466 : u32; - v485 = arith.add v483, v484 : u32 #[overflow = checked]; + v502 = arith.mod v500, v815 : u32; + hir.assertz v502 #[code = 250]; + v503 = hir.int_to_ptr v500 : ptr; + v504 = hir.load v503 : felt; v814 = arith.constant 4 : u32; - v487 = arith.mod v485, v814 : u32; - hir.assertz v487 #[code = 250]; - v488 = hir.int_to_ptr v485 : ptr; - v489 = hir.load v488 : felt; - v491 = arith.constant 12 : u32; - v490 = hir.bitcast v466 : u32; - v492 = arith.add v490, v491 : u32 #[overflow = checked]; + v505 = hir.bitcast v470 : u32; + v507 = arith.add v505, v814 : u32 #[overflow = checked]; v813 = arith.constant 4 : u32; - v494 = arith.mod v492, v813 : u32; - hir.assertz v494 #[code = 250]; - v495 = hir.int_to_ptr v492 : ptr; - v496 = hir.load v495 : felt; - v497 = hir.bitcast v467 : u32; - v812 = arith.constant 4 : u32; - v499 = arith.mod v497, v812 : u32; - hir.assertz v499 #[code = 250]; - v500 = hir.int_to_ptr v497 : ptr; - v501 = hir.load v500 : felt; + v509 = arith.mod v507, v813 : u32; + hir.assertz v509 #[code = 250]; + v510 = hir.int_to_ptr v507 : ptr; + v511 = hir.load v510 : felt; + v812 = arith.constant 8 : u32; + v512 = hir.bitcast v470 : u32; + v514 = arith.add v512, v812 : u32 #[overflow = checked]; v811 = arith.constant 4 : u32; - v502 = hir.bitcast v467 : u32; - v504 = arith.add v502, v811 : u32 #[overflow = checked]; - v810 = arith.constant 4 : u32; - v506 = arith.mod v504, v810 : u32; - hir.assertz v506 #[code = 250]; - v507 = hir.int_to_ptr v504 : ptr; - v508 = hir.load v507 : felt; - v809 = arith.constant 8 : u32; - v509 = hir.bitcast v467 : u32; - v511 = arith.add v509, v809 : u32 #[overflow = checked]; - v808 = arith.constant 4 : u32; - v513 = arith.mod v511, v808 : u32; - hir.assertz v513 #[code = 250]; - v514 = hir.int_to_ptr v511 : ptr; - v515 = hir.load v514 : felt; - v807 = arith.constant 12 : u32; - v516 = hir.bitcast v467 : u32; - v518 = arith.add v516, v807 : u32 #[overflow = checked]; - v806 = arith.constant 4 : u32; - v520 = arith.mod v518, v806 : u32; - hir.assertz v520 #[code = 250]; - v521 = hir.int_to_ptr v518 : ptr; - v522 = hir.load v521 : felt; - v468 = arith.constant 255 : i32; - v469 = arith.band v465, v468 : i32; - v470 = hir.bitcast v469 : felt; - hir.exec @miden:counter-contract/counter@0.1.0/counter_contract/miden_base_sys::bindings::storage::extern_set_storage_map_item(v470, v475, v482, v489, v496, v501, v508, v515, v522, v464) + v516 = arith.mod v514, v811 : u32; + hir.assertz v516 #[code = 250]; + v517 = hir.int_to_ptr v514 : ptr; + v518 = hir.load v517 : felt; + v810 = arith.constant 12 : u32; + v519 = hir.bitcast v470 : u32; + v521 = arith.add v519, v810 : u32 #[overflow = checked]; + v809 = arith.constant 4 : u32; + v523 = arith.mod v521, v809 : u32; + hir.assertz v523 #[code = 250]; + v524 = hir.int_to_ptr v521 : ptr; + v525 = hir.load v524 : felt; + v471 = arith.constant 255 : i32; + v472 = arith.band v468, v471 : i32; + v473 = hir.bitcast v472 : felt; + hir.exec @miden:counter-contract/counter@0.1.0/counter_contract/miden_base_sys::bindings::storage::extern_set_storage_map_item(v473, v478, v485, v492, v499, v504, v511, v518, v525, v467) builtin.ret ; }; - private builtin.function @>::from(v523: i32, v524: felt) { - ^block62(v523: i32, v524: felt): - v533 = arith.constant 12 : u32; - v532 = hir.bitcast v523 : u32; - v534 = arith.add v532, v533 : u32 #[overflow = checked]; - v535 = arith.constant 4 : u32; - v536 = arith.mod v534, v535 : u32; - hir.assertz v536 #[code = 250]; - v537 = hir.int_to_ptr v534 : ptr; - hir.store v537, v524; - v539 = arith.constant 8 : u32; - v538 = hir.bitcast v523 : u32; - v540 = arith.add v538, v539 : u32 #[overflow = checked]; - v825 = arith.constant 4 : u32; - v542 = arith.mod v540, v825 : u32; - hir.assertz v542 #[code = 250]; - v819 = arith.constant 0 : felt; - v543 = hir.int_to_ptr v540 : ptr; - hir.store v543, v819; - v824 = arith.constant 4 : u32; - v544 = hir.bitcast v523 : u32; - v546 = arith.add v544, v824 : u32 #[overflow = checked]; - v823 = arith.constant 4 : u32; - v548 = arith.mod v546, v823 : u32; - hir.assertz v548 #[code = 250]; + private builtin.function @>::from(v526: i32, v527: felt) { + ^block66(v526: i32, v527: felt): + v536 = arith.constant 12 : u32; + v535 = hir.bitcast v526 : u32; + v537 = arith.add v535, v536 : u32 #[overflow = checked]; + v538 = arith.constant 4 : u32; + v539 = arith.mod v537, v538 : u32; + hir.assertz v539 #[code = 250]; + v540 = hir.int_to_ptr v537 : ptr; + hir.store v540, v527; + v542 = arith.constant 8 : u32; + v541 = hir.bitcast v526 : u32; + v543 = arith.add v541, v542 : u32 #[overflow = checked]; + v828 = arith.constant 4 : u32; + v545 = arith.mod v543, v828 : u32; + hir.assertz v545 #[code = 250]; v822 = arith.constant 0 : felt; - v549 = hir.int_to_ptr v546 : ptr; - hir.store v549, v822; - v550 = hir.bitcast v523 : u32; - v821 = arith.constant 4 : u32; - v552 = arith.mod v550, v821 : u32; - hir.assertz v552 #[code = 250]; - v820 = arith.constant 0 : felt; - v553 = hir.int_to_ptr v550 : ptr; - hir.store v553, v820; + v546 = hir.int_to_ptr v543 : ptr; + hir.store v546, v822; + v827 = arith.constant 4 : u32; + v547 = hir.bitcast v526 : u32; + v549 = arith.add v547, v827 : u32 #[overflow = checked]; + v826 = arith.constant 4 : u32; + v551 = arith.mod v549, v826 : u32; + hir.assertz v551 #[code = 250]; + v825 = arith.constant 0 : felt; + v552 = hir.int_to_ptr v549 : ptr; + hir.store v552, v825; + v553 = hir.bitcast v526 : u32; + v824 = arith.constant 4 : u32; + v555 = arith.mod v553, v824 : u32; + hir.assertz v555 #[code = 250]; + v823 = arith.constant 0 : felt; + v556 = hir.int_to_ptr v553 : ptr; + hir.store v556, v823; builtin.ret ; }; - private builtin.function @core::ptr::alignment::Alignment::max(v554: i32, v555: i32) -> i32 { - ^block64(v554: i32, v555: i32): - v562 = arith.constant 0 : i32; - v558 = hir.bitcast v555 : u32; - v557 = hir.bitcast v554 : u32; - v559 = arith.gt v557, v558 : i1; - v560 = arith.zext v559 : u32; - v561 = hir.bitcast v560 : i32; - v563 = arith.neq v561, v562 : i1; - v564 = cf.select v563, v554, v555 : i32; - builtin.ret v564; + private builtin.function @core::ptr::alignment::Alignment::max(v557: i32, v558: i32) -> i32 { + ^block68(v557: i32, v558: i32): + v565 = arith.constant 0 : i32; + v561 = hir.bitcast v558 : u32; + v560 = hir.bitcast v557 : u32; + v562 = arith.gt v560, v561 : i1; + v563 = arith.zext v562 : u32; + v564 = hir.bitcast v563 : i32; + v566 = arith.neq v564, v565 : i1; + v567 = cf.select v566, v557, v558 : i32; + builtin.ret v567; }; - public builtin.function @cabi_realloc(v565: i32, v566: i32, v567: i32, v568: i32) -> i32 { - ^block66(v565: i32, v566: i32, v567: i32, v568: i32): - v570 = hir.exec @miden:counter-contract/counter@0.1.0/counter_contract/cabi_realloc_wit_bindgen_0_28_0(v565, v566, v567, v568) : i32 - builtin.ret v570; + public builtin.function @cabi_realloc(v568: i32, v569: i32, v570: i32, v571: i32) -> i32 { + ^block70(v568: i32, v569: i32, v570: i32, v571: i32): + v573 = hir.exec @miden:counter-contract/counter@0.1.0/counter_contract/cabi_realloc_wit_bindgen_0_28_0(v568, v569, v570, v571) : i32 + builtin.ret v573; }; builtin.global_variable private @#__stack_pointer : i32 { @@ -791,14 +805,14 @@ builtin.component miden:counter-contract/counter@0.1.0 { }; public builtin.function @get-count() -> felt { - ^block68: - v571 = hir.exec @miden:counter-contract/counter@0.1.0/counter_contract/miden:counter-contract/counter@0.1.0#get-count() : felt - builtin.ret v571; + ^block72: + v574 = hir.exec @miden:counter-contract/counter@0.1.0/counter_contract/miden:counter-contract/counter@0.1.0#get-count() : felt + builtin.ret v574; }; public builtin.function @increment-count() -> felt { - ^block70: - v572 = hir.exec @miden:counter-contract/counter@0.1.0/counter_contract/miden:counter-contract/counter@0.1.0#increment-count() : felt - builtin.ret v572; + ^block74: + v575 = hir.exec @miden:counter-contract/counter@0.1.0/counter_contract/miden:counter-contract/counter@0.1.0#increment-count() : felt + builtin.ret v575; }; }; \ No newline at end of file diff --git a/tests/integration/expected/examples/counter.masm b/tests/integration/expected/examples/counter.masm index 069b45d76..cb1122b65 100644 --- a/tests/integration/expected/examples/counter.masm +++ b/tests/integration/expected/examples/counter.masm @@ -27,6 +27,10 @@ end # mod miden:counter-contract/counter@0.1.0::counter_contract +proc.miden_base_sys::bindings::account::extern_account_incr_nonce + exec.::miden::account::incr_nonce +end + proc.miden_base_sys::bindings::storage::extern_get_storage_map_item exec.::miden::account::get_map_item movup.4 @@ -710,6 +714,8 @@ export.miden:counter-contract/counter@0.1.0#increment-count swap.1 u32wrapping_add exec.::miden:counter-contract/counter@0.1.0::counter_contract::miden_base_sys::bindings::storage::set_map_item + push.1 + exec.::miden:counter-contract/counter@0.1.0::counter_contract::miden_base_sys::bindings::account::incr_nonce push.1048576 movup.2 swap.1 @@ -978,6 +984,10 @@ proc.::alloc end end +proc.miden_base_sys::bindings::account::incr_nonce + exec.::miden:counter-contract/counter@0.1.0::counter_contract::miden_base_sys::bindings::account::extern_account_incr_nonce +end + proc.miden_base_sys::bindings::storage::get_map_item dup.2 push.4 diff --git a/tests/integration/expected/examples/counter.wat b/tests/integration/expected/examples/counter.wat index 6edfd3bea..4e52e6938 100644 --- a/tests/integration/expected/examples/counter.wat +++ b/tests/integration/expected/examples/counter.wat @@ -21,6 +21,8 @@ (export (;0;) "get-map-item" (func (type 0))) (type (;1;) (func (param "index" f32) (param "key0" f32) (param "key1" f32) (param "key2" f32) (param "key3" f32) (param "value0" f32) (param "value1" f32) (param "value2" f32) (param "value3" f32) (param "result-ptr" s32))) (export (;1;) "set-map-item" (func (type 1))) + (type (;2;) (func (param "value" u32))) + (export (;2;) "incr-nonce" (func (type 2))) ) ) (import "miden:core-import/account@1.0.0" (instance (;2;) (type 2))) @@ -35,21 +37,23 @@ (type (;0;) (func (param i32) (result f32))) (type (;1;) (func (param f32 f32) (result f32))) (type (;2;) (func (result i32))) - (type (;3;) (func (param f32 f32 f32 f32 f32 i32))) - (type (;4;) (func (param f32 f32 f32 f32 f32 f32 f32 f32 f32 i32))) - (type (;5;) (func)) - (type (;6;) (func (param i32 i32) (result i32))) - (type (;7;) (func (param i32 i32 i32 i32) (result i32))) - (type (;8;) (func (result f32))) - (type (;9;) (func (param i32 i32 i32) (result i32))) - (type (;10;) (func (param i32 i32 i32))) - (type (;11;) (func (param i32 i32 i32 i32))) - (type (;12;) (func (param i32 f32))) + (type (;3;) (func (param i32))) + (type (;4;) (func (param f32 f32 f32 f32 f32 i32))) + (type (;5;) (func (param f32 f32 f32 f32 f32 f32 f32 f32 f32 i32))) + (type (;6;) (func)) + (type (;7;) (func (param i32 i32) (result i32))) + (type (;8;) (func (param i32 i32 i32 i32) (result i32))) + (type (;9;) (func (result f32))) + (type (;10;) (func (param i32 i32 i32) (result i32))) + (type (;11;) (func (param i32 i32 i32))) + (type (;12;) (func (param i32 i32 i32 i32))) + (type (;13;) (func (param i32 f32))) (import "miden:core-import/intrinsics-felt@1.0.0" "from-u32" (func $miden_stdlib_sys::intrinsics::felt::extern_from_u32 (;0;) (type 0))) (import "miden:core-import/intrinsics-felt@1.0.0" "add" (func $miden_stdlib_sys::intrinsics::felt::extern_add (;1;) (type 1))) (import "miden:core-import/intrinsics-mem@1.0.0" "heap-base" (func $miden_sdk_alloc::heap_base (;2;) (type 2))) - (import "miden:core-import/account@1.0.0" "get-map-item" (func $miden_base_sys::bindings::storage::extern_get_storage_map_item (;3;) (type 3))) - (import "miden:core-import/account@1.0.0" "set-map-item" (func $miden_base_sys::bindings::storage::extern_set_storage_map_item (;4;) (type 4))) + (import "miden:core-import/account@1.0.0" "incr-nonce" (func $miden_base_sys::bindings::account::extern_account_incr_nonce (;3;) (type 3))) + (import "miden:core-import/account@1.0.0" "get-map-item" (func $miden_base_sys::bindings::storage::extern_get_storage_map_item (;4;) (type 4))) + (import "miden:core-import/account@1.0.0" "set-map-item" (func $miden_base_sys::bindings::storage::extern_set_storage_map_item (;5;) (type 5))) (table (;0;) 3 3 funcref) (memory (;0;) 17) (global $__stack_pointer (;0;) (mut i32) i32.const 1048576) @@ -59,15 +63,15 @@ (export "cabi_realloc_wit_bindgen_0_28_0" (func $cabi_realloc_wit_bindgen_0_28_0)) (export "cabi_realloc" (func $cabi_realloc)) (elem (;0;) (i32.const 1) func $counter_contract::bindings::__link_custom_section_describing_imports $cabi_realloc) - (func $__wasm_call_ctors (;5;) (type 5)) - (func $counter_contract::bindings::__link_custom_section_describing_imports (;6;) (type 5)) - (func $__rustc::__rust_alloc (;7;) (type 6) (param i32 i32) (result i32) + (func $__wasm_call_ctors (;6;) (type 6)) + (func $counter_contract::bindings::__link_custom_section_describing_imports (;7;) (type 6)) + (func $__rustc::__rust_alloc (;8;) (type 7) (param i32 i32) (result i32) i32.const 1048612 local.get 1 local.get 0 call $::alloc ) - (func $__rustc::__rust_realloc (;8;) (type 7) (param i32 i32 i32 i32) (result i32) + (func $__rustc::__rust_realloc (;9;) (type 8) (param i32 i32 i32 i32) (result i32) block ;; label = @1 i32.const 1048612 local.get 2 @@ -92,7 +96,7 @@ end local.get 2 ) - (func $miden:counter-contract/counter@0.1.0#get-count (;9;) (type 8) (result f32) + (func $miden:counter-contract/counter@0.1.0#get-count (;10;) (type 9) (result f32) (local i32 i32 i32 f32) global.get $__stack_pointer local.tee 0 @@ -151,7 +155,7 @@ global.set $__stack_pointer local.get 3 ) - (func $miden:counter-contract/counter@0.1.0#increment-count (;10;) (type 8) (result f32) + (func $miden:counter-contract/counter@0.1.0#increment-count (;11;) (type 9) (result f32) (local i32 i32 i32 f32) global.get $__stack_pointer local.tee 0 @@ -241,18 +245,20 @@ i32.const 128 i32.add call $miden_base_sys::bindings::storage::set_map_item + i32.const 1 + call $miden_base_sys::bindings::account::incr_nonce local.get 1 global.set $__stack_pointer local.get 3 ) - (func $cabi_realloc_wit_bindgen_0_28_0 (;11;) (type 7) (param i32 i32 i32 i32) (result i32) + (func $cabi_realloc_wit_bindgen_0_28_0 (;12;) (type 8) (param i32 i32 i32 i32) (result i32) local.get 0 local.get 1 local.get 2 local.get 3 call $wit_bindgen_rt::cabi_realloc ) - (func $wit_bindgen_rt::cabi_realloc (;12;) (type 7) (param i32 i32 i32 i32) (result i32) + (func $wit_bindgen_rt::cabi_realloc (;13;) (type 8) (param i32 i32 i32 i32) (result i32) block ;; label = @1 block ;; label = @2 block ;; label = @3 @@ -283,7 +289,7 @@ end local.get 2 ) - (func $wit_bindgen_rt::run_ctors_once (;13;) (type 5) + (func $wit_bindgen_rt::run_ctors_once (;14;) (type 6) block ;; label = @1 i32.const 0 i32.load8_u offset=1048617 @@ -294,7 +300,7 @@ i32.store8 offset=1048617 end ) - (func $::alloc (;14;) (type 9) (param i32 i32 i32) (result i32) + (func $::alloc (;15;) (type 10) (param i32 i32 i32) (result i32) (local i32 i32) block ;; label = @1 local.get 1 @@ -366,7 +372,11 @@ end unreachable ) - (func $miden_base_sys::bindings::storage::get_map_item (;15;) (type 10) (param i32 i32 i32) + (func $miden_base_sys::bindings::account::incr_nonce (;16;) (type 3) (param i32) + local.get 0 + call $miden_base_sys::bindings::account::extern_account_incr_nonce + ) + (func $miden_base_sys::bindings::storage::get_map_item (;17;) (type 11) (param i32 i32 i32) local.get 1 i32.const 255 i32.and @@ -382,7 +392,7 @@ local.get 0 call $miden_base_sys::bindings::storage::extern_get_storage_map_item ) - (func $miden_base_sys::bindings::storage::set_map_item (;16;) (type 11) (param i32 i32 i32 i32) + (func $miden_base_sys::bindings::storage::set_map_item (;18;) (type 12) (param i32 i32 i32 i32) local.get 1 i32.const 255 i32.and @@ -406,7 +416,7 @@ local.get 0 call $miden_base_sys::bindings::storage::extern_set_storage_map_item ) - (func $>::from (;17;) (type 12) (param i32 f32) + (func $>::from (;19;) (type 13) (param i32 f32) (local f32 f32 f32) i32.const 0 call $miden_stdlib_sys::intrinsics::felt::extern_from_u32 @@ -430,7 +440,7 @@ local.get 2 f32.store ) - (func $core::ptr::alignment::Alignment::max (;18;) (type 6) (param i32 i32) (result i32) + (func $core::ptr::alignment::Alignment::max (;20;) (type 7) (param i32 i32) (result i32) local.get 0 local.get 1 local.get 0 @@ -438,7 +448,7 @@ i32.gt_u select ) - (func $cabi_realloc (;19;) (type 7) (param i32 i32 i32 i32) (result i32) + (func $cabi_realloc (;21;) (type 8) (param i32 i32 i32 i32) (result i32) local.get 0 local.get 1 local.get 2 @@ -461,13 +471,16 @@ (core instance (;1;) (export "heap-base" (func 2)) ) - (alias export 2 "get-map-item" (func (;3;))) + (alias export 2 "incr-nonce" (func (;3;))) (core func (;3;) (canon lower (func 3))) - (alias export 2 "set-map-item" (func (;4;))) + (alias export 2 "get-map-item" (func (;4;))) (core func (;4;) (canon lower (func 4))) + (alias export 2 "set-map-item" (func (;5;))) + (core func (;5;) (canon lower (func 5))) (core instance (;2;) - (export "get-map-item" (func 3)) - (export "set-map-item" (func 4)) + (export "incr-nonce" (func 3)) + (export "get-map-item" (func 4)) + (export "set-map-item" (func 5)) ) (core instance (;3;) (instantiate 0 (with "miden:core-import/intrinsics-felt@1.0.0" (instance 0)) @@ -478,11 +491,11 @@ (alias core export 3 "memory" (core memory (;0;))) (alias export 3 "felt" (type (;4;))) (type (;5;) (func (result 4))) - (alias core export 3 "miden:counter-contract/counter@0.1.0#get-count" (core func (;5;))) - (alias core export 3 "cabi_realloc" (core func (;6;))) - (func (;5;) (type 5) (canon lift (core func 5))) - (alias core export 3 "miden:counter-contract/counter@0.1.0#increment-count" (core func (;7;))) - (func (;6;) (type 5) (canon lift (core func 7))) + (alias core export 3 "miden:counter-contract/counter@0.1.0#get-count" (core func (;6;))) + (alias core export 3 "cabi_realloc" (core func (;7;))) + (func (;6;) (type 5) (canon lift (core func 6))) + (alias core export 3 "miden:counter-contract/counter@0.1.0#increment-count" (core func (;8;))) + (func (;7;) (type 5) (canon lift (core func 8))) (alias export 3 "felt" (type (;6;))) (component (;0;) (type (;0;) (record (field "inner" f32))) @@ -497,8 +510,8 @@ (export (;3;) "increment-count" (func 1) (func (type 5))) ) (instance (;4;) (instantiate 0 - (with "import-func-get-count" (func 5)) - (with "import-func-increment-count" (func 6)) + (with "import-func-get-count" (func 6)) + (with "import-func-increment-count" (func 7)) (with "import-type-felt" (type 6)) (with "import-type-felt0" (type 4)) ) diff --git a/tests/rust-apps-wasm/rust-sdk/wit-sdk/miden-core-import.wit b/tests/rust-apps-wasm/rust-sdk/wit-sdk/miden-core-import.wit index f0e97175e..5065db638 100644 --- a/tests/rust-apps-wasm/rust-sdk/wit-sdk/miden-core-import.wit +++ b/tests/rust-apps-wasm/rust-sdk/wit-sdk/miden-core-import.wit @@ -44,6 +44,9 @@ interface account { get-map-item: func(index: f32, key0: f32, key1: f32, key2: f32, key3: f32, result-ptr: s32); /// Sets a map item in the account storage set-map-item: func(index: f32, key0: f32, key1: f32, key2: f32, key3: f32, value0: f32, value1: f32, value2: f32, value3: f32, result-ptr: s32); + + /// Increments the account nonce by the provided value. + incr-nonce: func(value: u32); } From bbbb2057752e3ffed574116d725e85f2f9b902ea Mon Sep 17 00:00:00 2001 From: Denys Zadorozhnyi Date: Fri, 25 Apr 2025 13:02:33 +0300 Subject: [PATCH 3/8] add `examples/counter-contract/README.md` --- examples/counter-contract/README.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 examples/counter-contract/README.md diff --git a/examples/counter-contract/README.md b/examples/counter-contract/README.md new file mode 100644 index 000000000..e60ed2d98 --- /dev/null +++ b/examples/counter-contract/README.md @@ -0,0 +1,7 @@ +# Counter Contract + +## Build + +```bash +cargo miden build --release +``` From 06ada7b5168b820891842f2bf0600086d0fe218b Mon Sep 17 00:00:00 2001 From: Denys Zadorozhnyi Date: Mon, 28 Apr 2025 08:15:04 +0300 Subject: [PATCH 4/8] chore: refine comments in counter contract example. --- examples/counter-contract/src/lib.rs | 8 ++++---- examples/counter-contract/wit/counter.wit | 3 +++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/examples/counter-contract/src/lib.rs b/examples/counter-contract/src/lib.rs index f6a90a7e3..7d9ebb603 100644 --- a/examples/counter-contract/src/lib.rs +++ b/examples/counter-contract/src/lib.rs @@ -23,10 +23,10 @@ mod bindings; use bindings::exports::miden::counter_contract::counter::Guest; use miden::{account, component, felt, Felt, StorageMap, StorageMapAccess, Word}; -// Define the main contract struct +/// Main contract structure for the counter example. #[component] struct CounterContract { - // Define the storage field for the counter value + /// Storage map holding the counter value. #[storage(slot(0), description = "counter contract storage map")] count_map: StorageMap, } @@ -34,7 +34,7 @@ struct CounterContract { bindings::export!(CounterContract with_types_in bindings); impl Guest for CounterContract { - // Function to retrieve the current counter value + /// Returns the current counter value stored in the contract's storage map. fn get_count() -> Felt { // Get the instance of the contract let contract = CounterContract::default(); @@ -44,7 +44,7 @@ impl Guest for CounterContract { contract.count_map.get(&key) } - // Function to increment the counter value + /// Increments the counter value stored in the contract's storage map by one. fn increment_count() -> Felt { // Get the instance of the contract let contract = CounterContract::default(); diff --git a/examples/counter-contract/wit/counter.wit b/examples/counter-contract/wit/counter.wit index 0cdc4ec0f..c734fc5e1 100644 --- a/examples/counter-contract/wit/counter.wit +++ b/examples/counter-contract/wit/counter.wit @@ -5,7 +5,10 @@ use miden:base/core-types@1.0.0; interface counter { use core-types.{felt}; + /// Returns the current counter value stored in the contract's storage. get-count: func() -> felt; + /// Increments the counter value stored in the contract's storage by one + //and return the new counter value increment-count: func() -> felt; } From 5da75b504e95f7275f8b78571fa0f68647b71fa9 Mon Sep 17 00:00:00 2001 From: Denys Zadorozhnyi Date: Mon, 28 Apr 2025 11:21:14 +0300 Subject: [PATCH 5/8] feature(cargo-miden): Detect the `cargo-miden` project type (program or library) --- tools/cargo-miden/src/compile_masm.rs | 13 ++++-- tools/cargo-miden/src/lib.rs | 9 ++-- tools/cargo-miden/src/target.rs | 21 ++++++++++ tools/cargo-miden/tests/mod.rs | 3 +- tools/cargo-miden/tests/project_type.rs | 56 +++++++++++++++++++++++++ 5 files changed, 93 insertions(+), 9 deletions(-) create mode 100644 tools/cargo-miden/tests/project_type.rs diff --git a/tools/cargo-miden/src/compile_masm.rs b/tools/cargo-miden/src/compile_masm.rs index ce8f315ec..22bbe0a96 100644 --- a/tools/cargo-miden/src/compile_masm.rs +++ b/tools/cargo-miden/src/compile_masm.rs @@ -3,6 +3,8 @@ use std::{ rc::Rc, }; +use crate::ProjectType; + use midenc_compile::{Compiler, Context}; use midenc_session::{ diagnostics::{IntoDiagnostic, Report, WrapErr}, @@ -12,7 +14,7 @@ use midenc_session::{ pub fn wasm_to_masm( wasm_file_path: &Path, output_folder: &Path, - is_bin: bool, + project_type: ProjectType, ) -> Result { if !output_folder.exists() { return Err(Report::msg(format!( @@ -35,20 +37,23 @@ pub fn wasm_to_masm( .unwrap(); let output_file = output_folder.join(masm_file_name).with_extension(OutputType::Masp.extension()); - let project_type = if is_bin { "--exe" } else { "--lib" }; + let project_type_arg = match project_type { + ProjectType::Program => "--exe", + ProjectType::Library => "--lib", + }; let entrypoint_opt = format!("--entrypoint={masm_file_name}::entrypoint"); let mut args: Vec<&std::ffi::OsStr> = vec![ "--output-dir".as_ref(), output_folder.as_os_str(), "-o".as_ref(), output_file.as_os_str(), - project_type.as_ref(), + project_type_arg.as_ref(), "--verbose".as_ref(), "--target".as_ref(), "rollup".as_ref(), ]; - if is_bin { + if project_type == ProjectType::Program { args.push(entrypoint_opt.as_ref()); } diff --git a/tools/cargo-miden/src/lib.rs b/tools/cargo-miden/src/lib.rs index bc4c0877c..997ad7cfe 100644 --- a/tools/cargo-miden/src/lib.rs +++ b/tools/cargo-miden/src/lib.rs @@ -12,6 +12,7 @@ use clap::{CommandFactory, Parser}; use commands::NewCommand; use compile_masm::wasm_to_masm; use non_component::run_cargo_command_for_non_component; +pub use target::{detect_project_type, ProjectType}; mod commands; mod compile_masm; @@ -142,6 +143,9 @@ where let cargo_args = CargoArguments::parse_from(args.clone().into_iter())?; // dbg!(&cargo_args); let metadata = load_metadata(cargo_args.manifest_path.as_deref())?; + + let project_type = target::detect_project_type(&metadata); + let mut packages = load_component_metadata( &metadata, cargo_args.packages.iter(), @@ -258,10 +262,7 @@ where let mut outputs = Vec::new(); for wasm in wasm_outputs { - // so far, we only support the Miden VM programs, unless `--lib` is - // specified (in our integration tests) - let is_bin = !args.contains(&"--lib".to_string()); - let output = wasm_to_masm(&wasm, miden_out_dir.as_std_path(), is_bin) + let output = wasm_to_masm(&wasm, miden_out_dir.as_std_path(), project_type) .map_err(|e| anyhow::anyhow!("{e}"))?; outputs.push(output); } diff --git a/tools/cargo-miden/src/target.rs b/tools/cargo-miden/src/target.rs index a4afbd68e..859157e85 100644 --- a/tools/cargo-miden/src/target.rs +++ b/tools/cargo-miden/src/target.rs @@ -6,6 +6,27 @@ use std::{ use anyhow::{bail, Result}; +/// Represents whether the Cargo project is a Miden program or a library. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum ProjectType { + Program, + Library, +} + +/// Detects whether the project is a Miden program or library based on Cargo metadata. +pub fn detect_project_type(metadata: &cargo_metadata::Metadata) -> ProjectType { + // is `[package.metadata.miden]` is present then it's a library, otherwise it's a program + metadata.root_package().map_or(ProjectType::Program, |root_pkg| { + root_pkg.metadata.as_object().map_or(ProjectType::Program, |meta_obj| { + if meta_obj.contains_key("miden") { + ProjectType::Library + } else { + ProjectType::Program + } + }) + }) +} + pub fn install_wasm32_wasip1() -> Result<()> { let sysroot = get_sysroot()?; if sysroot.join("lib/rustlib/wasm32-wasip1").exists() { diff --git a/tools/cargo-miden/tests/mod.rs b/tools/cargo-miden/tests/mod.rs index 3a146708a..0a326beef 100755 --- a/tools/cargo-miden/tests/mod.rs +++ b/tools/cargo-miden/tests/mod.rs @@ -1,2 +1,3 @@ mod build; -mod utils; +mod project_type; +mod utils; \ No newline at end of file diff --git a/tools/cargo-miden/tests/project_type.rs b/tools/cargo-miden/tests/project_type.rs new file mode 100644 index 000000000..9b1460038 --- /dev/null +++ b/tools/cargo-miden/tests/project_type.rs @@ -0,0 +1,56 @@ +use cargo_miden::ProjectType; +use cargo_metadata::MetadataCommand; +use std::path::Path; + +#[test] +fn test_project_type_detection() { + let examples = [ + ("collatz", ProjectType::Program), + ("counter-contract", ProjectType::Library), + ("fibonacci", ProjectType::Program), + ("is-prime", ProjectType::Program), + ("storage-example", ProjectType::Library), + ]; + + for (example_name, expected_type) in examples { + let manifest_dir = Path::new(env!("CARGO_MANIFEST_DIR")); + // Relative path from tools/cargo-miden/tests/ -> tools/cargo-miden/ -> examples/ + let example_manifest_path = manifest_dir + .join("../../examples") // Go up two levels from crate root + .join(example_name) + .join("Cargo.toml") + .canonicalize() // Resolve path for clearer error messages + .unwrap_or_else(|e| { + panic!("Failed to find manifest path for {}: {}", example_name, e) + }); + + println!( + "Testing project type detection for: {}", + example_manifest_path.display() + ); + + let metadata = MetadataCommand::new() + .manifest_path(&example_manifest_path) + .no_deps() // Avoid pulling deps for simple metadata read + .exec() + .unwrap_or_else(|e| { + panic!( + "Failed to load metadata for {}: {}", + example_manifest_path.display(), + e + ) + }); + + let detected_type = cargo_miden::detect_project_type(&metadata); + + assert_eq!( + detected_type, + expected_type, + "Mismatch for example '{}': expected {:?}, detected {:?} (manifest: {})", + example_name, + expected_type, + detected_type, + example_manifest_path.display() + ); + } +} From 0be7158bb7193e224ba6f6f17aed72d0daf188bc Mon Sep 17 00:00:00 2001 From: Denys Zadorozhnyi Date: Mon, 28 Apr 2025 11:27:36 +0300 Subject: [PATCH 6/8] chore: fix code formatting --- tools/cargo-miden/tests/project_type.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/tools/cargo-miden/tests/project_type.rs b/tools/cargo-miden/tests/project_type.rs index 9b1460038..1b7d4af5f 100644 --- a/tools/cargo-miden/tests/project_type.rs +++ b/tools/cargo-miden/tests/project_type.rs @@ -1,7 +1,8 @@ -use cargo_miden::ProjectType; -use cargo_metadata::MetadataCommand; use std::path::Path; +use cargo_metadata::MetadataCommand; +use cargo_miden::ProjectType; + #[test] fn test_project_type_detection() { let examples = [ @@ -24,10 +25,7 @@ fn test_project_type_detection() { panic!("Failed to find manifest path for {}: {}", example_name, e) }); - println!( - "Testing project type detection for: {}", - example_manifest_path.display() - ); + println!("Testing project type detection for: {}", example_manifest_path.display()); let metadata = MetadataCommand::new() .manifest_path(&example_manifest_path) From 6ee888d7e189a56f5fd3654f63dc4d7d6f3ddc45 Mon Sep 17 00:00:00 2001 From: Denys Zadorozhnyi Date: Mon, 28 Apr 2025 11:35:09 +0300 Subject: [PATCH 7/8] chore: fix code formatting --- tools/cargo-miden/src/compile_masm.rs | 4 ++-- tools/cargo-miden/tests/mod.rs | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/tools/cargo-miden/src/compile_masm.rs b/tools/cargo-miden/src/compile_masm.rs index 22bbe0a96..8c2aaf327 100644 --- a/tools/cargo-miden/src/compile_masm.rs +++ b/tools/cargo-miden/src/compile_masm.rs @@ -3,14 +3,14 @@ use std::{ rc::Rc, }; -use crate::ProjectType; - use midenc_compile::{Compiler, Context}; use midenc_session::{ diagnostics::{IntoDiagnostic, Report, WrapErr}, InputFile, OutputType, }; +use crate::ProjectType; + pub fn wasm_to_masm( wasm_file_path: &Path, output_folder: &Path, diff --git a/tools/cargo-miden/tests/mod.rs b/tools/cargo-miden/tests/mod.rs index 0a326beef..43bd6e236 100755 --- a/tools/cargo-miden/tests/mod.rs +++ b/tools/cargo-miden/tests/mod.rs @@ -1,3 +1,4 @@ mod build; mod project_type; -mod utils; \ No newline at end of file +mod utils; + From 93eb52fec68ca8fd396ed1880fbf0f33e271ed8b Mon Sep 17 00:00:00 2001 From: Denys Zadorozhnyi Date: Mon, 28 Apr 2025 11:46:58 +0300 Subject: [PATCH 8/8] chore: fix code formatting --- tools/cargo-miden/tests/mod.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/cargo-miden/tests/mod.rs b/tools/cargo-miden/tests/mod.rs index 43bd6e236..0b5d648c5 100755 --- a/tools/cargo-miden/tests/mod.rs +++ b/tools/cargo-miden/tests/mod.rs @@ -1,4 +1,3 @@ mod build; mod project_type; mod utils; -