-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Generic Transaction Queue logic in runtime #728
Description
The goal of this PR is to work towards a flexible transaction queue that relies only on runtime logic to provide comprehensive dependency and queuing management. In particular, the unified transaction queue integrated into substrate-node should not be aware of the concepts of accounts, signatures, indexes or nonces. Rather an alternative model of tags (a tag is an arbitrary Vec<u8>) is used with transactions requiring some set (possibly empty) of tags before they become valid and providing some other set of tags (though usually just one).
SRML runtime API should expose a function:
enum TransactionValidity { Valid(u64, Vec<u8>, Vec<u8>), Invalid, Unknown }fn validate_transaction(transaction: Vec<u8>) -> TransactionValidity
Returns Valid if the transaction can be statically validated; in this case it returns a pair of tags and a block number; the first is the tags that including this provides, the second is the tags that must have been provided by transactions prior to this, the u64 is the priority used to determine which of a mutually exclusive set of transactions are better to include. The transaction queue should build a dependency graph using the tags in order to ensure transactions are included in blocks in the correct order. Any transactions that do get included in a block should be instantly discarded (and banned) if they result in a panic execution.
Unknown is returned if the transaction might yet become valid in the future. No further information is given and the transaction queue is free to disregard (and even temporarily ban) the transaction in expectation that once it becomes valid it will be rebroadcast.
Invalid is returned if the transaction is strictly malformed or contains data that imply it could never be valid for this chain. The transaction queue should disregard and ban it ASAP; it should also consider a small punishment to the peer that provided it.
Parts:
- Change to the runtime (Generalised Transaction Queue API #741)
- Change to the transaction queue.