Repository navigation
contracts: the contract engine, in the kit and its wasm build - #35
Merged
Merged
Conversation
A wallet that holds a key a contract names had no way to read the
contract, recognise its output or spend it: lwk_simplicity handles one
leaf with no tree, no annex, no budget check and no fee asset, and it is
in no shipped wasm build.
lwk_contracts reads a sequentia-contracts descriptor (versions 1 and 2)
with that repository's own reader, and checks it with its pinned
compiler from the resolved source texts it is handed, so it runs in a
browser. It recomputes an instance's output, address and control blocks
exactly as the golden vectors and the other readers do, lists each
spending path and what it needs, and builds the spend of a chosen path
from a request: it refuses an output the request mislabels, a
confidential output, a missing or second fee and unbalanced outputs, and
a lock the chain would refuse now. It signs only with a contract key
(m/8383h/{coin}h/0h, the Simplex fork's account) and only the one the
path names, runs the program against the final transaction (naming the
source check that fails when it refuses), and pads under the budget rule.
The faucet drip covenant has a planner for its tier, interval and
successor.
The kit carries the three published templates, their vectors and the
refusal corpus, pinned in templates/PIN.json. The Simplex SDK needs Rust
1.87 against the kit's 1.85, so the engine uses its libraries directly
and ports its budget rule; that moved bitcoin_hashes and semver one
patch each and held psm at 0.1.26.
lwk_wasm exposes ContractTemplate, ContractInstance and ContractSpend.
build-web.sh builds the browser package with every build-machine path
remapped and fails if one remains. CI gains a contracts job.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The kit's contract engine,
lwk_contracts, and its wasm bindings: a wallet can now read asequentia-contractstemplate, recognise an instance's output and spend one of its paths.What it does
sequentia-contracts' own reader (pinned atad8ed18) and checks them with the pinned compiler (simplicityhl 0.7.2) from resolved source texts (Descriptor::validate_sources, contracts doc: point every repository link at the ConcatenaLabs organisation #13/doc: add the standing documentation rules #14), so it runs in a browser.m/8383h/{coin}h/0h(the Simplex fork's account), and only the key the path names. Runs the program against the final transaction (naming the source check that fails), and pads with an annex under the budget rule (ported from the Simplex fork).drip::plan: the faucet drip covenant's tier, interval and successor, as its program checks them.sequentia/one-key,one-key-exitandfaucet-drip, their vectors and the refusal corpus (templates/PIN.json).lwk_wasm:ContractTemplate,ContractInstance,ContractSpend.build-web.shbuilds the browser package with build-machine paths remapped, and fails if one remains.contractsjob.Why the SDK is not a dependency: smplx-sdk needs Rust 1.87; the kit pins 1.85. The engine therefore uses the SDK's libraries directly. Lock changes:
bitcoin_hashes0.14.0→0.14.1,semver1.0.27→1.0.28,psmheld at 0.1.26. simplicity-sys 0.7 links beside lwk_simplicity's 0.6 (versioned C symbols).Proof (node v25.2.1,
elementsregtest, Simplicity from genesis,-par=1)cargo test -p lwk_contracts: all 30 vectors reproduced (one_key 6, one_key_exit 10, faucet_drip 8, v2 fixture 6); 75 refusals made for their reason, 1 accepted; budget padding equals S1.2's 742-byte case. Before this change:package ID specification lwk_contracts did not match any packages.--target nodejs):contract_vectors.jsgives the same counts.SEQUENTIA_BIN=… cargo test -p lwk_contracts --test drip_regtest:non-BIP68-final); forced, mempoolnon-BIP68-final, blockTestBlockValidity failed: bad-txns-nonfinal;the check that fails is assert!(jet::le_64(drip, tier(reserve, floors, maxes))); forced, mempool and blockAssertion failed inside jet;assert!(jet::eq_256(script, script_hash))); forced, the same block error;arca_signers.jsandark_records.jspass.