|
18 | 18 | from struct import pack
|
19 | 19 | from typing import TYPE_CHECKING, Any, Optional
|
20 | 20 |
|
21 |
| -from hathor import daa |
22 | 21 | from hathor.checkpoint import Checkpoint
|
23 | 22 | from hathor.feature_activation.feature import Feature
|
24 | 23 | from hathor.feature_activation.model.feature_state import FeatureState
|
25 | 24 | from hathor.profiler import get_cpu_profiler
|
26 | 25 | from hathor.transaction import BaseTransaction, TxOutput, TxVersion
|
27 |
| -from hathor.transaction.exceptions import ( |
28 |
| - BlockWithInputs, |
29 |
| - BlockWithTokensError, |
30 |
| - CheckpointError, |
31 |
| - InvalidBlockReward, |
32 |
| - RewardLocked, |
33 |
| - TransactionDataError, |
34 |
| - WeightError, |
35 |
| -) |
| 26 | +from hathor.transaction.exceptions import BlockWithTokensError, CheckpointError |
36 | 27 | from hathor.transaction.util import VerboseCallback, int_to_bytes, unpack, unpack_len
|
37 | 28 | from hathor.util import not_none
|
38 | 29 | from hathor.utils.int import get_bit_list
|
@@ -337,55 +328,12 @@ def verify_checkpoint(self, checkpoints: list[Checkpoint]) -> None:
|
337 | 328 | # TODO: check whether self is a parent of any checkpoint-valid block, this is left for a future PR
|
338 | 329 | pass
|
339 | 330 |
|
340 |
| - def verify_weight(self) -> None: |
341 |
| - """Validate minimum block difficulty.""" |
342 |
| - block_weight = daa.calculate_block_difficulty(self) |
343 |
| - if self.weight < block_weight - self._settings.WEIGHT_TOL: |
344 |
| - raise WeightError(f'Invalid new block {self.hash_hex}: weight ({self.weight}) is ' |
345 |
| - f'smaller than the minimum weight ({block_weight})') |
346 |
| - |
347 |
| - def verify_height(self) -> None: |
348 |
| - """Validate that the block height is enough to confirm all transactions being confirmed.""" |
349 |
| - meta = self.get_metadata() |
350 |
| - assert meta.height is not None |
351 |
| - assert meta.min_height is not None |
352 |
| - if meta.height < meta.min_height: |
353 |
| - raise RewardLocked(f'Block needs {meta.min_height} height but has {meta.height}') |
354 |
| - |
355 |
| - def verify_reward(self) -> None: |
356 |
| - """Validate reward amount.""" |
357 |
| - parent_block = self.get_block_parent() |
358 |
| - tokens_issued_per_block = daa.get_tokens_issued_per_block(parent_block.get_height() + 1) |
359 |
| - if self.sum_outputs != tokens_issued_per_block: |
360 |
| - raise InvalidBlockReward( |
361 |
| - f'Invalid number of issued tokens tag=invalid_issued_tokens tx.hash={self.hash_hex} ' |
362 |
| - f'issued={self.sum_outputs} allowed={tokens_issued_per_block}' |
363 |
| - ) |
364 |
| - |
365 |
| - def verify_no_inputs(self) -> None: |
366 |
| - inputs = getattr(self, 'inputs', None) |
367 |
| - if inputs: |
368 |
| - raise BlockWithInputs('number of inputs {}'.format(len(inputs))) |
369 |
| - |
370 | 331 | def verify_outputs(self) -> None:
|
371 | 332 | super().verify_outputs()
|
372 | 333 | for output in self.outputs:
|
373 | 334 | if output.get_token_index() > 0:
|
374 | 335 | raise BlockWithTokensError('in output: {}'.format(output.to_human_readable()))
|
375 | 336 |
|
376 |
| - def verify_data(self) -> None: |
377 |
| - if len(self.data) > self._settings.BLOCK_DATA_MAX_SIZE: |
378 |
| - raise TransactionDataError('block data has {} bytes'.format(len(self.data))) |
379 |
| - |
380 |
| - def verify_without_storage(self) -> None: |
381 |
| - """ Run all verifications that do not need a storage. |
382 |
| - """ |
383 |
| - self.verify_pow() |
384 |
| - self.verify_no_inputs() |
385 |
| - self.verify_outputs() |
386 |
| - self.verify_data() |
387 |
| - self.verify_sigops_output() |
388 |
| - |
389 | 337 | def get_base_hash(self) -> bytes:
|
390 | 338 | from hathor.merged_mining.bitcoin import sha256d_hash
|
391 | 339 | return sha256d_hash(self.get_header_without_nonce())
|
|
0 commit comments