Skip to content

Gateway

Abstract

This module is responsible for the management of data on the gateway chain

Contents

  1. Concepts
  2. Keeper
  3. Messages
  4. Params
chat/
β”œβ”€β”€ client
β”‚ └── rest
β”‚ β”œβ”€β”€ error.go # interface error collection
β”‚ β”œβ”€β”€ grpc.go # grpc query method
β”‚ β”œβ”€β”€ handle_comm.go # comm module message pre-processing
β”‚ β”œβ”€β”€ handle_msg.go # comm module message pre-processing
β”‚ β”œβ”€β”€ query.go # interface query function
β”‚ β”œβ”€β”€ rest.go # Registration of message and query routing
β”‚ └── tx.go # tx related methods, including broadcasting, etc.
β”œβ”€β”€keeper
β”‚ β”œβ”€β”€ hooks.go # Hook function, triggered by other module logic
β”‚ β”œβ”€β”€ keeper.go # storage manager, handles the business logic of the module, and has permission to access specific subtrees of the state tree
β”‚ β”œβ”€β”€ msg_server.go # Provide service processing logic for uplink messages
β”‚ β”œβ”€β”€ params.go # Setting and obtaining module parameters
β”‚ β”œβ”€β”€ query.go # Status query function
β”œβ”€β”€ types
β”‚ β”œβ”€β”€ codec.go # code registration type
β”‚ β”œβ”€β”€ errors.go # module-specific errors
β”‚ β”œβ”€β”€ events.go # Events exposed to Tendermint PubSub/Websocket
β”‚ β”œβ”€β”€ genesis.go # Genesis state of the module
β”‚ β”œβ”€β”€ interface.go # interface collection of modules
β”‚ β”œβ”€β”€ keys.go # module stores key and some other constants
β”‚ β”œβ”€β”€ msg.go # Chat module transaction message
β”‚ β”œβ”€β”€ params.go # The custom parameters that the module can modify through the governance module
β”‚ β”œβ”€β”€ interface.go # The method implemented by the imported external module
β”‚ └── types.go # module type collection
β”œβ”€β”€ genesis.go # ABCI's genesis state initialization and export function
β”œβ”€β”€ handler.go # message routing
└── module.go # Module settings of the module manager

Concepts

Gateway

The gateway module is responsible for the management of the data on the gateway chain, including the ownership and acquisition of the number segment

Gateway Information

Gateway registration needs to fill in the name of the gateway, the communication address of the gateway, the name of the APP package, and the first number segment information. The gateway communication address supports IP and domain names, and needs to be bound to the 50327 communication port. The APP package name needs to start with a lowercase letter, and the length cannot exceed 32 characters. Gateways cannot be registered repeatedly, and each DPOS node can only register one gateway. Gateway information supports modifying the name and gateway communication address. 🚨 DANGER: Once the communication address of the gateway is modified, the chat information of the gateway will be reset, please proceed with caution.

Number section

For the first registration of the gateway, a number segment must be filled in, which will be marked as the first number segment of the gateway and used as the communication domain name. The length of the number segment can be 5, 6, or 7. When the quota of the gateway number segment is sufficient, it supports adding multiple number segments. The number segment is divided into three states: binding, redeeming, and unbound. The number segment that has been bound and redeemed cannot be used by other gateways. The number segment that is being redeemed has a default protection period of one year. When the gateway owner pledges again, he can choose the number segment again and bind it. The unbound number segment can be used again by all gateways.

Gateway pledge and redemption

By default, every 10 NXN pledged can get a gateway number segment quota. When the gateway owner redeems DPOS, corresponding to the redemption of 10 NXN, one number segment must be redeemed or the amount of the corresponding number segment should be reduced. When redeeming in part, the first number segment is not allowed to be redeemed, only other number segments can be selected. If all pledges are redeemed, all number segments will be redeemed. After all pledges are redeemed, the gateway status becomes unavailable.

Keeper

The contract module 'Keeper' grants access to the state of the chat module And implement 'statedb. Interface to support 'StateDB' implementation. Keeper contains a storage key that allows the repository Write to the concrete subtree of the multibase that can only be accessed by the Chat module. Instead of using trees and databases for querying and persistence (the 'StateDB' implementation), DaoDst uses Cosmos' "KVStore" (key-value store) and Cosmos SDK's "Keeper" to facilitate state transitions.

In order to support the interface function, it imports 7 module Keepers:

  • auth: addition, deletion, modification and query of accounts
  • bank: addition, deletion, modification and query of supply and balance
  • staking: management of gateway related data
  • pledge: management of chat related data
  • evm: management of evm related data
  • chat: management of chat related data
  • gateway: gateway data management
    type Keeper struct {
        storeKey   sdk.StoreKey
        cdc        codec.BinaryCodec
        paramstore paramtypes.Subspace

        stakingKeeper *stakingKeeper.Keeper
        accountKeeper types.AccountKeeper
        BankKeeper    types.BankKeeper
        pledgeKeeper  types.PledgeKeeper
        evmKeeper     types.EVMKeeper
        chatKeeper    types.ChatKeeper
        gatewayKeeper types.GatewayKeeper
        erc20Keeper   erc20keeper.Keeper
    }

Messages

MsgAppTokenIssue

Through this message, back up the gateway's authenticator key and other information
    type MsgGatewayUpload struct {
        FromAddress    string `protobuf:"bytes,1,opt,name=fromAddress,proto3" json:"fromAddress,omitempty" yaml:"from_address"`
        GatewayKeyInfo []byte `protobuf:"bytes,2,opt,name=GatewayKeyInfo,proto3" json:"GatewayKeyInfo,omitempty" yaml:"gateway_key_info"`
    }

MsgGatewayRegister

Through this message, register as a gateway and get the did number segment
    type MsgGatewayRegister struct {
        Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"`
        GatewayName string `protobuf:"bytes,2,opt,name=gateway_name,json=gatewayName,proto3" json:"gateway_name,omitempty"`
        GatewayUrl string `protobuf:"bytes,3,opt,name=gateway_url,json=gatewayUrl,proto3" json:"gateway_url,omitempty"`
        Delegation string `protobuf:"bytes,4,opt,name=delegation,proto3" json:"delegation,omitempty"`
        IndexNumber []string `protobuf:"bytes,5,rep,name=index_number,json=indexNumber,proto3" json:"index_number,omitempty"`
    }

MsgGatewayIndexNum

Through this message, the gateway can obtain additional did number segments through pledge
    type MsgGatewayIndexNum struct {
        DelegatorAddress string `protobuf:"bytes,1,opt,name=delegator_address,json=delegatorAddress,proto3" json:"delegator_address,omitempty" yaml:"delegator_address"`
        ValidatorAddress string `protobuf:"bytes,2,opt,name=validator_address,json=validatorAddress,proto3" json:"validator_address,omitempty" yaml:"validator_address"`
        IndexNumber []string `protobuf:"bytes,3,rep,name=index_number,json=indexNumber,proto3" json:"index_number,omitempty"`
    }

MsgGatewayUndelegate

With this message, the gateway can redeem the stake
    type MsgGatewayUndelegate struct {
        DelegatorAddress string      `protobuf:"bytes,1,opt,name=delegator_address,json=delegatorAddress,proto3" json:"delegator_address,omitempty" yaml:"delegator_address"`
        ValidatorAddress string      `protobuf:"bytes,2,opt,name=validator_address,json=validatorAddress,proto3" json:"validator_address,omitempty" yaml:"validator_address"`
        Amount           types1.Coin `protobuf:"bytes,3,opt,name=amount,proto3" json:"amount"`
        IndexNumber []string `protobuf:"bytes,4,rep,name=index_number,json=indexNumber,proto3" json:"index_number,omitempty"`
    }

Parameters

The gateway module contains the following module parameters

Params

Key Type Default Value
IndexNumHeight int64 100
RedeemFeeHeight int64 432000
RedeemFee github_com_cosmos_cosmos_sdk_types.Dec 0.1
MinDelegate github_com_cosmos_cosmos_sdk_types.Coin 10000000000000000000000fm
Validity int64 5256000