$$ \newcommand \Commit {\mathrm{Commit}} \newcommand \RetrieveProposal {\mathrm{RetrieveProposal}} \newcommand \ApplyDeltas {\mathrm{ApplyDeltas}} \newcommand \TP {\mathrm{TransactionPool}} \newcommand \Update {\mathrm{Update}} \newcommand \PSfunction {\textbf{function }} \newcommand \PSendfunction {\textbf{end function}} \newcommand \pset {\mathit{payset}} $$
Commitment
The commitment is the final stage that updates the copy of the Ledger on the node, applying all the state deltas (e.g., account balances, application state, etc.) related to the transactions contained in the committed block proposal.
Algorithm
In the following pseudocode \( e_t \) denotes the body (transactions) of the proposal (a.k.a. the payset).
\( \textbf{Algorithm 8} \text{: Commit} \)
$$ \begin{aligned} &\text{1: } \PSfunction \Commit(v) \\ &\text{2: } \quad e \gets \RetrieveProposal(v)_e \\ &\text{3: } \quad L \gets L || e \\ &\text{4: } \quad \ApplyDeltas(e) \\ &\text{5: } \quad \TP.\Update(e_t) \\ &\text{6: } \PSendfunction \end{aligned} $$
⚙️ IMPLEMENTATION
Commit block proposal reference implementation.
The function commits to the Ledger the block corresponding to the received proposal-value.
The proposal-value must be committable, which implies both validity and availability of the full block body and seed.
The node retrieves the full block \( e \) related to the proposal-value (Line 2), and appends it to the Ledger \( L \) (Line 3).
Then, the node updates the Ledger state (and trackers) with all state changes (deltas) produced by the new committed block.
For further details, refer to the Ledger normative section.
The \( \TP \) is then purged of all transactions in the committed block.
For further details on this process, see the Ledger non-normative section.