Skip to content

Commit

Permalink
Merge pull request #998 from toxeus/master
Browse files Browse the repository at this point in the history
Parametrize first batch of fork constants.
  • Loading branch information
toxeus committed Jul 19, 2018
2 parents 49df918 + 5d02837 commit c0088fd
Show file tree
Hide file tree
Showing 6 changed files with 146 additions and 108 deletions.
10 changes: 6 additions & 4 deletions include/bitcoin/bitcoin/chain/chain_state.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,9 @@ class BC_API chain_state

/// Checkpoints must be ordered by height with greatest at back.
static map get_map(size_t height, const checkpoints& checkpoints,
uint32_t forks, size_t retargeting_interval);
uint32_t forks, size_t retargeting_interval, size_t net_sample);

static uint32_t signal_version(uint32_t forks);
static uint32_t signal_version(uint32_t forks, const settings& settings);

/// Create pool state from top chain top block state.
chain_state(const chain_state& top, const settings& settings);
Expand Down Expand Up @@ -185,15 +185,17 @@ class BC_API chain_state
uint32_t maximum_transaction_version;
};

static activations activation(const data& values, uint32_t forks);
static activations activation(const data& values, uint32_t forks,
const settings& settings);
static uint32_t median_time_past(const data& values, uint32_t forks);
static uint32_t work_required(const data& values, uint32_t forks,
const settings& settings);

private:
static size_t bits_count(size_t height, uint32_t forks,
size_t retargeting_interval);
static size_t version_count(size_t height, uint32_t forks);
static size_t version_count(size_t height, uint32_t forks,
size_t net_sample);
static size_t timestamp_count(size_t height, uint32_t forks);
static size_t retarget_height(size_t height, uint32_t forks,
size_t retargeting_interval);
Expand Down
32 changes: 0 additions & 32 deletions include/bitcoin/bitcoin/constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,47 +98,15 @@ BC_CONSTEXPR uint32_t relative_locktime_time_locked = 0x00400000;
// Fork constants.
//-----------------------------------------------------------------------------

// Consensus rule change activation and enforcement parameters.
BC_CONSTEXPR uint32_t first_version = 1;
BC_CONSTEXPR uint32_t bip34_version = 2;
BC_CONSTEXPR uint32_t bip66_version = 3;
BC_CONSTEXPR uint32_t bip65_version = 4;
BC_CONSTEXPR uint32_t bip9_version_bit0 = 1u << 0;
BC_CONSTEXPR uint32_t bip9_version_bit1 = 1u << 1;
BC_CONSTEXPR uint32_t bip9_version_base = 0x20000000;

// Mainnet activation parameters (bip34-style activations).
BC_CONSTEXPR size_t mainnet_active = 750;
BC_CONSTEXPR size_t mainnet_enforce = 950;
BC_CONSTEXPR size_t mainnet_sample = 1000;

// Testnet activation parameters (bip34-style activations).
BC_CONSTEXPR size_t testnet_active = 51;
BC_CONSTEXPR size_t testnet_enforce = 75;
BC_CONSTEXPR size_t testnet_sample = 100;

// Mainnet frozen activation heights (frozen_activations).
BC_CONSTEXPR size_t mainnet_bip65_freeze = 388381;
BC_CONSTEXPR size_t mainnet_bip66_freeze = 363725;
BC_CONSTEXPR size_t mainnet_bip34_freeze = 227931;

// Testnet frozen activation heights (frozen_activations).
BC_CONSTEXPR size_t testnet_bip65_freeze = 581885;
BC_CONSTEXPR size_t testnet_bip66_freeze = 330776;
BC_CONSTEXPR size_t testnet_bip34_freeze = 21111;

// Regtest (arbitrary) frozen activation heights (frozen_activations).
BC_CONSTEXPR size_t regtest_bip65_freeze = 1351;
BC_CONSTEXPR size_t regtest_bip66_freeze = 1251;
BC_CONSTEXPR size_t regtest_bip34_freeze = 0;

// Block 514 is the first testnet block after date-based activation.
// Block 173805 is the first mainnet block after date-based activation.
// The first mainnet activation window hardwired in satoshi 0.6.0rc1 failed.
BC_CONSTEXPR uint32_t mainnet_bip16_activation_time = 0x4f779a80;
BC_CONSTEXPR uint32_t testnet_bip16_activation_time = 0x4f3af580;
BC_CONSTEXPR uint32_t regtest_bip16_activation_time = 0x4f3af580;

// github.com/bitcoin/bips/blob/master/bip-0030.mediawiki#specification
static const config::checkpoint mainnet_bip30_exception_checkpoint1
{
Expand Down
26 changes: 26 additions & 0 deletions include/bitcoin/bitcoin/settings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,32 @@ class BC_API settings
size_t retargeting_interval;

chain::block genesis_block;

// Fork settings.
//--------------------------------------------------------------------------

// Consensus rule change activation and enforcement parameters.
uint32_t first_version;
uint32_t bip34_version;
uint32_t bip66_version;
uint32_t bip65_version;
uint32_t bip9_version_bit0;
uint32_t bip9_version_bit1;
uint32_t bip9_version_base;

// Activation parameters (bip34-style activations).
size_t net_active;
size_t net_enforce;
size_t net_sample;

// Frozen activation heights (frozen_activations).
size_t bip65_freeze;
size_t bip66_freeze;

// Block 514 is the first testnet block after date-based activation.
// Block 173805 is the first mainnet block after date-based activation.
// The first mainnet activation window hardwired in satoshi 0.6.0rc1 failed.
uint32_t bip16_activation_time;
};

} // namespace libbitcoin
Expand Down
Loading

0 comments on commit c0088fd

Please sign in to comment.