Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@
7305,
-900,
1716,
549,
960,
57,
85848,
0,
Expand All @@ -419,9 +419,9 @@
42921,
4,
2,
24548,
29498,
38,
30623,
28755,
75,
1,
898148,
27279,
Expand Down Expand Up @@ -474,7 +474,7 @@
7305,
-900,
1716,
549,
960,
57,
85848,
0,
Expand All @@ -490,7 +490,7 @@
7305,
-900,
1716,
549,
960,
57,
85848,
0,
Expand All @@ -501,7 +501,7 @@
7305,
-900,
1716,
549,
960,
57,
85848,
0,
Expand Down Expand Up @@ -651,6 +651,59 @@
1,
1964219,
24520,
3
3,
607153,
231697,
53144,
0,
1,
116711,
1957,
4,
231883,
10,
1000,
24838,
7,
1,
232010,
32,
321837444,
25087669,
18,
617887431,
67302824,
36,
356924,
18413,
45,
21,
219951,
9444,
1,
1000,
172116,
183150,
6,
24,
21,
213283,
618401,
1998,
28258,
1,
1000,
38159,
2,
22,
1000,
95933,
1,
1,
11,
1000,
277577,
12,
21
]
}
14 changes: 14 additions & 0 deletions cardano_node_tests/tests/test_node_upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ def test_update_cost_models(
Test updating Plutus cost models after node upgrade. Runs only on step 2 of upgrade
testing sequence.

* Check that the cost model update is actually needed at this point
* Load cost model proposal from JSON file (PlutusV2 and PlutusV3 models)
* Get default governance data (DReps, committee members, pools)
* Submit cost model update governance action
Expand All @@ -142,6 +143,19 @@ def test_update_cost_models(
cluster = cluster_singleton
temp_template = common.get_test_id(cluster)
cost_proposal_file = DATA_DIR / "cost_models_list_185_297_v2_v3.json"
cost_models_to_check = ("PlutusV2", "PlutusV3")

# This step is expected to run against a cost model that is still short. If it's
# already at the proposed length, the "cost model not yet updated" scenario was
# missed, e.g. the cluster started with it already updated.
assert conway_common.is_cost_model_update_needed(
cluster_obj=cluster,
cost_proposal_file=cost_proposal_file,
cost_models_to_check=cost_models_to_check,
), (
"Cost model(s) already at or above the proposed length before the update. "
"The 'cost model not yet updated' test scenario would be missed."
)

governance_data = governance_setup.get_default_governance(
cluster_manager=cluster_manager, cluster_obj=cluster
Expand Down
25 changes: 25 additions & 0 deletions cardano_node_tests/tests/tests_conway/conway_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,31 @@ def propose_pparams_update(
)


def is_cost_model_update_needed(
cluster_obj: clusterlib.ClusterLib,
cost_proposal_file: pl.Path,
cost_models_to_check: tp.Sequence[str],
) -> bool:
"""Check whether any of `cost_models_to_check` is still below its proposed length.

`cost_proposal_file` can bundle cost models that aren't the actual subject of the
calling test, e.g. carried along unchanged because the CLI needs a full file. Only
`cost_models_to_check` is compared, other cost models in the file are ignored.

Returns:
True if at least one of `cost_models_to_check` is below its proposed length, i.e.
an update is still needed. False if all of them are already at or above it.
"""
with open(cost_proposal_file, encoding="utf-8") as fp:
cost_models_in = json.load(fp)

live_cost_models = cluster_obj.g_query.get_protocol_params()["costModels"]
return any(
len(live_cost_models.get(name, [])) < len(cost_models_in[name])
for name in cost_models_to_check
)


def update_cost_model(
cluster_obj: clusterlib.ClusterLib,
name_template: str,
Expand Down
Loading