Skip to content

fix: simplicity activation when dynafed is active #1438

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ class CMainParams : public CChainParams {
consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].min_activation_height = 709632; // Approximately November 12th, 2021

// Simplicity
consensus.vDeployments[Consensus::DEPLOYMENT_SIMPLICITY].bit = 24;
consensus.vDeployments[Consensus::DEPLOYMENT_SIMPLICITY].bit = 21;
consensus.vDeployments[Consensus::DEPLOYMENT_SIMPLICITY].nStartTime = Consensus::BIP9Deployment::NEVER_ACTIVE;
consensus.vDeployments[Consensus::DEPLOYMENT_SIMPLICITY].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
consensus.vDeployments[Consensus::DEPLOYMENT_SIMPLICITY].min_activation_height = 0; // No activation delay
Expand Down Expand Up @@ -361,7 +361,7 @@ class CTestNetParams : public CChainParams {
consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].min_activation_height = 0; // No activation delay

// Simplicity
consensus.vDeployments[Consensus::DEPLOYMENT_SIMPLICITY].bit = 24;
consensus.vDeployments[Consensus::DEPLOYMENT_SIMPLICITY].bit = 21;
consensus.vDeployments[Consensus::DEPLOYMENT_SIMPLICITY].nStartTime = Consensus::BIP9Deployment::NEVER_ACTIVE;
consensus.vDeployments[Consensus::DEPLOYMENT_SIMPLICITY].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
consensus.vDeployments[Consensus::DEPLOYMENT_SIMPLICITY].min_activation_height = 0; // No activation delay
Expand Down Expand Up @@ -527,7 +527,7 @@ class SigNetParams : public CChainParams {
consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].min_activation_height = 0; // No activation delay

// Simplicity
consensus.vDeployments[Consensus::DEPLOYMENT_SIMPLICITY].bit = 24;
consensus.vDeployments[Consensus::DEPLOYMENT_SIMPLICITY].bit = 21;
consensus.vDeployments[Consensus::DEPLOYMENT_SIMPLICITY].nStartTime = Consensus::BIP9Deployment::NEVER_ACTIVE;
consensus.vDeployments[Consensus::DEPLOYMENT_SIMPLICITY].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
consensus.vDeployments[Consensus::DEPLOYMENT_SIMPLICITY].min_activation_height = 0; // No activation delay
Expand Down Expand Up @@ -626,7 +626,7 @@ class CRegTestParams : public CChainParams {
consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].nThreshold = 128;

// Simplicity
consensus.vDeployments[Consensus::DEPLOYMENT_SIMPLICITY].bit = 24;
consensus.vDeployments[Consensus::DEPLOYMENT_SIMPLICITY].bit = 21;
consensus.vDeployments[Consensus::DEPLOYMENT_SIMPLICITY].nStartTime = Consensus::BIP9Deployment::NEVER_ACTIVE;
consensus.vDeployments[Consensus::DEPLOYMENT_SIMPLICITY].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
consensus.vDeployments[Consensus::DEPLOYMENT_SIMPLICITY].min_activation_height = 0; // No activation delay
Expand Down Expand Up @@ -1288,7 +1288,7 @@ class CLiquidV1Params : public CChainParams {
consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].nThreshold = 10080; // ...of 100% signalling

// Simplicity
consensus.vDeployments[Consensus::DEPLOYMENT_SIMPLICITY].bit = 24;
consensus.vDeployments[Consensus::DEPLOYMENT_SIMPLICITY].bit = 21;
consensus.vDeployments[Consensus::DEPLOYMENT_SIMPLICITY].nStartTime = Consensus::BIP9Deployment::NEVER_ACTIVE;
consensus.vDeployments[Consensus::DEPLOYMENT_SIMPLICITY].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
consensus.vDeployments[Consensus::DEPLOYMENT_SIMPLICITY].min_activation_height = 0; // No activation delay
Expand Down
23 changes: 12 additions & 11 deletions test/functional/feature_elements_simplicity_activation.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class SimplicityActivationTest(BitcoinTestFramework):
def set_test_params(self):
self.setup_clean_chain = True
self.num_nodes = 1
self.extra_args = [["-evbparams=dynafed:0:::"]]

def skip_test_if_missing_module(self):
self.skip_if_no_wallet()
Expand All @@ -36,8 +37,8 @@ def test_activation(self, rpc, activation_height):
if n < 143:
assert_equal (decode["versionHex"], "20000000")
elif n < 431:
# TESTDUMMY deployment: 144 blocks active, 144 blocks locked in
assert_equal (decode["versionHex"], "30000000")
# TESTDUMMY and DYNAFED deployment: 144 blocks active, 144 blocks locked in
assert_equal (decode["versionHex"], "32000000")
else:
assert_equal (decode["versionHex"], "20000000")

Expand All @@ -52,38 +53,38 @@ def test_activation(self, rpc, activation_height):
blocks = self.generatetoaddress(rpc, 127, rpc.getnewaddress())
for n, block in enumerate(blocks):
decode = rpc.getblockheader(block)
assert_equal (decode["versionHex"], "21000000")
assert_equal (decode["versionHex"], "20200000")
assert_equal(rpc.getdeploymentinfo()["deployments"]["simplicity"]["bip9"]["status"], "started")

# Fail to signal on the 128th block. Since the threshold for Simplicity is
# 100% this will prevent activation. Note that our period is 128, not
# 144 (the default), as we have overridden the period for Simplicity. On
# the main Liquid chain it is overridden to be one week of signalling.
block = rpc.getnewblockhex()
block = block[:7] + "0" + block[8:] # turn off Simplicity signal
block = block[:4] + "0" + block[5:] # turn off Simplicity signal
rpc.submitblock(block)
assert_equal(rpc.getdeploymentinfo()["deployments"]["simplicity"]["bip9"]["status"], "started")

# Run through another 128 blocks, without failing to signal
blocks = self.generatetoaddress(rpc, 127, rpc.getnewaddress())
for n, block in enumerate(blocks):
decode = rpc.getblockheader(block)
assert_equal (decode["versionHex"], "21000000")
assert_equal (decode["versionHex"], "20200000")
assert_equal(rpc.getdeploymentinfo()["deployments"]["simplicity"]["bip9"]["status"], "started")
# The 128th block then switches from "started" to "locked_in"
blocks = self.generatetoaddress(rpc, 1, rpc.getnewaddress())
assert_equal(rpc.getdeploymentinfo()["deployments"]["simplicity"]["bip9"]["status"], "started")
assert_equal(rpc.getdeploymentinfo()["deployments"]["simplicity"]["bip9"]["status_next"], "locked_in")
assert_equal(rpc.getblockheader(blocks[0])["versionHex"], "21000000")
assert_equal(rpc.getblockheader(blocks[0])["versionHex"], "20200000")

# Run through another 128 blocks, which will go from "locked in" to "active" regardless of signalling
blocks = self.generatetoaddress(rpc, 127, rpc.getnewaddress())
for n, block in enumerate(blocks):
decode = rpc.getblockheader(block)
assert_equal (decode["versionHex"], "21000000")
assert_equal (decode["versionHex"], "20200000")
assert_equal(rpc.getdeploymentinfo()["deployments"]["simplicity"]["bip9"]["status"], "locked_in")
block = rpc.getnewblockhex()
block = block[:7] + "0" + block[8:] # turn off Simplicity signal
block = block[:4] + "0" + block[5:] # turn off Simplicity signal
rpc.submitblock(block)
assert_equal(rpc.getdeploymentinfo()["deployments"]["simplicity"]["bip9"]["status"], "locked_in")
assert_equal(rpc.getdeploymentinfo()["deployments"]["simplicity"]["bip9"]["status_next"], "active")
Expand All @@ -103,15 +104,15 @@ def run_test(self):
if n < 143:
assert_equal (decode["versionHex"], "20000000")
elif n < 431:
# TESTDUMMY deployment: 144 blocks active, 144 blocks locked in
assert_equal (decode["versionHex"], "30000000")
# TESTDUMMY and DYNAFED deployment: 144 blocks active, 144 blocks locked in
assert_equal (decode["versionHex"], "32000000")
else:
assert_equal (decode["versionHex"], "20000000")

# Test activation starting from height 1000
# Note that for Simplicity this is an illogical combination (Simplicity without
# Taproot) but for purposes of this test it's fine.
self.restart_node(0, ["-evbparams=simplicity:500:::"])
self.restart_node(0, ["-evbparams=dynafed:0:::", "-evbparams=simplicity:500:::"])
self.nodes[0].invalidateblock(self.nodes[0].getblockhash(1))
self.test_activation(self.nodes[0], 500)

Expand Down