refactor(consensus)!: block diffs, exec on propose and locks improvement #1035
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Local-Only-Rules
)Motivation and Context
This PR improves locking, substate management and allows local-only transaction concurrency.
It adds the following concepts:
BlockDiff
- contains the substate changes (UP or DOWN) for a block. Is used to commit state in a commit blockPendingSubstateStore
- tracks and validates changes to the substate store and decouples state from execution. It is used to generate a BlockDiff, track locks in the current block context, and to generate the state tree diff.ProposedBlockChangeSet
- contains all the pending changes to be committed when deciding to ACCEPT a new blockTransactionExecution
- decouples execution results from a transaction record. These represent an execution within the context of a block. Once a transaction is finalized, the execution result is added to the final result in the transaction.Possible issues:
Currently to fetch the correct transaction executions and locks for a block we need to limit the results to those that match the chain. This query will grow slower as the chain progresses. Bugs may still occur in the unhappy/malicious path.
How Has This Been Tested?
New deferred transaction consensus test, new unit tests, existing tests, removed ignore attribute from several consensus tests.
What process can a PR reviewer use to test or verify this change?
Submit transactions without specifying the version of the input. Submit local-only transactions concurrently that spend previous outputs from other local only transactions.
Breaking Changes
BREAKING CHANGE: database structure changed