Resource-Aware Session Types for Digital Contracts
Programming digital contracts comes with unique challenges, which include describing and enforcing protocols of interaction, controlling resource usage, and tracking linear assets. This article presents the type-theoretic foundation of Nomos, a programming language for digital contracts whose strong static guarantees match the domain-specific requirements and facilitate contract development. To describe and enforce protocols, Nomos is based on shared binary session types rooted in linear logic. To control resource usage, Nomos uses resource-aware session types and automatic amortized resource analysis, a type based technique for inferring resource bounds. To track linear assets, Nomos employs a linear type system that prevents assets from being duplicated or discarded. The technical contribution is the design and soundness proof of Nomos' type system, which integrates shared session types and resource-aware session types with a functional type system that supports automatic amortized resource analysis. To demonstrate the practicability of Nomos' session-type--based design, we implemented three digital contracts in an existing prototype language. Experiments indicate that the performance of the contracts is adequate for scaling to thousands of users and interactions.
READ FULL TEXT