Can Bitcoin Script be expressed in Simplicity? #328
-
|
I believe the most significant cost of adding Simplicity to Bitcoin is the eternal carrying cost of an additional language in consensus code. How close to 1 language can we get with Simplicity? Obviously, Script can't be removed, but to what extent can Script be implemented in Simplicity? If so, it seems to me Bitcoin Core consensus code would become strictly cheaper to reason about than today, and alternate implementations would become more feasible: given Simplicity in Bitcoin, and Script implemented in Simplicity it should be much safer to use a node in language X given a provably correct Simplicity implementation in X. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
|
Simplicity can express the semantics of any Bitcoin script, i.e., the Simplicity program will accept exactly the same witness data + transaction introspection as the Bitcoin script. Writing a Bitcoin Script interpreter in Simplicity is more difficult, because Bitcoin Script has weird quirks around the interpretation of bytes as integers, lock times, etc., to name one of many challenges. |
Beta Was this translation helpful? Give feedback.
-
Unfortunately I think it's impossible to reimplement Script in any other language. Simplicity is expressive enough to do it, but it's the rules of C++ which are fractal and unknowable, so any attempt to do this would inevitably entail an unintentional hardforking change. So the answer to "how close to" is "not close enough" :). If we were to start with a clean slate, say, if we were implementing Liquid today, we'd probably start out trying to implement as much of our consensus logic directly in Simplicity, which would give us a formal specification (and reimplementability) for free. We might even attempt to reimplement Script, so that users from Bitcoin could port their code without too much pain. But the result would certainly not be bug-for-bug compatible with Script. |
Beta Was this translation helpful? Give feedback.
Unfortunately I think it's impossible to reimplement Script in any other language. Simplicity is expressive enough to do it, but it's the rules of C++ which are fractal and unknowable, so any attempt to do this would inevitably entail an unintentional hardforking change.
So the answer to "how close to" is "not close enough" :).
If we were to start with a clean slate, say, if we were implementing Liquid today, we'd probably start out trying to implement as much of our consensus logic directly in Simplicity, which would give us a formal specification (and reimplementability) for free. We might even attempt to reimplement Script, so that …