Skip to content

Add state commitment functions for persistent storage via Taproot - #46

Open
schoen wants to merge 5 commits into
BlockstreamResearch:masterfrom
schoen:feat/storage
Open

Add state commitment functions for persistent storage via Taproot#46
schoen wants to merge 5 commits into
BlockstreamResearch:masterfrom
schoen:feat/storage

Conversation

@schoen

@schoen schoen commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Add storage.simf with state commitment functions load and store.

This is based on @apoelstra's stage management MVP functions, originally written around December 2025, with minor name changes and comment edits by me. Versions of these functions have been used in many covenants over the last several months. I'd like them to be in the standard library so that everyone can use them easily without copying and pasting them as "folklore" about how to do basic Simplicity state management.

There are 13 Simplex test cases created by Claude. I asked Claude for each individual test case, and I'm satisfied that they test the most important cases and that they work properly. We test that the storage does work when it should, and that loading or storing the wrong state (or storing to a Taproot or non-Taproot output other than a copy of the current program) fails. The other good thing is that we also test interoperability between state commitments generated by rust-elements calls and state commitments generated by the store function's jets calls (which, as Claude pointed out to me, are two different implementations of portions of the relevant logic). This confirms that we can assert commitments from outside of a contract (like with hal-simplicity or LWK or a wallet) and verify them from inside of the contract. We already know this because we already do this in some actual contracts, but it's also directly tested here.

As in #45, Claude wrote comments about what the various tests and helper functions do, which could be unnecessarily verbose, and which I'm happy to trim down if that would be preferable.

There may be a further discussion about whether we can usefully extend state commitments to let cooperating covenants load or store one another's state values, but this should wait for the covenant convention stuff (to include documented recommendations for how to accomplish this).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant