forked from 0xPolygon/polygon-edge
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 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
Showing
7 changed files
with
359 additions
and
7 deletions.
There are no files selected for viewing
This file contains 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,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 }} |
This file contains 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 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 |
---|---|---|
|
@@ -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 | ||
|
@@ -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 | ||
|
@@ -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] | ||
|
@@ -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 | ||
|
@@ -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: | ||
|
This file contains 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.