Repository navigation
waved: implement SendAssetOOR RPC, incoming asset OOR receive, and real-engine systest - #1658
Conversation
Add the daemon-only SendAssetOOR RPC (plus REST gateway mapping) to waverpc so waved can submit out-of-round Taproot Asset transfers without exposing a CLI surface yet, and add optional batch_asset_root (field 5) on arkrpc.TreePath so clients can authenticate composed asset batch output expiry against confirmed commitment transactions.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b20140a8c2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Regenerate waverpc, arkrpc, and devrpc registry artifacts after adding SendAssetOOR and TreePath.batch_asset_root.
Asset batch outputs commit to TapBranch(SweepTapscriptRoot, BatchAssetRoot) rather than SweepTapscriptRoot alone. Export arkscript.TapBranchHash, carry optional 32-byte BatchAssetRoot on tree.Tree, lib/treecodec (TLV type 7), arkrpc.TreePath, and tapassets.TreeRootAssetSource, and fold it into vtxo.validateExpiryFragment so AuthenticateBatchEvidence verifies confirmed asset batch outputs without trusting operator expiry scalars.
Store the operator's advertised compressed OORCarrierPubKey on OperatorTerms so waved can verify leased carrier-float policies before building asset OOR transfers.
Add SelectAndReserveAssetSpend (in lib/actormsg, vtxo, and wallet) to select and atomically lock up to eight live asset VTXOs of a requested asset reference in largest-first order, classifying locked-liquidity shortfalls separately from balance shortfalls. Add AllowAssetTransition on round.SpendReserveEvent so plain Bitcoin spends keep failing closed with ErrAssetVTXORequiresTransition while asset-aware OOR selection transitions live asset VTXOs into SpendingState.
Allow ListVTXOsByScriptsTaproot and durable serverconn queries to carry an optional SignerScript alongside each queried PkScript so clients can prove script-scope ownership using the uncomposed base receive key when querying composed Taproot Asset output scripts.
b20140a to
7b2f1f4
Compare
|
@codex review |
7b2f1f4 to
dba8c20
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: dba8c20c62
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
dba8c20 to
ed9611c
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ed9611cecd
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
ed9611c to
f098880
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f09888022f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Add NewOORProofVerifier to check unconfirmed Taproot Asset proof anchors against a VTXO's authenticated commitment tree and OOR package chain, and add VerifyOORAssetVTXO on VTXOVerifier so incoming OOR asset receives verify sealed Ark asset packages (including merged multi-input packages) before persisting them for unilateral claims and respends.
Forward PreparedSubmitPackage through durable StartTransferRequest TLV so asset OOR sends enter the outgoing FSM with pre-committed packages, and keep VTXO.TapScript nil for asset-bearing TransferInputs across validation, snapshots, and incoming materialization. Wire incoming asset OOR metadata, composed RoutingPkScript derivation, async VerifyIncomingAssetPackage authentication outside the write lock, and sealed Ark asset package persistence on received VTXOs. Track CompletedEventIDs across incoming snapshots and queue concurrent distinct hints on parkedSelfHints so multi-output transfers to one wallet (such as asset change plus Bitcoin carrier return) materialize every owned output regardless of push ordering.
Implement daemon-only SendAssetOOR: validate allowlisted asset and operator carrier key, select and lock up to eight asset VTXOs, lease an operator carrier float via LeaseOORCarrier, plan carrier allocation (returning round-originated carriers as sender Bitcoin change), build the asset transition via tapassets.BuildOORTransfer, attach composed tapleaf scripts, and submit through the durable OOR registry. Wire incoming OOR asset verification onto the embedded asset engine, route composed asset outputs through uncomposed receive scripts for ownership lookup and signer-scoped indexer queries, and carry OORCarrierPubKey from GetInfo.
Add TestAssetOORMergeAndClaim running two real embedded-engine waved daemons on regtest bitcoind, Esplora, and tapd: Alice merges two confirmed-round V1 asset VTXOs (400 + 300 units) via SendAssetOOR using an operator-leased carrier float, Bob authenticates batch expiry with BatchAssetRoot and verifies the merged 550-unit VTXO while Alice receives her 150-unit asset change and 2,000-sat carrier return, and Bob unilaterally exits and claims all 550 units into his embedded asset wallet.
Add VTXOStatus.IsTerminal and guard handleVTXOsMaterialized against replayed notifications for already-terminal stored VTXOs. Set AllowAssetTransition on the startup reservation-sweep redrive so resumed asset OOR reservations are not rejected, and match asset references case-insensitively during candidate selection.
Key multi-output incoming receive hints, parked self-hints, and
ReceiveCompleted tracking on IncomingHintKey{ScriptHash, EventID} so
distinct fresh scripts numbered 1 by the operator do not collide.
Record MaterializedPlainScripts so plain Bitcoin sessions stay dormant
without reopening, preserve prior ReceiveCompleted if a follow-up pass
fails, reject stale phase-1 resolutions, reconstruct active hints on
restore, and guard persistIncomingDescriptor against terminal rows.
Isolate per-output asset verification failures and disabled-asset
sessions so sibling plain Bitcoin outputs still materialize, normalize
incoming TaprootAssetRef casing, and add version-2 OutgoingAssetReplay
proofs to isolate asset and Bitcoin idempotency namespaces.
Validate policy_template destinations with arkscript.ValidatePolicy, parse oor_carrier_pubkey leniently during operator-terms bootstrap, and build checkpoint owner leaves under current terms.PubKey so asset VTXOs remain spendable across operator key rotations. Consolidate SendAssetOOR lock cleanup into a single detached-context defer and check local carrier floor preconditions before leasing a carrier float. Bind keyed asset OOR attempts to v2 OutgoingAssetReplay identity, reject cross-type Bitcoin/asset key reuse with AlreadyExists, and return stored summary figures without emitting duplicate metrics. Wire incomingAssetVerifier as nil when Taproot Assets are disabled, unwrap proof-verifier errors so transient chain outages retry with bounded backoff, and skip unverifiable asset events during wallet recovery instead of aborting the scan.
Document that SignerScript overrides local receive-key lookup for the script_scope proof while the RPC request queries the composed PkScript.
Match real operator per-script recipient_event_id numbering starting at 1 so TestAssetOORMergeAndClaim exercises distinct fresh scripts sharing event_id 1 in the same OOR transfer.
|
@codex review |
f098880 to
202919e
Compare
|
Codex Review: Didn't find any major issues. More of your lovely PRs please. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Summary
Completes the daemon-side out-of-round (OOR) Taproot Assets slice on top of #1619 and #1649:
SendAssetOORRPC (waverpc,waved,rpc/restclient):SendAssetOORtowaverpc/daemon.proto+ REST gateway mapping (no top-levelwavecliuser command; reachable via the generated devrpc registrywavecli dev daemon send-asset-oor).OORCarrierPubKey, and destination policies (arkscript.ValidatePolicy), checks canonical v2oor.OutgoingAssetReplayidempotency identity (isolating Bitcoin and asset idempotency namespaces), selects and locks up to 8 live asset VTXOs (SelectAndReserveAssetSpendinlib/actormsg,vtxo,wallet), checks local carrier preconditions before leasing an operator carrier float (LeaseOORCarrier), plans carrier allocation (returning round-originated carriers as sender Bitcoin change), builds the asset transition viatapassets.BuildOORTransferwith current-operator checkpoint leaves, attaches composed tapleaf scripts, and submits via the durableoorregistry (StartTransferRequest.PreparedSubmit).--dry_runpreview and idempotency-key replay returning stored summary figures.tapassets,indexer,serverconn,oor,waved):tapassets.NewOORProofVerifierandVTXOVerifier.VerifyOORAssetVTXOto verify incoming OOR asset packages (including merged multi-input packages) against the embedded asset engine and authenticated Bitcoin/OOR lineage before materialization.SignerScriptonindexer.TaprootScriptScopeand durableserverconnqueries so clients resolve the local uncomposed receive key forscript_scopeproofs while querying composed asset output scripts.VerifyIncomingAssetPackage(nil when Taproot Assets are disabled) synchronously outside the actor SQLite write transaction, isolates per-output asset failures from sibling Bitcoin outputs, retries proof/chain backend failures with bounded backoff, and persistsTaprootAssetRoot/Ref/Amount/TaprootAssetSealedPackage(with canonical lowercasedRef) on received VTXOs so unilateral claims and subsequent OOR respends work.BatchAssetRoot): carries optional 32-byteBatchAssetRootontree.Tree,lib/treecodec(TLV type 7),arkrpc.TreePath(field 5), andtapassets.TreeRootAssetSource, folding it viaarkscript.TapBranchHashintovtxo.validateExpiryFragmentsoAuthenticateBatchEvidenceauthenticates confirmed asset batch outputs.round.SpendReserveEvent.AllowAssetTransition): keeps plain Bitcoin spends fail-closed withErrAssetVTXORequiresTransitionwhile lettinghandleSelectAndReserveAssetSpendand startup reservation redrive transition live asset VTXOs intoSpendingState.TapScript == nilconsistency (oor): alignsTransferInput.Validate,TransferInputFromSnapshot, and incoming asset materialization withdb.VTXOStore(asset VTXOs keepTapScriptnil and derive composed spend paths fromPolicyTemplate+TaprootAssetRoot).oor,vtxo): keys completed hints, busy checks, and FIFOparkedSelfHintsonIncomingHintKey{ScriptHash, EventID}(handling per-script event IDs starting at 1), tracksMaterializedPlainScriptsso completed plain Bitcoin sessions stay dormant without reopening, preserves priorReceiveCompletedon follow-up failure, rejects stale phase-1 resolutions, and guardspersistIncomingDescriptorandhandleVTXOsMaterializedagainst already-terminal stored VTXOs.systest/asset_oor_test.go):TestAssetOORMergeAndClaimruns two real embedded-enginewaveddaemons against regtestbitcoind, Esplora, andtapdwith per-script event IDs starting at 1: Alice merges two real confirmed-round V1 asset VTXOs (400 + 300 units -> 550 to Bob + 150 asset change + 2,000 sat BTC carrier return) using an operator-leased carrier float, Bob verifies and persists the merged 550-unit VTXO, and Bob unilaterally unrolls and claims all 550 units into his embedded asset wallet.