Repository navigation
Wasm space api - #24
Merged
Merged
Conversation
Thread the real NounSpace through noun decoding and noun-reading helpers, switching from the removed private Cell/Atom accessors to NounHandle/CellHandle/AtomHandle traversal. - NounDecode::from_noun now takes (&Noun, &NounSpace) - Hashable::from_noun and hashing::raw helpers take a space - Tip5Hasher uses nockchain-math digests instead of door jets (the jets now require the num-rounds door subject) - Copy nouns into the jet stack with their source space - ZMap/ZSet decoding and test helpers pass the slab space The no_std path (crypto only) is unchanged.
Declare both the vendored nockchain-minimal crates and upstream nockchain 73877be as aliased optional dependencies and select between them with the mutually exclusive 'embedded' (default) and 'native' features. 'std' gates the transaction/block/hashing modules and requires exactly one runtime backend, so the crypto-only no_std path still builds with default features disabled. Port the vendored minimal runtime to the current NounSpace/handle API: - nockvm: NounSpace, NounHandle/CellHandle/AtomHandle, Noun/Cell/Atom in_space, and a default NounAllocator::noun_space. - nockapp: space-aware copy_into plus NounAllocatorExt, and re-exports for NounAllocator/NounSpace. - noun-serde/derive: two-argument NounDecode::from_noun and all impls and generated code. - nockchain-math/libp2p/zkvm: space-aware TIP5 and shape entry points, and hash_ten_cell/hash_belts_slice shims. Bins now require std so they are not built for no_std targets. The obsolete consumer patch section and toggle scripts are removed.
- fee: count note-data words as Hoon rep shape (2n+1), not the z-map noun
- Hash::from_b58: five divmods, zero high quotient, canonical re-encode
- hashing: propagate Result instead of fabricating zero digests; validate leaves;
zmap/zset expose try_{put,get,has,del} and no longer hash-fallback to zero
- schnorr: reject zero scalars and non-canonical T8 limbs
- validator: fail closed with UnsupportedVersion for V1
- block types: page-aware build_lock_merkle_proof (stub below BYTHOS_PHASE)
- v1 decode/hash: return errors instead of expect/assert; reject tim != 0
- pokenoun: hostile-jam hardening (checked sizes, bounded walks) and numeric
atom comparisons for non-minimal encodings
- delete dead hashing/tip5_impl.rs
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.
Summary
Adds first-class runtime selection to
tx-typesand migrates the crate to the upstream nockchain NounSpace/handle API, so the same source serves:nockster-espdefault-features = falsepokenoun(no_std, crypto-only)std,embeddednockchain-minimalstd,nativeSWPSCO/nockchain@73877beembeddedandnativeare mutually exclusive;stdrequires exactly one. Both are compile errors if violated. Thepokenounre-export and the crypto-only no_std path are unchanged.This is the point of
tx-types: embedders and wasm consumers import it instead of the full nockchain tree, while native consumers still share the same wire types and hashing logic.Runtime selection
Dependency sets are declared as aliased optional deps (
nockapp-minimal/nockapp-upstream, etc.) and selected at the crate root withextern crate … as …. This keeps::nockapp,::nockvm,::noun_serde, and derive-generated paths identical for both runtimes. Cargo does not allow a feature to switch dependency sources, so both sets live in this manifest.BUILDING.mddocuments the matrix; the olduse-local-nockchain.sh/use-git-nockchain.shscripts and the consumer-side[patch]are removed.Upstream API migration
NounDecode::from_noun(&Noun, &NounSpace)everywhere, including the derive andnockchain-minimal.noun.in_space(space).as_cell()/as_atom(),CellHandle::head()/tail(),AtomHandle.noun_space()on slabs/stacks,copy_into(root, &space), and space-aware TIP5/math entry points.nockvm/nockappgained the new types/methods; existing 1-arg helpers remain where possible.Correctness / parity fixes
From a line-by-line audit against nockchain
73877be:count_note_data_wordsnow matches Hoon (2n+1atoms per note-data entry); previously3n+1, overcharging minimum fees.Hash::from_b58: five divmods, reject non-zero high quotient and non-canonical spellings (exact re-encode).Hash { [0; 5] }/ cue→0 fallbacks; hashing returnsResult, unbased/oversized atoms error.1<<20walk budget, numeric atom comparisons (non-minimal spellings compare equal).chal/sigand non-canonical T8 limbs.UnsupportedVersioninstead of silentlyOk(()).build_lock_merkle_proofselects stub below the phase and full at/above; callers pass a page/height.expect/asserton noun shapes replaced with errors;Witness::tim != 0rejected; dead non-consensus TIP5 file removed.try_*variants added; legacy helpers no longer fabricate zero digests.Breaking changes
compute_tx_id_v1*,hash_noun_varlen,hash_hashable, V1to_hash/to_hashable, and related hashing helpers returnResult.build_lock_merkle_proofrequires apageargument.Witness::from_nounrejects non-zerotim.TransactionValidationError::UnsupportedVersionadded.embeddedis the default backend; native consumers must opt out of defaults and selectstd,native.Consumers updated in lockstep:
siger-esp(std,embedded, host + wasm + thumb) and native consumers (std,native).CI
rust-toolchain.toml(nightly-2026-04-03) viaactions-rust-lang/setup-rust-toolchain.rustflags: ""so pre-existing warnings in vendoredibigare not promoted to errors.Verification
cargo check -p tx-types(default embedded+std)cargo test -p tx-types --lib— 80 passedcargo check -p tx-types --no-default-featuresand--target thumbv7em-none-eabihf— passcargo check -p tx-types --no-default-features --features std,embedded— pass... --features std,native— pass... --features std,embedded --target wasm32-unknown-unknown— passcargo test -p pokenoun— 11 passedFollow-ups
pokenoun::jamstill emits no backreferences (cue-compatible; byte size differs fromnockvm::jam).nockster-fw) requires the ESP/Xtensa toolchain; no_std was verified onthumbv7em-none-eabihfin CI.