Skip to content

Commit

Permalink
Availability tests (#429)
Browse files Browse the repository at this point in the history
* Add Availability Tests

* Availability Tests changes; LT result artifact

* Notification status

* Small text changes

* Potencial Slack problem with link

* Get Public Address from Private Key
  • Loading branch information
bane authored Nov 13, 2024
1 parent 7ddf17c commit 273e470
Show file tree
Hide file tree
Showing 7 changed files with 359 additions and 7 deletions.
189 changes: 189 additions & 0 deletions .github/workflows/availability-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
---
name: Availability Tests
on:
workflow_dispatch:
inputs:
environment:
description: The environment to run against
required: true
type: string
rpc_url:
description: JSON-RPC URL
required: true
type: string
fund_amount:
description: Amount in Ether to fund
required: true
type: string
default: "5"
london:
description: Is London fork active?
required: true
type: boolean
default: true
notification:
description: Notification
type: boolean
default: true
workflow_call:
inputs:
environment:
description: The environment to run against
required: true
type: string
rpc_url:
description: JSON-RPC URL
required: true
type: string
fund_amount:
description: Amount in Ether to fund
required: true
type: string
london:
description: Is London fork active?
required: true
type: boolean
notification:
description: Notification
type: boolean
required: true
outputs:
availability_test_status:
value: ${{ jobs.availability_test.outputs.availability_test_status }}
produce_blocks:
value: ${{ jobs.availability_test.outputs.produce_blocks }}
fund_status:
value: ${{ jobs.availability_test.outputs.fund_status }}
check_deployed_smart_contract_status:
value: ${{ jobs.availability_test.outputs.check_deployed_smart_contract_status }}
method_set_status:
value: ${{ jobs.availability_test.outputs.method_set_status }}
method_get_status:
value: ${{ jobs.availability_test.outputs.method_get_status }}
secrets:
FAUCET_PRIVATE_KEY:
required: true
ACCOUNT_PRIVATE_KEY:
required: true
SLACK_WEBHOOK_URL:
required: true

jobs:
availability_test:
name: Availability Test
runs-on: ubuntu-latest
outputs:
availability_test_status: ${{ steps.final_status.outputs.status }}
produce_blocks: ${{ steps.latest_block_number.outputs.produce_blocks }}
fund_status: ${{ steps.fund.outputs.status }}
check_deployed_smart_contract_status: ${{ steps.check_deployed_smart_contract.outputs.status }}
method_set_status: ${{ steps.method_set.outputs.status }}
method_get_status: ${{ steps.method_get.outputs.status }}
steps:
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly-f625d0fa7c51e65b4bf1e8f7931cd1c6e2e285e9
- name: Get latest block number
id: latest_block_number
run: |
current_block_number=$(cast to-dec `cast rpc --rpc-url ${{ inputs.rpc_url }} eth_blockNumber | sed 's/"//g'`)
sleep 15
latest_block_number=$(cast to-dec `cast rpc --rpc-url ${{ inputs.rpc_url }} eth_blockNumber | sed 's/"//g'`)
if [ $current_block_number != $latest_block_number ]; then
echo "produce_blocks=true" >> $GITHUB_OUTPUT
fi
- name: Fund account
id: fund
run: |
public_address=$(cast wallet address --private-key ${{ secrets.ACCOUNT_PRIVATE_KEY }})
current_balance=$(cast rpc --rpc-url ${{ inputs.rpc_url }} eth_getBalance $public_address latest | sed 's/"//g')
current_balance_converted=$(echo "`cast to-dec $current_balance`/1000000000000000000" | bc -l)
fund=$(cast send --rpc-url ${{ inputs.rpc_url }} --private-key ${{ secrets.FAUCET_PRIVATE_KEY }} --value ${{ inputs.fund_amount }}ether $public_address `[[ ${{ inputs.london }} == false ]] && echo --legacy`)
if [ $(echo "$fund" | grep -c "transactionHash") -eq 1 ]; then
new_balance=$(cast rpc --rpc-url ${{ inputs.rpc_url }} eth_getBalance $public_address latest | sed 's/"//g')
new_balance_converted=$(echo "`cast to-dec $new_balance`/1000000000000000000" | bc -l)
if [ $current_balance_converted != $new_balance_converted ]; then
echo "status=true" >> $GITHUB_OUTPUT
fi
fi
- name: Forge Init
run: forge init . --no-git
- name: Create Simple Smart Contract
run: |
cat <<EOF > src/SimpleContract.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.2;
contract SimpleContract {
uint256 number;
function set(uint256 num) public {
number = num;
}
function get() public view returns (uint256) {
return number;
}
}
EOF
- name: Forge Compile
run: forge compile
- name: Deploy Smart Contract to the network
id: deploy_smart_contract
if: steps.fund.outputs.status
run: |
output=$(forge create SimpleContract --rpc-url ${{ inputs.rpc_url }} --private-key ${{ secrets.ACCOUNT_PRIVATE_KEY }} `[[ ${{ inputs.london }} == false ]] && echo --legacy`)
address=$(echo "$output" | awk -F "Deployed to: | Transaction hash:" '{print $2}')
echo "hash=$(jq -Rn --arg value $address '$value')" >> $GITHUB_OUTPUT
- name: Check if Smart Contract deployed successfully
id: check_deployed_smart_contract
if: steps.fund.outputs.status
run: |
bytecode=$(cast rpc --rpc-url ${{ inputs.rpc_url }} eth_getCode ${{ steps.deploy_smart_contract.outputs.hash }} latest | sed 's/"//g')
if [ $bytecode != "0x" ] && [ $bytecode != "" ]; then
echo "status=true" >> $GITHUB_OUTPUT
fi
- name: Call set() method from Smart Contract
id: method_set
if: steps.check_deployed_smart_contract.outputs.status
run: |
output=$(cast send --rpc-url ${{ inputs.rpc_url }} --private-key ${{ secrets.ACCOUNT_PRIVATE_KEY }} ${{ steps.deploy_smart_contract.outputs.hash }} "function set(uint256)" 100 `[[ ${{ inputs.london }} == false ]] && echo --legacy`)
if [ $(echo "$output" | grep -c "transactionHash") -eq 1 ]; then
echo "status=true" >> $GITHUB_OUTPUT
fi
- name: Call get() method from Smart Contract
id: method_get
if: steps.check_deployed_smart_contract.outputs.status && steps.method_set.outputs.status
run: |
output=$(cast call --rpc-url ${{ inputs.rpc_url }} ${{ steps.deploy_smart_contract.outputs.hash }} "function get()" `[[ ${{ inputs.london }} == false ]] && echo --legacy`)
if [ $(cast to-dec `echo $output`) -eq 100 ]; then
echo "status=true" >> $GITHUB_OUTPUT
fi
- name: Final status
id: final_status
run: |
if [ ${{ steps.latest_block_number.outputs.produce_blocks }} = "true" ] &&
[ ${{ steps.fund.outputs.status }} = "true" ] &&
[ ${{ steps.check_deployed_smart_contract.outputs.status }} = "true" ] &&
[ ${{ steps.method_set.outputs.status }} = "true" ] &&
[ ${{ steps.method_get.outputs.status }} = "true" ]; then
echo "status=true" >> $GITHUB_OUTPUT
fi
notification:
name: Availability Test Notification
needs: availability_test
uses: ./.github/workflows/notification-availability-test.yml
if: ((success() || failure()) && inputs.notification)
with:
environment: ${{ inputs.environment }}
availability_test_status: ${{ needs.availability_test.outputs.availability_test_status }}
produce_blocks: ${{ needs.availability_test.outputs.produce_blocks }}
fund_status: ${{ needs.availability_test.outputs.fund_status }}
check_deployed_smart_contract_status: ${{ needs.availability_test.outputs.check_deployed_smart_contract_status }}
method_set_status: ${{ needs.availability_test.outputs.method_set_status }}
method_get_status: ${{ needs.availability_test.outputs.method_get_status }}
secrets:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
3 changes: 3 additions & 0 deletions .github/workflows/deploy-network.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ on: # yamllint disable-line rule:truthy
blade_healthcheck_output:
description: Blade Healthcheck output
value: ${{ jobs.deploy_network.outputs.blade_healthcheck_output }}
rpc_url:
description: RPC URL
value: ${{ jobs.check_network.outputs.rpc_url || jobs.deploy_network.outputs.rpc_url }}
secrets:
AWS_ROLE_ARN:
required: true
Expand Down
14 changes: 13 additions & 1 deletion .github/workflows/load-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ on: # yamllint disable-line rule:truthy
txpool_queued:
description: Queued Transactions Count
value: ${{ jobs.txpool_status.outputs.txpool_queued }}
results_artifact_id:
description: Results Artifact ID
value: ${{ jobs.load_test.outputs.results_artifact_id }}
secrets:
AWS_ROLE_ARN:
required: true
Expand Down Expand Up @@ -194,7 +197,7 @@ jobs:
github-token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
aws-resource-tags: >
[
{"Key": "Name", "Value": "LoadTestRunner"}
{"Key": "Name", "Value": "${{ inputs.environment }}-load-test-runner"}
]
load_test:
name: Run Load Test
Expand All @@ -211,6 +214,7 @@ jobs:
avg_gas_per_tx: ${{ steps.load_test_results.outputs.avg_gas_per_tx }}
avg_gas_utilization: ${{ steps.load_test_results.outputs.avg_gas_utilization }}
max_gas_utilization: ${{ steps.load_test_results.outputs.max_gas_utilization }}
results_artifact_id: ${{ steps.artifact-upload.outputs.artifact-id }}
steps:
- name: Checkout code
uses: actions/[email protected]
Expand All @@ -237,6 +241,13 @@ jobs:
if: success()
id: load_test_results_success
run: echo "test_output=true" >> $GITHUB_OUTPUT
- name: Upload Artifact
uses: actions/[email protected]
id: artifact-upload
with:
name: results_${{ inputs.type }}.tar.gz
path: results_${{ inputs.type }}.json
retention-days: 3
txpool_status:
name: Check txpool status after Load Test
runs-on: ubuntu-latest
Expand Down Expand Up @@ -277,6 +288,7 @@ jobs:
max_gas_utilization: ${{ needs.load_test.outputs.max_gas_utilization }}
txpool_pending: ${{ needs.txpool_status.outputs.txpool_pending }}
txpool_queued: ${{ needs.txpool_status.outputs.txpool_queued }}
results_url: ${{ needs.load_test.outputs.results_url }}
secrets:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
destroy_load_test_runner:
Expand Down
31 changes: 25 additions & 6 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,20 @@ jobs:
AWS_ROLE_ARN: ${{ secrets.AWS_ROLE_ARN }}
AWS_S3_BLADE_BUCKET: ${{ secrets.AWS_S3_BLADE_BUCKET }}
VAULT_PASSWORD: ${{ secrets.VAULT_PASSWORD }}
availability_tests:
name: Availability Tests
uses: ./.github/workflows/availability-tests.yml
needs: deploy_network
with:
environment: nightly
rpc_url: ${{ needs.deploy_network.outputs.rpc_url }}
fund_amount: "5"
london: true
notification: false
secrets:
FAUCET_PRIVATE_KEY: ${{ secrets.FAUCET_PRIVATE_KEY }}
ACCOUNT_PRIVATE_KEY: ${{ secrets.ACCOUNT_PRIVATE_KEY }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
sanity_check_tests:
name: Sanity Check Tests
uses: ./.github/workflows/sanity-check-test.yml
Expand All @@ -49,7 +63,7 @@ jobs:
load_test_eoa:
name: Load Test EOA
uses: ./.github/workflows/load-test.yml
needs: [deploy_network, sanity_check_tests]
needs: [deploy_network, availability_tests, sanity_check_tests]
with:
environment: nightly
type: EOA
Expand All @@ -73,7 +87,7 @@ jobs:
load_test_erc20:
name: Load Test ERC20
uses: ./.github/workflows/load-test.yml
needs: [deploy_network, sanity_check_tests, load_test_eoa]
needs: [deploy_network, availability_tests, sanity_check_tests, load_test_eoa]
with:
environment: nightly
type: ERC20
Expand All @@ -97,7 +111,7 @@ jobs:
load_test_erc721:
name: Load Test ERC721
uses: ./.github/workflows/load-test.yml
needs: [deploy_network, sanity_check_tests, load_test_eoa, load_test_erc20]
needs: [deploy_network, availability_tests, sanity_check_tests, load_test_eoa, load_test_erc20]
with:
environment: nightly
type: ERC721
Expand All @@ -121,7 +135,7 @@ jobs:
load_test_mixed:
name: Load Test MIXED
uses: ./.github/workflows/load-test.yml
needs: [deploy_network, sanity_check_tests, load_test_eoa, load_test_erc20, load_test_erc721]
needs: [deploy_network, availability_tests, sanity_check_tests, load_test_eoa, load_test_erc20, load_test_erc721]
with:
environment: nightly
type: MIXED
Expand All @@ -145,7 +159,7 @@ jobs:
destroy_network:
name: Destroy Network
uses: ./.github/workflows/destroy-network.yml
needs: [deploy_network, sanity_check_tests, load_test_eoa, load_test_erc20, load_test_erc721, load_test_mixed]
needs: [deploy_network, availability_tests, sanity_check_tests, load_test_eoa, load_test_erc20, load_test_erc721, load_test_mixed]
if: always()
with:
environment: nightly
Expand All @@ -158,7 +172,7 @@ jobs:
notification_nightly:
name: Nightly Notification
uses: ./.github/workflows/notification-nightly.yml
needs: [ci, deploy_network, sanity_check_tests, load_test_eoa, load_test_erc20, load_test_erc721, load_test_mixed, destroy_network]
needs: [ci, deploy_network, availability_tests, sanity_check_tests, load_test_eoa, load_test_erc20, load_test_erc721, load_test_mixed, destroy_network]
if: success() || failure()
with:
environment: nightly
Expand All @@ -178,6 +192,7 @@ jobs:
property_polybft_test_output: ${{ needs.ci.outputs.property_polybft_test }}
fuzz_test_output: ${{ needs.ci.outputs.fuzz_test }}
benchmark_test_output: ${{ needs.ci.outputs.benchmark_test }}
availability_test_status: ${{ needs.availability_tests.outputs.availability_test_status }}
sanity_check_tests_output: ${{ needs.sanity_check_tests.outputs.sanity_check_tests_output }}
stake_test_output: ${{ needs.sanity_check_tests.outputs.stake_test_output }}
unstake_test_output: ${{ needs.sanity_check_tests.outputs.unstake_test_output }}
Expand Down Expand Up @@ -230,6 +245,7 @@ jobs:
max_gas_utilization: ${{ needs.load_test_eoa.outputs.max_gas_utilization }}
txpool_pending: ${{ needs.load_test_eoa.outputs.txpool_pending }}
txpool_queued: ${{ needs.load_test_eoa.outputs.txpool_queued }}
results_artifact_id: ${{ needs.load_test_eoa.outputs.results_artifact_id }}
secrets:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
notification_load_test_erc20:
Expand Down Expand Up @@ -258,6 +274,7 @@ jobs:
max_gas_utilization: ${{ needs.load_test_erc20.outputs.max_gas_utilization }}
txpool_pending: ${{ needs.load_test_erc20.outputs.txpool_pending }}
txpool_queued: ${{ needs.load_test_erc20.outputs.txpool_queued }}
results_artifact_id: ${{ needs.load_test_erc20.outputs.results_artifact_id }}
secrets:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
notification_load_test_erc721:
Expand Down Expand Up @@ -286,6 +303,7 @@ jobs:
max_gas_utilization: ${{ needs.load_test_erc721.outputs.max_gas_utilization }}
txpool_pending: ${{ needs.load_test_erc721.outputs.txpool_pending }}
txpool_queued: ${{ needs.load_test_erc721.outputs.txpool_queued }}
results_artifact_id: ${{ needs.load_test_erc721.outputs.results_artifact_id }}
secrets:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
notification_load_test_mixed:
Expand Down Expand Up @@ -314,5 +332,6 @@ jobs:
max_gas_utilization: ${{ needs.load_test_mixed.outputs.max_gas_utilization }}
txpool_pending: ${{ needs.load_test_mixed.outputs.txpool_pending }}
txpool_queued: ${{ needs.load_test_mixed.outputs.txpool_queued }}
results_artifact_id: ${{ needs.load_test_mixed.outputs.results_artifact_id }}
secrets:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
Loading

0 comments on commit 273e470

Please sign in to comment.