Skip to content
This repository has been archived by the owner on Feb 9, 2021. It is now read-only.

Simplify Lovelace type #668

Open
dcoutts opened this issue Oct 18, 2019 · 1 comment
Open

Simplify Lovelace type #668

dcoutts opened this issue Oct 18, 2019 · 1 comment

Comments

@dcoutts
Copy link
Contributor

dcoutts commented Oct 18, 2019

The Lovelace type and operations currently enforce a 45billion limit. This is indeed the limit, but the argument is that this is the wrong place to enforce it.

Just as we concluded that for the specification we should use signed types for currency, and enforce that tx outputs be non-negative, the same logic applied to lovelace suggests that we should not enforce the limits in the type but in the appropriate places in the ledger rules.

We do still have to be careful about integer overflow when checking the ledger rules: if we use 64bit values for tx outputs then the sum of these must not overflow before we compare with the sum of inputs.

Concretely, the suggestion is that we analyse changing the Lovelace type to be a Word64 (as it is now) but without any special upper bound (deriving Bounded). We would eliminate LovelaceTooLarge and LovelaceTooSmall but keep LovelaceOverflow and LovelaceUnderflow. Our QC generators should then also generate maxBound sometimes.

@kevinhammond
Copy link

I’d be inclined to do both. A type can always be eliminated in an implementation if it’s known to always be satisfied by the type checker. This avoids issued if there’s a bug in the proof for example . Likewise with the currency. Enforce the constraints in the implementation. There’s no good reason not to and it may save a problem as well as reducing testing.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants