Skip to content

Commit

Permalink
feat(rpc): add a new field 'hardforkFeatures' in response of getConse…
Browse files Browse the repository at this point in the history
…nsus

Add a new field 'hardforkFeatures' in response of getConsensus

BREAKING CHANGE: Add a new field 'hardforkFeatures' in response of getConsensus

ref nervosnetwork/ckb#2879
  • Loading branch information
Keith-CY committed Aug 30, 2021
1 parent 45bfbc4 commit 133fe26
Show file tree
Hide file tree
Showing 5 changed files with 109 additions and 0 deletions.
18 changes: 18 additions & 0 deletions packages/ckb-sdk-rpc/__tests__/ckb-rpc.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,15 @@ describe('Test with mock', () => {
tx_proposal_window: { closest: '0x2', farthest: '0xa' },
tx_version: '0x0',
type_id_code_hash: '0x00000000000000000000000000000000000000000000000000545950455f4944',
hardfork_features: [
{ epoch_number: '0x0', rfc: '0028' },
{ epoch_number: '0x0', rfc: '0029' },
{ epoch_number: '0x0', rfc: '0030' },
{ epoch_number: '0x0', rfc: '0031' },
{ epoch_number: '0x0', rfc: '0032' },
{ epoch_number: '0x0', rfc: '0036' },
{ epoch_number: '0x0', rfc: '0038' },
],
},
},
})
Expand Down Expand Up @@ -669,6 +678,15 @@ describe('Test with mock', () => {
txProposalWindow: { closest: '0x2', farthest: '0xa' },
txVersion: '0x0',
typeIdCodeHash: '0x00000000000000000000000000000000000000000000000000545950455f4944',
hardforkFeatures: [
{ epochNumber: '0x0', rfc: '0028' },
{ epochNumber: '0x0', rfc: '0029' },
{ epochNumber: '0x0', rfc: '0030' },
{ epochNumber: '0x0', rfc: '0031' },
{ epochNumber: '0x0', rfc: '0032' },
{ epochNumber: '0x0', rfc: '0036' },
{ epochNumber: '0x0', rfc: '0038' },
],
})
})

Expand Down
86 changes: 86 additions & 0 deletions packages/ckb-sdk-rpc/__tests__/formatters/result.fixtures.json
Original file line number Diff line number Diff line change
Expand Up @@ -1544,6 +1544,92 @@
"txVersion": "0x0",
"typeIdCodeHash": "0x00000000000000000000000000000000000000000000000000545950455f4944"
}
},
{
"result": {
"block_version": "0x0",
"cellbase_maturity": "0x10000000000",
"dao_type_hash": null,
"epoch_duration_target": "0x3840",
"genesis_hash": "0x7978ec7ce5b507cfb52e149e36b1a23f6062ed150503c85bbf825da3599095ed",
"id": "main",
"initial_primary_epoch_reward": "0x71afd498d000",
"max_block_bytes": "0x91c08",
"max_block_cycles": "0xd09dc300",
"max_block_proposals_limit": "0x5dc",
"max_uncles_num": "0x2",
"median_time_block_count": "0x25",
"orphan_rate_target": {
"denom": "0x28",
"numer": "0x1"
},
"permanent_difficulty_in_dummy": false,
"primary_epoch_reward_halving_interval": "0x2238",
"proposer_reward_ratio": {
"denom": "0xa",
"numer": "0x4"
},
"secondary_epoch_reward": "0x37d0c8e28542",
"secp256k1_blake160_multisig_all_type_hash": null,
"secp256k1_blake160_sighash_all_type_hash": null,
"tx_proposal_window": {
"closest": "0x2",
"farthest": "0xa"
},
"tx_version": "0x0",
"type_id_code_hash": "0x00000000000000000000000000000000000000000000000000545950455f4944",
"hardfork_features": [
{ "epoch_number": "0x0", "rfc": "0028" },
{ "epoch_number": "0x0", "rfc": "0029" },
{ "epoch_number": "0x0", "rfc": "0030" },
{ "epoch_number": "0x0", "rfc": "0031" },
{ "epoch_number": "0x0", "rfc": "0032" },
{ "epoch_number": "0x0", "rfc": "0036" },
{ "epoch_number": "0x0", "rfc": "0038" }
]
},
"expected": {
"blockVersion": "0x0",
"cellbaseMaturity": "0x10000000000",
"daoTypeHash": null,
"epochDurationTarget": "0x3840",
"genesisHash": "0x7978ec7ce5b507cfb52e149e36b1a23f6062ed150503c85bbf825da3599095ed",
"id": "main",
"initialPrimaryEpochReward": "0x71afd498d000",
"maxBlockBytes": "0x91c08",
"maxBlockCycles": "0xd09dc300",
"maxBlockProposalsLimit": "0x5dc",
"maxUnclesNum": "0x2",
"medianTimeBlockCount": "0x25",
"orphanRateTarget": {
"denom": "0x28",
"numer": "0x1"
},
"permanentDifficultyInDummy": false,
"primaryEpochRewardHalvingInterval": "0x2238",
"proposerRewardRatio": {
"denom": "0xa",
"numer": "0x4"
},
"secondaryEpochReward": "0x37d0c8e28542",
"secp256k1Blake160MultisigAllTypeHash": null,
"secp256k1Blake160SighashAllTypeHash": null,
"txProposalWindow": {
"closest": "0x2",
"farthest": "0xa"
},
"txVersion": "0x0",
"typeIdCodeHash": "0x00000000000000000000000000000000000000000000000000545950455f4944",
"hardforkFeatures": [
{ "epochNumber": "0x0", "rfc": "0028" },
{ "epochNumber": "0x0", "rfc": "0029" },
{ "epochNumber": "0x0", "rfc": "0030" },
{ "epochNumber": "0x0", "rfc": "0031" },
{ "epochNumber": "0x0", "rfc": "0032" },
{ "epochNumber": "0x0", "rfc": "0036" },
{ "epochNumber": "0x0", "rfc": "0038" }
]
}
}
],
"toRawTxPool": [
Expand Down
3 changes: 3 additions & 0 deletions packages/ckb-sdk-rpc/src/resultFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,9 @@ const formatter = {
txProposalWindow: consensus.tx_proposal_window,
txVersion: consensus.tx_version,
typeIdCodeHash: consensus.type_id_code_hash,
hardforkFeatures:
consensus.hardfork_features?.map(({ epoch_number: epochNumber, ...rest }) => ({ epochNumber, ...rest })) ??
consensus.hardfork_features,
}
},
toRawTxPool: (rawTxPool: RPC.RawTxPool): CKBComponents.RawTxPool => {
Expand Down
1 change: 1 addition & 0 deletions packages/ckb-sdk-rpc/types/rpc/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ declare module RPC {
export interface Consensus {
id: string
genesis_hash: Hash256
hardfork_features: Array<{ rfc: string; epoch_number: string | null }>
dao_type_hash: Hash256 | null
secp256k1_blake160_sighash_all_type_hash: Hash256 | null
secp256k1_blake160_multisig_all_type_hash: Hash256 | null
Expand Down
1 change: 1 addition & 0 deletions packages/ckb-types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,7 @@ declare namespace CKBComponents {
export interface Consensus {
id: string
genesisHash: Hash256
hardforkFeatures: Array<{ rfc: string; epochNumber: string | null }>
daoTypeHash: Hash256 | null
secp256k1Blake160SighashAllTypeHash: Hash256 | null
secp256k1Blake160MultisigAllTypeHash: Hash256 | null
Expand Down

0 comments on commit 133fe26

Please sign in to comment.