Skip to content

Commit

Permalink
feat: prepare configuration for 2023
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangsoledad committed Apr 7, 2023
1 parent 4cbfb15 commit 0281179
Show file tree
Hide file tree
Showing 26 changed files with 289 additions and 324 deletions.
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 12 additions & 7 deletions chain/src/tests/load_code_with_snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ use ckb_types::prelude::*;
use ckb_types::{
bytes::Bytes,
core::{
capacity_bytes, hardfork::HardForkSwitch, BlockBuilder, Capacity, EpochNumberWithFraction,
ScriptHashType, TransactionBuilder, TransactionView,
capacity_bytes,
hardfork::{HardForks, CKB2021, CKB2023},
BlockBuilder, Capacity, EpochNumberWithFraction, ScriptHashType, TransactionBuilder,
TransactionView,
},
packed::{self, CellDep, CellInput, CellOutputBuilder, OutPoint, Script},
utilities::DIFF_TWO,
Expand Down Expand Up @@ -235,11 +237,14 @@ fn _test_load_code_with_snapshot_after_hardfork(script_type: ScriptHashType) {
.dao(dao)
.build();

let hardfork_switch = HardForkSwitch::new_mirana()
.as_builder()
.rfc_0032(0)
.build()
.unwrap();
let hardfork_switch = HardForks {
ckb2021: CKB2021::new_mirana()
.as_builder()
.rfc_0032(0)
.build()
.unwrap(),
ckb2023: CKB2023::new_builder().build().unwrap(),
};
let consensus = ConsensusBuilder::default()
.cellbase_maturity(EpochNumberWithFraction::new(0, 0, 1))
.genesis_block(genesis_block)
Expand Down
8 changes: 1 addition & 7 deletions resource/specs/dev.toml
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,7 @@ genesis_epoch_length = 1000
permanent_difficulty_in_dummy = true

[params.hardfork]
rfc_0028 = 0
rfc_0029 = 0
rfc_0030 = 0
rfc_0031 = 0
rfc_0032 = 0
rfc_0036 = 0
rfc_0038 = 0


[pow]
func = "Dummy"
8 changes: 1 addition & 7 deletions resource/specs/staging.toml
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,7 @@ epoch_duration_target = 14400
genesis_epoch_length = 1000

[params.hardfork]
rfc_0028 = 0
rfc_0029 = 0
rfc_0030 = 0
rfc_0031 = 0
rfc_0032 = 0
rfc_0036 = 0
rfc_0038 = 0


[pow]
func = "Eaglesong"
36 changes: 16 additions & 20 deletions rpc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ The crate `ckb-rpc`'s minimum supported rustc version is 1.67.1.
* [Type `EstimateCycles`](#type-estimatecycles)
* [Type `FeeRateStatics`](#type-feeratestatics)
* [Type `H256`](#type-h256)
* [Type `HardForkFeature`](#type-hardforkfeature)
* [Type `HardForks`](#type-hardforks)
* [Type `Header`](#type-header)
* [Type `HeaderView`](#type-headerview)
* [Type `IndexerCell`](#type-indexercell)
Expand Down Expand Up @@ -1647,15 +1647,18 @@ Response
"dao_type_hash": null,
"epoch_duration_target": "0x3840",
"genesis_hash": "0x7978ec7ce5b507cfb52e149e36b1a23f6062ed150503c85bbf825da3599095ed",
"hardfork_features": [
{ "rfc": "0028", "epoch_number": "0x1526" },
{ "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", "epoch_number": "0x0" }
],
"hardfork_features": {
"ckb2021": [
{ "rfc": "0028", "epoch_number": "0x1526" },
{ "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", "epoch_number": "0x0" }
],
"ckb2023": []
},
"id": "main",
"initial_primary_epoch_reward": "0x71afd498d000",
"max_block_bytes": "0x91c08",
Expand Down Expand Up @@ -5607,7 +5610,7 @@ Consensus defines various parameters that influence chain consensus

* `permanent_difficulty_in_dummy`: `boolean` - Keep difficulty be permanent if the pow is dummy

* `hardfork_features`: `Array<` [`HardForkFeature`](#type-hardforkfeature) `>` - Hardfork features
* `hardfork_features`: [`HardForks`](#type-hardforks) - Hardfork features


### Type `Cycle`
Expand Down Expand Up @@ -5801,17 +5804,10 @@ The fee_rate statistics information, includes mean and median, unit: shannons pe

The 256-bit binary data encoded as a 0x-prefixed hex string in JSON.

### Type `HardForkFeature`

The information about one hardfork feature.

#### Fields

`HardForkFeature` is a JSON object with the following fields.
### Type `HardForks`

* `rfc`: `string` - The related RFC ID.
Returns a list of hardfork features from a hardfork switch.

* `epoch_number`: [`EpochNumber`](#type-epochnumber) `|` `null` - The first epoch when the feature is enabled, `null` indicates that the RFC has never been enabled.


### Type `Header`
Expand Down
21 changes: 12 additions & 9 deletions rpc/src/module/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1333,15 +1333,18 @@ pub trait ChainRpc {
/// "dao_type_hash": null,
/// "epoch_duration_target": "0x3840",
/// "genesis_hash": "0x7978ec7ce5b507cfb52e149e36b1a23f6062ed150503c85bbf825da3599095ed",
/// "hardfork_features": [
/// { "rfc": "0028", "epoch_number": "0x1526" },
/// { "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", "epoch_number": "0x0" }
/// ],
/// "hardfork_features": {
/// "ckb2021": [
/// { "rfc": "0028", "epoch_number": "0x1526" },
/// { "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", "epoch_number": "0x0" }
/// ],
/// "ckb2023": []
/// },
/// "id": "main",
/// "initial_primary_epoch_reward": "0x71afd498d000",
/// "max_block_bytes": "0x91c08",
Expand Down
1 change: 0 additions & 1 deletion script/fuzz/fuzz_targets/syscall_exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use ckb_types::{
core::{
capacity_bytes,
cell::{CellMetaBuilder, ResolvedTransaction},
hardfork::HardForkSwitch,
Capacity, HeaderView, ScriptHashType, TransactionBuilder, TransactionInfo,
},
packed::{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use ckb_types::{
core::{
capacity_bytes,
cell::{CellMetaBuilder, ResolvedTransaction},
hardfork::HardForkSwitch,
Capacity, HeaderView, ScriptHashType, TransactionBuilder, TransactionInfo,
},
h256,
Expand Down
14 changes: 6 additions & 8 deletions spec/src/consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use ckb_types::{
bytes::Bytes,
constants::{BLOCK_VERSION, TX_VERSION},
core::{
hardfork::HardForkSwitch, BlockBuilder, BlockNumber, BlockView, Capacity, Cycle, EpochExt,
hardfork::HardForks, BlockBuilder, BlockNumber, BlockView, Capacity, Cycle, EpochExt,
EpochNumber, EpochNumberWithFraction, HeaderView, Ratio, TransactionBuilder,
TransactionView, Version,
},
Expand Down Expand Up @@ -282,7 +282,7 @@ impl ConsensusBuilder {
primary_epoch_reward_halving_interval:
DEFAULT_PRIMARY_EPOCH_REWARD_HALVING_INTERVAL,
permanent_difficulty_in_dummy: false,
hardfork_switch: HardForkSwitch::new_mirana(),
hardfork_switch: HardForks::new_mirana(),
deployments: HashMap::new(),
versionbits_caches: VersionbitsCache::default(),
},
Expand Down Expand Up @@ -468,7 +468,7 @@ impl ConsensusBuilder {
}

/// Sets a hard fork switch for the new Consensus.
pub fn hardfork_switch(mut self, hardfork_switch: HardForkSwitch) -> Self {
pub fn hardfork_switch(mut self, hardfork_switch: HardForks) -> Self {
self.inner.hardfork_switch = hardfork_switch;
self
}
Expand Down Expand Up @@ -554,7 +554,7 @@ pub struct Consensus {
/// Keep difficulty be permanent if the pow is dummy
pub permanent_difficulty_in_dummy: bool,
/// A switch to select hard fork features base on the epoch number.
pub hardfork_switch: HardForkSwitch,
pub hardfork_switch: HardForks,
/// Soft fork deployments
pub deployments: HashMap<DeploymentPos, Deployment>,
/// Soft fork state cache
Expand Down Expand Up @@ -951,7 +951,7 @@ impl Consensus {
}

/// Returns the hardfork switch.
pub fn hardfork_switch(&self) -> &HardForkSwitch {
pub fn hardfork_switch(&self) -> &HardForks {
&self.hardfork_switch
}

Expand Down Expand Up @@ -1062,9 +1062,7 @@ impl From<Consensus> for ckb_jsonrpc_types::Consensus {
.primary_epoch_reward_halving_interval
.into(),
permanent_difficulty_in_dummy: consensus.permanent_difficulty_in_dummy,
hardfork_features: ckb_jsonrpc_types::HardForkFeature::load_list_from_switch(
&consensus.hardfork_switch,
),
hardfork_features: ckb_jsonrpc_types::HardForks::new(&consensus.hardfork_switch),
}
}
}
Expand Down
Loading

0 comments on commit 0281179

Please sign in to comment.