Resource Specifications for Resource-Manipulating Programs
Zachary Grannan, Alexander J. Summers
TL;DR
The paper addresses the semantic gap in specifying resource-manipulating programs by showing that state-based specifications requiring explicit frame conditions are verbose and brittle. It proposes first-class resources, ghost resource state, resource operations, and coupling invariants to express resource changes directly, implemented as an extension to the Prusti verifier via Viper. A Fungible Token Transfer case study on cross-chain IBC demonstrates that resource-based specifications enable concise, structurally simpler proofs while preserving key properties like a Two-Way Peg and Preservation of Supply. The evaluation across multiple applications indicates substantial reductions in specification size and syntactic complexity, with a modest verification-time overhead, underscoring the practical impact for verifying resource-based systems such as smart contracts and blockchain protocols.
Abstract
Specifications for modular program verifiers are expressed as constraints on program states (e.g. preconditions) and relations on program states (e.g. postconditions). For programs whose domain is managing resources of any kind (e.g. cryptocurrencies), such state-based specifications must make explicit properties that a human would implicitly understand for free. For example, it's clear that depositing into your bank account will not change other balances, but classically this must be stated as a frame condition. As a result, classical specifications for resource-manipulating programs quickly become verbose and difficult to interpret, write and debug. In this paper, we present a novel methodology that extends a modular program verifier to support user-defined first-class resources, allowing resource-related operations and properties to be expressed directly and eliminating the need to reify implicit knowledge in the specifications. We implement our methodology as an extension of the program verifier Prusti, and use it to verify real-world smart contracts and a key part of a blockchain application. Our evaluation demonstrates that specifications written with our methodology are more concise and substantially simpler than specifications written purely in terms of program states.
