Open
Conversation
…alanceIntervals` Closes #1113
5 tasks
carlostome
reviewed
Mar 13, 2026
Comment on lines
+36
to
+37
| A `DirectDeposits`{.AgdaDatatype} map records the ADA being deposited into account | ||
| (reward) addresses within a single transaction. Each entry maps the stake credential |
Collaborator
There was a problem hiding this comment.
Maybe note that "reward addresses" is pre-Dijkstra nomenclature, and that now these are called account addresses.
Comment on lines
+56
to
+94
| We represent a `BalanceInterval` as a pair of optional bounds, following the same | ||
| `Maybe × Maybe` convention used by the existing validity-interval type | ||
| (`Maybe Slot × Maybe Slot`). | ||
|
|
||
| ```agda | ||
| BalanceInterval : Type | ||
| BalanceInterval = Maybe Coin × Maybe Coin | ||
| ``` | ||
| <!-- | ||
| ```agda | ||
| -- (just lo , just hi) represents [lo, hi) | ||
| -- (just lo , nothing) represents [lo, ∞) | ||
| -- (nothing , just hi) represents [0, hi) | ||
| -- (nothing , nothing) is excluded by the well-formedness predicate below. | ||
| ``` | ||
| --> | ||
|
|
||
| ### Well-Formedness {#sec:balance-interval-wf} | ||
|
|
||
| [CIP 159][] requires that at least one bound is present. The | ||
| `validBalanceInterval`{.AgdaFunction} predicate excludes the `(nothing, nothing)` | ||
| case. | ||
|
|
||
| ```agda | ||
| validBalanceInterval : BalanceInterval → Type | ||
| validBalanceInterval (just _ , _ ) = ⊤ | ||
| validBalanceInterval (nothing , just _ ) = ⊤ | ||
| validBalanceInterval (nothing , nothing) = ⊥ | ||
| ``` | ||
|
|
||
| <!-- | ||
| ```agda | ||
| validBalanceInterval? : ∀ bi → Dec (validBalanceInterval bi) | ||
| validBalanceInterval? (just _ , _ ) = yes tt | ||
| validBalanceInterval? (nothing , just _ ) = yes tt | ||
| validBalanceInterval? (nothing , nothing) = no (λ ()) | ||
| ``` | ||
| --> | ||
|
|
Collaborator
There was a problem hiding this comment.
A better approach will be to forbid by construction invalid balance intervals
Member
Author
There was a problem hiding this comment.
Yes, I thought of that (and Claude also suggested that as an alternative), but I thought it best to get it working with a simpler type, plus a predicate, first and then later upgrade to a richer type. Wdyt?
Co-authored-by: Carlos Tomé Cortiñas <carlos.tome-cortinas@iohk.io>
Co-authored-by: Carlos Tomé Cortiñas <carlos.tome-cortinas@iohk.io>
Co-authored-by: Carlos Tomé Cortiñas <carlos.tome-cortinas@iohk.io>
Co-authored-by: Carlos Tomé Cortiñas <carlos.tome-cortinas@iohk.io>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Closes #1113
CIP-159-01: Core types
DirectDeposits,BalanceInterval,AccountBalanceIntervalsSummary
This PR introduces the shared domain types required by CIP-159 (Account Address Enhancement) in a new module
Ledger.Dijkstra.Specification.Account. These types are used acrossTransaction,Certs,Utxo, andScript.Validation, so they are factored into their own module to avoid circular dependencies.This covers Phase 1 (ADA-only). Phase 2 (multi-asset) upgrade paths are documented in the module as comments.
What's included
DirectDepositsCredential ⇀ CoinBalanceIntervalMaybe Coin × Maybe Coin[lo, hi)for balance assertionsAccountBalanceIntervalsCredential ⇀ BalanceIntervalvalidBalanceIntervalBalanceInterval → TypeinBalanceIntervalCoin → BalanceInterval → TypeDecinstanceDesign decisions
Maybe × Mayberepresentation forBalanceInterval: Follows the existingMaybe Slot × Maybe Slotconvention used by validity intervals. A separatevalidBalanceIntervalpredicate excludes the(nothing, nothing)case rather than encoding it structurally, giving downstream rules flexibility in how they assert well-formedness.Half-open interval semantics: Unlike
inIntervalfor slots (which uses closed[l, r]bounds),inBalanceIntervalimplements[lo, hi)as specified by CIP-159 (inclusive_lower_bound,exclusive_upper_bound). The upper bound check issuc c ≤ hi(i.e.,c < hi).No explicit
DecEqdeclarations:BalanceIntervalinheritsDecEqfromDecEq-×andDecEq-Maybein the prelude.DirectDepositsandAccountBalanceIntervalsare type aliases over⇀.Module parameterization: Parameterized by
GovStructure(likeCerts), giving access toCredential,Coin, etc.Acceptance criteria checklist
DirectDepositstype alias defined and available for importBalanceIntervalandAccountBalanceIntervalstypes definedinBalanceIntervalpredicate defined with decidability (Dec)DecEqinstances available where needed (inherited from prelude)--safeChecklist
CHANGELOG.md