You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
unconstrained fnmain(sorted_index:[u32;2]){let original = [55,11];letmut sorted = original;for i in0..2{let index = sorted_index[i];let value = original[index];
sorted[i] = value;}assert_eq(sorted[1],55);}
Expected Behavior
With this Prover.toml:
sorted_index = ["1", "0"]
Program execution should pass
Bug
The program doesn't execute correctly, since DIE removes the inc_rc on the constant array:
After Constraint Folding:
brillig fn main f0 {
b0(v0: [u32; 2]):
inc_rc [Field 55, Field 11]
inc_rc [Field 55, Field 11]
v5 = allocate
store [Field 55, Field 11] at v5
jmp b1(u32 0)
b1(v1: u32):
v8 = lt v1, u32 2
jmpif v8 then: b3, else: b2
b3():
v13 = array_get v0, index v1
v14 = array_get [Field 55, Field 11], index v13
v15 = load v5
v16 = array_set v15, index v1, value v14
v17 = add v1, u32 1
store v16 at v5
jmp b1(v17)
b2():
v9 = load v5
v11 = array_get v9, index u32 1
v12 = eq v11, Field 55
constrain v11 == Field 55
return
}
After Dead Instruction Elimination:
brillig fn main f0 {
b0(v0: [u32; 2]):
v2 = allocate
store [Field 55, Field 11] at v2
jmp b1(u32 0)
b1(v1: u32):
v8 = lt v1, u32 2
jmpif v8 then: b3, else: b2
b3():
v12 = array_get v0, index v1
v13 = array_get [Field 55, Field 11], index v12
v14 = load v2
v15 = array_set v14, index v1, value v13
v16 = add v1, u32 1
store v15 at v2
jmp b1(v16)
b2():
v9 = load v2
v11 = array_get v9, index u32 1
constrain v11 == Field 55
return
}
After Array Set Optimizations:
brillig fn main f0 {
b0(v0: [u32; 2]):
v2 = allocate
store [Field 55, Field 11] at v2
jmp b1(u32 0)
b1(v1: u32):
v8 = lt v1, u32 2
jmpif v8 then: b3, else: b2
b3():
v12 = array_get v0, index v1
v13 = array_get [Field 55, Field 11], index v12
v14 = load v2
v15 = array_set v14, index v1, value v13
v16 = add v1, u32 1
store v15 at v2
jmp b1(v16)
b2():
v9 = load v2
v11 = array_get v9, index u32 1
constrain v11 == Field 55
return
}
So when executing v16 = array_set v15, index v1, value v14 we overwrite in place the constant array.
To Reproduce
Workaround
None
Workaround Description
No response
Additional Context
No response
Project Impact
None
Blocker Context
No response
Nargo Version
No response
NoirJS Version
No response
Proving Backend Tooling & Version
No response
Would you like to submit a PR for this Issue?
None
Support Needs
No response
The text was updated successfully, but these errors were encountered:
# Description
## Problem\*
Resolves#6121
## Summary\*
Die was not considering constants as used. As a result, the reference
counter operations on constants were removed.
This created a correctness issue.
## Additional Context
## Documentation\*
Check one:
- [x] No documentation needed.
- [ ] Documentation included in this PR.
- [ ] **[For Experimental Features]** Documentation to be submitted in a
separate PR.
# PR Checklist\*
- [x] I have tested the changes locally.
- [x] I have formatted the changes with [Prettier](https://prettier.io/)
and/or `cargo fmt` on default settings.
Aim
Compile the following program:
Expected Behavior
With this Prover.toml:
Program execution should pass
Bug
The program doesn't execute correctly, since DIE removes the inc_rc on the constant array:
So when executing
v16 = array_set v15, index v1, value v14
we overwrite in place the constant array.To Reproduce
Workaround
None
Workaround Description
No response
Additional Context
No response
Project Impact
None
Blocker Context
No response
Nargo Version
No response
NoirJS Version
No response
Proving Backend Tooling & Version
No response
Would you like to submit a PR for this Issue?
None
Support Needs
No response
The text was updated successfully, but these errors were encountered: