Module execute

Source
Expand description

Implementation of execution process on a sequence of Commands. The process starts from Pre-Charge phase, and then goes into Commands Phases, and finally Charge Phase.

Processes include execution of:

§Executing Commands from a Transaction

It is the normal flow of a transaction. Firstly, basic checking is performed and cancel the execution if it fails, and Balance of signer is deducted beforehand (Pre-Charge).

Then Commands are encapsulated into Command Tasks. Each command task is an item in a stack. Execution order starts from the top item. When Call Command is executed successfully with Deferred Command, the Deferred Commands are then encapsulated into Command Task and put to the stack. This stack model allows the Deferred Command to be executed right after its parent Call Command in the same way other commands do.

Each command task completes with a Command Receipt. If it fails, the process aborts and then goes to Charge Phase immediately.

Finally in the Charge Phase, the signer balance is adjusted according to the gas used. Some fees are also transferred to Proposer and Treasury.

§Executing a View Call

View Call means execution of a contract by calling its view-only methods. There is not Pre-Charge Phase nor Charge Phase. The gas used in the resulting command receipt is only catered for the gas consumption of this contract call.

§Executing Next Epoch Command

Next Epoch Command is a special command that does not go through Pre-Charge Phase or Charge Phase, but will modify the state and update signers nonce. Its goal is to compute the resulting state of Network Account and return changes to a validator set for next epoch in TransitionResult.