Skip to content

Commit

Permalink
Add deployment info for TXHASH
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenroose committed Mar 28, 2024
1 parent d7eac66 commit c3edafb
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/consensus/params.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ enum DeploymentPos : uint16_t {
DEPLOYMENT_TESTDUMMY,
DEPLOYMENT_CHECKTEMPLATEVERIFY, // Deployment of CTV (BIP 119)
DEPLOYMENT_ANYPREVOUT,
DEPLOYMENT_TXHASH, // Deployment of TXHASH/CHECKTXHASHVERIFY
// 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 @@ -19,6 +19,10 @@ const struct VBDeploymentInfo VersionBitsDeploymentInfo[Consensus::MAX_VERSION_B
/*.name =*/ "checktemplateverify",
/*.gbt_force =*/ true,
},
{
/*.name =*/ "txhash",
/*.gbt_force =*/ true,
},
{
/*.name =*/ "anyprevout",
/*.gbt_force =*/ true,
Expand Down
9 changes: 9 additions & 0 deletions src/kernel/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ class CMainParams : public CChainParams {
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY] = SetupDeployment{.activate = 0x30000000, .abandon = 0, .never = true};
consensus.vDeployments[Consensus::DEPLOYMENT_CHECKTEMPLATEVERIFY] = SetupDeployment{.activate = 0x60007700, .abandon = 0x40007700, .never = true};
consensus.vDeployments[Consensus::DEPLOYMENT_ANYPREVOUT] = SetupDeployment{.activate = 0x60007600, .abandon = 0x40007600, .never = true};
consensus.vDeployments[Consensus::DEPLOYMENT_TXHASH] = SetupDeployment{.activate = 0x60007700, .abandon = 0x40007700, .never = true};

consensus.nMinimumChainWork = uint256S("0x000000000000000000000000000000000000000044a50fe819c39ad624021859");
consensus.defaultAssumeValid = uint256S("0x000000000000000000035c3f0d31e71a5ee24c5aaf3354689f65bd7b07dee632"); // 784000
Expand Down Expand Up @@ -246,6 +247,7 @@ class CTestNetParams : public CChainParams {
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY] = SetupDeployment{.activate = 0x30000000, .abandon = 0, .never = true};
consensus.vDeployments[Consensus::DEPLOYMENT_CHECKTEMPLATEVERIFY] = SetupDeployment{.activate = 0x60007700, .abandon = 0x40007700, .never = true};
consensus.vDeployments[Consensus::DEPLOYMENT_ANYPREVOUT] = SetupDeployment{.activate = 0x60007600, .abandon = 0x40007600, .never = true};
consensus.vDeployments[Consensus::DEPLOYMENT_TXHASH] = SetupDeployment{.activate = 0x60007700, .abandon = 0x40007700, .never = true};

consensus.nMinimumChainWork = uint256S("0x000000000000000000000000000000000000000000000977edb0244170858d07");
consensus.defaultAssumeValid = uint256S("0x0000000000000021bc50a89cde4870d4a81ffe0153b3c8de77b435a2fd3f6761"); // 2429000
Expand Down Expand Up @@ -394,6 +396,12 @@ class SigNetParams : public CChainParams {
.activate = 0x60007600,
.abandon = 0x40007600,
};
consensus.vDeployments[Consensus::DEPLOYMENT_TXHASH] = SetupDeployment{
.start = 1654041600, // 2022-06-01
.timeout = 1969660800, // 2032-06-01
.activate = 0x60007700,
.abandon = 0x40007700,
};

RenounceDeployments(options.renounce, consensus.vDeployments);

Expand Down Expand Up @@ -461,6 +469,7 @@ class CRegTestParams : public CChainParams
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY] = SetupDeployment{.start = 0, .timeout = Consensus::HereticalDeployment::NO_TIMEOUT, .activate = 0x30000000, .abandon = 0x50000000};
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_TXHASH] = SetupDeployment{.activate = 0x60007700, .abandon = 0x40007700, .always = true};

consensus.nMinimumChainWork = uint256{};
consensus.defaultAssumeValid = uint256{};
Expand Down
1 change: 1 addition & 0 deletions src/rpc/blockchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1339,6 +1339,7 @@ UniValue DeploymentInfo(const CBlockIndex* blockindex, const ChainstateManager&
SoftForkDescPushBack(blockindex, softforks, chainman, Consensus::DEPLOYMENT_TAPROOT);
SoftForkDescPushBack(blockindex, softforks, chainman, Consensus::DEPLOYMENT_CHECKTEMPLATEVERIFY);
SoftForkDescPushBack(blockindex, softforks, chainman, Consensus::DEPLOYMENT_ANYPREVOUT);
SoftForkDescPushBack(blockindex, softforks, chainman, Consensus::DEPLOYMENT_TXHASH);
return softforks;
}
} // anon namespace
Expand Down
6 changes: 4 additions & 2 deletions src/script/interpreter.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,12 @@ enum : uint32_t {
// Making ANYPREVOUT public key versions (in BIP 342 scripts) non-standard
SCRIPT_VERIFY_DISCOURAGE_ANYPREVOUT = (1U << 25),

// Support OP_TXHASH and OP_CHECKTXHASHVERIFY.
//
// Support OP_TXHASH and OP_CHECKTXHASHVERIFY for standard template
SCRIPT_VERIFY_TXHASH = (1U << 26),

// discourage OP_TXHASH and OP_CHECKTXHASHVERIFY
SCRIPT_VERIFY_DISCOURAGE_TXHASH = (1U << 27),

// Constants to point to the highest flag in use. Add new flags above this line.
//
SCRIPT_VERIFY_END_MARKER
Expand Down
7 changes: 7 additions & 0 deletions src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1008,9 +1008,11 @@ bool MemPoolAccept::PolicyScriptChecks(const ATMPArgs& args, Workspace& ws)
TxValidationState& state = ws.m_state;

const bool ctv_active = DeploymentActiveAfter(m_active_chainstate.m_chain.Tip(), m_active_chainstate.m_chainman, Consensus::DEPLOYMENT_CHECKTEMPLATEVERIFY);
const bool txh_active = DeploymentActiveAfter(m_active_chainstate.m_chain.Tip(), m_active_chainstate.m_chainman, Consensus::DEPLOYMENT_TXHASH);
const bool apo_active = DeploymentActiveAfter(m_active_chainstate.m_chain.Tip(), m_active_chainstate.m_chainman, Consensus::DEPLOYMENT_ANYPREVOUT);
const unsigned int scriptVerifyFlags = STANDARD_SCRIPT_VERIFY_FLAGS
| (ctv_active ? SCRIPT_VERIFY_NONE : SCRIPT_VERIFY_DISCOURAGE_CHECK_TEMPLATE_VERIFY_HASH)
| (txh_active ? SCRIPT_VERIFY_NONE : SCRIPT_VERIFY_DISCOURAGE_TXHASH)
| (apo_active ? SCRIPT_VERIFY_NONE : SCRIPT_VERIFY_DISCOURAGE_ANYPREVOUT);

// Check input scripts and signatures.
Expand Down Expand Up @@ -2020,6 +2022,11 @@ unsigned int GetBlockScriptFlags(const CBlockIndex& block_index, const Chainstat
flags |= SCRIPT_VERIFY_ANYPREVOUT;
}

// Enforce TXHASH
if (DeploymentActiveAt(block_index, chainman, Consensus::DEPLOYMENT_TXHASH)) {
flags |= SCRIPT_VERIFY_TXHASH;
}

return flags;
}

Expand Down
17 changes: 16 additions & 1 deletion test/functional/rpc_blockchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,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,P2SH,TAPROOT,WITNESS",
"script_flags": "ANYPREVOUT,CHECKLOCKTIMEVERIFY,CHECKSEQUENCEVERIFY,DEFAULT_CHECK_TEMPLATE_VERIFY_HASH,DERSIG,NULLDUMMY,P2SH,TAPROOT,TXHASH,WITNESS",
"deployments": {
'bip34': {'type': 'buried', 'active': True, 'height': 2},
'bip66': {'type': 'buried', 'active': True, 'height': 3},
Expand Down Expand Up @@ -235,6 +235,21 @@ def check_signalling_deploymentinfo_result(self, gdi_result, height, blockhash):
'height': 0,
'active': True
},
'txhash': {
'type': 'heretical',
'heretical': {
'bip': 118,
'bip_version': 0,
'start_time': -1,
'timeout': 9223372036854775807,
'period': 144,
'status': 'active',
'status_next': 'active',
'since': 0,
},
'height': 0,
'active': True
},
'anyprevout': {
'type': 'heretical',
'heretical': {
Expand Down

0 comments on commit c3edafb

Please sign in to comment.