Skip to content

Commit

Permalink
Merge pull request #537 from Chia-Network/hex-test-constants
Browse files Browse the repository at this point in the history
Use hex-literal and const in test constants
  • Loading branch information
Rigidity committed May 23, 2024
2 parents 88fffac + 1007df7 commit 2e26419
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 29 deletions.
43 changes: 15 additions & 28 deletions crates/chia-consensus/src/consensus_constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use chia_streamable_macro::streamable;

#[cfg(feature = "py-bindings")]
use chia_py_streamable_macro::{PyGetters, PyJsonDict, PyStreamable};
use hex_literal::hex;

#[cfg_attr(
feature = "py-bindings",
Expand Down Expand Up @@ -142,11 +143,9 @@ pub const TEST_CONSTANTS: ConsensusConstants = ConsensusConstants {
max_sub_slot_blocks: 128,
num_sps_sub_slot: 64,
sub_slot_iters_starting: u64::pow(2, 27),

difficulty_constant_factor: u128::pow(2, 67),
difficulty_starting: 7,
difficulty_change_max_factor: 3,

sub_epoch_blocks: 384,
epoch_blocks: 4608,
significant_bits: 8,
Expand All @@ -158,35 +157,22 @@ pub const TEST_CONSTANTS: ConsensusConstants = ConsensusConstants {
num_sp_intervals_extra: 3,
max_future_time2: 2 * 60,
number_of_timestamps: 11,
genesis_challenge: Bytes32::const_new([
0xe3, 0xb0, 0xc4, 0x42, 0x98, 0xfc, 0x1c, 0x14, 0x9a, 0xfb, 0xf4, 0xc8, 0x99, 0x6f, 0xb9,
0x24, 0x27, 0xae, 0x41, 0xe4, 0x64, 0x9b, 0x93, 0x4c, 0xa4, 0x95, 0x99, 0x1b, 0x78, 0x52,
0xb8, 0x55,
]),

agg_sig_me_additional_data: Bytes32::const_new([
0xcc, 0xd5, 0xbb, 0x71, 0x18, 0x35, 0x32, 0xbf, 0xf2, 0x20, 0xba, 0x46, 0xc2, 0x68, 0x99,
0x1a, 0x3f, 0xf0, 0x7e, 0xb3, 0x58, 0xe8, 0x25, 0x5a, 0x65, 0xc3, 0x0a, 0x2d, 0xce, 0x0e,
0x5f, 0xbb,
]),
genesis_pre_farm_pool_puzzle_hash: Bytes32::const_new([
0xd2, 0x3d, 0xa1, 0x46, 0x95, 0xa1, 0x88, 0xae, 0x57, 0x08, 0xdd, 0x15, 0x22, 0x63, 0xc4,
0xdb, 0x88, 0x3e, 0xb2, 0x7e, 0xde, 0xb9, 0x36, 0x17, 0x8d, 0x4d, 0x98, 0x8b, 0x8f, 0x3c,
0xe5, 0xfc,
]),
genesis_pre_farm_farmer_puzzle_hash: Bytes32::const_new([
0x3d, 0x87, 0x65, 0xd3, 0xa5, 0x97, 0xec, 0x1d, 0x99, 0x66, 0x3f, 0x6c, 0x98, 0x16, 0xd9,
0x15, 0xb9, 0xf6, 0x86, 0x13, 0xac, 0x94, 0x00, 0x98, 0x84, 0xc4, 0xad, 0xda, 0xef, 0xcc,
0xe6, 0xaf,
]),
genesis_challenge: Bytes32::new(hex!(
"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
)),
agg_sig_me_additional_data: Bytes32::new(hex!(
"ccd5bb71183532bff220ba46c268991a3ff07eb358e8255a65c30a2dce0e5fbb"
)),
genesis_pre_farm_pool_puzzle_hash: Bytes32::new(hex!(
"d23da14695a188ae5708dd152263c4db883eb27edeb936178d4d988b8f3ce5fc"
)),
genesis_pre_farm_farmer_puzzle_hash: Bytes32::new(hex!(
"3d8765d3a597ec1d99663f6c9816d915b9f68613ac94009884c4addaefcce6af"
)),
max_vdf_witness_size: 64,

mempool_block_buffer: 10,

max_coin_amount: ((1u128 << 64) - 1) as u64,

max_coin_amount: u64::MAX,
max_block_cost_clvm: 11000000000,

cost_per_byte: 12000,
weight_proof_threshold: 2,
blocks_cache_size: 4608 + (128 * 4),
Expand All @@ -197,6 +183,7 @@ pub const TEST_CONSTANTS: ConsensusConstants = ConsensusConstants {
pool_sub_slot_iters: 37600000000,
soft_fork2_height: 0,
soft_fork4_height: 5716000,
soft_fork5_height: 5940000,
hard_fork_height: 5496000,
hard_fork_fix_height: 5496000,
plot_filter_128_height: 10542000,
Expand Down
2 changes: 1 addition & 1 deletion crates/chia-protocol/src/bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ impl Deref for Bytes {
pub struct BytesImpl<const N: usize>([u8; N]);

impl<const N: usize> BytesImpl<N> {
pub fn new(bytes: [u8; N]) -> Self {
pub const fn new(bytes: [u8; N]) -> Self {
Self(bytes)
}

Expand Down

0 comments on commit 2e26419

Please sign in to comment.