-
Notifications
You must be signed in to change notification settings - Fork 2
Description
authors: @dr-orlovsky, @zoedberg
layers: consensus
breaking: consensus, api, serialization
Background
RGB contracts have global state; which is assembled from the contributions of individual operations (genesis, state transitions and state extensions). Since schema defines a maximum number of global state items of each type, the ordering of this processing affects what is reported to the clients. The global state is also accessible via AluVM op codes (CnC, LdC) and can be used in validating consequent operations. Thus, the order in which operations are processed during the validation and state computing affects consensus and validity of future operations. This order is named "consensus ordering" (of operations or global state).
At this moment the ordering happens according to the following ruleset:
- genesis always goes first;
- we order the rest of operations basing on the mining height of a witness bitcoin transaction committing to the operation data;
- if the operation is not mined (i.e. its witness transaction is in mempool, RBF, lightning channel), it is ordered after all mined operations;
- state extensions, which doesn't have direct witness transaction are ordered using witness transaction of a first state transition which closes a single-use seal defined in the extension; and they always are processed before that state transition;
- if two or more witness transactions are mined in the same block, they are ordered by a lexicographic ordering of their txids;
- we always use block timestamp and not block height, such that we can support multiple layer 1 (bitcoin, liquid) with different block production times (and incomparable heights);
- for multiple off chain transactions (mempool, LN channel) we use a dedicated parameter
priorityprovided as a part of their off chain status, such that HTLCs can be indicated to be processed after the commitment transaction.
Motivation
The provided ruleset has one inconsistency: in lightning channels we order HTLCs after commitment using a dedicated off chain priority field, which will not be reflected if these transactions get mined, when they will get re-ordered basing on their txids, such that there is no guarantee that the state of HTLCs will not come before the commitment transaction (which may render it invalid)
Proposal
It is proposed to:
- remove
priorityfield from off chain transaction ordering; - add new
noncefield to state transactions and state transitions, such their operation id commits to it - use that
noncefor ordering operations with witnesses mined in the same block - the value of
noncemust be a 64-bit integer - add operation type as a factor of ordering, assigning its higher priority than
nonce.
This will allow to order graphs of off chain transactions in a consistent way, preserved even when they are mined.
Rationale
- 64-bit nonce. The max number of eltoo channel updates is 2^48 - 1. Since all updates are added to the graph, plus we need to order HTLCs (and we may have thousands of them), we need 64-bit nonce. Even though not of all of commitment transactions would be published, some may, and all of them must be ordered appropriately.
- operation type used in ordering. If we have two different state transitions of different mined into the same block, which (by mistake) have the same nonce, we still can order them using type. This allows usage of type id value as a way of setting strong ordering overriding nonce values (for instance token issues can be always ordered before spendings).
Metadata
Metadata
Assignees
Labels
Type
Projects
Status