Skip to content

Commit 3e5a6ef

Browse files
UdjinM6PastaPastaPasta
authored andcommitted
fix(rpc): pass blockhash into TxToJSON so that getspecialtxes could show correct instantlock/chainlock values (dashpay#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)_
1 parent ee4c27d commit 3e5a6ef

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

doc/release-notes-5774.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
RPC changes
2+
-----------
3+
4+
In `getspecialtxes` `instantlock` and `chainlock` fields were always `false`. They should show actual values now.

src/rpc/blockchain.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2462,7 +2462,7 @@ static UniValue getspecialtxes(const JSONRPCRequest& request)
24622462
CTxMemPool& mempool = EnsureMemPool(node);
24632463
LLMQContext& llmq_ctx = EnsureLLMQContext(node);
24642464

2465-
uint256 hash(ParseHashV(request.params[0], "blockhash"));
2465+
uint256 blockhash(ParseHashV(request.params[0], "blockhash"));
24662466

24672467
int nTxType = -1;
24682468
if (!request.params[1].isNull()) {
@@ -2491,7 +2491,7 @@ static UniValue getspecialtxes(const JSONRPCRequest& request)
24912491
}
24922492
}
24932493

2494-
const CBlockIndex* pblockindex = chainman.m_blockman.LookupBlockIndex(hash);
2494+
const CBlockIndex* pblockindex = chainman.m_blockman.LookupBlockIndex(blockhash);
24952495
if (!pblockindex) {
24962496
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found");
24972497
}
@@ -2519,7 +2519,7 @@ static UniValue getspecialtxes(const JSONRPCRequest& request)
25192519
case 2 :
25202520
{
25212521
UniValue objTx(UniValue::VOBJ);
2522-
TxToJSON(*tx, uint256(), mempool, chainman.ActiveChainstate(), *llmq_ctx.clhandler, *llmq_ctx.isman, objTx);
2522+
TxToJSON(*tx, blockhash, mempool, chainman.ActiveChainstate(), *llmq_ctx.clhandler, *llmq_ctx.isman, objTx);
25232523
result.push_back(objTx);
25242524
break;
25252525
}

test/functional/feature_llmq_chainlocks.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,13 @@ def run_test(self):
4040
self.test_coinbase_best_cl(self.nodes[0], expected_cl_in_cb=False)
4141

4242
# v20 is active, no quorums, no CLs - null CL in CbTx
43-
self.nodes[0].generate(1)
43+
nocl_block_hash = self.nodes[0].generate(1)[0]
4444
self.test_coinbase_best_cl(self.nodes[0], expected_cl_in_cb=True, expected_null_cl=True)
45+
cbtx = self.nodes[0].getspecialtxes(nocl_block_hash, 5, 1, 0, 2)[0]
46+
assert_equal(cbtx["instantlock"], False)
47+
assert_equal(cbtx["instantlock_internal"], False)
48+
assert_equal(cbtx["chainlock"], False)
49+
4550

4651
self.nodes[0].sporkupdate("SPORK_17_QUORUM_DKG_ENABLED", 0)
4752
self.wait_for_sporks_same()
@@ -55,6 +60,12 @@ def run_test(self):
5560
self.wait_for_chainlocked_block_all_nodes(self.nodes[0].getbestblockhash())
5661
self.test_coinbase_best_cl(self.nodes[0])
5762

63+
# ChainLock locks all the blocks below it so nocl_block_hash should be locked too
64+
cbtx = self.nodes[0].getspecialtxes(nocl_block_hash, 5, 1, 0, 2)[0]
65+
assert_equal(cbtx["instantlock"], True)
66+
assert_equal(cbtx["instantlock_internal"], False)
67+
assert_equal(cbtx["chainlock"], True)
68+
5869
self.log.info("Mine many blocks, wait for chainlock")
5970
self.nodes[0].generate(20)
6071
# We need more time here due to 20 blocks being generated at once

0 commit comments

Comments
 (0)