delvingbitcoin

DSL for experimenting with contracts

DSL for experimenting with contracts

Original Postby jungly

Posted on: April 9, 2024 09:08 UTC

TLA+ and a domain-specific language (DSL) serve distinct purposes in the realm of programming, each with its own set of advantages.

TLA+ is an advanced tool designed for defining system states and transitions, facilitating the exploration of all possible states through a model checker. This capability is invaluable for ensuring that defined properties remain valid across all possible states, thus aiding in the debugging of concurrent protocols, such as those used by Bitcoin and the Lightning Network (LN). The use of TLA+ for specifying LN network communication protocols is highlighted as particularly beneficial.

In contrast, the DSL approach requires developers to manually script state transitions and their execution, akin to writing unit or functional tests. Its primary advantage lies in running code on regtest, thereby offering insights into real-world system transitions. Furthermore, the DSL has been identified as a useful educational tool for understanding various contract constructions.

The application of TLA+ in current projects is exemplified by its use in specifying protocols for Braidpool, which aims at identifying potential errors prior to coding, thereby enhancing robustness against human error. Additionally, TLA+ has been employed to detail the commitment and breach transactions protocol for LN, with an initial focus on creating a model for Bitcoin that facilitates the definition of state transitions resulting from LN contract executions.

Looking forward, there's an interest in decomposing complex contracts, such as atomic swap contracts, into multiple modules. These include capturing the Bitcoin blockchain's state and transitions, developing a module of functions for contract building—an area acknowledged for its complexity—and managing communication between parties, which is suggested to be handled via standard TLA+ or PlusCal. The ambition to create a library of TLA+ modules akin to the TLA+ Community Modules reflects a broader vision for leveraging TLA+ in simplifying and structuring contract development.