Skip to content

Commit

Permalink
Merge pull request #2641 from IntersectMBO/upgrade_testing_from_conway
Browse files Browse the repository at this point in the history
feat: upgrade testing from Conway era
  • Loading branch information
mkoura committed Sep 20, 2024
2 parents dfc219a + 9f30e5a commit a812c91
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 188 deletions.
88 changes: 17 additions & 71 deletions .github/node_upgrade_pytest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@ retval=1

export CARDANO_NODE_SOCKET_PATH="$CARDANO_NODE_SOCKET_PATH_CI"

export CLUSTER_ERA="${CLUSTER_ERA:-"babbage"}"
export TX_ERA="$CLUSTER_ERA"
export CLUSTER_ERA="${CLUSTER_ERA:-"conway"}"
export COMMAND_ERA="$CLUSTER_ERA"

CLUSTER_SCRIPTS_DIR="$WORKDIR/cluster0_${CLUSTER_ERA}"
STATE_CLUSTER="${CARDANO_NODE_SOCKET_PATH_CI%/*}"
NUM_CC=5

# init dir for step1 binaries
STEP1_BIN="$WORKDIR/step1-bin"
Expand Down Expand Up @@ -163,35 +162,20 @@ elif [ "$1" = "step2" ]; then
selected_conway_file="shelley/genesis.conway.json"
fi

# If the base revision doesn't have Conway genesis and the config file is for pool3,
# then don't add Conway genesis records.
if [[ "$fname" = "config-pool3.json" && "$selected_conway_hash" = "" ]]; then
jq \
--arg byron_hash "$BYRON_GENESIS_HASH" \
--arg shelley_hash "$SHELLEY_GENESIS_HASH" \
--arg alonzo_file "$selected_alonzo_file" \
--arg alonzo_hash "$selected_alonzo_hash" \
'.ByronGenesisHash = $byron_hash
| .ShelleyGenesisHash = $shelley_hash
| .AlonzoGenesisFile = $alonzo_file
| .AlonzoGenesisHash = $alonzo_hash' \
"$conf" > "$STATE_CLUSTER/$fname"
else
jq \
--arg byron_hash "$BYRON_GENESIS_HASH" \
--arg shelley_hash "$SHELLEY_GENESIS_HASH" \
--arg alonzo_file "$selected_alonzo_file" \
--arg alonzo_hash "$selected_alonzo_hash" \
--arg conway_file "$selected_conway_file" \
--arg conway_hash "$selected_conway_hash" \
'.ByronGenesisHash = $byron_hash
| .ShelleyGenesisHash = $shelley_hash
| .AlonzoGenesisFile = $alonzo_file
| .AlonzoGenesisHash = $alonzo_hash
| .ConwayGenesisFile = $conway_file
| .ConwayGenesisHash = $conway_hash' \
"$conf" > "$STATE_CLUSTER/$fname"
fi
jq \
--arg byron_hash "$BYRON_GENESIS_HASH" \
--arg shelley_hash "$SHELLEY_GENESIS_HASH" \
--arg alonzo_file "$selected_alonzo_file" \
--arg alonzo_hash "$selected_alonzo_hash" \
--arg conway_file "$selected_conway_file" \
--arg conway_hash "$selected_conway_hash" \
'.ByronGenesisHash = $byron_hash
| .ShelleyGenesisHash = $shelley_hash
| .AlonzoGenesisFile = $alonzo_file
| .AlonzoGenesisHash = $alonzo_hash
| .ConwayGenesisFile = $conway_file
| .ConwayGenesisHash = $conway_hash' \
"$conf" > "$STATE_CLUSTER/$fname"
done

# run the pool3 with the original cardano-node binary
Expand Down Expand Up @@ -297,42 +281,11 @@ elif [ "$1" = "step3" ]; then
# copy newly generated topology files to the cluster state dir
cp -f "$WORKDIR"/dry_p2p/state-cluster0/topology-*.json "$STATE_CLUSTER"

# Create committee keys
mkdir -p "$STATE_CLUSTER/governance_data"
for i in $(seq 1 "$NUM_CC"); do
cardano-cli conway governance committee key-gen-cold \
--cold-verification-key-file "$STATE_CLUSTER/governance_data/cc_member${i}_committee_cold.vkey" \
--cold-signing-key-file "$STATE_CLUSTER/governance_data/cc_member${i}_committee_cold.skey"
cardano-cli conway governance committee key-gen-hot \
--verification-key-file "$STATE_CLUSTER/governance_data/cc_member${i}_committee_hot.vkey" \
--signing-key-file "$STATE_CLUSTER/governance_data/cc_member${i}_committee_hot.skey"
cardano-cli conway governance committee create-hot-key-authorization-certificate \
--cold-verification-key-file "$STATE_CLUSTER/governance_data/cc_member${i}_committee_cold.vkey" \
--hot-verification-key-file "$STATE_CLUSTER/governance_data/cc_member${i}_committee_hot.vkey" \
--out-file "$STATE_CLUSTER/governance_data/cc_member${i}_committee_hot_auth.cert"
cardano-cli conway governance committee key-hash \
--verification-key-file "$STATE_CLUSTER/governance_data/cc_member${i}_committee_cold.vkey" \
> "$STATE_CLUSTER/governance_data/cc_member${i}_committee_cold.hash"
done

# Pre-register committee in genesis
cp -f "$STATE_CLUSTER/shelley/genesis.conway.json" "$STATE_CLUSTER/shelley/genesis.conway.step2.json"
KEY_HASH_JSON=$(jq -nR '[inputs | {("keyHash-" + .): 10000}] | add' \
"$STATE_CLUSTER"/governance_data/cc_member*_committee_cold.hash)
jq \
--argjson keyHashJson "$KEY_HASH_JSON" \
'.committee.members = $keyHashJson
| .committee.threshold = 0.6
| .committeeMinSize = 2' \
"$STATE_CLUSTER/shelley/genesis.conway.step2.json" > "$STATE_CLUSTER/shelley/genesis.conway.json"

# Copy newly generated config files to the cluster state dir, but use the original genesis files
BYRON_GENESIS_HASH="$(jq -r ".ByronGenesisHash" "$STATE_CLUSTER/config-bft1.json")"
SHELLEY_GENESIS_HASH="$(jq -r ".ShelleyGenesisHash" "$STATE_CLUSTER/config-bft1.json")"
ALONZO_GENESIS_HASH="$(jq -r ".AlonzoGenesisHash" "$STATE_CLUSTER/config-bft1.json")"
# Use the new Conway genesis
CONWAY_GENESIS_HASH="$(cardano-cli genesis hash --genesis \
"$STATE_CLUSTER/shelley/genesis.conway.json")"
CONWAY_GENESIS_HASH="$(jq -r ".ConwayGenesisHash" "$STATE_CLUSTER/config-bft1.json")"
for conf in "$WORKDIR"/dry_p2p/state-cluster0/config-*.json; do
fname="${conf##*/}"
jq \
Expand Down Expand Up @@ -371,13 +324,6 @@ elif [ "$1" = "step3" ]; then
pytest cardano_node_tests/tests/test_node_upgrade.py -k test_ignore_log_errors
err_retval="$?"

# Update to Conway
pytest cardano_node_tests/tests/test_node_upgrade.py -k test_update_to_conway_pv9 || exit 6

# From now on, we are in the Conway era
unset TX_ERA
export CLUSTER_ERA=conway COMMAND_ERA=conway

# Run smoke tests
pytest \
cardano_node_tests \
Expand Down
111 changes: 0 additions & 111 deletions cardano_node_tests/tests/test_node_upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@

from cardano_node_tests.cluster_management import cluster_management
from cardano_node_tests.tests import common
from cardano_node_tests.utils import cluster_nodes
from cardano_node_tests.utils import clusterlib_utils
from cardano_node_tests.utils import governance_utils
from cardano_node_tests.utils import helpers
from cardano_node_tests.utils import logfiles
from cardano_node_tests.utils import temptools
Expand Down Expand Up @@ -104,115 +102,6 @@ def test_ignore_log_errors(
ignore_file_id=worker_id,
)

@allure.link(helpers.get_vcs_link())
@pytest.mark.skipif(UPGRADE_TESTS_STEP != 3, reason="runs only on step 3 of upgrade testing")
def test_update_to_conway_pv9(
self,
cluster_singleton: clusterlib.ClusterLib,
payment_addr_locked: clusterlib.AddressRecord,
):
"""Update cluster to Conway PV9."""
cluster = cluster_singleton
temp_template = common.get_test_id(cluster)

def _update_to_pv9() -> None:
cluster.wait_for_new_epoch()

update_proposal_pv9 = [
clusterlib_utils.UpdateProposal(
arg="--protocol-major-version",
value=9,
name="", # needs custom check
),
clusterlib_utils.UpdateProposal(
arg="--protocol-minor-version",
value=0,
name="", # needs custom check
),
]

clusterlib_utils.update_params(
cluster_obj=cluster,
src_addr_record=payment_addr_locked,
update_proposals=update_proposal_pv9,
)

cluster.wait_for_new_epoch(padding_seconds=3)

prot_ver = cluster.g_query.get_protocol_params()["protocolVersion"]
assert prot_ver["major"] == 9
assert prot_ver["minor"] == 0

def _load_cc_members(
cluster_obj: clusterlib.ClusterLib,
) -> tp.List[governance_utils.CCMemberAuth]:
data_dir = cluster_obj.state_dir / GOV_DATA_DIR

cc_members = []
for vkey_file in sorted(data_dir.glob("cc_member*_committee_cold.vkey")):
fpath = vkey_file.parent
fbase = vkey_file.name.replace("cold.vkey", "")
hot_vkey_file = fpath / f"{fbase}hot.vkey"
cold_vkey_hash = cluster_obj.g_conway_governance.committee.get_key_hash(
vkey_file=vkey_file
)
auth_cert = fpath / f"{fbase}hot_auth.cert"
cold_key_pair = clusterlib.KeyPair(
vkey_file=vkey_file, skey_file=fpath / f"{fbase}cold.skey"
)
hot_key_pair = clusterlib.KeyPair(
vkey_file=hot_vkey_file, skey_file=fpath / f"{fbase}hot.skey"
)
cc_members.append(
governance_utils.CCMemberAuth(
auth_cert=auth_cert,
cold_key_pair=cold_key_pair,
hot_key_pair=hot_key_pair,
key_hash=cold_vkey_hash,
)
)

return cc_members

def _reg_cc_members(
cluster_obj: clusterlib.ClusterLib, cc_members: tp.List[governance_utils.CCMemberAuth]
) -> None:
tx_files = clusterlib.TxFiles(
certificate_files=[c.auth_cert for c in cc_members],
signing_key_files=[
payment_addr_locked.skey_file,
*[c.cold_key_pair.skey_file for c in cc_members],
],
)

tx_output_auth = clusterlib_utils.build_and_submit_tx(
cluster_obj=cluster_obj,
name_template=f"{temp_template}_auth",
src_address=payment_addr_locked.address,
tx_files=tx_files,
)

auth_out_utxos = cluster_obj.g_query.get_utxo(tx_raw_output=tx_output_auth)
assert (
clusterlib.filter_utxos(utxos=auth_out_utxos, address=payment_addr_locked.address)[
0
].amount
== clusterlib.calculate_utxos_balance(tx_output_auth.txins) - tx_output_auth.fee
), f"Incorrect balance for source address `{payment_addr_locked.address}`"

auth_committee_state = cluster_obj.g_conway_governance.query.committee_state()
for cm in cc_members:
member_key = f"keyHash-{cm.key_hash}"
member_rec = auth_committee_state["committee"][member_key]
assert (
member_rec["hotCredsAuthStatus"]["tag"] == "MemberAuthorized"
), "CC Member was NOT authorized"

_update_to_pv9()
cluster_conway = cluster_nodes.get_cluster_type().get_cluster_obj(command_era="conway")
cc_members = _load_cc_members(cluster_obj=cluster_conway)
_reg_cc_members(cluster_obj=cluster_conway, cc_members=cc_members)


@pytest.mark.upgrade
class TestUpgrade:
Expand Down
9 changes: 3 additions & 6 deletions src_docs/source/test_results/nightly_system_tests.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,17 @@ Nightly upgrade testing

* `Step 1 <https://cardano-tests-reports-3-74-115-22.nip.io/cardano-node-tests-nightly-upgrade/step1/>`__: |nightly-upgrade-step1-badge|
* use the `latest cardano-node release <https://github.com/IntersectMBO/cardano-node-tests/blob/master/.github/env_nightly_upgrade>`__ for Mainnet
* network in Babbage era
* Babbage transaction era
* network in Conway era
* protocol version 9 (bootstrap phase)
* Constitutional Commitee has 5 members
* default (legacy) network topology
* smoke tests
* `Step 2 <https://cardano-tests-reports-3-74-115-22.nip.io/cardano-node-tests-nightly-upgrade/step2/>`__: |nightly-upgrade-step2-badge|
* upgrade all nodes except one to latest cardano-node master
* network in Babbage era
* Babbage transaction era
* mixed network topology (half nodes P2P, half nodes legacy topology)
* smoke tests
* `Step 3 <https://cardano-tests-reports-3-74-115-22.nip.io/cardano-node-tests-nightly-upgrade/step3/>`__: |nightly-upgrade-step3-badge|
* upgrade the last remaining node to latest cardano-node master
* network in Babbage era
* Babbage transaction era
* P2P network topology
* smoke tests

Expand Down

0 comments on commit a812c91

Please sign in to comment.