kadena-io / pact

The Pact Smart Contract Language
https://docs.kadena.io/build/pact
BSD 3-Clause "New" or "Revised" License
579 stars 100 forks source link

Divide by 0 in gas computation of `(concat)` #1316

Closed CryptoPascal31 closed 9 months ago

CryptoPascal31 commented 10 months ago

Issue description

When using (concat) with an empty list, a divide by 0 error is thrown here: https://github.com/kadena-io/pact/blob/9d8d0975d58fd811404130a57724bfb5a2f2af80/src/Pact/Gas/Table.hs#L270

This bug as been introduced in Pact 4.8 by: https://github.com/kadena-io/pact/pull/1269

Steps to reproduce

pact> (concat [])
""

OK


but:

pact> (env-gasmodel "table")
pact> (env-gaslimit 10000)
"Set gas limit to 10000"
pact> (concat [])
<interactive>:1:0:Error: divide by zero

And of course, the error occurs on-chain too.

rsoeldner commented 10 months ago

Good catch, thank you @CryptoPascal31

CryptoPascal31 commented 10 months ago

https://github.com/kadena-io/pact/pull/1317