Skip to content

feat(v3): add GraftConfigTreeNode to materialize anonymous config tree nodes - #370

Merged
pkieltyka merged 2 commits into
masterfrom
feat/graft-config-tree-node
Aug 24, 2026
Merged

feat(v3): add GraftConfigTreeNode to materialize anonymous config tree nodes#370
pkieltyka merged 2 commits into
masterfrom
feat/graft-config-tree-node

Conversation

@ScreamingHawk

Copy link
Copy Markdown
Contributor

What

Adds v3.GraftConfigTreeNode(tree, replacement) — swaps the first anonymous node-hash leaf (WalletConfigTreeNodeLeaf) whose image hash equals replacement.ImageHash() for the full replacement subtree. The tree's image hash is unchanged by construction: a swap only happens on hash equality. Idempotent: if the hash is already materialized as a full subtree, the tree is returned unchanged with ok=true.

Why

BuildIntentConfigurationSignature / BuildRegularSignatureFromSignatures can only attach a supplied signer signature to a full leaf. Configs decoded from keymachine can carry sapient leaves (e.g. the Trails timed-refund leaf) as anonymous node hashes — no address — so the supplied sapient signature silently contributes zero weight and the on-chain threshold fails.

Both trails-api and trails-watchtower currently carry private copies of this graft (graftSapientLeaf). This upstreams it generically: any subtree can be grafted, and hash-equality matching makes the substitution provably config-preserving without a separate verification step. Related: the commented-out reverse-direction replaceSapientSignerWithNodeInConfigTree in intent_config.go.

Tests

core/v3/graft_test.go: value and pointer node leaves under WalletConfigTreeNode, node leaf under WalletConfigTreeNestedLeaf (Weight/Threshold preserved), already-materialized subtree, hash absent, nil inputs. Every graft asserts image-hash equality with the original tree and that the input tree is not mutated. Includes a non-sapient replacement to cover the generic case.

chatgpt-codex-connector[bot]

This comment was marked as outdated.

@pkieltyka
pkieltyka merged commit fc68b61 into master Aug 24, 2026
6 checks passed
@pkieltyka
pkieltyka deleted the feat/graft-config-tree-node branch August 24, 2026 19:33
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.

2 participants