[M1: Audit 2: L-09]: CIP112: Saturate time arithmetic so an oversized `maxTTL` or `lockGrace` cannot overflow
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 68/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Domain
- blockchain
Research direction
Start with computeStorageExpiry in Holding.daml as the existing saturation example, then read the timestamp calculations and invariants in Transfer.daml, Allocation.daml, Registry.daml, and the TransferInstructionState and AllocationState templates. Add coverage for transfers, mint offers, and allocation creation and settlement with large maxTTL and lockGrace values, and update the token-cip112-utils README.md. Done when these paths saturate at Time bounds, the invariants accept a lock expiry at maxTime, and the tests pass.
Written by the indexing model from the issue text.
Description
Addresses L-09
Changes
Code:
- Every timestamp computed from
maxTTLorlockGraceshould saturate at the bounds ofTimeinstead of raising anArithmeticError, ascomputeStorageExpiryalready does formaxTTL. This covers:- the
maxTTLwindow and request-age bounds invalidateTransfer(Transfer.daml) andallocationFactoryImpl(Allocation.daml), in the form they take after #91 (executeBefore - maxTTL,requestedAt + maxTTL); - the
lockGraceadditions on the transfer, mint (Registry.daml), allocation creation, and allocation settlement paths.
- the
- The
expiresAt < lockExpiresAtinvariant inTransferInstructionStateandAllocationStateshould also acceptlockExpiresAt == maxTime, so a saturated lock expiry does not fail the template'sensure. isValidRegistryConfigandisValidAllocationStatekeep accepting any positivemaxTTLandlockGrace. A value that saturates means the window or lock never expires in practice.
Tests:
- Cover transfers, mint offers, and allocation creation and settlement under a
maxTTLand alockGracelarge enough to saturate.
Documentation:
- The
token-cip112-utilsREADME.mdshould state that timestamps derived frommaxTTLandlockGracesaturate at the bounds ofTime.
- 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