Skip to content

Commit 88fac90

Browse files
committed
WIP
1 parent a8e1850 commit 88fac90

File tree

6 files changed

+183
-61
lines changed

6 files changed

+183
-61
lines changed

cardano_node_tests/cluster_scripts/conway/start-cluster

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1276,6 +1276,8 @@ if [ -n "${PV10:-""}" ]; then
12761276

12771277
echo "Submitting hard fork proposal to update to Conway PV10"
12781278

1279+
# TODO: replace 5d372dca1a4cc90d7d16d966c48270e33e3aa0abcb0e78f0d5ca7ff330d2245d with
1280+
# proper anchor data
12791281
cardano_cli_log conway governance action create-hardfork \
12801282
--testnet \
12811283
--governance-action-deposit "$GOV_ACTION_DEPOSIT" \
@@ -1328,8 +1330,6 @@ if [ -n "${PV10:-""}" ]; then
13281330
--governance-action-tx-id "$ACTION_TXID" \
13291331
--governance-action-index 0 \
13301332
--cc-hot-verification-key-file "$f" \
1331-
--anchor-url "http://www.cc-vote${INDEX}-hf-pv10.com" \
1332-
--anchor-data-hash 5d372dca1a4cc90d7d16d966c48270e33e3aa0abcb0e78f0d5ca7ff330d2245d \
13331333
--out-file "${PV10_ACTION}_cc${INDEX}.vote"
13341334
done
13351335

@@ -1341,8 +1341,6 @@ if [ -n "${PV10:-""}" ]; then
13411341
--governance-action-tx-id "$ACTION_TXID" \
13421342
--governance-action-index 0 \
13431343
--cold-verification-key-file "$f" \
1344-
--anchor-url "http://www.spo-vote${INDEX}-hf-pv10.com" \
1345-
--anchor-data-hash 5d372dca1a4cc90d7d16d966c48270e33e3aa0abcb0e78f0d5ca7ff330d2245d \
13461344
--out-file "${PV10_ACTION}_spo${INDEX}.vote"
13471345
done
13481346

cardano_node_tests/tests/tests_conway/conway_common.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import itertools
55
import json
66
import logging
7+
import pathlib as pl
78
import typing as tp
89

910
from cardano_clusterlib import clusterlib
@@ -12,6 +13,7 @@
1213
from cardano_node_tests.tests import common
1314
from cardano_node_tests.utils import clusterlib_utils
1415
from cardano_node_tests.utils import governance_utils
16+
from cardano_node_tests.utils import web
1517

1618
LOGGER = logging.getLogger(__name__)
1719

@@ -25,6 +27,13 @@ class PParamPropRec:
2527
future_pparams: dict[str, tp.Any]
2628

2729

30+
@dataclasses.dataclass(frozen=True)
31+
class AnchorData:
32+
url: str
33+
hash: str
34+
data_file: pl.Path
35+
36+
2837
def is_in_bootstrap(
2938
cluster_obj: clusterlib.ClusterLib,
3039
) -> bool:
@@ -562,3 +571,14 @@ def propose_pparams_update(
562571
proposal_names=proposal_names,
563572
future_pparams=prop_action["proposalProcedure"]["govAction"]["contents"][1],
564573
)
574+
575+
576+
def get_anchor_data(
577+
cluster_obj: clusterlib.ClusterLib, name_template: str, anchor_text: str
578+
) -> AnchorData:
579+
"""Publish anchor data and return the URL and data hash."""
580+
anchor_file = pl.Path(f"{name_template}_anchor.txt")
581+
anchor_file.write_text(anchor_text, encoding="utf-8")
582+
url = web.publish(file_path=anchor_file)
583+
data_hash = cluster_obj.g_conway_governance.get_anchor_data_hash(file_text=anchor_file)
584+
return AnchorData(url=url, hash=data_hash, data_file=anchor_file)

cardano_node_tests/tests/tests_conway/test_committee.py

Lines changed: 81 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
from cardano_node_tests.utils import helpers
2626
from cardano_node_tests.utils import submit_api
2727
from cardano_node_tests.utils import submit_utils
28+
from cardano_node_tests.utils import web
2829
from cardano_node_tests.utils.versions import VERSIONS
2930

3031
LOGGER = logging.getLogger(__name__)
@@ -180,8 +181,12 @@ def test_update_committee_action(
180181
]
181182

182183
deposit_amt = cluster.conway_genesis["govActionDeposit"]
183-
anchor_url = "http://www.cc-update.com"
184-
anchor_data_hash = "5d372dca1a4cc90d7d16d966c48270e33e3aa0abcb0e78f0d5ca7ff330d2245d"
184+
anchor_text = f"Update committee action, temp ID {temp_template}"
185+
anchor_data = conway_common.get_anchor_data(
186+
cluster_obj=cluster,
187+
name_template=temp_template,
188+
anchor_text=anchor_text,
189+
)
185190
prev_action_rec = governance_utils.get_prev_action(
186191
action_type=governance_utils.PrevGovActionIds.COMMITTEE,
187192
gov_state=cluster.g_conway_governance.query.gov_state(),
@@ -191,8 +196,8 @@ def test_update_committee_action(
191196
update_action = cluster.g_conway_governance.action.update_committee(
192197
action_name=temp_template,
193198
deposit_amt=deposit_amt,
194-
anchor_url=anchor_url,
195-
anchor_data_hash=anchor_data_hash,
199+
anchor_url=anchor_data.url,
200+
anchor_data_hash=anchor_data.hash,
196201
threshold=threshold,
197202
add_cc_members=cc_members,
198203
prev_action_txid=prev_action_rec.txid,
@@ -458,9 +463,11 @@ def _auth_hot_keys() -> None:
458463

459464
def _add_members() -> tuple[clusterlib.ActionUpdateCommittee, str, int]:
460465
"""Add new CC members."""
461-
anchor_url_add = "http://www.cc-add.com"
462-
anchor_data_hash_add = (
463-
"5d372dca1a4cc90d7d16d966c48270e33e3aa0abcb0e78f0d5ca7ff330d2245d"
466+
anchor_text_add = f"Add CC member action, temp ID {temp_template}"
467+
anchor_data_add = conway_common.get_anchor_data(
468+
cluster_obj=cluster,
469+
name_template=f"{temp_template}_add",
470+
anchor_text=anchor_text_add,
464471
)
465472
prev_action_rec = governance_utils.get_prev_action(
466473
action_type=governance_utils.PrevGovActionIds.COMMITTEE,
@@ -472,8 +479,8 @@ def _add_members() -> tuple[clusterlib.ActionUpdateCommittee, str, int]:
472479
add_cc_action = cluster.g_conway_governance.action.update_committee(
473480
action_name=f"{temp_template}_add",
474481
deposit_amt=deposit_amt,
475-
anchor_url=anchor_url_add,
476-
anchor_data_hash=anchor_data_hash_add,
482+
anchor_url=anchor_data_add.url,
483+
anchor_data_hash=anchor_data_add.hash,
477484
threshold=str(cluster.conway_genesis["committee"]["threshold"]),
478485
add_cc_members=[*cc_members, cc_members[0]], # test adding the same member twice
479486
prev_action_txid=prev_action_rec.txid,
@@ -532,11 +539,19 @@ def _resign_member(res_member: clusterlib.CCMember) -> None:
532539
_url = helpers.get_vcs_link()
533540
[r.start(url=_url) for r in (reqc.cli007, reqc.cip012)]
534541

542+
res_metadata_file = pl.Path(f"{temp_template}_res_metadata.json")
543+
res_metadata_content = {"name": "The DRep", "ranking": "uno"}
544+
helpers.write_json(out_file=res_metadata_file, content=res_metadata_content)
545+
res_metadata_hash = cluster.g_conway_governance.get_anchor_data_hash(
546+
file_text=res_metadata_file
547+
)
548+
res_metadata_url = web.publish(file_path=res_metadata_file)
549+
535550
res_cert = cluster.g_conway_governance.committee.gen_cold_key_resignation_cert(
536551
key_name=temp_template,
537552
cold_vkey_file=res_member.cold_vkey_file,
538-
resignation_metadata_url="http://www.cc-resign.com",
539-
resignation_metadata_hash="5d372dca1a4cc90d7d16d966c48270e33e3aa0abcb0e78f0d5ca7ff330d2245d",
553+
resignation_metadata_url=res_metadata_url,
554+
resignation_metadata_hash=res_metadata_hash,
540555
)
541556
reqc.cli007.success()
542557

@@ -574,17 +589,19 @@ def _remove_member(
574589
rem_member: clusterlib.CCMember, prev_action_txid: str, prev_action_ix: int
575590
) -> tuple[clusterlib.ActionUpdateCommittee, str, int]:
576591
"""Remove a CC member."""
577-
anchor_url_rem = "http://www.cc-rem.com"
578-
anchor_data_hash_rem = (
579-
"5d372dca1a4cc90d7d16d966c48270e33e3aa0abcb0e78f0d5ca7ff330d2245d"
592+
anchor_text_rem = f"Rem CC member action, temp ID {temp_template}"
593+
anchor_data_rem = conway_common.get_anchor_data(
594+
cluster_obj=cluster,
595+
name_template=f"{temp_template}_rem",
596+
anchor_text=anchor_text_rem,
580597
)
581598

582599
reqc.cip005.start(url=helpers.get_vcs_link())
583600
rem_cc_action = cluster.g_conway_governance.action.update_committee(
584601
action_name=f"{temp_template}_rem",
585602
deposit_amt=deposit_amt,
586-
anchor_url=anchor_url_rem,
587-
anchor_data_hash=anchor_data_hash_rem,
603+
anchor_url=anchor_data_rem.url,
604+
anchor_data_hash=anchor_data_rem.hash,
588605
threshold=str(cluster.conway_genesis["committee"]["threshold"]),
589606
rem_cc_members=[rem_member],
590607
prev_action_txid=prev_action_txid,
@@ -646,14 +663,25 @@ def _resign_active():
646663
cluster_obj=cluster, start=1, stop=common.EPOCH_STOP_SEC_BUFFER
647664
)
648665

666+
def _get_res_cert(idx: int, cc_auth: governance_utils.CCMemberAuth) -> pl.Path:
667+
res_metadata_file = pl.Path(f"{temp_template}_{idx}_res_metadata.json")
668+
res_metadata_content = {"name": "The DRep", "ranking": "uno", "idx": idx}
669+
helpers.write_json(out_file=res_metadata_file, content=res_metadata_content)
670+
res_metadata_hash = cluster.g_conway_governance.get_anchor_data_hash(
671+
file_text=res_metadata_file
672+
)
673+
res_metadata_url = web.publish(file_path=res_metadata_file)
674+
cert = cluster.g_conway_governance.committee.gen_cold_key_resignation_cert(
675+
key_name=f"{temp_template}_res{idx}",
676+
cold_vkey_file=cc_auth.cold_key_pair.vkey_file,
677+
resignation_metadata_url=res_metadata_url,
678+
resignation_metadata_hash=res_metadata_hash,
679+
)
680+
return cert
681+
649682
auth_committee_state = cluster.g_conway_governance.query.committee_state()
650683
res_certs = [
651-
cluster.g_conway_governance.committee.gen_cold_key_resignation_cert(
652-
key_name=f"{temp_template}_res{i}",
653-
cold_vkey_file=r.cold_key_pair.vkey_file,
654-
resignation_metadata_url="http://www.cc-resign.com",
655-
resignation_metadata_hash="5d372dca1a4cc90d7d16d966c48270e33e3aa0abcb0e78f0d5ca7ff330d2245d",
656-
)
684+
_get_res_cert(idx=i, cc_auth=r)
657685
for i, r in enumerate((cc_auth_record1, cc_auth_record2, cc_auth_record3))
658686
if governance_utils.is_cc_active(
659687
auth_committee_state["committee"].get(f"keyHash-{r.key_hash}") or {}
@@ -1072,8 +1100,12 @@ def test_empty_committee(
10721100

10731101
def _set_zero_committee_pparam() -> conway_common.PParamPropRec:
10741102
"""Set the `committeeMinSize` pparam to 0."""
1075-
anchor_url = "http://www.pparam-cc-min-size.com"
1076-
anchor_data_hash = "5d372dca1a4cc90d7d16d966c48270e33e3aa0abcb0e78f0d5ca7ff330d2245d"
1103+
anchor_text = f"Set `committeeMinSize` pparam to 0, temp ID {temp_template}"
1104+
anchor_data = conway_common.get_anchor_data(
1105+
cluster_obj=cluster,
1106+
name_template=f"{temp_template}_zero_cc",
1107+
anchor_text=anchor_text,
1108+
)
10771109

10781110
update_proposals = [
10791111
clusterlib_utils.UpdateProposal(
@@ -1086,17 +1118,19 @@ def _set_zero_committee_pparam() -> conway_common.PParamPropRec:
10861118
return conway_common.propose_pparams_update(
10871119
cluster_obj=cluster,
10881120
name_template=f"{temp_template}_zero_cc",
1089-
anchor_url=anchor_url,
1090-
anchor_data_hash=anchor_data_hash,
1121+
anchor_url=anchor_data.url,
1122+
anchor_data_hash=anchor_data.hash,
10911123
pool_user=pool_user_lg,
10921124
proposals=update_proposals,
10931125
)
10941126

10951127
def _rem_committee() -> tuple[clusterlib.ActionUpdateCommittee, str, int]:
10961128
"""Remove all CC members."""
1097-
anchor_url_rem = "http://www.cc-rem-all.com"
1098-
anchor_data_hash_rem = (
1099-
"5d372dca1a4cc90d7d16d966c48270e33e3aa0abcb0e78f0d5ca7ff330d2245d"
1129+
anchor_text = f"Remove all CC members, temp ID {temp_template}"
1130+
anchor_data = conway_common.get_anchor_data(
1131+
cluster_obj=cluster,
1132+
name_template=f"{temp_template}_rem",
1133+
anchor_text=anchor_text,
11001134
)
11011135
prev_action_rec = governance_utils.get_prev_action(
11021136
action_type=governance_utils.PrevGovActionIds.COMMITTEE,
@@ -1106,8 +1140,8 @@ def _rem_committee() -> tuple[clusterlib.ActionUpdateCommittee, str, int]:
11061140
rem_cc_action = cluster.g_conway_governance.action.update_committee(
11071141
action_name=f"{temp_template}_rem",
11081142
deposit_amt=deposit_amt,
1109-
anchor_url=anchor_url_rem,
1110-
anchor_data_hash=anchor_data_hash_rem,
1143+
anchor_url=anchor_data.url,
1144+
anchor_data_hash=anchor_data.hash,
11111145
threshold="0.0",
11121146
rem_cc_members=[r.cc_member for r in governance_data.cc_key_members],
11131147
prev_action_txid=prev_action_rec.txid,
@@ -1371,8 +1405,12 @@ def test_update_committee_threshold_out_of_range(
13711405
temp_template = f"{common.get_test_id(cluster)}_{common.unique_time_str()}"
13721406

13731407
deposit_amt = cluster.conway_genesis["govActionDeposit"]
1374-
anchor_url = "http://www.cc-update.com"
1375-
anchor_data_hash = "5d372dca1a4cc90d7d16d966c48270e33e3aa0abcb0e78f0d5ca7ff330d2245d"
1408+
anchor_text = f"Update committee action, temp ID {temp_template}"
1409+
anchor_data = conway_common.get_anchor_data(
1410+
cluster_obj=cluster,
1411+
name_template=temp_template,
1412+
anchor_text=anchor_text,
1413+
)
13761414
prev_action_rec = governance_utils.get_prev_action(
13771415
action_type=governance_utils.PrevGovActionIds.COMMITTEE,
13781416
gov_state=cluster.g_conway_governance.query.gov_state(),
@@ -1382,8 +1420,8 @@ def test_update_committee_threshold_out_of_range(
13821420
cluster.g_conway_governance.action.update_committee(
13831421
action_name=temp_template,
13841422
deposit_amt=deposit_amt,
1385-
anchor_url=anchor_url,
1386-
anchor_data_hash=anchor_data_hash,
1423+
anchor_url=anchor_data.url,
1424+
anchor_data_hash=anchor_data.hash,
13871425
threshold=str(threshold),
13881426
prev_action_txid=prev_action_rec.txid,
13891427
prev_action_ix=prev_action_rec.ix,
@@ -1453,8 +1491,12 @@ def _check_rat_enact_state(
14531491
assert prev_action_rec.txid == action_txid, "Action not enacted"
14541492

14551493
deposit_amt = cluster.conway_genesis["govActionDeposit"]
1456-
anchor_url = "http://www.cc-update.com"
1457-
anchor_data_hash = "5d372dca1a4cc90d7d16d966c48270e33e3aa0abcb0e78f0d5ca7ff330d2245d"
1494+
anchor_text = f"Update committee action, temp ID {temp_template}"
1495+
anchor_data = conway_common.get_anchor_data(
1496+
cluster_obj=cluster,
1497+
name_template=temp_template,
1498+
anchor_text=anchor_text,
1499+
)
14581500
prev_action_rec = governance_utils.get_prev_action(
14591501
action_type=governance_utils.PrevGovActionIds.COMMITTEE,
14601502
gov_state=cluster.g_conway_governance.query.gov_state(),
@@ -1464,8 +1506,8 @@ def _check_rat_enact_state(
14641506
update_threshold_action = cluster.g_conway_governance.action.update_committee(
14651507
action_name=temp_template,
14661508
deposit_amt=deposit_amt,
1467-
anchor_url=anchor_url,
1468-
anchor_data_hash=anchor_data_hash,
1509+
anchor_url=anchor_data.url,
1510+
anchor_data_hash=anchor_data.hash,
14691511
threshold="0",
14701512
prev_action_txid=prev_action_rec.txid,
14711513
prev_action_ix=prev_action_rec.ix,

cardano_node_tests/tests/tests_conway/test_constitution.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
from cardano_node_tests.utils import governance_setup
2323
from cardano_node_tests.utils import governance_utils
2424
from cardano_node_tests.utils import helpers
25+
from cardano_node_tests.utils import web
2526
from cardano_node_tests.utils.versions import VERSIONS
2627

2728
LOGGER = logging.getLogger(__name__)
@@ -348,10 +349,13 @@ def test_change_constitution(
348349

349350
# Create an action
350351

351-
anchor_url = f"http://www.const-action-{rand_str}.com"
352-
anchor_data_hash = cluster.g_conway_governance.get_anchor_data_hash(text=anchor_url)
352+
anchor_text = f"Change constitution action, temp ID {temp_template}"
353+
anchor_data = conway_common.get_anchor_data(
354+
cluster_obj=cluster,
355+
name_template=temp_template,
356+
anchor_text=anchor_text,
357+
)
353358

354-
constitution_file = f"{temp_template}_constitution.txt"
355359
constitution_text = (
356360
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, "
357361
"sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. "
@@ -361,10 +365,10 @@ def test_change_constitution(
361365
"Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia "
362366
"deserunt mollit anim id est laborum."
363367
)
364-
with open(constitution_file, "w", encoding="utf-8") as out_fp:
365-
out_fp.write(constitution_text)
368+
constitution_file = pl.Path(f"{temp_template}_constitution.txt")
369+
constitution_file.write_text(data=constitution_text, encoding="utf-8")
370+
constitution_url = web.publish(file_path=constitution_file)
366371

367-
constitution_url = f"http://www.const-new-{rand_str}.com"
368372
reqc.cli002.start(url=helpers.get_vcs_link())
369373
constitution_hash = cluster.g_conway_governance.get_anchor_data_hash(
370374
file_text=constitution_file
@@ -377,8 +381,8 @@ def test_change_constitution(
377381
conway_common.propose_change_constitution(
378382
cluster_obj=cluster,
379383
name_template=f"{temp_template}_constitution_bootstrap",
380-
anchor_url=anchor_url,
381-
anchor_data_hash=anchor_data_hash,
384+
anchor_url=anchor_data.url,
385+
anchor_data_hash=anchor_data.hash,
382386
constitution_url=constitution_url,
383387
constitution_hash=constitution_hash,
384388
pool_user=pool_user_lg,
@@ -397,8 +401,8 @@ def test_change_constitution(
397401
) = conway_common.propose_change_constitution(
398402
cluster_obj=cluster,
399403
name_template=f"{temp_template}_constitution",
400-
anchor_url=anchor_url,
401-
anchor_data_hash=anchor_data_hash,
404+
anchor_url=anchor_data.url,
405+
anchor_data_hash=anchor_data.hash,
402406
constitution_url=constitution_url,
403407
constitution_hash=constitution_hash,
404408
pool_user=pool_user_lg,

0 commit comments

Comments
 (0)