-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Description
Basically we want to know when does a transaction is committed during parallel block execution, a committed transaction won’t be re-executed again.
A transaction is committed iff:
- All the txs before it are committed
- The last validation is successful and late enough (there's no pending validations that will fail it later).
The first property can be implemented with a commit_idx atomic counter, it’s increased when a transaction get committed.
The second property is tricker, we observe that a validation can only be scheduled in two ways:
- schedule validation of a specific transaction (by return
TaskKindValidationinFinishExecution) - validate a wave of validations for all transactions after i (by setting the
validationIdxcounter inDecreaseValidationIdx).
To make sure the current validation execution is triggered late enough, we need to track is the current validation is the last one in the triggered ones. We need to add some atomic counters to record the ordering information between events:
validation_waveincreased whenever a validation wave is triggered.[BlockSize]triggered_waverecord the wave counter when txitrigger wave validation.commit_wave, when txicommit, record the maximumtriggered_wave[i]in i and all txs before it.required_waverecord the current wave number when trigger a specific tx validation.
When validation succeeds, it check commit_idx to be i-1, and wave number equal to or larger than both commit_wave, and required_wave.