[M1: Audit 2: L-05]: CIP112: Split `consumeHolding` into a spend hook and a release hook
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 48/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Domain
- blockchain
Research direction
Start with HoldingOps in packages/token/token-cip112-utils/daml/OpenZeppelin/Token/Cip112/Utils/Holding.daml and trace how consumeUnlockedHolding, consumeLockedHolding and unlockHoldings are used. Then check the token-cip112-v1 implementation, the custom example, and the trust-boundary section of the README. Done means spend rules apply only to caller-supplied inputs, locked funding can be released on every listed workflow path, and regression tests, comments and the changelog reflect the change.
Written by the indexing model from the issue text.
Description
Addresses L-05
HoldingOps.consumeHolding does two jobs: it checks that a holding is an accepted implementation, and it is the spend hook. The workflows call it on caller-supplied inputs and also on funding they locked themselves. As a result, a spend rule placed in it runs on accept, reject, withdraw, expire, settle and cancel. A minimum-age rule blocks the receiver's accept and reject, and the sender's withdraw, until the funding is old enough. A rule that never passes for workflow-created holdings blocks every return path until lockExpiresAt. After that, only holdingOwnerUnlockImpl can recover the funds.
Changes
Code:
- Replace
consumeHoldinginHoldingOpswith two operations:spendHoldingfor caller-supplied inputs: the accepted-implementation check plus the consumer's spend rules. Called byconsumeUnlockedHoldingin the transfer and allocation factories.releaseHoldingfor funding the workflow locked: the accepted-implementation check only. Called byconsumeLockedHoldingandunlockHoldingson accept, reject, withdraw, expire, settle and cancel.
- Set both operations to
consumeByArchive @TokenHoldingintoken-cip112-v1. - In the custom example, keep
MyHolding_SpendbehindspendHoldingand setreleaseHoldingtoconsumeByArchive @MyHolding.
Documentation:
- Update the
HoldingOpsdoc comment and the trust boundary section of thetoken-cip112-utilsREADME.md. Both should name the workflow paths that call each hook, and state thatreleaseHoldingmust not reject a holding the workflow locked. - Update the custom example module comment, which says the freeze refuses every workflow path.
- Add a
CHANGELOG.mdentry for theHoldingOpschange.
Tests:
- Add a case where
spendHoldingrejects the locked funding, for example with a minimum-age rule, and check that accept, reject, withdraw, expire, settle and cancel still succeed.
- Dominant language
- Haskell
- Stars
- 5
- Forks
- 0
- Avg merge
- 1d 36m
- Merged PRs (30d)
- 11
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from OpenZeppelin/canton-contracts
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
OpenZeppelin/canton-contracts#92 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
OpenZeppelin/canton-contracts#88 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
OpenZeppelin/canton-contracts#86 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 55/100
OpenZeppelin/canton-contracts#96 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
OpenZeppelin/canton-contracts#95 ·
Maintainers usually reply within 1 day
All issues in OpenZeppelin/canton-contracts
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 75/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
IntersectMBO/cardano-ledger#6276 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
hasura/graphql-engine#10954 ·
Maintainers usually reply within 1 day