Debug mode to turn off hermetization #775

Merged
zxq9 merged 1 commits from hermetization-turnoff into lima 2020-10-12 20:17:41 +09:00
zxq9 commented 2020-10-10 01:44:13 +09:00 (Migrated from gitlab.com)

Created by: radrow

Added debug_mode option which exposes all functions in all namespaces and main contract to ease the process of unit testing. Meaning of this flag can be later extended to some additional features.

fixes #277

*Created by: radrow* Added `debug_mode` option which exposes all functions in all namespaces and main contract to ease the process of unit testing. Meaning of this flag can be later extended to some additional features. fixes #277
gorbak25 (Migrated from gitlab.com) approved these changes 2020-10-10 01:44:13 +09:00
zxq9 commented 2020-10-10 03:45:36 +09:00 (Migrated from gitlab.com)

Created by: hanssv

Friday evening so not looking at the PR in detail. But this is really dangerous - imagine if you forget to switch off the option and deploy - is there a clever way to make it safer? 🤔

*Created by: hanssv* Friday evening so not looking at the PR in detail. But this is really dangerous - imagine if you forget to switch off the option and deploy - is there a clever way to make it safer? 🤔
zxq9 commented 2020-10-11 03:14:35 +09:00 (Migrated from gitlab.com)

Created by: radrow

I don't think it is a real issue - this flag is supposed to be used only by debuggers and sdks. If someone would be about to deploy a contract in debug mode then their interface should warn them about it

*Created by: radrow* I don't think it is a real issue - this flag is supposed to be used only by debuggers and sdks. If someone would be about to deploy a contract in debug mode then their interface should warn them about it
zxq9 commented 2020-10-11 03:17:28 +09:00 (Migrated from gitlab.com)

Created by: radrow

We can also add a pragma for network id and require additional flag if someone is going to deploy debug contract to the mainnet. But this would require some assertion of the net id from inside of the bytecode to make it work reasonably...

*Created by: radrow* We can also add a pragma for network id and require additional flag if someone is going to deploy debug contract to the mainnet. But this would require some assertion of the net id from inside of the bytecode to make it work reasonably...
zxq9 commented 2020-10-12 16:08:42 +09:00 (Migrated from gitlab.com)

Created by: hanssv

I'm not sure it is worth it, I'm normally all for giving users/people good tools for shooting themselves in the foot - it's just that crypto people seem to be so talented in screwing up...

*Created by: hanssv* I'm not sure it is worth it, I'm normally all for giving users/people good tools for shooting themselves in the foot - it's just that crypto people seem to be so talented in screwing up...
gorbak25 commented 2020-10-12 17:40:33 +09:00 (Migrated from gitlab.com)

I agree that exposing a debug mode gives users a new way to kill their app.
On the other hand I see 2 reasons why this is a good idea:

  • Unit tests of internals - let's say I've implemented my own qsort routine in my contract and I want to test it without exporting it as an entrypoint.
  • A bytecode validation infrastructure needs to be set up sooner or later - a contract compiled in debug mode won't validate

It's a security/usability trade-off.

I agree that exposing a debug mode gives users a new way to kill their app. On the other hand I see 2 reasons why this is a good idea: - Unit tests of internals - let's say I've implemented my own qsort routine in my contract and I want to test it without exporting it as an entrypoint. - A bytecode validation infrastructure needs to be set up sooner or later - a contract compiled in debug mode won't validate It's a security/usability trade-off.
zxq9 commented 2020-10-12 17:51:05 +09:00 (Migrated from gitlab.com)

Created by: radrow

Anyway, nobody uses the compiler directly. There is always a frontend to it that is responsible for handling flags and configurations. If it is not implemented there, the flag won't be even usable for regular users.

*Created by: radrow* Anyway, nobody uses the compiler directly. There is always a frontend to it that is responsible for handling flags and configurations. If it is not implemented there, the flag won't be even usable for regular users.
zxq9 commented 2020-10-12 18:16:56 +09:00 (Migrated from gitlab.com)

Created by: hanssv

Review: Approved

*Created by: hanssv* **Review:** Approved
gorbak25 commented 2020-10-12 20:16:42 +09:00 (Migrated from gitlab.com)

approved this merge request

approved this merge request
zxq9 commented 2020-10-12 20:17:41 +09:00 (Migrated from gitlab.com)

Merged by: radrow at 2020-10-12 11:17:41 UTC

*Merged by: radrow at 2020-10-12 11:17:41 UTC*
Sign in to join this conversation.
No description provided.