mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-13 12:33:42 +02:00
s/m_dyna_params/m_dynafed_params/
This commit is contained in:
parent
6ed63c1fb3
commit
dddc040aa0
9 changed files with 31 additions and 31 deletions
|
|
@ -47,7 +47,7 @@ static bool CheckProofGeneric(const CBlockHeader& block, const uint32_t max_bloc
|
||||||
bool CheckProof(const CBlockHeader& block, const Consensus::Params& params)
|
bool CheckProof(const CBlockHeader& block, const Consensus::Params& params)
|
||||||
{
|
{
|
||||||
if (g_signed_blocks) {
|
if (g_signed_blocks) {
|
||||||
const DynaFedParams& dynafed_params = block.m_dyna_params;
|
const DynaFedParams& dynafed_params = block.m_dynafed_params;
|
||||||
if (dynafed_params.IsNull()) {
|
if (dynafed_params.IsNull()) {
|
||||||
return CheckProofGeneric(block, params.max_block_signature_size, params.signblockscript, block.proof.solution, CScriptWitness());
|
return CheckProofGeneric(block, params.max_block_signature_size, params.signblockscript, block.proof.solution, CScriptWitness());
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -60,7 +60,7 @@ bool CheckProof(const CBlockHeader& block, const Consensus::Params& params)
|
||||||
|
|
||||||
bool CheckProofSignedParent(const CBlockHeader& block, const Consensus::Params& params)
|
bool CheckProofSignedParent(const CBlockHeader& block, const Consensus::Params& params)
|
||||||
{
|
{
|
||||||
const DynaFedParams& dynafed_params = block.m_dyna_params;
|
const DynaFedParams& dynafed_params = block.m_dynafed_params;
|
||||||
if (dynafed_params.IsNull()) {
|
if (dynafed_params.IsNull()) {
|
||||||
return CheckProofGeneric(block, params.max_block_signature_size, params.parent_chain_signblockscript, block.proof.solution, CScriptWitness());
|
return CheckProofGeneric(block, params.max_block_signature_size, params.parent_chain_signblockscript, block.proof.solution, CScriptWitness());
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -272,7 +272,7 @@ public:
|
||||||
nBits = block.nBits;
|
nBits = block.nBits;
|
||||||
nNonce = block.nNonce;
|
nNonce = block.nNonce;
|
||||||
proof = block.proof;
|
proof = block.proof;
|
||||||
dynafed_params = block.m_dyna_params;
|
dynafed_params = block.m_dynafed_params;
|
||||||
m_signblock_witness = block.m_signblock_witness;
|
m_signblock_witness = block.m_signblock_witness;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -308,7 +308,7 @@ public:
|
||||||
block.nBits = nBits;
|
block.nBits = nBits;
|
||||||
block.nNonce = nNonce;
|
block.nNonce = nNonce;
|
||||||
block.proof = proof;
|
block.proof = proof;
|
||||||
block.m_dyna_params = dynafed_params;
|
block.m_dynafed_params = dynafed_params;
|
||||||
block.m_signblock_witness = m_signblock_witness;
|
block.m_signblock_witness = m_signblock_witness;
|
||||||
return block;
|
return block;
|
||||||
}
|
}
|
||||||
|
|
@ -480,7 +480,7 @@ public:
|
||||||
block.nBits = nBits;
|
block.nBits = nBits;
|
||||||
block.nNonce = nNonce;
|
block.nNonce = nNonce;
|
||||||
block.proof = proof;
|
block.proof = proof;
|
||||||
block.m_dyna_params = dynafed_params;
|
block.m_dynafed_params = dynafed_params;
|
||||||
return block.GetHash();
|
return block.GetHash();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -153,7 +153,7 @@ std::unique_ptr<CBlockTemplate> BlockAssembler::CreateNewBlock(const CScript& sc
|
||||||
if (IsDynaFedEnabled(pindexPrev, chainparams.GetConsensus())) {
|
if (IsDynaFedEnabled(pindexPrev, chainparams.GetConsensus())) {
|
||||||
DynaFedParamEntry current_params = ComputeNextBlockCurrentParameters(chainActive.Tip(), chainparams.GetConsensus());
|
DynaFedParamEntry current_params = ComputeNextBlockCurrentParameters(chainActive.Tip(), chainparams.GetConsensus());
|
||||||
DynaFedParams block_params(current_params, proposed_entry ? *proposed_entry : DynaFedParamEntry());
|
DynaFedParams block_params(current_params, proposed_entry ? *proposed_entry : DynaFedParamEntry());
|
||||||
pblock->m_dyna_params = block_params;
|
pblock->m_dynafed_params = block_params;
|
||||||
nBlockWeight += ::GetSerializeSize(block_params, PROTOCOL_VERSION)*WITNESS_SCALE_FACTOR;
|
nBlockWeight += ::GetSerializeSize(block_params, PROTOCOL_VERSION)*WITNESS_SCALE_FACTOR;
|
||||||
nBlockWeight += current_params.m_signblock_witness_limit; // Note witness discount
|
nBlockWeight += current_params.m_signblock_witness_limit; // Note witness discount
|
||||||
assert(pblock->proof.IsNull());
|
assert(pblock->proof.IsNull());
|
||||||
|
|
|
||||||
|
|
@ -190,7 +190,7 @@ public:
|
||||||
// Only used pre-dynamic federation
|
// Only used pre-dynamic federation
|
||||||
CProof proof;
|
CProof proof;
|
||||||
// Dynamic federation: Subsumes the proof field
|
// Dynamic federation: Subsumes the proof field
|
||||||
DynaFedParams m_dyna_params;
|
DynaFedParams m_dynafed_params;
|
||||||
CScriptWitness m_signblock_witness;
|
CScriptWitness m_signblock_witness;
|
||||||
|
|
||||||
CBlockHeader()
|
CBlockHeader()
|
||||||
|
|
@ -217,7 +217,7 @@ public:
|
||||||
this->nVersion = ~DYNAFED_HF_MASK & nVersion;
|
this->nVersion = ~DYNAFED_HF_MASK & nVersion;
|
||||||
} else {
|
} else {
|
||||||
nVersion = this->nVersion;
|
nVersion = this->nVersion;
|
||||||
if (!m_dyna_params.IsNull()) {
|
if (!m_dynafed_params.IsNull()) {
|
||||||
nVersion |= DYNAFED_HF_MASK;
|
nVersion |= DYNAFED_HF_MASK;
|
||||||
is_dyna = true;
|
is_dyna = true;
|
||||||
}
|
}
|
||||||
|
|
@ -229,7 +229,7 @@ public:
|
||||||
READWRITE(hashMerkleRoot);
|
READWRITE(hashMerkleRoot);
|
||||||
READWRITE(nTime);
|
READWRITE(nTime);
|
||||||
READWRITE(block_height);
|
READWRITE(block_height);
|
||||||
READWRITE(m_dyna_params);
|
READWRITE(m_dynafed_params);
|
||||||
// We do not serialize witness for hashes, or weight calculation
|
// We do not serialize witness for hashes, or weight calculation
|
||||||
if (!(s.GetType() & SER_GETHASH) && fAllowWitness) {
|
if (!(s.GetType() & SER_GETHASH) && fAllowWitness) {
|
||||||
READWRITE(m_signblock_witness.stack);
|
READWRITE(m_signblock_witness.stack);
|
||||||
|
|
@ -265,7 +265,7 @@ public:
|
||||||
bool IsNull() const
|
bool IsNull() const
|
||||||
{
|
{
|
||||||
if (g_signed_blocks) {
|
if (g_signed_blocks) {
|
||||||
return proof.IsNull() && m_dyna_params.IsNull();
|
return proof.IsNull() && m_dynafed_params.IsNull();
|
||||||
} else {
|
} else {
|
||||||
return (nBits == 0);
|
return (nBits == 0);
|
||||||
}
|
}
|
||||||
|
|
@ -326,7 +326,7 @@ public:
|
||||||
block.nBits = nBits;
|
block.nBits = nBits;
|
||||||
block.nNonce = nNonce;
|
block.nNonce = nNonce;
|
||||||
block.proof = proof;
|
block.proof = proof;
|
||||||
block.m_dyna_params = m_dyna_params;
|
block.m_dynafed_params = m_dynafed_params;
|
||||||
return block;
|
return block;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -182,12 +182,12 @@ UniValue blockToJSON(const CBlock& block, const CBlockIndex* tip, const CBlockIn
|
||||||
result.pushKV("difficulty", GetDifficulty(blockindex));
|
result.pushKV("difficulty", GetDifficulty(blockindex));
|
||||||
result.pushKV("chainwork", blockindex->nChainWork.GetHex());
|
result.pushKV("chainwork", blockindex->nChainWork.GetHex());
|
||||||
} else {
|
} else {
|
||||||
if (block.m_dyna_params.IsNull()) {
|
if (block.m_dynafed_params.IsNull()) {
|
||||||
result.pushKV("signblock_witness_asm", ScriptToAsmStr(blockindex->proof.solution));
|
result.pushKV("signblock_witness_asm", ScriptToAsmStr(blockindex->proof.solution));
|
||||||
result.pushKV("signblock_witness_hex", HexStr(blockindex->proof.solution));
|
result.pushKV("signblock_witness_hex", HexStr(blockindex->proof.solution));
|
||||||
result.pushKV("signblock_challenge", HexStr(blockindex->proof.challenge));
|
result.pushKV("signblock_challenge", HexStr(blockindex->proof.challenge));
|
||||||
} else {
|
} else {
|
||||||
result.pushKV("dynamic_parameters", dynaParamsToJSON(block.m_dyna_params));
|
result.pushKV("dynamic_parameters", dynaParamsToJSON(block.m_dynafed_params));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
result.pushKV("nTx", (uint64_t)blockindex->nTx);
|
result.pushKV("nTx", (uint64_t)blockindex->nTx);
|
||||||
|
|
|
||||||
|
|
@ -144,7 +144,7 @@ UniValue generateBlocks(std::shared_ptr<CReserveScript> coinbaseScript, int nGen
|
||||||
|
|
||||||
// Fill out block witness if dynamic federation is enabled
|
// Fill out block witness if dynamic federation is enabled
|
||||||
// since we are assuming WSH(OP_TRUE)
|
// since we are assuming WSH(OP_TRUE)
|
||||||
if (!pblock->m_dyna_params.IsNull()) {
|
if (!pblock->m_dynafed_params.IsNull()) {
|
||||||
CScript op_true(OP_TRUE);
|
CScript op_true(OP_TRUE);
|
||||||
pblock->m_signblock_witness.stack.push_back(std::vector<unsigned char>(op_true.begin(), op_true.end()));
|
pblock->m_signblock_witness.stack.push_back(std::vector<unsigned char>(op_true.begin(), op_true.end()));
|
||||||
}
|
}
|
||||||
|
|
@ -1083,7 +1083,7 @@ UniValue getnewblockhex(const JSONRPCRequest& request)
|
||||||
|
|
||||||
// If WSH(OP_TRUE) block, fill in witness
|
// If WSH(OP_TRUE) block, fill in witness
|
||||||
CScript op_true(OP_TRUE);
|
CScript op_true(OP_TRUE);
|
||||||
if (pblocktemplate->block.m_dyna_params.m_current.m_signblockscript ==
|
if (pblocktemplate->block.m_dynafed_params.m_current.m_signblockscript ==
|
||||||
GetScriptForDestination(WitnessV0ScriptHash(op_true))) {
|
GetScriptForDestination(WitnessV0ScriptHash(op_true))) {
|
||||||
pblocktemplate->block.m_signblock_witness.stack.push_back(std::vector<unsigned char>(op_true.begin(), op_true.end()));
|
pblocktemplate->block.m_signblock_witness.stack.push_back(std::vector<unsigned char>(op_true.begin(), op_true.end()));
|
||||||
}
|
}
|
||||||
|
|
@ -1153,7 +1153,7 @@ UniValue combineblocksigs(const JSONRPCRequest& request)
|
||||||
sig_data.signatures[pubkey.GetID()] = std::make_pair(pubkey, sig_bytes);
|
sig_data.signatures[pubkey.GetID()] = std::make_pair(pubkey, sig_bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!block.m_dyna_params.IsNull()) {
|
if (!block.m_dynafed_params.IsNull()) {
|
||||||
if (request.params[2].isNull()) {
|
if (request.params[2].isNull()) {
|
||||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "Signing dynamic blocks requires the witnessScript argument");
|
throw JSONRPCError(RPC_INVALID_PARAMETER, "Signing dynamic blocks requires the witnessScript argument");
|
||||||
}
|
}
|
||||||
|
|
@ -1162,7 +1162,7 @@ UniValue combineblocksigs(const JSONRPCRequest& request)
|
||||||
keystore.AddCScript(CScript(witness_bytes.begin(), witness_bytes.end()));
|
keystore.AddCScript(CScript(witness_bytes.begin(), witness_bytes.end()));
|
||||||
}
|
}
|
||||||
// Finalizes the signatures, has no access to keys
|
// Finalizes the signatures, has no access to keys
|
||||||
ProduceSignature(keystore, signature_creator, block.m_dyna_params.m_current.m_signblockscript, sig_data, SCRIPT_NO_SIGHASH_BYTE);
|
ProduceSignature(keystore, signature_creator, block.m_dynafed_params.m_current.m_signblockscript, sig_data, SCRIPT_NO_SIGHASH_BYTE);
|
||||||
block.m_signblock_witness = sig_data.scriptWitness;
|
block.m_signblock_witness = sig_data.scriptWitness;
|
||||||
} else {
|
} else {
|
||||||
// Finalizes the signatures, has no access to keys
|
// Finalizes the signatures, has no access to keys
|
||||||
|
|
|
||||||
|
|
@ -2131,7 +2131,7 @@ bool CChainState::ConnectBlock(const CBlock& block, CValidationState& state, CBl
|
||||||
// ELEMENTS:
|
// ELEMENTS:
|
||||||
|
|
||||||
// Enforce PAK post-dynafed
|
// Enforce PAK post-dynafed
|
||||||
if (chainparams.GetEnforcePak() && !block.m_dyna_params.IsNull()) {
|
if (chainparams.GetEnforcePak() && !block.m_dynafed_params.IsNull()) {
|
||||||
// GetActivePAKList computes for the following block, so use previous index
|
// GetActivePAKList computes for the following block, so use previous index
|
||||||
CPAKList paklist = GetActivePAKList(pindex->pprev, chainparams.GetConsensus());
|
CPAKList paklist = GetActivePAKList(pindex->pprev, chainparams.GetConsensus());
|
||||||
for (const auto& tx : block.vtx) {
|
for (const auto& tx : block.vtx) {
|
||||||
|
|
@ -3472,7 +3472,7 @@ static bool ContextualCheckDynaFedHeader(const CBlockHeader& block, CValidationS
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const DynaFedParams& dynafed_params = block.m_dyna_params;
|
const DynaFedParams& dynafed_params = block.m_dynafed_params;
|
||||||
|
|
||||||
// Dynamic blocks must at least publish current signblockscript in full
|
// Dynamic blocks must at least publish current signblockscript in full
|
||||||
if (dynafed_params.m_current.IsNull()) {
|
if (dynafed_params.m_current.IsNull()) {
|
||||||
|
|
|
||||||
|
|
@ -4782,7 +4782,7 @@ UniValue signblock(const JSONRPCRequest& request)
|
||||||
|
|
||||||
// Expose SignatureData internals in return value in lieu of "Partially Signed Bitcoin Blocks"
|
// Expose SignatureData internals in return value in lieu of "Partially Signed Bitcoin Blocks"
|
||||||
SignatureData block_sigs;
|
SignatureData block_sigs;
|
||||||
if (block.m_dyna_params.IsNull()) {
|
if (block.m_dynafed_params.IsNull()) {
|
||||||
GenericSignScript(*pwallet, block.GetBlockHeader(), block.proof.challenge, block_sigs);
|
GenericSignScript(*pwallet, block.GetBlockHeader(), block.proof.challenge, block_sigs);
|
||||||
} else {
|
} else {
|
||||||
if (request.params[1].isNull()) {
|
if (request.params[1].isNull()) {
|
||||||
|
|
@ -4794,7 +4794,7 @@ UniValue signblock(const JSONRPCRequest& request)
|
||||||
if (!witness_bytes.empty()) {
|
if (!witness_bytes.empty()) {
|
||||||
pwallet->AddCScript(CScript(witness_bytes.begin(), witness_bytes.end()));
|
pwallet->AddCScript(CScript(witness_bytes.begin(), witness_bytes.end()));
|
||||||
}
|
}
|
||||||
GenericSignScript(*pwallet, block.GetBlockHeader(), block.m_dyna_params.m_current.m_signblockscript, block_sigs);
|
GenericSignScript(*pwallet, block.GetBlockHeader(), block.m_dynafed_params.m_current.m_signblockscript, block_sigs);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Error if sig data didn't "grow"
|
// Error if sig data didn't "grow"
|
||||||
|
|
|
||||||
|
|
@ -928,7 +928,7 @@ HEADER_HF_BIT = 1 << 31
|
||||||
HEADER_DYNAFED_HF_MASK = 0x7fffffff
|
HEADER_DYNAFED_HF_MASK = 0x7fffffff
|
||||||
class CBlockHeader:
|
class CBlockHeader:
|
||||||
__slots__ = ("hash", "hashMerkleRoot", "hashPrevBlock", "nBits", "nNonce",
|
__slots__ = ("hash", "hashMerkleRoot", "hashPrevBlock", "nBits", "nNonce",
|
||||||
"nTime", "nVersion", "sha256", "block_height", "proof", "m_dyna_params",
|
"nTime", "nVersion", "sha256", "block_height", "proof", "m_dynafed_params",
|
||||||
"m_signblock_witness")
|
"m_signblock_witness")
|
||||||
|
|
||||||
def __init__(self, header=None):
|
def __init__(self, header=None):
|
||||||
|
|
@ -943,7 +943,7 @@ class CBlockHeader:
|
||||||
self.proof = header.proof
|
self.proof = header.proof
|
||||||
self.sha256 = header.sha256
|
self.sha256 = header.sha256
|
||||||
self.hash = header.hash
|
self.hash = header.hash
|
||||||
self.m_dyna_params = header.m_dyna_params
|
self.m_dynafed_params = header.m_dynafed_params
|
||||||
self.m_signblock_witness = header.m_signblock_witness
|
self.m_signblock_witness = header.m_signblock_witness
|
||||||
self.calc_sha256()
|
self.calc_sha256()
|
||||||
|
|
||||||
|
|
@ -954,7 +954,7 @@ class CBlockHeader:
|
||||||
self.nTime = 0
|
self.nTime = 0
|
||||||
self.block_height = 0
|
self.block_height = 0
|
||||||
self.proof = CProof()
|
self.proof = CProof()
|
||||||
self.m_dyna_params = DynaFedParams()
|
self.m_dynafed_params = DynaFedParams()
|
||||||
self.m_signblock_witness = CScriptWitness()
|
self.m_signblock_witness = CScriptWitness()
|
||||||
self.sha256 = None
|
self.sha256 = None
|
||||||
self.hash = None
|
self.hash = None
|
||||||
|
|
@ -972,7 +972,7 @@ class CBlockHeader:
|
||||||
self.nTime = struct.unpack("<I", f.read(4))[0]
|
self.nTime = struct.unpack("<I", f.read(4))[0]
|
||||||
self.block_height = struct.unpack("<I", f.read(4))[0]
|
self.block_height = struct.unpack("<I", f.read(4))[0]
|
||||||
if is_dyna:
|
if is_dyna:
|
||||||
self.m_dyna_params.deserialize(f)
|
self.m_dynafed_params.deserialize(f)
|
||||||
self.m_signblock_witness.stack = deser_string_vector(f)
|
self.m_signblock_witness.stack = deser_string_vector(f)
|
||||||
else:
|
else:
|
||||||
self.proof.deserialize(f)
|
self.proof.deserialize(f)
|
||||||
|
|
@ -983,7 +983,7 @@ class CBlockHeader:
|
||||||
r = b""
|
r = b""
|
||||||
nVersion = self.nVersion
|
nVersion = self.nVersion
|
||||||
is_dyna = False
|
is_dyna = False
|
||||||
if not self.m_dyna_params.is_null():
|
if not self.m_dynafed_params.is_null():
|
||||||
nVersion -= HEADER_HF_BIT
|
nVersion -= HEADER_HF_BIT
|
||||||
is_dyna = True
|
is_dyna = True
|
||||||
|
|
||||||
|
|
@ -993,7 +993,7 @@ class CBlockHeader:
|
||||||
r += struct.pack("<I", self.nTime)
|
r += struct.pack("<I", self.nTime)
|
||||||
r += struct.pack("<I", self.block_height)
|
r += struct.pack("<I", self.block_height)
|
||||||
if is_dyna:
|
if is_dyna:
|
||||||
r += self.m_dyna_params.serialize()
|
r += self.m_dynafed_params.serialize()
|
||||||
r += ser_string_vector(self.m_signblock_witness.stack)
|
r += ser_string_vector(self.m_signblock_witness.stack)
|
||||||
else:
|
else:
|
||||||
r += self.proof.serialize()
|
r += self.proof.serialize()
|
||||||
|
|
@ -1003,7 +1003,7 @@ class CBlockHeader:
|
||||||
if self.sha256 is None:
|
if self.sha256 is None:
|
||||||
nVersion = self.nVersion
|
nVersion = self.nVersion
|
||||||
is_dyna = False
|
is_dyna = False
|
||||||
if not self.m_dyna_params.is_null():
|
if not self.m_dynafed_params.is_null():
|
||||||
nVersion -= HEADER_HF_BIT
|
nVersion -= HEADER_HF_BIT
|
||||||
is_dyna = True
|
is_dyna = True
|
||||||
|
|
||||||
|
|
@ -1014,7 +1014,7 @@ class CBlockHeader:
|
||||||
r += struct.pack("<I", self.nTime)
|
r += struct.pack("<I", self.nTime)
|
||||||
r += struct.pack("<I", self.block_height)
|
r += struct.pack("<I", self.block_height)
|
||||||
if is_dyna:
|
if is_dyna:
|
||||||
r += self.m_dyna_params.serialize()
|
r += self.m_dynafed_params.serialize()
|
||||||
else:
|
else:
|
||||||
r += self.proof.serialize_for_hash()
|
r += self.proof.serialize_for_hash()
|
||||||
self.sha256 = uint256_from_str(hash256(r))
|
self.sha256 = uint256_from_str(hash256(r))
|
||||||
|
|
@ -1101,9 +1101,9 @@ class CBlock(CBlockHeader):
|
||||||
# self.rehash()
|
# self.rehash()
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "CBlock(nVersion=%i hashPrevBlock=%064x hashMerkleRoot=%064x nTime=%s vtx=%s m_dyna_params=%s)" \
|
return "CBlock(nVersion=%i hashPrevBlock=%064x hashMerkleRoot=%064x nTime=%s vtx=%s m_dynafed_params=%s)" \
|
||||||
% (self.nVersion, self.hashPrevBlock, self.hashMerkleRoot,
|
% (self.nVersion, self.hashPrevBlock, self.hashMerkleRoot,
|
||||||
time.ctime(self.nTime), repr(self.vtx), self.m_dyna_params)
|
time.ctime(self.nTime), repr(self.vtx), self.m_dynafed_params)
|
||||||
|
|
||||||
|
|
||||||
class PrefilledTransaction:
|
class PrefilledTransaction:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue