mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 03:52:49 +01:00
fix(rpc): pass blockhash into TxToJSON
so that getspecialtxes
could show correct instantlock
/chainlock
values (#5774)
## Issue being fixed or feature implemented `instantlock` and `chainlock` are broken in `getspecialtxes` kudos to @thephez for finding the issue ## What was done? pass the hash and also rename the variable to self-describing ## How Has This Been Tested? run `getspecialtxes` on a node with and without the patch ## Breaking Changes `instantlock` and `chainlock` will show actual values and not just `false` all the time now (not sure if that qualifies for "breaking" though) ## Checklist: - [x] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have added or updated relevant unit/integration/functional/e2e tests - [ ] I have made corresponding changes to the documentation - [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_
This commit is contained in:
parent
ee4c27d0b9
commit
3e5a6ef649
4
doc/release-notes-5774.md
Normal file
4
doc/release-notes-5774.md
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
RPC changes
|
||||||
|
-----------
|
||||||
|
|
||||||
|
In `getspecialtxes` `instantlock` and `chainlock` fields were always `false`. They should show actual values now.
|
@ -2462,7 +2462,7 @@ static UniValue getspecialtxes(const JSONRPCRequest& request)
|
|||||||
CTxMemPool& mempool = EnsureMemPool(node);
|
CTxMemPool& mempool = EnsureMemPool(node);
|
||||||
LLMQContext& llmq_ctx = EnsureLLMQContext(node);
|
LLMQContext& llmq_ctx = EnsureLLMQContext(node);
|
||||||
|
|
||||||
uint256 hash(ParseHashV(request.params[0], "blockhash"));
|
uint256 blockhash(ParseHashV(request.params[0], "blockhash"));
|
||||||
|
|
||||||
int nTxType = -1;
|
int nTxType = -1;
|
||||||
if (!request.params[1].isNull()) {
|
if (!request.params[1].isNull()) {
|
||||||
@ -2491,7 +2491,7 @@ static UniValue getspecialtxes(const JSONRPCRequest& request)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const CBlockIndex* pblockindex = chainman.m_blockman.LookupBlockIndex(hash);
|
const CBlockIndex* pblockindex = chainman.m_blockman.LookupBlockIndex(blockhash);
|
||||||
if (!pblockindex) {
|
if (!pblockindex) {
|
||||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found");
|
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found");
|
||||||
}
|
}
|
||||||
@ -2519,7 +2519,7 @@ static UniValue getspecialtxes(const JSONRPCRequest& request)
|
|||||||
case 2 :
|
case 2 :
|
||||||
{
|
{
|
||||||
UniValue objTx(UniValue::VOBJ);
|
UniValue objTx(UniValue::VOBJ);
|
||||||
TxToJSON(*tx, uint256(), mempool, chainman.ActiveChainstate(), *llmq_ctx.clhandler, *llmq_ctx.isman, objTx);
|
TxToJSON(*tx, blockhash, mempool, chainman.ActiveChainstate(), *llmq_ctx.clhandler, *llmq_ctx.isman, objTx);
|
||||||
result.push_back(objTx);
|
result.push_back(objTx);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -40,8 +40,13 @@ class LLMQChainLocksTest(DashTestFramework):
|
|||||||
self.test_coinbase_best_cl(self.nodes[0], expected_cl_in_cb=False)
|
self.test_coinbase_best_cl(self.nodes[0], expected_cl_in_cb=False)
|
||||||
|
|
||||||
# v20 is active, no quorums, no CLs - null CL in CbTx
|
# v20 is active, no quorums, no CLs - null CL in CbTx
|
||||||
self.nodes[0].generate(1)
|
nocl_block_hash = self.nodes[0].generate(1)[0]
|
||||||
self.test_coinbase_best_cl(self.nodes[0], expected_cl_in_cb=True, expected_null_cl=True)
|
self.test_coinbase_best_cl(self.nodes[0], expected_cl_in_cb=True, expected_null_cl=True)
|
||||||
|
cbtx = self.nodes[0].getspecialtxes(nocl_block_hash, 5, 1, 0, 2)[0]
|
||||||
|
assert_equal(cbtx["instantlock"], False)
|
||||||
|
assert_equal(cbtx["instantlock_internal"], False)
|
||||||
|
assert_equal(cbtx["chainlock"], False)
|
||||||
|
|
||||||
|
|
||||||
self.nodes[0].sporkupdate("SPORK_17_QUORUM_DKG_ENABLED", 0)
|
self.nodes[0].sporkupdate("SPORK_17_QUORUM_DKG_ENABLED", 0)
|
||||||
self.wait_for_sporks_same()
|
self.wait_for_sporks_same()
|
||||||
@ -55,6 +60,12 @@ class LLMQChainLocksTest(DashTestFramework):
|
|||||||
self.wait_for_chainlocked_block_all_nodes(self.nodes[0].getbestblockhash())
|
self.wait_for_chainlocked_block_all_nodes(self.nodes[0].getbestblockhash())
|
||||||
self.test_coinbase_best_cl(self.nodes[0])
|
self.test_coinbase_best_cl(self.nodes[0])
|
||||||
|
|
||||||
|
# ChainLock locks all the blocks below it so nocl_block_hash should be locked too
|
||||||
|
cbtx = self.nodes[0].getspecialtxes(nocl_block_hash, 5, 1, 0, 2)[0]
|
||||||
|
assert_equal(cbtx["instantlock"], True)
|
||||||
|
assert_equal(cbtx["instantlock_internal"], False)
|
||||||
|
assert_equal(cbtx["chainlock"], True)
|
||||||
|
|
||||||
self.log.info("Mine many blocks, wait for chainlock")
|
self.log.info("Mine many blocks, wait for chainlock")
|
||||||
self.nodes[0].generate(20)
|
self.nodes[0].generate(20)
|
||||||
# We need more time here due to 20 blocks being generated at once
|
# We need more time here due to 20 blocks being generated at once
|
||||||
|
Loading…
Reference in New Issue
Block a user