diff --git a/Cargo.lock b/Cargo.lock index 9202e33a78f..d0bc0e7c491 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,9 +4,9 @@ version = 3 [[package]] name = "acir" -version = "0.13.1" +version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5b1acebc24fe47a54761470d907a71abb5065c71236e8ad91763f7cfeda91e6" +checksum = "e011212158b81a8bbe6c9f7f4713fbf8b9542076a49ba916769436833b5d738f" dependencies = [ "acir_field", "brillig_vm", @@ -18,9 +18,9 @@ dependencies = [ [[package]] name = "acir_field" -version = "0.13.1" +version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56a34985546b0dc8148b9f8a4e7388e32924b108bfe6f1fee2886ca9fcd46ce7" +checksum = "08e3bbb98412bdcb65b7b688269cbc04db0710e25f3c32e99cf3923026ea3941" dependencies = [ "ark-bn254", "ark-ff", @@ -32,9 +32,9 @@ dependencies = [ [[package]] name = "acvm" -version = "0.13.1" +version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ef2fb115fd5b52adc06c7a62ce44d19da746d39b858415750eaf72c763e1b88" +checksum = "d5b5a910c6dcbea83195107368805911a02b2ed3453a1516e15fa2bc89e4d1c2" dependencies = [ "acir", "acvm_stdlib", @@ -44,7 +44,7 @@ dependencies = [ "k256", "num-bigint", "num-traits", - "sha2 0.10.6", + "sha2", "sha3", "thiserror", ] @@ -71,9 +71,9 @@ dependencies = [ [[package]] name = "acvm_stdlib" -version = "0.13.1" +version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1985da8071de8cc8680eec187b19b31fa19c00439291cd188247429d9f0f9c21" +checksum = "ffe3837b19bcbf11cecd61083e088a49c2d7911abedd0585cc62bf77bb47a384" dependencies = [ "acir", ] @@ -243,7 +243,7 @@ dependencies = [ "ark-serialize", "ark-std", "derivative", - "digest 0.10.7", + "digest", "itertools", "num-bigint", "num-traits", @@ -296,7 +296,7 @@ checksum = "adb7b85a02b83d2f22f89bd5cac66c9c89474240cb6207cb1efc16d098e822a5" dependencies = [ "ark-serialize-derive", "ark-std", - "digest 0.10.7", + "digest", "num-bigint", ] @@ -397,12 +397,24 @@ dependencies = [ "thiserror", ] +[[package]] +name = "base16ct" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "349a06037c7bf932dd7e7d1f653678b2038b9ad46a74102f1fc7bd7872678cce" + [[package]] name = "base64" version = "0.21.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "604178f6c5c21f02dc555784810edfb88d34ac2c73b2eae109655649ee73ce3d" +[[package]] +name = "base64ct" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" + [[package]] name = "bincode" version = "1.3.3" @@ -440,27 +452,16 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" -[[package]] -name = "bitvec" -version = "0.18.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98fcd36dda4e17b7d7abc64cb549bf0201f4ab71e00700c798ca7e62ed3761fa" -dependencies = [ - "funty 1.1.0", - "radium 0.3.0", - "wyz 0.2.0", -] - [[package]] name = "bitvec" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" dependencies = [ - "funty 2.0.0", - "radium 0.7.0", + "funty", + "radium", "tap", - "wyz 0.5.1", + "wyz", ] [[package]] @@ -469,16 +470,7 @@ version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "46502ad458c9a52b69d4d4d32775c788b7a1b85e8bc9d482d92250fc0e3f8efe" dependencies = [ - "digest 0.10.7", -] - -[[package]] -name = "block-buffer" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" -dependencies = [ - "generic-array", + "digest", ] [[package]] @@ -492,9 +484,9 @@ dependencies = [ [[package]] name = "brillig_vm" -version = "0.13.1" +version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6e6db12d2fa2a555e26513c457bf44154cfb1738ad6a42537089d63ede7f1c1" +checksum = "b690fd9d34b8653edf286c03982433e80e6e3878a8fc6289b680997c3e80925b" dependencies = [ "acir_field", "num-bigint", @@ -732,9 +724,9 @@ dependencies = [ [[package]] name = "const-oid" -version = "0.4.5" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f6b64db6932c7e49332728e3a6bd82c6b7e16016607d20923b537c3bc4c0d5f" +checksum = "520fbf3c07483f94e3e3ca9d0cfd913d7718ef2483d2cfd91c0d9e91474ab913" [[package]] name = "const_format" @@ -896,23 +888,25 @@ dependencies = [ ] [[package]] -name = "crypto-common" -version = "0.1.6" +name = "crypto-bigint" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +checksum = "ef2b4b23cddf68b89b8f8069890e8c270d54e2d5fe1b143820234805e4cb17ef" dependencies = [ "generic-array", - "typenum", + "rand_core 0.6.4", + "subtle", + "zeroize", ] [[package]] -name = "crypto-mac" -version = "0.10.1" +name = "crypto-common" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bff07008ec701e8028e2ceb8f83f0e4274ee62bd2dbdc4fefff2e9a91824081a" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" dependencies = [ "generic-array", - "subtle", + "typenum", ] [[package]] @@ -951,11 +945,12 @@ dependencies = [ [[package]] name = "der" -version = "0.1.0" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51f59c66c30bb7445c8320a5f9233e437e3572368099f25532a59054328899b4" +checksum = "f1a467a65c5e759bce6e65eaf91cc29f466cdc57cb65777bd646872a8a1fd4de" dependencies = [ "const-oid", + "zeroize", ] [[package]] @@ -975,22 +970,13 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6184e33543162437515c2e2b48714794e37845ec9851711914eec9d308f6ebe8" -[[package]] -name = "digest" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" -dependencies = [ - "generic-array", -] - [[package]] name = "digest" version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ - "block-buffer 0.10.4", + "block-buffer", "crypto-common", "subtle", ] @@ -1023,12 +1009,13 @@ checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" [[package]] name = "ecdsa" -version = "0.10.2" +version = "0.14.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41fbdb4ff710acb4db8ca29f93b897529ea6d6a45626d5183b47e012aa6ae7e4" +checksum = "413301934810f597c1d19ca71c8710e99a3f1ba28a0d2ebc01551a2daeea3c5c" dependencies = [ + "der", "elliptic-curve", - "hmac", + "rfc6979", "signature", ] @@ -1040,18 +1027,20 @@ checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" [[package]] name = "elliptic-curve" -version = "0.8.5" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2db227e61a43a34915680bdda462ec0e212095518020a88a1f91acd16092c39" +checksum = "e7bb888ab5300a19b8e5bceef25ac745ad065f3c9f7efc6de1b91958110891d3" dependencies = [ - "bitvec 0.18.5", - "digest 0.9.0", + "base16ct", + "crypto-bigint", + "der", + "digest", "ff", - "funty 1.1.0", "generic-array", "group", "pkcs8", - "rand_core 0.5.1", + "rand_core 0.6.4", + "sec1", "subtle", "zeroize", ] @@ -1154,12 +1143,11 @@ dependencies = [ [[package]] name = "ff" -version = "0.8.0" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01646e077d4ebda82b73f1bca002ea1e91561a77df2431a9e79729bcc31950ef" +checksum = "d013fc25338cc558c5c2cfbad646908fb23591e2404481826742b651c9af7160" dependencies = [ - "bitvec 0.18.5", - "rand_core 0.5.1", + "rand_core 0.6.4", "subtle", ] @@ -1214,12 +1202,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" -[[package]] -name = "funty" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fed34cd105917e91daa4da6b3728c47b068749d6a62c59811f06ed2ac71d9da7" - [[package]] name = "funty" version = "2.0.0" @@ -1359,12 +1341,12 @@ dependencies = [ [[package]] name = "group" -version = "0.8.0" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc11f9f5fbf1943b48ae7c2bf6846e7d827a512d1be4f23af708f5ca5d01dde1" +checksum = "5dfbfb3a6cfbd390d5c9564ab283a0349b9b9fcd46a706c1eb10e0db70bfbac7" dependencies = [ "ff", - "rand_core 0.5.1", + "rand_core 0.6.4", "subtle", ] @@ -1443,12 +1425,11 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "hmac" -version = "0.10.1" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1441c6b1e930e2817404b5046f1f989899143a12bf92de603b69f4e0aee1e15" +checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" dependencies = [ - "crypto-mac", - "digest 0.9.0", + "digest", ] [[package]] @@ -1663,14 +1644,14 @@ dependencies = [ [[package]] name = "k256" -version = "0.7.3" +version = "0.11.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4476a0808212a9e81ce802eb1a0cfc60e73aea296553bacc0fac7e1268bc572a" +checksum = "72c1e0b51e7ec0a97369623508396067a486bd0cbed95a2659a4b863d28cfc8b" dependencies = [ "cfg-if", "ecdsa", "elliptic-curve", - "sha2 0.9.9", + "sha2", ] [[package]] @@ -1899,6 +1880,7 @@ dependencies = [ "acvm", "build-data", "console_error_panic_hook", + "getrandom", "gloo-utils", "log", "noirc_driver", @@ -2067,12 +2049,6 @@ version = "1.17.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9670a07f94779e00908f3e686eab508878ebb390ba6e604d3a284c00e8d0487b" -[[package]] -name = "opaque-debug" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" - [[package]] name = "owo-colors" version = "3.5.0" @@ -2111,11 +2087,12 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "pkcs8" -version = "0.3.3" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4839a901843f3942576e65857f0ebf2e190ef7024d3c62a94099ba3f819ad1d" +checksum = "9eca2c590a5f85da82668fa685c09ce2888b9430e83299debf1f34b65fd4a4ba" dependencies = [ "der", + "spki", ] [[package]] @@ -2243,12 +2220,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "radium" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "def50a86306165861203e7f84ecffbbdfdea79f0e51039b33de1e952358c47ac" - [[package]] name = "radium" version = "0.7.0" @@ -2304,12 +2275,6 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" -[[package]] -name = "rand_core" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" - [[package]] name = "rand_core" version = "0.6.4" @@ -2482,6 +2447,17 @@ dependencies = [ "winreg", ] +[[package]] +name = "rfc6979" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7743f17af12fa0b03b803ba12cd6a8d9483a587e89c69445e3909655c0b9fabb" +dependencies = [ + "crypto-bigint", + "hmac", + "zeroize", +] + [[package]] name = "ring" version = "0.16.20" @@ -2503,7 +2479,7 @@ version = "0.7.42" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0200c8230b013893c0b2d6213d6ec64ed2b9be2e0e016682b7224ff82cff5c58" dependencies = [ - "bitvec 1.0.1", + "bitvec", "bytecheck", "hashbrown 0.12.3", "ptr_meta", @@ -2579,7 +2555,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "512b0ab6853f7e14e3c8754acb43d6f748bb9ced66aa5915a6553ac8213f7731" dependencies = [ "globset", - "sha2 0.10.6", + "sha2", "walkdir", ] @@ -2745,6 +2721,20 @@ version = "4.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b" +[[package]] +name = "sec1" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3be24c1842290c45df0a7bf069e0c268a747ad05a192f2fd7dcfdbc1cba40928" +dependencies = [ + "base16ct", + "der", + "generic-array", + "pkcs8", + "subtle", + "zeroize", +] + [[package]] name = "semver" version = "1.0.17" @@ -2821,19 +2811,6 @@ dependencies = [ "serde", ] -[[package]] -name = "sha2" -version = "0.9.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" -dependencies = [ - "block-buffer 0.9.0", - "cfg-if", - "cpufeatures", - "digest 0.9.0", - "opaque-debug", -] - [[package]] name = "sha2" version = "0.10.6" @@ -2842,7 +2819,7 @@ checksum = "82e6b795fe2e3b1e845bafcb27aa35405c4d47cdfc92af5fc8d3002f76cebdc0" dependencies = [ "cfg-if", "cpufeatures", - "digest 0.10.7", + "digest", ] [[package]] @@ -2851,7 +2828,7 @@ version = "0.10.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "75872d278a8f37ef87fa0ddbda7802605cb18344497949862c0d4dcb291eba60" dependencies = [ - "digest 0.10.7", + "digest", "keccak", ] @@ -2881,12 +2858,12 @@ checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3" [[package]] name = "signature" -version = "1.2.2" +version = "1.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29f060a7d147e33490ec10da418795238fd7545bba241504d6b31a409f2e6210" +checksum = "74233d3b3b2f6d4b006dc19dee745e73e2a6bfb6f93607cd3b02bd5b00797d7c" dependencies = [ - "digest 0.9.0", - "rand_core 0.5.1", + "digest", + "rand_core 0.6.4", ] [[package]] @@ -2944,6 +2921,16 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" +[[package]] +name = "spki" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67cf02bbac7a337dc36e4f5a693db6c21e7863f45070f7064577eb4367a3212b" +dependencies = [ + "base64ct", + "der", +] + [[package]] name = "stable_deref_trait" version = "1.2.0" @@ -4003,12 +3990,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "wyz" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85e60b0d1b5f99db2556934e21937020776a5d31520bf169e851ac44e6420214" - [[package]] name = "wyz" version = "0.5.1" diff --git a/Cargo.toml b/Cargo.toml index b56e140ed58..e188f19dd89 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2021" rust-version = "1.66" [workspace.dependencies] -acvm = "0.13.0" +acvm = "=0.13.3" arena = { path = "crates/arena" } fm = { path = "crates/fm" } iter-extended = { path = "crates/iter-extended" } @@ -38,7 +38,7 @@ noirc_frontend = { path = "crates/noirc_frontend" } noir_wasm = { path = "crates/wasm" } cfg-if = "1.0.0" -clap = { version = "4.1.4", features = ["derive"]} +clap = { version = "4.1.4", features = ["derive"] } codespan = "0.9.5" codespan-reporting = "0.9.5" chumsky = { git = "https://github.com/jfecher/chumsky", rev = "ad9d312" } diff --git a/crates/nargo_cli/tests/test_data_ssa_refactor/brillig/Nargo.toml b/crates/nargo_cli/tests/test_data_ssa_refactor/brillig/Nargo.toml new file mode 100644 index 00000000000..e0b467ce5da --- /dev/null +++ b/crates/nargo_cli/tests/test_data_ssa_refactor/brillig/Nargo.toml @@ -0,0 +1,5 @@ +[package] +authors = [""] +compiler_version = "0.1" + +[dependencies] \ No newline at end of file diff --git a/crates/nargo_cli/tests/test_data_ssa_refactor/brillig/Prover.toml b/crates/nargo_cli/tests/test_data_ssa_refactor/brillig/Prover.toml new file mode 100644 index 00000000000..55cccb955a9 --- /dev/null +++ b/crates/nargo_cli/tests/test_data_ssa_refactor/brillig/Prover.toml @@ -0,0 +1,2 @@ +x = "3" + diff --git a/crates/nargo_cli/tests/test_data_ssa_refactor/brillig/src/main.nr b/crates/nargo_cli/tests/test_data_ssa_refactor/brillig/src/main.nr new file mode 100644 index 00000000000..4931fd24f38 --- /dev/null +++ b/crates/nargo_cli/tests/test_data_ssa_refactor/brillig/src/main.nr @@ -0,0 +1,10 @@ +// Tests a very simple program. +// +// The features being tested is assertion +fn main(x : Field) { + assert(x == identity(x)); +} + +unconstrained fn identity(x : Field) -> Field { + x +} \ No newline at end of file diff --git a/crates/noirc_evaluator/src/ssa_refactor/acir_gen/acir_ir/acir_variable.rs b/crates/noirc_evaluator/src/ssa_refactor/acir_gen/acir_ir/acir_variable.rs index db5cd340b13..155ace62b9b 100644 --- a/crates/noirc_evaluator/src/ssa_refactor/acir_gen/acir_ir/acir_variable.rs +++ b/crates/noirc_evaluator/src/ssa_refactor/acir_gen/acir_ir/acir_variable.rs @@ -1,5 +1,8 @@ use crate::ssa_refactor::ir::{instruction::Endian, types::NumericType}; -use acvm::acir::brillig_vm::Opcode as BrilligOpcode; +use acvm::acir::{ + brillig_vm::Opcode as BrilligOpcode, + circuit::brillig::{BrilligInputs, BrilligOutputs}, +}; use super::{ errors::AcirGenError, @@ -697,8 +700,21 @@ impl AcirContext { id } - pub(crate) fn brillig(&mut self, _code: Vec) { - todo!(); + pub(crate) fn brillig( + &mut self, + code: Vec, + inputs: Vec, + output_len: usize, + ) -> Vec { + let b_inputs = + vecmap(inputs, |i| BrilligInputs::Single(self.data[&i].to_expression().into_owned())); + let outputs = vecmap(0..output_len, |_| self.acir_ir.next_witness_index()); + let outputs_var = + vecmap(&outputs, |witness_index| self.add_data(AcirVarData::Witness(*witness_index))); + let b_outputs = vecmap(outputs, BrilligOutputs::Simple); + self.acir_ir.brillig(code, b_inputs, b_outputs); + + outputs_var } } diff --git a/crates/noirc_evaluator/src/ssa_refactor/acir_gen/acir_ir/generated_acir.rs b/crates/noirc_evaluator/src/ssa_refactor/acir_gen/acir_ir/generated_acir.rs index 95fa1411b5e..b67eac031aa 100644 --- a/crates/noirc_evaluator/src/ssa_refactor/acir_gen/acir_ir/generated_acir.rs +++ b/crates/noirc_evaluator/src/ssa_refactor/acir_gen/acir_ir/generated_acir.rs @@ -2,7 +2,9 @@ //! program as it is being converted from SSA form. use super::errors::AcirGenError; use acvm::acir::{ + brillig_vm::Opcode as BrilligOpcode, circuit::{ + brillig::{Brillig as AcvmBrillig, BrilligInputs, BrilligOutputs}, directives::{LogInfo, QuotientDirective}, opcodes::{BlackBoxFuncCall, FunctionInput, Opcode as AcirOpcode}, }, @@ -464,6 +466,22 @@ impl GeneratedAcir { Ok(q_witness) } + + pub(crate) fn brillig( + &mut self, + code: Vec, + inputs: Vec, + outputs: Vec, + ) { + let opcode = AcirOpcode::Brillig(AcvmBrillig { + inputs, + outputs, + foreign_call_results: Vec::new(), + bytecode: code, + predicate: None, + }); + self.push_opcode(opcode); + } } /// This function will return the number of inputs that a blackbox function diff --git a/crates/noirc_evaluator/src/ssa_refactor/acir_gen/mod.rs b/crates/noirc_evaluator/src/ssa_refactor/acir_gen/mod.rs index 90a880b50c9..4eac2a0194e 100644 --- a/crates/noirc_evaluator/src/ssa_refactor/acir_gen/mod.rs +++ b/crates/noirc_evaluator/src/ssa_refactor/acir_gen/mod.rs @@ -22,6 +22,7 @@ use super::{ ssa_gen::Ssa, }; use crate::brillig::{artifact::BrilligArtifact, Brillig}; +use iter_extended::vecmap; use noirc_abi::{AbiType, FunctionSignature, Sign}; pub(crate) use acir_ir::generated_acir::GeneratedAcir; @@ -90,11 +91,6 @@ impl Context { brillig: Brillig, allow_log_ops: bool, ) -> GeneratedAcir { - assert_eq!( - ssa.functions.len(), - 1, - "expected only a single function to be present with all other functions being inlined." - ); let main_func = ssa.main(); let dfg = &main_func.dfg; let entry_block = &dfg[main_func.entry_block()]; @@ -214,10 +210,11 @@ impl Context { "expected an intrinsic/brillig call, but found {func:?}. All ACIR methods should be inlined" ), RuntimeType::Brillig => { + let inputs = vecmap(arguments, |&a| {self.convert_ssa_value(a, dfg)}); // Generate the brillig code of the function let code = BrilligArtifact::default().link(&brillig[*id]); - self.acir_context.brillig(code); - (result_ids.to_vec(), Vec::new()) + let outputs = self.acir_context.brillig(code, inputs, result_ids.len()); + (result_ids.to_vec(), outputs) } } } diff --git a/crates/noirc_evaluator/src/ssa_refactor/opt/inlining.rs b/crates/noirc_evaluator/src/ssa_refactor/opt/inlining.rs index 29466cba346..9d75f14b9bb 100644 --- a/crates/noirc_evaluator/src/ssa_refactor/opt/inlining.rs +++ b/crates/noirc_evaluator/src/ssa_refactor/opt/inlining.rs @@ -253,10 +253,7 @@ impl<'function> PerFunctionContext<'function> { match self.context.builder[id] { Value::Function(id) => Some(id), Value::Intrinsic(_) => None, - _ => { - self.context.failed_to_inline_a_call = true; - None - } + _ => None, } } @@ -326,9 +323,15 @@ impl<'function> PerFunctionContext<'function> { Instruction::Call { func, arguments } => match self.get_function(*func) { Some(function) => match ssa.functions[&function].runtime() { RuntimeType::Acir => self.inline_function(ssa, *id, function, arguments), - RuntimeType::Brillig => self.push_instruction(*id), + RuntimeType::Brillig => { + self.context.failed_to_inline_a_call = true; + self.push_instruction(*id); + } }, - None => self.push_instruction(*id), + None => { + self.context.failed_to_inline_a_call = true; + self.push_instruction(*id); + } }, _ => self.push_instruction(*id), } diff --git a/crates/wasm/Cargo.toml b/crates/wasm/Cargo.toml index bbcabe12e0a..7660f67bd57 100644 --- a/crates/wasm/Cargo.toml +++ b/crates/wasm/Cargo.toml @@ -22,5 +22,9 @@ wasm-logger = "0.2.0" console_error_panic_hook = "0.1.7" gloo-utils = { version = "0.1", features = ["serde"] } +# This is an unused dependency, we are adding it +# so that we can enable the js feature in getrandom. +getrandom = { version = "*", features = ["js"] } + [build-dependencies] build-data = "0.1.3" diff --git a/crates/wasm/src/lib.rs b/crates/wasm/src/lib.rs index 2a659b94965..b4e18d3cece 100644 --- a/crates/wasm/src/lib.rs +++ b/crates/wasm/src/lib.rs @@ -9,6 +9,13 @@ use serde::{Deserialize, Serialize}; use std::str::FromStr; use wasm_bindgen::prelude::*; +// This dependency is not used. We import it +// to bypass the `unused_crate_dependencies` lint. +// +// It is being imported as we get errors regarding the +// js feature not being enabled. +use getrandom as _; + mod circuit; mod compile;