12
12
13
13
import click
14
14
import zstd
15
- from chia_rs import SpendBundle
15
+ from chia_rs . sized_bytes import bytes32
16
16
from chia_rs .sized_ints import uint32 , uint64
17
17
18
18
from chia ._tests .util .constants import test_constants
@@ -83,6 +83,11 @@ def main(length: int, fill_rate: int, profile: bool, block_refs: bool, output: O
83
83
initialize_logging (
84
84
"generate_chain" , {"log_level" : "DEBUG" , "log_stdout" : False , "log_syslog" : False }, root_path = root_path
85
85
)
86
+ farmer_puzzlehash : bytes32 = bt .farmer_ph
87
+ pool_puzzlehash : bytes32 = bt .farmer_ph
88
+ unspent_coins : set [Coin ] = bt .available_coins
89
+ num_spends : int = bt .prev_num_spends
90
+ num_additions : int = bt .prev_num_additions
86
91
87
92
print (f"writing blockchain to { output } " )
88
93
with closing (sqlite3 .connect (output )) as db :
@@ -95,9 +100,6 @@ def main(length: int, fill_rate: int, profile: bool, block_refs: bool, output: O
95
100
"block blob)"
96
101
)
97
102
98
- wallet = bt .get_farmer_wallet_tool ()
99
- farmer_puzzlehash = wallet .get_new_puzzlehash ()
100
- pool_puzzlehash = wallet .get_new_puzzlehash ()
101
103
transaction_blocks : list [uint32 ] = []
102
104
103
105
blocks = bt .get_consecutive_blocks (
@@ -108,12 +110,7 @@ def main(length: int, fill_rate: int, profile: bool, block_refs: bool, output: O
108
110
genesis_timestamp = uint64 (1234567890 ),
109
111
)
110
112
111
- unspent_coins : list [Coin ] = []
112
-
113
113
for b in blocks :
114
- for coin in b .get_included_reward_coins ():
115
- if coin .puzzle_hash in {farmer_puzzlehash , pool_puzzlehash }:
116
- unspent_coins .append (coin )
117
114
db .execute (
118
115
"INSERT INTO full_blocks VALUES(?, ?, ?, ?, ?)" ,
119
116
(
@@ -128,41 +125,26 @@ def main(length: int, fill_rate: int, profile: bool, block_refs: bool, output: O
128
125
129
126
b = blocks [- 1 ]
130
127
131
- num_tx_per_block = int (1010 * fill_rate / 100 )
132
-
133
128
while True :
134
129
with enable_profiler (profile , b .height ):
135
130
start_time = time .monotonic ()
136
131
137
- new_coins : list [Coin ] = []
138
- spend_bundles : list [SpendBundle ] = []
139
- i = 0
140
- for i in range (num_tx_per_block ):
141
- if unspent_coins == []:
142
- break
143
- c = unspent_coins .pop (random .randrange (len (unspent_coins )))
144
- receiver = wallet .get_new_puzzlehash ()
145
- bundle = wallet .generate_signed_transaction (uint64 (c .amount // 2 ), receiver , c )
146
- new_coins .extend (bundle .additions ())
147
- spend_bundles .append (bundle )
148
-
149
132
block_references : list [uint32 ]
150
133
if block_refs :
151
134
block_references = random .sample (transaction_blocks , min (len (transaction_blocks ), 512 ))
152
135
random .shuffle (block_references )
153
136
else :
154
137
block_references = []
155
138
156
- farmer_puzzlehash = wallet .get_new_puzzlehash ()
157
- pool_puzzlehash = wallet .get_new_puzzlehash ()
158
139
prev_num_blocks = len (blocks )
159
140
blocks = bt .get_consecutive_blocks (
160
141
1 ,
161
142
blocks ,
162
143
farmer_reward_puzzle_hash = farmer_puzzlehash ,
163
144
pool_reward_puzzle_hash = pool_puzzlehash ,
164
145
keep_going_until_tx_block = True ,
165
- transaction_data = SpendBundle .aggregate (spend_bundles ),
146
+ include_transactions = True ,
147
+ block_fillrate = fill_rate ,
166
148
block_refs = block_references ,
167
149
)
168
150
prev_tx_block = b
@@ -171,11 +153,8 @@ def main(length: int, fill_rate: int, profile: bool, block_refs: bool, output: O
171
153
height = b .height
172
154
assert b .is_transaction_block ()
173
155
transaction_blocks .append (height )
174
-
175
- for bl in blocks [prev_num_blocks :]:
176
- for coin in bl .get_included_reward_coins ():
177
- unspent_coins .append (coin )
178
- unspent_coins .extend (new_coins )
156
+ num_spends += bt .prev_num_spends
157
+ num_additions += bt .prev_num_additions
179
158
180
159
if b .transactions_info :
181
160
actual_fill_rate = b .transactions_info .cost / test_constants .MAX_BLOCK_COST_CLVM
@@ -194,10 +173,10 @@ def main(length: int, fill_rate: int, profile: bool, block_refs: bool, output: O
194
173
195
174
print (
196
175
f"height: { b .height } "
197
- f"spends: { i + 1 } "
176
+ f"spends: { num_spends } "
198
177
f"refs: { len (block_references )} "
199
178
f"fill_rate: { actual_fill_rate * 100 :.1f} % "
200
- f"new coins: { len ( new_coins ) } "
179
+ f"new coins: { num_additions } "
201
180
f"unspent: { len (unspent_coins )} "
202
181
f"difficulty: { b .weight - prev_block .weight } "
203
182
f"timestamp: { ts } "
0 commit comments