Gateway
Abstract
This module is responsible for the management of data on the gateway chain
Contents
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 accountsbank
: addition, deletion, modification and query of supply and balancestaking
: management of gateway related datapledge
: management of chat related dataevm
: management of evm related datachat
: management of chat related datagateway
: 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 |