Execution modules

Overview

Execution modules are responsible for carrying out the operations validated by the system. They perform the specific actions required by the operations, such as transferring tokens, invoking other smart contracts, or updating account states. This separation of execution from validation allows for clearer logic and better security management within the Veive protocol.

Flow

Execution modules are invoked after the validation phase, in phase 2 of the operation workflow. Once an operation has passed all necessary validation checks, the execution module takes over to perform the specified actions. This could involve moving funds, updating contract states, or any other blockchain transaction.

For instance, in the case of a token transfer, the execution module would deduct the amount from the sender's balance and add it to the receiver's balance. If the operation involves interacting with another smart contract, the execution module ensures that the correct method and parameters are used.

Scope

The scope of execution modules, like validation modules, is defined at different levels to specify when and how they should be invoked:

  1. Entry Point + Contract ID: Applies to specific methods within specific contracts. For example, a module may handle only the transfer method in a particular token contract.

  2. Entry Point: Handles operations involving a specific method across various contracts. This is useful for implementing general functionalities like fee deductions or logging.

  3. Any: The most general scope, where the module executes for any operation. This is often used for modules that need to log all activities or perform broad actions like audits.

Unlike validation modules, multiple execution modules can operate in parallel if they match the operation's scope. This allows for comprehensive execution, including logging, auditing, and performing the main operation.

Examples

  1. Token Transfer Module: Executes the transfer of tokens between accounts. This module updates the balances and records the transaction.

  2. Contract Interaction Module: Facilitates interactions with other smart contracts. For example, it might call a method on another contract to stake tokens or vote in a DAO.

  3. Piggybank Module: This module is an example of an execution module that automatically saves a percentage of each transfer operation into a separate savings account. It operates in the "transfer" scope, ensuring that a portion of each transfer is stored away as savings.

These modules demonstrate the diverse applications of execution modules, from simple token transfers to complex contract interactions.

Last updated