Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Introduce on-chain architecture #5603

Closed
shuse2 opened this issue Aug 4, 2020 · 0 comments
Closed

Introduce on-chain architecture #5603

shuse2 opened this issue Aug 4, 2020 · 0 comments

Comments

@shuse2
Copy link
Collaborator

shuse2 commented Aug 4, 2020

Description

Defining and applying the module system for the on-chain block processing. It combines current block processing, transaction processing and schema definition and split them into 4 modules, token, sequence, DPoS and keys.

  • Token module is responsible for managing the balance including the transfer asset.
  • Sequence module is responsible for managing the nonce.
  • DPoS module is responsible for managing the DPoS properties and selection of the validators including register, vote, unlock and punishment assets.
  • Key module is responsible for multi-signature and signature validation including the register asset.

Each module will have possibility to add hooks as below:

// BaseModule to be extended per module
class BaseModule {
  public name: string;
  public type: number;
  // List of transaction assets for this module
  public assets: BaseAsset[];
  // Schema of account asset to be used in this module
  public accountSchema?: Schema;
  // Set of actions which can be called from framework
  public actions?: Map<string, ActionHandler>;
  // Set of events name that will be emitted from this module
  public events?: string[];
  // Set of actions which can be called from other modules during the block processing
  public reducers?: Map<string, ReduceHandler>;
  // A function which will be called for all transactions regardless of modules.
  public beforeTransactionApply?: ({tx: Transaction, stateStore: StateStore, moduleAccess}) => void;
  // A function which will be called for all transactions regardless of modules.
  public afterTransactionApply?: ({tx: Transaction, stateStore: StateStore, moduleAccess}) => void;
  // A function which will be called while applying genesis block
  public afterGenesisBlockApply?: ({block: GenesisBlock, stateStore: StateStore, consensus: Consensus, moduleAccess}) => void;
  // A function which will be called in sequence at beforeBlockApply step
  public beforeBlockApply?: ({block: Block, stateStore: StateStore, moduleAccess}) => void;
  // A function which will be called in sequence at afterBlockApply step
  public afterBlockApply?: ({block: Block, stateStore: StateStore, consensus: Consensus, moduleAccess}) => void;
}

Also asset will have the hooks as below, which will be exactly the same as current custom transaction hooks.

class BaseAsset<K> {
  // Name of the module which will be used in the path resolution
  public name: string;
  public type: number;
  // Base fee to be included in the minFee
  public baseFee?: bigint;
  // Schema of the content of this asset
  public assetSchema: Schema;
  // Validation function that can be implemented if additional 
  public applyAsset: ({senderID:Buffer, asset: K, stateStore: StateStore, moduleAccess }) => void;
  // Validation function that can be implemented if additional 
  public validateAsset?: (asset: K) => void;
}

Motivation

The main motivations for introducing an on-chain architecture to the Lisk SDK are as follows:

  • Enable developers to make block level state changes
  • Enable developers to define per module account schemas
  • Encapsulate the application domain properly

Tasks

Sprint 25

Sprint 26

@sridharmeganathan sridharmeganathan added this to the Sprint 26 milestone Aug 28, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants