Gas consumption differs with or without logger
I found an example of different gas consumption with and without the --trace-stack
option.
The example below shows that
-
run script
fails because of out of gas without--trace-stack
-
run script
succeeds with--trace-stack
I believe some gases for MAP
(IOPT_MAP
) are not charged with loggers.
$ cat opt_map.tz
{ parameter unit ;
storage unit ;
code { PUSH int 0;
SOME;
PUSH int 1000;
PUSH bool True;
LOOP
{
DIP { MAP { PUSH int 1; ADD }; };
PUSH int 1;
SWAP;
SUB;
DUP;
GT;
};
DROP;
DROP;
CDR;
NIL operation;
PAIR;
}
}
$ octez-client --mode mockup --base-dir mockup run script ./opt_map.tz on storage "Unit" and input "Unit" -G 208
Runtime error in contract KT1BEqzn5Wx8uJrZNvuS9DVHmLvG9td3fDLi:
01: { parameter unit ;
02: storage unit ;
03: code { PUSH int 0;
04: SOME;
05: PUSH int 1000;
06: PUSH bool True;
07: LOOP
08: {
09: DIP { MAP { PUSH int 1; ADD }; };
10: PUSH int 1;
11: SWAP;
12: SUB;
13: DUP;
14: GT;
15: };
16: DROP;
17: DROP;
18: CDR;
19: NIL operation;
20: PAIR;
21: }
22: }
23:
Gas limit exceeded during typechecking or execution.
Try again with a higher gas limit.
Fatal error:
error running script
$ octez-client --mode mockup --base-dir mockup run script ./opt_map.tz on storage "Unit" and input "Unit" -G 208 --trace-stack
storage
Unit
emitted operations
big_map diff
trace
- location: 7 (remaining gas: 191.330 units remaining)
[ (Pair Unit Unit) ]
- location: 7 (remaining gas: 191.320 units remaining)
[ 0
(Pair Unit Unit) ]
:
- location: 36 (remaining gas: 1.260 units remaining)
[ Unit ]
- location: 37 (remaining gas: 1.250 units remaining)
[ {}
Unit ]
- location: 39 (remaining gas: 1.240 units remaining)
[ (Pair {} Unit) ]