-
Notifications
You must be signed in to change notification settings - Fork 137
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Create ApplyingChunk.md * Update specs/RuntimeSpec/ApplyingChunk.md * Update specs/RuntimeSpec/ApplyingChunk.md * Update README.md * Update ApplyingChunk.md * Update ApplyingChunk.md * Update specs/RuntimeSpec/ApplyingChunk.md Co-authored-by: Aleksandr Logunov <the.aleksandr.logunov@gmail.com> * Update specs/RuntimeSpec/ApplyingChunk.md Co-authored-by: Aleksandr Logunov <the.aleksandr.logunov@gmail.com> * Update specs/RuntimeSpec/ApplyingChunk.md Co-authored-by: Aleksandr Logunov <the.aleksandr.logunov@gmail.com> * Update specs/RuntimeSpec/ApplyingChunk.md Co-authored-by: Aleksandr Logunov <the.aleksandr.logunov@gmail.com> * Update specs/RuntimeSpec/ApplyingChunk.md Co-authored-by: Aleksandr Logunov <the.aleksandr.logunov@gmail.com> Co-authored-by: Aleksandr Logunov <the.aleksandr.logunov@gmail.com>
- Loading branch information
1 parent
11e5164
commit 47f2860
Showing
2 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Applying chunk | ||
|
||
## Inputs and outputs | ||
|
||
Runtime.apply takes following inputs: | ||
* trie and current state root | ||
* *validator_accounts_update* | ||
* *incoming_receipts* | ||
* *transactions* | ||
|
||
and produces following outputs: | ||
* new state root | ||
* *validator_proposals* | ||
* *outgoing_receipts* | ||
* (executed receipt) *outcomes* | ||
* *proof* | ||
|
||
## Processing order | ||
|
||
* If this is first block of an epoch, dispense [epoch rewards](../Economics/README.md#validator-rewards-calculation) to validators (in order of *validator_accounts_update.stake_info*) | ||
* Slash locked balance for malicious behavior (in order of *validator_accounts_update.slashing_info*) | ||
* If [treasury account](../Economics/README.md#protocol-treasury) was not one of validators and this is first block of an epoch, dispense treasury account reward | ||
* If this is first block of new version or first block with chunk of new version, apply corresponding migrations | ||
* If this block do not have chunk for this shard, end process early | ||
* Process [transactions](Transactions.md) (in order of *transactions*) | ||
* Process local [receipts](Receipts.md) (in order of *transactions* that generated them) | ||
* Process delayed [receipts](Receipts.md) (ordered first by block where they were generated, then first local receipts based on order of generating *transactions*, | ||
then incoming receipts, ordered by *incoming_receipts* order) | ||
* Process incoming [receipts](Receipts.md) (ordered by *incoming_receipts*) | ||
|
||
When processing receipts we track gas used (including gas used on migrations). If we use up gas limit, we immediately stop to process delayed receipts, and for local and incoming | ||
receipts we add them to delayed receipts) | ||
|
||
* If any of the delayed receipts were processed or any new receipts were delayed, update indices of first and last unprocessed receipts in state | ||
* Remove duplicate validator proposals (for each account we only keep last one in receipts processing order) | ||
|
||
Please note that local receipts are receipts generated by transaction where receiver is the same as signer of the transaction | ||
|
||
## Delayed receipts | ||
|
||
In each block we have maximal amount of Gas we can use to process receipts and migrations, currently 500 TGas. If any incoming or local receipts are not processed due to lack of remaining Gas, they are stored in state with key <pre>TrieKey::DelayedReceipt { id }</pre> where id is unique index for each shard, assigned consecutively. Currently sender does not need to stake any tokens to store delayed receipts. State also contains special key <pre>TrieKey::DelayedReceiptIndices</pre> where first and last ids of delayed receipts not yet processed are stored. |
This file contains 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