Zokrates / ZoKrates

A toolbox for zkSNARKs on Ethereum
https://zokrates.github.io
GNU Lesser General Public License v3.0
1.81k stars 361 forks source link

Wrong output of function log inside loop #1324

Open beriarue opened 1 year ago

beriarue commented 1 year ago

Description

In the code below, the function log should be executed for 5 times, and the sentence res is "0x00000000" should be printed for 5 times. However, such sentence is only printed once during the runtime.

def main() -> u32 {
    u32 res = 0;
    for u32 i in 0..5 {
        log("res is {}", res);
    }
    return res;
}

Expected result:

...
res is "0x00000000"
res is "0x00000000"
res is "0x00000000"
res is "0x00000000"
res is "0x00000000"
...

Environment

Steps to Reproduce

Save the buggy code into buggy.zok. Run the following commands from CLI:

# compile
zokrates compile --debug -i buggy.zok
zokrates setup
zokrates compute-witness
zokrates generate-proof
zokrates verify

You would see the following output, which is different from the expected result shown before.

...
res is "0x00000000"
...