Skip to content

L-04: Pass consumed holdings to createHolding so consumer fields surv… - #129

Open
haseebrabbani wants to merge 1 commit into
audit-m1-02-l05from
audit-m1-02-l04-v2
Open

haseebrabbani wants to merge 1 commit into
audit-m1-02-l05from
audit-m1-02-l04-v2

Conversation

@haseebrabbani

Copy link
Copy Markdown
Collaborator

Closes #89. Stacked on #116 (base audit-m1-02-l05).

  • API: HoldingOps h is parameterised over the owner's per-holding state. fundHolding/deliverHolding/returnHolding return (view, h); createHolding : [h] -> HoldingView -> Update ... receives the states of the holdings that fund the new one. consumeByArchive @t returns the archived t; holdingOwnerUnlockImpl takes the exercised holding's state.
  • Sources per path: transfer/allocation inputs → change, locked funding, one-step receiver; accept/settle locked funding → surplus, receiver, reserve, payout (per instrument); every return → the replaced locked holding; owner unlock → the exercised holding. Mint and net-credit-only settlement payouts get none.
  • Behaviour: TokenHolding and the custom example ignore sources, so nothing changes for them. The example's freeze is tracked in CIP112: settleBatchImpl: forward each authorizer's own context to its Allocation_Settle #82.
  • Docs: HoldingOps haddock and utils README.md list the sources per path, warn that underived fields reset and that sources are order- and amount-agnostic, and point restrictions on in-flight funds to a per-account contract.
  • Tests: new Utils/Test/Sources.daml (10 scripts) tags each holding with its sources' tags through every re-creation path. Mutating the wiring fails them.
  • Validation: all AGENTS.md commands pass, including the token sandbox suite. All 10 Sources scripts pass on a static Canton sandbox, and a JSON Ledger API smoke passes 29/29 happy and 6/6 error paths.
  • Ports the design of 0xNeshi's audit-m1-02-l04 branch onto the L-05: Split consumeHolding into fund, deliver and return operations #116 hooks.

…ive re-creation

HoldingOps takes the owner's per-holding state as a type parameter h. The
three consumption operations return the consumed holding's view and state,
and createHolding receives the states of the holdings that fund the new
one: a transfer's or allocation's inputs, the locked funding on accept and
settle (per instrument), the replaced locked holding on every return, and
the exercised holding on an owner unlock. A mint and a settlement payout
funded only by net credit get no sources. consumeByArchive @t returns the
archived t, so holdingOpsFor @t builds a HoldingOps t.

TokenHolding has no extra fields and ignores the sources. The custom
example also ignores them: no source it sees is ever frozen.

The HoldingOps docs and the utils README list the sources per path, state
that a field the closure does not derive from them resets, and point
restrictions on in-flight funds to a per-account contract. A new utils test
suite tags each holding with its sources' tags and follows them through
every re-creation path.

Ports the design of 0xNeshi's audit-m1-02-l04 branch onto the L-05 hooks.

Closes #89
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