Skip to content
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

feat: ability to disable clsig creation while retaining clsig enforcement #5398

Merged
merged 3 commits into from May 31, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/llmq/chainlocks.cpp
Expand Up @@ -249,6 +249,10 @@ void CChainLocksHandler::TrySignChainTip()
return;
}

if (!ChainLocksSigningEnabled(spork_manager)) {
return;
}

const CBlockIndex* pindex = WITH_LOCK(cs_main, return ::ChainActive().Tip());

if (pindex->pprev == nullptr) {
Expand Down Expand Up @@ -687,4 +691,9 @@ bool AreChainLocksEnabled(const CSporkManager& sporkManager)
return sporkManager.IsSporkActive(SPORK_19_CHAINLOCKS_ENABLED);
}

bool ChainLocksSigningEnabled(const CSporkManager& sporkManager)
{
return sporkManager.GetSporkValue(SPORK_19_CHAINLOCKS_ENABLED) == 0;
}

} // namespace llmq
1 change: 1 addition & 0 deletions src/llmq/chainlocks.h
Expand Up @@ -128,6 +128,7 @@ class CChainLocksHandler : public CRecoveredSigsListener
extern std::unique_ptr<CChainLocksHandler> chainLocksHandler;

bool AreChainLocksEnabled(const CSporkManager& sporkManager);
bool ChainLocksSigningEnabled(const CSporkManager& sporkManager);

} // namespace llmq

Expand Down
15 changes: 15 additions & 0 deletions test/functional/feature_llmq_chainlocks.py
Expand Up @@ -66,6 +66,21 @@ def run_test(self):
block = self.nodes[0].getblock(self.nodes[0].getblockhash(h))
assert block['chainlock']

# Update spork to SPORK_19_CHAINLOCKS_ENABLED and test its behaviour
self.nodes[0].sporkupdate("SPORK_19_CHAINLOCKS_ENABLED", 1)
self.wait_for_sporks_same()

# Generate new blocks and verify that they are not chainlocked
previous_block_hash = self.nodes[0].getbestblockhash()
for _ in range(2):
self.nodes[0].generate(1)
block_hash = self.nodes[0].getbestblockhash()
PastaPastaPasta marked this conversation as resolved.
Show resolved Hide resolved
self.wait_for_chainlocked_block_all_nodes(block_hash, expected=False)
assert self.nodes[0].getblock(previous_block_hash)["chainlock"]

self.nodes[0].sporkupdate("SPORK_19_CHAINLOCKS_ENABLED", 0)
self.wait_for_sporks_same()

self.log.info("Isolate node, mine on another, and reconnect")
self.isolate_node(0)
node0_mining_addr = self.nodes[0].getnewaddress()
Expand Down
4 changes: 2 additions & 2 deletions test/functional/test_framework/test_framework.py
Expand Up @@ -1513,9 +1513,9 @@ def check_chainlocked_block():
if wait_until(check_chainlocked_block, timeout=timeout, sleep=0.1, do_assert=expected) and not expected:
raise AssertionError("waiting unexpectedly succeeded")

def wait_for_chainlocked_block_all_nodes(self, block_hash, timeout=15):
def wait_for_chainlocked_block_all_nodes(self, block_hash, timeout=15, expected=True):
for node in self.nodes:
self.wait_for_chainlocked_block(node, block_hash, timeout=timeout)
self.wait_for_chainlocked_block(node, block_hash, expected=expected, timeout=timeout)

def wait_for_best_chainlock(self, node, block_hash, timeout=15):
wait_until(lambda: node.getbestchainlock()["blockhash"] == block_hash, timeout=timeout, sleep=0.1)
Expand Down