# poc Consensus Module

# Why do you have a consensus module?

As we all know, the core of the blockchain is the consensus mechanism.Unlike the traditional Internet's clipet-server architecture, the nodes of the blockchain are peer-to-peer, without the center, and everyone has the same rights; so in order to make the data consistent, let a network without a center maintain a set of books that everyone agrees with. This is the role of the consensus mechanism. Broadly speaking, the consensus mechanism is the rule or algorithm that each node of the blockchain adheres to, and is the basis for mutual trust, so that decentralized unsupervised can be realized and the normal operation of the entire platform can be maintained. In a narrow sense, the consensus mechanism determines the mechanism by which each node verifies and validates transactions on the blockchain.

# What does the consensus module do?

Every transaction in the blockchain must be approved by each node. Only after the whole network has reached a consensus, the transaction is completed.It is like in a democratic election, the voting method or rules must be recognized by the whole people, based on which the election can be completed.In the blockchain, the main performance of the consensus mechanism is the incentive system, which is the reward for the miners.Under the guarantee of the consensus mechanism, every miner can be rewarded, and the entire blockchain can operate in an orderly manner, providing a fair, transparent and trusting environment.Therefore, the consensus module needs to provide a specific algorithm to maintain, that is, the consensus algorithm.

There are many public chain consensus mechanisms, and the mainstream is POW, POS, and DPOS.The NULS main network adopts the self-originated POC (Proof Of Credit) consensus mechanism, which inherits the security and high efficiency of the Dpos consensus mechanism. At the same time, it has made great improvements in collaboration, which can be regarded as an upgraded version. Dpos.

# poc Consensus Module Responsibilities:

  • Legality verification after block synchronization

  • Create consensus nodes, delegate participation consensus, cancel delegation, and cancel consensus nodes ★

  • Consensus node packs out blocks

  • Disbursement of network maintenance incentives

  • Do evil node punishment ★

    Different consensus mechanisms have different consensus algorithms, and there are tags that are unique to the poc consensus.

# "Consensus Module" positioning in the system

The consensus module is a relatively core piece in the system. It is mainly responsible for packing transactions, verifying block headers, managing consensus node information in the management system, entrusting information, and penalizing information.

# Interface List

# createAgentValid

create agent transaction validate

# scope:public

# version:1.0

# parameter list

Parameter Name Parameter Type Parameter Description Is Not Empty
chainId int chain id yes
tx string Transactions Yes

# return value

Field Name Field Type Parameter Description
value boolean Create Node Verification Results

# stopAgentValid

stop agent transaction validate

# scope:public

# version:1.0

# parameter list

Parameter Name Parameter Type Parameter Description Is Not Empty
chainId int chain id yes
tx string Transactions Yes

# return value

Field Name Field Type Parameter Description
value boolean Stop node transaction verification result

# depositValid

deposit agent transaction validate

# scope:public

# version:1.0

# parameter list

Parameter Name Parameter Type Parameter Description Is Not Empty
chainId int chain id yes
tx string Transactions Yes

# return value

Field Name Field Type Parameter Description
value boolean Trusted Transaction Verification Results

# withdrawValid

withdraw deposit agent transaction validate

# scope:public

# version:1.0

# parameter list

Parameter Name Parameter Type Parameter Description Is Not Empty
chainId int chain id yes
tx string Transactions Yes

# return value

Field Name Field Type Parameter Description
value boolean Exit Consensus Transaction Verification Results

# cs_runChain

Running a sub chain 1.0

# scope:public

# version:1.0

# parameter list

Parameter Name Parameter Type Parameter Description Is Not Empty
chainId string yes

# return value

No return value

# cs_getAgentChangeInfo

get seed nodes list

# scope:public

# version:1.0

# parameter list

Parameter Name Parameter Type Parameter Description Is Not Empty
chainId string yes

# return value

No return value

# cs_addEvidenceRecord

Chain evidence record /add evidence record

# scope:public

# version:1.0

# parameter list

Parameter Name Parameter Type Parameter Description Is Not Empty
chainId int chain id yes
blockHeader string Forked block head one Yes
evidenceHeader string bifurcation block header 2 yes

# return value

Field Name Field Type Parameter Description
value boolean Processing Results

# cs_doubleSpendRecord

Double flower transaction record / double spend transaction record

# scope:public

# version:1.0

# parameter list

Parameter Name Parameter Type Parameter Description Is Not Empty
chainId int chain id yes
block string Block Information Yes
tx string Fork Trading Yes

# return value

Field Name Field Type Parameter Description
value boolean Processing Results

# cs_getWholeInfo

Query the consensus information of the whole network

# scope:public

# version:1.0

# parameter list

Parameter Name Parameter Type Parameter Description Is Not Empty
chainId int chain id yes

# return value

Field Name Field Type Parameter Description
agentCount int Number of nodes
totalDeposit string total delegate two
rewardOfDay string Total Consensus Bonus for the day
consensusAccountNumber int Number of participants in consensus
packingAgentCount int Current round out block number

# cs_getInfo

Query specific account consensus data for specified accounts

# scope:public

# version:1.0

# parameter list

Parameter Name Parameter Type Parameter Description Is Not Empty
chainId int chain id yes
address string account address yes

# return value

Field Name Field Type Parameter Description
agentCount int Number of nodes
totalDeposit string Total amount of participation in consensus
joinAgentCount int Number of participating consensus nodes
usableBalance string Available balances
reward string Consensus Awards
rewardOfDay string Consensus Awards received on the day
agentHash string created node HASH

# cs_getPublishList

Query red and yellow card records /query punish list

# scope:public

# version:1.0

# parameter list

Parameter Name Parameter Type Parameter Description Is Not Empty
chainId int chain id yes
address string address yes
type int penalty type 0 red and yellow card record 1 red card record 2 yellow card record yes

# return value

Field Name Field Type Parameter Description
RedPunish list<string> List of red cards obtained
yellowPunish list<string> Get the yellow card penalty list

# cs_getRoundInfo

Get current round information

# scope:public

# version:1.0

# parameter list

Parameter Name Parameter Type Parameter Description Is Not Empty
chainId int chain id yes

# return value

Field Name Field Type Parameter Description
totalWeight double current round total weight
index long Round subscript
startTime long Round start time
endTime long Round end time
memberCount int Number of nodes in this round
memberList list<object> This round of member information
        roundIndex long Round subscript
        roundStartTime long Round start time
        packingIndexOfRound int The node is the first in this round
        agent object Consensus Node Information
                agentAddress byte[] Node Address
                packingAddress byte[] Block Address
                rewardAddress byte[] Reward Address
                deposit biginteger Margin
                commissionRate byte Commission Ratio
                time long creation time
                 blockHeight long
                delHeight long Node Logout Height
                status int Status, 0: Consensus unConsensus, 1: Consensus Consensus
                creditVal double Reputation Value
                totalDeposit biginteger Total node commission amount
                txHash nulshash Create this node's transaction HASH
                memberCount int
                alais string node alias
        depositList list<object> Current node delegation information
                deposit biginteger
                agentHash nulshash Delegate Node HASH
                address byte[]
                time long
                status int Status
                txHash nulshash Commissioning HASH
                blockHeight long The height of the delegated transaction is packaged
                delHeight long Exit delegate height
        sortValue string Sort Value
        packStartTime long Current node starts to block time
        packEndTime long Current Node Out End Time
preRound object<meetinground> Last round of information
myMember object current node block information
        roundIndex long Round subscript
        roundStartTime long Round start time
        packingIndexOfRound int The node is the first in this round
        agent object Consensus Node Information
                agentAddress byte[] Node Address
                packingAddress byte[] Block Address
                rewardAddress byte[] Reward Address
                deposit biginteger Margin
                commissionRate byte Commission Ratio
                time long creation time
                 blockHeight long
                delHeight long Node Logout Height
                status int Status, 0: Consensus unConsensus, 1: Consensus Consensus
                creditVal double Reputation Value
                totalDeposit biginteger Total node commission amount
                txHash nulshash Create this node's transaction HASH
                memberCount int
                alais string node alias
        depositList list<object> Current node delegation information
                deposit biginteger
                agentHash nulshash Delegate Node HASH
                address byte[]
                time long
                status int Status
                txHash nulshash Commissioning HASH
                blockHeight long The height of the delegated transaction is packaged
                delHeight long Exit delegate height
        sortValue string Sort Value
        packStartTime long Current node starts to block time
        packEndTime long Current Node Out End Time

# cs_getRoundMemberList

Query the membership list of the specified block's rounds

# scope:public

# version:1.0

# parameter list

Parameter Name Parameter Type Parameter Description Is Not Empty
chainId int chain id yes
extend string Block header extension information Yes

# return value

Field Name Field Type Parameter Description
packAddressList list<string> Current list of outgoing addresses

# cs_getConsensusConfig

Get consensus module configuration information / get consensus config

# scope:public

# version:1.0

# parameter list

Parameter Name Parameter Type Parameter Description Is Not Empty
chainId int chain id yes

# return value

Field Name Field Type Parameter Description
seedNodes string seed node list
inflationAmount integer
agentAssetId integer Consensus Asset ID
agentChainId integer Consensus Asset Chain ID
awardAssetId integer Reward Asset ID (Consensus Reward for this Chain Asset)

# cs_runMainChain

run main chain 1.0

# scope:public

# version:1.0

# parameter list

Parameter Name Parameter Type Parameter Description Is Not Empty
chainId string yes

# return value

No return value

# cs_stopChain

stop a chain 1.0

# scope:public

# version:1.0

# parameter list

Parameter Name Parameter Type Parameter Description Is Not Empty
chainId string yes

# return value

No return value

# cs_getAgentList

Query the list of consensus nodes in the current network

# scope:public

# version:1.0

# parameter list

Parameter Name Parameter Type Parameter Description Is Not Empty
chainId int chain id yes
pageNumber int Page Number No
pageSize int per page size no
keyWord string Keywords No

# return value

Field Name Field Type Parameter Description
agentHash string Node HASH
agentAddress string node address
packingAddress string Node Outbound Address
rewardAddress string Node Reward Address
deposit string Mortgage Amount
commissionRate byte Commission Ratio
agentName string node name
agentId string node ID
introduction string Node Introduction
time long node creation time
blockHeight long Node Packing Height
delHeight long Node Failure Height
status int Status
creditVal double Reputation Value
totalDeposit string Total Delegate Amount
txHash string Create Node Trading HASH
memberCount int Number of delegates
version string version

# cs_stopAgent

Logout node/stop agent

# scope:public

# version:1.0

# parameter list

Parameter Name Parameter Type Parameter Description Is Not Empty
chainId int chain id yes
address string node address yes
password string password yes

# return value

Field Name Field Type Parameter Description
txHash string Stop Node Trading HASH

# cs_createAgent

Create node transaction / create agent transaction

# scope:public

# version:1.0

# parameter list

Parameter Name Parameter Type Parameter Description Is Not Empty
chainId int chain id yes
agentAddress string node address yes
packingAddress string Node Block Address Yes
rewardAddress string reward address, default node address no
commissionRate int Commission Ratio Yes
deposit string Mortgage amount Yes
password string password yes

# return value

Field Name Field Type Parameter Description
txHash string Create Node Trading HASH

# cs_getAgentInfo

Query pointing node details / Query pointer node details

# scope:public

# version:1.0

# parameter list

Parameter Name Parameter Type Parameter Description Is Not Empty
chainId int chain id yes
agentHash string Node HASH Yes

# return value

Field Name Field Type Parameter Description
agentHash string Node HASH
agentAddress string node address
packingAddress string Node Outbound Address
rewardAddress string Node Reward Address
deposit string Mortgage Amount
commissionRate byte Commission Ratio
agentName string node name
agentId string node ID
introduction string Node Introduction
time long node creation time
blockHeight long Node Packing Height
delHeight long Node Failure Height
status int Status
creditVal double Reputation Value
totalDeposit string Total Delegate Amount
txHash string Create Node Trading HASH
memberCount int Number of delegates
version string version

# cs_getAgentStatus

Query the specified consensus node status / query the specified consensus node status 1.0

# scope:public

# version:1.0

# parameter list

Parameter Name Parameter Type Parameter Description Is Not Empty
chainId int chain id yes
agentHash string Node HASH Yes

# return value

Field Name Field Type Parameter Description
status byte Node Status

# cs_updateAgentConsensusStatus

Modify node consensus state /modifying the Node Consensus State

# scope:public

# version:1.0

# parameter list

Parameter Name Parameter Type Parameter Description Is Not Empty
chainId int chain id yes

# return value

Field Name Field Type Parameter Description
N/A void No specific return value, no error means the node consensus state was modified successfully

# cs_updateAgentStatus

Modify the Packing State of Nodes

# scope:public

# version:1.0

# parameter list

Parameter Name Parameter Type Parameter Description Is Not Empty
chainId int chain id yes
status int Node Status Yes

# return value

Field Name Field Type Parameter Description
N/A void No specific return value, no error means the node packing status is modified successfully

# cs_getNodePackingAddress

Get the current node out address/Get the current node's out-of-block address

# scope:public

# version:1.0

# parameter list

Parameter Name Parameter Type Parameter Description Is Not Empty
chainId int chain id yes

# return value

Field Name Field Type Parameter Description
packAddress string current node block address

# cs_getAgentAddressList

Get the current network consensus node outbound address list or query the nearest N blocks outbound address/Get all node out-of-block addresses or specify N block out-of-block designations

# scope:public

# version:1.0

# parameter list

Parameter Name Parameter Type Parameter Description Is Not Empty
chainId int chain id yes

# return value

Field Name Field Type Parameter Description
packAddress string Consensus Node List

# cs_getPackerInfo

Get the current node's outbound account information /modifying the Packing State of Nodes

# scope:public

# version:1.0

# parameter list

Parameter Name Parameter Type Parameter Description Is Not Empty
chainId int chain id yes

# return value

Field Name Field Type Parameter Description
address string current node block address
password string current node password
packAddressList list<string> Current Packed Address List

# cs_getSeedNodeInfo

Get seed node information / get seed node info

# scope:public

# version:1.0

# parameter list

Parameter Name Parameter Type Parameter Description Is Not Empty
chainId int chain id yes

# return value

Field Name Field Type Parameter Description
address string current node block address
password string current node password
packAddressList list<string> Current Packed Address List

# cs_stopContractAgent

Smart contract logout node/contract stop agent

# scope:public

# version:1.0

# parameter list

Parameter Name Parameter Type Parameter Description Is Not Empty
chainId int chain id yes
contractAddress string contract address yes
contractSender string contract caller address yes
contractBalance string Current balance of contract address Yes
contractNonce string current nonce value of the contract address Yes
blockTime long Current packed block time Yes

# return value

Field Name Field Type Parameter Description
Return value list<string> Return transaction HASH and transaction

# cs_createContractAgent

Smart contract creation node / contract create agent

# scope:public

# version:1.0

# parameter list

Parameter Name Parameter Type Parameter Description Is Not Empty
chainId int chain id yes
packingAddress string Block Address Yes
deposit string Mortgage amount Yes
commissionRate string commission ratio yes
contractAddress string contract address yes
contractSender string contract caller address yes
contractBalance string Current balance of contract address Yes
contractNonce string current nonce value of the contract address Yes
blockTime long Current packed block time Yes

# return value

Field Name Field Type Parameter Description
Return value list<string> Return transaction HASH and transaction

# cs_contractDeposit

Smart contract delegation

# scope:public

# version:1.0

# parameter list

Parameter Name Parameter Type Parameter Description Is Not Empty
chainId int chain id yes
agentHash string delegate node HASH yes
deposit string commission amount yes
contractAddress string contract address yes
contractSender string contract caller address yes
contractBalance string Current balance of contract address Yes
contractNonce string current nonce value of the contract address Yes
blockTime long Current packed block time Yes

# return value

Field Name Field Type Parameter Description
Return value list<string> Return transaction HASH and transaction

# cs_contractWithdraw

Smart contract withdrawal agreement

# scope:public

# version:1.0

# parameter list

Parameter Name Parameter Type Parameter Description Is Not Empty
chainId int chain id yes
joinAgentHash string Node HASH Yes
contractAddress string contract address yes
contractSender string contract caller address yes
contractBalance string Current balance of contract address Yes
contractNonce string current nonce value of the contract address Yes
blockTime long Current packed block time Yes

# return value

Field Name Field Type Parameter Description
Return value list<string> Return transaction HASH and transaction

# cs_getContractDepositInfo

Intelligent Contract Query for Assigned Account Delegation Information

# scope:public

# version:1.0

# parameter list

Parameter Name Parameter Type Parameter Description Is Not Empty
chainId int chain id yes
joinAgentHash string Node HASH Yes
contractAddress string contract address yes
contractSender string contract caller address yes

# return value

Field Name Field Type Parameter Description
Return value list<string> Delegation information

# cs_getContractAgentInfo

Smart contract node / contract get agent info

# scope:public

# version:1.0

# parameter list

Parameter Name Parameter Type Parameter Description Is Not Empty
chainId int chain id yes
agentHash string Node HASH Yes
contractAddress string contract address yes
contractSender string contract caller address yes

# return value

Field Name Field Type Parameter Description
return value list<string> node information

# cs_triggerCoinBaseContract

Trading module triggers CoinBase smart contract/trigger coin base contract

# scope:public

# version:1.0

# parameter list

Parameter Name Parameter Type Parameter Description Is Not Empty
chainId int chain id yes
tx string Trading Information Yes
blockHeader string Block Head Yes
stateRoot string stateRoot yes

# return value

Field Name Field Type Parameter Description
value string stateRoot

# cs_chainRollBack

Block rollback/chain rollback

# scope:public

# version:1.0

# parameter list

Parameter Name Parameter Type Parameter Description Is Not Empty
chainId int chain id yes
height int Height the block is rolled back to Yes

# return value

Field Name Field Type Parameter Description
value boolean Block Rollback Results

# cs_addBlock

Receive and cache new blocks/Receiving and caching new blocks

# scope:public

# version:1.0

# parameter list

Parameter Name Parameter Type Parameter Description Is Not Empty
chainId int chain id yes
blockHeader string Block Head Yes

# return value

Field Name Field Type Parameter Description
value boolean Interface execution success or not

# cs_receiveHeaderList

Receive and cache block list/Receive and cache block lists

# scope:public

# version:1.0

# parameter list

Parameter Name Parameter Type Parameter Description Is Not Empty
chainId int chain id yes
headerList string block header list yes

# return value

Field Name Field Type Parameter Description
value boolean Whether to receive processing successfully

# cs_validBlock

Verification block /verify block correctness

# scope:public

# version:1.0

# parameter list

Parameter Name Parameter Type Parameter Description Is Not Empty
chainId int chain id yes
download int Block Status Yes
block string Block Information Yes

# return value

Field Name Field Type Parameter Description
value boolean Verify Results

# cs_createMultiAgent

Multi-Sign Account Create Agent transaction

# scope:public

# version:1.0

# parameter list

Parameter Name Parameter Type Parameter Description Is Not Empty
chainId int chain id yes
agentAddress string node address (multiple signing address) yes
packingAddress string Node Block Address Yes
rewardAddress string reward address, default node address no
commissionRate int Commission Ratio Yes
deposit string Mortgage amount Yes
password string Signature Account Password Yes
signAddress string Signature Account Address Yes

# return value

Field Name Field Type Parameter Description
tx string Complete transaction serialization string, continue signature if the transaction does not reach the minimum number of signatures
txHash string Trading hash
completed boolean true: the transaction is complete (broadcast), false: the transaction is not completed, the minimum number of signatures has not been reached

# cs_stopMultiAgent

Multi-Sign Account Stop Agent

# scope:public

# version:1.0

# parameter list

Parameter Name Parameter Type Parameter Description Is Not Empty
chainId int chain id yes
address string node address (multiple signing address) yes
password string Signature Account Password Yes
signAddress string Signature Account Address Yes

# return value

Field Name Field Type Parameter Description
tx string Complete transaction serialization string, continue signature if the transaction does not reach the minimum number of signatures
txHash string Trading hash
completed boolean true: the transaction is complete (broadcast), false: the transaction is not completed, the minimum number of signatures has not been reached

# cs_multiDeposit

Multi-Sign Account deposit agent transaction

# scope:public

# version:1.0

# parameter list

Parameter Name Parameter Type Parameter Description Is Not Empty
chainId int chain id yes
address string Multi-Sign Account Address Yes
agentHash string Node HASH Yes
deposit string commission amount yes
password string Signature Account Password Yes
signAddress string Signature Account Address Yes

# return value

Field Name Field Type Parameter Description
tx string Complete transaction serialization string, continue signature if the transaction does not reach the minimum number of signatures
txHash string Trading hash
completed boolean true: the transaction is complete (broadcast), false: the transaction is not completed, the minimum number of signatures has not been reached

# cs_multiWithdraw

Multi-Sign Account withdraw deposit agent transaction

# scope:public

# version:1.0

# parameter list

Parameter Name Parameter Type Parameter Description Is Not Empty
chainId int chain id yes
address string Multi-Sign Account Address Yes
txHash string Join the consensus transaction HASH Yes
password string Signature Account Password Yes
signAddress string Signature Account Address Yes

# return value

Field Name Field Type Parameter Description
tx string Complete transaction serialization string, continue signature if the transaction does not reach the minimum number of signatures
txHash string Trading hash
completed boolean true: the transaction is complete (broadcast), false: the transaction is not completed, the minimum number of signatures has not been reached

# cs_random_seed_count

Generate a random seed based on the height and the number of original seeds and return

# scope:public

# version:1.0

# parameter list

Parameter Name Parameter Type Parameter Description Is Not Empty
chainId int chain id yes
height long maximum height yes
count int Number of original seeds Yes
Algorithm string Algorithm ID: SHA3... Yes

# return value

Field Name Field Type Parameter Description
seed string generated random seed
algorithm string Algorithm ID
count int Number of original seeds

# cs_random_seed_height

Generate a random seed based on the height interval and return

# scope:public

# version:1.0

# parameter list

Parameter Name Parameter Type Parameter Description Is Not Empty
chainId int chain id yes
startHeight long starting height yes
endHeight long cutoff height yes
Algorithm string Algorithm ID: SHA3... Yes

# return value

Field Name Field Type Parameter Description
seed string generated random seed
algorithm string Algorithm ID
count int Number of original seeds

# cs_random_raw_seeds_count

Find the original seed list based on height and return

# scope:public

# version:1.0

# parameter list

Parameter Name Parameter Type Parameter Description Is Not Empty
chainId int chain id yes
height long starting height yes
count int Cutoff Height Yes

# return value

Field Name Field Type Parameter Description
Return value list<string>

# cs_random_raw_seeds_height

Query the original seed list based on the height interval and return

# scope:public

# version:1.0

# parameter list

Parameter Name Parameter Type Parameter Description Is Not Empty
chainId int chain id yes
startHeight long starting height yes
endHeight long cutoff height yes

# return value

Field Name Field Type Parameter Description
Return value list<string>

# cs_getDepositList

Query delegation information for a specified account or a specified node

# scope:public

# version:1.0

# parameter list

Parameter Name Parameter Type Parameter Description Is Not Empty
chainId int chain id yes
pageNumber int Page Number Yes
pageSize int per page yes
address string account address yes
agentHash string Node HASH Yes

# return value

Field Name Field Type Parameter Description
deposit string
agentHash string Node HASH
address string Account Address
time long delegation time
txHash string Commissioned Trading HASH
blockHeight long Delegate transaction is packaged height
delHeight long Exit delegate height
status int Node Status 0: To be Consensus, 1: Consensus
agentName string node name
agentAddress string node address

# cs_depositToAgent

Create a delegate transaction /deposit agent transaction

# scope:public

# version:1.0

# parameter list

Parameter Name Parameter Type Parameter Description Is Not Empty
chainId int chain id yes
address string account address yes
agentHash string Node HASH Yes
deposit string commission amount yes
password string account password yes

# return value

Field Name Field Type Parameter Description
txHash string Join Consensus Trading Hash

# cs_withdraw

Exit commission transaction /withdraw deposit agent transaction

# scope:public

# version:1.0

# parameter list

Parameter Name Parameter Type Parameter Description Is Not Empty
chainId int chain id yes
address string account address yes
txHash string Join the consensus transaction HASH Yes
password string account password yes

# return value

Field Name Field Type Parameter Description
txHash string Exit Consensus Trading Hash
Last Updated: 9/5/2019, 4:50:57 PM