Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Brillig functions with oracle calls are being optimized away #2333

Closed
TomAFrench opened this issue Aug 15, 2023 · 1 comment
Closed

Brillig functions with oracle calls are being optimized away #2333

TomAFrench opened this issue Aug 15, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@TomAFrench
Copy link
Member

Aim

Brillig functions which contain oracle calls should be maintained whether we use the output or not.

Expected Behavior

Brillig functions which contain oracle calls should be maintained whether we use the output or not as the caller may be relying on the foreign call to pass out information from the circuit.

Bug

The integration test brillig_oracle gets compiled down to an empty circuit.

To Reproduce

  1. Install nargo 0.10.1
  2. run nargo info --show-ssa on brillig_oracle test case
  3. See that dead instruction pass removes call to get_number_sequence_wrapper

Installation Method

Compiled from source

Nargo Version

nargo 0.10.1 (git version hash: fd29197, is dirty: false)

Additional Context

No response

Would you like to submit a PR for this Issue?

No

Support Needs

No response

@TomAFrench TomAFrench added the bug Something isn't working label Aug 15, 2023
@TomAFrench
Copy link
Member Author

After Constant Folding:
acir fn main f0 {
  b0(v0: Field):
    call f1(Field 20)
    return 
}
brillig fn get_number_sequence_wrapper f1 {
  b0(v0: Field):
    v195 = call v1(v0)
    v196 = array_get v195, index u32 0
    v197 = eq v196, Field 0
    constrain v197
    v198 = array_get v195, index u32 1
    v199 = eq v198, Field 1
    constrain v199
    v200 = array_get v195, index u32 2
    v201 = eq v200, Field 2
    constrain v201
    v202 = array_get v195, index u32 3
    v203 = eq v202, Field 3
    constrain v203
    v204 = array_get v195, index u32 4
    v205 = eq v204, Field 4
    constrain v205
    v206 = array_get v195, index u32 5
    v207 = eq v206, Field 5
    constrain v207
    v208 = array_get v195, index u32 6
    v209 = eq v208, Field 6
    constrain v209
    v210 = array_get v195, index u32 7
    v211 = eq v210, Field 7
    constrain v211
    v212 = array_get v195, index u32 8
    v213 = eq v212, Field 8
    constrain v213
    v214 = array_get v195, index u32 9
    v215 = eq v214, Field 9
    constrain v215
    v216 = array_get v195, index u32 10
    v217 = eq v216, Field 10
    constrain v217
    v218 = array_get v195, index u32 11
    v219 = eq v218, Field 11
    constrain v219
    v220 = array_get v195, index u32 12
    v221 = eq v220, Field 12
    constrain v221
    v222 = array_get v195, index u32 13
    v223 = eq v222, Field 13
    constrain v223
    v224 = array_get v195, index u32 14
    v225 = eq v224, Field 14
    constrain v225
    v226 = array_get v195, index u32 15
    v227 = eq v226, Field 15
    constrain v227
    v228 = array_get v195, index u32 2⁴
    v229 = eq v228, Field 2⁴
    constrain v229
    v230 = array_get v195, index u32 17
    v231 = eq v230, Field 17
    constrain v231
    v232 = array_get v195, index u32 18
    v233 = eq v232, Field 18
    constrain v233
    v234 = call v13(v0)
    v235 = array_get v195, index u32 0
    v236 = array_get v234, index u32 19
    v237 = eq v235, v236
    constrain v237
    v238 = array_get v195, index u32 1
    v239 = array_get v234, index u32 18
    v240 = eq v238, v239
    constrain v240
    v241 = array_get v195, index u32 2
    v242 = array_get v234, index u32 17
    v243 = eq v241, v242
    constrain v243
    v244 = array_get v195, index u32 3
    v245 = array_get v234, index u32 2⁴
    v246 = eq v244, v245
    constrain v246
    v247 = array_get v195, index u32 4
    v248 = array_get v234, index u32 15
    v249 = eq v247, v248
    constrain v249
    v250 = array_get v195, index u32 5
    v251 = array_get v234, index u32 14
    v252 = eq v250, v251
    constrain v252
    v253 = array_get v195, index u32 6
    v254 = array_get v234, index u32 13
    v255 = eq v253, v254
    constrain v255
    v256 = array_get v195, index u32 7
    v257 = array_get v234, index u32 12
    v258 = eq v256, v257
    constrain v258
    v259 = array_get v195, index u32 8
    v260 = array_get v234, index u32 11
    v261 = eq v259, v260
    constrain v261
    v262 = array_get v195, index u32 9
    v263 = array_get v234, index u32 10
    v264 = eq v262, v263
    constrain v264
    v265 = array_get v195, index u32 10
    v266 = array_get v234, index u32 9
    v267 = eq v265, v266
    constrain v267
    v268 = array_get v195, index u32 11
    v269 = array_get v234, index u32 8
    v270 = eq v268, v269
    constrain v270
    v271 = array_get v195, index u32 12
    v272 = array_get v234, index u32 7
    v273 = eq v271, v272
    constrain v273
    v274 = array_get v195, index u32 13
    v275 = array_get v234, index u32 6
    v276 = eq v274, v275
    constrain v276
    v277 = array_get v195, index u32 14
    v278 = array_get v234, index u32 5
    v279 = eq v277, v278
    constrain v279
    v280 = array_get v195, index u32 15
    v281 = array_get v234, index u32 4
    v282 = eq v280, v281
    constrain v282
    v283 = array_get v195, index u32 2⁴
    v284 = array_get v234, index u32 3
    v285 = eq v283, v284
    constrain v285
    v286 = array_get v195, index u32 17
    v287 = array_get v234, index u32 2
    v288 = eq v286, v287
    constrain v288
    v289 = array_get v195, index u32 18
    v290 = array_get v234, index u32 1
    v291 = eq v289, v290
    constrain v291
    return 
}
acir fn main f2 {
  b0(v0: Field):
    call f1(Field 20)
    return 
}

After Dead Instruction Elimination:
acir fn main f0 {
  b0(v0: Field):
    return 
}
brillig fn get_number_sequence_wrapper f1 {
  b0(v0: Field):
    v195 = call v1(v0)
    v196 = array_get v195, index u32 0
    v197 = eq v196, Field 0
    constrain v197
    v198 = array_get v195, index u32 1
    v199 = eq v198, Field 1
    constrain v199
    v200 = array_get v195, index u32 2
    v201 = eq v200, Field 2
    constrain v201
    v202 = array_get v195, index u32 3
    v203 = eq v202, Field 3
    constrain v203
    v204 = array_get v195, index u32 4
    v205 = eq v204, Field 4
    constrain v205
    v206 = array_get v195, index u32 5
    v207 = eq v206, Field 5
    constrain v207
    v208 = array_get v195, index u32 6
    v209 = eq v208, Field 6
    constrain v209
    v210 = array_get v195, index u32 7
    v211 = eq v210, Field 7
    constrain v211
    v212 = array_get v195, index u32 8
    v213 = eq v212, Field 8
    constrain v213
    v214 = array_get v195, index u32 9
    v215 = eq v214, Field 9
    constrain v215
    v216 = array_get v195, index u32 10
    v217 = eq v216, Field 10
    constrain v217
    v218 = array_get v195, index u32 11
    v219 = eq v218, Field 11
    constrain v219
    v220 = array_get v195, index u32 12
    v221 = eq v220, Field 12
    constrain v221
    v222 = array_get v195, index u32 13
    v223 = eq v222, Field 13
    constrain v223
    v224 = array_get v195, index u32 14
    v225 = eq v224, Field 14
    constrain v225
    v226 = array_get v195, index u32 15
    v227 = eq v226, Field 15
    constrain v227
    v228 = array_get v195, index u32 2⁴
    v229 = eq v228, Field 2⁴
    constrain v229
    v230 = array_get v195, index u32 17
    v231 = eq v230, Field 17
    constrain v231
    v232 = array_get v195, index u32 18
    v233 = eq v232, Field 18
    constrain v233
    v234 = call v13(v0)
    v235 = array_get v195, index u32 0
    v236 = array_get v234, index u32 19
    v237 = eq v235, v236
    constrain v237
    v238 = array_get v195, index u32 1
    v239 = array_get v234, index u32 18
    v240 = eq v238, v239
    constrain v240
    v241 = array_get v195, index u32 2
    v242 = array_get v234, index u32 17
    v243 = eq v241, v242
    constrain v243
    v244 = array_get v195, index u32 3
    v245 = array_get v234, index u32 2⁴
    v246 = eq v244, v245
    constrain v246
    v247 = array_get v195, index u32 4
    v248 = array_get v234, index u32 15
    v249 = eq v247, v248
    constrain v249
    v250 = array_get v195, index u32 5
    v251 = array_get v234, index u32 14
    v252 = eq v250, v251
    constrain v252
    v253 = array_get v195, index u32 6
    v254 = array_get v234, index u32 13
    v255 = eq v253, v254
    constrain v255
    v256 = array_get v195, index u32 7
    v257 = array_get v234, index u32 12
    v258 = eq v256, v257
    constrain v258
    v259 = array_get v195, index u32 8
    v260 = array_get v234, index u32 11
    v261 = eq v259, v260
    constrain v261
    v262 = array_get v195, index u32 9
    v263 = array_get v234, index u32 10
    v264 = eq v262, v263
    constrain v264
    v265 = array_get v195, index u32 10
    v266 = array_get v234, index u32 9
    v267 = eq v265, v266
    constrain v267
    v268 = array_get v195, index u32 11
    v269 = array_get v234, index u32 8
    v270 = eq v268, v269
    constrain v270
    v271 = array_get v195, index u32 12
    v272 = array_get v234, index u32 7
    v273 = eq v271, v272
    constrain v273
    v274 = array_get v195, index u32 13
    v275 = array_get v234, index u32 6
    v276 = eq v274, v275
    constrain v276
    v277 = array_get v195, index u32 14
    v278 = array_get v234, index u32 5
    v279 = eq v277, v278
    constrain v279
    v280 = array_get v195, index u32 15
    v281 = array_get v234, index u32 4
    v282 = eq v280, v281
    constrain v282
    v283 = array_get v195, index u32 2⁴
    v284 = array_get v234, index u32 3
    v285 = eq v283, v284
    constrain v285
    v286 = array_get v195, index u32 17
    v287 = array_get v234, index u32 2
    v288 = eq v286, v287
    constrain v288
    v289 = array_get v195, index u32 18
    v290 = array_get v234, index u32 1
    v291 = eq v289, v290
    constrain v291
    return 
}
acir fn main f2 {
  b0(v0: Field):
    return 
}


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Archived in project
Development

No branches or pull requests

1 participant