Skip to content

Commit

Permalink
Merge pull request #4019 from zhangsoledad/zhangsoledad/update_rfc_num
Browse files Browse the repository at this point in the history
chore: update 2023 rfc number
  • Loading branch information
zhangsoledad authored Jun 16, 2023
2 parents 384911d + 2be50db commit 714af35
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 37 deletions.
4 changes: 2 additions & 2 deletions chain/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,14 +193,14 @@ impl ForkChanges {
false
} else {
// This method assumes that the input blocks are sorted and unique.
let rfc_0148 = hardfork.ckb2023.rfc_0148();
let rfc_0049 = hardfork.ckb2023.rfc_0049();
let epoch_first = blocks.front().unwrap().epoch().number();
let epoch_next = blocks
.back()
.unwrap()
.epoch()
.minimum_epoch_number_after_n_blocks(1);
epoch_first < rfc_0148 && rfc_0148 <= epoch_next
epoch_first < rfc_0049 && rfc_0049 <= epoch_next
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions rpc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1666,8 +1666,8 @@ Response
{ "rfc": "0038", "epoch_number": "0x0" }
],
"ckb2023": [
{ "rfc": "0146", "epoch_number": null },
{ "rfc": "0148", "epoch_number": null }
{ "rfc": "0048", "epoch_number": null },
{ "rfc": "0049", "epoch_number": null }
]
},
"id": "main",
Expand Down
4 changes: 2 additions & 2 deletions rpc/src/module/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1348,8 +1348,8 @@ pub trait ChainRpc {
/// { "rfc": "0038", "epoch_number": "0x0" }
/// ],
/// "ckb2023": [
/// { "rfc": "0146", "epoch_number": null },
/// { "rfc": "0148", "epoch_number": null }
/// { "rfc": "0048", "epoch_number": null },
/// { "rfc": "0049", "epoch_number": null }
/// ]
/// },
/// "id": "main",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ fn run(data: &[u8]) {
ckb2021: CKB2021::new_mirana().as_builder().build().unwrap(),
ckb2023: CKB2023::new_mirana()
.as_builder()
.rfc_0148(0)
.rfc_0049(0)
.build()
.unwrap(),
};
Expand Down
2 changes: 1 addition & 1 deletion script/src/verify/tests/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ impl TransactionScriptsVerifierWithEnv {
ckb2021: CKB2021::new_mirana(),
ckb2023: CKB2023::new_mirana()
.as_builder()
.rfc_0148(version_2_enabled_at)
.rfc_0049(version_2_enabled_at)
.build()
.unwrap(),
};
Expand Down
8 changes: 4 additions & 4 deletions spec/src/consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1028,13 +1028,13 @@ impl Consensus {

let epoch_number = epoch.number();

let rfc_0148 = self.hardfork_switch.ckb2023.rfc_0148();
let rfc_0049 = self.hardfork_switch.ckb2023.rfc_0049();

// dev default is 0
if rfc_0148 != 0 && rfc_0148 != EpochNumber::MAX {
return (epoch_number + 1 == rfc_0148
if rfc_0049 != 0 && rfc_0049 != EpochNumber::MAX {
return (epoch_number + 1 == rfc_0049
&& (proposal_window.farthest() + index) >= epoch_length)
|| (epoch_number == rfc_0148 && index <= proposal_window.farthest());
|| (epoch_number == rfc_0049 && index <= proposal_window.farthest());
}
false
}
Expand Down
2 changes: 1 addition & 1 deletion spec/src/hardfork.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ impl HardForkConfig {
builder: CKB2023Builder,
ckb2023: EpochNumber,
) -> Result<CKB2023Builder, String> {
let builder = builder.rfc_0146(ckb2023).rfc_0148(ckb2023);
let builder = builder.rfc_0048(ckb2023).rfc_0049(ckb2023);
Ok(builder)
}

Expand Down
6 changes: 3 additions & 3 deletions tx-pool/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,11 @@ pub(crate) fn after_delay_window(snapshot: &Snapshot) -> bool {
let index = epoch.index();
let epoch_number = epoch.number();

let rfc_0148 = snapshot.consensus().hardfork_switch.ckb2023.rfc_0148();
let rfc_0049 = snapshot.consensus().hardfork_switch.ckb2023.rfc_0049();

if rfc_0148 == 0 && rfc_0148 == EpochNumber::MAX {
if rfc_0049 == 0 && rfc_0049 == EpochNumber::MAX {
return true;
}

epoch_number > rfc_0148 || (epoch_number == rfc_0148 && index > proposal_window.farthest())
epoch_number > rfc_0049 || (epoch_number == rfc_0049 && index > proposal_window.farthest())
}
4 changes: 2 additions & 2 deletions util/jsonrpc-types/src/blockchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1403,8 +1403,8 @@ impl HardForks {
HardForkFeature::new("0038", convert(hardforks.ckb2021.rfc_0038())),
],
ckb2023: vec![
HardForkFeature::new("0146", convert(hardforks.ckb2023.rfc_0146())),
HardForkFeature::new("0148", convert(hardforks.ckb2023.rfc_0148())),
HardForkFeature::new("0048", convert(hardforks.ckb2023.rfc_0048())),
HardForkFeature::new("0049", convert(hardforks.ckb2023.rfc_0049())),
],
}
}
Expand Down
36 changes: 18 additions & 18 deletions util/types/src/core/hardfork/ckb2023.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ use paste::paste;
/// [`CKB2023Builder`]: struct.CKB2023Builder.html
#[derive(Debug, Clone)]
pub struct CKB2023 {
rfc_0146: EpochNumber,
rfc_0148: EpochNumber,
rfc_0048: EpochNumber,
rfc_0049: EpochNumber,
}

/// Builder for [`CKB2023`].
///
/// [`CKB2023`]: struct.CKB2023.html
#[derive(Debug, Clone, Default)]
pub struct CKB2023Builder {
rfc_0146: Option<EpochNumber>,
rfc_0148: Option<EpochNumber>,
rfc_0048: Option<EpochNumber>,
rfc_0049: Option<EpochNumber>,
}

impl CKB2023 {
Expand All @@ -32,42 +32,42 @@ impl CKB2023 {
/// Creates a new builder based on the current instance.
pub fn as_builder(&self) -> CKB2023Builder {
Self::new_builder()
.rfc_0146(self.rfc_0146())
.rfc_0148(self.rfc_0148())
.rfc_0048(self.rfc_0048())
.rfc_0049(self.rfc_0049())
}

/// Creates a new mirana instance.
pub fn new_mirana() -> Self {
// Use a builder to ensure all features are set manually.
Self::new_builder()
.rfc_0146(hardfork::mainnet::CKB2023_START_EPOCH)
.rfc_0148(hardfork::mainnet::CKB2023_START_EPOCH)
.rfc_0048(hardfork::mainnet::CKB2023_START_EPOCH)
.rfc_0049(hardfork::mainnet::CKB2023_START_EPOCH)
.build()
.unwrap()
}

/// Creates a new dev instance.
pub fn new_dev() -> Self {
// Use a builder to ensure all features are set manually.
Self::new_builder().rfc_0146(0).rfc_0148(0).build().unwrap()
Self::new_builder().rfc_0048(0).rfc_0049(0).build().unwrap()
}
}

define_methods!(
CKB2023,
rfc_0146,
rfc_0048,
remove_header_version_reservation_rule,
is_remove_header_version_reservation_rule_enabled,
disable_rfc_0146,
"RFC PR 0146"
disable_rfc_0048,
"RFC PR 0048"
);
define_methods!(
CKB2023,
rfc_0148,
rfc_0049,
vm_version_2_and_syscalls_3,
is_vm_version_2_and_syscalls_3_enabled,
disable_rfc_0148,
"RFC PR 0148"
disable_rfc_0049,
"RFC PR 0049"
);

impl CKB2023Builder {
Expand All @@ -78,9 +78,9 @@ impl CKB2023Builder {
///
/// [`CKB2023`]: struct.CKB2023.html
pub fn build(self) -> Result<CKB2023, String> {
let rfc_0146 = try_find!(self, rfc_0146);
let rfc_0148 = try_find!(self, rfc_0148);
let rfc_0048 = try_find!(self, rfc_0048);
let rfc_0049 = try_find!(self, rfc_0049);

Ok(CKB2023 { rfc_0146, rfc_0148 })
Ok(CKB2023 { rfc_0048, rfc_0049 })
}
}
2 changes: 1 addition & 1 deletion verification/src/tests/header_verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub fn test_version() {
ckb2021: CKB2021::new_mirana(),
ckb2023: CKB2023::new_mirana()
.as_builder()
.rfc_0146(10)
.rfc_0048(10)
.build()
.unwrap(),
};
Expand Down

0 comments on commit 714af35

Please sign in to comment.