mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-14 12:43:40 +02:00
s/m_sbs_wit_limit/m_signblock_witness_limit/
This commit is contained in:
parent
b66804678c
commit
642260a126
8 changed files with 25 additions and 25 deletions
|
|
@ -51,7 +51,7 @@ bool CheckProof(const CBlockHeader& block, const Consensus::Params& params)
|
|||
if (dynafed_params.IsNull()) {
|
||||
return CheckProofGeneric(block, params.max_block_signature_size, params.signblockscript, block.proof.solution, CScriptWitness());
|
||||
} else {
|
||||
return CheckProofGeneric(block, dynafed_params.m_current.m_sbs_wit_limit, dynafed_params.m_current.m_signblockscript, CScript(), block.m_signblock_witness);
|
||||
return CheckProofGeneric(block, dynafed_params.m_current.m_signblock_witness_limit, dynafed_params.m_current.m_signblockscript, CScript(), block.m_signblock_witness);
|
||||
}
|
||||
} else {
|
||||
return CheckProofOfWork(block.GetHash(), block.nBits, params);
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ ConsensusParamEntry ComputeNextBlockCurrentParameters(const CBlockIndex* pindexP
|
|||
// Return appropriate format based on epoch age
|
||||
if (epoch_age > 0) {
|
||||
// TODO implement "prune" function to remove fields in place and change serialize type
|
||||
return ConsensusParamEntry(entry.m_signblockscript, entry.m_sbs_wit_limit);
|
||||
return ConsensusParamEntry(entry.m_signblockscript, entry.m_signblock_witness_limit);
|
||||
} else {
|
||||
return entry;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -155,7 +155,7 @@ std::unique_ptr<CBlockTemplate> BlockAssembler::CreateNewBlock(const CScript& sc
|
|||
DynaFedParams block_params(current_params, proposed_entry ? *proposed_entry : ConsensusParamEntry());
|
||||
pblock->m_dyna_params = block_params;
|
||||
nBlockWeight += ::GetSerializeSize(block_params, PROTOCOL_VERSION)*WITNESS_SCALE_FACTOR;
|
||||
nBlockWeight += current_params.m_sbs_wit_limit; // Note witness discount
|
||||
nBlockWeight += current_params.m_signblock_witness_limit; // Note witness discount
|
||||
assert(pblock->proof.IsNull());
|
||||
|
||||
} else if (g_signed_blocks) {
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ uint256 ConsensusParamEntry::CalculateRoot() const
|
|||
|
||||
std::vector<uint256> leaves;
|
||||
leaves.push_back(SerializeHash(m_signblockscript, SER_GETHASH, 0));
|
||||
leaves.push_back(SerializeHash(m_sbs_wit_limit, SER_GETHASH, 0));
|
||||
leaves.push_back(SerializeHash(m_signblock_witness_limit, SER_GETHASH, 0));
|
||||
leaves.push_back(SerializeHash(m_fedpegscript, SER_GETHASH, 0));
|
||||
leaves.push_back(SerializeHash(m_extension_space, SER_GETHASH, 0));
|
||||
return ComputeFastMerkleRoot(leaves);
|
||||
|
|
|
|||
|
|
@ -58,16 +58,16 @@ class ConsensusParamEntry
|
|||
public:
|
||||
unsigned char m_serialize_type; // Determines how it is serialized, defaults to null
|
||||
CScript m_signblockscript;
|
||||
uint32_t m_sbs_wit_limit; // Max block signature witness serialized size
|
||||
uint32_t m_signblock_witness_limit; // Max block signature witness serialized size
|
||||
CScript m_fedpegscript;
|
||||
// No consensus meaning to the particular bytes, currently we interpret as PAK keys, details in pak.h
|
||||
std::vector<std::vector<unsigned char>> m_extension_space;
|
||||
|
||||
// Each constructor sets its own serialization type implicitly based on which
|
||||
// arguments are given
|
||||
ConsensusParamEntry() { m_sbs_wit_limit = 0; m_serialize_type = 0; };
|
||||
ConsensusParamEntry(const CScript& signblockscript_in, const uint32_t sbs_wit_limit_in) : m_signblockscript(signblockscript_in), m_sbs_wit_limit(sbs_wit_limit_in) { m_serialize_type = 1; };
|
||||
ConsensusParamEntry(const CScript& signblockscript_in, const uint32_t sbs_wit_limit_in, const CScript& fedpegscript_in, const std::vector<std::vector<unsigned char>> extension_space_in) : m_signblockscript(signblockscript_in), m_sbs_wit_limit(sbs_wit_limit_in), m_fedpegscript(fedpegscript_in), m_extension_space(extension_space_in) { m_serialize_type = 2; };
|
||||
ConsensusParamEntry() { m_signblock_witness_limit = 0; m_serialize_type = 0; };
|
||||
ConsensusParamEntry(const CScript& signblockscript_in, const uint32_t sbs_wit_limit_in) : m_signblockscript(signblockscript_in), m_signblock_witness_limit(sbs_wit_limit_in) { m_serialize_type = 1; };
|
||||
ConsensusParamEntry(const CScript& signblockscript_in, const uint32_t sbs_wit_limit_in, const CScript& fedpegscript_in, const std::vector<std::vector<unsigned char>> extension_space_in) : m_signblockscript(signblockscript_in), m_signblock_witness_limit(sbs_wit_limit_in), m_fedpegscript(fedpegscript_in), m_extension_space(extension_space_in) { m_serialize_type = 2; };
|
||||
|
||||
ADD_SERIALIZE_METHODS;
|
||||
|
||||
|
|
@ -80,11 +80,11 @@ public:
|
|||
break;
|
||||
case 1:
|
||||
READWRITE(m_signblockscript);
|
||||
READWRITE(m_sbs_wit_limit);
|
||||
READWRITE(m_signblock_witness_limit);
|
||||
break;
|
||||
case 2:
|
||||
READWRITE(m_signblockscript);
|
||||
READWRITE(m_sbs_wit_limit);
|
||||
READWRITE(m_signblock_witness_limit);
|
||||
READWRITE(m_fedpegscript);
|
||||
READWRITE(m_extension_space);
|
||||
break;
|
||||
|
|
@ -99,7 +99,7 @@ public:
|
|||
{
|
||||
return m_serialize_type == 0 &&
|
||||
m_signblockscript.empty() &&
|
||||
m_sbs_wit_limit == 0 &&
|
||||
m_signblock_witness_limit == 0 &&
|
||||
m_fedpegscript.empty() &&
|
||||
m_extension_space.empty();
|
||||
|
||||
|
|
@ -109,7 +109,7 @@ public:
|
|||
{
|
||||
m_serialize_type = 0;
|
||||
m_signblockscript = CScript();
|
||||
m_sbs_wit_limit = 0;
|
||||
m_signblock_witness_limit = 0;
|
||||
m_fedpegscript = CScript();
|
||||
m_extension_space.clear();
|
||||
}
|
||||
|
|
@ -118,7 +118,7 @@ public:
|
|||
{
|
||||
return m_serialize_type == other.m_serialize_type &&
|
||||
m_signblockscript == other.m_signblockscript &&
|
||||
m_sbs_wit_limit == other.m_sbs_wit_limit &&
|
||||
m_signblock_witness_limit == other.m_signblock_witness_limit &&
|
||||
m_fedpegscript == other.m_fedpegscript &&
|
||||
m_extension_space == other.m_extension_space;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ UniValue paramEntryToJSON(const ConsensusParamEntry& entry)
|
|||
{
|
||||
UniValue result(UniValue::VOBJ);
|
||||
result.pushKV("signblockscript", HexStr(entry.m_signblockscript));
|
||||
result.pushKV("max_block_witness", (uint64_t)entry.m_sbs_wit_limit);
|
||||
result.pushKV("max_block_witness", (uint64_t)entry.m_signblock_witness_limit);
|
||||
result.pushKV("fedpegscript", HexStr(entry.m_fedpegscript));
|
||||
UniValue result_extension(UniValue::VARR);
|
||||
for (auto& item : entry.m_extension_space) {
|
||||
|
|
@ -1461,7 +1461,7 @@ UniValue getblockchaininfo(const JSONRPCRequest& request)
|
|||
const ConsensusParamEntry entry = ComputeNextBlockFullCurrentParameters(chainActive.Tip(), chainparams.GetConsensus());
|
||||
obj.pushKV("current_signblock_asm", ScriptToAsmStr(entry.m_signblockscript));
|
||||
obj.pushKV("current_signblock_hex", HexStr(entry.m_signblockscript));
|
||||
obj.pushKV("max_block_witness", (uint64_t)entry.m_sbs_wit_limit);
|
||||
obj.pushKV("max_block_witness", (uint64_t)entry.m_signblock_witness_limit);
|
||||
UniValue arr(UniValue::VARR);
|
||||
for (const auto& extension : entry.m_extension_space) {
|
||||
arr.push_back(HexStr(extension));
|
||||
|
|
|
|||
|
|
@ -1049,7 +1049,7 @@ UniValue getnewblockhex(const JSONRPCRequest& request)
|
|||
if (max_sbs_wit < 0) {
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "max_block_witness must be non-negative");
|
||||
}
|
||||
proposed.m_sbs_wit_limit = max_sbs_wit;
|
||||
proposed.m_signblock_witness_limit = max_sbs_wit;
|
||||
|
||||
std::string fps_str = prop["fedpegscript"].get_str();
|
||||
if (!IsHex(fps_str)) {
|
||||
|
|
|
|||
|
|
@ -836,15 +836,15 @@ class CProof:
|
|||
% (self.challenge, self.solution)
|
||||
|
||||
class ConsensusParamEntry:
|
||||
__slots__ = ("m_serialize_type", "m_signblockscript", "m_sbs_wit_limit", "m_fedpegscript", "m_extension_space")
|
||||
__slots__ = ("m_serialize_type", "m_signblockscript", "m_signblock_witness_limit", "m_fedpegscript", "m_extension_space")
|
||||
|
||||
# Constructor args will define serialization type:
|
||||
# null = 0
|
||||
# signblock-related fields = 1, required for m_current on non-epoch-starts
|
||||
# all fields = 2, required for epoch starts
|
||||
def __init__(self, m_signblockscript=b"", m_sbs_wit_limit=0, m_fedpegscript=b"", m_extension_space=[]):
|
||||
def __init__(self, m_signblockscript=b"", m_signblock_witness_limit=0, m_fedpegscript=b"", m_extension_space=[]):
|
||||
self.m_signblockscript = m_signblockscript
|
||||
self.m_sbs_wit_limit = m_sbs_wit_limit
|
||||
self.m_signblock_witness_limit = m_signblock_witness_limit
|
||||
self.m_fedpegscript = m_fedpegscript
|
||||
self.m_extension_space = m_extension_space
|
||||
if self.is_null():
|
||||
|
|
@ -856,13 +856,13 @@ class ConsensusParamEntry:
|
|||
|
||||
def set_null(self):
|
||||
self.m_signblockscript = b""
|
||||
self.m_sbs_wit_limit = 0
|
||||
self.m_signblock_witness_limit = 0
|
||||
self.m_fedpegscript = b""
|
||||
self.m_extension_space = []
|
||||
self.m_serialize_type = 0
|
||||
|
||||
def is_null(self):
|
||||
return self.m_signblockscript == b"" and self.m_sbs_wit_limit == 0 and \
|
||||
return self.m_signblockscript == b"" and self.m_signblock_witness_limit == 0 and \
|
||||
self.m_fedpegscript == b"" and self.m_extension_space == []
|
||||
|
||||
def serialize(self):
|
||||
|
|
@ -870,10 +870,10 @@ class ConsensusParamEntry:
|
|||
r += struct.pack("B", self.m_serialize_type)
|
||||
if self.m_serialize_type == 1:
|
||||
r += ser_string(self.m_signblockscript)
|
||||
r += struct.pack("<I", self.m_sbs_wit_limit)
|
||||
r += struct.pack("<I", self.m_signblock_witness_limit)
|
||||
elif self.m_serialize_type == 2:
|
||||
r += ser_string(self.m_signblockscript)
|
||||
r += struct.pack("<I", self.m_sbs_wit_limit)
|
||||
r += struct.pack("<I", self.m_signblock_witness_limit)
|
||||
r += ser_string(self.m_fedpegscript)
|
||||
r += ser_string_vector(self.m_extension_space)
|
||||
elif self.m_serialize_type > 2:
|
||||
|
|
@ -884,10 +884,10 @@ class ConsensusParamEntry:
|
|||
self.m_serialize_type = struct.unpack("B", f.read(1))[0]
|
||||
if self.m_serialize_type == 1:
|
||||
self.m_signblockscript = deser_string(f)
|
||||
self.m_sbs_wit_limit = struct.unpack("<I", f.read(4))[0]
|
||||
self.m_signblock_witness_limit = struct.unpack("<I", f.read(4))[0]
|
||||
elif self.m_serialize_type == 2:
|
||||
self.m_signblockscript = deser_string(f)
|
||||
self.m_sbs_wit_limit = struct.unpack("<I", f.read(4))[0]
|
||||
self.m_signblock_witness_limit = struct.unpack("<I", f.read(4))[0]
|
||||
self.m_fedpegscript = deser_string(f)
|
||||
self.m_extension_space = deser_string_vector(f)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue