mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-17 13:07:54 +02:00
Enforce PAK checks on dynafed proposals
This commit is contained in:
parent
dce4cecdda
commit
6000752a92
3 changed files with 18 additions and 1 deletions
|
|
@ -61,6 +61,8 @@ public:
|
||||||
**/
|
**/
|
||||||
bool ScriptHasValidPAKProof(const CScript& script, const uint256& genesis_hash, const CPAKList& paklist);
|
bool ScriptHasValidPAKProof(const CScript& script, const uint256& genesis_hash, const CPAKList& paklist);
|
||||||
|
|
||||||
|
CPAKList CreatePAKListFromExtensionSpace(const std::vector<std::vector<unsigned char>>& extension_space);
|
||||||
|
|
||||||
CPAKList GetActivePAKList(const CBlockIndex* pblockindex, const Consensus::Params& params);
|
CPAKList GetActivePAKList(const CBlockIndex* pblockindex, const Consensus::Params& params);
|
||||||
|
|
||||||
bool IsPAKValidOutput(const CTxOut& txout, const CPAKList& paklist);
|
bool IsPAKValidOutput(const CTxOut& txout, const CPAKList& paklist);
|
||||||
|
|
|
||||||
|
|
@ -3524,6 +3524,16 @@ static bool ContextualCheckDynaFedHeader(const CBlockHeader& block, CValidationS
|
||||||
return state.Invalid(false, REJECT_INVALID, "invalid-dyna-fed", "Proposed fedpegscript starts with OP_DEPTH, which is illegal");
|
return state.Invalid(false, REJECT_INVALID, "invalid-dyna-fed", "Proposed fedpegscript starts with OP_DEPTH, which is illegal");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// When enforcing PAK, extension_space must give non-empty PAK list when
|
||||||
|
// the vector itself is non-empty. Otherwise this means there were "junk"
|
||||||
|
// entries
|
||||||
|
if (params.GetEnforcePak()) {
|
||||||
|
if (!proposed.m_extension_space.empty() &&
|
||||||
|
CreatePAKListFromExtensionSpace(proposed.m_extension_space).IsReject()) {
|
||||||
|
return state.Invalid(false, REJECT_INVALID, "invalid-dyna-fed", "Extension space is not list of valid PAK entries");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -133,6 +133,11 @@ class DynaFedTest(BitcoinTestFramework):
|
||||||
assert_raises_rpc_error(-1, "invalid-dyna-fed, proposed signblockscript must be native segwit scriptPubkey", self.nodes[0].getnewblockhex, 0, {"signblockscript":"51", "max_block_witness":100, "fedpegscript":"51", "extension_space":[]})
|
assert_raises_rpc_error(-1, "invalid-dyna-fed, proposed signblockscript must be native segwit scriptPubkey", self.nodes[0].getnewblockhex, 0, {"signblockscript":"51", "max_block_witness":100, "fedpegscript":"51", "extension_space":[]})
|
||||||
assert_raises_rpc_error(-1, "invalid-dyna-fed, proposed signblockscript must be native segwit scriptPubkey", self.nodes[0].getnewblockhex, 0, {"signblockscript":"00"+WSH_OP_TRUE, "max_block_witness":100, "fedpegscript":"51", "extension_space":[]})
|
assert_raises_rpc_error(-1, "invalid-dyna-fed, proposed signblockscript must be native segwit scriptPubkey", self.nodes[0].getnewblockhex, 0, {"signblockscript":"00"+WSH_OP_TRUE, "max_block_witness":100, "fedpegscript":"51", "extension_space":[]})
|
||||||
|
|
||||||
|
# Since we're enforcing PAK, extension space entries *must* be 66 bytes
|
||||||
|
# each 33 of which are serialized compressed pubkeys
|
||||||
|
assert_raises_rpc_error(-1, "invalid-dyna-fed, Extension space is not list of valid PAK entries", self.nodes[0].getnewblockhex, 0, {"signblockscript":WSH_OP_TRUE, "max_block_witness":100, "fedpegscript":"51", "extension_space":["00"]})
|
||||||
|
assert_raises_rpc_error(-1, "invalid-dyna-fed, Extension space is not list of valid PAK entries", self.nodes[0].getnewblockhex, 0, {"signblockscript":WSH_OP_TRUE, "max_block_witness":100, "fedpegscript":"51", "extension_space":["", initial_extension[0]]})
|
||||||
|
|
||||||
def test_no_vote(self):
|
def test_no_vote(self):
|
||||||
self.log.info("Testing no-vote epoch...")
|
self.log.info("Testing no-vote epoch...")
|
||||||
go_to_epoch_end(self.nodes[0])
|
go_to_epoch_end(self.nodes[0])
|
||||||
|
|
@ -360,7 +365,7 @@ class DynaFedTest(BitcoinTestFramework):
|
||||||
|
|
||||||
# Now have node 1 transition to new pak and fedpegscript
|
# Now have node 1 transition to new pak and fedpegscript
|
||||||
pak_prop["fedpegscript"] = "52"
|
pak_prop["fedpegscript"] = "52"
|
||||||
pak_prop["extension_space"] = ["deadbeef"]
|
pak_prop["extension_space"] = initial_extension
|
||||||
for _ in range(10):
|
for _ in range(10):
|
||||||
raw_pool = self.nodes[0].getrawmempool()
|
raw_pool = self.nodes[0].getrawmempool()
|
||||||
assert claim_id in raw_pool
|
assert claim_id in raw_pool
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue