xuperchain

xuperunion/pb at master · xuperchain/xuperunion

TOC

Create Google Protocol Buffers docs

git clone https://github.com/xuperchain/xuperunion.git /tmp/src/xuperunion
bash tc.sh --gen-proto-doc /tmp/src/xuperunion/pb /tmp/output.md

Generated Date:2019-09-12T15:04:36+08:00

Protocol Documentation

Table of Contents

Top

chainedbft.proto

ChainedBftPhaseMessage

ChainedBftPhaseMessage is the proposal message of the protocal. In Hotstuff, there are two kinds of messages, "NEW_VIEW_MESSAGE" and "QC_Message". A stable leader can skip this "NEW_VIEW_MESSAGE".

FieldTypeLabelDescription
TypeQCStateMessage Type: NEW_VIEW_MESSAGE or QC_MESSAGE
ViewNumberint64ViewNumber the current view number
ProposalQCQuorumCertThe new proposal send to other replicas while the
JustifyQCQuorumCertJustifyQC is the QC of the leader gathered, send to next leader, while the message type is "NEW_VIEW_MESSAGE"
MsgDigestbytesMsgDigest is the digest of the msgg
SignatureSignInfoSignature for this msg

ChainedBftVoteMessage

ChainedBftVoteMessage is the vote message of the protocal.

FieldTypeLabelDescription
ProposalIdbytesThe id of this message votes for.
SignatureSignInfoReplica will sign the QCMessage if the QuorumCert if valid.

QCSignInfos

QCSignInfos is the signs of the leader gathered from replicas of a specifically certType. A slice of signs is used at present. TODO @qizheng09: It will be change to Threshold-Signatures after Crypto lib support Threshold-Signatures.

FieldTypeLabelDescription
QCSignInfosSignInforepeatedQCSignInfos

QuorumCert

QuorumCert is a data type that combines a collection of signatures from replicas.

FieldTypeLabelDescription
ProposalIdbytesThe id of Proposal this QC certified.
ProposalMsgbytesThe msg of Proposal this QC certified.
TypeQCStateThe current type of this QC certified. the type contains NEW_VIEW, PREPARE
ViewNumberint64The view number of this QC certified.
SignInfosQCSignInfosSignInfos is the signs of the leader gathered from replicas of a specifically certType.

SignInfo

SignInfo is the signature information of the

FieldTypeLabelDescription
Addressstring
PublicKeystring
Signbytes

QCState

QCState is the phase of hotstuff

NameNumberDescription
NEW_VIEW0
PREPARE1
PRE_COMMIT2
COMMIT3
DECIDE4

Top

xcheck.proto

ComplianceCheckResponse

FieldTypeLabelDescription
headerHeader
signatureSignatureInfo

TransferCheckResponse

FieldTypeLabelDescription
headerHeader
signatureSignatureInfo

Xcheck

Method NameRequest TypeResponse TypeDescription
ComplianceCheckTxStatusComplianceCheckResponse
TransferCheckTxStatusTransferCheckResponse

Top

xchain_spv.proto

ECDSAAccount

助记词、私钥的json、公钥的json、钱包地址

FieldTypeLabelDescription
entropyBytebytes
mnemonicstring
jsonPrivateKeystring
jsonPublicKeystring
addressstring

ECDSAAccountFromCloud

钱包地址、被加密后的私钥、被加密后的助记词

FieldTypeLabelDescription
addressstring
jsonEncryptedPrivateKeystring
encryptedMnemonicstring

ECDSAAccountToCloud

钱包地址、被加密后的私钥、被加密后的助记词、支付密码的明文

FieldTypeLabelDescription
addressstring
jsonEncryptedPrivateKeystring
encryptedMnemonicstring
passwordstring

ECDSAInfo

助记词、随机字节数组、钱包地址

FieldTypeLabelDescription
entropyBytebytes
mnemonicstring
addressstring

Node

全节点

FieldTypeLabelDescription
hostbytes
utxoQueryUrlbytes
txPostUrlbytes
balanceQueryUrlbytes

TxInputs

交易输入列表

FieldTypeLabelDescription
txInputListTxInputrepeated

TxOutputs

交易输出列表

FieldTypeLabelDescription
txOutputListTxOutputrepeated

UTXO

未花费的交易输出

FieldTypeLabelDescription
amountbytes
toAddrbytes
toPubkeybytes
refTxidbytes
refOffsetint32

UTXOs

未花费的交易输出列表

FieldTypeLabelDescription
uTXOListUTXOrepeated

ReturnCode

ReturnCode is the code for client

NameNumberDescription
RETURNSUCCESS0Operation success
INTERNALERR101000Err about Account
FILENOTEXIST101002
PARAMERR101003
HTTPREQUERTFAIL101004
HTTPRESPONSEFAIL101005
ACCOUNTNOTEXIST101008
PWNOTEXIST101009
PWEXIST101010
NOTLOGIN101012
CONNECTNODEFAIL102001Err about Transaction
UTXONOTENOUGH102002
ADDRESSINVALID102003
FEEINVALID102004
CONNECTREFUSED102005
UTXOENCRYPTERR102006
FEENOTENOUGN102007
PARAMSINVALID102008
TXSIGNERR102009
REPOSTTXERR102010
BLOCKCHAINNOTEXIST102011
SERVERERR102012

Top

xchain.proto

AK2AccountRequest

FieldTypeLabelDescription
headerHeader
bcnamestring
addressstring

AK2AccountResponse

FieldTypeLabelDescription
headerHeader
bcnamestring
accountstringrepeated

Acl

Acl实际使用的结构

FieldTypeLabelDescription
pmPermissionModel采用的权限模型
aksWeightAcl.AksWeightEntryrepeated公钥or账户名 -> 权重
akSetsAkSets

Acl.AksWeightEntry

FieldTypeLabelDescription
keystring
valuedouble

AclStatus

查询Acl

FieldTypeLabelDescription
headerHeader
bcnamestring
accountNamestring
contractNamestring
methodNamestring
confirmedbool
aclAcl

AddressBalanceStatus

FieldTypeLabelDescription
headerHeader
addressstring
tfdsTokenFrozenDetailsrepeated

AddressStatus

FieldTypeLabelDescription
headerHeader
addressstring
bcsTokenDetailrepeated

AkSet

AK集的表示方法

FieldTypeLabelDescription
aksstringrepeated一堆公钥

AkSets

FieldTypeLabelDescription
setsAkSets.SetsEntryrepeated公钥or账户名集
expressionstring表达式,一期不支持表达式,默认集合内是and,集合间是or

AkSets.SetsEntry

FieldTypeLabelDescription
keystring
valueAkSet

BCSpeeds

FieldTypeLabelDescription
BcSpeedBCSpeeds.BcSpeedEntryrepeated

BCSpeeds.BcSpeedEntry

FieldTypeLabelDescription
keystring
valuedouble

BCStatus

BlockChain status

FieldTypeLabelDescription
headerHeader
bcnamestringblock name
metaLedgerMetaledger metadata
blockInternalBlockThe information of the longest block
utxoMetaUtxoMetaUtox information

BCTipStatus

FieldTypeLabelDescription
headerHeader
is_trunk_tipbool

BatchTxs

FieldTypeLabelDescription
headerHeader
TxsTxStatusrepeated

Block

FieldTypeLabelDescription
headerHeader
bcnamestring
blockidbytes
statusBlock.EBlockStatus
blockInternalBlock

BlockChains

FieldTypeLabelDescription
headerHeader
blockchainsstringrepeated

BlockHeight

FieldTypeLabelDescription
headerHeader
bcnamestring
heightint64

BlockID

FieldTypeLabelDescription
headerHeader
bcnamestring
blockidbytes
need_contentboolif need content

是否需要内容 |

CommonIn

FieldTypeLabelDescription
headerHeader

CommonReply

FieldTypeLabelDescription
headerHeader

ContractResponse

ContractResponse is the response returnd by contract

FieldTypeLabelDescription
statusint32
messagestring
bodybytes

ContractStatus

Status of a contract

FieldTypeLabelDescription
contract_namestring
txidstring
descbytes
is_bannedbool

DeployNativeCodeRequest

FieldTypeLabelDescription
headerHeader
bcnamestringchain name
descNativeCodeDescnative code desc
codebytescode is the bytes of binary code
addressstringthe address of deployer
pubkeybytesthe public key of deployer
signbytesthe sign of desc

DeployNativeCodeResponse

FieldTypeLabelDescription
headerHeader

DposCandidatesRequest

候选人列表接口

FieldTypeLabelDescription
headerHeader
bcnamestring

DposCandidatesResponse

候选人列表返回

FieldTypeLabelDescription
headerHeader
candidatesInfostringrepeated

DposCheckResultsRequest

查询检票结果记录请求

FieldTypeLabelDescription
headerHeader
bcnamestring
termint64

DposCheckResultsResponse

查询检票结果记录返回

FieldTypeLabelDescription
headerHeader
termint64
checkResultstringrepeated

DposNominateInfo

候选人信息

FieldTypeLabelDescription
candidatestring
txidstring

DposNominateRecordsRequest

提名者提名记录请求

FieldTypeLabelDescription
headerHeader
bcnamestring
addressstring

DposNominateRecordsResponse

提名者提名记录返回

FieldTypeLabelDescription
headerHeader
nominateRecordsDposNominateInforepeated

DposNomineeRecordsRequest

候选人被提名记录请求

FieldTypeLabelDescription
headerHeader
bcnamestring
addressstring

DposNomineeRecordsResponse

候选人被提名记录返回

FieldTypeLabelDescription
headerHeader
txidstring

DposStatus

FieldTypeLabelDescription
termint64
block_numint64
proposerstring
proposer_numint64
checkResultstringrepeated

DposStatusRequest

query dpos consensus current status request

FieldTypeLabelDescription
headerHeader
bcnamestring

DposStatusResponse

query dpos consensus current status reply

FieldTypeLabelDescription
headerHeader
statusDposStatus

DposVoteRecordsRequest

选民投票记录请求

FieldTypeLabelDescription
headerHeader
bcnamestring
addressstring

DposVoteRecordsResponse

选民投票记录返回

FieldTypeLabelDescription
headerHeader
voteTxidRecordsvoteRecordrepeated选民投票txid记录

DposVotedRecordsRequest

候选人被投票记录请求

FieldTypeLabelDescription
headerHeader
bcnamestring
addressstring

DposVotedRecordsResponse

候选人被投票记录返回

FieldTypeLabelDescription
headerHeader
votedTxidRecordsvotedRecordrepeated候选人被投票的txid记录

GetAccountContractsRequest

Query account contracts request

FieldTypeLabelDescription
headerHeader
bcnamestring
accountstring

GetAccountContractsResponse

Query account contracts response

FieldTypeLabelDescription
headerHeader
contracts_statusContractStatusrepeated

Header

FieldTypeLabelDescription
logidstring如果logid没填写,生成一个
from_nodestringcall rpc client address,客户端可以为空,节点一定要写自己的address
errorXChainErrorEnum

IdentityAuth

Identity authentication request

FieldTypeLabelDescription
signbytes
pubkeybytes
addrstring
peerIDstring
timestampstring

IdentityAuths

Identity authentication requests

FieldTypeLabelDescription
authIdentityAuthrepeated

InternalBlock

The internal block struct

FieldTypeLabelDescription
versionint32block version
nonceint32Random number used to avoid replay attacks
blockidbytesblockid generate the hash sign of the block used by sha256
pre_hashbytespre_hash is the parent blockid of the block
proposerbytesThe miner id
signbytesThe sign which miner signed: blockid + nonce + timestamp
pubkeybytesThe pk of the miner
merkle_rootbytesThe Merkle Tree root
heightint64The height of the blockchain
timestampint64Timestamp of the block
transactionsTransactionrepeatedTransactions of the block, only txid stored on kv, the detail information stored in another table
tx_countint32The transaction count of the block
merkle_treebytesrepeated所有交易hash的merkle tree
curTermint64
curBlockNumint64
failed_txsInternalBlock.FailedTxsEntryrepeatedtxid -> failed reason
targetBitsint32
JustifyQuorumCertJustify used in chained-bft
in_trunkbool下面的属性会动态变化 If the block is on the trunk
next_hashbytesNext next block which on trunk

InternalBlock.FailedTxsEntry

FieldTypeLabelDescription
keystring
valuestring

InvokeRPCRequest

FieldTypeLabelDescription
headerHeader
bcnamestring
requestsInvokeRequestrepeated
initiatorstring
auth_requirestringrepeated

InvokeRPCResponse

FieldTypeLabelDescription
headerHeader
bcnamestring
responseInvokeResponse

InvokeRequest

预执行的请求结构

FieldTypeLabelDescription
module_namestring
contract_namestring
method_namestring
argsInvokeRequest.ArgsEntryrepeated
resource_limitsResourceLimitrepeated

InvokeRequest.ArgsEntry

FieldTypeLabelDescription
keystring
valuebytes

InvokeResponse

预执行的返回结构

FieldTypeLabelDescription
inputsTxInputExtrepeated
outputsTxOutputExtrepeated
responsebytesrepeated
gas_usedint64
requestsInvokeRequestrepeated
responsesContractResponserepeated

LedgerMeta

Ledger metadata

FieldTypeLabelDescription
root_blockidbytesroot block id
tip_blockidbytestip block id
trunk_heightint64the height of the trunk
max_block_sizeint64max block size
reserved_contractsInvokeRequestrepeatedpreset contracts
forbidden_contractInvokeRequestreset forbidden contract configuration

NativeCodeDesc

FieldTypeLabelDescription
namestringnative code name
versionstringcode version
digestbytesdigest of binary
prevVersionstringthe previous verion
xuperApiVersionint32xuper api version

NativeCodeStatus

FieldTypeLabelDescription
descNativeCodeDesc
statusint32
healthybool

NativeCodeStatusRequest

FieldTypeLabelDescription
headerHeader
bcnamestring

NativeCodeStatusResponse

FieldTypeLabelDescription
headerHeader
statusNativeCodeStatusrepeated

PermissionModel

FieldTypeLabelDescription
rulePermissionRule
acceptValuedouble取决于用哪种rule, 可以表示签名率,签名数或权重阈值

PreExecWithSelectUTXORequest

PreExecWithSelectUTXORequest preExec + selectUtxo for request

FieldTypeLabelDescription
headerHeader
bcnamestring
addressstring
totalAmountint64
signInfoSignatureInfo
needLockbool
requestInvokeRPCRequest

PreExecWithSelectUTXOResponse

PreExecWithSelectUTXOResponse preExec + selectUtxo for response

FieldTypeLabelDescription
headerHeader
bcnamestring
responseInvokeResponse
utxoOutputUtxoOutputfor preExec & selectUTXO

RawUrl

RawUrl return the node's connect url

FieldTypeLabelDescription
headerHeader
rawUrlstring

ResourceLimit

FieldTypeLabelDescription
typeResourceType
limitint64

SignatureInfo

签名详情

FieldTypeLabelDescription
PublicKeystring
Signbytes

Speeds

FieldTypeLabelDescription
SumSpeedsSpeeds.SumSpeedsEntryrepeated
BcSpeedsSpeeds.BcSpeedsEntryrepeated

Speeds.BcSpeedsEntry

FieldTypeLabelDescription
keystring
valueBCSpeeds

Speeds.SumSpeedsEntry

FieldTypeLabelDescription
keystring
valuedouble

SystemsStatus

FieldTypeLabelDescription
headerHeader
bcs_statusBCStatusrepeated
speedsSpeeds
peerUrlsstringrepeated

SystemsStatusReply

FieldTypeLabelDescription
headerHeader
systems_statusSystemsStatus

TokenDetail

FieldTypeLabelDescription
bcnamestring
balancestring
errorXChainErrorEnum

TokenFrozenDetail

FieldTypeLabelDescription
balancestring
isFrozenbool

TokenFrozenDetails

FieldTypeLabelDescription
bcnamestring
tfdTokenFrozenDetailrepeated
errorXChainErrorEnum

Transaction

Transaction is the information of the transaction

FieldTypeLabelDescription
txidbytestxid is the id of this transaction
blockidbytesthe blockid the transaction belong to
tx_inputsTxInputrepeatedTransaction input list
tx_outputsTxOutputrepeatedTransaction output list
descbytesTransaction description or system contract
coinbaseboolMining rewards
noncestringRandom number used to avoid replay attacks
timestampint64Timestamp to launch the transaction
versionint32tx format version; tx格式版本号
autogenboolauto generated tx
tx_inputs_extTxInputExtrepeated
tx_outputs_extTxOutputExtrepeated
contract_requestsInvokeRequestrepeated
initiatorstring权限系统新增字段 交易发起者, 可以是一个Address或者一个Account
auth_requirestringrepeated交易发起需要被收集签名的AddressURL集合信息,包括用于utxo转账和用于合约调用
initiator_signsSignatureInforepeated交易发起者对交易元数据签名,签名的内容包括auth_require字段
auth_require_signsSignatureInforepeated收集到的签名
received_timestampint64节点收到tx的时间戳,不参与签名
xuper_signXuperSignature统一签名(支持多重签名/环签名等,与initiator_signs/auth_require_signs不同时使用)

TxData

FieldTypeLabelDescription
headerHeader
txidbytesTransaction id
bcnamestringBlock name
from_addrstringAccount which start the transaction
from_pubkeystringThe pk of the account which start the transaction
from_scrkeystringThe sk of the account which start the transaction
user_signbytesif user don't want to provide scrkey, he should sign the txdata into user_sign
accountTxDataAccountrepeatedThe account list accept tx
noncestringRandom number used to avoid replay attacks
timestampint64Timestamp to launch the Tx
descbytes
versionint32tx version

TxDataAccount

FieldTypeLabelDescription
addressstring地址
amountstring金额
frozen_heightint64冻结高度

TxInput

Transaction input

FieldTypeLabelDescription
ref_txidbytesThe transaction id referenced to
ref_offsetint32The output offset of the transaction referenced to
from_addrbytesThe address of the launcher
amountbytesThe amount of the transaction
frozen_heightint64Frozen height

TxInputExt

扩展输入

FieldTypeLabelDescription
bucketstring
keybytes
ref_txidbytes
ref_offsetint32

TxOutput

Transaction output

FieldTypeLabelDescription
amountbytesThe amount of the transaction
to_addrbytesThe address of the launcher
frozen_heightint64Fronzen height

TxOutputExt

扩展输出

FieldTypeLabelDescription
bucketstring
keybytes
valuebytes

TxStatus

FieldTypeLabelDescription
headerHeader
bcnamestring
txidbytes
statusTransactionStatus当前状态
distanceint64离主干末端的距离(如果在主干上)
txTransaction

Utxo

FieldTypeLabelDescription
amountbytes
toAddrbytes
toPubkeybytes
refTxidbytes
refOffsetint32

UtxoInput

UtxoInput query info to query utxos

FieldTypeLabelDescription
headerHeader
bcnamestringwhich bcname to select
addressstringaddress to select
publickeystringpublickey of the address
totalNeedstringtotalNeed refer the total need utxos to select
userSignbytesuserSign of input
needLockboolneed lock

UtxoMeta

Utxo metadata

FieldTypeLabelDescription
latest_blockidbytesutxo vm目前执行到的blockid
lock_key_liststringrepeated
utxo_totalstring当前utxo vm上的总资产
avgDelayint64平均上链延时
unconfirmTxAmountint64待确认交易量

UtxoOutput

UtxoOutput query results

FieldTypeLabelDescription
headerHeader
utxoListUtxorepeatedoutSign return the output bytes outSign = 2; utxo list
totalSelectedstringtotal selected amount

WasmCodeDesc

FieldTypeLabelDescription
runtimestring
compilerstring
digestbytes
vm_compilerstring

XuperSignature

Unified Xuper Signature

FieldTypeLabelDescription
public_keysbytesrepeated
signaturebytes

voteRecord

选民投票记录

FieldTypeLabelDescription
candidatestring
txidstring

votedRecord

候选人被投票记录

FieldTypeLabelDescription
voterstring
txidstring

Block.EBlockStatus

NameNumberDescription
ERROR0
TRUNK1
BRANCH2
NOEXIST3

PermissionRule

-------- Account and Permission Section --------

NameNumberDescription
NULL0无权限控制
SIGN_THRESHOLD1签名阈值策略
SIGN_AKSET2AKSet签名策略
SIGN_RATE3签名率策略
SIGN_SUM4签名个数策略
CA_SERVER5CA服务器鉴权
COMMUNITY_VOTE6社区治理

ResourceType

NameNumberDescription
CPU0
MEMORY1
DISK2
XFEE3the fee used in kernel contract

TransactionStatus

TransactionStatus is the status of transaction

NameNumberDescription
UNDEFINE0Undefined status
NOEXIST1Transaction not exist
CONFIRM2Transaction have been confirmed
FURCATION3Transaction is on the furcation
UNCONFIRM4Transaction have not been confirmed

XChainErrorEnum

NameNumberDescription
SUCCESS0
UNKNOW_ERROR1
CONNECT_REFUSE2
NOT_ENOUGH_UTXO_ERROR3
UTXOVM_ALREADY_UNCONFIRM_ERROR4
UTXOVM_NOT_FOUND_ERROR5
INPUT_OUTPUT_NOT_EQUAL_ERROR6
TX_NOT_FOUND_ERROR7
TX_SIGN_ERROR8
BLOCKCHAIN_NOTEXIST9
VALIDATE_ERROR10
CANNOT_SYNC_BLOCK_ERROR11
CONFIRM_BLOCK_ERROR12
UTXOVM_PLAY_ERROR13
WALK_ERROR14
NOT_READY_ERROR15
BLOCK_EXIST_ERROR16
ROOT_BLOCK_EXIST_ERROR17
TX_DUPLICATE_ERROR19
SERVICE_REFUSED_ERROR20
TXDATA_SIGN_ERROR21
TX_SLE_ERROR25
TX_FEE_NOT_ENOUGH_ERROR26
UTXO_SIGN_ERROR28
DPOS_QUERY_ERROR31
RWSET_INVALID_ERROR33
RWACL_INVALID_ERROR34
GAS_NOT_ENOUGH_ERROR35
TX_VERSION_INVALID_ERROR36
COMPLIANCE_CHECK_NOT_APPROVED37
ACCOUNT_CONTRACT_STATUS_ERROR38
TX_VERIFICATION_ERROR40

Xchain

Xchain is the main interfaces

Method NameRequest TypeResponse TypeDescription
PostTxTxStatusCommonReplyPostTx post Transaction to a node
QueryACLAclStatusAclStatus
GetAccountContractsGetAccountContractsRequestGetAccountContractsResponse
QueryTxTxStatusTxStatusQueryTx query Transaction by TxStatus, Bcname and Txid are required for this
GetBalanceAddressStatusAddressStatusGetBalance get balance of an address, Address is required for this
GetBalanceDetailAddressBalanceStatusAddressBalanceStatusGetFrozenBalance get two kinds of balance 1. Still be frozen of an address 2. Available now of an address Address is required for this
GetFrozenBalanceAddressStatusAddressStatusGetFrozenBalance get balance that still be frozen of an address, Address is required for this
GetBlockBlockIDBlockGetBlock get block by blockid and return if the block in trunk or in branch
GetBlockByHeightBlockHeightBlockGetBlockByHeight get block by height and return if the block in trunk or in branch
GetBlockChainStatusBCStatusBCStatus
GetBlockChainsCommonInBlockChainsGet blockchains query blockchains
GetSystemStatusCommonInSystemsStatusReplyGetSystemStatus query system status
GetNetURLCommonInRawUrlGetNetURL return net url
SelectUTXOUtxoInputUtxoOutput新的Select utxos接口, 不需要签名,可以支持选择账户的utxo
PreExecWithSelectUTXOPreExecWithSelectUTXORequestPreExecWithSelectUTXOResponsePreExecWithSelectUTXO preExec & selectUtxo
DeployNativeCodeDeployNativeCodeRequestDeployNativeCodeResponseNative code deploy interface
NativeCodeStatusNativeCodeStatusRequestNativeCodeStatusResponseNative code status
DposCandidatesDposCandidatesRequestDposCandidatesResponseDposCandidates get all candidates of the tdpos consensus
DposNominateRecordsDposNominateRecordsRequestDposNominateRecordsResponseDposNominateRecords get all records nominated by an user
DposNomineeRecordsDposNomineeRecordsRequestDposNomineeRecordsResponseDposNomineeRecords get nominated record of a candidate
DposVoteRecordsDposVoteRecordsRequestDposVoteRecordsResponseDposVoteRecords get all vote records voted by an user
DposVotedRecordsDposVotedRecordsRequestDposVotedRecordsResponseDposVotedRecords get all vote records of a candidate
DposCheckResultsDposCheckResultsRequestDposCheckResultsResponseDposCheckResults get check results of a specific term
DposStatusDposStatusRequestDposStatusResponseDposStatus get dpos status
GetAccountByAKAK2AccountRequestAK2AccountResponseGetAccountByAK get account sets contain a specific address
PreExecInvokeRPCRequestInvokeRPCResponse预执行合约

Scalar Value Types

.proto TypeNotesC++ TypeJava TypePython Type
doubledoubledoublefloat
floatfloatfloatfloat
int32Uses variable-length encoding. Inefficient for encoding negative numbers – if your field is likely to have negative values, use sint32 instead.int32intint
int64Uses variable-length encoding. Inefficient for encoding negative numbers – if your field is likely to have negative values, use sint64 instead.int64longint/long
uint32Uses variable-length encoding.uint32intint/long
uint64Uses variable-length encoding.uint64longint/long
sint32Uses variable-length encoding. Signed int value. These more efficiently encode negative numbers than regular int32s.int32intint
sint64Uses variable-length encoding. Signed int value. These more efficiently encode negative numbers than regular int64s.int64longint/long
fixed32Always four bytes. More efficient than uint32 if values are often greater than 2^28.uint32intint
fixed64Always eight bytes. More efficient than uint64 if values are often greater than 2^56.uint64longint/long
sfixed32Always four bytes.int32intint
sfixed64Always eight bytes.int64longint/long
boolboolbooleanboolean
stringA string must always contain UTF-8 encoded or 7-bit ASCII text.stringStringstr/unicode
bytesMay contain any arbitrary sequence of bytes.stringByteStringstr

Protos File Tree


.
├── chainedbft.proto
├── googleapis
│   └── google
│       └── api
│           ├── annotations.proto
│           └── http.proto
├── xchain.proto
├── xchain_spv.proto
└── xcheck.proto

3 directories, 6 files

Protobuf sources

src:./chainedbft.proto


syntax = "proto3";

package pb;

// QCState is the phase of hotstuff
enum QCState {
    NEW_VIEW = 0; 
    PREPARE = 1;
    PRE_COMMIT = 2;
    COMMIT = 3;
    DECIDE = 4;
}

// QuorumCert is a data type that combines a collection of signatures from replicas.
message QuorumCert {
    // The id of Proposal this QC certified.
    bytes ProposalId = 1;
    // The msg of Proposal this QC certified. 
    bytes ProposalMsg = 2;
    // The current type of this QC certified.
    // the type contains `NEW_VIEW`, `PREPARE`
	QCState Type = 3;
	// The view number of this QC certified.
	int64 ViewNumber = 4;
	// SignInfos is the signs of the leader gathered from replicas
    // of a specifically certType.
    QCSignInfos SignInfos  = 5;
}

// QCSignInfos is the signs of the leader gathered from replicas of a specifically certType.
// A slice of signs is used at present.
// TODO @qizheng09: It will be change to Threshold-Signatures after 
// Crypto lib support Threshold-Signatures.
message QCSignInfos {
    // QCSignInfos 
   repeated SignInfo QCSignInfos = 1; 
}

// SignInfo is the signature information of the 
message SignInfo {
  string Address = 1;
  string PublicKey = 2;
  bytes  Sign = 3;
}

// ChainedBftPhaseMessage is the proposal message of the protocal.
// In Hotstuff, there are two kinds of messages, "NEW_VIEW_MESSAGE" and "QC_Message".
// A stable leader can skip this "NEW_VIEW_MESSAGE".
message ChainedBftPhaseMessage {
    // Message Type: NEW_VIEW_MESSAGE or QC_MESSAGE
    QCState Type = 1;
    // ViewNumber the current view number 
    int64 ViewNumber = 2;
    // The new proposal send to other replicas while the 
	QuorumCert ProposalQC = 3;
    // JustifyQC is the QC of the leader gathered, send to next leader, while the message type is "NEW_VIEW_MESSAGE"
    QuorumCert JustifyQC = 4;
    // MsgDigest is the digest of the msgg
    bytes MsgDigest = 5;
    // Signature for this msg
    SignInfo Signature = 6;
}

// ChainedBftVoteMessage is the vote message of the protocal.
message ChainedBftVoteMessage {
    // The id of this message votes for.
    bytes ProposalId = 1;
    // Replica will sign the QCMessage if the QuorumCert if valid.
    SignInfo Signature = 2;
}

src:./xcheck.proto


syntax = "proto3";

package pb;

import "google/api/annotations.proto";
import "xchain.proto";

service Xcheck {
    rpc ComplianceCheck(TxStatus) returns (ComplianceCheckResponse);
    rpc TransferCheck(TxStatus) returns (TransferCheckResponse);
}

message ComplianceCheckResponse {
    Header header = 1;
    SignatureInfo signature = 2;
}

message TransferCheckResponse {
    Header header = 1;
    SignatureInfo signature = 2;
}

src:./xchain_spv.proto


syntax = "proto3";

package pb;

import "google/api/annotations.proto";
import "xchain.proto";

// 助记词、私钥的json、公钥的json、钱包地址
message ECDSAAccount
{
    bytes entropyByte = 1;
    string mnemonic = 2;
    string jsonPrivateKey = 3;
    string jsonPublicKey = 4;
    string address = 5;
}

// 助记词、随机字节数组、钱包地址
message ECDSAInfo
{
    bytes entropyByte = 1;
    string mnemonic = 2;
    string address = 3;
}

// 钱包地址、被加密后的私钥、被加密后的助记词
message ECDSAAccountFromCloud
{
    string address = 1;
    string jsonEncryptedPrivateKey = 2;
    string encryptedMnemonic = 3;
}

// 钱包地址、被加密后的私钥、被加密后的助记词、支付密码的明文
message ECDSAAccountToCloud
{
    string address = 1;
    string jsonEncryptedPrivateKey = 2;
    string encryptedMnemonic = 3;
    string password = 4;
}

// 全节点
message Node
{
    bytes host = 1;
    bytes utxoQueryUrl = 2;
    bytes txPostUrl = 3;
    bytes balanceQueryUrl = 4;
}

// 交易输入列表
message TxInputs
{
    repeated TxInput txInputList = 1;
}
// 交易输出列表
message TxOutputs
{
    repeated TxOutput txOutputList = 1;
}


// 未花费的交易输出列表
message UTXOs
{
    repeated UTXO uTXOList = 1;
}
// 未花费的交易输出
message UTXO
{
    bytes amount = 1;
    bytes toAddr = 2;
    bytes toPubkey = 3;
    bytes refTxid = 4;
    int32 refOffset = 5;
}

// ReturnCode is the code for client
enum ReturnCode {
    // Operation success
       RETURNSUCCESS = 0;
    // Err about Account
       INTERNALERR = 101000;
       FILENOTEXIST = 101002;
       PARAMERR = 101003;
       HTTPREQUERTFAIL = 101004;
       HTTPRESPONSEFAIL = 101005;
       ACCOUNTNOTEXIST = 101008;
       PWNOTEXIST = 101009;
       PWEXIST = 101010;
       NOTLOGIN = 101012;
    // Err about Transaction
       CONNECTNODEFAIL = 102001;
       UTXONOTENOUGH = 102002;
       ADDRESSINVALID = 102003;
       FEEINVALID = 102004;
       CONNECTREFUSED = 102005;
       UTXOENCRYPTERR = 102006;
       FEENOTENOUGN = 102007;
       PARAMSINVALID = 102008;
       TXSIGNERR = 102009;
       REPOSTTXERR = 102010;
       BLOCKCHAINNOTEXIST = 102011;
       SERVERERR = 102012;
    }

src:./xchain.proto


syntax = "proto3";
 
import "google/api/annotations.proto";
import "chainedbft.proto";
package pb;


enum XChainErrorEnum {
  SUCCESS = 0;
  UNKNOW_ERROR = 1;
  CONNECT_REFUSE = 2;
  NOT_ENOUGH_UTXO_ERROR = 3;
  UTXOVM_ALREADY_UNCONFIRM_ERROR = 4;
  UTXOVM_NOT_FOUND_ERROR = 5;
  INPUT_OUTPUT_NOT_EQUAL_ERROR = 6;
  TX_NOT_FOUND_ERROR = 7;
  TX_SIGN_ERROR = 8;
  BLOCKCHAIN_NOTEXIST = 9;
  VALIDATE_ERROR = 10;
  CANNOT_SYNC_BLOCK_ERROR = 11;
  CONFIRM_BLOCK_ERROR = 12;
  UTXOVM_PLAY_ERROR = 13;
  WALK_ERROR = 14;
  NOT_READY_ERROR = 15;
  BLOCK_EXIST_ERROR = 16;
  ROOT_BLOCK_EXIST_ERROR = 17;
  TX_DUPLICATE_ERROR = 19;
  SERVICE_REFUSED_ERROR = 20;
  TXDATA_SIGN_ERROR = 21;
  TX_SLE_ERROR = 25;
  TX_FEE_NOT_ENOUGH_ERROR = 26;
  UTXO_SIGN_ERROR = 28;
  DPOS_QUERY_ERROR = 31;
  RWSET_INVALID_ERROR = 33;
  RWACL_INVALID_ERROR = 34;
  GAS_NOT_ENOUGH_ERROR = 35;
  TX_VERSION_INVALID_ERROR = 36;
  COMPLIANCE_CHECK_NOT_APPROVED = 37;
  ACCOUNT_CONTRACT_STATUS_ERROR = 38;
  TX_VERIFICATION_ERROR = 40;
}

// TransactionStatus is the status of transaction
enum TransactionStatus {
  // Undefined status
  UNDEFINE = 0;
  // Transaction not exist
  NOEXIST = 1;
  // Transaction have been confirmed
  CONFIRM = 2;
  // Transaction is on the furcation
  FURCATION = 3;
  // Transaction have not been confirmed
  UNCONFIRM = 4;
}

// Xchain is the main interfaces
service Xchain {

  // PostTx post Transaction to a node
  rpc PostTx(TxStatus) returns (CommonReply) {
    option (google.api.http) = {
      post : "/v1/post_tx"
      body : "*"
    };
  }

  rpc QueryACL(AclStatus) returns (AclStatus) {
    option (google.api.http) = {
      post : "/v1/query_acl"
      body : "*"
    };
  }

  rpc GetAccountContracts(GetAccountContractsRequest)
      returns (GetAccountContractsResponse) {
    option (google.api.http) = {
      post : "/v1/get_account_contracts"
      body : "*"
    };
  }

  // QueryTx query Transaction by TxStatus,
  // Bcname and Txid are required for this
  rpc QueryTx(TxStatus) returns (TxStatus) {
    option (google.api.http) = {
      post : "/v1/query_tx"
      body : "*"
    };
  }

  // GetBalance get balance of an address,
  // Address is required for this
  rpc GetBalance(AddressStatus) returns (AddressStatus) {
    option (google.api.http) = {
      post : "/v1/get_balance"
      body : "*"
    };
  }
  
  // GetFrozenBalance get two kinds of balance
  // 1. Still be frozen of an address
  // 2. Available now of an address
  // Address is required for this
  rpc GetBalanceDetail(AddressBalanceStatus) returns (AddressBalanceStatus) {
  option (google.api.http) = {
    post: "/v1/get_balance_detail"
    body: "*"
    };
  }

  // GetFrozenBalance get balance that still be frozen of an address,
  // Address is required for this
  rpc GetFrozenBalance(AddressStatus) returns (AddressStatus) {
    option (google.api.http) = {
      post : "/v1/get_frozen_balance"
      body : "*"
    };
  }

  // GetBlock get block by blockid and return if the block in trunk or in branch
  rpc GetBlock(BlockID) returns (Block) {
    option (google.api.http) = {
      post : "/v1/get_block"
      body : "*"
    };
  }

  // GetBlockByHeight get block by height and return if the block in trunk or in
  // branch
  rpc GetBlockByHeight(BlockHeight) returns (Block) {
    option (google.api.http) = {
      post : "/v1/get_block_by_height"
      body : "*"
    };
  }

  rpc GetBlockChainStatus(BCStatus) returns (BCStatus) {
    option (google.api.http) = {
      post : "/v1/get_bcstatus"
      body : "*"
    };
  }

  // Get blockchains query blockchains
  rpc GetBlockChains(CommonIn) returns (BlockChains) {
    option (google.api.http) = {
      get : "/v1/get_bcchains"
      // body: "*"
    };
  }

  // GetSystemStatus query system status
  rpc GetSystemStatus(CommonIn) returns (SystemsStatusReply) {
    option (google.api.http) = {
      post : "/v1/get_sysstatus"
      body : "*"
    };
  }

  // GetNetURL return net url
  rpc GetNetURL(CommonIn) returns (RawUrl) {}

  // 新的Select utxos接口, 不需要签名,可以支持选择账户的utxo
  rpc SelectUTXO(UtxoInput) returns (UtxoOutput) {
    option (google.api.http) = {
      post : "/v1/select_utxos_v2"
      body : "*"
    };
  }

  // PreExecWithSelectUTXO preExec & selectUtxo
  rpc PreExecWithSelectUTXO(PreExecWithSelectUTXORequest) returns (PreExecWithSelectUTXOResponse);

  // Native code deploy interface
  rpc DeployNativeCode(DeployNativeCodeRequest)
      returns (DeployNativeCodeResponse);
  // Native code status
  rpc NativeCodeStatus(NativeCodeStatusRequest)
      returns (NativeCodeStatusResponse);

  /*
   * DPoS query interface
   */
  //  DposCandidates get all candidates of the tdpos consensus
  rpc DposCandidates(DposCandidatesRequest) returns (DposCandidatesResponse);
  //  DposNominateRecords get all records nominated by an user
  rpc DposNominateRecords(DposNominateRecordsRequest)
      returns (DposNominateRecordsResponse);
  //  DposNomineeRecords get nominated record of a candidate
  rpc DposNomineeRecords(DposNomineeRecordsRequest)
      returns (DposNomineeRecordsResponse);
  //  DposVoteRecords get all vote records voted by an user
  rpc DposVoteRecords(DposVoteRecordsRequest) returns (DposVoteRecordsResponse);
  //  DposVotedRecords get all vote records of a candidate
  rpc DposVotedRecords(DposVotedRecordsRequest)
      returns (DposVotedRecordsResponse);
  //  DposCheckResults get check results of a specific term
  rpc DposCheckResults(DposCheckResultsRequest)
      returns (DposCheckResultsResponse);

  // DposStatus get dpos status
  rpc DposStatus(DposStatusRequest) returns (DposStatusResponse);

  // GetAccountByAK get account sets contain a specific address
  rpc GetAccountByAK(AK2AccountRequest) returns (AK2AccountResponse) {
    option (google.api.http) = {
      post : "/v1/get_account_by_ak"
      body : "*"
    };
  }

  //预执行合约
  rpc PreExec(InvokeRPCRequest) returns (InvokeRPCResponse);
}

message Header {
  string logid = 1;  //如果logid没填写,生成一个
  string from_node = 2;  //call rpc client address,客户端可以为空,节点一定要写自己的address
  XChainErrorEnum error = 3;
}

message TxDataAccount {
  string address = 1;  //地址
  string amount = 2;  //金额
  int64 frozen_height = 3; //冻结高度
}

message TxData {
  Header header = 13;
  // Transaction id
  bytes txid = 1;
  // Block name
  string bcname = 2;
  // Account which start the transaction
  string from_addr = 3;
  // The pk of the account which start the transaction
  string from_pubkey = 4;
  // The sk of the account which start the transaction
  string from_scrkey = 5;
  // if user don't want to provide scrkey, he should sign the txdata into
  // user_sign
  bytes user_sign = 14;
  // The account list accept tx
  repeated TxDataAccount account = 6;
  // Random number used to avoid replay attacks
  string nonce = 8;
  // Timestamp to launch the Tx
  int64 timestamp = 9;
  bytes desc = 12;
  // tx version
  int32 version = 15;
}

message TxStatus {
  Header header = 1;
  string bcname = 2;
  bytes txid = 3;
  TransactionStatus status = 4;  //当前状态
  int64 distance = 5;  //离主干末端的距离(如果在主干上)
  Transaction tx = 7;
}

message BatchTxs {
  Header header = 1;
  repeated TxStatus Txs = 2;
}

message Block {
  Header header = 1;
  string bcname = 2;
  bytes blockid = 3;
  enum EBlockStatus {
    ERROR = 0;
    TRUNK = 1;
    BRANCH = 2;
    NOEXIST = 3;
  }
  EBlockStatus status = 4;
  InternalBlock block = 5;
}

message BlockID {
  Header header = 4;
  string bcname = 1;
  bytes blockid = 2;
  // if need content
  bool need_content = 3;  //是否需要内容
}

message BlockHeight {
  Header header = 3;
  string bcname = 1;
  int64 height = 2;
}

message CommonReply { Header header = 1; }

message CommonIn { Header header = 1; }

message TokenDetail {
  string bcname = 1;
  string balance = 2;
  XChainErrorEnum error = 3;
}

message AddressStatus {
  Header header = 1;
  string address = 2;
  repeated TokenDetail bcs = 3;
}

message TokenFrozenDetail
{
  string balance = 1;
  bool isFrozen = 2;
}

message TokenFrozenDetails
{
  string bcname = 1;
  repeated TokenFrozenDetail tfd = 2;
  XChainErrorEnum error  = 3;
}

message AddressBalanceStatus
{
  Header header = 1;
  string address = 2;
  repeated TokenFrozenDetails tfds = 3;
}

// Transaction input
message TxInput {
  // The transaction id referenced to
  bytes ref_txid = 1;
  // The output offset of the transaction referenced to
  int32 ref_offset = 2;
  // The address of the launcher
  bytes from_addr = 5;
  // The amount of the transaction
  bytes amount = 6;
  // Frozen height
  int64 frozen_height = 7;
}

// Transaction output
message TxOutput {
  // The amount of the transaction
  bytes amount = 1;
  // The address of the launcher
  bytes to_addr = 2;
  // Fronzen height
  int64 frozen_height = 4;
}

// Unified Xuper Signature
message XuperSignature {
  repeated bytes public_keys = 1;
  bytes signature = 2;
}

// Transaction is the information of the transaction
message Transaction {
  // txid is the id of this transaction
  bytes txid = 1;
  // the blockid the transaction belong to
  bytes blockid = 2;
  // Transaction input list
  repeated TxInput tx_inputs = 3;
  // Transaction output list
  repeated TxOutput tx_outputs = 4;
  // Transaction description or system contract
  bytes desc = 6;
  // Mining rewards
  bool coinbase = 7;
  // Random number used to avoid replay attacks
  string nonce = 8;
  // Timestamp to launch the transaction
  int64 timestamp = 9;
  // tx format version; tx格式版本号
  int32 version = 10;
  // auto generated tx
  bool autogen = 11;

  repeated TxInputExt tx_inputs_ext = 23;
  repeated TxOutputExt tx_outputs_ext = 24;
  repeated InvokeRequest contract_requests = 25;

  // 权限系统新增字段
  // 交易发起者, 可以是一个Address或者一个Account
  string initiator = 26;
  // 交易发起需要被收集签名的AddressURL集合信息,包括用于utxo转账和用于合约调用
  repeated string auth_require = 27;
  // 交易发起者对交易元数据签名,签名的内容包括auth_require字段
  repeated SignatureInfo initiator_signs = 28;
  // 收集到的签名
  repeated SignatureInfo auth_require_signs = 29;
  // 节点收到tx的时间戳,不参与签名
  int64 received_timestamp = 30;
  // 统一签名(支持多重签名/环签名等,与initiator_signs/auth_require_signs不同时使用)
  XuperSignature xuper_sign = 31;
}

// Ledger metadata
message LedgerMeta {
  // root block id
  bytes root_blockid = 1;
  // tip block id
  bytes tip_blockid = 2;
  // the height of the trunk
  int64 trunk_height = 3;
  // max block size
  int64 max_block_size = 4;
  // preset contracts
  repeated InvokeRequest reserved_contracts = 5;
  // reset forbidden contract configuration
  InvokeRequest forbidden_contract = 6;
}

// Utxo metadata
message UtxoMeta {
  bytes latest_blockid = 1; // utxo vm目前执行到的blockid
  repeated string lock_key_list = 2;
  string utxo_total = 3;       // 当前utxo vm上的总资产
  int64 avgDelay = 4;          // 平均上链延时
  int64 unconfirmTxAmount = 5; // 待确认交易量
}

// The internal block struct
message InternalBlock {
  // block version
  int32 version = 1;
  // Random number used to avoid replay attacks
  int32 nonce = 2;
  // blockid generate the hash sign of the block used by sha256
  bytes blockid = 3;
  // pre_hash is the parent blockid of the block
  bytes pre_hash = 4;
  // The miner id
  bytes proposer = 5;
  // The sign which miner signed: blockid + nonce + timestamp
  bytes sign = 6;
  // The pk of the miner
  bytes pubkey = 7;
  // The Merkle Tree root
  bytes merkle_root = 8;
  // The height of the blockchain
  int64 height = 9;
  // Timestamp of the block
  int64 timestamp = 10;
  // Transactions of the block, only txid stored on kv, the detail information
  // stored in another table
  repeated Transaction transactions = 11;
  // The transaction count of the block
  int32 tx_count = 12;
  // 所有交易hash的merkle tree
  repeated bytes merkle_tree = 13;
  int64 curTerm = 16;
  int64 curBlockNum = 17;
  map<string, string> failed_txs = 18; // txid -> failed reason
  int32 targetBits = 19;

  // Justify used in chained-bft
  QuorumCert Justify = 20;
  
  // 下面的属性会动态变化
  // If the block is on the trunk
  bool in_trunk = 14;
  // Next next block which on trunk
  bytes next_hash = 15;
}

// BlockChain status
message BCStatus {
  Header header = 1;
  // block name
  string bcname = 2;
  // ledger metadata
  LedgerMeta meta = 3;
  // The information of the longest block
  InternalBlock block = 4;
  // Utox information
  UtxoMeta utxoMeta = 5;
}

message BCTipStatus {
  Header header = 1;
  bool is_trunk_tip = 2;
}

message BlockChains {
  Header header = 1;
  repeated string blockchains = 2;
}

message Speeds {
  map<string, double> SumSpeeds = 1;
  map<string, BCSpeeds> BcSpeeds = 2;
}

message BCSpeeds { map<string, double> BcSpeed = 1; }

message SystemsStatus {
  Header header = 1;
  repeated BCStatus bcs_status = 2;
  Speeds speeds = 3;
  repeated string peerUrls = 4;
}

message SystemsStatusReply {
  Header header = 1;
  SystemsStatus systems_status = 2;
}

// RawUrl return the node's  connect url
message RawUrl {
  Header header = 1;
  string rawUrl = 2;
}

message Utxo {
  bytes amount = 1;
  bytes toAddr = 2;
  bytes toPubkey = 3;
  bytes refTxid = 4;
  int32 refOffset = 5;
}

// UtxoInput query info to query utxos
message UtxoInput {
  Header header = 1;
  // which bcname to select
  string bcname = 2;
  // address to select
  string address = 3;
  // publickey of the address
  string publickey = 4;
  // totalNeed refer the total need utxos to select
  string totalNeed = 5;
  // userSign of input
  bytes userSign = 7;
  // need lock
  bool needLock = 8;
}

// UtxoOutput query results
message UtxoOutput {
  Header header = 1;
  // outSign return the output
  // bytes outSign = 2;
  // utxo list
  repeated Utxo utxoList = 2;
  // total selected amount
  string totalSelected = 3;
}

message NativeCodeDesc {
  // native code name
  string name = 1;
  // code version
  string version = 2;
  // digest of binary
  bytes digest = 3;
  // the previous verion
  string prevVersion = 4;
  // xuper api version
  int32 xuperApiVersion = 5;
}

message WasmCodeDesc {
  string runtime = 1;
  string compiler = 2;
  bytes digest = 3;
  string vm_compiler = 4;
}

message DeployNativeCodeRequest {
  Header header = 1;
  // chain name
  string bcname = 2;
  // native code desc
  NativeCodeDesc desc = 3;
  // code is the bytes of binary code
  bytes code = 4;
  // the address of deployer
  string address = 5;
  // the public key of deployer
  bytes pubkey = 6;
  // the sign of desc
  bytes sign = 7;
}

message DeployNativeCodeResponse { Header header = 1; }

message NativeCodeStatus {
  NativeCodeDesc desc = 1;
  int32 status = 2;
  bool healthy = 3;
}

message NativeCodeStatusRequest {
  Header header = 1;
  string bcname = 2;
}

message NativeCodeStatusResponse {
  Header header = 1;
  repeated NativeCodeStatus status = 2;
}

/*
 * DPoS query interface
 */
// 候选人列表接口
message DposCandidatesRequest {
  Header header = 1;
  string bcname = 2;
}

// 候选人列表返回
message DposCandidatesResponse {
  Header header = 1;
  repeated string candidatesInfo = 2;
}

// 提名者提名记录请求
message DposNominateRecordsRequest {
  Header header = 1;
  string bcname = 2;
  string address = 3;
}

// 候选人信息
message DposNominateInfo {
  string candidate = 1;
  string txid = 2;
}

// 提名者提名记录返回
message DposNominateRecordsResponse {
  Header header = 1;
  repeated DposNominateInfo nominateRecords = 2;
}

// 候选人被提名记录请求
message DposNomineeRecordsRequest {
  Header header = 1;
  string bcname = 2;
  string address = 3;
}

// 候选人被提名记录返回
message DposNomineeRecordsResponse {
  Header header = 1;
  string txid = 2;
}

// 选民投票记录请求
message DposVoteRecordsRequest {
  Header header = 1;
  string bcname = 2;
  string address = 3;
}

// 选民投票记录
message voteRecord {
  string candidate = 1;
  string txid = 2;
}

// 选民投票记录返回
message DposVoteRecordsResponse {
  Header header = 1;
  // 选民投票txid记录
  repeated voteRecord voteTxidRecords = 2;
}

// 候选人被投票记录请求
message DposVotedRecordsRequest {
  Header header = 1;
  string bcname = 2;
  string address = 3;
}
// 候选人被投票记录
message votedRecord {
  string voter = 1;
  string txid = 2;
}

// 候选人被投票记录返回
message DposVotedRecordsResponse {
  Header header = 1;
  // 候选人被投票的txid记录
  repeated votedRecord votedTxidRecords = 2;
}

// 查询检票结果记录请求
message DposCheckResultsRequest {
  Header header = 1;
  string bcname = 2;
  int64 term = 3;
}

// 查询检票结果记录返回
message DposCheckResultsResponse {
  Header header = 1;
  int64 term = 2;
  repeated string checkResult = 3;
}

// query dpos consensus current status request
message DposStatusRequest {
  Header header = 1;
  string bcname = 2;
}

// query dpos consensus current status reply
message DposStatusResponse {
  Header header = 1;
  DposStatus status = 2;
}

message DposStatus {
  int64 term = 1;
  int64 block_num = 2;
  string proposer = 3;
  int64 proposer_num = 4;
  repeated string checkResult = 5;
}

message InvokeRPCRequest {
  Header header = 1;
  string bcname = 2;
  repeated InvokeRequest requests = 3;
  string initiator = 4;
  repeated string auth_require = 5;
}

message InvokeRPCResponse {
  Header header = 1;
  string bcname = 2;
  InvokeResponse response = 3;
}

// 预执行的请求结构
message InvokeRequest {
  string module_name = 1;
  string contract_name = 2;
  string method_name = 3;
  map<string, bytes> args = 4;
  repeated ResourceLimit resource_limits = 5;
}

// 预执行的返回结构
message InvokeResponse {
  repeated TxInputExt inputs = 1;
  repeated TxOutputExt outputs = 2;
  repeated bytes response = 3;
  int64 gas_used = 4;
  repeated InvokeRequest requests = 5;
  repeated ContractResponse responses = 6;
}

// 扩展输入
message TxInputExt {
  string bucket = 1;
  bytes key = 2;
  bytes ref_txid = 3;
  int32 ref_offset = 4;
}

// 扩展输出
message TxOutputExt {
  string bucket = 1;
  bytes key = 2;
  bytes value = 3;
}

// 签名详情
message SignatureInfo {
  string PublicKey = 1;
  bytes Sign = 2;
}

// --------   Account and Permission Section --------
enum PermissionRule {
  NULL = 0;           // 无权限控制
  SIGN_THRESHOLD = 1; // 签名阈值策略
  SIGN_AKSET = 2;     // AKSet签名策略
  SIGN_RATE = 3;      // 签名率策略
  SIGN_SUM = 4;       // 签名个数策略
  CA_SERVER = 5;      // CA服务器鉴权
  COMMUNITY_VOTE = 6; // 社区治理
}

message PermissionModel {
  PermissionRule rule = 1;
  double acceptValue = 2; // 取决于用哪种rule, 可以表示签名率,签名数或权重阈值
}

// AK集的表示方法
message AkSet {
  repeated string aks = 1; // 一堆公钥
}
message AkSets {
  map<string, AkSet> sets = 1; // 公钥or账户名集
  string expression =
      2; // 表达式,一期不支持表达式,默认集合内是and,集合间是or
}

// Acl实际使用的结构
message Acl {
  PermissionModel pm = 1;            // 采用的权限模型
  map<string, double> aksWeight = 2; // 公钥or账户名  -> 权重
  AkSets akSets = 3;
}

// 查询Acl
message AclStatus {
  Header header = 1;
  string bcname = 2;
  string accountName = 3;
  string contractName = 4;
  string methodName = 5;
  bool confirmed = 6;
  Acl acl = 7;
}

// Identity authentication request
message IdentityAuth {
  bytes sign = 1;
  bytes pubkey = 2;
  string addr = 3;
  string peerID = 4;
  string timestamp = 5;
}

// Identity authentication requests
message IdentityAuths { repeated IdentityAuth auth = 1; }

enum ResourceType {
  CPU = 0;
  MEMORY = 1;
  DISK = 2;
  XFEE = 3; // the fee used in kernel contract
}

message ResourceLimit {
  ResourceType type = 1;
  int64 limit = 2;
}

message AK2AccountRequest {
  Header header = 1;
  string bcname = 2;
  string address = 3;
}

message AK2AccountResponse {
  Header header = 1;
  string bcname = 2;
  repeated string account = 3;
}

// Query account contracts request
message GetAccountContractsRequest {
  Header header = 1;
  string bcname = 2;
  string account = 3;
}

// Query account contracts response
message GetAccountContractsResponse {
  Header header = 1;
  repeated ContractStatus contracts_status = 2;
}

// Status of a contract
message ContractStatus {
  string contract_name = 1;
  string txid = 2;
  bytes desc = 3;
  bool is_banned = 4;
}

// PreExecWithSelectUTXORequest preExec + selectUtxo for request
message PreExecWithSelectUTXORequest {
  Header header = 1;
  string bcname = 2;
  string address = 3;
  int64 totalAmount = 4;
  SignatureInfo signInfo = 6;
  bool needLock = 7;
  InvokeRPCRequest request = 5;
}

// PreExecWithSelectUTXOResponse preExec + selectUtxo for response
message PreExecWithSelectUTXOResponse {
  Header header = 1;
  string bcname = 2;
  InvokeResponse response = 3;
  // for preExec & selectUTXO
  UtxoOutput utxoOutput = 4;
}

// ContractResponse is the response returnd by contract
message ContractResponse {
  int32  status = 1;
  string message = 2;
  bytes  body = 3;
}