Add support for LWMA chains by skipping pow validation
Add SKIP_POW_DIFFICULTY_VALIDATION flag to AbstractNet for chains using custom difficulty algorithms like LWMA. Update blockchain.py to skip pow validation when flag is set, relying on server validation and checkpoints instead. Also update Palladium checkpoints.
This commit is contained in:
@@ -312,13 +312,16 @@ class Blockchain(Logger):
|
||||
raise InvalidHeader("prev hash mismatch: %s vs %s" % (prev_hash, header.get('prev_block_hash')))
|
||||
if constants.net.TESTNET:
|
||||
return
|
||||
bits = cls.target_to_bits(target)
|
||||
if bits != header.get('bits'):
|
||||
raise InvalidHeader("bits mismatch: %s vs %s" % (bits, header.get('bits')))
|
||||
_pow_hash = pow_hash_header(header)
|
||||
pow_hash_as_num = int.from_bytes(bfh(_pow_hash), byteorder='big')
|
||||
if pow_hash_as_num > target:
|
||||
raise InvalidHeader(f"insufficient proof of work: {pow_hash_as_num} vs target {target}")
|
||||
# Skip difficulty validation for chains with custom difficulty algorithms (e.g., LWMA)
|
||||
# We rely on server validation and checkpoints instead
|
||||
if not constants.net.SKIP_POW_DIFFICULTY_VALIDATION:
|
||||
bits = cls.target_to_bits(target)
|
||||
if bits != header.get('bits'):
|
||||
raise InvalidHeader("bits mismatch: %s vs %s" % (bits, header.get('bits')))
|
||||
_pow_hash = pow_hash_header(header)
|
||||
pow_hash_as_num = int.from_bytes(bfh(_pow_hash), byteorder='big')
|
||||
if pow_hash_as_num > target:
|
||||
raise InvalidHeader(f"insufficient proof of work: {pow_hash_as_num} vs target {target}")
|
||||
|
||||
def verify_chunk(self, index: int, data: bytes) -> None:
|
||||
num = len(data) // HEADER_SIZE
|
||||
|
||||
Reference in New Issue
Block a user