-
Notifications
You must be signed in to change notification settings - Fork 52
Adapt end-to-end test for on-chain configuration parameters #3489
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
turmelclem
merged 3 commits into
main
from
ctl/3396-adapt-end-to-end-tests-for-on-chain-configuration-parameters-2
Aug 25, 2026
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
ae11905
feature(end-to-end): adapt tests tu support protocol configurations o…
turmelclem 81ecb86
refactor(end-to-end): add a argument for signers to read protocol con…
turmelclem ad65ef2
chore: upgrade crate versions and `mithril-test-lab/cardano-devnet/VE…
turmelclem File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,2 @@ | ||
| 0.4.39 | ||
| 0.4.40 | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
237 changes: 237 additions & 0 deletions
237
mithril-test-lab/cardano-devnet/mkfiles/mkfiles-protocol-configuration.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,237 @@ | ||
| # Create Mithril protocol configuration keypair and address | ||
| ADDR=protocol-config | ||
|
|
||
| ## Payment address keys | ||
| $CARDANO_CLI "$CARDANO_CLI_ERA" address key-gen \ | ||
| --verification-key-file addresses/${ADDR}.vkey \ | ||
| --signing-key-file addresses/${ADDR}.skey | ||
|
|
||
| ## Payment addresses | ||
| $CARDANO_CLI "$CARDANO_CLI_ERA" address build \ | ||
| --payment-verification-key-file addresses/${ADDR}.vkey \ | ||
| --testnet-magic "${NETWORK_MAGIC}" \ | ||
| --out-file addresses/${ADDR}.addr | ||
|
|
||
| ## Write datums for protocol configuration address | ||
| N=1 | ||
| SCRIPT_TX_VALUE=7200000 | ||
| AMOUNT_TRANSFERRED=$(( SCRIPT_TX_VALUE * 10 )) | ||
| MITHRIL_PROTOCOL_CONFIG_ERROR_FILE=./protocol-config-error | ||
| cat >> protocol-configuration.sh <<EOF | ||
| #!/usr/bin/env bash | ||
| set -e | ||
|
|
||
| # Wait for a number of blocks has elapsed | ||
| function wait_for_elapsed_blocks { | ||
| CARDANO_BLOCK_OFFSET=\$1 | ||
| CARDANO_NEXT_BLOCK_WAIT_ROUNDS_MAX=30 | ||
| CARDANO_NEXT_BLOCK_WAIT_ROUNDS=1 | ||
| CARDANO_NEXT_BLOCK_WAIT_ROUND_DELAY=2 | ||
| CURRENT_CARDANO_BLOCK=\$(CARDANO_NODE_SOCKET_PATH=node-pool${N}/ipc/node.sock $CARDANO_CLI $CARDANO_CLI_ERA query tip \\ | ||
| --testnet-magic ${NETWORK_MAGIC} \\ | ||
| | jq -r '.block') | ||
| while true | ||
| do | ||
| CARDANO_BLOCK_TARGET=\$(( \${CURRENT_CARDANO_BLOCK} + \${CARDANO_BLOCK_OFFSET} )) | ||
| CARDANO_BLOCK=\$(CARDANO_NODE_SOCKET_PATH=node-pool${N}/ipc/node.sock $CARDANO_CLI $CARDANO_CLI_ERA query tip \\ | ||
| --testnet-magic ${NETWORK_MAGIC} \\ | ||
| | jq -r '.block') | ||
| if [ \$CARDANO_BLOCK -lt \$CARDANO_BLOCK_TARGET ] ; then | ||
| echo ">>>> Cardano target block not reached yet... [current: \$CARDANO_BLOCK, target: \$CARDANO_BLOCK_TARGET] [attempt \$CARDANO_NEXT_BLOCK_WAIT_ROUNDS]" | ||
| sleep \$CARDANO_NEXT_BLOCK_WAIT_ROUND_DELAY | ||
| else | ||
| echo ">>>> Cardano target block is reached [current: \$CARDANO_BLOCK, target: \$CARDANO_BLOCK_TARGET] [attempt \$CARDANO_NEXT_BLOCK_WAIT_ROUNDS]" | ||
| break | ||
| fi | ||
| CARDANO_NEXT_BLOCK_WAIT_ROUNDS=\$(( \$CARDANO_NEXT_BLOCK_WAIT_ROUNDS + 1 )) | ||
| if [ "\$CARDANO_NEXT_BLOCK_WAIT_ROUNDS" -gt "\$CARDANO_NEXT_BLOCK_WAIT_ROUNDS_MAX" ] ; then | ||
| echo ">>>> Timeout: Cardano target block was not reached within \$CARDANO_NEXT_BLOCK_WAIT_ROUNDS_MAX attempts" | ||
| exit 1 | ||
| fi | ||
| done | ||
| } | ||
|
|
||
| # Send funds to protocol configuration address | ||
| function send_funds_to_protocol_config_address { | ||
| # Remove if exists previous error file | ||
| rm -f ${MITHRIL_PROTOCOL_CONFIG_ERROR_FILE} | ||
|
|
||
| # Get current Cardano era | ||
| CURRENT_CARDANO_ERA=\$(CARDANO_NODE_SOCKET_PATH=node-pool${N}/ipc/node.sock $CARDANO_CLI $CARDANO_CLI_ERA query tip \\ | ||
| --testnet-magic ${NETWORK_MAGIC} \\ | ||
| | jq -r '.era |= ascii_downcase | .era') | ||
| echo ">>>> Current Cardano Era: \${CURRENT_CARDANO_ERA}" | ||
|
|
||
| # Get current Cardano block | ||
| CURRENT_CARDANO_BLOCK=\$(CARDANO_NODE_SOCKET_PATH=node-pool${N}/ipc/node.sock $CARDANO_CLI $CARDANO_CLI_ERA query tip \\ | ||
| --testnet-magic ${NETWORK_MAGIC} \\ | ||
| | jq -r '.block') | ||
| echo ">>>> Current Cardano Block: \${CURRENT_CARDANO_BLOCK}" | ||
|
|
||
| # Send funds to protocol configuration address | ||
| ## Get the UTxO of utxo${N} | ||
| TX_IN=\$(CARDANO_NODE_SOCKET_PATH=node-pool${N}/ipc/node.sock $CARDANO_CLI \${CURRENT_CARDANO_ERA} query utxo \\ | ||
| --testnet-magic ${NETWORK_MAGIC} --address \$(cat addresses/utxo${N}.addr) --out-file /dev/stdout \\ | ||
| | jq -r 'to_entries | [last] | .[0].key') | ||
|
|
||
| ## Build the transaction | ||
| CARDANO_NODE_SOCKET_PATH=node-pool${N}/ipc/node.sock $CARDANO_CLI \${CURRENT_CARDANO_ERA} transaction build \\ | ||
| --tx-in \${TX_IN} \\ | ||
| --tx-out \$(cat addresses/${ADDR}.addr)+${AMOUNT_TRANSFERRED} \\ | ||
| --change-address \$(cat addresses/utxo${N}.addr) \\ | ||
| --testnet-magic ${NETWORK_MAGIC} \\ | ||
| --invalid-hereafter 100000 \\ | ||
| --out-file node-pool${N}/tx/tx${N}-protocol-config-funds.txbody | ||
|
|
||
| ## Sign the transaction | ||
| CARDANO_NODE_SOCKET_PATH=node-pool${N}/ipc/node.sock $CARDANO_CLI \${CURRENT_CARDANO_ERA} transaction sign \\ | ||
| --signing-key-file addresses/utxo${N}.skey \\ | ||
| --testnet-magic ${NETWORK_MAGIC} \\ | ||
| --tx-body-file node-pool${N}/tx/tx${N}-protocol-config-funds.txbody \\ | ||
| --out-file node-pool${N}/tx/tx${N}-protocol-config-funds.tx | ||
|
|
||
| ## Submit the transaction | ||
| CARDANO_NODE_SOCKET_PATH=node-pool${N}/ipc/node.sock $CARDANO_CLI \${CURRENT_CARDANO_ERA} transaction submit \\ | ||
| --tx-file node-pool${N}/tx/tx${N}-protocol-config-funds.tx \\ | ||
| --testnet-magic ${NETWORK_MAGIC} | ||
|
|
||
| ## Compute the submitted transaction id | ||
| TX_ID_SUBMITTED=\$(CARDANO_NODE_SOCKET_PATH=node-pool${N}/ipc/node.sock $CARDANO_CLI \${CURRENT_CARDANO_ERA} transaction txid --tx-file node-pool${N}/tx/tx${N}-protocol-config-funds.tx) | ||
| if [[ "\${TX_ID_SUBMITTED}" =~ txhash ]]; then | ||
| TX_ID_SUBMITTED=\$(echo \$TX_ID_SUBMITTED | jq -r '.txhash') | ||
| fi | ||
|
|
||
| ## Wait at least for 10 blocks so that the transaction is confirmed | ||
| wait_for_elapsed_blocks 10 | ||
|
|
||
| ## Wait for all pool nodes to see the new transaction | ||
| for (( i=1; i<=${NUM_POOL_NODES}; i++ )); do | ||
| TOTAL_UTXOS_FOR_TX_ID=\$(CARDANO_NODE_SOCKET_PATH=node-pool\${i}/ipc/node.sock $CARDANO_CLI \${CURRENT_CARDANO_ERA} query utxo \\ | ||
| --testnet-magic ${NETWORK_MAGIC} --address \$(cat addresses/${ADDR}.addr) --out-file /dev/stdout \\ | ||
| | jq '. | with_entries(select(.key | startswith("${TX_ID_SUBMITTED}"))) | length') | ||
| echo ">>>>>> Protocol configuration address funds retrieved on node-pool\${i}: \${TOTAL_UTXOS_FOR_TX_ID}" | ||
| if [ "\${TOTAL_UTXOS_FOR_TX_ID}" == "0" ]; then | ||
| touch ${MITHRIL_PROTOCOL_CONFIG_ERROR_FILE} | ||
| break | ||
| fi | ||
| done | ||
| } | ||
|
|
||
| # Try to send funds to protocol configuration address | ||
| function try_send_funds_to_protocol_config_address { | ||
| SEND_FUNDS_PROTOCOL_CONFIG_ADDRESS_WAIT_ROUNDS_MAX=10 | ||
| SEND_FUNDS_PROTOCOL_CONFIG_ADDRESS_WAIT_ROUNDS=1 | ||
| SEND_FUNDS_PROTOCOL_CONFIG_ADDRESS_WAIT_ROUND_DELAY=2 | ||
| while true | ||
| do | ||
| send_funds_to_protocol_config_address | ||
| if [ -f ${MITHRIL_PROTOCOL_CONFIG_ERROR_FILE} ]; then | ||
| echo ">>>> Funds not transferred successfully to protocol configuration address, a rollback has happened [attempt \$SEND_FUNDS_PROTOCOL_CONFIG_ADDRESS_WAIT_ROUNDS]!" | ||
| sleep \$SEND_FUNDS_PROTOCOL_CONFIG_ADDRESS_WAIT_ROUND_DELAY | ||
| else | ||
| echo ">>>> Funds transferred successfully to protocol configuration address [attempt \$SEND_FUNDS_PROTOCOL_CONFIG_ADDRESS_WAIT_ROUNDS]!" | ||
| break | ||
| fi | ||
| SEND_FUNDS_PROTOCOL_CONFIG_ADDRESS_WAIT_ROUNDS=\$(( \$SEND_FUNDS_PROTOCOL_CONFIG_ADDRESS_WAIT_ROUNDS + 1 )) | ||
| if [ "\$SEND_FUNDS_PROTOCOL_CONFIG_ADDRESS_WAIT_ROUNDS" -gt "\$SEND_FUNDS_PROTOCOL_CONFIG_ADDRESS_WAIT_ROUNDS_MAX" ] ; then | ||
| echo ">>>> Timeout: Funds were not transferred successfully to protocol configuration address within \$SEND_FUNDS_PROTOCOL_CONFIG_ADDRESS_WAIT_ROUNDS_MAX attempts" | ||
| exit 1 | ||
| fi | ||
| done | ||
| } | ||
|
|
||
| # Write datums for protocol configuration address | ||
| function write_datums_for_protocol_config_address { | ||
| # Remove if exists previous error file | ||
| rm -f ${MITHRIL_PROTOCOL_CONFIG_ERROR_FILE} | ||
|
|
||
| # Fetch transactions from UTxOs of the protocol configuration address | ||
| TX_IN_DATUM=\$(CARDANO_NODE_SOCKET_PATH=node-pool${N}/ipc/node.sock $CARDANO_CLI \${CURRENT_CARDANO_ERA} query utxo \\ | ||
| --testnet-magic ${NETWORK_MAGIC} --address \$(cat addresses/${ADDR}.addr) --out-file /dev/stdout \\ | ||
| | jq -r 'to_entries | map({utxo: .key} + .value) | . [] | select(.inlineDatum | . != null and . != "") | .utxo') | ||
| TX_IN_NO_DATUM=\$(CARDANO_NODE_SOCKET_PATH=node-pool${N}/ipc/node.sock $CARDANO_CLI \${CURRENT_CARDANO_ERA} query utxo \\ | ||
| --testnet-magic ${NETWORK_MAGIC} --address \$(cat addresses/${ADDR}.addr) --out-file /dev/stdout \\ | ||
| | jq -r 'to_entries | [last] | .[0].key') | ||
|
|
||
| ## Build the transaction | ||
| if [ "\${TX_IN_DATUM}" == "" ]; then | ||
| CARDANO_NODE_SOCKET_PATH=node-pool${N}/ipc/node.sock $CARDANO_CLI \${CURRENT_CARDANO_ERA} transaction build \\ | ||
| --tx-in \${TX_IN_NO_DATUM} \\ | ||
| --tx-out \$(cat addresses/${ADDR}.addr)+${SCRIPT_TX_VALUE} \\ | ||
| --tx-out-inline-datum-file \${PROTOCOL_CONFIG_DATUM_FILE} \\ | ||
| --change-address \$(cat addresses/${ADDR}.addr) \\ | ||
| --testnet-magic ${NETWORK_MAGIC} \\ | ||
| --invalid-hereafter 100000 \\ | ||
| --out-file node-pool${N}/tx/tx${N}-protocol-configuration-datum.txbody | ||
| else | ||
| CARDANO_NODE_SOCKET_PATH=node-pool${N}/ipc/node.sock $CARDANO_CLI \${CURRENT_CARDANO_ERA} transaction build \\ | ||
| --tx-in \${TX_IN_DATUM} \\ | ||
| --tx-in \${TX_IN_NO_DATUM} \\ | ||
| --tx-out \$(cat addresses/${ADDR}.addr)+${SCRIPT_TX_VALUE} \\ | ||
| --tx-out-inline-datum-file \${PROTOCOL_CONFIG_DATUM_FILE} \\ | ||
| --change-address \$(cat addresses/${ADDR}.addr) \\ | ||
| --testnet-magic ${NETWORK_MAGIC} \\ | ||
| --invalid-hereafter 100000 \\ | ||
| --out-file node-pool${N}/tx/tx${N}-protocol-configuration-datum.txbody | ||
| fi | ||
|
|
||
| ## Sign the transaction | ||
| CARDANO_NODE_SOCKET_PATH=node-pool${N}/ipc/node.sock $CARDANO_CLI \${CURRENT_CARDANO_ERA} transaction sign \\ | ||
| --signing-key-file addresses/${ADDR}.skey \\ | ||
| --testnet-magic ${NETWORK_MAGIC} \\ | ||
| --tx-body-file node-pool${N}/tx/tx${N}-protocol-configuration-datum.txbody \\ | ||
| --out-file node-pool${N}/tx/tx${N}-protocol-configuration-datum.tx | ||
|
|
||
| ## Submit the transaction | ||
| CARDANO_NODE_SOCKET_PATH=node-pool${N}/ipc/node.sock $CARDANO_CLI \${CURRENT_CARDANO_ERA} transaction submit \\ | ||
| --tx-file node-pool${N}/tx/tx${N}-protocol-configuration-datum.tx \\ | ||
| --testnet-magic ${NETWORK_MAGIC} | ||
|
|
||
| ## Wait at least for 10 blocks so that the transaction is confirmed | ||
| wait_for_elapsed_blocks 10 | ||
|
|
||
| ## Wait for all pool nodes to see the new protocol configuration datum | ||
| for (( i=1; i<=${NUM_POOL_NODES}; i++ )); do | ||
| INLINE_DATUM=\$(CARDANO_NODE_SOCKET_PATH=node-pool\${i}/ipc/node.sock $CARDANO_CLI \${CURRENT_CARDANO_ERA} query utxo \\ | ||
| --testnet-magic ${NETWORK_MAGIC} --address \$(cat addresses/${ADDR}.addr) --out-file /dev/stdout \\ | ||
| | jq -r '. [] | select(.inlineDatum | . != null and . != "") | .inlineDatum.fields[].bytes' | xxd -r -p | jq) | ||
| echo ">>>>>> Protocol configuration address inline datum retrieved on node-pool\${i}: \${INLINE_DATUM}" | ||
| if [ "\${INLINE_DATUM}" == "" ]; then | ||
| touch ${MITHRIL_PROTOCOL_CONFIG_ERROR_FILE} | ||
| break | ||
| fi | ||
| done | ||
| } | ||
|
|
||
| # Try to write datums for protocol configuration address | ||
| function try_write_datums_for_protocol_config_address { | ||
| WRITE_DATUMS_PROTOCOL_CONFIG_ADDRESS_WAIT_ROUNDS_MAX=10 | ||
| WRITE_DATUMS_PROTOCOL_CONFIG_ADDRESS_WAIT_ROUNDS=1 | ||
| WRITE_DATUMS_PROTOCOL_CONFIG_ADDRESS_WAIT_ROUND_DELAY=2 | ||
| while true | ||
| do | ||
| write_datums_for_protocol_config_address | ||
| if [ -f ${MITHRIL_PROTOCOL_CONFIG_ERROR_FILE} ]; then | ||
| echo ">>>> Datums not written successfully for protocol configuration address, a rollback has happened [attempt \$WRITE_DATUMS_PROTOCOL_CONFIG_ADDRESS_WAIT_ROUNDS]!" | ||
| sleep \$WRITE_DATUMS_PROTOCOL_CONFIG_ADDRESS_WAIT_ROUND_DELAY | ||
| else | ||
| echo ">>>> Datums successfully written for protocol configuration address [attempt \$WRITE_DATUMS_PROTOCOL_CONFIG_ADDRESS_WAIT_ROUNDS]!" | ||
| break | ||
| fi | ||
| WRITE_DATUMS_PROTOCOL_CONFIG_ADDRESS_WAIT_ROUNDS=\$(( \$WRITE_DATUMS_PROTOCOL_CONFIG_ADDRESS_WAIT_ROUNDS + 1 )) | ||
| if [ "\$WRITE_DATUMS_PROTOCOL_CONFIG_ADDRESS_WAIT_ROUNDS" -gt "\$WRITE_DATUMS_PROTOCOL_CONFIG_ADDRESS_WAIT_ROUNDS_MAX" ] ; then | ||
| echo ">>>> Timeout: Datums were not written successfully for protocol configuration address within \$WRITE_DATUMS_PROTOCOL_CONFIG_ADDRESS_WAIT_ROUNDS_MAX attempts" | ||
| exit 1 | ||
| fi | ||
| done | ||
| } | ||
|
|
||
| # Try to send funds to protocol configuration address | ||
| try_send_funds_to_protocol_config_address | ||
|
|
||
| # Try to write datums for protocol configuration address | ||
| try_write_datums_for_protocol_config_address | ||
|
|
||
| EOF | ||
|
|
||
| chmod u+x protocol-configuration.sh |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.