Skip to content

Commit

Permalink
feat(rpc): a new field 'extension' is added to the block body
Browse files Browse the repository at this point in the history
A new field 'extension' is added to the block body

BREAKING CHANGE: A new field 'extension' is added to the block body

ref nervosnetwork/rfcs#224
  • Loading branch information
Keith-CY committed Aug 30, 2021
1 parent 45bfbc4 commit 285a829
Show file tree
Hide file tree
Showing 4 changed files with 211 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/ckb-sdk-rpc/__tests__/ckb-rpc.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ describe('Test with mock', () => {
},
],
uncles: [],
extension: '0x636b62',
},
},
})
Expand Down Expand Up @@ -142,6 +143,7 @@ describe('Test with mock', () => {
},
],
uncles: [],
extension: '0x636b62',
})
})
it('tx pool info', async () => {
Expand Down
204 changes: 204 additions & 0 deletions packages/ckb-sdk-rpc/__tests__/formatters/result.fixtures.json
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,210 @@
"uncles": []
}
},
{
"result": {
"header": {
"compact_target": "0x1e083126",
"dao": "0x010000000000000063ae2493990ab00000f0c890408900000061eb7ada030000",
"epoch": "0",
"hash": "0x0a663a245ae0b3545a24e4ec06066b9e9f0bd32e5fdbb9038ec15af59ef2593d",
"number": "1024",
"parent_hash": "0x5eae6dfdac4b3099619a131975fd0be6da3c099eeaae8261182627a53548fc87",
"proposals_hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"nonce": "0",
"timestamp": "1557311767",
"transactions_root": "0x64a872caca3c7b671b64897230e88dec8800b594347d192661908a87f7fbcb9b",
"extra_hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"version": "0"
},
"proposals": [],
"transactions": [
{
"cell_deps": [],
"header_deps": [],
"hash": "0x8027376875e45318ed469bed6314408e8f1986de246cbd03a786b69073c948b8",
"inputs": [
{
"previous_output": {
"tx_hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"index": "4294967295"
},
"since": "0"
}
],
"outputs": [
{
"capacity": "5000000000000",

"lock": {
"args": "0x",
"code_hash": "0x0000000000000000000000000000000000000000000000000000000000000001",
"hash_type": "data"
},
"type": null
}
],
"version": "0",
"witnesses": [],
"outputs_data": ["0x"]
}
],
"uncles": [],
"extension": "0x636b62"
},
"expected": {
"header": {
"compactTarget": "0x1e083126",
"dao": "0x010000000000000063ae2493990ab00000f0c890408900000061eb7ada030000",
"epoch": "0",
"hash": "0x0a663a245ae0b3545a24e4ec06066b9e9f0bd32e5fdbb9038ec15af59ef2593d",
"number": "1024",
"parentHash": "0x5eae6dfdac4b3099619a131975fd0be6da3c099eeaae8261182627a53548fc87",
"proposalsHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"nonce": "0",
"timestamp": "1557311767",
"transactionsRoot": "0x64a872caca3c7b671b64897230e88dec8800b594347d192661908a87f7fbcb9b",
"extraHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"version": "0"
},
"proposals": [],
"transactions": [
{
"cellDeps": [],
"headerDeps": [],
"hash": "0x8027376875e45318ed469bed6314408e8f1986de246cbd03a786b69073c948b8",
"inputs": [
{
"previousOutput": {
"txHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"index": "4294967295"
},
"since": "0"
}
],
"outputs": [
{
"capacity": "5000000000000",

"lock": {
"args": "0x",
"codeHash": "0x0000000000000000000000000000000000000000000000000000000000000001",
"hashType": "data"
},
"type": null
}
],
"version": "0",
"witnesses": [],
"outputsData": ["0x"]
}
],
"uncles": [],
"extension": "0x636b62"
}
},
{
"result": {
"header": {
"compact_target": "0x1e083126",
"dao": "0x010000000000000063ae2493990ab00000f0c890408900000061eb7ada030000",
"epoch": "0",
"hash": "0x0a663a245ae0b3545a24e4ec06066b9e9f0bd32e5fdbb9038ec15af59ef2593d",
"number": "1024",
"parent_hash": "0x5eae6dfdac4b3099619a131975fd0be6da3c099eeaae8261182627a53548fc87",
"proposals_hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"nonce": "0",
"timestamp": "1557311767",
"transactions_root": "0x64a872caca3c7b671b64897230e88dec8800b594347d192661908a87f7fbcb9b",
"extra_hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"version": "0"
},
"proposals": [],
"transactions": [
{
"cell_deps": [],
"header_deps": [],
"hash": "0x8027376875e45318ed469bed6314408e8f1986de246cbd03a786b69073c948b8",
"inputs": [
{
"previous_output": {
"tx_hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"index": "4294967295"
},
"since": "0"
}
],
"outputs": [
{
"capacity": "5000000000000",

"lock": {
"args": "0x",
"code_hash": "0x0000000000000000000000000000000000000000000000000000000000000001",
"hash_type": "data"
},
"type": null
}
],
"version": "0",
"witnesses": [],
"outputs_data": ["0x"]
}
],
"uncles": [],
"extension": null
},
"expected": {
"header": {
"compactTarget": "0x1e083126",
"dao": "0x010000000000000063ae2493990ab00000f0c890408900000061eb7ada030000",
"epoch": "0",
"hash": "0x0a663a245ae0b3545a24e4ec06066b9e9f0bd32e5fdbb9038ec15af59ef2593d",
"number": "1024",
"parentHash": "0x5eae6dfdac4b3099619a131975fd0be6da3c099eeaae8261182627a53548fc87",
"proposalsHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"nonce": "0",
"timestamp": "1557311767",
"transactionsRoot": "0x64a872caca3c7b671b64897230e88dec8800b594347d192661908a87f7fbcb9b",
"extraHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"version": "0"
},
"proposals": [],
"transactions": [
{
"cellDeps": [],
"headerDeps": [],
"hash": "0x8027376875e45318ed469bed6314408e8f1986de246cbd03a786b69073c948b8",
"inputs": [
{
"previousOutput": {
"txHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"index": "4294967295"
},
"since": "0"
}
],
"outputs": [
{
"capacity": "5000000000000",

"lock": {
"args": "0x",
"codeHash": "0x0000000000000000000000000000000000000000000000000000000000000001",
"hashType": "data"
},
"type": null
}
],
"version": "0",
"witnesses": [],
"outputsData": ["0x"]
}
],
"uncles": [],
"extension": null
}
},
{
"result": {
"header": {
Expand Down
2 changes: 2 additions & 0 deletions packages/ckb-sdk-rpc/types/rpc/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ declare module RPC {
export type RationalU256 = CKBComponents.RationalU256
export type ProposalWindow = CKBComponents.ProposalWindow
export type EpochNumberWithFraction = CKBComponents.EpochNumberWithFraction
export type JsonBytes = CKBComponents.JsonBytes

enum TransactionStatus {
Pending = 'pending',
Expand Down Expand Up @@ -155,6 +156,7 @@ declare module RPC {
uncles: UncleBlock[]
transactions: Transaction[]
proposals: ProposalShortId[]
extension?: JsonBytes | null
}

export interface AlertMessage {
Expand Down
3 changes: 3 additions & 0 deletions packages/ckb-types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ declare namespace CKBComponents {
export type ScriptHashType = 'data' | 'type'

export type DepType = 'code' | 'depGroup'
export type JsonBytes = string

/**
* @typedef Bytes, keep consistent with CKB
Expand Down Expand Up @@ -234,12 +235,14 @@ declare namespace CKBComponents {
* @property uncles, uncle blocks
* @property transactions
* @property proposals
* @property extension
*/
export interface Block {
header: BlockHeader
uncles: UncleBlock[]
transactions: Transaction[]
proposals: ProposalShortId[]
extension?: JsonBytes | null
}

/**
Expand Down

0 comments on commit 285a829

Please sign in to comment.