Open daira opened 2 weeks ago
Thanks for the detailed explanation and discussion! I have made this explicit in the specification in https://github.com/QED-it/zips/pull/83 (that the order of access should be as per the transaction format, viz. burn checks happening first, then burn updates, then issuance checks and issuance updates to state).
That PR will merge into #960 once we internally review and fine-tune it.
(This interacts with #950, but I am filing it as a separate issue because #950 is about the current protocol prior to ZSAs.)
ZIP 227 - Rationale for Global Issuance State says:
Like other pools, the balance of any issued Custom Asset should never become negative at any transaction boundary; not just at block boundaries (see #950, which is only to clarify the spec: checking at transaction boundaries is how it is implemented). So this should say:
Note that this is in a Rationale section and therefore non-normative. The actual specification is split between ZIPs 227 (for issuance) and 226 (for burning).
For issuance, the proposed changes are in ZIP 227 - Specification: Consensus Rule Changes:
The proposed consensus rule for burning of Custom Assets is rule 4 in ZIP 226 - Burn Mechanism - Additional Consensus Rules:
The relative ordering of accesses to the global state is not defined. It must be, because checking $\mathsf{v} \leq \mathsf{issuedAssets}(\mathsf{AssetBase})\mathsf{.balance}$ might give different results depending on whether it is done before or after the state update for issuance. (IMHO it makes more sense either to do issuance first, or to prohibit issuing and burning the same asset in a transaction.)
This is a consequence of the use of imperative statements like "reduce the value" or "increase the value". I don't want to claim these are strictly never used in existing consensus rules, but it is undesirable to use them because of ambiguities like that above. It is far preferable to refer explicitly to indexed states, i.e. to define notation for the global state before and after the transaction. Then a consensus rule that performs an "update" can be rephrased as imposing a relation between the before-state and after-state, which resolves a lot of potential ambiguities (in particular, conflicting requirements automatically do the right thing which is to reject the transaction).