28
28
from hathor .simulator .clock import HeapClock , MemoryReactorHeapClock
29
29
from hathor .simulator .miner .geometric_miner import GeometricMiner
30
30
from hathor .simulator .tx_generator import RandomTransactionGenerator
31
+ from hathor .simulator .verification import (
32
+ SimulatorBlockVerifier ,
33
+ SimulatorMergeMinedBlockVerifier ,
34
+ SimulatorTokenCreationTransactionVerifier ,
35
+ SimulatorTransactionVerifier ,
36
+ )
31
37
from hathor .util import Random
38
+ from hathor .verification .verification_service import VertexVerifiers
32
39
from hathor .wallet import HDWallet
33
40
34
41
if TYPE_CHECKING :
@@ -52,25 +59,17 @@ def _apply_patches(cls):
52
59
53
60
Patches:
54
61
55
- - disable pow verification
56
62
- disable Transaction.resolve method
57
63
- set DAA test-mode to DISABLED (will actually run the pow function, that won't actually verify the pow)
58
64
- override AVG_TIME_BETWEEN_BLOCKS to 64
59
65
"""
60
66
from hathor .transaction import BaseTransaction
61
67
62
- def verify_pow (self : BaseTransaction , * args : Any , ** kwargs : Any ) -> None :
63
- assert self .hash is not None
64
- logger .new ().debug ('Skipping BaseTransaction.verify_pow() for simulator' )
65
-
66
68
def resolve (self : BaseTransaction , update_time : bool = True ) -> bool :
67
69
self .update_hash ()
68
70
logger .new ().debug ('Skipping BaseTransaction.resolve() for simulator' )
69
71
return True
70
72
71
- cls ._original_verify_pow = BaseTransaction .verify_pow
72
- BaseTransaction .verify_pow = verify_pow
73
-
74
73
cls ._original_resolve = BaseTransaction .resolve
75
74
BaseTransaction .resolve = resolve
76
75
@@ -85,7 +84,6 @@ def _remove_patches(cls):
85
84
""" Remove the patches previously applied.
86
85
"""
87
86
from hathor .transaction import BaseTransaction
88
- BaseTransaction .verify_pow = cls ._original_verify_pow
89
87
BaseTransaction .resolve = cls ._original_resolve
90
88
91
89
from hathor import daa
@@ -170,10 +168,18 @@ def create_artifacts(self, builder: Optional[Builder] = None) -> BuildArtifacts:
170
168
wallet = HDWallet (gap_limit = 2 )
171
169
wallet ._manually_initialize ()
172
170
171
+ vertex_verifiers = VertexVerifiers (
172
+ block = SimulatorBlockVerifier (settings = self .settings ),
173
+ merge_mined_block = SimulatorMergeMinedBlockVerifier (settings = self .settings ),
174
+ tx = SimulatorTransactionVerifier (settings = self .settings ),
175
+ token_creation_tx = SimulatorTokenCreationTransactionVerifier (settings = self .settings ),
176
+ )
177
+
173
178
artifacts = builder \
174
179
.set_reactor (self ._clock ) \
175
180
.set_rng (Random (self .rng .getrandbits (64 ))) \
176
181
.set_wallet (wallet ) \
182
+ .set_vertex_verifiers (vertex_verifiers ) \
177
183
.build ()
178
184
179
185
artifacts .manager .start ()
0 commit comments