Skip to content

Commit 27f0015

Browse files
committed
refactor(blocks): use "forged" instead of "minted" terminology
Update tests and utilities to consistently use "forged" instead of "minted" when referring to block creation. This aligns terminology with Cardano node logs and documentation.
1 parent 3415592 commit 27f0015

File tree

6 files changed

+78
-78
lines changed

6 files changed

+78
-78
lines changed

cardano_node_tests/tests/test_blocks.py

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@ def test_pool_blocks( # noqa: C901
4545
cluster_use_pool: tuple[clusterlib.ClusterLib, str],
4646
for_epoch: str,
4747
):
48-
"""Check that blocks were minted according to leadership schedule.
48+
"""Check that blocks were forged according to leadership schedule.
4949
5050
* query leadership schedule for selected pool for current epoch or next epoch
5151
* wait for epoch that comes after the queried epoch
52-
* get info about minted blocks in queried epoch for the selected pool
53-
* compare leadership schedule with blocks that were actually minted
52+
* get info about forged blocks in queried epoch for the selected pool
53+
* compare leadership schedule with blocks that were actually forged
5454
* compare log records with ledger state dump
55-
* (optional) check minted blocks in db-sync
55+
* (optional) check forged blocks in db-sync
5656
"""
5757
cluster, pool_name = cluster_use_pool
5858
pool_short_name = f"{pool_name.replace('node-', '')}"
@@ -94,7 +94,7 @@ def test_pool_blocks( # noqa: C901
9494
# Wait for epoch that comes after the queried epoch
9595
cluster.wait_for_epoch(epoch_no=queried_epoch + 1, padding_seconds=10, future_is_ok=False)
9696

97-
# Get number of minted blocks from ledger
97+
# Get number of forged blocks from ledger
9898
ledger_state = clusterlib_utils.get_ledger_state(cluster_obj=cluster)
9999
clusterlib_utils.save_ledger_state(
100100
cluster_obj=cluster,
@@ -103,13 +103,13 @@ def test_pool_blocks( # noqa: C901
103103
)
104104
blocks_before: dict[str, int] = ledger_state["blocksBefore"]
105105
pool_id_dec = helpers.decode_bech32(pool_id)
106-
minted_blocks_ledger = blocks_before.get(pool_id_dec) or 0
106+
forged_blocks_ledger = blocks_before.get(pool_id_dec) or 0
107107

108108
errors: list[str] = []
109109

110110
def _check_logs() -> None:
111-
# Get info about minted blocks in queried epoch for the selected pool
112-
minted_lines = logfiles.find_msgs_in_logs(
111+
# Get info about forged blocks in queried epoch for the selected pool
112+
forged_lines = logfiles.find_msgs_in_logs(
113113
regex='"TraceForgedBlock"',
114114
logfile=pool_log,
115115
seek_offset=seek_offset,
@@ -123,67 +123,67 @@ def _check_logs() -> None:
123123
first_slot_queried_ep = first_slot_this_ep - (ep_num_after_queried * ep_length)
124124
last_slot_queried_ep = first_slot_queried_ep + ep_length - 1
125125
slots_pattern = re.compile(r'"slot",Number (\d+)\.0')
126-
slots_when_minted = {
126+
slots_when_forged = {
127127
s
128-
for m in minted_lines
128+
for m in forged_lines
129129
if (o := slots_pattern.search(m)) is not None
130130
and first_slot_queried_ep <= (s := int(o.group(1))) <= last_slot_queried_ep
131131
}
132-
with open(f"{debug_log_template}_minted.txt", "w", encoding="utf-8") as out_fp:
133-
out_fp.write(f"{pool_id_dec}: {slots_when_minted}")
132+
with open(f"{debug_log_template}_forged.txt", "w", encoding="utf-8") as out_fp:
133+
out_fp.write(f"{pool_id_dec}: {slots_when_forged}")
134134

135-
# Compare leadership schedule with blocks that were actually minted
136-
difference_scheduled = slots_when_minted.difference(slots_when_scheduled)
135+
# Compare leadership schedule with blocks that were actually forged
136+
difference_scheduled = slots_when_forged.difference(slots_when_scheduled)
137137
if difference_scheduled:
138138
errors.append(
139-
f"Some blocks were minted in other slots than scheduled: {difference_scheduled}"
139+
f"Some blocks were forged in other slots than scheduled: {difference_scheduled}"
140140
)
141141

142-
difference_minted = slots_when_scheduled.difference(slots_when_minted)
143-
if len(difference_minted) > len(leadership_schedule) // 5:
144-
errors.append(f"Lot of slots missed: {difference_minted}")
142+
difference_forged = slots_when_scheduled.difference(slots_when_forged)
143+
if len(difference_forged) > len(leadership_schedule) // 5:
144+
errors.append(f"Lot of slots missed: {difference_forged}")
145145

146146
# Compare log records with ledger state dump
147-
minted_blocks_logs = len(slots_when_minted)
148-
# Some minted block may not be adopted, and so the total number of adopted blocks
149-
# may be lower than the number of minted blocks.
150-
if minted_blocks_ledger > minted_blocks_logs:
147+
forged_blocks_logs = len(slots_when_forged)
148+
# Some forged block may not be adopted, and so the total number of adopted blocks
149+
# may be lower than the number of forged blocks.
150+
if forged_blocks_ledger > forged_blocks_logs:
151151
errors.append(
152-
"Number of minted blocks reported by ledger state "
152+
"Number of forged blocks reported by ledger state "
153153
"is higher than number extracted from log file: "
154-
f"{minted_blocks_ledger} vs {minted_blocks_logs}"
154+
f"{forged_blocks_ledger} vs {forged_blocks_logs}"
155155
)
156156

157157
def _check_dbsync() -> None:
158-
# Get info about minted blocks in queried epoch for the selected pool
159-
minted_blocks = list(
158+
# Get info about forged blocks in queried epoch for the selected pool
159+
forged_blocks = list(
160160
dbsync_queries.query_blocks(
161161
pool_id_bech32=pool_id, epoch_from=queried_epoch, epoch_to=queried_epoch
162162
)
163163
)
164-
slots_when_minted = {r.slot_no for r in minted_blocks}
165-
with open(f"{debug_log_template}_db_minted.txt", "w", encoding="utf-8") as out_fp:
166-
out_fp.write(f"{pool_id_dec}: {slots_when_minted}")
164+
slots_when_forged = {r.slot_no for r in forged_blocks}
165+
with open(f"{debug_log_template}_db_forged.txt", "w", encoding="utf-8") as out_fp:
166+
out_fp.write(f"{pool_id_dec}: {slots_when_forged}")
167167

168-
# Compare leadership schedule with blocks that were actually minted
169-
difference_scheduled = slots_when_minted.difference(slots_when_scheduled)
168+
# Compare leadership schedule with blocks that were actually forged
169+
difference_scheduled = slots_when_forged.difference(slots_when_scheduled)
170170
if difference_scheduled:
171171
errors.append(
172-
"DB-Sync: Some blocks were minted in other slots than scheduled: "
172+
"DB-Sync: Some blocks were forged in other slots than scheduled: "
173173
f"{difference_scheduled}"
174174
)
175175

176-
difference_minted = slots_when_scheduled.difference(slots_when_minted)
177-
if len(difference_minted) > len(leadership_schedule) // 3:
178-
errors.append(f"DB-Sync: Lot of slots missed: {difference_minted}")
176+
difference_forged = slots_when_scheduled.difference(slots_when_forged)
177+
if len(difference_forged) > len(leadership_schedule) // 3:
178+
errors.append(f"DB-Sync: Lot of slots missed: {difference_forged}")
179179

180180
# Compare db-sync records with ledger state dump
181-
minted_blocks_db = len(slots_when_minted)
182-
if minted_blocks_ledger != minted_blocks_db:
181+
forged_blocks_db = len(slots_when_forged)
182+
if forged_blocks_ledger != forged_blocks_db:
183183
errors.append(
184-
"DB-Sync: Numbers of minted blocks reported by ledger state "
184+
"DB-Sync: Numbers of forged blocks reported by ledger state "
185185
"and db-sync don't match: "
186-
f"{minted_blocks_ledger} vs {minted_blocks_db}"
186+
f"{forged_blocks_ledger} vs {forged_blocks_db}"
187187
)
188188

189189
_check_logs()

cardano_node_tests/tests/test_cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1088,7 +1088,7 @@ def _dump_on_error():
10881088
f"{expected_pool_ids_dec.symmetric_difference(out_pool_ids_dec)}"
10891089
)
10901090
# Active stake can be lower than sum of stakes, as some pools may not be running
1091-
# and minting blocks
1091+
# and forging blocks
10921092
if sum_mark < stake_snapshot["total"]["stakeMark"]:
10931093
total_stake_errors.append(
10941094
f"active_mark: {sum_mark} < {stake_snapshot['total']['stakeMark']}"

cardano_node_tests/tests/test_kes.py

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,11 @@ def _check_block_production(
115115
ledger_state=ledger_state,
116116
)
117117

118-
# Check if the pool is minting any blocks
118+
# Check if the pool is forging any blocks
119119
blocks_made = ledger_state["blocksCurrent"] or {}
120-
is_minting = pool_id_dec in blocks_made
120+
is_forging = pool_id_dec in blocks_made
121121

122-
return epoch, is_minting
122+
return epoch, is_forging
123123

124124

125125
class TestKES:
@@ -146,9 +146,9 @@ def test_expired_kes(
146146
* start local cluster instance configured with short KES period and low number of key
147147
evolutions, so KES expires soon on all pools
148148
* refresh opcert on 2 of the 3 pools, so KES doesn't expire on those 2 pools and
149-
the pools keep minting blocks
149+
the pools keep forging blocks
150150
* wait for KES expiration on the selected pool
151-
* check that the pool with expired KES didn't mint blocks in an epoch that followed after
151+
* check that the pool with expired KES didn't forg blocks in an epoch that followed after
152152
KES expiration
153153
* check KES period info command with an operational certificate with an expired KES
154154
* check KES period info command with operational certificates with a valid KES
@@ -167,7 +167,7 @@ def test_expired_kes(
167167
expire_pool_id_dec = helpers.decode_bech32(expire_pool_id)
168168

169169
# Refresh opcert on all pools except of pool1, so KES doesn't expire on those pools and
170-
# the pools keep minting blocks.
170+
# the pools keep forging blocks.
171171
refreshed_nodes = [
172172
f"pool{i}" for i in range(2, len(cluster_management.Resources.ALL_POOLS) + 1)
173173
]
@@ -312,7 +312,7 @@ def _check_kes_period_info(
312312
# supposed to expire.
313313
_refresh_opcerts()
314314

315-
this_epoch, is_minting = _check_block_production(
315+
this_epoch, is_forging = _check_block_production(
316316
cluster_obj=cluster,
317317
temp_template=temp_template,
318318
pool_id_dec=expire_pool_id_dec,
@@ -322,9 +322,9 @@ def _check_kes_period_info(
322322
_save_all_metrics(temp_template=f"{temp_template}_{this_epoch}_before_refresh")
323323
_save_all_period_info(temp_template=f"{temp_template}_{this_epoch}_before_refresh")
324324

325-
# Check that the expired pool is not minting any blocks
326-
assert not is_minting, (
327-
f"The pool '{expire_pool_name}' has minted blocks in epoch {this_epoch}"
325+
# Check that the expired pool is not forging any blocks
326+
assert not is_forging, (
327+
f"The pool '{expire_pool_name}' has forged blocks in epoch {this_epoch}"
328328
)
329329

330330
# Refresh opcerts one more time on pools that are not supposed to expire
@@ -358,16 +358,16 @@ def test_opcert_invalid_kes_period(
358358
359359
* generate new operational certificate with `--kes-period` in the future
360360
* restart the node with the new operational certificate
361-
* check that the pool is not minting any blocks
361+
* check that the pool is not forging any blocks
362362
* if network era > Alonzo
363363
364364
- generate new operational certificate with valid `--kes-period`, but counter value +2
365365
from last used operational certificate
366366
- restart the node
367-
- check that the pool is not minting any blocks
367+
- check that the pool is not forging any blocks
368368
369369
* generate new operational certificate with valid `--kes-period` and restart the node
370-
* check that the pool is minting blocks again
370+
* check that the pool is forging blocks again
371371
"""
372372
__: tp.Any # mypy workaround
373373
kes_period_info_errors_list = []
@@ -425,17 +425,17 @@ def test_opcert_invalid_kes_period(
425425
LOGGER.info("Checking blocks production for 4 epochs.")
426426
this_epoch = cluster.g_query.get_epoch()
427427
for invalid_opcert_epoch in range(4):
428-
this_epoch, is_minting = _check_block_production(
428+
this_epoch, is_forging = _check_block_production(
429429
cluster_obj=cluster,
430430
temp_template=temp_template,
431431
pool_id_dec=pool_id_dec,
432432
in_epoch=this_epoch + 1,
433433
)
434434
_save_metrics(pool_num=pool_num, temp_template=f"{temp_template}_{this_epoch}")
435435

436-
# Check that the pool is not minting any blocks
437-
assert not is_minting, (
438-
f"The pool '{pool_name}' has minted blocks in epoch {this_epoch}"
436+
# Check that the pool is not forging any blocks
437+
assert not is_forging, (
438+
f"The pool '{pool_name}' has forged blocks in epoch {this_epoch}"
439439
)
440440

441441
if invalid_opcert_epoch == 1:
@@ -532,16 +532,16 @@ def test_opcert_invalid_kes_period(
532532
updated_epoch = cluster.g_query.get_epoch()
533533
this_epoch = updated_epoch
534534
for __ in range(6):
535-
this_epoch, is_minting = _check_block_production(
535+
this_epoch, is_forging = _check_block_production(
536536
cluster_obj=cluster,
537537
temp_template=temp_template,
538538
pool_id_dec=pool_id_dec,
539539
in_epoch=this_epoch + 1,
540540
)
541541
_save_metrics(pool_num=pool_num, temp_template=f"{temp_template}_{this_epoch}")
542542

543-
# Check that the pool is minting blocks
544-
if is_minting:
543+
# Check that the pool is forging blocks
544+
if is_forging:
545545
break
546546
else:
547547
try:
@@ -560,7 +560,7 @@ def test_opcert_invalid_kes_period(
560560
raise
561561

562562
msg = (
563-
f"The pool '{pool_name}' has not minted any blocks since epoch {updated_epoch}."
563+
f"The pool '{pool_name}' has not forged any blocks since epoch {updated_epoch}."
564564
)
565565
raise AssertionError(msg)
566566

@@ -608,12 +608,12 @@ def test_update_valid_opcert(
608608
609609
* generate new operational certificate with valid `--kes-period`
610610
* copy new operational certificate to the node
611-
* stop the node so the corresponding pool is not minting new blocks
612-
* check `kes-period-info` while the pool is not minting blocks
611+
* stop the node so the corresponding pool is not forging new blocks
612+
* check `kes-period-info` while the pool is not forging blocks
613613
* start the node with the new operational certificate
614-
* check that the pool is minting blocks again
614+
* check that the pool is forging blocks again
615615
* check that metrics reported by `kes-period-info` got updated once the pool started
616-
minting blocks again
616+
forging blocks again
617617
* check `kes-period-info` with the old (replaced) operational certificate
618618
"""
619619
__: tp.Any # mypy workaround
@@ -652,12 +652,12 @@ def test_update_valid_opcert(
652652
)
653653
shutil.copy(new_opcert_file, opcert_file)
654654

655-
# Stop the node so the corresponding pool is not minting new blocks
655+
# Stop the node so the corresponding pool is not forging new blocks
656656
cluster_nodes.stop_nodes([node_name])
657657

658658
time.sleep(10)
659659

660-
# Check kes-period-info while the pool is not minting blocks
660+
# Check kes-period-info while the pool is not forging blocks
661661
kes_period_info_new = cluster.g_query.get_kes_period_info(opcert_file)
662662
with open(f"{temp_template}_kes_period_info_1.json", "w", encoding="utf-8") as out_fp:
663663
json.dump(kes_period_info_new, out_fp, indent=2)
@@ -700,16 +700,16 @@ def test_update_valid_opcert(
700700
updated_epoch = cluster.g_query.get_epoch()
701701
this_epoch = updated_epoch
702702
for __ in range(6):
703-
this_epoch, is_minting = _check_block_production(
703+
this_epoch, is_forging = _check_block_production(
704704
cluster_obj=cluster,
705705
temp_template=temp_template,
706706
pool_id_dec=pool_id_dec,
707707
in_epoch=this_epoch + 1,
708708
)
709709
_save_metrics(pool_num=pool_num, temp_template=f"{temp_template}_{this_epoch}")
710710

711-
# Check that the pool is minting blocks
712-
if is_minting:
711+
# Check that the pool is forging blocks
712+
if is_forging:
713713
break
714714
else:
715715
try:
@@ -728,12 +728,12 @@ def test_update_valid_opcert(
728728
raise
729729

730730
msg = (
731-
f"The pool '{pool_name}' has not minted any blocks since epoch {updated_epoch}."
731+
f"The pool '{pool_name}' has not forged any blocks since epoch {updated_epoch}."
732732
)
733733
raise AssertionError(msg)
734734

735735
# Check that metrics reported by kes-period-info got updated once the pool started
736-
# minting blocks again
736+
# forging blocks again
737737
kes_period_info_updated = cluster.g_query.get_kes_period_info(opcert_file)
738738
with open(f"{temp_template}_kes_period_info_3.json", "w", encoding="utf-8") as out_fp:
739739
json.dump(kes_period_info_updated, out_fp, indent=2)

cardano_node_tests/tests/test_ledger_state.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ def _get_delegations(snapshot: str) -> dict[str, list[str]]:
201201
if sum_go != stake_snapshot["total"]["stakeGo"]:
202202
errors.append(f"total_go: {sum_go} != {stake_snapshot['total']['stakeGo']}")
203203
# Active stake can be lower than sum of stakes, as some pools may not be running
204-
# and minting blocks
204+
# and forging blocks
205205
else:
206206
if sum_mark < stake_snapshot["activeStakeMark"]:
207207
errors.append(f"active_mark: {sum_mark} < {stake_snapshot['activeStakeMark']}")

cardano_node_tests/tests/test_pool_saturation.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class PoolRecord:
3535
delegation_out: delegation.DelegationOut
3636
user_rewards: list[RewardRecord]
3737
owner_rewards: list[RewardRecord]
38-
blocks_minted: dict[int, int]
38+
blocks_forged: dict[int, int]
3939
saturation_amounts: dict[int, int]
4040

4141

@@ -96,7 +96,7 @@ def _get_reward_per_block(pool_record: PoolRecord, owner_rewards: bool = False)
9696
assert for_epoch == rew_for.epoch_no
9797
results[for_epoch] = (
9898
rew_received.reward_per_epoch
99-
/ pool_record.blocks_minted[for_epoch]
99+
/ pool_record.blocks_forged[for_epoch]
100100
/ rew_for.stake_total
101101
)
102102

@@ -282,7 +282,7 @@ def _save_pool_records() -> None:
282282
delegation_out=delegation_out,
283283
user_rewards=[],
284284
owner_rewards=[],
285-
blocks_minted={},
285+
blocks_forged={},
286286
saturation_amounts={},
287287
)
288288

@@ -344,7 +344,7 @@ def _save_pool_records() -> None:
344344
prev_user_reward = pool_rec.user_rewards[-1].reward_total
345345
prev_owner_reward = pool_rec.owner_rewards[-1].reward_total
346346

347-
pool_rec.blocks_minted[this_epoch - 1] = (
347+
pool_rec.blocks_forged[this_epoch - 1] = (
348348
ledger_state["blocksBefore"].get(pool_rec.id_dec) or 0
349349
)
350350

0 commit comments

Comments
 (0)