Skip to content

Commit

Permalink
Merge pull request #783 from Chia-Network/keccak-softfork
Browse files Browse the repository at this point in the history
Add keccak softfork constant and flag
  • Loading branch information
Rigidity authored Nov 13, 2024
2 parents cad639f + b338e78 commit 08e7f3b
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 11 deletions.
24 changes: 22 additions & 2 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ chia-puzzles-fuzz = { path = "./crates/chia-puzzles/fuzz", version = "0.15.0" }
clvm-traits-fuzz = { path = "./crates/clvm-traits/fuzz", version = "0.15.0" }
clvm-utils-fuzz = { path = "./crates/clvm-utils/fuzz", version = "0.15.0" }
blst = { version = "0.3.12", features = ["portable"] }
clvmr = "0.9.1"
clvmr = "0.10.0"
syn = "2.0.83"
quote = "1.0.32"
proc-macro2 = "1.0.89"
Expand Down
7 changes: 4 additions & 3 deletions crates/chia-consensus/src/consensus_constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ pub struct ConsensusConstants {

pool_sub_slot_iters: u64,

/// Soft fork initiated in 2.4.0 release.
soft_fork5_height: u32,
/// Soft fork initiated in 2.5.0 release.
soft_fork6_height: u32,

/// The hard fork planned with the 2.0 release.
/// This is the block with the first plot filter adjustment.
Expand Down Expand Up @@ -198,7 +198,8 @@ pub const TEST_CONSTANTS: ConsensusConstants = ConsensusConstants {
max_generator_size: 1_000_000,
max_generator_ref_list_size: 512,
pool_sub_slot_iters: 37_600_000_000,
soft_fork5_height: 5_940_000,
// TODO: This is just a rough estimate. We should figure out the actual height.
soft_fork6_height: 6_663_456,
hard_fork_height: 5_496_000,
plot_filter_128_height: 10_542_000,
plot_filter_64_height: 15_592_000,
Expand Down
9 changes: 9 additions & 0 deletions crates/chia-consensus/src/spendbundle_validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use chia_bls::GTElement;
use chia_bls::{aggregate_verify_gt, hash_to_g2};
use chia_protocol::SpendBundle;
use chia_sha2::Sha256;
use clvmr::chia_dialect::ENABLE_KECCAK;
use clvmr::LIMIT_HEAP;
use std::time::{Duration, Instant};

Expand Down Expand Up @@ -78,6 +79,14 @@ pub fn get_flags_for_height_and_constants(height: u32, constants: &ConsensusCons
// serialization format (with back-references)
flags |= ALLOW_BACKREFS;
}

// The soft fork initiated with 2.5.0. The activation date is still TBD.
// Adds a new keccak256 operator under the softfork guard with extension 1.
// This operator can be hard forked in later, but is not included in a hard fork yet.
if height >= constants.soft_fork6_height {
flags |= ENABLE_KECCAK;
}

flags
}

Expand Down
2 changes: 1 addition & 1 deletion tests/run_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
MAX_GENERATOR_SIZE=uint32(1000000),
MAX_GENERATOR_REF_LIST_SIZE=uint32(512),
POOL_SUB_SLOT_ITERS=uint64(37600000000),
SOFT_FORK5_HEIGHT=uint32(0),
SOFT_FORK6_HEIGHT=uint32(0),
HARD_FORK_HEIGHT=uint32(5496000),
PLOT_FILTER_128_HEIGHT=uint32(10542000),
PLOT_FILTER_64_HEIGHT=uint32(15592000),
Expand Down
2 changes: 1 addition & 1 deletion tests/test_blscache.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
MAX_GENERATOR_SIZE=uint32(1000000),
MAX_GENERATOR_REF_LIST_SIZE=uint32(512),
POOL_SUB_SLOT_ITERS=uint64(37600000000),
SOFT_FORK5_HEIGHT=uint32(0),
SOFT_FORK6_HEIGHT=uint32(0),
HARD_FORK_HEIGHT=uint32(5496000),
PLOT_FILTER_128_HEIGHT=uint32(10542000),
PLOT_FILTER_64_HEIGHT=uint32(15592000),
Expand Down
6 changes: 3 additions & 3 deletions wheel/python/chia_rs/chia_rs.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -4176,7 +4176,7 @@ class ConsensusConstants:
MAX_GENERATOR_SIZE: uint32
MAX_GENERATOR_REF_LIST_SIZE: uint32
POOL_SUB_SLOT_ITERS: uint64
SOFT_FORK5_HEIGHT: uint32
SOFT_FORK6_HEIGHT: uint32
HARD_FORK_HEIGHT: uint32
PLOT_FILTER_128_HEIGHT: uint32
PLOT_FILTER_64_HEIGHT: uint32
Expand Down Expand Up @@ -4224,7 +4224,7 @@ class ConsensusConstants:
MAX_GENERATOR_SIZE: uint32,
MAX_GENERATOR_REF_LIST_SIZE: uint32,
POOL_SUB_SLOT_ITERS: uint64,
SOFT_FORK5_HEIGHT: uint32,
SOFT_FORK6_HEIGHT: uint32,
HARD_FORK_HEIGHT: uint32,
PLOT_FILTER_128_HEIGHT: uint32,
PLOT_FILTER_64_HEIGHT: uint32,
Expand Down Expand Up @@ -4288,7 +4288,7 @@ class ConsensusConstants:
MAX_GENERATOR_SIZE: Union[ uint32, _Unspec] = _Unspec(),
MAX_GENERATOR_REF_LIST_SIZE: Union[ uint32, _Unspec] = _Unspec(),
POOL_SUB_SLOT_ITERS: Union[ uint64, _Unspec] = _Unspec(),
SOFT_FORK5_HEIGHT: Union[ uint32, _Unspec] = _Unspec(),
SOFT_FORK6_HEIGHT: Union[ uint32, _Unspec] = _Unspec(),
HARD_FORK_HEIGHT: Union[ uint32, _Unspec] = _Unspec(),
PLOT_FILTER_128_HEIGHT: Union[ uint32, _Unspec] = _Unspec(),
PLOT_FILTER_64_HEIGHT: Union[ uint32, _Unspec] = _Unspec(),
Expand Down

0 comments on commit 08e7f3b

Please sign in to comment.