Skip to content

Commit

Permalink
consensus: add BIN-2024-000[34] deployment params
Browse files Browse the repository at this point in the history
Activates OP_CHECKSIGFROMSTACK, OP_CHECKSIGFROMSTACKVERIFY, and
OP_INTERNALKEY on regtest and signet.

always active on regtest
active from 2024-01-12 until 2034-01-12 on signet
never active on testnet, mainnet
  • Loading branch information
reardencode committed Jul 12, 2024
1 parent 6e60cf2 commit 455c56b
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/consensus/params.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ enum DeploymentPos : uint16_t {
DEPLOYMENT_CHECKTEMPLATEVERIFY, // Deployment of CTV (BIP 119)
DEPLOYMENT_ANYPREVOUT,
DEPLOYMENT_OP_CAT,
DEPLOYMENT_CHECKSIGFROMSTACK, // Deployment of OP_CHECKSIGFROMSTACK(VERIFY)
DEPLOYMENT_INTERNALKEY, // Deployment of OP_INTERNALKEY
// NOTE: Also add new deployments to VersionBitsDeploymentInfo in deploymentinfo.cpp
MAX_VERSION_BITS_DEPLOYMENTS
};
Expand Down
4 changes: 4 additions & 0 deletions src/deploymentinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ const struct VBDeploymentInfo VersionBitsDeploymentInfo[Consensus::MAX_VERSION_B
/*.name =*/ "opcat",
/*.gbt_force =*/ true,
},
{
/*.name =*/ "lnhance",
/*.gbt_force =*/ true,
},
};

std::string DeploymentName(Consensus::BuriedDeployment dep)
Expand Down
28 changes: 28 additions & 0 deletions src/kernel/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,11 @@ class CMainParams : public CChainParams {

consensus.nMinimumChainWork = uint256S("0x000000000000000000000000000000000000000063c4ebd298db40af57541800");
consensus.defaultAssumeValid = uint256S("0x000000000000000000026811d149d4d261995ec5b3f64f439a0a10e1a464af9a"); // 824000
consensus.vDeployments[Consensus::DEPLOYMENT_CHECKSIGFROMSTACK] = SetupDeployment{.year = 2024, .number = 3, .revision = 1, .never = true};
consensus.vDeployments[Consensus::DEPLOYMENT_INTERNALKEY] = SetupDeployment{.year = 2024, .number = 4, .revision = 1, .never = true};

consensus.nMinimumChainWork = uint256S("0x000000000000000000000000000000000000000044a50fe819c39ad624021859");
consensus.defaultAssumeValid = uint256S("0x000000000000000000035c3f0d31e71a5ee24c5aaf3354689f65bd7b07dee632"); // 784000

/**
* The message start string is designed to be unlikely to occur in normal data.
Expand Down Expand Up @@ -250,6 +255,11 @@ class CTestNetParams : public CChainParams {

consensus.nMinimumChainWork = uint256S("0x000000000000000000000000000000000000000000000c59b14e264ba6c15db9");
consensus.defaultAssumeValid = uint256S("0x000000000001323071f38f21ea5aae529ece491eadaccce506a59bcc2d968917"); // 2550000
consensus.vDeployments[Consensus::DEPLOYMENT_CHECKSIGFROMSTACK] = SetupDeployment{.year = 2024, .number = 3, .revision = 1, .never = true};
consensus.vDeployments[Consensus::DEPLOYMENT_INTERNALKEY] = SetupDeployment{.year = 2024, .number = 4, .revision = 1, .never = true};

consensus.nMinimumChainWork = uint256S("0x000000000000000000000000000000000000000000000977edb0244170858d07");
consensus.defaultAssumeValid = uint256S("0x0000000000000021bc50a89cde4870d4a81ffe0153b3c8de77b435a2fd3f6761"); // 2429000

pchMessageStart[0] = 0x0b;
pchMessageStart[1] = 0x11;
Expand Down Expand Up @@ -397,6 +407,20 @@ class SigNetParams : public CChainParams {
.activate = 0x62000100,
.abandon = 0x42000100,
};
consensus.vDeployments[Consensus::DEPLOYMENT_CHECKSIGFROMSTACK] = SetupDeployment{
.year = 2024,
.number = 3,
.revision = 1,
.start = 1705046400, // 2024-01-12
.timeout = 2020665600, // 2034-01-12
};
consensus.vDeployments[Consensus::DEPLOYMENT_INTERNALKEY] = SetupDeployment{
.year = 2024,
.number = 4,
.revision = 1,
.start = 1705046400, // 2024-01-12
.timeout = 2020665600, // 2034-01-12
};

RenounceDeployments(options.renounce, consensus.vDeployments);

Expand Down Expand Up @@ -472,6 +496,10 @@ class CRegTestParams : public CChainParams
consensus.vDeployments[Consensus::DEPLOYMENT_CHECKTEMPLATEVERIFY] = SetupDeployment{.activate = 0x60007700, .abandon = 0x40007700, .always = true};
consensus.vDeployments[Consensus::DEPLOYMENT_ANYPREVOUT] = SetupDeployment{.activate = 0x60007600, .abandon = 0x40007600, .always = true};
consensus.vDeployments[Consensus::DEPLOYMENT_OP_CAT] = SetupDeployment{.activate = 0x62000100, .abandon = 0x42000100, .always = true};

consensus.vDeployments[Consensus::DEPLOYMENT_CHECKSIGFROMSTACK] = SetupDeployment{.year = 2024, .number = 3, .revision = 1, .always = true};
consensus.vDeployments[Consensus::DEPLOYMENT_INTERNALKEY] = SetupDeployment{.year = 2024, .number = 4, .revision = 1, .always = true};

consensus.nMinimumChainWork = uint256{};
consensus.defaultAssumeValid = uint256{};

Expand Down
2 changes: 2 additions & 0 deletions src/rpc/blockchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1334,6 +1334,8 @@ UniValue DeploymentInfo(const CBlockIndex* blockindex, const ChainstateManager&
SoftForkDescPushBack(blockindex, softforks, chainman, Consensus::DEPLOYMENT_CHECKTEMPLATEVERIFY);
SoftForkDescPushBack(blockindex, softforks, chainman, Consensus::DEPLOYMENT_ANYPREVOUT);
SoftForkDescPushBack(blockindex, softforks, chainman, Consensus::DEPLOYMENT_OP_CAT);
SoftForkDescPushBack(blockindex, softforks, chainman, Consensus::DEPLOYMENT_CHECKSIGFROMSTACK);
SoftForkDescPushBack(blockindex, softforks, chainman, Consensus::DEPLOYMENT_INTERNALKEY);
return softforks;
}
} // anon namespace
Expand Down
12 changes: 12 additions & 0 deletions src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1067,6 +1067,8 @@ bool MemPoolAccept::PolicyScriptChecks(const ATMPArgs& args, Workspace& ws)
{ Consensus::DEPLOYMENT_CHECKTEMPLATEVERIFY, SCRIPT_VERIFY_DISCOURAGE_CHECK_TEMPLATE_VERIFY_HASH },
{ Consensus::DEPLOYMENT_ANYPREVOUT, SCRIPT_VERIFY_DISCOURAGE_ANYPREVOUT },
{ Consensus::DEPLOYMENT_OP_CAT, SCRIPT_VERIFY_DISCOURAGE_OP_CAT },
{ Consensus::DEPLOYMENT_INTERNALKEY, SCRIPT_VERIFY_DISCOURAGE_INTERNALKEY },
{ Consensus::DEPLOYMENT_CHECKSIGFROMSTACK, SCRIPT_VERIFY_DISCOURAGE_CHECKSIGFROMSTACK },
});

// Check input scripts and signatures.
Expand Down Expand Up @@ -2172,6 +2174,16 @@ unsigned int GetBlockScriptFlags(const CBlockIndex& block_index, const Chainstat
flags |= SCRIPT_VERIFY_OP_CAT;
}

// Enforce CHECKSIGFROMSTACK(VERIFY) (BIN-2024-0003)
if (DeploymentActiveAt(block_index, chainman, Consensus::DEPLOYMENT_CHECKSIGFROMSTACK)) {
flags |= SCRIPT_VERIFY_CHECKSIGFROMSTACK;
}

// Process INTERNALKEY (BIN-2024-0004)
if (DeploymentActiveAt(block_index, chainman, Consensus::DEPLOYMENT_INTERNALKEY)) {
flags |= SCRIPT_VERIFY_INTERNALKEY;
}

return flags;
}

Expand Down
34 changes: 33 additions & 1 deletion test/functional/rpc_blockchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ def check_signalling_deploymentinfo_result(self, gdi_result, height, blockhash):
assert_equal(gdi_result, {
"hash": blockhash,
"height": height,
"script_flags": ["ANYPREVOUT","CHECKLOCKTIMEVERIFY","CHECKSEQUENCEVERIFY","DEFAULT_CHECK_TEMPLATE_VERIFY_HASH","DERSIG","NULLDUMMY","OP_CAT","P2SH","TAPROOT","WITNESS"],
"script_flags": ["ANYPREVOUT","CHECKLOCKTIMEVERIFY","CHECKSEQUENCEVERIFY","DEFAULT_CHECK_TEMPLATE_VERIFY_HASH","DERSIG","NULLDUMMY","OP_CAT","LNHANCE","P2SH","TAPROOT","WITNESS"],
"deployments": {
'bip34': {'type': 'buried', 'active': True, 'height': 2},
'bip66': {'type': 'buried', 'active': True, 'height': 3},
Expand Down Expand Up @@ -261,6 +261,38 @@ def check_signalling_deploymentinfo_result(self, gdi_result, height, blockhash):
'height': 0,
'active': True,
},
'checksigfromstack': {
'type': 'heretical',
'heretical': {
'year': 2024,
'number': 3,
'revision': 1,
'start_time': -1,
'timeout': 0x7fffffffffffffff, # testdummy does not have a timeout so is set to the max int64 value
'period': 144,
'status': 'active',
'status_next': 'active',
'since': 0,
},
'active': True,
'height': 0,
},
'internalkey': {
'type': 'heretical',
'heretical': {
'year': 2024,
'number': 4,
'revision': 1,
'start_time': -1,
'timeout': 0x7fffffffffffffff, # testdummy does not have a timeout so is set to the max int64 value
'period': 144,
'status': 'active',
'status_next': 'active',
'since': 0,
},
'active': True,
'height': 0,
},
}
})

Expand Down

0 comments on commit 455c56b

Please sign in to comment.