|
|
|
|
|
by jsnathan
3216 days ago
|
|
I'm curious: could any of the recently known smart contract bugs have been prevented through the use of a stricter type system? I tend to think of type systems more as a hindrance myself. I mean, they can certainly help you catch bugs before the code even runs - but which of those bugs would you not catch during the testing phase anyway? I'm genuinely curious: what types of bugs does a stricter type system catch that a reasonable test suite probably would not? Note I'm not saying that tests guarantee bug-free code, or that you can't do both. I'm just wondering about which different kinds of bugs you might catch. |
|
Short-answer is yes, and there's been lots of work done to go even further than having static typing and have formal verification for smart-contracts.
>I'm genuinely curious: what types of bugs does a stricter type system catch that a reasonable test suite probably would not?
Not sure what you mean by "reasonable" (is it extensive? testing pathological cases? where do you draw the line?). But type checking at compile time makes your code less inclined to showcase a certain class of bugs that are the byproduct of ambiguity in the language semantics and logical mistake in the programmer writing the code.
And with formal verification you can actually make sure that your logic meets the specs. You can hardly extract stronger correctness guarantees than that!
If that interests you, check out Tezos (https://tezos.com/) and github.com/tezos/tezos. The entire codebase is in OCaml.
It was on the frontpage a while back: https://news.ycombinator.com/item?id=15061029