get_block_template

NumberCategoryStatusAuthorOrganizationCreated
0013Standards TrackProposalDingwei ZhangNervos Foundation2019-01-02

get_block_template

Abstract

This RFC describes the decentralized CKB mining protocol.

Motivation

The original get_work [btc eth] mining protocol simply issues block headers for a miner to solve, the miner is kept in the dark, and has no influence over block creation. get_block_template moves block creation to the miner, the entire block structure is sent, and left to the miner to (optionally) customize and assemble, miner are enabled to audit and possibly modify the block before hashing it, this improves the security of the CKB network by making blocks decentralized.

Specification

Block Template Request

A JSON-RPC method is defined, called get_block_template. It accepts exactly three argument:

KeyRequiredTypeDescription
cycles_limitNoNumbermaximum number of cycles to include in template
bytes_limitNoNumbermaximum number of bytes to use for the entire block
max_versionNoNumberhighest block version number supported

For cycles_limit, bytes_limit and max_version, if omitted, the default limit (consensus level) is used. Servers SHOULD respect these desired maximums (if those maximums exceed consensus level limit, Servers SHOULD instead return the consensus level limit), but are NOT required to, clients SHOULD check that the returned template satisfies their requirements appropriately.

get_block_template MUST return a JSON Object containing the following keys:

KeyRequiredTypeDescription
versionYesNumberblock version
difficultyYesStringdifficulty in hex-encoded string
current_timeYesNumberthe current time as seen by the server (recommended for block time)
numberYesNumberthe number of the block we are looking for
parent_hashYesStringthe hash of the parent block, in hex-encoded string
cycles_limitNoNumbermaximum number of cycles allowed in blocks
bytes_limitNoNumbermaximum number of bytes allowed in blocks
commit_transactionsShouldArray of Objectsobjects containing information for CKB transactions (excluding cellbase)
proposal_transactionsShouldArray of Stringarray of hex-encoded transaction proposal_short_id
cellbaseYesObjectinformation for cellbase transaction
work_idNoStringif provided, this value must be returned with results (see Block Submission)

Transaction Object

The Objects listed in the response's "commit_transactions" key contains these keys:

KeyRequiredTypeDescription
hashYesStringthe hash of the transaction
requiredNoBooleanif provided and true, this transaction must be in the final block
cyclesNoNumbertotal number of cycles, if key is not present, cycles is unknown and clients MUST NOT assume there aren't any
dependsNoArray of Numbersother transactions before this one (by 1-based index in "transactions" list) that must be present in the final block if this one is; if key is not present, dependencies are unknown and clients MUST NOT assume there aren't any
dataYesStringtransaction Molecule bytes in hex-encoded string

Block Submission

A JSON-RPC method is defined, called submit_block. to submit potential blocks (or shares). It accepts two arguments: the first is always a String of the hex-encoded block Molecule bytes to submit; the second is String of work_id.

KeyRequiredTypeDescription
dataYesStringblock Molecule bytes in hex-encoded string
work_idNoStringif the server provided a workid, it MUST be included with submissions

References