diff --git a/compiler/noirc_evaluator/src/ssa/opt/remove_unreachable.rs b/compiler/noirc_evaluator/src/ssa/opt/remove_unreachable.rs index 731f2e6c82c..b1361f2194e 100644 --- a/compiler/noirc_evaluator/src/ssa/opt/remove_unreachable.rs +++ b/compiler/noirc_evaluator/src/ssa/opt/remove_unreachable.rs @@ -87,6 +87,7 @@ fn used_functions(func: &Function) -> BTreeSet { Instruction::Store { .. } | Instruction::Call { .. } | Instruction::MakeArray { .. } + | Instruction::ArraySet { .. } ) { instruction.for_each_value(&mut find_functions); } @@ -211,4 +212,38 @@ mod tests { assert_normalized_ssa_equals(ssa, src); } + + #[test] + fn keep_functions_used_in_array_set() { + // Regression test for issue "V-NSCA-VUL-003: Missing ArraySet case in Removing Unreachable Functions pass" + // found in Veridise Audit. https://github.com/noir-lang/noir/issues/8890 + + // f2 is written to an array using an `array_set` instruction. Thus, we do not want to remove it. + let src = r#" + acir(inline) fn main f0 { + b0(v0: Field, v1: Field): + v2 = make_array [f1] : [function; 1] + v3 = array_set v2, index u32 0, value f2 + v4 = array_get v3, index u32 0 -> function + v5 = call v4(v0) -> Field + return + } + + acir(inline) fn my_fun f1 { + b0(v0: Field): + v2 = add v0, Field 1 + return v2 + } + + acir(inline) fn my_fun2 f2 { + b0(v0: Field): + v2 = add v0, Field 2 + return v2 + }"#; + + let ssa = Ssa::from_str(src).unwrap(); + let ssa = ssa.remove_unreachable_functions(); + + assert_normalized_ssa_equals(ssa, src); + } } diff --git a/cspell.json b/cspell.json index 4167a516ca6..236382ae45e 100644 --- a/cspell.json +++ b/cspell.json @@ -195,6 +195,7 @@ "nomicfoundation", "noncanonical", "nouner", + "NSCA", "oneof", "oneshot", "Ottenstein", @@ -288,6 +289,7 @@ "vecmap", "vecs", "Vecs", + "Veridise", "vitkov", "VM", "walkdir", diff --git a/test_programs/execution_success/regression_8890/Nargo.toml b/test_programs/execution_success/regression_8890/Nargo.toml new file mode 100644 index 00000000000..462519808ca --- /dev/null +++ b/test_programs/execution_success/regression_8890/Nargo.toml @@ -0,0 +1,7 @@ +[package] +name = "regression_8890" +version = "0.1.0" +type = "bin" +authors = [""] + +[dependencies] diff --git a/test_programs/execution_success/regression_8890/Prover.toml b/test_programs/execution_success/regression_8890/Prover.toml new file mode 100644 index 00000000000..3e7661d7e4c --- /dev/null +++ b/test_programs/execution_success/regression_8890/Prover.toml @@ -0,0 +1,4 @@ +x = "3" +y = "4" + +return = 5 diff --git a/test_programs/execution_success/regression_8890/src/main.nr b/test_programs/execution_success/regression_8890/src/main.nr new file mode 100644 index 00000000000..17c1374e7e2 --- /dev/null +++ b/test_programs/execution_success/regression_8890/src/main.nr @@ -0,0 +1,17 @@ +// Regression test for issue "V-NSCA-VUL-003: Missing ArraySet case in Removing Unreachable Functions pass" +// found in Veridise Audit. + +fn main(x: Field, y: pub Field) -> pub Field { + assert(x != y); + let mut f = [my_fun]; + f[0] = my_fun2; + (f[0])(x) +} + +fn my_fun(x: Field) -> Field { + x + 1 +} + +fn my_fun2(x: Field) -> Field { + x + 2 +} diff --git a/tooling/nargo_cli/tests/snapshots/execution_success/regression_8890/execute__tests__expanded.snap b/tooling/nargo_cli/tests/snapshots/execution_success/regression_8890/execute__tests__expanded.snap new file mode 100644 index 00000000000..79002ec1599 --- /dev/null +++ b/tooling/nargo_cli/tests/snapshots/execution_success/regression_8890/execute__tests__expanded.snap @@ -0,0 +1,18 @@ +--- +source: tooling/nargo_cli/tests/execute.rs +expression: expanded_code +--- +fn main(x: Field, y: pub Field) -> pub Field { + assert(x != y); + let mut f: [fn(Field) -> Field; 1] = [my_fun]; + f[0] = my_fun2; + f[0](x) +} + +fn my_fun(x: Field) -> Field { + x + 1 +} + +fn my_fun2(x: Field) -> Field { + x + 2 +} diff --git a/tooling/nargo_cli/tests/snapshots/execution_success/regression_8890/execute__tests__force_brillig_false_inliner_-9223372036854775808.snap b/tooling/nargo_cli/tests/snapshots/execution_success/regression_8890/execute__tests__force_brillig_false_inliner_-9223372036854775808.snap new file mode 100644 index 00000000000..4613ecc333c --- /dev/null +++ b/tooling/nargo_cli/tests/snapshots/execution_success/regression_8890/execute__tests__force_brillig_false_inliner_-9223372036854775808.snap @@ -0,0 +1,58 @@ +--- +source: tooling/nargo_cli/tests/execute.rs +expression: artifact +--- +{ + "noir_version": "[noir_version]", + "hash": "[hash]", + "abi": { + "parameters": [ + { + "name": "x", + "type": { + "kind": "field" + }, + "visibility": "private" + }, + { + "name": "y", + "type": { + "kind": "field" + }, + "visibility": "public" + } + ], + "return_type": { + "abi_type": { + "kind": "field" + }, + "visibility": "public" + }, + "error_types": {} + }, + "bytecode": [ + "func 0", + "current witness index : _3", + "private parameters indices : [_0]", + "public parameters indices : [_1]", + "return value indices : [_2]", + "BRILLIG CALL func 0: inputs: [Single(Expression { mul_terms: [], linear_combinations: [(1, Witness(0)), (-1, Witness(1))], q_c: 0 })], outputs: [Simple(Witness(3))]", + "EXPR [ (1, _0, _3) (-1, _1, _3) -1 ]", + "EXPR [ (-1, _0) (1, _2) -2 ]", + "unconstrained func 0", + "[Const { destination: Direct(21), bit_size: Integer(U32), value: 1 }, Const { destination: Direct(20), bit_size: Integer(U32), value: 0 }, CalldataCopy { destination_address: Direct(0), size_address: Direct(21), offset_address: Direct(20) }, Const { destination: Direct(2), bit_size: Field, value: 0 }, BinaryFieldOp { destination: Direct(3), op: Equals, lhs: Direct(0), rhs: Direct(2) }, JumpIf { condition: Direct(3), location: 8 }, Const { destination: Direct(1), bit_size: Field, value: 1 }, BinaryFieldOp { destination: Direct(0), op: Div, lhs: Direct(1), rhs: Direct(0) }, Stop { return_data: HeapVector { pointer: Direct(20), size: Direct(21) } }]" + ], + "debug_symbols": "jZBBDoMgEEXvMmsWiqVNvUrTGMTRkBAgCE0a4907Gml1YdINw8znfSZ/gg7bNDTa9m6E+jFBG7QxemiMUzJqZ2k6zQxy28SASCPY6UR5GdBGqG0yhsFLmrQ+Gr20a40ykFowQNtRJcNeG1xuM/vRxTla3sUG86L84uJvnotL5q/VGc/P+epy2/hK8AP/pE4qHQ6JQUErMyjpnBfToGVrcMuyT1btoo1vn5Ucvg9OYZcCLqarRt98AA==", + "file_map": { + "50": { + "source": "// Regression test for issue \"V-NSCA-VUL-003: Missing ArraySet case in Removing Unreachable Functions pass\"\n// found in Veridise Audit.\n\nfn main(x: Field, y: pub Field) -> pub Field {\n assert(x != y);\n let mut f = [my_fun];\n f[0] = my_fun2;\n (f[0])(x)\n}\n\nfn my_fun(x: Field) -> Field {\n x + 1\n}\n\nfn my_fun2(x: Field) -> Field {\n x + 2\n}\n", + "path": "" + } + }, + "names": [ + "main" + ], + "brillig_names": [ + "directive_invert" + ] +} diff --git a/tooling/nargo_cli/tests/snapshots/execution_success/regression_8890/execute__tests__force_brillig_false_inliner_0.snap b/tooling/nargo_cli/tests/snapshots/execution_success/regression_8890/execute__tests__force_brillig_false_inliner_0.snap new file mode 100644 index 00000000000..4613ecc333c --- /dev/null +++ b/tooling/nargo_cli/tests/snapshots/execution_success/regression_8890/execute__tests__force_brillig_false_inliner_0.snap @@ -0,0 +1,58 @@ +--- +source: tooling/nargo_cli/tests/execute.rs +expression: artifact +--- +{ + "noir_version": "[noir_version]", + "hash": "[hash]", + "abi": { + "parameters": [ + { + "name": "x", + "type": { + "kind": "field" + }, + "visibility": "private" + }, + { + "name": "y", + "type": { + "kind": "field" + }, + "visibility": "public" + } + ], + "return_type": { + "abi_type": { + "kind": "field" + }, + "visibility": "public" + }, + "error_types": {} + }, + "bytecode": [ + "func 0", + "current witness index : _3", + "private parameters indices : [_0]", + "public parameters indices : [_1]", + "return value indices : [_2]", + "BRILLIG CALL func 0: inputs: [Single(Expression { mul_terms: [], linear_combinations: [(1, Witness(0)), (-1, Witness(1))], q_c: 0 })], outputs: [Simple(Witness(3))]", + "EXPR [ (1, _0, _3) (-1, _1, _3) -1 ]", + "EXPR [ (-1, _0) (1, _2) -2 ]", + "unconstrained func 0", + "[Const { destination: Direct(21), bit_size: Integer(U32), value: 1 }, Const { destination: Direct(20), bit_size: Integer(U32), value: 0 }, CalldataCopy { destination_address: Direct(0), size_address: Direct(21), offset_address: Direct(20) }, Const { destination: Direct(2), bit_size: Field, value: 0 }, BinaryFieldOp { destination: Direct(3), op: Equals, lhs: Direct(0), rhs: Direct(2) }, JumpIf { condition: Direct(3), location: 8 }, Const { destination: Direct(1), bit_size: Field, value: 1 }, BinaryFieldOp { destination: Direct(0), op: Div, lhs: Direct(1), rhs: Direct(0) }, Stop { return_data: HeapVector { pointer: Direct(20), size: Direct(21) } }]" + ], + "debug_symbols": "jZBBDoMgEEXvMmsWiqVNvUrTGMTRkBAgCE0a4907Gml1YdINw8znfSZ/gg7bNDTa9m6E+jFBG7QxemiMUzJqZ2k6zQxy28SASCPY6UR5GdBGqG0yhsFLmrQ+Gr20a40ykFowQNtRJcNeG1xuM/vRxTla3sUG86L84uJvnotL5q/VGc/P+epy2/hK8AP/pE4qHQ6JQUErMyjpnBfToGVrcMuyT1btoo1vn5Ucvg9OYZcCLqarRt98AA==", + "file_map": { + "50": { + "source": "// Regression test for issue \"V-NSCA-VUL-003: Missing ArraySet case in Removing Unreachable Functions pass\"\n// found in Veridise Audit.\n\nfn main(x: Field, y: pub Field) -> pub Field {\n assert(x != y);\n let mut f = [my_fun];\n f[0] = my_fun2;\n (f[0])(x)\n}\n\nfn my_fun(x: Field) -> Field {\n x + 1\n}\n\nfn my_fun2(x: Field) -> Field {\n x + 2\n}\n", + "path": "" + } + }, + "names": [ + "main" + ], + "brillig_names": [ + "directive_invert" + ] +} diff --git a/tooling/nargo_cli/tests/snapshots/execution_success/regression_8890/execute__tests__force_brillig_false_inliner_9223372036854775807.snap b/tooling/nargo_cli/tests/snapshots/execution_success/regression_8890/execute__tests__force_brillig_false_inliner_9223372036854775807.snap new file mode 100644 index 00000000000..4613ecc333c --- /dev/null +++ b/tooling/nargo_cli/tests/snapshots/execution_success/regression_8890/execute__tests__force_brillig_false_inliner_9223372036854775807.snap @@ -0,0 +1,58 @@ +--- +source: tooling/nargo_cli/tests/execute.rs +expression: artifact +--- +{ + "noir_version": "[noir_version]", + "hash": "[hash]", + "abi": { + "parameters": [ + { + "name": "x", + "type": { + "kind": "field" + }, + "visibility": "private" + }, + { + "name": "y", + "type": { + "kind": "field" + }, + "visibility": "public" + } + ], + "return_type": { + "abi_type": { + "kind": "field" + }, + "visibility": "public" + }, + "error_types": {} + }, + "bytecode": [ + "func 0", + "current witness index : _3", + "private parameters indices : [_0]", + "public parameters indices : [_1]", + "return value indices : [_2]", + "BRILLIG CALL func 0: inputs: [Single(Expression { mul_terms: [], linear_combinations: [(1, Witness(0)), (-1, Witness(1))], q_c: 0 })], outputs: [Simple(Witness(3))]", + "EXPR [ (1, _0, _3) (-1, _1, _3) -1 ]", + "EXPR [ (-1, _0) (1, _2) -2 ]", + "unconstrained func 0", + "[Const { destination: Direct(21), bit_size: Integer(U32), value: 1 }, Const { destination: Direct(20), bit_size: Integer(U32), value: 0 }, CalldataCopy { destination_address: Direct(0), size_address: Direct(21), offset_address: Direct(20) }, Const { destination: Direct(2), bit_size: Field, value: 0 }, BinaryFieldOp { destination: Direct(3), op: Equals, lhs: Direct(0), rhs: Direct(2) }, JumpIf { condition: Direct(3), location: 8 }, Const { destination: Direct(1), bit_size: Field, value: 1 }, BinaryFieldOp { destination: Direct(0), op: Div, lhs: Direct(1), rhs: Direct(0) }, Stop { return_data: HeapVector { pointer: Direct(20), size: Direct(21) } }]" + ], + "debug_symbols": "jZBBDoMgEEXvMmsWiqVNvUrTGMTRkBAgCE0a4907Gml1YdINw8znfSZ/gg7bNDTa9m6E+jFBG7QxemiMUzJqZ2k6zQxy28SASCPY6UR5GdBGqG0yhsFLmrQ+Gr20a40ykFowQNtRJcNeG1xuM/vRxTla3sUG86L84uJvnotL5q/VGc/P+epy2/hK8AP/pE4qHQ6JQUErMyjpnBfToGVrcMuyT1btoo1vn5Ucvg9OYZcCLqarRt98AA==", + "file_map": { + "50": { + "source": "// Regression test for issue \"V-NSCA-VUL-003: Missing ArraySet case in Removing Unreachable Functions pass\"\n// found in Veridise Audit.\n\nfn main(x: Field, y: pub Field) -> pub Field {\n assert(x != y);\n let mut f = [my_fun];\n f[0] = my_fun2;\n (f[0])(x)\n}\n\nfn my_fun(x: Field) -> Field {\n x + 1\n}\n\nfn my_fun2(x: Field) -> Field {\n x + 2\n}\n", + "path": "" + } + }, + "names": [ + "main" + ], + "brillig_names": [ + "directive_invert" + ] +} diff --git a/tooling/nargo_cli/tests/snapshots/execution_success/regression_8890/execute__tests__force_brillig_true_inliner_-9223372036854775808.snap b/tooling/nargo_cli/tests/snapshots/execution_success/regression_8890/execute__tests__force_brillig_true_inliner_-9223372036854775808.snap new file mode 100644 index 00000000000..4f7244bd30d --- /dev/null +++ b/tooling/nargo_cli/tests/snapshots/execution_success/regression_8890/execute__tests__force_brillig_true_inliner_-9223372036854775808.snap @@ -0,0 +1,61 @@ +--- +source: tooling/nargo_cli/tests/execute.rs +expression: artifact +--- +{ + "noir_version": "[noir_version]", + "hash": "[hash]", + "abi": { + "parameters": [ + { + "name": "x", + "type": { + "kind": "field" + }, + "visibility": "private" + }, + { + "name": "y", + "type": { + "kind": "field" + }, + "visibility": "public" + } + ], + "return_type": { + "abi_type": { + "kind": "field" + }, + "visibility": "public" + }, + "error_types": { + "17843811134343075018": { + "error_kind": "string", + "string": "Stack too deep" + } + } + }, + "bytecode": [ + "func 0", + "current witness index : _2", + "private parameters indices : [_0]", + "public parameters indices : [_1]", + "return value indices : [_2]", + "BRILLIG CALL func 0: inputs: [Single(Expression { mul_terms: [], linear_combinations: [(1, Witness(0))], q_c: 0 }), Single(Expression { mul_terms: [], linear_combinations: [(1, Witness(1))], q_c: 0 })], outputs: [Simple(Witness(2))]", + "unconstrained func 0", + "[Const { destination: Direct(2), bit_size: Integer(U32), value: 1 }, Const { destination: Direct(1), bit_size: Integer(U32), value: 32839 }, Const { destination: Direct(0), bit_size: Integer(U32), value: 3 }, Const { destination: Relative(3), bit_size: Integer(U32), value: 2 }, Const { destination: Relative(4), bit_size: Integer(U32), value: 0 }, CalldataCopy { destination_address: Direct(32836), size_address: Relative(3), offset_address: Relative(4) }, Mov { destination: Relative(1), source: Direct(32836) }, Mov { destination: Relative(2), source: Direct(32837) }, Call { location: 14 }, Call { location: 15 }, Mov { destination: Direct(32838), source: Relative(1) }, Const { destination: Relative(2), bit_size: Integer(U32), value: 32838 }, Const { destination: Relative(3), bit_size: Integer(U32), value: 1 }, Stop { return_data: HeapVector { pointer: Relative(2), size: Relative(3) } }, Return, Call { location: 26 }, BinaryFieldOp { destination: Relative(3), op: Equals, lhs: Relative(1), rhs: Relative(2) }, Const { destination: Relative(2), bit_size: Integer(U1), value: 0 }, BinaryIntOp { destination: Relative(4), op: Equals, bit_size: U1, lhs: Relative(3), rhs: Relative(2) }, JumpIf { condition: Relative(4), location: 22 }, Const { destination: Relative(5), bit_size: Integer(U32), value: 0 }, Trap { revert_data: HeapVector { pointer: Direct(1), size: Relative(5) } }, Const { destination: Relative(2), bit_size: Field, value: 2 }, BinaryFieldOp { destination: Relative(3), op: Add, lhs: Relative(1), rhs: Relative(2) }, Mov { destination: Relative(1), source: Relative(3) }, Return, Const { destination: Direct(32772), bit_size: Integer(U32), value: 30720 }, BinaryIntOp { destination: Direct(32771), op: LessThan, bit_size: U32, lhs: Direct(0), rhs: Direct(32772) }, JumpIf { condition: Direct(32771), location: 31 }, IndirectConst { destination_pointer: Direct(1), bit_size: Integer(U64), value: 17843811134343075018 }, Trap { revert_data: HeapVector { pointer: Direct(1), size: Direct(2) } }, Return]" + ], + "debug_symbols": "jZHLqsMgEIbfZdYuvDTpaV6llGCSSRHEBKsHSvDdO+bSpotAN37q+P0DzgQdNvFeG9cPD6iuEzTeWGvutR1aHczg6HYCnhdRQiUYiPOCvwWXGZIvEAskVIqgCCkx2LLq4BFz1C6cWo7aowtQuWgtg39t4/zoMWo3M2hPVc4AXUekwN5YzLvEPjY/VsWlWGXJxVsvfvZlcdr8Uh358thXp/Pqq0J++Tc66db4r+9OOckb3Vhcj3107a4anuNW2cY1+qHFLnrMSbuZ0XqVJVPilnK3Fw==", + "file_map": { + "50": { + "source": "// Regression test for issue \"V-NSCA-VUL-003: Missing ArraySet case in Removing Unreachable Functions pass\"\n// found in Veridise Audit.\n\nfn main(x: Field, y: pub Field) -> pub Field {\n assert(x != y);\n let mut f = [my_fun];\n f[0] = my_fun2;\n (f[0])(x)\n}\n\nfn my_fun(x: Field) -> Field {\n x + 1\n}\n\nfn my_fun2(x: Field) -> Field {\n x + 2\n}\n", + "path": "" + } + }, + "names": [ + "main" + ], + "brillig_names": [ + "main" + ] +} diff --git a/tooling/nargo_cli/tests/snapshots/execution_success/regression_8890/execute__tests__force_brillig_true_inliner_0.snap b/tooling/nargo_cli/tests/snapshots/execution_success/regression_8890/execute__tests__force_brillig_true_inliner_0.snap new file mode 100644 index 00000000000..4f7244bd30d --- /dev/null +++ b/tooling/nargo_cli/tests/snapshots/execution_success/regression_8890/execute__tests__force_brillig_true_inliner_0.snap @@ -0,0 +1,61 @@ +--- +source: tooling/nargo_cli/tests/execute.rs +expression: artifact +--- +{ + "noir_version": "[noir_version]", + "hash": "[hash]", + "abi": { + "parameters": [ + { + "name": "x", + "type": { + "kind": "field" + }, + "visibility": "private" + }, + { + "name": "y", + "type": { + "kind": "field" + }, + "visibility": "public" + } + ], + "return_type": { + "abi_type": { + "kind": "field" + }, + "visibility": "public" + }, + "error_types": { + "17843811134343075018": { + "error_kind": "string", + "string": "Stack too deep" + } + } + }, + "bytecode": [ + "func 0", + "current witness index : _2", + "private parameters indices : [_0]", + "public parameters indices : [_1]", + "return value indices : [_2]", + "BRILLIG CALL func 0: inputs: [Single(Expression { mul_terms: [], linear_combinations: [(1, Witness(0))], q_c: 0 }), Single(Expression { mul_terms: [], linear_combinations: [(1, Witness(1))], q_c: 0 })], outputs: [Simple(Witness(2))]", + "unconstrained func 0", + "[Const { destination: Direct(2), bit_size: Integer(U32), value: 1 }, Const { destination: Direct(1), bit_size: Integer(U32), value: 32839 }, Const { destination: Direct(0), bit_size: Integer(U32), value: 3 }, Const { destination: Relative(3), bit_size: Integer(U32), value: 2 }, Const { destination: Relative(4), bit_size: Integer(U32), value: 0 }, CalldataCopy { destination_address: Direct(32836), size_address: Relative(3), offset_address: Relative(4) }, Mov { destination: Relative(1), source: Direct(32836) }, Mov { destination: Relative(2), source: Direct(32837) }, Call { location: 14 }, Call { location: 15 }, Mov { destination: Direct(32838), source: Relative(1) }, Const { destination: Relative(2), bit_size: Integer(U32), value: 32838 }, Const { destination: Relative(3), bit_size: Integer(U32), value: 1 }, Stop { return_data: HeapVector { pointer: Relative(2), size: Relative(3) } }, Return, Call { location: 26 }, BinaryFieldOp { destination: Relative(3), op: Equals, lhs: Relative(1), rhs: Relative(2) }, Const { destination: Relative(2), bit_size: Integer(U1), value: 0 }, BinaryIntOp { destination: Relative(4), op: Equals, bit_size: U1, lhs: Relative(3), rhs: Relative(2) }, JumpIf { condition: Relative(4), location: 22 }, Const { destination: Relative(5), bit_size: Integer(U32), value: 0 }, Trap { revert_data: HeapVector { pointer: Direct(1), size: Relative(5) } }, Const { destination: Relative(2), bit_size: Field, value: 2 }, BinaryFieldOp { destination: Relative(3), op: Add, lhs: Relative(1), rhs: Relative(2) }, Mov { destination: Relative(1), source: Relative(3) }, Return, Const { destination: Direct(32772), bit_size: Integer(U32), value: 30720 }, BinaryIntOp { destination: Direct(32771), op: LessThan, bit_size: U32, lhs: Direct(0), rhs: Direct(32772) }, JumpIf { condition: Direct(32771), location: 31 }, IndirectConst { destination_pointer: Direct(1), bit_size: Integer(U64), value: 17843811134343075018 }, Trap { revert_data: HeapVector { pointer: Direct(1), size: Direct(2) } }, Return]" + ], + "debug_symbols": "jZHLqsMgEIbfZdYuvDTpaV6llGCSSRHEBKsHSvDdO+bSpotAN37q+P0DzgQdNvFeG9cPD6iuEzTeWGvutR1aHczg6HYCnhdRQiUYiPOCvwWXGZIvEAskVIqgCCkx2LLq4BFz1C6cWo7aowtQuWgtg39t4/zoMWo3M2hPVc4AXUekwN5YzLvEPjY/VsWlWGXJxVsvfvZlcdr8Uh358thXp/Pqq0J++Tc66db4r+9OOckb3Vhcj3107a4anuNW2cY1+qHFLnrMSbuZ0XqVJVPilnK3Fw==", + "file_map": { + "50": { + "source": "// Regression test for issue \"V-NSCA-VUL-003: Missing ArraySet case in Removing Unreachable Functions pass\"\n// found in Veridise Audit.\n\nfn main(x: Field, y: pub Field) -> pub Field {\n assert(x != y);\n let mut f = [my_fun];\n f[0] = my_fun2;\n (f[0])(x)\n}\n\nfn my_fun(x: Field) -> Field {\n x + 1\n}\n\nfn my_fun2(x: Field) -> Field {\n x + 2\n}\n", + "path": "" + } + }, + "names": [ + "main" + ], + "brillig_names": [ + "main" + ] +} diff --git a/tooling/nargo_cli/tests/snapshots/execution_success/regression_8890/execute__tests__force_brillig_true_inliner_9223372036854775807.snap b/tooling/nargo_cli/tests/snapshots/execution_success/regression_8890/execute__tests__force_brillig_true_inliner_9223372036854775807.snap new file mode 100644 index 00000000000..4f7244bd30d --- /dev/null +++ b/tooling/nargo_cli/tests/snapshots/execution_success/regression_8890/execute__tests__force_brillig_true_inliner_9223372036854775807.snap @@ -0,0 +1,61 @@ +--- +source: tooling/nargo_cli/tests/execute.rs +expression: artifact +--- +{ + "noir_version": "[noir_version]", + "hash": "[hash]", + "abi": { + "parameters": [ + { + "name": "x", + "type": { + "kind": "field" + }, + "visibility": "private" + }, + { + "name": "y", + "type": { + "kind": "field" + }, + "visibility": "public" + } + ], + "return_type": { + "abi_type": { + "kind": "field" + }, + "visibility": "public" + }, + "error_types": { + "17843811134343075018": { + "error_kind": "string", + "string": "Stack too deep" + } + } + }, + "bytecode": [ + "func 0", + "current witness index : _2", + "private parameters indices : [_0]", + "public parameters indices : [_1]", + "return value indices : [_2]", + "BRILLIG CALL func 0: inputs: [Single(Expression { mul_terms: [], linear_combinations: [(1, Witness(0))], q_c: 0 }), Single(Expression { mul_terms: [], linear_combinations: [(1, Witness(1))], q_c: 0 })], outputs: [Simple(Witness(2))]", + "unconstrained func 0", + "[Const { destination: Direct(2), bit_size: Integer(U32), value: 1 }, Const { destination: Direct(1), bit_size: Integer(U32), value: 32839 }, Const { destination: Direct(0), bit_size: Integer(U32), value: 3 }, Const { destination: Relative(3), bit_size: Integer(U32), value: 2 }, Const { destination: Relative(4), bit_size: Integer(U32), value: 0 }, CalldataCopy { destination_address: Direct(32836), size_address: Relative(3), offset_address: Relative(4) }, Mov { destination: Relative(1), source: Direct(32836) }, Mov { destination: Relative(2), source: Direct(32837) }, Call { location: 14 }, Call { location: 15 }, Mov { destination: Direct(32838), source: Relative(1) }, Const { destination: Relative(2), bit_size: Integer(U32), value: 32838 }, Const { destination: Relative(3), bit_size: Integer(U32), value: 1 }, Stop { return_data: HeapVector { pointer: Relative(2), size: Relative(3) } }, Return, Call { location: 26 }, BinaryFieldOp { destination: Relative(3), op: Equals, lhs: Relative(1), rhs: Relative(2) }, Const { destination: Relative(2), bit_size: Integer(U1), value: 0 }, BinaryIntOp { destination: Relative(4), op: Equals, bit_size: U1, lhs: Relative(3), rhs: Relative(2) }, JumpIf { condition: Relative(4), location: 22 }, Const { destination: Relative(5), bit_size: Integer(U32), value: 0 }, Trap { revert_data: HeapVector { pointer: Direct(1), size: Relative(5) } }, Const { destination: Relative(2), bit_size: Field, value: 2 }, BinaryFieldOp { destination: Relative(3), op: Add, lhs: Relative(1), rhs: Relative(2) }, Mov { destination: Relative(1), source: Relative(3) }, Return, Const { destination: Direct(32772), bit_size: Integer(U32), value: 30720 }, BinaryIntOp { destination: Direct(32771), op: LessThan, bit_size: U32, lhs: Direct(0), rhs: Direct(32772) }, JumpIf { condition: Direct(32771), location: 31 }, IndirectConst { destination_pointer: Direct(1), bit_size: Integer(U64), value: 17843811134343075018 }, Trap { revert_data: HeapVector { pointer: Direct(1), size: Direct(2) } }, Return]" + ], + "debug_symbols": "jZHLqsMgEIbfZdYuvDTpaV6llGCSSRHEBKsHSvDdO+bSpotAN37q+P0DzgQdNvFeG9cPD6iuEzTeWGvutR1aHczg6HYCnhdRQiUYiPOCvwWXGZIvEAskVIqgCCkx2LLq4BFz1C6cWo7aowtQuWgtg39t4/zoMWo3M2hPVc4AXUekwN5YzLvEPjY/VsWlWGXJxVsvfvZlcdr8Uh358thXp/Pqq0J++Tc66db4r+9OOckb3Vhcj3107a4anuNW2cY1+qHFLnrMSbuZ0XqVJVPilnK3Fw==", + "file_map": { + "50": { + "source": "// Regression test for issue \"V-NSCA-VUL-003: Missing ArraySet case in Removing Unreachable Functions pass\"\n// found in Veridise Audit.\n\nfn main(x: Field, y: pub Field) -> pub Field {\n assert(x != y);\n let mut f = [my_fun];\n f[0] = my_fun2;\n (f[0])(x)\n}\n\nfn my_fun(x: Field) -> Field {\n x + 1\n}\n\nfn my_fun2(x: Field) -> Field {\n x + 2\n}\n", + "path": "" + } + }, + "names": [ + "main" + ], + "brillig_names": [ + "main" + ] +} diff --git a/tooling/nargo_cli/tests/snapshots/execution_success/regression_8890/execute__tests__stdout.snap b/tooling/nargo_cli/tests/snapshots/execution_success/regression_8890/execute__tests__stdout.snap new file mode 100644 index 00000000000..9ec4dff6130 --- /dev/null +++ b/tooling/nargo_cli/tests/snapshots/execution_success/regression_8890/execute__tests__stdout.snap @@ -0,0 +1,5 @@ +--- +source: tooling/nargo_cli/tests/execute.rs +expression: stdout +--- +[regression_8890] Circuit output: Field(5)