From eef2330c485873a5b6c664f8dc074e4e21cb562e Mon Sep 17 00:00:00 2001 From: Branislav Kojic Date: Thu, 18 Jan 2024 16:41:51 +0100 Subject: [PATCH 01/67] Deploy Network (#1) --- .github/workflows/deploy-network.yml | 90 ++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 .github/workflows/deploy-network.yml diff --git a/.github/workflows/deploy-network.yml b/.github/workflows/deploy-network.yml new file mode 100644 index 0000000000..67d2b68a5b --- /dev/null +++ b/.github/workflows/deploy-network.yml @@ -0,0 +1,90 @@ +--- + +name: Deploy Network +on: # yamllint disable-line rule:truthy + workflow_dispatch: + inputs: + environment: + description: The environment to run against + type: environment + required: true + workflow_call: + inputs: + environment: + description: The environment to run against + type: string + required: true + +jobs: + build: + runs-on: ubuntu-latest + environment: ${{ inputs.environment }} + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + repository: Ethernal-Tech/blade-deployment + ref: changes + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v2 + with: + aws-region: ${{ secrets.AWS_REGION }} + role-to-assume: ${{ secrets.AWS_ROLE_ARN }} + - name: Install Terraform + uses: hashicorp/setup-terraform@v2.0.3 + with: + terraform_version: 1.4.5 + - name: "Configure terraform for ${{ inputs.environment }} build" + run: | + sed 's/# backend "s3" {}/backend "s3" {}/' main.tf > main.tf.tmp && mv main.tf.tmp main.tf + - name: Terraform Init + id: init + run: terraform init -backend-config="bucket=blade-github" -backend-config="key=states/${{ inputs.environment }}" -backend-config="region=${{ secrets.AWS_REGION }}" + - name: Terraform Validate + id: validate + run: terraform validate -no-color + continue-on-error: true + - name: Terraform Apply + id: apply + run: terraform apply -auto-approve + env: + TF_VAR_deployment_name: ${{ inputs.environment }} + TF_VAR_base_instance_type: ${{ vars.AWS_BASE_INSTANCE_TYPE }} + TF_VAR_geth_count: ${{ vars.GETH_COUNT }} + TF_VAR_fullnode_count: ${{ vars.FULLNODE_COUNT }} + TF_VAR_validator_count: ${{ vars.VALIDATOR_COUNT }} + - name: Retrieve state file from s3 + run: aws s3 cp s3://blade-github/states/${{ inputs.environment }} state.json + - name: Configure private keys + run: | + terraform output pk_ansible > ~/private.key + chmod 600 ~/private.key + eval "$(ssh-agent)" + ssh-add ~/private.key + - name: Install ansible / botocore / boto3 + run: | + python3 -m pip install --user ansible + python3 -m pip install boto3 botocore + - name: Configure ansible for nightly build + working-directory: ansible + run: | + echo "${{ secrets.VAULT_PASSWORD }}" > password.txt + sed 's/devnet13/${{ inputs.environment }}/g' inventory/aws_ec2.yml > inventory/aws_ec2.yml.tmp && mv inventory/aws_ec2.yml.tmp inventory/aws_ec2.yml + sed 's/devnet13/${{ inputs.environment }}/g' group_vars/all.yml > group_vars/all.yml.tmp && mv group_vars/all.yml.tmp group_vars/all.yml + sed 's/blade_tag: .*/blade_tag: ${{ vars.BLADE_TAG }}/g' group_vars/all.yml > group_vars/all.yml.tmp && mv group_vars/all.yml.tmp group_vars/all.yml + sed 's/is_bridge_active: .*/is_bridge_active: ${{ vars.IS_BRIDGE_ACTIVE }}/g' group_vars/all.yml > group_vars/all.yml.tmp && mv group_vars/all.yml.tmp group_vars/all.yml + sed 's/INFO/${{ secrets.LOG_LEVEL }}/g' roles/blade/templates/blade.service > roles/blade/templates/blade.service.tmp && mv roles/blade/templates/blade.service.tmp roles/blade/templates/blade.service + - name: Run Ansible + working-directory: ansible + run: | + ansible-inventory --graph + ansible-galaxy install -r requirements.yml + ansible-playbook site.yml --extra-vars "block_gas_limit=200000000 block_time=2" + - name: Set rpc url value + id: url + run: | + terraform output -raw aws_lb_ext_domain | grep -o -E '^ext[^:]*' > rpc_url.txt + - uses: actions/upload-artifact@v3 + with: + name: rpc_url + path: rpc_url.txt From eefbc13e17f0683d3f61cfe3d9909eff0fcc2afe Mon Sep 17 00:00:00 2001 From: Branislav Kojic Date: Thu, 18 Jan 2024 17:14:57 +0100 Subject: [PATCH 02/67] Add Permisions (#2) * Deploy Network * Add Permissions --- .github/workflows/deploy-network.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/deploy-network.yml b/.github/workflows/deploy-network.yml index 67d2b68a5b..7da54ea1d4 100644 --- a/.github/workflows/deploy-network.yml +++ b/.github/workflows/deploy-network.yml @@ -15,6 +15,11 @@ on: # yamllint disable-line rule:truthy type: string required: true +permissions: + id-token: write + contents: read + security-events: write + jobs: build: runs-on: ubuntu-latest From 7d08b73629925bd80c397abf6fb295442295decb Mon Sep 17 00:00:00 2001 From: Branislav Kojic Date: Thu, 18 Jan 2024 18:12:20 +0100 Subject: [PATCH 03/67] Minor changes (#3) * Deploy Network * Add Permissions * Minor changes --- .github/dependabot.yml | 15 -- .github/issue_template.md | 30 --- .github/pull_request_template.md | 39 --- .../workflows/ansible/update_bladenet.yaml | 68 ----- .github/workflows/ci.yml | 19 -- .github/workflows/cla.yml | 27 -- .github/workflows/deploy-network.yml | 9 +- .github/workflows/deploy.nightly.devnet.yml | 234 ------------------ .github/workflows/e2e-legacy.yaml | 50 ---- .github/workflows/e2e-polybft.yml | 50 ---- .github/workflows/lint.yml | 30 --- .github/workflows/loadtest.yml | 224 ----------------- .github/workflows/property-polybft.yml | 47 ---- .github/workflows/release.yml | 62 ----- .github/workflows/test.yml | 38 --- 15 files changed, 6 insertions(+), 936 deletions(-) delete mode 100644 .github/dependabot.yml delete mode 100644 .github/issue_template.md delete mode 100644 .github/pull_request_template.md delete mode 100644 .github/workflows/ansible/update_bladenet.yaml delete mode 100644 .github/workflows/ci.yml delete mode 100644 .github/workflows/cla.yml delete mode 100644 .github/workflows/deploy.nightly.devnet.yml delete mode 100644 .github/workflows/e2e-legacy.yaml delete mode 100644 .github/workflows/e2e-polybft.yml delete mode 100644 .github/workflows/lint.yml delete mode 100644 .github/workflows/loadtest.yml delete mode 100644 .github/workflows/property-polybft.yml delete mode 100644 .github/workflows/release.yml delete mode 100644 .github/workflows/test.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml deleted file mode 100644 index 2d4f711a31..0000000000 --- a/.github/dependabot.yml +++ /dev/null @@ -1,15 +0,0 @@ -version: 2 -updates: - - package-ecosystem: gomod - directory: / - target-branch: "develop" - schedule: - interval: monthly - ignore: - - dependency-name: "github.com/aws/aws-sdk-go" - update-types: [ "version-update:semver-patch" ] - open-pull-requests-limit: 20 - pull-request-branch-name: - separator: "-" - reviewers: - - "Ethernal-Tech/blade-devs" diff --git a/.github/issue_template.md b/.github/issue_template.md deleted file mode 100644 index 9ab09bbe93..0000000000 --- a/.github/issue_template.md +++ /dev/null @@ -1,30 +0,0 @@ -# [ Subject of the issue ] -## Description -Describe your issue in as much detail as possible here. - -## Your environment -- OS and version. -- The version of the Polygon Edge. - (*Confirm the version of your Polygon edge client by running the following command: `polygon-edge version --grpc-address GRPC_ADDRESS`*) -- The branch that causes this issue. -- Locally or Cloud hosted (which provider). -- Please confirm if the validators are running under containerized environment (K8s, Docker, etc.). - -## Steps to reproduce -- Tell us how to reproduce this issue. -- Where the issue is, if you know. -- Which commands triggered the issue, if any. -- Provide us with the content of your genesis file. -- Provide us with commands that you used to start your validators. -- Provide us with the peer list of each of your validators by running the following command: `polygon-edge peers list --grpc-address GRPC_ADDRESS`. -- Is the chain producing blocks and serving customers atm? - -## Expected behavior -- Tell us what should happen. -- Tell us what happened instead. - -## Logs -Provide us with debug logs from all of your validators by setting logging to `debug` output with: `server --log-level debug` - -## Proposed solution -If you have an idea on how to fix this issue, please write it down here, so we can begin discussing it diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md deleted file mode 100644 index 8038dfd032..0000000000 --- a/.github/pull_request_template.md +++ /dev/null @@ -1,39 +0,0 @@ -# Description - -Please provide a detailed description of what was done in this PR - -# Changes include - -- [ ] Bugfix (non-breaking change that solves an issue) -- [ ] Hotfix (change that solves an urgent issue, and requires immediate attention) -- [ ] New feature (non-breaking change that adds functionality) -- [ ] Breaking change (change that is not backwards-compatible and/or changes current functionality) - -# Breaking changes - -Please complete this section if any breaking changes have been made, otherwise delete it - -# Checklist - -- [ ] I have assigned this PR to myself -- [ ] I have added at least 1 reviewer -- [ ] I have added the relevant labels -- [ ] I have updated the official documentation -- [ ] I have added sufficient documentation in code - -## Testing - -- [ ] I have tested this code with the official test suite -- [ ] I have tested this code manually - -### Manual tests - -Please complete this section if you ran manual tests for this functionality, otherwise delete it - -# Documentation update - -Please link the documentation update PR in this section if it's present, otherwise delete it - -# Additional comments - -Please post additional comments in this section if you have them, otherwise delete it diff --git a/.github/workflows/ansible/update_bladenet.yaml b/.github/workflows/ansible/update_bladenet.yaml deleted file mode 100644 index ee964124a5..0000000000 --- a/.github/workflows/ansible/update_bladenet.yaml +++ /dev/null @@ -1,68 +0,0 @@ ---- -- - name: Update Blade binary - hosts: - - all - become: yes - tasks: - ## update & upgrade system - - name: Update & upgrade system - apt: - upgrade: yes - update_cache: yes - - ## stop blade service - - name: Stop Blade service - systemd: - state: stopped - name: blade - - ## get the latest release - - name: Get latest release link - uri: - url: https://api.github.com/repos/Ethernal-Tech/blade/releases/latest - return_content: true - register: blade_release - - ## download the latest release - - name: Download latest Blade release - get_url: - url: "{{ blade_release.json.assets[3].browser_download_url }}" - dest: /tmp/blade.tar.gz - force: yes - - ## create temp dir for release - - name: Create temp dir for Blade release - file: - path: /tmp/blade - state: directory - - ## unpack release tar - - name: Unpack Blade release - unarchive: - remote_src: yes - src: /tmp/blade.tar.gz - dest: /tmp/blade - - ## set blade to PATH - - name: Place Blade binary to PATH - copy: - remote_src: yes - src: /tmp/blade/blade - dest: /usr/local/bin/ - mode: a+x - force: yes - - ## remove release temp dir - - name: Remove temp Blade release dir - file: - state: absent - path: /tmp/blade - - ## start Blade service - - name: Start blade service - systemd: - state: restarted - name: blade - daemon_reload: yes - enabled: yes \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index 237a0631b8..0000000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,19 +0,0 @@ ---- -name: CI -on: # yamllint disable-line rule:truthy - push: - branches: - - main - - develop - pull_request: - workflow_dispatch: {} - -jobs: - build: - name: Build - uses: ./.github/workflows/build.yml - - test: - name: Test - uses: ./.github/workflows/test.yml - needs: build diff --git a/.github/workflows/cla.yml b/.github/workflows/cla.yml deleted file mode 100644 index 4e5b7e4444..0000000000 --- a/.github/workflows/cla.yml +++ /dev/null @@ -1,27 +0,0 @@ ---- -name: "CLA Assistant" -on: # yamllint disable-line rule:truthy - issue_comment: - types: - - created - pull_request_target: - types: - - opened - - synchronize - -jobs: - CLAssistant: - runs-on: ubuntu-latest - steps: - - name: "Check CLA" - if: (github.event.comment.body == 'recheck' || github.event.comment.body == 'I have read the CLA Document and I hereby sign the CLA') || github.event_name == 'pull_request_target' - uses: contributor-assistant/github-action@v2.3.1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # the below token should have repo scope and must be manually added by you in the repository's secret - PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} - with: - path-to-signatures: "cla.json" - path-to-document: "https://github.com/Ethernal-Tech/blade/blob/develop/CLA.md" - branch: "cla-signatures" - allowlist: dependabot[bot],dependabot-preview[bot] diff --git a/.github/workflows/deploy-network.yml b/.github/workflows/deploy-network.yml index 7da54ea1d4..6d6f379db2 100644 --- a/.github/workflows/deploy-network.yml +++ b/.github/workflows/deploy-network.yml @@ -6,7 +6,10 @@ on: # yamllint disable-line rule:truthy inputs: environment: description: The environment to run against - type: environment + type: choice + options: + - dev + - test required: true workflow_call: inputs: @@ -74,8 +77,8 @@ jobs: working-directory: ansible run: | echo "${{ secrets.VAULT_PASSWORD }}" > password.txt - sed 's/devnet13/${{ inputs.environment }}/g' inventory/aws_ec2.yml > inventory/aws_ec2.yml.tmp && mv inventory/aws_ec2.yml.tmp inventory/aws_ec2.yml - sed 's/devnet13/${{ inputs.environment }}/g' group_vars/all.yml > group_vars/all.yml.tmp && mv group_vars/all.yml.tmp group_vars/all.yml + sed 's/devnet/${{ inputs.environment }}/g' inventory/aws_ec2.yml > inventory/aws_ec2.yml.tmp && mv inventory/aws_ec2.yml.tmp inventory/aws_ec2.yml + sed 's/devnet/${{ inputs.environment }}/g' group_vars/all.yml > group_vars/all.yml.tmp && mv group_vars/all.yml.tmp group_vars/all.yml sed 's/blade_tag: .*/blade_tag: ${{ vars.BLADE_TAG }}/g' group_vars/all.yml > group_vars/all.yml.tmp && mv group_vars/all.yml.tmp group_vars/all.yml sed 's/is_bridge_active: .*/is_bridge_active: ${{ vars.IS_BRIDGE_ACTIVE }}/g' group_vars/all.yml > group_vars/all.yml.tmp && mv group_vars/all.yml.tmp group_vars/all.yml sed 's/INFO/${{ secrets.LOG_LEVEL }}/g' roles/blade/templates/blade.service > roles/blade/templates/blade.service.tmp && mv roles/blade/templates/blade.service.tmp roles/blade/templates/blade.service diff --git a/.github/workflows/deploy.nightly.devnet.yml b/.github/workflows/deploy.nightly.devnet.yml deleted file mode 100644 index d3aa5f8714..0000000000 --- a/.github/workflows/deploy.nightly.devnet.yml +++ /dev/null @@ -1,234 +0,0 @@ ---- - -name: Build Devnet -on: # yamllint disable-line rule:truthy - workflow_dispatch: - inputs: - environment: - description: The environment to run against - required: false - type: environment - duration: - default: "10m" - description: Duration of the test - required: false - type: string - workflow_call: - inputs: - environment: - description: The environment to run against - type: string - required: true - duration: - default: "10m" - description: Duration of the test - required: false - type: string - outputs: - workflow_output_loadtest1: - description: "Loadtest output" - value: ${{ jobs.loadtest1.outputs.workflow_output }} - workflow_output_loadtest2: - description: "Loadtest output" - value: ${{ jobs.loadtest2.outputs.workflow_output }} - secrets: - AWS_ROLE_ARN: - required: true - AWS_REGION: - required: true - TF_VAR_DEPLOYMENT_NAME: - required: true - TF_VAR_OWNER: - required: true - TF_VAR_BASE_INSTANCE_TYPE: - required: true - SLACK_PERFORMANCE_WEBHOOK_URL: - required: true - LOADTESTER_AWS_SUBNET_ID: - required: true - LOADTESTER_AWS_SG_ID: - required: true - LOADTESTER_INSTANCE_TYPE: - required: true - LOADTESTER_AMI: - required: true - LOADTEST_MNEMONIC: - required: true - VAULT_PASSWORD_FILE: - required: true - IS_BRIDGE_ACTIVE: - required: true - PTA: - required: true - BLADE_TAG: - required: true - LOG_LEVEL: - required: true - -jobs: - build: - runs-on: ubuntu-latest - environment: ${{ inputs.environment }} - steps: - - name: Checkout code - uses: actions/checkout@v3 - with: - repository: Ethernal-Tech/blade-deployment - ref: main - - name: Configure AWS Credentials - uses: aws-actions/configure-aws-credentials@v2 - with: - role-to-assume: ${{ secrets.AWS_ROLE_ARN }} - aws-region: ${{ secrets.AWS_REGION }} - - name: Install Terraform - uses: hashicorp/setup-terraform@v2.0.3 - with: - terraform_version: 1.4.5 - - name: Configure terraform for nightly build - run: | - sed 's/# backend "s3" {}/backend "s3" {}/' main.tf > main.tf.tmp && mv main.tf.tmp main.tf - - name: Terraform Init - id: init - run: terraform init -backend-config="bucket=blade-terraform-states" -backend-config="key=state/${{ secrets.TF_VAR_DEPLOYMENT_NAME }}" -backend-config="region=${{ secrets.AWS_REGION }}" - - name: Terraform Validate - id: validate - run: terraform validate -no-color - continue-on-error: true - - name: Terraform Apply - id: apply - run: terraform apply -auto-approve - env: - TF_VAR_deployment_name: ${{ secrets.TF_VAR_DEPLOYMENT_NAME }} - TF_VAR_owner: ${{ secrets.TF_VAR_OWNER }} - TF_VAR_base_instance_type: ${{ secrets.TF_VAR_BASE_INSTANCE_TYPE }} - - name: Retrieve state file from s3 - run: aws s3 cp s3://blade-terraform-states/state/${{ secrets.TF_VAR_DEPLOYMENT_NAME }} state.json - - name: Configure private keys - run: | - terraform output pk_ansible > ~/devnet_private.key - chmod 600 ~/devnet_private.key - eval "$(ssh-agent)" - ssh-add ~/devnet_private.key - - name: Install ansible / botocore / boto3 - run: | - python3 -m pip install --user ansible - python3 -m pip install boto3 botocore - - name: Configure ansible for nightly build - working-directory: ansible - run: | - echo "${{ secrets.VAULT_PASSWORD_FILE }}" > password.txt - sed 's/devnet13/${{ secrets.TF_VAR_DEPLOYMENT_NAME }}/g' inventory/aws_ec2.yml > inventory/aws_ec2.yml.tmp && mv inventory/aws_ec2.yml.tmp inventory/aws_ec2.yml - sed 's/devnet13/${{ secrets.TF_VAR_DEPLOYMENT_NAME }}/g' group_vars/all.yml > group_vars/all.yml.tmp && mv group_vars/all.yml.tmp group_vars/all.yml - sed 's/blade_tag: .*/blade_tag: ${{ secrets.BLADE_TAG }}/g' group_vars/all.yml > group_vars/all.yml.tmp && mv group_vars/all.yml.tmp group_vars/all.yml - sed 's/is_bridge_active: .*/is_bridge_active: ${{ secrets.IS_BRIDGE_ACTIVE }}/g' group_vars/all.yml > group_vars/all.yml.tmp && mv group_vars/all.yml.tmp group_vars/all.yml - sed 's/INFO/${{ secrets.LOG_LEVEL }}/g' roles/blade/templates/blade.service > roles/blade/templates/blade.service.tmp && mv roles/blade/templates/blade.service.tmp roles/blade/templates/blade.service - - name: Run Ansible - working-directory: ansible - run: | - ansible-inventory --graph - ansible-galaxy install -r requirements.yml - ansible-playbook site.yml --extra-vars "block_gas_limit=200000000 block_time=2" - - name: Set rpc url value - id: url - run: | - terraform output -raw aws_lb_ext_domain | grep -o -E '^ext[^:]*' > rpc_url.txt - - uses: actions/upload-artifact@v3 - with: - name: rpc_url - path: rpc_url.txt - - loadtest1: - needs: build - uses: ./.github/workflows/loadtest.yml - name: Load Test Nightly Build - multiple_EOA - secrets: - AWS_REGION: ${{ secrets.AWS_REGION }} - AWS_ROLE_ARN: ${{ secrets.AWS_ROLE_ARN }} - LOADTESTER_INSTANCE_TYPE: ${{ secrets.LOADTESTER_INSTANCE_TYPE }} - LOADTESTER_AMI: ${{ secrets.LOADTESTER_AMI }} - LOADTESTER_AWS_SUBNET_ID: ${{ secrets.LOADTESTER_AWS_SUBNET_ID }} - LOADTESTER_AWS_SG_ID: ${{ secrets.LOADTESTER_AWS_SG_ID }} - SLACK_PERFORMANCE_WEBHOOK_URL: ${{ secrets.SLACK_PERFORMANCE_WEBHOOK_URL }} - LOADTEST_RPC_URL: "" # this is a workaround because of actions bug in passing output to another job - LOADTEST_MNEMONIC: ${{ secrets.LOADTEST_MNEMONIC }} - PTA: ${{ secrets.PTA }} - with: - environment: ${{ inputs.environment }} - scenario: multiple_EOA - duration: ${{ inputs.duration }} - - loadtest2: - needs: loadtest1 - uses: ./.github/workflows/loadtest.yml - name: Load Test Nightly Build - multiple_ERC20 - secrets: - AWS_REGION: ${{ secrets.AWS_REGION }} - AWS_ROLE_ARN: ${{ secrets.AWS_ROLE_ARN }} - LOADTESTER_INSTANCE_TYPE: ${{ secrets.LOADTESTER_INSTANCE_TYPE }} - LOADTESTER_AMI: ${{ secrets.LOADTESTER_AMI }} - LOADTESTER_AWS_SUBNET_ID: ${{ secrets.LOADTESTER_AWS_SUBNET_ID }} - LOADTESTER_AWS_SG_ID: ${{ secrets.LOADTESTER_AWS_SG_ID }} - SLACK_PERFORMANCE_WEBHOOK_URL: ${{ secrets.SLACK_PERFORMANCE_WEBHOOK_URL }} - LOADTEST_RPC_URL: "" # this is a workaround because of actions bug in passing output to another job - LOADTEST_MNEMONIC: ${{ secrets.LOADTEST_MNEMONIC }} - PTA: ${{ secrets.PTA }} - with: - environment: ${{ inputs.environment }} - scenario: multiple_ERC20 - duration: ${{ inputs.duration }} - - destroy_devnet: - needs: [loadtest1, loadtest2] - if: always() - name: Destroy Nightly Build - runs-on: ubuntu-latest - environment: ${{ inputs.environment }} - steps: - - name: Checkout code - uses: actions/checkout@v3 - with: - repository: Ethernal-Tech/blade-deployment - ref: main - - name: Configure AWS Credentials - uses: aws-actions/configure-aws-credentials@v2 - with: - role-to-assume: ${{ secrets.AWS_ROLE_ARN }} - aws-region: ${{ secrets.AWS_REGION }} - - name: Install Terraform - uses: hashicorp/setup-terraform@v2.0.3 - with: - terraform_version: 1.4.5 - - name: Configure terraform for nightly build - run: | - sed 's/# backend "s3" {}/backend "s3" {}/' main.tf > main.tf.tmp && mv main.tf.tmp main.tf - - name: Terraform Init - id: init - run: terraform init -backend-config="bucket=blade-terraform-states" -backend-config="key=state/${{ secrets.TF_VAR_DEPLOYMENT_NAME }}" -backend-config="region=${{ secrets.AWS_REGION }}" - - name: Retrieve state file from s3 - run: aws s3 cp s3://blade-terraform-states/state/${{ secrets.TF_VAR_DEPLOYMENT_NAME }} state.json - - name: Configure private keys - run: | - terraform output pk_ansible > ~/devnet_private.key - chmod 600 ~/devnet_private.key - eval "$(ssh-agent)" - ssh-add ~/devnet_private.key - - name: Install ansible / botocore / boto3 - run: | - python3 -m pip install --user ansible - python3 -m pip install boto3 botocore - - name: Configure ansible for nightly logs - working-directory: ansible - run: | - echo "${{ secrets.VAULT_PASSWORD_FILE }}" > password.txt - sed 's/{{ current_datetime\.stdout }}/${{ github.run_id }}/g' roles/upload-logs/tasks/logs.yml > roles/upload-logs/tasks/logs.yml.tmp && mv roles/upload-logs/tasks/logs.yml.tmp roles/upload-logs/tasks/logs.yml - - name: Upload Logs - working-directory: ansible - run: | - ansible-playbook upload-logs.yml - - name: Terraform Destroy - id: destroy - run: terraform destroy -auto-approve -state=state.json - env: - TF_VAR_deployment_name: ${{ secrets.TF_VAR_DEPLOYMENT_NAME }} - TF_VAR_owner: ${{ secrets.TF_VAR_OWNER }} - TF_VAR_base_instance_type: ${{ secrets.TF_VAR_BASE_INSTANCE_TYPE }} diff --git a/.github/workflows/e2e-legacy.yaml b/.github/workflows/e2e-legacy.yaml deleted file mode 100644 index 8777392adb..0000000000 --- a/.github/workflows/e2e-legacy.yaml +++ /dev/null @@ -1,50 +0,0 @@ ---- -name: Legacy E2E tests -on: # yamllint disable-line rule:truthy - push: - branches: - - main - - develop - pull_request: - workflow_dispatch: - workflow_call: - outputs: - workflow_output: - description: "E2E Legacy output" - value: ${{ jobs.build.outputs.e2e_legacy_output_failure }} - -jobs: - build: - runs-on: ubuntu-latest - env: - E2E_TESTS: true - E2E_LOGS: true - CI_VERBOSE: true - outputs: - e2e_legacy_output_failure: ${{ steps.run_e2e_legacy_failure.outputs.test_output }} - steps: - - name: Checkout code - uses: actions/checkout@v3 - with: - submodules: recursive - - - name: Install Go - uses: actions/setup-go@v3 - with: - go-version: 1.20.x - - - name: Run tests - run: make test-e2e - - - name: Run tests failed - if: failure() - id: run_e2e_legacy_failure - run: echo "test_output=false" >> $GITHUB_OUTPUT - - - name: Archive test logs - if: always() - uses: actions/upload-artifact@v3 - with: - name: e2e-logs - path: e2e-logs-*/ - retention-days: 30 diff --git a/.github/workflows/e2e-polybft.yml b/.github/workflows/e2e-polybft.yml deleted file mode 100644 index 3611caa897..0000000000 --- a/.github/workflows/e2e-polybft.yml +++ /dev/null @@ -1,50 +0,0 @@ ---- -name: PolyBFT E2E tests -on: # yamllint disable-line rule:truthy - push: - branches: - - main - - develop - pull_request: - workflow_dispatch: - workflow_call: - outputs: - workflow_output: - description: "E2E output" - value: ${{ jobs.build.outputs.e2e_output_failure }} - -jobs: - build: - runs-on: ubuntu-latest - env: - E2E_TESTS: true - E2E_LOGS: true - CI_VERBOSE: true - outputs: - e2e_output_failure: ${{ steps.run_e2e_failure.outputs.test_output }} - steps: - - name: Checkout code - uses: actions/checkout@v3 - - - name: Install Go - uses: actions/setup-go@v4 - with: - go-version: 1.20.x - check-latest: true - cache-dependency-path: go.sum - - - name: Run tests - run: make test-e2e-polybft - - - name: Run tests failed - if: failure() - id: run_e2e_failure - run: echo "test_output=false" >> $GITHUB_OUTPUT - - - name: Archive test logs - if: always() - uses: actions/upload-artifact@v3 - with: - name: e2e-logs - path: e2e-logs-*/ - retention-days: 30 diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml deleted file mode 100644 index 7a70ba0ecb..0000000000 --- a/.github/workflows/lint.yml +++ /dev/null @@ -1,30 +0,0 @@ ---- -name: Lint -on: # yamllint disable-line rule:truthy - push: - branches: - - main - - develop - - pull_request: - - workflow_call: {} - workflow_dispatch: {} - -jobs: - golangci_lint: - name: Linter - runs-on: ubuntu-latest - steps: - - name: Install Go - uses: actions/setup-go@v3 - with: - go-version: 1.20.x - - - name: Checkout code - uses: actions/checkout@v3 - - - name: Lint - uses: golangci/golangci-lint-action@v3 - with: - args: --timeout 10m --verbose diff --git a/.github/workflows/loadtest.yml b/.github/workflows/loadtest.yml deleted file mode 100644 index e3089765ec..0000000000 --- a/.github/workflows/loadtest.yml +++ /dev/null @@ -1,224 +0,0 @@ ---- -name: Load Test -on: # yamllint disable-line rule:truthy - workflow_dispatch: - inputs: - environment: - default: devnet - description: The environment to run against - required: false - type: environment - scenario: - default: 'simple' - description: The scenario to run - type: string - duration: - default: '5m' - description: Duration of the test - required: false - type: string - workflow_call: - inputs: - environment: - default: devnet - description: The environment to run against - type: string - required: true - scenario: - default: 'simple' - required: true - description: The mode for the stress test - type: string - duration: - default: '5m' - description: Duration of the test - required: false - type: string - outputs: - workflow_output: - description: "Loadtest output" - value: ${{ jobs.run_k6.outputs.loadtest_output_success }} - secrets: - AWS_REGION: - required: true - AWS_ROLE_ARN: - required: true - LOADTESTER_AWS_SUBNET_ID: - required: true - LOADTESTER_AWS_SG_ID: - required: true - LOADTESTER_INSTANCE_TYPE: - required: true - LOADTESTER_AMI: - required: true - LOADTEST_RPC_URL: - required: true - LOADTEST_MNEMONIC: - required: true - SLACK_PERFORMANCE_WEBHOOK_URL: - required: true - PTA: - required: true - -jobs: - build: - environment: ${{ inputs.environment }} - runs-on: ubuntu-latest - outputs: - label: ${{ steps.start-loadtester.outputs.label }} - ec2-instance-id: ${{ steps.start-loadtester.outputs.ec2-instance-id }} - steps: - - name: Configure AWS credentials - uses: aws-actions/configure-aws-credentials@v2 - with: - role-to-assume: ${{ secrets.AWS_ROLE_ARN }} - aws-region: ${{ secrets.AWS_REGION }} - - name: Start loadtester - id: start-loadtester - uses: machulav/ec2-github-runner@v2 - with: - mode: start - github-token: ${{ secrets.PTA }} - ec2-image-id: ${{ secrets.LOADTESTER_AMI }} - ec2-instance-type: ${{ secrets.LOADTESTER_INSTANCE_TYPE }} - subnet-id: ${{ secrets.LOADTESTER_AWS_SUBNET_ID }} - security-group-id: ${{ secrets.LOADTESTER_AWS_SG_ID }} - run_k6: - environment: ${{ inputs.environment }} - needs: build - runs-on: "${{ needs.build.outputs.label }}" - outputs: - loadtest_output_success: ${{ steps.run_k6_success.outputs.test_output }} - steps: - - name: Checkout code - uses: actions/checkout@v3 - - - id: random-number-generator - run: echo "random-number=$(echo $RANDOM)" >> $GITHUB_OUTPUT - shell: bash - - - name: Install JQ - run: | - mkdir -p $HOME/.local/bin - curl -sLo $HOME/.local/bin/jq https://github.com/stedolan/jq/releases/download/jq-1.5/jq-linux64 && chmod +x $HOME/.local/bin/jq - echo "$HOME/.local/bin" >> $GITHUB_PATH - - - name: Download artifact to get rpc url - env: - url: ${{ secrets.LOADTEST_RPC_URL }} - if: ${{ env.url == '' }} - uses: actions/download-artifact@v3 - with: - name: rpc_url - - - name: Set rpc_url - id: set_rpc_url - run: | - if [[ -z "${{ secrets.LOADTEST_RPC_URL }}" ]]; then - echo "rpc_url=http://$(cat rpc_url.txt)" >> $GITHUB_OUTPUT - else - echo "rpc_url=${{ secrets.LOADTEST_RPC_URL }}" >> $GITHUB_OUTPUT - fi - - - id: k6 - name: Run scenario - run: | - /home/ubuntu/k6 run --out statsd loadtest/scenarios/${{ inputs.scenario }}.js - echo "tps_avg=$(cat summary.json | jq -r '.metrics.ethereum_tps.values.avg')" >> $GITHUB_OUTPUT - echo "tps_max=$(cat summary.json | jq -r '.metrics.ethereum_tps.values.max')" >> $GITHUB_OUTPUT - echo "iterations=$(cat summary.json | jq -r '.metrics.iterations.values.count')" >> $GITHUB_OUTPUT - echo "block=$(cat summary.json | jq -r '.metrics.ethereum_block.values.count')" >> $GITHUB_OUTPUT - echo "ttm=$(cat summary.json | jq -r '.metrics.ethereum_time_to_mine.values.avg')" >> $GITHUB_OUTPUT - echo "gas_avg=$(cat summary.json | jq -r '.metrics.ethereum_gas_used.values.avg')" >> $GITHUB_OUTPUT - echo "gas_max=$(cat summary.json | jq -r '.metrics.ethereum_gas_used.values.max')" >> $GITHUB_OUTPUT - env: - K6_STATSD_ENABLE_TAGS: true - RPC_URL: ${{ steps.set_rpc_url.outputs.rpc_url }} - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_PERFORMANCE_WEBHOOK_URL }} - LOADTEST_MNEMONIC: ${{ secrets.LOADTEST_MNEMONIC }} - LOADTEST_DURATION: ${{ inputs.duration }} - - - name: Run tests success - if: success() - id: run_k6_success - run: echo "test_output=true" >> $GITHUB_OUTPUT - - - name: Notify Slack - uses: slackapi/slack-github-action@v1.23.0 - env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_PERFORMANCE_WEBHOOK_URL }} - SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK - with: - payload: | - { - "attachments": [ - { - "color": "#03C03C", - "blocks": [ - { - "type": "header", - "text": { - "type": "plain_text", - "text": "K6 Loadtest ${{ inputs.scenario }} :zap:" - } - }, - { - "type": "context", - "elements": [ - { - "type": "mrkdwn", - "text": "Environment: *${{ inputs.environment }}*" - } - ] - }, - { - "type": "context", - "elements": [ - { - "type": "mrkdwn", - "text": "JSON-RPC: *<${{ steps.set_rpc_url.outputs.rpc_url }}|Open URL>*" - } - ] - }, - { - "type": "actions", - "elements": [ - { - "type": "button", - "text": { - "type": "plain_text", - "text": "View workflow run" - }, - "url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" - } - ] - }, - { - "type": "section", - "text": { - "type": "mrkdwn", - "text": "Average TPS: *${{ steps.k6.outputs.tps_avg }}*\nMax TPS: *${{ steps.k6.outputs.tps_max }}*\nTransactions: *${{ steps.k6.outputs.iterations }}*\nBlock Number: *${{ steps.k6.outputs.block }}*\nTime to Mine: *${{ steps.k6.outputs.ttm }}*\nAverage Gas Used: *${{ steps.k6.outputs.gas_avg }}*\nMax Gas Used: *${{ steps.k6.outputs.gas_max }}*" - } - } - ] - } - ] - } - destroy: - environment: ${{ inputs.environment }} - needs: [build, run_k6] - if: always() - runs-on: ubuntu-latest - steps: - - name: Configure AWS credentials - uses: aws-actions/configure-aws-credentials@v2 - with: - role-to-assume: ${{ secrets.AWS_ROLE_ARN }} - aws-region: ${{ secrets.AWS_REGION }} - - name: Stop loadtester - uses: machulav/ec2-github-runner@v2 - with: - mode: stop - github-token: ${{ secrets.PTA }} - label: ${{ needs.build.outputs.label }} - ec2-instance-id: ${{ needs.build.outputs.ec2-instance-id }} \ No newline at end of file diff --git a/.github/workflows/property-polybft.yml b/.github/workflows/property-polybft.yml deleted file mode 100644 index fbb3706793..0000000000 --- a/.github/workflows/property-polybft.yml +++ /dev/null @@ -1,47 +0,0 @@ ---- -name: PolyBFT Property tests -on: # yamllint disable-line rule:truthy - push: - branches: - - main - - develop - workflow_dispatch: - workflow_call: - outputs: - workflow_output: - description: "Property output" - value: ${{ jobs.build.outputs.property_output_failure }} - -jobs: - build: - runs-on: ubuntu-latest - env: - E2E_TESTS: true - E2E_LOGS: true - CI_VERBOSE: true - outputs: - property_output_failure: ${{ steps.run_property_failure.outputs.test_output }} - steps: - - name: Checkout code - uses: actions/checkout@v3 - - - name: Install Go - uses: actions/setup-go@v3 - with: - go-version: 1.20.x - - - name: Run tests - run: make test-property-polybft - - - name: Run tests failed - if: failure() - id: run_property_failure - run: echo "test_output=false" >> $GITHUB_OUTPUT - - - name: Archive test logs - if: always() - uses: actions/upload-artifact@v3 - with: - name: e2e-logs - path: e2e-logs-*/ - retention-days: 30 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 918d1eb684..0000000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,62 +0,0 @@ ---- -name: Release -on: # yamllint disable-line rule:truthy - push: - branches-ignore: - - '**' - tags: - - 'v*.*.*' - # to be used by fork patch-releases ^^ - - 'v*.*.*-*' - -jobs: - goreleaser: - runs-on: ubuntu-latest - env: - DOCKER_CONFIG: $HOME/.docker - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Set up Go - uses: actions/setup-go@v3 - with: - go-version: 1.20.x - - - name: Prepare - id: prepare - run: | - TAG=${GITHUB_REF#refs/tags/} - echo tag_name=${TAG} >> $GITHUB_OUTPUT - - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - - name: Login to Docker Hub - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Run GoReleaser - run: | - docker run \ - --rm \ - --privileged \ - -e CGO_ENABLED=1 \ - -e GITHUB_TOKEN \ - -e SLACK_WEBHOOK \ - -e DOCKER_CONFIG \ - -v /var/run/docker.sock:/var/run/docker.sock \ - -v `pwd`:/go/src/$(PACKAGE_NAME) \ - -w /go/src/$(PACKAGE_NAME) \ - ghcr.io/goreleaser/goreleaser-cross:${GOLANG_CROSS_VERSION} \ - --rm-dist --skip-validate - env: - PACKAGE_NAME: github.com/Ethernal-Tech/blade - GOLANG_CROSS_VERSION: v1.20.5 - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - VERSION: ${{ steps.prepare.outputs.tag_name }} - SLACK_WEBHOOK: ${{ secrets.SLACK_BLADE_GITHUB_URL }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index 99feb414dc..0000000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,38 +0,0 @@ ---- -name: Test -on: # yamllint disable-line rule:truthy - workflow_dispatch: - workflow_call: - outputs: - workflow_output: - description: "Unit tests output" - value: ${{ jobs.go_test.outputs.test_output_failure }} - -jobs: - go_test: - name: Blade - runs-on: ubuntu-latest - outputs: - test_output_failure: ${{ steps.run_tests_failure.outputs.test_output }} - steps: - - name: Setup Go - uses: actions/setup-go@v3 - with: - go-version: 1.20.x - - - name: Checkout Code - uses: actions/checkout@v3 - with: - submodules: recursive - fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - - - name: Install Dependencies - run: ./setup-ci.sh - - - name: Run Go Test - run: make test - - - name: Run Go Test Failed - if: failure() - id: run_tests_failure - run: echo "test_output=false" >> $GITHUB_OUTPUT From 6ca83e4f598055876d40636bdab1bc962cbeb5c8 Mon Sep 17 00:00:00 2001 From: Branislav Kojic Date: Thu, 18 Jan 2024 19:12:11 +0100 Subject: [PATCH 04/67] Minor Changes (#4) * Deploy Network * Add Permissions * Minor changes * Concurrency change --- .github/workflows/deploy-network.yml | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/.github/workflows/deploy-network.yml b/.github/workflows/deploy-network.yml index 6d6f379db2..ccc81171cc 100644 --- a/.github/workflows/deploy-network.yml +++ b/.github/workflows/deploy-network.yml @@ -1,5 +1,5 @@ --- - +concurrency: ci-$ name: Deploy Network on: # yamllint disable-line rule:truthy workflow_dispatch: @@ -7,9 +7,7 @@ on: # yamllint disable-line rule:truthy environment: description: The environment to run against type: choice - options: - - dev - - test + options: [dev, test] required: true workflow_call: inputs: @@ -24,7 +22,7 @@ permissions: security-events: write jobs: - build: + deploy: runs-on: ubuntu-latest environment: ${{ inputs.environment }} steps: @@ -42,7 +40,7 @@ jobs: uses: hashicorp/setup-terraform@v2.0.3 with: terraform_version: 1.4.5 - - name: "Configure terraform for ${{ inputs.environment }} build" + - name: "Configure Terraform for ${{ inputs.environment }} build" run: | sed 's/# backend "s3" {}/backend "s3" {}/' main.tf > main.tf.tmp && mv main.tf.tmp main.tf - name: Terraform Init @@ -69,11 +67,11 @@ jobs: chmod 600 ~/private.key eval "$(ssh-agent)" ssh-add ~/private.key - - name: Install ansible / botocore / boto3 + - name: Install Ansible / botocore / boto3 run: | python3 -m pip install --user ansible python3 -m pip install boto3 botocore - - name: Configure ansible for nightly build + - name: Configure Ansible for ${{ inputs.environment }} build working-directory: ansible run: | echo "${{ secrets.VAULT_PASSWORD }}" > password.txt @@ -88,7 +86,7 @@ jobs: ansible-inventory --graph ansible-galaxy install -r requirements.yml ansible-playbook site.yml --extra-vars "block_gas_limit=200000000 block_time=2" - - name: Set rpc url value + - name: Set RPC URL value id: url run: | terraform output -raw aws_lb_ext_domain | grep -o -E '^ext[^:]*' > rpc_url.txt From 00cb2273b7afe032184531a69c81a76cb11ea6aa Mon Sep 17 00:00:00 2001 From: Branislav Kojic Date: Thu, 18 Jan 2024 20:07:52 +0100 Subject: [PATCH 05/67] Destory Network (#5) * Deploy Network * Add Permissions * Minor changes * Concurrency change * Destroy Network --- .github/workflows/deploy-network.yml | 9 +-- .github/workflows/destroy-network.yml | 99 +++++++++++++++++++++++++++ 2 files changed, 104 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/destroy-network.yml diff --git a/.github/workflows/deploy-network.yml b/.github/workflows/deploy-network.yml index ccc81171cc..86dd8ba229 100644 --- a/.github/workflows/deploy-network.yml +++ b/.github/workflows/deploy-network.yml @@ -22,7 +22,8 @@ permissions: security-events: write jobs: - deploy: + deploy_network: + name: Deploy ${{ inputs.environment }} Network runs-on: ubuntu-latest environment: ${{ inputs.environment }} steps: @@ -32,7 +33,7 @@ jobs: repository: Ethernal-Tech/blade-deployment ref: changes - name: Configure AWS Credentials - uses: aws-actions/configure-aws-credentials@v2 + uses: aws-actions/configure-aws-credentials@v3 with: aws-region: ${{ secrets.AWS_REGION }} role-to-assume: ${{ secrets.AWS_ROLE_ARN }} @@ -40,7 +41,7 @@ jobs: uses: hashicorp/setup-terraform@v2.0.3 with: terraform_version: 1.4.5 - - name: "Configure Terraform for ${{ inputs.environment }} build" + - name: Configure Terraform for ${{ inputs.environment }} run: | sed 's/# backend "s3" {}/backend "s3" {}/' main.tf > main.tf.tmp && mv main.tf.tmp main.tf - name: Terraform Init @@ -71,7 +72,7 @@ jobs: run: | python3 -m pip install --user ansible python3 -m pip install boto3 botocore - - name: Configure Ansible for ${{ inputs.environment }} build + - name: Configure Ansible for ${{ inputs.environment }} working-directory: ansible run: | echo "${{ secrets.VAULT_PASSWORD }}" > password.txt diff --git a/.github/workflows/destroy-network.yml b/.github/workflows/destroy-network.yml new file mode 100644 index 0000000000..a781464d1c --- /dev/null +++ b/.github/workflows/destroy-network.yml @@ -0,0 +1,99 @@ +--- +concurrency: ci-$ +name: Destroy Network +on: # yamllint disable-line rule:truthy + workflow_dispatch: + inputs: + environment: + description: The environment to run against + type: choice + options: [dev, test] + required: true + logs: + description: Do you want to upload logs from hosts? + type: boolean + default: false + required: true + workflow_call: + inputs: + environment: + description: The environment to run against + type: string + required: true + logs: + description: Do you want to upload logs from hosts? + type: boolean + required: true + +permissions: + id-token: write + contents: read + security-events: write + +jobs: + upload_logs: + name: Upload logs from hosts + runs-on: ubuntu-latest + environment: ${{ inputs.environment }} + if: ${{ inputs.logs == 'true' }} + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + repository: Ethernal-Tech/blade-deployment + ref: changes + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v3 + with: + aws-region: ${{ secrets.AWS_REGION }} + role-to-assume: ${{ secrets.AWS_ROLE_ARN }} + - name: Retrieve state file from s3 + run: aws s3 cp s3://blade-github/states/${{ inputs.environment }} state.json + - name: Configure private keys + run: | + terraform output pk_ansible > ~/private.key + chmod 600 ~/private.key + eval "$(ssh-agent)" + ssh-add ~/private.key + - name: Install Ansible / botocore / boto3 + run: | + python3 -m pip install --user ansible + python3 -m pip install boto3 botocore + - name: Configure Ansible for ${{ inputs.environment }} + working-directory: ansible + run: | + echo "${{ secrets.VAULT_PASSWORD }}" > password.txt + sed 's/devnet/${{ inputs.environment }}/g' roles/upload-logs/tasks/logs.yml > roles/upload-logs/tasks/logs.yml.tmp && mv roles/upload-logs/tasks/logs.yml.tmp roles/upload-logs/tasks/logs.yml + sed 's/{{ current_datetime\.stdout }}/${{ github.run_id }}/g' roles/upload-logs/tasks/logs.yml > roles/upload-logs/tasks/logs.yml.tmp && mv roles/upload-logs/tasks/logs.yml.tmp roles/upload-logs/tasks/logs.yml + - name: Upload logs + working-directory: ansible + run: | + ansible-playbook upload-logs.yml + + destroy_network: + name: Destroy ${{ inputs.environment }} Network + runs-on: ubuntu-latest + environment: ${{ inputs.environment }} + needs: [upload_logs] + if: always() + steps: + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v3 + with: + aws-region: ${{ secrets.AWS_REGION }} + role-to-assume: ${{ secrets.AWS_ROLE_ARN }} + - name: Install Terraform + uses: hashicorp/setup-terraform@v2.0.3 + with: + terraform_version: 1.4.5 + - name: Configure Terraform for ${{ inputs.environment }} + run: | + sed 's/# backend "s3" {}/backend "s3" {}/' main.tf > main.tf.tmp && mv main.tf.tmp main.tf + - name: Terraform Init + id: init + run: terraform init -backend-config="bucket=blade-github" -backend-config="key=states/${{ inputs.environment }}" -backend-config="region=${{ secrets.AWS_REGION }}" + - name: Retrieve state file from s3 + run: aws s3 cp s3://blade-github/states/${{ inputs.environment }} state.json + - name: Terraform Destroy + id: destroy + run: terraform destroy -auto-approve -state=state.json From cfc93e44199229bec0240ca396c03b9c36052a9b Mon Sep 17 00:00:00 2001 From: Branislav Kojic Date: Thu, 18 Jan 2024 20:38:18 +0100 Subject: [PATCH 06/67] Minor changes (#6) * Deploy Network * Add Permissions * Minor changes * Concurrency change * Destroy Network * Minor changes --- .github/workflows/destroy-network.yml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/destroy-network.yml b/.github/workflows/destroy-network.yml index a781464d1c..11c2799b86 100644 --- a/.github/workflows/destroy-network.yml +++ b/.github/workflows/destroy-network.yml @@ -10,7 +10,7 @@ on: # yamllint disable-line rule:truthy options: [dev, test] required: true logs: - description: Do you want to upload logs from hosts? + description: Upload logs type: boolean default: false required: true @@ -21,7 +21,7 @@ on: # yamllint disable-line rule:truthy type: string required: true logs: - description: Do you want to upload logs from hosts? + description: Upload logs type: boolean required: true @@ -35,7 +35,7 @@ jobs: name: Upload logs from hosts runs-on: ubuntu-latest environment: ${{ inputs.environment }} - if: ${{ inputs.logs == 'true' }} + if: ${{ inputs.logs == true }} steps: - name: Checkout code uses: actions/checkout@v3 @@ -77,6 +77,11 @@ jobs: needs: [upload_logs] if: always() steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + repository: Ethernal-Tech/blade-deployment + ref: changes - name: Configure AWS Credentials uses: aws-actions/configure-aws-credentials@v3 with: From 8be8cb12646192d6399a46397219eea2af5049b9 Mon Sep 17 00:00:00 2001 From: Branislav Kojic Date: Thu, 18 Jan 2024 21:34:00 +0100 Subject: [PATCH 07/67] Minor changes (#7) * Deploy Network * Add Permissions * Concurrency change * Destroy Network * Minor changes --- .github/workflows/deploy-network.yml | 33 +++++++++++++++++++++++---- .github/workflows/destroy-network.yml | 12 +++++++++- 2 files changed, 40 insertions(+), 5 deletions(-) diff --git a/.github/workflows/deploy-network.yml b/.github/workflows/deploy-network.yml index 86dd8ba229..3a157702fb 100644 --- a/.github/workflows/deploy-network.yml +++ b/.github/workflows/deploy-network.yml @@ -9,12 +9,39 @@ on: # yamllint disable-line rule:truthy type: choice options: [dev, test] required: true + block_gas_limit: + description: Set block gas limit + type: string + default: "200000000" + required: true + block_time: + description: Set block time + type: string + default: "2" + required: true + is_bridge_active: + description: Activate Bridge + type: boolean + default: true + required: true workflow_call: inputs: environment: description: The environment to run against type: string required: true + block_gas_limit: + description: Set block gas limit + type: string + required: true + block_time: + description: Set block time + type: string + required: true + is_bridge_active: + description: Activate Bridge + type: boolean + required: true permissions: id-token: write @@ -77,16 +104,14 @@ jobs: run: | echo "${{ secrets.VAULT_PASSWORD }}" > password.txt sed 's/devnet/${{ inputs.environment }}/g' inventory/aws_ec2.yml > inventory/aws_ec2.yml.tmp && mv inventory/aws_ec2.yml.tmp inventory/aws_ec2.yml - sed 's/devnet/${{ inputs.environment }}/g' group_vars/all.yml > group_vars/all.yml.tmp && mv group_vars/all.yml.tmp group_vars/all.yml - sed 's/blade_tag: .*/blade_tag: ${{ vars.BLADE_TAG }}/g' group_vars/all.yml > group_vars/all.yml.tmp && mv group_vars/all.yml.tmp group_vars/all.yml - sed 's/is_bridge_active: .*/is_bridge_active: ${{ vars.IS_BRIDGE_ACTIVE }}/g' group_vars/all.yml > group_vars/all.yml.tmp && mv group_vars/all.yml.tmp group_vars/all.yml + sed 's/blade_tag: .*/blade_tag: ${GITHUB_SHA}/g' group_vars/all.yml > group_vars/all.yml.tmp && mv group_vars/all.yml.tmp group_vars/all.yml sed 's/INFO/${{ secrets.LOG_LEVEL }}/g' roles/blade/templates/blade.service > roles/blade/templates/blade.service.tmp && mv roles/blade/templates/blade.service.tmp roles/blade/templates/blade.service - name: Run Ansible working-directory: ansible run: | ansible-inventory --graph ansible-galaxy install -r requirements.yml - ansible-playbook site.yml --extra-vars "block_gas_limit=200000000 block_time=2" + ansible-playbook site.yml --extra-vars "clean_deploy_title=${{ inputs.environment }} block_gas_limit=${{ inputs.block_gas_limit }} block_time=${{ inputs.block_time }} is_bridge_active=${{ inputs.is_bridge_active }}" - name: Set RPC URL value id: url run: | diff --git a/.github/workflows/destroy-network.yml b/.github/workflows/destroy-network.yml index 11c2799b86..ab458fa6a5 100644 --- a/.github/workflows/destroy-network.yml +++ b/.github/workflows/destroy-network.yml @@ -32,7 +32,7 @@ permissions: jobs: upload_logs: - name: Upload logs from hosts + name: Upload ${{ inputs.environment }} Logs runs-on: ubuntu-latest environment: ${{ inputs.environment }} if: ${{ inputs.logs == true }} @@ -47,6 +47,16 @@ jobs: with: aws-region: ${{ secrets.AWS_REGION }} role-to-assume: ${{ secrets.AWS_ROLE_ARN }} + - name: Install Terraform + uses: hashicorp/setup-terraform@v2.0.3 + with: + terraform_version: 1.4.5 + - name: Configure Terraform for ${{ inputs.environment }} + run: | + sed 's/# backend "s3" {}/backend "s3" {}/' main.tf > main.tf.tmp && mv main.tf.tmp main.tf + - name: Terraform Init + id: init + run: terraform init -backend-config="bucket=blade-github" -backend-config="key=states/${{ inputs.environment }}" -backend-config="region=${{ secrets.AWS_REGION }}" - name: Retrieve state file from s3 run: aws s3 cp s3://blade-github/states/${{ inputs.environment }} state.json - name: Configure private keys From e0aa52e0892643971bffc43b8e7a0e2282dfee72 Mon Sep 17 00:00:00 2001 From: Branislav Kojic Date: Thu, 18 Jan 2024 22:10:42 +0100 Subject: [PATCH 08/67] FIx commit sha (#8) * Deploy Network * Add Permissions * Minor changes * Concurrency change * Destroy Network * Minor changes * Fix commit sha --- .github/workflows/deploy-network.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy-network.yml b/.github/workflows/deploy-network.yml index 3a157702fb..94e6accabb 100644 --- a/.github/workflows/deploy-network.yml +++ b/.github/workflows/deploy-network.yml @@ -104,7 +104,7 @@ jobs: run: | echo "${{ secrets.VAULT_PASSWORD }}" > password.txt sed 's/devnet/${{ inputs.environment }}/g' inventory/aws_ec2.yml > inventory/aws_ec2.yml.tmp && mv inventory/aws_ec2.yml.tmp inventory/aws_ec2.yml - sed 's/blade_tag: .*/blade_tag: ${GITHUB_SHA}/g' group_vars/all.yml > group_vars/all.yml.tmp && mv group_vars/all.yml.tmp group_vars/all.yml + sed 's/blade_tag: .*/blade_tag: ${{ github.sha }}/g' group_vars/all.yml > group_vars/all.yml.tmp && mv group_vars/all.yml.tmp group_vars/all.yml sed 's/INFO/${{ secrets.LOG_LEVEL }}/g' roles/blade/templates/blade.service > roles/blade/templates/blade.service.tmp && mv roles/blade/templates/blade.service.tmp roles/blade/templates/blade.service - name: Run Ansible working-directory: ansible From 6a3aee5c2de189178f1338ba7f875a5bccd1604d Mon Sep 17 00:00:00 2001 From: Branislav Kojic Date: Thu, 18 Jan 2024 22:25:35 +0100 Subject: [PATCH 09/67] Upload logs fixes (#9) * Deploy Network * Add Permissions * Minor changes * Concurrency change * Destroy Network * Fix commit sha --- .github/workflows/destroy-network.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/destroy-network.yml b/.github/workflows/destroy-network.yml index ab458fa6a5..adf3d967d4 100644 --- a/.github/workflows/destroy-network.yml +++ b/.github/workflows/destroy-network.yml @@ -73,12 +73,13 @@ jobs: working-directory: ansible run: | echo "${{ secrets.VAULT_PASSWORD }}" > password.txt + sed 's/devnet/${{ inputs.environment }}/g' inventory/aws_ec2.yml > inventory/aws_ec2.yml.tmp && mv inventory/aws_ec2.yml.tmp inventory/aws_ec2.yml sed 's/devnet/${{ inputs.environment }}/g' roles/upload-logs/tasks/logs.yml > roles/upload-logs/tasks/logs.yml.tmp && mv roles/upload-logs/tasks/logs.yml.tmp roles/upload-logs/tasks/logs.yml sed 's/{{ current_datetime\.stdout }}/${{ github.run_id }}/g' roles/upload-logs/tasks/logs.yml > roles/upload-logs/tasks/logs.yml.tmp && mv roles/upload-logs/tasks/logs.yml.tmp roles/upload-logs/tasks/logs.yml - name: Upload logs working-directory: ansible run: | - ansible-playbook upload-logs.yml + ansible-playbook upload-logs.yml --extra-vars "clean_deploy_title=${{ inputs.environment }}" destroy_network: name: Destroy ${{ inputs.environment }} Network From 42a0aeb8f0c6abf9787df55ba4b19c2a3b811d3b Mon Sep 17 00:00:00 2001 From: Branislav Kojic Date: Fri, 19 Jan 2024 11:58:08 +0100 Subject: [PATCH 10/67] Add Tests (#10) * Deploy Network * Add Permissions * Minor changes * Concurrency change * Destroy Network * Fix commit sha * Add Tests --- .github/workflows/build.yml | 13 +--- .github/workflows/deploy-network.yml | 4 +- .github/workflows/destroy-network.yml | 11 ++-- .github/workflows/e2e-legacy-test.yml | 47 ++++++++++++++ .github/workflows/e2e-polybft-test.yml | 47 ++++++++++++++ .github/workflows/fuzz-test.yml | 11 +--- .github/workflows/property-polybft-test.yml | 44 +++++++++++++ .github/workflows/tests.yml | 69 +++++++++++++++++++++ .github/workflows/unit-test.yml | 34 ++++++++++ Makefile | 12 ++-- 10 files changed, 258 insertions(+), 34 deletions(-) create mode 100644 .github/workflows/e2e-legacy-test.yml create mode 100644 .github/workflows/e2e-polybft-test.yml create mode 100644 .github/workflows/property-polybft-test.yml create mode 100644 .github/workflows/tests.yml create mode 100644 .github/workflows/unit-test.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5535456f59..ac7ac783b4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,5 +1,5 @@ --- -name: Build +name: Build Blade on: # yamllint disable-line rule:truthy workflow_dispatch: workflow_call: @@ -11,37 +11,32 @@ on: # yamllint disable-line rule:truthy jobs: go_build: - name: Blade + name: Build Blade runs-on: ubuntu-latest outputs: build_output_failure: ${{ steps.blade_build_failure.outputs.build_output }} steps: - name: Checkout code uses: actions/checkout@v3 - - name: Setup Go environment uses: actions/setup-go@v3 with: go-version: 1.20.x - - name: Build Blade - run: go build -o blade -tags netgo -ldflags="-s -w -X \"github.com/Ethernal-Tech/blade/versioning.Version=${GITHUB_REF_NAME}\" -X \"github.com/Ethernal-Tech/blade/versioning.Commit=${GITHUB_SHA}\"" && tar -czvf blade.tar.gz blade + run: go build -o blade -tags netgo -ldflags="-s -w -X \"github.com/bane/blade/versioning.Version=${GITHUB_REF_NAME}\" -X \"github.com/bane/blade/versioning.Commit=${GITHUB_SHA}\"" && tar -czvf blade.tar.gz blade env: GOARC: amd64 GOOS: linux - - name: Build Blade Failed if: failure() id: blade_build_failure run: echo "build_output=false" >> $GITHUB_OUTPUT - - name: "Upload Artifact" uses: actions/upload-artifact@v3 with: name: blade path: blade.tar.gz retention-days: 3 - go_build_reproducibility: name: Verify Build Reproducibility runs-on: ubuntu-latest @@ -49,12 +44,10 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v3 - - name: Setup Go environment uses: actions/setup-go@v3 with: go-version: 1.20.x - - name: Reproduce builds continue-on-error: true run: | diff --git a/.github/workflows/deploy-network.yml b/.github/workflows/deploy-network.yml index 94e6accabb..ffef08777c 100644 --- a/.github/workflows/deploy-network.yml +++ b/.github/workflows/deploy-network.yml @@ -8,7 +8,6 @@ on: # yamllint disable-line rule:truthy description: The environment to run against type: choice options: [dev, test] - required: true block_gas_limit: description: Set block gas limit type: string @@ -23,7 +22,6 @@ on: # yamllint disable-line rule:truthy description: Activate Bridge type: boolean default: true - required: true workflow_call: inputs: environment: @@ -83,7 +81,7 @@ jobs: run: terraform apply -auto-approve env: TF_VAR_deployment_name: ${{ inputs.environment }} - TF_VAR_base_instance_type: ${{ vars.AWS_BASE_INSTANCE_TYPE }} + TF_VAR_base_instance_type: ${{ vars.AWS_INSTANCE_TYPE }} TF_VAR_geth_count: ${{ vars.GETH_COUNT }} TF_VAR_fullnode_count: ${{ vars.FULLNODE_COUNT }} TF_VAR_validator_count: ${{ vars.VALIDATOR_COUNT }} diff --git a/.github/workflows/destroy-network.yml b/.github/workflows/destroy-network.yml index adf3d967d4..ca48f0121b 100644 --- a/.github/workflows/destroy-network.yml +++ b/.github/workflows/destroy-network.yml @@ -8,12 +8,10 @@ on: # yamllint disable-line rule:truthy description: The environment to run against type: choice options: [dev, test] - required: true logs: - description: Upload logs + description: Upload Logs type: boolean default: false - required: true workflow_call: inputs: environment: @@ -21,7 +19,7 @@ on: # yamllint disable-line rule:truthy type: string required: true logs: - description: Upload logs + description: Upload Logs type: boolean required: true @@ -32,7 +30,7 @@ permissions: jobs: upload_logs: - name: Upload ${{ inputs.environment }} Logs + name: Upload Logs runs-on: ubuntu-latest environment: ${{ inputs.environment }} if: ${{ inputs.logs == true }} @@ -76,11 +74,10 @@ jobs: sed 's/devnet/${{ inputs.environment }}/g' inventory/aws_ec2.yml > inventory/aws_ec2.yml.tmp && mv inventory/aws_ec2.yml.tmp inventory/aws_ec2.yml sed 's/devnet/${{ inputs.environment }}/g' roles/upload-logs/tasks/logs.yml > roles/upload-logs/tasks/logs.yml.tmp && mv roles/upload-logs/tasks/logs.yml.tmp roles/upload-logs/tasks/logs.yml sed 's/{{ current_datetime\.stdout }}/${{ github.run_id }}/g' roles/upload-logs/tasks/logs.yml > roles/upload-logs/tasks/logs.yml.tmp && mv roles/upload-logs/tasks/logs.yml.tmp roles/upload-logs/tasks/logs.yml - - name: Upload logs + - name: Upload Logs working-directory: ansible run: | ansible-playbook upload-logs.yml --extra-vars "clean_deploy_title=${{ inputs.environment }}" - destroy_network: name: Destroy ${{ inputs.environment }} Network runs-on: ubuntu-latest diff --git a/.github/workflows/e2e-legacy-test.yml b/.github/workflows/e2e-legacy-test.yml new file mode 100644 index 0000000000..d9ab62af21 --- /dev/null +++ b/.github/workflows/e2e-legacy-test.yml @@ -0,0 +1,47 @@ +--- +name: Legacy E2E Tests +on: # yamllint disable-line rule:truthy + push: + branches: + - main + - develop + pull_request: + workflow_dispatch: + workflow_call: + outputs: + workflow_output: + description: "Legacy E2E Tests output" + value: ${{ jobs.e2e_legacy.outputs.e2e_legacy_output_failure }} + +jobs: + e2e_legacy: + name: Legacy E2E Tests + runs-on: ubuntu-latest + env: + E2E_TESTS: true + E2E_LOGS: true + CI_VERBOSE: true + outputs: + e2e_legacy_output_failure: ${{ steps.run_e2e_legacy_failure.outputs.test_output }} + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + submodules: recursive + - name: Install Go + uses: actions/setup-go@v3 + with: + go-version: 1.20.x + - name: Run tests + run: make test-e2e-legacy + - name: Run tests failed + if: failure() + id: run_e2e_legacy_failure + run: echo "test_output=false" >> $GITHUB_OUTPUT + - name: Archive test logs + if: always() + uses: actions/upload-artifact@v3 + with: + name: e2e-logs + path: e2e-logs-*/ + retention-days: 30 diff --git a/.github/workflows/e2e-polybft-test.yml b/.github/workflows/e2e-polybft-test.yml new file mode 100644 index 0000000000..88f2523ac7 --- /dev/null +++ b/.github/workflows/e2e-polybft-test.yml @@ -0,0 +1,47 @@ +--- +name: PolyBFT E2E Tests +on: # yamllint disable-line rule:truthy + push: + branches: + - main + - develop + pull_request: + workflow_dispatch: + workflow_call: + outputs: + workflow_output: + description: "PolyBFT E2E Tests output" + value: ${{ jobs.e2e_polybft.outputs.e2e_polybft_output_failure }} + +jobs: + e2e_polybft: + name: PolyBFT E2E Tests + runs-on: ubuntu-latest + env: + E2E_TESTS: true + E2E_LOGS: true + CI_VERBOSE: true + outputs: + e2e_polybft_output_failure: ${{ steps.run_e2e_polybft_failure.outputs.test_output }} + steps: + - name: Checkout code + uses: actions/checkout@v3 + - name: Install Go + uses: actions/setup-go@v4 + with: + go-version: 1.20.x + check-latest: true + cache-dependency-path: go.sum + - name: Run tests + run: make test-e2e-polybft + - name: Run tests failed + if: failure() + id: run_e2e_polybft_failure + run: echo "test_output=false" >> $GITHUB_OUTPUT + - name: Archive test logs + if: always() + uses: actions/upload-artifact@v3 + with: + name: e2e-logs + path: e2e-logs-*/ + retention-days: 30 diff --git a/.github/workflows/fuzz-test.yml b/.github/workflows/fuzz-test.yml index e16a0b0ee5..2e2e5e6600 100644 --- a/.github/workflows/fuzz-test.yml +++ b/.github/workflows/fuzz-test.yml @@ -1,5 +1,5 @@ --- -name: Fuzz tests +name: Fuzz Tests on: # yamllint disable-line rule:truthy push: branches: @@ -9,13 +9,12 @@ on: # yamllint disable-line rule:truthy workflow_call: outputs: workflow_output: - description: "Fuzz output" + description: "Fuzz Tests output" value: ${{ jobs.fuzz_test.outputs.fuzz_output_failure }} - jobs: fuzz_test: - name: Blade + name: Fuzz Tests runs-on: ubuntu-latest outputs: fuzz_output_failure: ${{ steps.run_fuzz_failure.outputs.test_output }} @@ -24,15 +23,11 @@ jobs: uses: actions/setup-go@v3 with: go-version: 1.20.x - - name: Checkout Code uses: actions/checkout@v3 - - name: Run Fuzz Test run: make fuzz-test - - name: Run fuzz tests failed if: failure() id: run_fuzz_failure run: echo "test_output=false" >> $GITHUB_OUTPUT - diff --git a/.github/workflows/property-polybft-test.yml b/.github/workflows/property-polybft-test.yml new file mode 100644 index 0000000000..93ee8f226b --- /dev/null +++ b/.github/workflows/property-polybft-test.yml @@ -0,0 +1,44 @@ +--- +name: PolyBFT Property Tests +on: # yamllint disable-line rule:truthy + push: + branches: + - main + - develop + workflow_dispatch: + workflow_call: + outputs: + workflow_output: + description: "PolyBFT Property Tests output" + value: ${{ jobs.polybft_property.outputs.property_output_failure }} + +jobs: + polybft_property: + name: PolyBFT Property Tests + runs-on: ubuntu-latest + env: + E2E_TESTS: true + E2E_LOGS: true + CI_VERBOSE: true + outputs: + property_output_failure: ${{ steps.run_property_failure.outputs.test_output }} + steps: + - name: Checkout code + uses: actions/checkout@v3 + - name: Install Go + uses: actions/setup-go@v3 + with: + go-version: 1.20.x + - name: Run tests + run: make test-property-polybft + - name: Run tests failed + if: failure() + id: run_property_failure + run: echo "test_output=false" >> $GITHUB_OUTPUT + - name: Archive test logs + if: always() + uses: actions/upload-artifact@v3 + with: + name: e2e-logs + path: e2e-logs-*/ + retention-days: 30 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000000..f302fdb98a --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,69 @@ +--- +name: Tests +on: #yamllint disable-line rule:truthy + workflow_dispatch: + inputs: + unit-test: + description: Unit Tests + type: boolean + default: true + e2e-polybft-test: + description: PolyBFT E2E Tests + type: boolean + default: true + e2e-legacy-test: + description: Legacy E2E Tests + type: boolean + default: true + property-polybft-test: + description: Polybft Property Tests + type: boolean + default: true + fuzz-test: + description: Fuzz Tests + type: boolean + default: true + workflow_call: + inputs: + unit-test: + description: Unit Tests + type: boolean + required: true + e2e-polybft-test: + description: PolyBFT E2E Tests + type: boolean + required: true + e2e-legacy-test: + description: Legacy E2E Tests + type: boolean + required: true + property-polybft-test: + description: Polybft Property Tests + type: boolean + required: true + fuzz-test: + description: Fuzz Tests + type: boolean + required: true + +jobs: + unit-test: + name: Unit Tests + if: ${{ inputs.unit-test == true }} + uses: ./.github/workflows/unit-test.yml + e2e-polybft-test: + name: PolyBFT E2E Tests + if: ${{ inputs.e2e-polybft-test == true }} + uses: ./.github/workflows/e2e-polybft-test.yml + e2e-legacy-test: + name: Legacy E2E Tests + if: ${{ inputs.e2e-legacy-test == true }} + uses: ./.github/workflows/e2e-legacy-test.yml + property-polybft-test: + name: Polybft Property Tests + if: ${{ inputs.property-polybft-test == true }} + uses: ./.github/workflows/property-polybft-test.yml + fuzz-test: + name: Fuzz Tests + if: ${{ inputs.fuzz-test == true }} + uses: ./.github/workflows/fuzz-test.yml diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml new file mode 100644 index 0000000000..24e12d9819 --- /dev/null +++ b/.github/workflows/unit-test.yml @@ -0,0 +1,34 @@ +--- +name: Unit Tests +on: # yamllint disable-line rule:truthy + workflow_dispatch: + workflow_call: + outputs: + workflow_output: + description: "Unit Tests output" + value: ${{ jobs.unit_test.outputs.test_output_failure }} + +jobs: + unit_test: + name: Blade + runs-on: ubuntu-latest + outputs: + test_output_failure: ${{ steps.run_tests_failure.outputs.test_output }} + steps: + - name: Setup Go + uses: actions/setup-go@v3 + with: + go-version: 1.20.x + - name: Checkout Code + uses: actions/checkout@v3 + with: + submodules: recursive + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + - name: Install Dependencies + run: ./setup-ci.sh + - name: Run Go Test + run: make unit-test + - name: Run Go Test Failed + if: failure() + id: run_tests_failure + run: echo "test_output=false" >> $GITHUB_OUTPUT diff --git a/Makefile b/Makefile index c83d4526bd..d3d0fce9c1 100644 --- a/Makefile +++ b/Makefile @@ -56,16 +56,16 @@ lint: check-lint generate-bsd-licenses: check-git ./generate_dependency_licenses.sh BSD-3-Clause,BSD-2-Clause > ./licenses/bsd_licenses.json -.PHONY: test -test: check-go +.PHONY: unit-test +unit-test: check-go go test -race -shuffle=on -coverprofile coverage.out -timeout 20m `go list ./... | grep -v e2e` .PHONY: fuzz-test fuzz-test: check-go ./scripts/fuzzAll -.PHONY: test-e2e -test-e2e: check-go +.PHONY: test-e2e-legacy +test-e2e-legacy: check-go go build -race -o artifacts/blade . env EDGE_BINARY=${PWD}/artifacts/blade go test -v -timeout=30m ./e2e/... @@ -112,9 +112,9 @@ help: @printf " %-35s - %s\n" "build" "Build the project" @printf " %-35s - %s\n" "lint" "Run linters on the codebase" @printf " %-35s - %s\n" "generate-bsd-licenses" "Generate BSD licenses" - @printf " %-35s - %s\n" "test" "Run unit tests" + @printf " %-35s - %s\n" "unit-test" "Run unit tests" @printf " %-35s - %s\n" "fuzz-test" "Run fuzz tests" - @printf " %-35s - %s\n" "test-e2e" "Run end-to-end tests" + @printf " %-35s - %s\n" "test-e2e-legacy" "Run end-to-end Legacy tests" @printf " %-35s - %s\n" "test-e2e-polybft" "Run end-to-end tests for PolyBFT" @printf " %-35s - %s\n" "test-property-polybft" "Run property tests for PolyBFT" @printf " %-35s - %s\n" "compile-blade-contracts" "Compile blade contracts" From 58321a8409d5ab3239ce94bc962d07ed3996aa75 Mon Sep 17 00:00:00 2001 From: Branislav Kojic Date: Fri, 19 Jan 2024 12:15:43 +0100 Subject: [PATCH 11/67] Disable Tests temporarily (#11) * Deploy Network * Add Permissions * Minor changes * Concurrency change * Destroy Network * Fix commit sha * Add Tests * Disable Tests temporarily --- .github/workflows/e2e-legacy-test.yml | 10 +++++----- .github/workflows/e2e-polybft-test.yml | 10 +++++----- .github/workflows/fuzz-test.yml | 8 ++++---- .github/workflows/property-polybft-test.yml | 8 ++++---- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/.github/workflows/e2e-legacy-test.yml b/.github/workflows/e2e-legacy-test.yml index d9ab62af21..643c5a51c4 100644 --- a/.github/workflows/e2e-legacy-test.yml +++ b/.github/workflows/e2e-legacy-test.yml @@ -1,11 +1,11 @@ --- name: Legacy E2E Tests on: # yamllint disable-line rule:truthy - push: - branches: - - main - - develop - pull_request: + # push: + # branches: + # - main + # - develop + # pull_request: workflow_dispatch: workflow_call: outputs: diff --git a/.github/workflows/e2e-polybft-test.yml b/.github/workflows/e2e-polybft-test.yml index 88f2523ac7..1913d1baa8 100644 --- a/.github/workflows/e2e-polybft-test.yml +++ b/.github/workflows/e2e-polybft-test.yml @@ -1,11 +1,11 @@ --- name: PolyBFT E2E Tests on: # yamllint disable-line rule:truthy - push: - branches: - - main - - develop - pull_request: + # push: + # branches: + # - main + # - develop + # pull_request: workflow_dispatch: workflow_call: outputs: diff --git a/.github/workflows/fuzz-test.yml b/.github/workflows/fuzz-test.yml index 2e2e5e6600..703c332eb5 100644 --- a/.github/workflows/fuzz-test.yml +++ b/.github/workflows/fuzz-test.yml @@ -1,10 +1,10 @@ --- name: Fuzz Tests on: # yamllint disable-line rule:truthy - push: - branches: - - main - - develop + # push: + # branches: + # - main + # - develop workflow_dispatch: workflow_call: outputs: diff --git a/.github/workflows/property-polybft-test.yml b/.github/workflows/property-polybft-test.yml index 93ee8f226b..8f45e97b0c 100644 --- a/.github/workflows/property-polybft-test.yml +++ b/.github/workflows/property-polybft-test.yml @@ -1,10 +1,10 @@ --- name: PolyBFT Property Tests on: # yamllint disable-line rule:truthy - push: - branches: - - main - - develop + # push: + # branches: + # - main + # - develop workflow_dispatch: workflow_call: outputs: From 4c68b5e1519a3c7ba29369e4917adc5c6a2f7463 Mon Sep 17 00:00:00 2001 From: Branislav Kojic Date: Fri, 19 Jan 2024 14:01:41 +0100 Subject: [PATCH 12/67] Nightly Build (#12) * Deploy Network * Add Permissions * Minor changes * Concurrency change * Destroy Network * Fix commit sha * Add Tests * Disable Tests temporarily * Nightly Build --- .github/workflows/e2e-legacy-test.yml | 2 +- .github/workflows/e2e-polybft-test.yml | 2 +- .github/workflows/fuzz-test.yml | 2 +- .github/workflows/nightly.yml | 221 ++------------------ .github/workflows/property-polybft-test.yml | 2 +- .github/workflows/unit-test.yml | 2 +- 6 files changed, 23 insertions(+), 208 deletions(-) diff --git a/.github/workflows/e2e-legacy-test.yml b/.github/workflows/e2e-legacy-test.yml index 643c5a51c4..b301d54968 100644 --- a/.github/workflows/e2e-legacy-test.yml +++ b/.github/workflows/e2e-legacy-test.yml @@ -15,7 +15,7 @@ on: # yamllint disable-line rule:truthy jobs: e2e_legacy: - name: Legacy E2E Tests + name: Run runs-on: ubuntu-latest env: E2E_TESTS: true diff --git a/.github/workflows/e2e-polybft-test.yml b/.github/workflows/e2e-polybft-test.yml index 1913d1baa8..1784c247a0 100644 --- a/.github/workflows/e2e-polybft-test.yml +++ b/.github/workflows/e2e-polybft-test.yml @@ -15,7 +15,7 @@ on: # yamllint disable-line rule:truthy jobs: e2e_polybft: - name: PolyBFT E2E Tests + name: Run runs-on: ubuntu-latest env: E2E_TESTS: true diff --git a/.github/workflows/fuzz-test.yml b/.github/workflows/fuzz-test.yml index 703c332eb5..370b74b73e 100644 --- a/.github/workflows/fuzz-test.yml +++ b/.github/workflows/fuzz-test.yml @@ -14,7 +14,7 @@ on: # yamllint disable-line rule:truthy jobs: fuzz_test: - name: Fuzz Tests + name: Run runs-on: ubuntu-latest outputs: fuzz_output_failure: ${{ steps.run_fuzz_failure.outputs.test_output }} diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 4f4d517a2c..ecd1ce209e 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -1,213 +1,28 @@ --- name: Nightly Build -on: #yamllint disable-line rule:truthy +on: # yamllint disable-line rule:truthy workflow_dispatch: - schedule: - # * is a special character in YAML so you have to quote this string - - cron: '0 0 * * *' - -permissions: - id-token: write - contents: read - security-events: write jobs: build: - name: Build + name: Build Blade uses: ./.github/workflows/build.yml - - test: - name: Test - uses: ./.github/workflows/test.yml - needs: build - - e2e-polybft: - name: PolyBFT E2E Tests - uses: ./.github/workflows/e2e-polybft.yml - needs: build - - e2e-legacy: - name: Legacy E2E Tests - uses: ./.github/workflows/e2e-legacy.yaml + tests: + name: Run Tests + uses: ./.github/workflows/tests.yml needs: build - - property: - name: Polybft Property Tests - uses: ./.github/workflows/property-polybft.yml - needs: build - - fuzz: - name: Fuzz Tests - uses: ./.github/workflows/fuzz-test.yml + with: + unit-test: true + e2e-polybft-test: true + e2e-legacy-test: true + property-polybft-test: true + fuzz-test: true + deploy_network: + name: Deploy nightly Network + uses: ./.github/workflows/deploy-network.yml needs: build - - loadtest: - name: Build Devnet - uses: ./.github/workflows/deploy.nightly.devnet.yml - secrets: - AWS_REGION: ${{ secrets.AWS_REGION }} - AWS_ROLE_ARN: ${{ secrets.AWS_ROLE_ARN }} - TF_VAR_DEPLOYMENT_NAME: ${{ secrets.TF_VAR_DEPLOYMENT_NAME }} - TF_VAR_OWNER: ${{ secrets.TF_VAR_OWNER }} - TF_VAR_BASE_INSTANCE_TYPE: ${{ secrets.TF_VAR_BASE_INSTANCE_TYPE }} - SLACK_PERFORMANCE_WEBHOOK_URL: ${{ secrets.SLACK_PERFORMANCE_WEBHOOK_URL }} - LOADTESTER_AWS_SUBNET_ID: ${{ secrets.LOADTESTER_AWS_SUBNET_ID }} - LOADTESTER_AWS_SG_ID: ${{ secrets.LOADTESTER_AWS_SG_ID }} - LOADTESTER_INSTANCE_TYPE: ${{ secrets.LOADTESTER_INSTANCE_TYPE }} - LOADTEST_MNEMONIC: ${{ secrets.LOADTEST_MNEMONIC }} - VAULT_PASSWORD_FILE: ${{ secrets.VAULT_PASSWORD_FILE }} - LOADTESTER_AMI: ${{ secrets.LOADTESTER_AMI }} - IS_BRIDGE_ACTIVE: ${{ secrets.IS_BRIDGE_ACTIVE }} - PTA: ${{ secrets.PTA }} - BLADE_TAG: ${{ secrets.BLADE_TAG }} - LOG_LEVEL: ${{ secrets.LOG_LEVEL }} with: - environment: devnet - - notification: - name: Nightly Notifications - runs-on: ubuntu-latest - needs: [build, test, e2e-polybft, e2e-legacy, property, fuzz, loadtest] - if: success() || failure() - steps: - - name: Notify Slack - uses: slackapi/slack-github-action@v1.23.0 - env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_BLADE_GITHUB_URL }} - SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK - with: - payload: | - { - "attachments": [ - { - "color": "${{ needs.build.outputs.workflow_output == '' && needs.test.outputs.workflow_output == '' && needs.e2e-polybft.outputs.workflow_output == '' && needs.e2e-legacy.outputs.workflow_output == '' && needs.property.outputs.workflow_output == '' && needs.fuzz.outputs.workflow_output == '' && needs.loadtest.outputs.workflow_output == '' && '#03C03C' || '#E60012' }}", - "blocks": [ - { - "type": "header", - "text": { - "type": "plain_text", - "text": "Nightly Build ${{ needs.build.outputs.workflow_output == '' && needs.test.outputs.workflow_output == '' && needs.e2e-polybft.outputs.workflow_output == '' && needs.e2e-legacy.outputs.workflow_output == '' && needs.property.outputs.workflow_output == '' && needs.fuzz.outputs.workflow_output == '' && needs.loadtest.outputs.workflow_output == '' && ':rocket:' || ':rotating_light:' }}" - } - }, - { - "type": "context", - "elements": [ - { - "type": "mrkdwn", - "text": "Logs: **" - } - ] - }, - { - "type": "actions", - "elements": [ - { - "type": "button", - "text": { - "type": "plain_text", - "text": "View workflow run" - }, - "url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" - } - ] - } - ] - }, - { - "color": "${{ needs.build.outputs.workflow_output == '' && '#03C03C' || '#E60012' }}", - "blocks": [ - { - "type": "section", - "text": { - "type": "mrkdwn", - "text": "*Build*" - } - } - ] - }, - { - "color": "${{ needs.test.outputs.workflow_output == '' && '#03C03C' || '#E60012' }}", - "blocks": [ - { - "type": "section", - "text": { - "type": "mrkdwn", - "text": "*Unit Tests*" - } - } - ] - }, - { - "color": "${{ needs.property.outputs.workflow_output == '' && '#03C03C' || '#E60012' }}", - "blocks": [ - { - "type": "section", - "text": { - "type": "mrkdwn", - "text": "*Property Tests*" - } - } - ] - }, - { - "color": "${{ needs.e2e-legacy.outputs.workflow_output == '' && '#03C03C' || '#E60012' }}", - "blocks": [ - { - "type": "section", - "text": { - "type": "mrkdwn", - "text": "*Legacy E2E Tests*" - } - } - ] - }, - { - "color": "${{ needs.e2e-polybft.outputs.workflow_output == '' && '#03C03C' || '#E60012' }}", - "blocks": [ - { - "type": "section", - "text": { - "type": "mrkdwn", - "text": "*PolyBFT E2E Tests*" - } - } - ] - }, - { - "color": "${{ needs.fuzz.outputs.workflow_output == '' && '#03C03C' || '#E60012' }}", - "blocks": [ - { - "type": "section", - "text": { - "type": "mrkdwn", - "text": "*Fuzz Tests*" - } - } - ] - }, - { - "color": "${{ needs.loadtest.outputs.workflow_output_loadtest1 == 'true' && '#03C03C' || '#E60012' }}", - "blocks": [ - { - "type": "section", - "text": { - "type": "mrkdwn", - "text": "*Load Tests multiple_EOA*" - } - } - ] - }, - { - "color": "${{ needs.loadtest.outputs.workflow_output_loadtest2 == 'true' && '#03C03C' || '#E60012' }}", - "blocks": [ - { - "type": "section", - "text": { - "type": "mrkdwn", - "text": "*Load Tests multiple_ERC20*" - } - } - ] - } - ] - } + environment: nightly + block_gas_limit: "200000000" + block_time: "2" + is_bridge_active: true diff --git a/.github/workflows/property-polybft-test.yml b/.github/workflows/property-polybft-test.yml index 8f45e97b0c..0c427bba84 100644 --- a/.github/workflows/property-polybft-test.yml +++ b/.github/workflows/property-polybft-test.yml @@ -14,7 +14,7 @@ on: # yamllint disable-line rule:truthy jobs: polybft_property: - name: PolyBFT Property Tests + name: Run runs-on: ubuntu-latest env: E2E_TESTS: true diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index 24e12d9819..3ff1d08eb1 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -10,7 +10,7 @@ on: # yamllint disable-line rule:truthy jobs: unit_test: - name: Blade + name: Run runs-on: ubuntu-latest outputs: test_output_failure: ${{ steps.run_tests_failure.outputs.test_output }} From dd9180add93b938aa9bd4c4b3ed085c3fc3cec1f Mon Sep 17 00:00:00 2001 From: Branislav Kojic Date: Fri, 19 Jan 2024 14:31:45 +0100 Subject: [PATCH 13/67] Minor fixes (#13) * Deploy Network * Add Permissions * Minor changes * Concurrency change * Destroy Network * Minor changes * Minor changes * Fix commit sha * Minor changes * Add Tests * Disable Tests temporarily * Nightly Build * Minor fixes --- .github/workflows/deploy-network.yml | 7 +++++++ .github/workflows/nightly.yml | 31 +++++++++++++++------------- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/.github/workflows/deploy-network.yml b/.github/workflows/deploy-network.yml index ffef08777c..c48bdfcb18 100644 --- a/.github/workflows/deploy-network.yml +++ b/.github/workflows/deploy-network.yml @@ -40,6 +40,13 @@ on: # yamllint disable-line rule:truthy description: Activate Bridge type: boolean required: true + secrets: + AWS_REGION: + required: true + AWS_ROLE_ARN: + required: true + VAULT_PASSWORD: + required: true permissions: id-token: write diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index ecd1ce209e..9bc20d43d0 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -4,25 +4,28 @@ on: # yamllint disable-line rule:truthy workflow_dispatch: jobs: - build: - name: Build Blade - uses: ./.github/workflows/build.yml - tests: - name: Run Tests - uses: ./.github/workflows/tests.yml - needs: build - with: - unit-test: true - e2e-polybft-test: true - e2e-legacy-test: true - property-polybft-test: true - fuzz-test: true + # build: + # name: Build Blade + # uses: ./.github/workflows/build.yml + # tests: + # name: Run Tests + # uses: ./.github/workflows/tests.yml + # needs: build + # with: + # unit-test: true + # e2e-polybft-test: true + # e2e-legacy-test: true + # property-polybft-test: true + # fuzz-test: true deploy_network: name: Deploy nightly Network uses: ./.github/workflows/deploy-network.yml - needs: build with: environment: nightly block_gas_limit: "200000000" block_time: "2" is_bridge_active: true + secrets: + AWS_REGION: ${{ secrets.AWS_REGION }} + AWS_ROLE_ARN: ${{ secrets.AWS_ROLE_ARN }} + VAULT_PASSWORD: ${{ secrets.VAULT_PASSWORD }} From 4d70fcd8017d3cfa5e84d761b1659baf7874cc2a Mon Sep 17 00:00:00 2001 From: Branislav Kojic Date: Thu, 25 Jan 2024 12:54:58 +0100 Subject: [PATCH 14/67] Big Changes (#15) * Deploy Network * Add Permissions * Minor changes * Concurrency change * Destroy Network * Fix commit sha * Add Tests * Disable Tests temporarily * Nightly Build * Minor fixes * Big changes --- .github/workflows/build.yml | 8 +- .github/workflows/deploy-network.yml | 86 ++++--- .github/workflows/destroy-network.yml | 70 ++++-- .github/workflows/e2e-legacy-test.yml | 13 +- .github/workflows/e2e-polybft-test.yml | 13 +- .github/workflows/fuzz-test.yml | 7 +- .github/workflows/load-test.yml | 232 ++++++++++++++++++ .github/workflows/nightly.yml | 160 ++++++++++-- .../workflows/notification-deploy-network.yml | 97 ++++++++ .../notification-destroy-network.yml | 97 ++++++++ .github/workflows/notification-load-test.yml | 145 +++++++++++ .github/workflows/notification-main.yml | 195 +++++++++++++++ .github/workflows/property-polybft-test.yml | 13 +- .github/workflows/tests.yml | 46 ++-- .github/workflows/unit-test.yml | 7 +- e2e/README.md | 2 +- loadtest/scenarios/multiple_EOA.js | 37 ++- loadtest/scenarios/multiple_ERC20.js | 27 +- 18 files changed, 1137 insertions(+), 118 deletions(-) create mode 100644 .github/workflows/load-test.yml create mode 100644 .github/workflows/notification-deploy-network.yml create mode 100644 .github/workflows/notification-destroy-network.yml create mode 100644 .github/workflows/notification-load-test.yml create mode 100644 .github/workflows/notification-main.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ac7ac783b4..c6491d96c9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,13 +11,13 @@ on: # yamllint disable-line rule:truthy jobs: go_build: - name: Build Blade + name: Build runs-on: ubuntu-latest outputs: build_output_failure: ${{ steps.blade_build_failure.outputs.build_output }} steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup Go environment uses: actions/setup-go@v3 with: @@ -32,7 +32,7 @@ jobs: id: blade_build_failure run: echo "build_output=false" >> $GITHUB_OUTPUT - name: "Upload Artifact" - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: blade path: blade.tar.gz @@ -43,7 +43,7 @@ jobs: continue-on-error: true steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup Go environment uses: actions/setup-go@v3 with: diff --git a/.github/workflows/deploy-network.yml b/.github/workflows/deploy-network.yml index c48bdfcb18..51aed876c0 100644 --- a/.github/workflows/deploy-network.yml +++ b/.github/workflows/deploy-network.yml @@ -1,25 +1,25 @@ --- -concurrency: ci-$ +concurrency: ci-$ # Only a single workflow can be executed concurrently name: Deploy Network -on: # yamllint disable-line rule:truthy +on: # yamllint disable-line rule:truthy workflow_dispatch: inputs: environment: description: The environment to run against type: choice - options: [dev, test] + options: [dev, test] # nightly should not be initiated manually block_gas_limit: - description: Set block gas limit + description: Block Gas Limit type: string default: "200000000" required: true block_time: - description: Set block time + description: Block Time type: string default: "2" required: true is_bridge_active: - description: Activate Bridge + description: With Bridge type: boolean default: true workflow_call: @@ -29,22 +29,29 @@ on: # yamllint disable-line rule:truthy type: string required: true block_gas_limit: - description: Set block gas limit + description: Block Gas Limit type: string required: true block_time: - description: Set block time + description: Block Time type: string required: true is_bridge_active: - description: Activate Bridge + description: With Bridge type: boolean required: true + outputs: + terraform_output: + description: "Terraform output" + value: ${{ jobs.deploy_network.outputs.terraform_output }} + ansible_output: + description: "Ansible output" + value: ${{ jobs.deploy_network.outputs.ansible_output }} secrets: - AWS_REGION: - required: true AWS_ROLE_ARN: required: true + AWS_S3_BLADE_BUCKET: + required: true VAULT_PASSWORD: required: true @@ -55,36 +62,38 @@ permissions: jobs: deploy_network: - name: Deploy ${{ inputs.environment }} Network + name: Deploy ${{ inputs.environment }} runs-on: ubuntu-latest - environment: ${{ inputs.environment }} + environment: + name: ${{ inputs.environment }} + url: ${{ steps.rpc_url.outputs.url }} + outputs: + terraform_output: ${{ steps.terraform_failure.outputs.terraform_output }} + ansible_output: ${{ steps.ansible_failure.outputs.ansible_output }} + rpc_url: ${{ steps.rpc_url.outputs.url }} steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: repository: Ethernal-Tech/blade-deployment ref: changes - name: Configure AWS Credentials uses: aws-actions/configure-aws-credentials@v3 with: - aws-region: ${{ secrets.AWS_REGION }} + aws-region: ${{ vars.AWS_REGION }} role-to-assume: ${{ secrets.AWS_ROLE_ARN }} - name: Install Terraform uses: hashicorp/setup-terraform@v2.0.3 with: terraform_version: 1.4.5 - name: Configure Terraform for ${{ inputs.environment }} - run: | - sed 's/# backend "s3" {}/backend "s3" {}/' main.tf > main.tf.tmp && mv main.tf.tmp main.tf + run: sed 's/# backend "s3" {}/backend "s3" {}/' main.tf > main.tf.tmp && mv main.tf.tmp main.tf - name: Terraform Init - id: init - run: terraform init -backend-config="bucket=blade-github" -backend-config="key=states/${{ inputs.environment }}" -backend-config="region=${{ secrets.AWS_REGION }}" + run: terraform init -backend-config="bucket=${{ secrets.AWS_S3_BLADE_BUCKET }}" -backend-config="key=states/${{ inputs.environment }}" -backend-config="region=${{ vars.AWS_REGION }}" - name: Terraform Validate - id: validate run: terraform validate -no-color continue-on-error: true - name: Terraform Apply - id: apply run: terraform apply -auto-approve env: TF_VAR_deployment_name: ${{ inputs.environment }} @@ -92,8 +101,10 @@ jobs: TF_VAR_geth_count: ${{ vars.GETH_COUNT }} TF_VAR_fullnode_count: ${{ vars.FULLNODE_COUNT }} TF_VAR_validator_count: ${{ vars.VALIDATOR_COUNT }} - - name: Retrieve state file from s3 - run: aws s3 cp s3://blade-github/states/${{ inputs.environment }} state.json + - name: Terraform Failed + if: failure() + id: terraform_failure + run: echo "terraform_output=false" >> $GITHUB_OUTPUT - name: Configure private keys run: | terraform output pk_ansible > ~/private.key @@ -110,18 +121,29 @@ jobs: echo "${{ secrets.VAULT_PASSWORD }}" > password.txt sed 's/devnet/${{ inputs.environment }}/g' inventory/aws_ec2.yml > inventory/aws_ec2.yml.tmp && mv inventory/aws_ec2.yml.tmp inventory/aws_ec2.yml sed 's/blade_tag: .*/blade_tag: ${{ github.sha }}/g' group_vars/all.yml > group_vars/all.yml.tmp && mv group_vars/all.yml.tmp group_vars/all.yml - sed 's/INFO/${{ secrets.LOG_LEVEL }}/g' roles/blade/templates/blade.service > roles/blade/templates/blade.service.tmp && mv roles/blade/templates/blade.service.tmp roles/blade/templates/blade.service + sed 's/INFO/${{ vars.LOG_LEVEL }}/g' roles/blade/templates/blade.service > roles/blade/templates/blade.service.tmp && mv roles/blade/templates/blade.service.tmp roles/blade/templates/blade.service - name: Run Ansible working-directory: ansible run: | ansible-inventory --graph ansible-galaxy install -r requirements.yml ansible-playbook site.yml --extra-vars "clean_deploy_title=${{ inputs.environment }} block_gas_limit=${{ inputs.block_gas_limit }} block_time=${{ inputs.block_time }} is_bridge_active=${{ inputs.is_bridge_active }}" - - name: Set RPC URL value - id: url - run: | - terraform output -raw aws_lb_ext_domain | grep -o -E '^ext[^:]*' > rpc_url.txt - - uses: actions/upload-artifact@v3 - with: - name: rpc_url - path: rpc_url.txt + - name: Ansible Failed + if: failure() + id: ansible_failure + run: echo "ansible_output=false" >> $GITHUB_OUTPUT + - name: Set RPC URL + id: rpc_url + run: echo "url=http://$(terraform output -raw aws_lb_ext_domain | grep -o -E '^ext[^:]*')" >> $GITHUB_OUTPUT + notification: + name: Deploy Notification + needs: deploy_network + uses: ./.github/workflows/notification-deploy-network.yml + if: always() && ${{ github.event_name == 'workflow_dispatch' }} + with: + environment: nightly + deploy_network_terraform_output: ${{ needs.deploy_network.outputs.terraform_output }} + deploy_network_ansible_output: ${{ needs.deploy_network.outputs.ansible_output }} + rpc_url: ${{ needs.deploy_network.outputs.rpc_url }} + secrets: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} diff --git a/.github/workflows/destroy-network.yml b/.github/workflows/destroy-network.yml index ca48f0121b..897c69cb7e 100644 --- a/.github/workflows/destroy-network.yml +++ b/.github/workflows/destroy-network.yml @@ -1,13 +1,13 @@ --- -concurrency: ci-$ +concurrency: ci-$ # Only a single workflow can be executed concurrently name: Destroy Network -on: # yamllint disable-line rule:truthy +on: # yamllint disable-line rule:truthy workflow_dispatch: inputs: environment: description: The environment to run against type: choice - options: [dev, test] + options: [dev, test] # nightly should not be initiated manually logs: description: Upload Logs type: boolean @@ -22,6 +22,20 @@ on: # yamllint disable-line rule:truthy description: Upload Logs type: boolean required: true + outputs: + logs_output: + description: Upload Logs output + value: ${{ jobs.upload_logs.outputs.logs_output }} + terraform_output: + description: Terraform output + value: ${{ jobs.destroy_network.outputs.terraform_output }} + secrets: + AWS_ROLE_ARN: + required: true + AWS_S3_BLADE_BUCKET: + required: true + VAULT_PASSWORD: + required: true permissions: id-token: write @@ -34,29 +48,28 @@ jobs: runs-on: ubuntu-latest environment: ${{ inputs.environment }} if: ${{ inputs.logs == true }} + outputs: + logs_output: ${{ steps.logs_failure.outputs.logs_output }} steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: repository: Ethernal-Tech/blade-deployment ref: changes - name: Configure AWS Credentials uses: aws-actions/configure-aws-credentials@v3 with: - aws-region: ${{ secrets.AWS_REGION }} + aws-region: ${{ vars.AWS_REGION }} role-to-assume: ${{ secrets.AWS_ROLE_ARN }} - name: Install Terraform uses: hashicorp/setup-terraform@v2.0.3 with: terraform_version: 1.4.5 - name: Configure Terraform for ${{ inputs.environment }} - run: | - sed 's/# backend "s3" {}/backend "s3" {}/' main.tf > main.tf.tmp && mv main.tf.tmp main.tf + run: sed 's/# backend "s3" {}/backend "s3" {}/' main.tf > main.tf.tmp && mv main.tf.tmp main.tf - name: Terraform Init id: init - run: terraform init -backend-config="bucket=blade-github" -backend-config="key=states/${{ inputs.environment }}" -backend-config="region=${{ secrets.AWS_REGION }}" - - name: Retrieve state file from s3 - run: aws s3 cp s3://blade-github/states/${{ inputs.environment }} state.json + run: terraform init -backend-config="bucket=${{ secrets.AWS_S3_BLADE_BUCKET }}" -backend-config="key=states/${{ inputs.environment }}" -backend-config="region=${{ vars.AWS_REGION }}" - name: Configure private keys run: | terraform output pk_ansible > ~/private.key @@ -76,24 +89,29 @@ jobs: sed 's/{{ current_datetime\.stdout }}/${{ github.run_id }}/g' roles/upload-logs/tasks/logs.yml > roles/upload-logs/tasks/logs.yml.tmp && mv roles/upload-logs/tasks/logs.yml.tmp roles/upload-logs/tasks/logs.yml - name: Upload Logs working-directory: ansible - run: | - ansible-playbook upload-logs.yml --extra-vars "clean_deploy_title=${{ inputs.environment }}" + run: ansible-playbook upload-logs.yml --extra-vars "clean_deploy_title=${{ inputs.environment }}" + - name: Logs Failed + if: failure() + id: logs_failure + run: echo "logs_output=false" >> $GITHUB_OUTPUT destroy_network: name: Destroy ${{ inputs.environment }} Network runs-on: ubuntu-latest environment: ${{ inputs.environment }} - needs: [upload_logs] + needs: upload_logs if: always() + outputs: + terraform_output: ${{ steps.terraform_failure.outputs.terraform_output }} steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: repository: Ethernal-Tech/blade-deployment ref: changes - name: Configure AWS Credentials uses: aws-actions/configure-aws-credentials@v3 with: - aws-region: ${{ secrets.AWS_REGION }} + aws-region: ${{ vars.AWS_REGION }} role-to-assume: ${{ secrets.AWS_ROLE_ARN }} - name: Install Terraform uses: hashicorp/setup-terraform@v2.0.3 @@ -104,9 +122,23 @@ jobs: sed 's/# backend "s3" {}/backend "s3" {}/' main.tf > main.tf.tmp && mv main.tf.tmp main.tf - name: Terraform Init id: init - run: terraform init -backend-config="bucket=blade-github" -backend-config="key=states/${{ inputs.environment }}" -backend-config="region=${{ secrets.AWS_REGION }}" - - name: Retrieve state file from s3 - run: aws s3 cp s3://blade-github/states/${{ inputs.environment }} state.json + run: terraform init -backend-config="bucket=${{ secrets.AWS_S3_BLADE_BUCKET }}" -backend-config="key=states/${{ inputs.environment }}" -backend-config="region=${{ vars.AWS_REGION }}" - name: Terraform Destroy id: destroy - run: terraform destroy -auto-approve -state=state.json + run: terraform destroy -auto-approve + - name: Terraform Failed + if: failure() + id: terraform_failure + run: echo "terraform_output=false" >> $GITHUB_OUTPUT + notification: + name: Network Notifications + uses: ./.github/workflows/notification-destroy-network.yml + needs: [upload_logs, destroy_network] + if: always() && ${{ github.event_name == 'workflow_dispatch' }} + with: + environment: ${{ inputs.environment }} + destroy_network_upload_logs: ${{ needs.upload_logs.outputs.logs_output }} + destroy_network_terraform_logs: ${{ needs.destroy_network.outputs.terraform_output }} + secrets: + AWS_S3_BLADE_BUCKET: ${{ secrets.AWS_S3_BLADE_BUCKET }} + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} diff --git a/.github/workflows/e2e-legacy-test.yml b/.github/workflows/e2e-legacy-test.yml index b301d54968..db85ef7f35 100644 --- a/.github/workflows/e2e-legacy-test.yml +++ b/.github/workflows/e2e-legacy-test.yml @@ -1,6 +1,6 @@ --- -name: Legacy E2E Tests -on: # yamllint disable-line rule:truthy +name: E2E Legacy Tests +on: # yamllint disable-line rule:truthy # push: # branches: # - main @@ -8,14 +8,15 @@ on: # yamllint disable-line rule:truthy # pull_request: workflow_dispatch: workflow_call: + # Map the workflow outputs to job outputs outputs: workflow_output: - description: "Legacy E2E Tests output" + description: "E2E Legacy Tests output" value: ${{ jobs.e2e_legacy.outputs.e2e_legacy_output_failure }} jobs: e2e_legacy: - name: Run + name: Run E2E Legacy Tests runs-on: ubuntu-latest env: E2E_TESTS: true @@ -25,7 +26,7 @@ jobs: e2e_legacy_output_failure: ${{ steps.run_e2e_legacy_failure.outputs.test_output }} steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: submodules: recursive - name: Install Go @@ -40,7 +41,7 @@ jobs: run: echo "test_output=false" >> $GITHUB_OUTPUT - name: Archive test logs if: always() - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: e2e-logs path: e2e-logs-*/ diff --git a/.github/workflows/e2e-polybft-test.yml b/.github/workflows/e2e-polybft-test.yml index 1784c247a0..1cc8f376ac 100644 --- a/.github/workflows/e2e-polybft-test.yml +++ b/.github/workflows/e2e-polybft-test.yml @@ -1,6 +1,6 @@ --- -name: PolyBFT E2E Tests -on: # yamllint disable-line rule:truthy +name: E2E PolyBFT Tests +on: # yamllint disable-line rule:truthy # push: # branches: # - main @@ -8,14 +8,15 @@ on: # yamllint disable-line rule:truthy # pull_request: workflow_dispatch: workflow_call: + # Map the workflow outputs to job outputs outputs: workflow_output: - description: "PolyBFT E2E Tests output" + description: "E2E PolyBFT Tests output" value: ${{ jobs.e2e_polybft.outputs.e2e_polybft_output_failure }} jobs: e2e_polybft: - name: Run + name: Run E2E PolyBFT Tests runs-on: ubuntu-latest env: E2E_TESTS: true @@ -25,7 +26,7 @@ jobs: e2e_polybft_output_failure: ${{ steps.run_e2e_polybft_failure.outputs.test_output }} steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Install Go uses: actions/setup-go@v4 with: @@ -40,7 +41,7 @@ jobs: run: echo "test_output=false" >> $GITHUB_OUTPUT - name: Archive test logs if: always() - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: e2e-logs path: e2e-logs-*/ diff --git a/.github/workflows/fuzz-test.yml b/.github/workflows/fuzz-test.yml index 370b74b73e..851d77c1f6 100644 --- a/.github/workflows/fuzz-test.yml +++ b/.github/workflows/fuzz-test.yml @@ -1,12 +1,13 @@ --- name: Fuzz Tests -on: # yamllint disable-line rule:truthy +on: # yamllint disable-line rule:truthy # push: # branches: # - main # - develop workflow_dispatch: workflow_call: + # Map the workflow outputs to job outputs outputs: workflow_output: description: "Fuzz Tests output" @@ -14,7 +15,7 @@ on: # yamllint disable-line rule:truthy jobs: fuzz_test: - name: Run + name: Run Fuzz Tests runs-on: ubuntu-latest outputs: fuzz_output_failure: ${{ steps.run_fuzz_failure.outputs.test_output }} @@ -24,7 +25,7 @@ jobs: with: go-version: 1.20.x - name: Checkout Code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Run Fuzz Test run: make fuzz-test - name: Run fuzz tests failed diff --git a/.github/workflows/load-test.yml b/.github/workflows/load-test.yml new file mode 100644 index 0000000000..b90c4fa40c --- /dev/null +++ b/.github/workflows/load-test.yml @@ -0,0 +1,232 @@ +--- +concurrency: ci-$ # Only a single workflow can be executed concurrently +name: Load Tests +on: # yamllint disable-line rule:truthy + workflow_dispatch: + inputs: + environment: + description: The environment to run against + type: choice + options: [dev, test] # nightly should not be initiated manually + scenario: + description: The scenario to run + type: choice + options: [EOA, ERC20] + setupTimeOut: + description: Setup TimeOut + type: string + default: "220s" + required: true + rate: + description: Rate + type: string + default: "3000" + required: true + timeUnit: + description: Time Unit + type: string + default: "1s" + required: true + duration: + description: Duration + type: string + default: "10m" + required: true + preAllocatedVUs: + description: Preallocated VUs + type: string + default: "60" + required: true + maxVUs: + description: Max VUs + type: string + default: "60" + required: true + workflow_call: + inputs: + environment: + description: The environment to run against + type: string + required: true + scenario: + description: The scenario to run + type: string + required: true + setupTimeOut: + description: Setup TimeOut + type: string + required: true + rate: + description: Rate + type: string + required: true + timeUnit: + description: Time Unit + type: string + required: true + duration: + description: Duration + type: string + required: true + preAllocatedVUs: + description: Preallocated VUs + type: string + required: true + maxVUs: + description: Max VUs + type: string + required: true + outputs: + load_test_output: + description: "Load Test output" + value: ${{ jobs.load_test_scenario.outputs.test_output_success }} + tps_avg: + description: "Average Transactions Per Second" + value: ${{ jobs.load_test_scenario.outputs.tps_avg }} + tps_max: + description: "Maximum Transactions Per Second" + value: ${{ jobs.load_test_scenario.outputs.tps_max }} + iterations: + description: "Number Of Transactions" + value: ${{ jobs.load_test_scenario.outputs.iterations }} + block: + description: "Block Number" + value: ${{ jobs.load_test_scenario.outputs.block }} + ttm: + description: "Time To Mine" + value: ${{ jobs.load_test_scenario.outputs.ttm }} + gas_avg: + description: "Average Gas Used" + value: ${{ jobs.load_test_scenario.outputs.gas_avg }} + gas_max: + description: "Maximum Gas Used" + value: ${{ jobs.load_test_scenario.outputs.gas_max }} + secrets: + AWS_ROLE_ARN: + required: true + AWS_S3_BLADE_BUCKET: + required: true + AWS_LOADTESTRUNNER_AMI_ID: + required: true + AWS_LOADTESTRUNNER_SUBNET_ID: + required: true + AWS_LOADTESTRUNNER_SG_ID: + required: true + AWS_LOADTESTRUNNER_MNEMONIC: + required: true + PERSONAL_ACCESS_TOKEN: + required: true + SLACK_WEBHOOK_URL: + required: true + +jobs: + load_test_runner: + name: Deploy Load Test Runner + runs-on: ubuntu-latest + environment: ${{ inputs.environment }} + outputs: + load_test_runner_label: ${{ steps.start_load_teste_runner.outputs.label }} + load_test_runner_instance_id: ${{ steps.start_load_teste_runner.outputs.ec2-instance-id }} + steps: + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v2 + with: + aws-region: ${{ vars.AWS_REGION }} + role-to-assume: ${{ secrets.AWS_ROLE_ARN }} + - name: Start Load Test Runner + id: start_load_teste_runner + uses: machulav/ec2-github-runner@v2 + with: + mode: start + ec2-instance-type: ${{ vars.AWS_INSTANCE_TYPE }} + ec2-image-id: ${{ secrets.AWS_LOADTESTRUNNER_AMI_ID }} + subnet-id: ${{ secrets.AWS_LOADTESTRUNNER_SUBNET_ID }} + security-group-id: ${{ secrets.AWS_LOADTESTRUNNER_SG_ID }} + github-token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} + load_test_scenario: + name: Run Load Test ${{ inputs.scenario }} Scenario + runs-on: ${{ needs.load_test_runner.outputs.load_test_runner_label }} + needs: load_test_runner + outputs: + test_output_success: ${{ steps.load_test_results_success.outputs.test_output }} + tps_avg: ${{ steps.load_test_results.outputs.tps_avg }} + tps_max: ${{ steps.load_test_results.outputs.tps_max }} + iterations: ${{ steps.load_test_results.outputs.iterations }} + block: ${{ steps.load_test_results.outputs.block }} + ttm: ${{ steps.load_test_results.outputs.ttm }} + gas_avg: ${{ steps.load_test_results.outputs.gas_avg }} + gas_max: ${{ steps.load_test_results.outputs.gas_max }} + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v2 + with: + aws-region: ${{ vars.AWS_REGION }} + role-to-assume: ${{ secrets.AWS_ROLE_ARN }} + - name: Retrieve state file from s3 + run: aws s3 cp s3://${{ secrets.AWS_S3_BLADE_BUCKET }}/states/${{ inputs.environment }} state.json + - name: Set RPC URL + id: set_rpc_url + run: echo "rpc_url_value=http://$(cat state.json | jq -r '.outputs.aws_lb_ext_domain.value')" >> $GITHUB_OUTPUT + - name: Run scenario + id: load_test_results + run: | + /home/ubuntu/k6 run --out statsd loadtest/scenarios/multiple_${{ inputs.scenario }}.js + echo "tps_avg=$(cat summary.json | jq -r '.metrics.ethereum_tps.values.avg')" >> $GITHUB_OUTPUT + echo "tps_max=$(cat summary.json | jq -r '.metrics.ethereum_tps.values.max')" >> $GITHUB_OUTPUT + echo "iterations=$(cat summary.json | jq -r '.metrics.iterations.values.count')" >> $GITHUB_OUTPUT + echo "block=$(cat summary.json | jq -r '.metrics.ethereum_block.values.count')" >> $GITHUB_OUTPUT + echo "ttm=$(cat summary.json | jq -r '.metrics.ethereum_time_to_mine.values.avg')" >> $GITHUB_OUTPUT + echo "gas_avg=$(cat summary.json | jq -r '.metrics.ethereum_gas_used.values.avg')" >> $GITHUB_OUTPUT + echo "gas_max=$(cat summary.json | jq -r '.metrics.ethereum_gas_used.values.max')" >> $GITHUB_OUTPUT + env: + K6_STATSD_ENABLE_TAGS: true + SETUP_TIMEOUT: ${{ inputs.setupTimeOut }} + RATE: ${{ inputs.rate }} + TIME_UNIT: ${{ inputs.timeUnit }} + DURATION: ${{ inputs.duration }} + PREALLOCATED_VUS: ${{ inputs.preAllocatedVUs }} + MAX_VUS: ${{ inputs.maxVUs }} + LOADTEST_MNEMONIC: ${{ secrets.AWS_LOADTESTRUNNER_MNEMONIC }} + RPC_URL: ${{ steps.set_rpc_url.outputs.rpc_url_value }} + - name: Run tests success + if: success() + id: load_test_results_success + run: echo "test_output=true" >> $GITHUB_OUTPUT + notification: + name: Load Test Notification + needs: load_test_scenario + uses: ./.github/workflows/notification-load-test.yml + if: success() && ${{ github.event_name == 'workflow_dispatch' }} + with: + environment: ${{ inputs.environment }} + scenario: ${{ inputs.scenario }} + tps_avg: ${{ needs.load_test_scenario.outputs.tps_avg }} + tps_max: ${{ needs.load_test_scenario.outputs.tps_max }} + iterations: ${{ needs.load_test_scenario.outputs.iterations }} + block: ${{ needs.load_test_scenario.outputs.block }} + ttm: ${{ needs.load_test_scenario.outputs.ttm }} + gas_avg: ${{ needs.load_test_scenario.outputs.gas_avg }} + gas_max: ${{ needs.load_test_scenario.outputs.gas_max }} + secrets: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + destroy_load_test_runner: + name: Destroy Load Test Runner + environment: ${{ inputs.environment }} + needs: [load_test_runner, load_test_scenario] + if: always() + runs-on: ubuntu-latest + steps: + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v2 + with: + aws-region: ${{ vars.AWS_REGION }} + role-to-assume: ${{ secrets.AWS_ROLE_ARN }} + - name: Stop Load Test Runner + uses: machulav/ec2-github-runner@v2 + with: + mode: stop + label: ${{ needs.load_test_runner.outputs.load_test_runner_label }} + ec2-instance-id: ${{ needs.load_test_runner.outputs.load_test_runner_instance_id }} + github-token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 9bc20d43d0..4babea61ee 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -1,31 +1,159 @@ --- name: Nightly Build -on: # yamllint disable-line rule:truthy +on: # yamllint disable-line rule:truthy workflow_dispatch: + schedule: + # * is a special character in YAML so you have to quote this string + - cron: '0 0 * * *' jobs: - # build: - # name: Build Blade - # uses: ./.github/workflows/build.yml - # tests: - # name: Run Tests - # uses: ./.github/workflows/tests.yml - # needs: build - # with: - # unit-test: true - # e2e-polybft-test: true - # e2e-legacy-test: true - # property-polybft-test: true - # fuzz-test: true + check: + name: Check new commits + runs-on: ubuntu-latest + outputs: + new_commit_count: ${{ steps.get_new_commits.outputs.commit_count }} + steps: + - name: Checkout Code + uses: actions/checkout@v4 + - name: Get new commits + id: get_new_commits + run: echo "commit_count=$(git log --oneline --since '24 hours ago' | wc -l | tr -d ' ')" >> $GITHUB_OUTPUT + build: + name: Build Blade + uses: ./.github/workflows/build.yml + needs: check + if: ${{ needs.check.outputs.new_commit_count > 0 }} + tests: + name: Tests + uses: ./.github/workflows/tests.yml + needs: build + with: + unit-test: true + e2e-polybft-test: true + e2e-legacy-test: true + property-polybft-test: true + fuzz-test: true deploy_network: - name: Deploy nightly Network + name: Deploy Network uses: ./.github/workflows/deploy-network.yml + needs: check + if: ${{ needs.check.outputs.new_commit_count > 0 }} with: environment: nightly block_gas_limit: "200000000" block_time: "2" is_bridge_active: true secrets: - AWS_REGION: ${{ secrets.AWS_REGION }} AWS_ROLE_ARN: ${{ secrets.AWS_ROLE_ARN }} + AWS_S3_BLADE_BUCKET: ${{ secrets.AWS_S3_BLADE_BUCKET }} VAULT_PASSWORD: ${{ secrets.VAULT_PASSWORD }} + load_test_multiple_eoa: + name: Load Test EOA + uses: ./.github/workflows/load-test.yml + needs: deploy_network + with: + environment: nightly + scenario: EOA + setupTimeOut: "220s" + rate: "3000" + timeUnit: "1s" + duration: "10m" + preAllocatedVUs: "60" + maxVUs: "60" + secrets: + AWS_ROLE_ARN: ${{ secrets.AWS_ROLE_ARN }} + AWS_S3_BLADE_BUCKET: ${{ secrets.AWS_S3_BLADE_BUCKET }} + AWS_LOADTESTRUNNER_AMI_ID: ${{ secrets.AWS_LOADTESTRUNNER_AMI_ID }} + AWS_LOADTESTRUNNER_SUBNET_ID: ${{ secrets.AWS_LOADTESTRUNNER_SUBNET_ID }} + AWS_LOADTESTRUNNER_SG_ID: ${{ secrets.AWS_LOADTESTRUNNER_SG_ID }} + AWS_LOADTESTRUNNER_MNEMONIC: ${{ secrets.AWS_LOADTESTRUNNER_MNEMONIC }} + PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + load_test_multiple_erc20: + name: Load Test ERC20 + uses: ./.github/workflows/load-test.yml + needs: [deploy_network, load_test_multiple_eoa] + with: + environment: nightly + scenario: ERC20 + setupTimeOut: "220s" + rate: "1500" + timeUnit: "1s" + duration: "10m" + preAllocatedVUs: "60" + maxVUs: "60" + secrets: + AWS_ROLE_ARN: ${{ secrets.AWS_ROLE_ARN }} + AWS_S3_BLADE_BUCKET: ${{ secrets.AWS_S3_BLADE_BUCKET }} + AWS_LOADTESTRUNNER_AMI_ID: ${{ secrets.AWS_LOADTESTRUNNER_AMI_ID }} + AWS_LOADTESTRUNNER_SUBNET_ID: ${{ secrets.AWS_LOADTESTRUNNER_SUBNET_ID }} + AWS_LOADTESTRUNNER_SG_ID: ${{ secrets.AWS_LOADTESTRUNNER_SG_ID }} + AWS_LOADTESTRUNNER_MNEMONIC: ${{ secrets.AWS_LOADTESTRUNNER_MNEMONIC }} + PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + destroy_network: + name: Destroy Network + uses: ./.github/workflows/destroy-network.yml + needs: [deploy_network, load_test_multiple_eoa, load_test_multiple_erc20] + if: always() + with: + environment: nightly + logs: true + secrets: + AWS_ROLE_ARN: ${{ secrets.AWS_ROLE_ARN }} + AWS_S3_BLADE_BUCKET: ${{ secrets.AWS_S3_BLADE_BUCKET }} + VAULT_PASSWORD: ${{ secrets.VAULT_PASSWORD }} + notification_main: + name: Nightly Notification + uses: ./.github/workflows/notification-main.yml + needs: [build, tests, deploy_network, load_test_multiple_eoa, load_test_multiple_erc20, destroy_network] + if: success() || failure() + with: + environment: nightly + build_output: ${{ needs.build.outputs.workflow_output }} + unit_test_output: ${{ needs.tests.outputs.unit-test }} + e2e_polybft_test_output: ${{ needs.tests.outputs.e2e-polybft-test }} + e2e_legacy_test_output: ${{ needs.tests.outputs.e2e-legacy-test }} + property_polybft_test_output: ${{ needs.tests.outputs.property-polybft-test }} + fuzz_test_output: ${{ needs.tests.outputs.fuzz-test }} + deploy_network_terraform_output: ${{ needs.deploy_network.outputs.terraform_output }} + deploy_network_ansible_output: ${{ needs.deploy_network.outputs.ansible_output }} + load_test_multiple_eoa_output: ${{ needs.load_test_multiple_eoa.outputs.load_test_output }} + load_test_multiple_erc20_output: ${{ needs.load_test_multiple_erc20.outputs.load_test_output }} + destroy_network_logs_output: ${{ needs.destroy_network.outputs.logs_output }} + destroy_network_terraform_output: ${{ needs.destroy_network.outputs.terraform_output }} + secrets: + AWS_S3_BLADE_BUCKET: ${{ secrets.AWS_S3_BLADE_BUCKET }} + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + notification_load_test_multiple_eoa: + name: Load Test multiple_EOA Notification + uses: ./.github/workflows/notification-load-test.yml + needs: [load_test_multiple_eoa, notification_main] + with: + environment: nightly + scenario: multiple_EOA + tps_avg: ${{ needs.load_test_multiple_eoa.outputs.tps_avg }} + tps_max: ${{ needs.load_test_multiple_eoa.outputs.tps_max }} + iterations: ${{ needs.load_test_multiple_eoa.outputs.iterations }} + block: ${{ needs.load_test_multiple_eoa.outputs.block }} + ttm: ${{ needs.load_test_multiple_eoa.outputs.ttm }} + gas_avg: ${{ needs.load_test_multiple_eoa.outputs.gas_avg }} + gas_max: ${{ needs.load_test_multiple_eoa.outputs.gas_max }} + secrets: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + notification_load_test_multiple_erc20: + name: Load Test multiple_ERC20 Notification + uses: ./.github/workflows/notification-load-test.yml + needs: [load_test_multiple_erc20, notification_main] + with: + environment: nightly + scenario: multiple_ERC20 + tps_avg: ${{ needs.load_test_multiple_erc20.outputs.tps_avg }} + tps_max: ${{ needs.load_test_multiple_erc20.outputs.tps_max }} + iterations: ${{ needs.load_test_multiple_erc20.outputs.iterations }} + block: ${{ needs.load_test_multiple_erc20.outputs.block }} + ttm: ${{ needs.load_test_multiple_erc20.outputs.ttm }} + gas_avg: ${{ needs.load_test_multiple_erc20.outputs.gas_avg }} + gas_max: ${{ needs.load_test_multiple_erc20.outputs.gas_max }} + secrets: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} diff --git a/.github/workflows/notification-deploy-network.yml b/.github/workflows/notification-deploy-network.yml new file mode 100644 index 0000000000..6ddcb1eb1e --- /dev/null +++ b/.github/workflows/notification-deploy-network.yml @@ -0,0 +1,97 @@ +--- +name: Notification - Deploy Network +on: # yamllint disable-line rule:truthy + workflow_call: + inputs: + environment: + description: The environment to run against + type: string + required: true + deploy_network_terraform_output: + description: "Deploy Network - Terraform output" + type: string + required: true + deploy_network_ansible_output: + description: "Deploy Network - Ansible output" + type: string + required: true + rpc_url: + description: "JSON-RPC URL" + type: string + required: true + secrets: + SLACK_WEBHOOK_URL: + required: true + +jobs: + notification: + name: Notification + runs-on: ubuntu-latest + steps: + - name: Notify Slack + uses: slackapi/slack-github-action@v1.24.0 + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK + green_color: '#03C03C' + red_color: '#E60012' + succeed_bnt: 'primary' + failed_bnt: 'danger' + with: + payload: | + { + "attachments": [ + { + "color": "${{ inputs.deploy_network_terraform_output == '' && inputs.deploy_network_ansible_output == '' && env.green_color || env.red_color }}", + "blocks": [ + { + "type": "header", + "text": { + "type": "plain_text", + "text": "Deploy ${{ inputs.environment }} network" + } + }, + { + "type": "context", + "elements": [ + { + "type": "mrkdwn", + "text": "Environment: *${{ inputs.environment }}*" + } + ] + }, + { + "type": "context", + "elements": [ + { + "type": "mrkdwn", + "text": "Triggered by: *${{ github.triggering_actor }}*" + } + ] + }, + { + "type": "actions", + "elements": [ + { + "type": "button", + "text": { + "type": "plain_text", + "text": "Workflow Run" + }, + "style": "${{ inputs.deploy_network_terraform_output == '' && inputs.deploy_network_ansible_output == '' && env.succeed_bnt || env.failed_bnt }}", + "url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" + }, + { + "type": "button", + "text": { + "type": "plain_text", + "text": "JSON-RPC" + }, + "url": "${{ inputs.rpc_url }}" + } + ] + } + ] + } + ] + } diff --git a/.github/workflows/notification-destroy-network.yml b/.github/workflows/notification-destroy-network.yml new file mode 100644 index 0000000000..2c80c03e77 --- /dev/null +++ b/.github/workflows/notification-destroy-network.yml @@ -0,0 +1,97 @@ +--- +name: Notification - Destroy Network +on: # yamllint disable-line rule:truthy + workflow_call: + inputs: + environment: + description: The environment to run against + type: string + required: true + destroy_network_upload_logs: + description: "Destory Network - Upload Logs" + type: string + required: true + destroy_network_terraform_logs: + description: "Deploy Network - Terraform output" + type: string + required: true + secrets: + AWS_S3_BLADE_BUCKET: + required: true + SLACK_WEBHOOK_URL: + required: true + +jobs: + notification: + name: Notification + runs-on: ubuntu-latest + steps: + - name: Notify Slack + uses: slackapi/slack-github-action@v1.24.0 + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK + green_color: '#03C03C' + red_color: '#E60012' + succeed_bnt: 'primary' + failed_bnt: 'danger' + with: + payload: | + { + "attachments": [ + { + "color": "${{ inputs.destroy_network_upload_logs == '' && inputs.destroy_network_terraform_logs == '' && env.green_color || env.red_color }}", + "blocks": [ + { + "type": "header", + "text": { + "type": "plain_text", + "text": "Destroy ${{ inputs.environment }}" + } + }, + { + "type": "context", + "elements": [ + { + "type": "mrkdwn", + "text": "Environment: *${{ inputs.environment }}*" + } + ] + }, + { + "type": "context", + "elements": [ + { + "type": "mrkdwn", + "text": "Triggered by: *${{ github.triggering_actor }}*" + } + ] + }, + { + "type": "actions", + "elements": [ + { + "type": "button", + "text": { + "type": "plain_text", + "text": "Workflow Run" + }, + "style": "${{ inputs.destroy_network_upload_logs == '' && inputs.destroy_network_terraform_logs == '' && env.succeed_bnt || env.failed_bnt }}", + "url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" + } + {%- if inputs.logs == true %} + ,{ + "type": "button", + "text": { + "type": "plain_text", + "text": "Logs" + }, + "url": "https://s3.console.aws.amazon.com/s3/buckets/${{ secrets.AWS_S3_BLADE_BUCKET }}?region=${{ vars.AWS_REGION }}&prefix=logs/${{ github.run_id }}/" + } + {%- endif %} + ] + } + ] + } + ] + } diff --git a/.github/workflows/notification-load-test.yml b/.github/workflows/notification-load-test.yml new file mode 100644 index 0000000000..b91a8415b9 --- /dev/null +++ b/.github/workflows/notification-load-test.yml @@ -0,0 +1,145 @@ +--- +name: Notification - Load Test +on: # yamllint disable-line rule:truthy + workflow_call: + inputs: + environment: + description: The environment to run against + type: string + required: true + scenario: + description: The scenario to run + type: string + required: true + tps_avg: + description: "Average Transactions Per Second" + type: string + required: true + tps_max: + description: "Maximum Transactions Per Second" + type: string + required: true + iterations: + description: "Number Of Transactions" + type: string + required: true + block: + description: "Block Number" + type: string + required: true + ttm: + description: "Time To Mine" + type: string + required: true + gas_avg: + description: "Average Gas Used" + type: string + required: true + gas_max: + description: "Maximum Gas Used" + type: string + required: true + secrets: + SLACK_WEBHOOK_URL: + required: true + +jobs: + notification: + name: Notification + runs-on: ubuntu-latest + steps: + - name: Notify Slack + uses: slackapi/slack-github-action@v1.24.0 + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK + green_color: '#03C03C' + succeed_bnt: 'primary' + with: + payload: | + { + "attachments": [ + { + "color": ${{ env.green_color }}, + "blocks": [ + { + "type": "header", + "text": { + "type": "plain_text", + "text": "K6 Load Test: ${{ inputs.scenario }}" + } + }, + { + "type": "context", + "elements": [ + { + "type": "mrkdwn", + "text": "Environment: *${{ inputs.environment }}*" + } + ] + }, + { + "type": "context", + "elements": [ + { + "type": "mrkdwn", + "text": "Triggered by: *${{ github.triggering_actor }}*" + } + ] + }, + { + "type": "actions", + "elements": [ + { + "type": "button", + "text": { + "type": "plain_text", + "text": "Workflow Run" + }, + "style": ${{ env.succeed_bnt }}, + "url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" + } + ] + } + ] + }, + { + "color": ${{ env.green_color }}, + "blocks": [ + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Average TPS*\n${{ inputs.tps_avg }}" + }, + { + "type": "mrkdwn", + "text": "*Max TPS*\n${{ inputs.tps_max }}" + }, + { + "type": "mrkdwn", + "text": "*Average Gas Used*\n${{ inputs.gas_avg }}" + }, + { + "type": "mrkdwn", + "text": "*Max Gas Used*\n${{ inputs.gas_max }}" + }, + { + "type": "mrkdwn", + "text": "*Transactions*\n${{ inputs.iterations }}" + }, + { + "type": "mrkdwn", + "text": "*Block Number*\n${{ inputs.block }}" + }, + { + "type": "mrkdwn", + "text": "*Time to Mine*\n${{ inputs.ttm }}" + } + ] + } + ] + } + ] + } diff --git a/.github/workflows/notification-main.yml b/.github/workflows/notification-main.yml new file mode 100644 index 0000000000..acd619d9a1 --- /dev/null +++ b/.github/workflows/notification-main.yml @@ -0,0 +1,195 @@ +--- +name: Notification - Main +on: # yamllint disable-line rule:truthy + workflow_call: + inputs: + environment: + description: The environment to run against + type: string + required: true + build_output: + description: Build output + type: string + required: true + unit_test_output: + description: Unit Tests output + type: string + required: true + e2e_polybft_test_output: + description: E2E PolyBFT Tests output + type: string + required: true + e2e_legacy_test_output: + description: E2E Legacy Tests output + type: string + required: true + property_polybft_test_output: + description: Property PolyBFT Tests output + type: string + required: true + fuzz_test_output: + description: Fuzz Tests output + type: string + required: true + deploy_network_terraform_output: + description: Deploy Network - Terraform output + type: string + required: true + deploy_network_ansible_output: + description: Deploy Network - Ansible output + type: string + required: true + load_test_multiple_eoa_output: + description: Load Test multiple_EOA output + type: string + required: true + load_test_multiple_erc20_output: + description: Load Test multiple_ERC20 output + type: string + required: true + destroy_network_logs_output: + description: Deploy Network - Logs output + type: string + required: true + destroy_network_terraform_output: + description: Destroy Network - Terraform output + type: string + required: true + secrets: + AWS_S3_BLADE_BUCKET: + required: true + SLACK_WEBHOOK_URL: + required: true + +jobs: + notification: + name: Notification + runs-on: ubuntu-latest + steps: + - name: Notify Slack + uses: slackapi/slack-github-action@v1.24.0 + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK + green_color: '#03C03C' + red_color: '#E60012' + succeed_bnt: 'primary' + failed_bnt: 'danger' + with: + payload: | + { + "attachments": [ + { + "color": "${{ inputs.build_output == '' && inputs.unit_test_output == '' && inputs.e2e_polybft_test_output == '' && inputs.e2e_legacy_test_output == '' && inputs.property_polybft_test_output == '' && inputs.fuzz_test_output == '' && inputs.deploy_network_terraform_output == '' && inputs.deploy_network_ansible_output == '' && inputs.load_test_multiple_eoa_output == 'true' && inputs.load_test_multiple_erc20_output == 'true' && inputs.destroy_network_logs_output == '' && inputs.destroy_network_terraform_output == '' && env.green_color || env.red_color }}", + "blocks": [ + { + "type": "header", + "text": { + "type": "plain_text", + "text": "Build: ${{ inputs.environment }}" + } + }, + { + "type": "context", + "elements": [ + { + "type": "mrkdwn", + "text": "Environment: *${{ inputs.environment }}*" + } + ] + }, + { + "type": "context", + "elements": [ + { + "type": "mrkdwn", + "text": "Triggered by: *${{ github.triggering_actor }}*" + } + ] + }, + { + "type": "actions", + "elements": [ + { + "type": "button", + "text": { + "type": "plain_text", + "text": "Workflow Run" + }, + "style": "${{ inputs.build_output == '' && inputs.unit_test_output == '' && inputs.e2e_polybft_test_output == '' && inputs.e2e_legacy_test_output == '' && inputs.property_polybft_test_output == '' && inputs.fuzz_test_output == '' && inputs.deploy_network_terraform_output == '' && inputs.deploy_network_ansible_output == '' && inputs.load_test_multiple_eoa_output == 'true' && inputs.load_test_multiple_erc20_output == 'true' && inputs.destroy_network_logs_output == '' && inputs.destroy_network_terraform_output == '' && env.succeed_bnt || env.failed_bnt }}", + "url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" + }, + { + "type": "button", + "text": { + "type": "plain_text", + "text": "Logs" + }, + "url": "https://s3.console.aws.amazon.com/s3/buckets/${{ secrets.AWS_S3_BLADE_BUCKET }}?region=${{ vars.AWS_REGION }}&prefix=logs/${{ github.run_id }}/" + } + ] + } + ] + }, + { + "color": "${{ inputs.build_output == '' && env.green_color || env.red_color }}", + "blocks": [ + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "*Build Blade*" + } + } + ] + }, + { + "color": "${{ inputs.unit_test_output == '' && inputs.fuzz_test_output == '' && inputs.e2e_legacy_test_output == '' && inputs.e2e_polybft_test_output && inputs.property_polybft_test_output == '' && env.green_color || env.red_color }}", + "blocks": [ + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "*Tests*\n${{ inputs.unit_test_output == '' && 'Unit' || '~Unit~' }}, ${{ inputs.fuzz_test_output == '' && 'Fuzz' || '~Fuzz~' }},\n${{ inputs.e2e_legacy_test_output == '' && 'E2E Legacy' || '~E2E Legacy~' }}, ${{ inputs.e2e_polybft_test_output == '' && 'E2E PolyBFT' || '~E2E PolyBFT~' }},\n${{ inputs.property_polybft_test_output == '' && 'Property PolyBFT' || '~Property PolyBFT~' }}" + } + } + ] + }, + { + "color": "${{ inputs.deploy_network_terraform_output == '' && inputs.deploy_network_ansible_output == '' && env.green_color || env.red_color }}", + "blocks": [ + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "*Deploy Network*" + } + } + ] + }, + { + "color": "${{ inputs.load_test_multiple_eoa_output == 'true' && inputs.load_test_multiple_erc20_output == 'true' && env.green_color || env.red_color }}", + "blocks": [ + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "*Load Tests*\n${{ inputs.load_test_multiple_eoa_output == 'true' && 'EOA' || '~EOA~' }},\n${{ inputs.load_test_multiple_erc20_output == 'true' && 'ERC20' || '~ERC20~' }}" + } + } + ] + }, + { + "color": "${{ inputs.destroy_network_logs_output == '' && inputs.destroy_network_terraform_output == '' && env.green_color || env.red_color }}", + "blocks": [ + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "*Destroy Network*" + } + } + ] + } + ] + } diff --git a/.github/workflows/property-polybft-test.yml b/.github/workflows/property-polybft-test.yml index 0c427bba84..f7c0d2e8ac 100644 --- a/.github/workflows/property-polybft-test.yml +++ b/.github/workflows/property-polybft-test.yml @@ -1,20 +1,21 @@ --- -name: PolyBFT Property Tests -on: # yamllint disable-line rule:truthy +name: Property PolyBFT Tests +on: # yamllint disable-line rule:truthy # push: # branches: # - main # - develop workflow_dispatch: workflow_call: + # Map the workflow outputs to job outputs outputs: workflow_output: - description: "PolyBFT Property Tests output" + description: "Property PolyBFT Tests output" value: ${{ jobs.polybft_property.outputs.property_output_failure }} jobs: polybft_property: - name: Run + name: Run Property PolyBFT Tests runs-on: ubuntu-latest env: E2E_TESTS: true @@ -24,7 +25,7 @@ jobs: property_output_failure: ${{ steps.run_property_failure.outputs.test_output }} steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Install Go uses: actions/setup-go@v3 with: @@ -37,7 +38,7 @@ jobs: run: echo "test_output=false" >> $GITHUB_OUTPUT - name: Archive test logs if: always() - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: e2e-logs path: e2e-logs-*/ diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index f302fdb98a..177214c9a6 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,6 +1,6 @@ --- name: Tests -on: #yamllint disable-line rule:truthy +on: # yamllint disable-line rule:truthy workflow_dispatch: inputs: unit-test: @@ -8,15 +8,15 @@ on: #yamllint disable-line rule:truthy type: boolean default: true e2e-polybft-test: - description: PolyBFT E2E Tests + description: E2E PolyBFT Tests type: boolean default: true e2e-legacy-test: - description: Legacy E2E Tests + description: E2E Legacy Tests type: boolean default: true property-polybft-test: - description: Polybft Property Tests + description: Property PolyBFT Tests type: boolean default: true fuzz-test: @@ -30,40 +30,56 @@ on: #yamllint disable-line rule:truthy type: boolean required: true e2e-polybft-test: - description: PolyBFT E2E Tests + description: E2E PolyBFT Tests type: boolean required: true e2e-legacy-test: - description: Legacy E2E Tests + description: E2E Legacy Tests type: boolean required: true property-polybft-test: - description: Polybft Property Tests + description: Property PolyBFT Tests type: boolean required: true fuzz-test: description: Fuzz Tests type: boolean required: true + outputs: + unit-test: + description: Unit Tests output + value: ${{ jobs.unit-test.outputs.workflow_output }} + e2e-polybft-test: + description: E2E PolyBFT Tests output + value: ${{ jobs.e2e-polybft-test.outputs.workflow_output }} + e2e-legacy-test: + description: E2E Legacy Tests output + value: ${{ jobs.e2e-legacy-test.outputs.workflow_output }} + property-polybft-test: + description: Property PolyBFT Tests output + value: ${{ jobs.property-polybft-test.outputs.workflow_output }} + fuzz-test: + description: Fuzz Tests output + value: ${{ jobs.fuzz-test.outputs.workflow_output }} jobs: unit-test: name: Unit Tests - if: ${{ inputs.unit-test == true }} uses: ./.github/workflows/unit-test.yml + if: ${{ inputs.unit-test == true }} e2e-polybft-test: - name: PolyBFT E2E Tests - if: ${{ inputs.e2e-polybft-test == true }} + name: E2E PolyBFT Tests uses: ./.github/workflows/e2e-polybft-test.yml + if: ${{ inputs.e2e-polybft-test == true }} e2e-legacy-test: - name: Legacy E2E Tests - if: ${{ inputs.e2e-legacy-test == true }} + name: E2E Legacy Tests uses: ./.github/workflows/e2e-legacy-test.yml + if: ${{ inputs.e2e-legacy-test == true }} property-polybft-test: - name: Polybft Property Tests - if: ${{ inputs.property-polybft-test == true }} + name: Property PolyBFT Tests uses: ./.github/workflows/property-polybft-test.yml + if: ${{ inputs.property-polybft-test == true }} fuzz-test: name: Fuzz Tests - if: ${{ inputs.fuzz-test == true }} uses: ./.github/workflows/fuzz-test.yml + if: ${{ inputs.fuzz-test == true }} diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index 3ff1d08eb1..71b8a6324c 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -1,8 +1,9 @@ --- name: Unit Tests -on: # yamllint disable-line rule:truthy +on: # yamllint disable-line rule:truthy workflow_dispatch: workflow_call: + # Map the workflow outputs to job outputs outputs: workflow_output: description: "Unit Tests output" @@ -10,7 +11,7 @@ on: # yamllint disable-line rule:truthy jobs: unit_test: - name: Run + name: Run Unit Tests runs-on: ubuntu-latest outputs: test_output_failure: ${{ steps.run_tests_failure.outputs.test_output }} @@ -20,7 +21,7 @@ jobs: with: go-version: 1.20.x - name: Checkout Code - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: submodules: recursive fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis diff --git a/e2e/README.md b/e2e/README.md index 1bb1eb5e9c..c67963d8e8 100644 --- a/e2e/README.md +++ b/e2e/README.md @@ -4,7 +4,7 @@ The implemented E2E tests start a local instance of polygon-edge. ## Step 1: Run the tests -Use the make file to launch the tests `make test-e2e` +Use the make file to launch the tests `make test-e2e-legacy` ## Manual checks if things are acting funny diff --git a/loadtest/scenarios/multiple_EOA.js b/loadtest/scenarios/multiple_EOA.js index aa5871adb3..38338d8261 100644 --- a/loadtest/scenarios/multiple_EOA.js +++ b/loadtest/scenarios/multiple_EOA.js @@ -3,21 +3,46 @@ import exec from 'k6/execution'; import { fundTestAccounts } from '../helpers/init.js'; import { textSummary } from 'https://jslib.k6.io/k6-summary/0.0.2/index.js'; -let duration = __ENV.LOADTEST_DURATION; +let setupTimeOut = __ENV.SETUP_TIMEOUT; +if (setupTimeOut == undefined) { + setupTimeOut = "220s" +} + +let rate = __ENV.RATE; +if (rate == undefined) { + rate = "3000" +} + +let timeUnit = __ENV.TIME_UNIT; +if (timeUnit == undefined) { + timeUnit = "1s" +} + +let duration = __ENV.DURATION; if (duration == undefined) { duration = "2m"; } +let preAllocatedVUs = __ENV.PREALLOCATED_VUS; +if (preAllocatedVUs == undefined) { + preAllocatedVUs = "60"; +} + +let maxVUs = __ENV.MAX_VUS; +if (maxVUs == undefined) { + maxVUs = "60"; +} + export const options = { - setupTimeout: '220s', + setupTimeout: setupTimeOut, scenarios: { constant_request_rate: { executor: 'constant-arrival-rate', - rate: 3000, - timeUnit: '1s', + rate: parseInt(rate), + timeUnit: timeUnit, duration: duration, - preAllocatedVUs: 60, - maxVUs: 60, + preAllocatedVUs: parseInt(preAllocatedVUs), + maxVUs: parseInt(maxVUs), }, }, }; diff --git a/loadtest/scenarios/multiple_ERC20.js b/loadtest/scenarios/multiple_ERC20.js index 3b291d2ac3..109ae3fbec 100644 --- a/loadtest/scenarios/multiple_ERC20.js +++ b/loadtest/scenarios/multiple_ERC20.js @@ -3,11 +3,36 @@ import exec from 'k6/execution'; import { fundTestAccounts } from '../helpers/init.js'; import { textSummary } from 'https://jslib.k6.io/k6-summary/0.0.2/index.js'; -let duration = __ENV.LOADTEST_DURATION; +let setupTimeOut = __ENV.SETUP_TIMEOUT; +if (setupTimeOut == undefined) { + setupTimeOut = "220s" +} + +let rate = __ENV.RATE; +if (rate == undefined) { + rate = "1500" +} + +let timeUnit = __ENV.TIME_UNIT; +if (timeUnit == undefined) { + timeUnit = "1s" +} + +let duration = __ENV.DURATION; if (duration == undefined) { duration = "2m"; } +let preAllocatedVUs = __ENV.PREALLOCATED_VUS; +if (preAllocatedVUs == undefined) { + preAllocatedVUs = "60"; +} + +let maxVUs = __ENV.MAX_VUS; +if (maxVUs == undefined) { + maxVUs = "60"; +} + export const options = { setupTimeout: '220s', scenarios: { From f0f44a4a0458c315c8f55a7fe5fb662cd31485f4 Mon Sep 17 00:00:00 2001 From: Branislav Kojic Date: Thu, 25 Jan 2024 13:42:32 +0100 Subject: [PATCH 15/67] Minor changes (#16) * Deploy Network * Add Permissions * Minor changes * Concurrency change * Destroy Network * Minor changes * Minor changes * Fix commit sha * Minor changes * Add Tests * Disable Tests temporarily * Nightly Build * Minor fixes * Big changes * Minor changes --- .github/workflows/destroy-network.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/destroy-network.yml b/.github/workflows/destroy-network.yml index 897c69cb7e..ca8e3da9c9 100644 --- a/.github/workflows/destroy-network.yml +++ b/.github/workflows/destroy-network.yml @@ -134,7 +134,7 @@ jobs: name: Network Notifications uses: ./.github/workflows/notification-destroy-network.yml needs: [upload_logs, destroy_network] - if: always() && ${{ github.event_name == 'workflow_dispatch' }} + if: ${{ github.event_name == 'workflow_dispatch' }} with: environment: ${{ inputs.environment }} destroy_network_upload_logs: ${{ needs.upload_logs.outputs.logs_output }} From 96488457da5cdf80f19d4873f07c47f0aececa75 Mon Sep 17 00:00:00 2001 From: Branislav Kojic Date: Thu, 25 Jan 2024 14:29:42 +0100 Subject: [PATCH 16/67] Minor changes (#17) * Deploy Network * Add Permissions * Minor changes * Concurrency change * Destroy Network * Minor changes * Minor changes * Fix commit sha * Minor changes * Add Tests * Disable Tests temporarily * Nightly Build * Minor fixes * Big changes * Minor changes * Minor changes --- .github/workflows/build.yml | 6 +++--- .github/workflows/deploy-network.yml | 2 +- .github/workflows/destroy-network.yml | 6 +++--- .github/workflows/e2e-legacy-test.yml | 4 ++-- .github/workflows/e2e-polybft-test.yml | 4 ++-- .github/workflows/fuzz-test.yml | 2 +- .github/workflows/load-test.yml | 2 +- .github/workflows/nightly.yml | 2 +- .github/workflows/notification-deploy-network.yml | 2 +- .github/workflows/notification-destroy-network.yml | 2 +- .github/workflows/notification-load-test.yml | 2 +- .github/workflows/notification-main.yml | 2 +- .github/workflows/property-polybft-test.yml | 4 ++-- .github/workflows/unit-test.yml | 2 +- 14 files changed, 21 insertions(+), 21 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c6491d96c9..959bb24d3a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,7 +17,7 @@ jobs: build_output_failure: ${{ steps.blade_build_failure.outputs.build_output }} steps: - name: Checkout code - uses: actions/checkout@v4 + uses: actions/checkout@v3 - name: Setup Go environment uses: actions/setup-go@v3 with: @@ -32,7 +32,7 @@ jobs: id: blade_build_failure run: echo "build_output=false" >> $GITHUB_OUTPUT - name: "Upload Artifact" - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v3 with: name: blade path: blade.tar.gz @@ -43,7 +43,7 @@ jobs: continue-on-error: true steps: - name: Checkout code - uses: actions/checkout@v4 + uses: actions/checkout@v3 - name: Setup Go environment uses: actions/setup-go@v3 with: diff --git a/.github/workflows/deploy-network.yml b/.github/workflows/deploy-network.yml index 51aed876c0..6e5b814ba3 100644 --- a/.github/workflows/deploy-network.yml +++ b/.github/workflows/deploy-network.yml @@ -73,7 +73,7 @@ jobs: rpc_url: ${{ steps.rpc_url.outputs.url }} steps: - name: Checkout code - uses: actions/checkout@v4 + uses: actions/checkout@v3 with: repository: Ethernal-Tech/blade-deployment ref: changes diff --git a/.github/workflows/destroy-network.yml b/.github/workflows/destroy-network.yml index ca8e3da9c9..6d7aa22d8c 100644 --- a/.github/workflows/destroy-network.yml +++ b/.github/workflows/destroy-network.yml @@ -52,7 +52,7 @@ jobs: logs_output: ${{ steps.logs_failure.outputs.logs_output }} steps: - name: Checkout code - uses: actions/checkout@v4 + uses: actions/checkout@v3 with: repository: Ethernal-Tech/blade-deployment ref: changes @@ -104,7 +104,7 @@ jobs: terraform_output: ${{ steps.terraform_failure.outputs.terraform_output }} steps: - name: Checkout code - uses: actions/checkout@v4 + uses: actions/checkout@v3 with: repository: Ethernal-Tech/blade-deployment ref: changes @@ -134,7 +134,7 @@ jobs: name: Network Notifications uses: ./.github/workflows/notification-destroy-network.yml needs: [upload_logs, destroy_network] - if: ${{ github.event_name == 'workflow_dispatch' }} + if: github.event_name == 'workflow_dispatch' with: environment: ${{ inputs.environment }} destroy_network_upload_logs: ${{ needs.upload_logs.outputs.logs_output }} diff --git a/.github/workflows/e2e-legacy-test.yml b/.github/workflows/e2e-legacy-test.yml index db85ef7f35..4b129f9368 100644 --- a/.github/workflows/e2e-legacy-test.yml +++ b/.github/workflows/e2e-legacy-test.yml @@ -26,7 +26,7 @@ jobs: e2e_legacy_output_failure: ${{ steps.run_e2e_legacy_failure.outputs.test_output }} steps: - name: Checkout code - uses: actions/checkout@v4 + uses: actions/checkout@v3 with: submodules: recursive - name: Install Go @@ -41,7 +41,7 @@ jobs: run: echo "test_output=false" >> $GITHUB_OUTPUT - name: Archive test logs if: always() - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v3 with: name: e2e-logs path: e2e-logs-*/ diff --git a/.github/workflows/e2e-polybft-test.yml b/.github/workflows/e2e-polybft-test.yml index 1cc8f376ac..dff16df83a 100644 --- a/.github/workflows/e2e-polybft-test.yml +++ b/.github/workflows/e2e-polybft-test.yml @@ -26,7 +26,7 @@ jobs: e2e_polybft_output_failure: ${{ steps.run_e2e_polybft_failure.outputs.test_output }} steps: - name: Checkout code - uses: actions/checkout@v4 + uses: actions/checkout@v3 - name: Install Go uses: actions/setup-go@v4 with: @@ -41,7 +41,7 @@ jobs: run: echo "test_output=false" >> $GITHUB_OUTPUT - name: Archive test logs if: always() - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v3 with: name: e2e-logs path: e2e-logs-*/ diff --git a/.github/workflows/fuzz-test.yml b/.github/workflows/fuzz-test.yml index 851d77c1f6..73a03c786a 100644 --- a/.github/workflows/fuzz-test.yml +++ b/.github/workflows/fuzz-test.yml @@ -25,7 +25,7 @@ jobs: with: go-version: 1.20.x - name: Checkout Code - uses: actions/checkout@v4 + uses: actions/checkout@v3 - name: Run Fuzz Test run: make fuzz-test - name: Run fuzz tests failed diff --git a/.github/workflows/load-test.yml b/.github/workflows/load-test.yml index b90c4fa40c..cb01b93db2 100644 --- a/.github/workflows/load-test.yml +++ b/.github/workflows/load-test.yml @@ -158,7 +158,7 @@ jobs: gas_max: ${{ steps.load_test_results.outputs.gas_max }} steps: - name: Checkout code - uses: actions/checkout@v4 + uses: actions/checkout@v3 - name: Configure AWS credentials uses: aws-actions/configure-aws-credentials@v2 with: diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 4babea61ee..610e1733b0 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -14,7 +14,7 @@ jobs: new_commit_count: ${{ steps.get_new_commits.outputs.commit_count }} steps: - name: Checkout Code - uses: actions/checkout@v4 + uses: actions/checkout@v3 - name: Get new commits id: get_new_commits run: echo "commit_count=$(git log --oneline --since '24 hours ago' | wc -l | tr -d ' ')" >> $GITHUB_OUTPUT diff --git a/.github/workflows/notification-deploy-network.yml b/.github/workflows/notification-deploy-network.yml index 6ddcb1eb1e..0cc4ad1bc9 100644 --- a/.github/workflows/notification-deploy-network.yml +++ b/.github/workflows/notification-deploy-network.yml @@ -29,7 +29,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Notify Slack - uses: slackapi/slack-github-action@v1.24.0 + uses: slackapi/slack-github-action@v1.23.0 env: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK diff --git a/.github/workflows/notification-destroy-network.yml b/.github/workflows/notification-destroy-network.yml index 2c80c03e77..31a4d5e2ca 100644 --- a/.github/workflows/notification-destroy-network.yml +++ b/.github/workflows/notification-destroy-network.yml @@ -27,7 +27,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Notify Slack - uses: slackapi/slack-github-action@v1.24.0 + uses: slackapi/slack-github-action@v1.23.0 env: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK diff --git a/.github/workflows/notification-load-test.yml b/.github/workflows/notification-load-test.yml index b91a8415b9..cae309ecab 100644 --- a/.github/workflows/notification-load-test.yml +++ b/.github/workflows/notification-load-test.yml @@ -49,7 +49,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Notify Slack - uses: slackapi/slack-github-action@v1.24.0 + uses: slackapi/slack-github-action@v1.23.0 env: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK diff --git a/.github/workflows/notification-main.yml b/.github/workflows/notification-main.yml index acd619d9a1..27dcd3ac1a 100644 --- a/.github/workflows/notification-main.yml +++ b/.github/workflows/notification-main.yml @@ -67,7 +67,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Notify Slack - uses: slackapi/slack-github-action@v1.24.0 + uses: slackapi/slack-github-action@v1.23.0 env: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK diff --git a/.github/workflows/property-polybft-test.yml b/.github/workflows/property-polybft-test.yml index f7c0d2e8ac..614a16f76d 100644 --- a/.github/workflows/property-polybft-test.yml +++ b/.github/workflows/property-polybft-test.yml @@ -25,7 +25,7 @@ jobs: property_output_failure: ${{ steps.run_property_failure.outputs.test_output }} steps: - name: Checkout code - uses: actions/checkout@v4 + uses: actions/checkout@v3 - name: Install Go uses: actions/setup-go@v3 with: @@ -38,7 +38,7 @@ jobs: run: echo "test_output=false" >> $GITHUB_OUTPUT - name: Archive test logs if: always() - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v3 with: name: e2e-logs path: e2e-logs-*/ diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index 71b8a6324c..2fc3dc0fa1 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -21,7 +21,7 @@ jobs: with: go-version: 1.20.x - name: Checkout Code - uses: actions/checkout@v4 + uses: actions/checkout@v3 with: submodules: recursive fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis From 726f0ba65b625f70103eb1432b5e572cd8bda04e Mon Sep 17 00:00:00 2001 From: Branislav Kojic Date: Thu, 25 Jan 2024 14:33:17 +0100 Subject: [PATCH 17/67] Minor changes (#18) * Deploy Network * Add Permissions * Minor changes * Concurrency change * Destroy Network * Minor changes * Minor changes * Fix commit sha * Minor changes * Add Tests * Disable Tests temporarily * Nightly Build * Minor fixes * Big changes * Minor changes * Minor changes * Minor changes --- .github/workflows/destroy-network.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/destroy-network.yml b/.github/workflows/destroy-network.yml index 6d7aa22d8c..2cdde4dfdc 100644 --- a/.github/workflows/destroy-network.yml +++ b/.github/workflows/destroy-network.yml @@ -95,7 +95,7 @@ jobs: id: logs_failure run: echo "logs_output=false" >> $GITHUB_OUTPUT destroy_network: - name: Destroy ${{ inputs.environment }} Network + name: Destroy ${{ inputs.environment }} runs-on: ubuntu-latest environment: ${{ inputs.environment }} needs: upload_logs @@ -134,7 +134,7 @@ jobs: name: Network Notifications uses: ./.github/workflows/notification-destroy-network.yml needs: [upload_logs, destroy_network] - if: github.event_name == 'workflow_dispatch' + if: always() && github.event_name == 'workflow_dispatch' with: environment: ${{ inputs.environment }} destroy_network_upload_logs: ${{ needs.upload_logs.outputs.logs_output }} From b1fac170a8cd83dcb77f3d77517c739641a34231 Mon Sep 17 00:00:00 2001 From: Branislav Kojic Date: Thu, 25 Jan 2024 14:43:51 +0100 Subject: [PATCH 18/67] Notification fixes (#19) * Deploy Network * Add Permissions * Minor changes * Concurrency change * Destroy Network * Minor changes * Minor changes * Fix commit sha * Minor changes * Add Tests * Disable Tests temporarily * Nightly Build * Minor fixes * Big changes * Minor changes * Minor changes * Minor changes * Notification fixes --- .../notification-destroy-network.yml | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/notification-destroy-network.yml b/.github/workflows/notification-destroy-network.yml index 31a4d5e2ca..1b3ae108cc 100644 --- a/.github/workflows/notification-destroy-network.yml +++ b/.github/workflows/notification-destroy-network.yml @@ -35,6 +35,7 @@ jobs: red_color: '#E60012' succeed_bnt: 'primary' failed_bnt: 'danger' + url: https://s3.console.aws.amazon.com/s3/buckets/${{ secrets.AWS_S3_BLADE_BUCKET }}?region=${{ vars.AWS_REGION }}&prefix=logs/${{ github.run_id }}/ with: payload: | { @@ -78,17 +79,16 @@ jobs: }, "style": "${{ inputs.destroy_network_upload_logs == '' && inputs.destroy_network_terraform_logs == '' && env.succeed_bnt || env.failed_bnt }}", "url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" + }, + { + "type": "button", + "text": { + "type": "plain_text", + "text": "Logs" + }, + "style": "${{ inputs.destroy_network_upload_logs && env.succeed_bnt || env.failed_bnt }}", + "url": "${{ inputs.destroy_network_upload_logs && env.url || '' }}" } - {%- if inputs.logs == true %} - ,{ - "type": "button", - "text": { - "type": "plain_text", - "text": "Logs" - }, - "url": "https://s3.console.aws.amazon.com/s3/buckets/${{ secrets.AWS_S3_BLADE_BUCKET }}?region=${{ vars.AWS_REGION }}&prefix=logs/${{ github.run_id }}/" - } - {%- endif %} ] } ] From 1b90010e984dd9b714e17480f6fce428888b5b7b Mon Sep 17 00:00:00 2001 From: Branislav Kojic Date: Thu, 25 Jan 2024 14:51:32 +0100 Subject: [PATCH 19/67] Notification changes (#20) * Deploy Network * Add Permissions * Minor changes * Concurrency change * Destroy Network * Minor changes * Minor changes * Fix commit sha * Minor changes * Add Tests * Disable Tests temporarily * Nightly Build * Minor fixes * Big changes * Minor changes * Minor changes * Minor changes * Notification fixes * Notification changes --- .github/workflows/notification-destroy-network.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/notification-destroy-network.yml b/.github/workflows/notification-destroy-network.yml index 1b3ae108cc..9864338dcc 100644 --- a/.github/workflows/notification-destroy-network.yml +++ b/.github/workflows/notification-destroy-network.yml @@ -87,7 +87,7 @@ jobs: "text": "Logs" }, "style": "${{ inputs.destroy_network_upload_logs && env.succeed_bnt || env.failed_bnt }}", - "url": "${{ inputs.destroy_network_upload_logs && env.url || '' }}" + "url": "https://s3.console.aws.amazon.com/s3/buckets/${{ secrets.AWS_S3_BLADE_BUCKET }}?region=${{ vars.AWS_REGION }}&prefix=logs/${{ github.run_id }}/" } ] } From f6e10167a18e2056e0b6a4c823e9117c8abac9ea Mon Sep 17 00:00:00 2001 From: Branislav Kojic Date: Thu, 25 Jan 2024 15:09:02 +0100 Subject: [PATCH 20/67] Minor changes (#21) * Deploy Network * Add Permissions * Minor changes * Concurrency change * Destroy Network * Minor changes * Minor changes * Fix commit sha * Minor changes * Add Tests * Disable Tests temporarily * Nightly Build * Minor fixes * Big changes * Minor changes * Minor changes * Minor changes * Notification fixes * Notification changes * Minor changes --- .github/workflows/deploy-network.yml | 2 +- .github/workflows/load-test.yml | 2 +- .github/workflows/nightly.yml | 8 ++++---- .github/workflows/notification-deploy-network.yml | 2 +- .github/workflows/notification-destroy-network.yml | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/deploy-network.yml b/.github/workflows/deploy-network.yml index 6e5b814ba3..3700768a70 100644 --- a/.github/workflows/deploy-network.yml +++ b/.github/workflows/deploy-network.yml @@ -139,7 +139,7 @@ jobs: name: Deploy Notification needs: deploy_network uses: ./.github/workflows/notification-deploy-network.yml - if: always() && ${{ github.event_name == 'workflow_dispatch' }} + if: always() && github.event_name == 'workflow_dispatch' with: environment: nightly deploy_network_terraform_output: ${{ needs.deploy_network.outputs.terraform_output }} diff --git a/.github/workflows/load-test.yml b/.github/workflows/load-test.yml index cb01b93db2..002f3e5b44 100644 --- a/.github/workflows/load-test.yml +++ b/.github/workflows/load-test.yml @@ -198,7 +198,7 @@ jobs: name: Load Test Notification needs: load_test_scenario uses: ./.github/workflows/notification-load-test.yml - if: success() && ${{ github.event_name == 'workflow_dispatch' }} + if: success() && github.event_name == 'workflow_dispatch' with: environment: ${{ inputs.environment }} scenario: ${{ inputs.scenario }} diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 610e1733b0..a3d2d59cda 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -126,12 +126,12 @@ jobs: AWS_S3_BLADE_BUCKET: ${{ secrets.AWS_S3_BLADE_BUCKET }} SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} notification_load_test_multiple_eoa: - name: Load Test multiple_EOA Notification + name: Load Test EOA Notification uses: ./.github/workflows/notification-load-test.yml needs: [load_test_multiple_eoa, notification_main] with: environment: nightly - scenario: multiple_EOA + scenario: EOA tps_avg: ${{ needs.load_test_multiple_eoa.outputs.tps_avg }} tps_max: ${{ needs.load_test_multiple_eoa.outputs.tps_max }} iterations: ${{ needs.load_test_multiple_eoa.outputs.iterations }} @@ -142,12 +142,12 @@ jobs: secrets: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} notification_load_test_multiple_erc20: - name: Load Test multiple_ERC20 Notification + name: Load Test ERC20 Notification uses: ./.github/workflows/notification-load-test.yml needs: [load_test_multiple_erc20, notification_main] with: environment: nightly - scenario: multiple_ERC20 + scenario: ERC20 tps_avg: ${{ needs.load_test_multiple_erc20.outputs.tps_avg }} tps_max: ${{ needs.load_test_multiple_erc20.outputs.tps_max }} iterations: ${{ needs.load_test_multiple_erc20.outputs.iterations }} diff --git a/.github/workflows/notification-deploy-network.yml b/.github/workflows/notification-deploy-network.yml index 0cc4ad1bc9..5b9f9164b8 100644 --- a/.github/workflows/notification-deploy-network.yml +++ b/.github/workflows/notification-deploy-network.yml @@ -48,7 +48,7 @@ jobs: "type": "header", "text": { "type": "plain_text", - "text": "Deploy ${{ inputs.environment }} network" + "text": "Deploy ${{ inputs.environment }}" } }, { diff --git a/.github/workflows/notification-destroy-network.yml b/.github/workflows/notification-destroy-network.yml index 9864338dcc..42c4bb7223 100644 --- a/.github/workflows/notification-destroy-network.yml +++ b/.github/workflows/notification-destroy-network.yml @@ -86,7 +86,7 @@ jobs: "type": "plain_text", "text": "Logs" }, - "style": "${{ inputs.destroy_network_upload_logs && env.succeed_bnt || env.failed_bnt }}", + "style": "${{ inputs.destroy_network_upload_logs == '' && env.succeed_bnt || env.failed_bnt }}", "url": "https://s3.console.aws.amazon.com/s3/buckets/${{ secrets.AWS_S3_BLADE_BUCKET }}?region=${{ vars.AWS_REGION }}&prefix=logs/${{ github.run_id }}/" } ] From 4002e6aeea6ed5719045f29b5ae6d847bc494060 Mon Sep 17 00:00:00 2001 From: Branislav Kojic Date: Thu, 25 Jan 2024 15:38:33 +0100 Subject: [PATCH 21/67] Permissions fixes (#22) * Deploy Network * Add Permissions * Minor changes * Concurrency change * Destroy Network * Minor changes * Minor changes * Fix commit sha * Minor changes * Add Tests * Disable Tests temporarily * Nightly Build * Minor fixes * Big changes * Minor changes * Minor changes * Minor changes * Notification fixes * Notification changes * Minor changes * Permissions fixes --- .github/workflows/load-test.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/load-test.yml b/.github/workflows/load-test.yml index 002f3e5b44..fd839825b0 100644 --- a/.github/workflows/load-test.yml +++ b/.github/workflows/load-test.yml @@ -119,6 +119,11 @@ on: # yamllint disable-line rule:truthy SLACK_WEBHOOK_URL: required: true +permissions: + id-token: write + contents: read + security-events: write + jobs: load_test_runner: name: Deploy Load Test Runner From 8c958c82c606732cec490de95c7fe51b4611f4b0 Mon Sep 17 00:00:00 2001 From: Branislav Kojic Date: Thu, 25 Jan 2024 16:49:31 +0100 Subject: [PATCH 22/67] More changes (#23) * Deploy Network * Add Permissions * Minor changes * Concurrency change * Destroy Network * Minor changes * Minor changes * Fix commit sha * Minor changes * Add Tests * Disable Tests temporarily * Nightly Build * Minor fixes * Big changes * Minor changes * Minor changes * Minor changes * Notification fixes * Notification changes * Minor changes * Permissions fixes * Minor changes * Notification changes --- .github/workflows/deploy-network.yml | 2 +- .github/workflows/notification-destroy-network.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy-network.yml b/.github/workflows/deploy-network.yml index 3700768a70..8c59fe700e 100644 --- a/.github/workflows/deploy-network.yml +++ b/.github/workflows/deploy-network.yml @@ -141,7 +141,7 @@ jobs: uses: ./.github/workflows/notification-deploy-network.yml if: always() && github.event_name == 'workflow_dispatch' with: - environment: nightly + environment: ${{ inputs.environment }} deploy_network_terraform_output: ${{ needs.deploy_network.outputs.terraform_output }} deploy_network_ansible_output: ${{ needs.deploy_network.outputs.ansible_output }} rpc_url: ${{ needs.deploy_network.outputs.rpc_url }} diff --git a/.github/workflows/notification-destroy-network.yml b/.github/workflows/notification-destroy-network.yml index 42c4bb7223..5f4319b8b9 100644 --- a/.github/workflows/notification-destroy-network.yml +++ b/.github/workflows/notification-destroy-network.yml @@ -84,7 +84,7 @@ jobs: "type": "button", "text": { "type": "plain_text", - "text": "Logs" + "text": "${{ inputs.destroy_network_upload_logs == '' && 'Logs' || 'No Logs' }}" }, "style": "${{ inputs.destroy_network_upload_logs == '' && env.succeed_bnt || env.failed_bnt }}", "url": "https://s3.console.aws.amazon.com/s3/buckets/${{ secrets.AWS_S3_BLADE_BUCKET }}?region=${{ vars.AWS_REGION }}&prefix=logs/${{ github.run_id }}/" From eb4c42c2f246a12db56ef9ba73cf0addec27d19e Mon Sep 17 00:00:00 2001 From: Branislav Kojic Date: Fri, 26 Jan 2024 03:52:52 +0100 Subject: [PATCH 23/67] Minor changes (#24) * Deploy Network * Add Permissions * Minor changes * Concurrency change * Destroy Network * Minor changes * Minor changes * Fix commit sha * Minor changes * Add Tests * Disable Tests temporarily * Nightly Build * Minor fixes * Big changes * Minor changes * Minor changes * Minor changes * Notification fixes * Notification changes * Minor changes * Permissions fixes * Minor changes * Notification changes * Minor changes --- .github/workflows/notification-main.yml | 7 +- .github/workflows/notification-tests.yml | 105 +++++++++++++++++++++++ .github/workflows/tests.yml | 13 +++ 3 files changed, 122 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/notification-tests.yml diff --git a/.github/workflows/notification-main.yml b/.github/workflows/notification-main.yml index 27dcd3ac1a..c9c1ffa6c2 100644 --- a/.github/workflows/notification-main.yml +++ b/.github/workflows/notification-main.yml @@ -123,8 +123,9 @@ jobs: "type": "button", "text": { "type": "plain_text", - "text": "Logs" + "text": "${{ inputs.destroy_network_logs_output == '' && 'Logs' || 'No Logs' }}" }, + "style": "${{ inputs.destroy_network_logs_output == '' && env.succeed_bnt || env.failed_bnt }}", "url": "https://s3.console.aws.amazon.com/s3/buckets/${{ secrets.AWS_S3_BLADE_BUCKET }}?region=${{ vars.AWS_REGION }}&prefix=logs/${{ github.run_id }}/" } ] @@ -144,7 +145,7 @@ jobs: ] }, { - "color": "${{ inputs.unit_test_output == '' && inputs.fuzz_test_output == '' && inputs.e2e_legacy_test_output == '' && inputs.e2e_polybft_test_output && inputs.property_polybft_test_output == '' && env.green_color || env.red_color }}", + "color": "${{ inputs.unit_test_output == '' && inputs.fuzz_test_output == '' && inputs.e2e_legacy_test_output == '' && inputs.e2e_polybft_test_output == '' && inputs.property_polybft_test_output == '' && env.green_color || env.red_color }}", "blocks": [ { "type": "section", @@ -180,7 +181,7 @@ jobs: ] }, { - "color": "${{ inputs.destroy_network_logs_output == '' && inputs.destroy_network_terraform_output == '' && env.green_color || env.red_color }}", + "color": "${{ inputs.destroy_network_terraform_output == '' && env.green_color || env.red_color }}", "blocks": [ { "type": "section", diff --git a/.github/workflows/notification-tests.yml b/.github/workflows/notification-tests.yml new file mode 100644 index 0000000000..d3b0b2b409 --- /dev/null +++ b/.github/workflows/notification-tests.yml @@ -0,0 +1,105 @@ +--- +name: Notification - Tests +on: # yamllint disable-line rule:truthy + workflow_call: + inputs: + unit_test_output: + description: Unit Tests output + type: string + required: true + e2e_polybft_test_output: + description: E2E PolyBFT Tests output + type: string + required: true + e2e_legacy_test_output: + description: E2E Legacy Tests output + type: string + required: true + property_polybft_test_output: + description: Property PolyBFT Tests output + type: string + required: true + fuzz_test_output: + description: Fuzz Tests output + type: string + required: true + secrets: + SLACK_WEBHOOK_URL: + required: true + +jobs: + notification: + name: Notification + runs-on: ubuntu-latest + steps: + - name: Notify Slack + uses: slackapi/slack-github-action@v1.23.0 + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK + green_color: '#03C03C' + red_color: '#E60012' + succeed_bnt: 'primary' + failed_bnt: 'danger' + with: + payload: | + { + "attachments": [ + { + "color": "${{ inputs.unit_test_output == '' && inputs.fuzz_test_output == '' && inputs.e2e_legacy_test_output == '' && inputs.e2e_polybft_test_output == '' && inputs.property_polybft_test_output == '' && env.green_color || env.red_color }}", + "blocks": [ + { + "type": "header", + "text": { + "type": "plain_text", + "text": "Tests" + } + }, + { + "type": "context", + "elements": [ + { + "type": "mrkdwn", + "text": "Commit: *${{ github.sha }}*" + } + ] + }, + { + "type": "context", + "elements": [ + { + "type": "mrkdwn", + "text": "Triggered by: *${{ github.triggering_actor }}*" + } + ] + }, + { + "type": "actions", + "elements": [ + { + "type": "button", + "text": { + "type": "plain_text", + "text": "Workflow Run" + }, + "style": "${{ inputs.unit_test_output == '' && inputs.fuzz_test_output == '' && inputs.e2e_legacy_test_output == '' && inputs.e2e_polybft_test_output == '' && inputs.property_polybft_test_output == '' && env.succeed_bnt || env.failed_bnt }}", + "url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" + }, + { + "color": "${{ inputs.unit_test_output == '' && inputs.fuzz_test_output == '' && inputs.e2e_legacy_test_output == '' && inputs.e2e_polybft_test_output == '' && inputs.property_polybft_test_output == '' && env.green_color || env.red_color }}", + "blocks": [ + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "*Tests*\n${{ inputs.unit_test_output == '' && 'Unit' || '~Unit~' }}, ${{ inputs.fuzz_test_output == '' && 'Fuzz' || '~Fuzz~' }},\n${{ inputs.e2e_legacy_test_output == '' && 'E2E Legacy' || '~E2E Legacy~' }}, ${{ inputs.e2e_polybft_test_output == '' && 'E2E PolyBFT' || '~E2E PolyBFT~' }},\n${{ inputs.property_polybft_test_output == '' && 'Property PolyBFT' || '~Property PolyBFT~' }}" + } + } + ] + } + ] + } + ] + } + ] + } diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 177214c9a6..72f207579b 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -83,3 +83,16 @@ jobs: name: Fuzz Tests uses: ./.github/workflows/fuzz-test.yml if: ${{ inputs.fuzz-test == true }} + notification: + name: Tests Notification + needs: [unit-test, e2e-polybft-test, e2e-legacy-test, property-polybft-test, fuzz-test] + uses: ./.github/workflows/notification-tests.yml + if: always() && github.event_name == 'workflow_dispatch' + with: + unit_test_output: ${{ needs.unit-test.outputs.workflow_output }} + e2e_polybft_test_output: ${{ needs.e2e-polybft-test.outputs.workflow_output }} + e2e_legacy_test_output: ${{ needs.e2e-legacy-test.outputs.workflow_output }} + property_polybft_test_output: ${{ needs.property-polybft-test.outputs.workflow_output }} + fuzz_test_output: ${{ needs.fuzz-test.outputs.workflow_output }} + secrets: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} From dfb9e30089ea34d81a8baddad1db1594c8d89c4c Mon Sep 17 00:00:00 2001 From: Branislav Kojic Date: Fri, 26 Jan 2024 04:37:17 +0100 Subject: [PATCH 24/67] Display commit on notifications (#25) * Deploy Network * Add Permissions * Minor changes * Concurrency change * Destroy Network * Minor changes * Minor changes * Fix commit sha * Minor changes * Add Tests * Disable Tests temporarily * Nightly Build * Minor fixes * Big changes * Minor changes * Minor changes * Minor changes * Notification fixes * Notification changes * Minor changes * Permissions fixes * Minor changes * Notification changes * Minor changes * Display commit on notifications --- .../workflows/notification-deploy-network.yml | 12 ++++++++ .github/workflows/notification-main.yml | 12 ++++++++ .github/workflows/notification-tests.yml | 29 ++++++++++--------- 3 files changed, 40 insertions(+), 13 deletions(-) diff --git a/.github/workflows/notification-deploy-network.yml b/.github/workflows/notification-deploy-network.yml index 5b9f9164b8..21774d46fc 100644 --- a/.github/workflows/notification-deploy-network.yml +++ b/.github/workflows/notification-deploy-network.yml @@ -28,6 +28,9 @@ jobs: name: Notification runs-on: ubuntu-latest steps: + - name: Short SHA + id: short_sha + run: echo "value=`echo ${{ github.sha }} | cut -c1-8`" >> $GITHUB_OUTPUT - name: Notify Slack uses: slackapi/slack-github-action@v1.23.0 env: @@ -60,6 +63,15 @@ jobs: } ] }, + { + "type": "context", + "elements": [ + { + "type": "mrkdwn", + "text": "Commit: **" + } + ] + }, { "type": "context", "elements": [ diff --git a/.github/workflows/notification-main.yml b/.github/workflows/notification-main.yml index c9c1ffa6c2..4ae5e05102 100644 --- a/.github/workflows/notification-main.yml +++ b/.github/workflows/notification-main.yml @@ -66,6 +66,9 @@ jobs: name: Notification runs-on: ubuntu-latest steps: + - name: Short SHA + id: short_sha + run: echo "value=`echo ${{ github.sha }} | cut -c1-8`" >> $GITHUB_OUTPUT - name: Notify Slack uses: slackapi/slack-github-action@v1.23.0 env: @@ -98,6 +101,15 @@ jobs: } ] }, + { + "type": "context", + "elements": [ + { + "type": "mrkdwn", + "text": "Commit: **" + } + ] + }, { "type": "context", "elements": [ diff --git a/.github/workflows/notification-tests.yml b/.github/workflows/notification-tests.yml index d3b0b2b409..50e3b3eca4 100644 --- a/.github/workflows/notification-tests.yml +++ b/.github/workflows/notification-tests.yml @@ -32,6 +32,9 @@ jobs: name: Notification runs-on: ubuntu-latest steps: + - name: Short SHA + id: short_sha + run: echo "value=`echo ${{ github.sha }} | cut -c1-8`" >> $GITHUB_OUTPUT - name: Notify Slack uses: slackapi/slack-github-action@v1.23.0 env: @@ -60,7 +63,7 @@ jobs: "elements": [ { "type": "mrkdwn", - "text": "Commit: *${{ github.sha }}*" + "text": "Commit: **" } ] }, @@ -84,22 +87,22 @@ jobs: }, "style": "${{ inputs.unit_test_output == '' && inputs.fuzz_test_output == '' && inputs.e2e_legacy_test_output == '' && inputs.e2e_polybft_test_output == '' && inputs.property_polybft_test_output == '' && env.succeed_bnt || env.failed_bnt }}", "url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" - }, - { - "color": "${{ inputs.unit_test_output == '' && inputs.fuzz_test_output == '' && inputs.e2e_legacy_test_output == '' && inputs.e2e_polybft_test_output == '' && inputs.property_polybft_test_output == '' && env.green_color || env.red_color }}", - "blocks": [ - { - "type": "section", - "text": { - "type": "mrkdwn", - "text": "*Tests*\n${{ inputs.unit_test_output == '' && 'Unit' || '~Unit~' }}, ${{ inputs.fuzz_test_output == '' && 'Fuzz' || '~Fuzz~' }},\n${{ inputs.e2e_legacy_test_output == '' && 'E2E Legacy' || '~E2E Legacy~' }}, ${{ inputs.e2e_polybft_test_output == '' && 'E2E PolyBFT' || '~E2E PolyBFT~' }},\n${{ inputs.property_polybft_test_output == '' && 'Property PolyBFT' || '~Property PolyBFT~' }}" - } - } - ] } ] } ] + }, + { + "color": "${{ inputs.unit_test_output == '' && inputs.fuzz_test_output == '' && inputs.e2e_legacy_test_output == '' && inputs.e2e_polybft_test_output == '' && inputs.property_polybft_test_output == '' && env.green_color || env.red_color }}", + "blocks": [ + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "*Tests*\n${{ inputs.unit_test_output == '' && 'Unit' || '~Unit~' }}, ${{ inputs.fuzz_test_output == '' && 'Fuzz' || '~Fuzz~' }},\n${{ inputs.e2e_legacy_test_output == '' && 'E2E Legacy' || '~E2E Legacy~' }}, ${{ inputs.e2e_polybft_test_output == '' && 'E2E PolyBFT' || '~E2E PolyBFT~' }},\n${{ inputs.property_polybft_test_output == '' && 'Property PolyBFT' || '~Property PolyBFT~' }}" + } + } + ] } ] } From 7357000a50da7dfc1149d0d8245b50c4d5ba806f Mon Sep 17 00:00:00 2001 From: Branislav Kojic Date: Fri, 26 Jan 2024 04:49:35 +0100 Subject: [PATCH 25/67] Minor changes (#26) * Deploy Network * Add Permissions * Minor changes * Concurrency change * Destroy Network * Minor changes * Minor changes * Fix commit sha * Minor changes * Add Tests * Disable Tests temporarily * Nightly Build * Minor fixes * Big changes * Minor changes * Minor changes * Minor changes * Notification fixes * Notification changes * Minor changes * Permissions fixes * Minor changes * Notification changes * Minor changes * Display commit on notifications * Minor changes --- .github/workflows/notification-deploy-network.yml | 2 +- .github/workflows/notification-main.yml | 2 +- .github/workflows/notification-tests.yml | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/notification-deploy-network.yml b/.github/workflows/notification-deploy-network.yml index 21774d46fc..1b0d5582d8 100644 --- a/.github/workflows/notification-deploy-network.yml +++ b/.github/workflows/notification-deploy-network.yml @@ -30,7 +30,7 @@ jobs: steps: - name: Short SHA id: short_sha - run: echo "value=`echo ${{ github.sha }} | cut -c1-8`" >> $GITHUB_OUTPUT + run: echo "value=`echo ${{ github.sha }} | cut -c1-7`" >> $GITHUB_OUTPUT - name: Notify Slack uses: slackapi/slack-github-action@v1.23.0 env: diff --git a/.github/workflows/notification-main.yml b/.github/workflows/notification-main.yml index 4ae5e05102..86bceb9d8c 100644 --- a/.github/workflows/notification-main.yml +++ b/.github/workflows/notification-main.yml @@ -68,7 +68,7 @@ jobs: steps: - name: Short SHA id: short_sha - run: echo "value=`echo ${{ github.sha }} | cut -c1-8`" >> $GITHUB_OUTPUT + run: echo "value=`echo ${{ github.sha }} | cut -c1-7`" >> $GITHUB_OUTPUT - name: Notify Slack uses: slackapi/slack-github-action@v1.23.0 env: diff --git a/.github/workflows/notification-tests.yml b/.github/workflows/notification-tests.yml index 50e3b3eca4..063e1b31fb 100644 --- a/.github/workflows/notification-tests.yml +++ b/.github/workflows/notification-tests.yml @@ -34,7 +34,7 @@ jobs: steps: - name: Short SHA id: short_sha - run: echo "value=`echo ${{ github.sha }} | cut -c1-8`" >> $GITHUB_OUTPUT + run: echo "value=`echo ${{ github.sha }} | cut -c1-7`" >> $GITHUB_OUTPUT - name: Notify Slack uses: slackapi/slack-github-action@v1.23.0 env: @@ -99,7 +99,7 @@ jobs: "type": "section", "text": { "type": "mrkdwn", - "text": "*Tests*\n${{ inputs.unit_test_output == '' && 'Unit' || '~Unit~' }}, ${{ inputs.fuzz_test_output == '' && 'Fuzz' || '~Fuzz~' }},\n${{ inputs.e2e_legacy_test_output == '' && 'E2E Legacy' || '~E2E Legacy~' }}, ${{ inputs.e2e_polybft_test_output == '' && 'E2E PolyBFT' || '~E2E PolyBFT~' }},\n${{ inputs.property_polybft_test_output == '' && 'Property PolyBFT' || '~Property PolyBFT~' }}" + "text": "${{ inputs.unit_test_output == '' && 'Unit' || '~Unit~' }}, ${{ inputs.fuzz_test_output == '' && 'Fuzz' || '~Fuzz~' }},\n${{ inputs.e2e_legacy_test_output == '' && 'E2E Legacy' || '~E2E Legacy~' }}, ${{ inputs.e2e_polybft_test_output == '' && 'E2E PolyBFT' || '~E2E PolyBFT~' }},\n${{ inputs.property_polybft_test_output == '' && 'Property PolyBFT' || '~Property PolyBFT~' }}" } } ] From f20fed9add6f50ded1e6cca8facc85b5ef1cd4d0 Mon Sep 17 00:00:00 2001 From: Branislav Kojic Date: Fri, 26 Jan 2024 05:49:45 +0100 Subject: [PATCH 26/67] Minor fixes (#27) * Deploy Network * Add Permissions * Minor changes * Concurrency change * Destroy Network * Minor changes * Minor changes * Fix commit sha * Minor changes * Add Tests * Disable Tests temporarily * Nightly Build * Minor fixes * Big changes * Minor changes * Minor changes * Minor changes * Notification fixes * Notification changes * Minor changes * Permissions fixes * Minor changes * Notification changes * Minor changes * Display commit on notifications * Minor changes * Minor fixes --- .github/workflows/notification-load-test.yml | 6 +++--- .github/workflows/notification-main.yml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/notification-load-test.yml b/.github/workflows/notification-load-test.yml index cae309ecab..fd5a222d6e 100644 --- a/.github/workflows/notification-load-test.yml +++ b/.github/workflows/notification-load-test.yml @@ -60,7 +60,7 @@ jobs: { "attachments": [ { - "color": ${{ env.green_color }}, + "color": "${{ env.green_color }}", "blocks": [ { "type": "header", @@ -96,7 +96,7 @@ jobs: "type": "plain_text", "text": "Workflow Run" }, - "style": ${{ env.succeed_bnt }}, + "style": "${{ env.succeed_bnt }}", "url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" } ] @@ -104,7 +104,7 @@ jobs: ] }, { - "color": ${{ env.green_color }}, + "color": "${{ env.green_color }}", "blocks": [ { "type": "section", diff --git a/.github/workflows/notification-main.yml b/.github/workflows/notification-main.yml index 86bceb9d8c..8d36ceae45 100644 --- a/.github/workflows/notification-main.yml +++ b/.github/workflows/notification-main.yml @@ -193,7 +193,7 @@ jobs: ] }, { - "color": "${{ inputs.destroy_network_terraform_output == '' && env.green_color || env.red_color }}", + "color": "${{ inputs.destroy_network_logs_output && inputs.destroy_network_terraform_output == '' && env.green_color || env.red_color }}", "blocks": [ { "type": "section", From 4073ece8724e0953b512145aa076a70b433a0267 Mon Sep 17 00:00:00 2001 From: Branislav Kojic Date: Fri, 26 Jan 2024 06:34:44 +0100 Subject: [PATCH 27/67] Logs notification fixes (#28) * Deploy Network * Add Permissions * Minor changes * Concurrency change * Destroy Network * Minor changes * Minor changes * Fix commit sha * Minor changes * Add Tests * Disable Tests temporarily * Nightly Build * Minor fixes * Big changes * Minor changes * Minor changes * Minor changes * Notification fixes * Notification changes * Minor changes * Permissions fixes * Minor changes * Notification changes * Minor changes * Display commit on notifications * Minor changes * Minor fixes * Logs notification fixes --- .github/workflows/destroy-network.yml | 1 + .github/workflows/notification-destroy-network.yml | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/destroy-network.yml b/.github/workflows/destroy-network.yml index 2cdde4dfdc..4836c23ab3 100644 --- a/.github/workflows/destroy-network.yml +++ b/.github/workflows/destroy-network.yml @@ -137,6 +137,7 @@ jobs: if: always() && github.event_name == 'workflow_dispatch' with: environment: ${{ inputs.environment }} + logs: ${{ inputs.logs }} destroy_network_upload_logs: ${{ needs.upload_logs.outputs.logs_output }} destroy_network_terraform_logs: ${{ needs.destroy_network.outputs.terraform_output }} secrets: diff --git a/.github/workflows/notification-destroy-network.yml b/.github/workflows/notification-destroy-network.yml index 5f4319b8b9..4c5c19c8fd 100644 --- a/.github/workflows/notification-destroy-network.yml +++ b/.github/workflows/notification-destroy-network.yml @@ -7,6 +7,10 @@ on: # yamllint disable-line rule:truthy description: The environment to run against type: string required: true + logs: + description: Upload Logs + type: boolean + required: true destroy_network_upload_logs: description: "Destory Network - Upload Logs" type: string @@ -84,7 +88,7 @@ jobs: "type": "button", "text": { "type": "plain_text", - "text": "${{ inputs.destroy_network_upload_logs == '' && 'Logs' || 'No Logs' }}" + "text": "${{ inputs.logs == true && inputs.destroy_network_upload_logs == '' && 'Logs' || 'No Logs' }}" }, "style": "${{ inputs.destroy_network_upload_logs == '' && env.succeed_bnt || env.failed_bnt }}", "url": "https://s3.console.aws.amazon.com/s3/buckets/${{ secrets.AWS_S3_BLADE_BUCKET }}?region=${{ vars.AWS_REGION }}&prefix=logs/${{ github.run_id }}/" From db76b1ba701f94148e4cc023debb8666358bbc20 Mon Sep 17 00:00:00 2001 From: Branislav Kojic Date: Fri, 26 Jan 2024 06:40:13 +0100 Subject: [PATCH 28/67] Minor fixes (#29) * Deploy Network * Add Permissions * Minor changes * Concurrency change * Destroy Network * Minor changes * Minor changes * Fix commit sha * Minor changes * Add Tests * Disable Tests temporarily * Nightly Build * Minor fixes * Big changes * Minor changes * Minor changes * Minor changes * Notification fixes * Notification changes * Minor changes * Permissions fixes * Minor changes * Notification changes * Minor changes * Display commit on notifications * Minor changes * Minor fixes * Logs notification fixes * Minor changes --- .github/workflows/nightly.yml | 1 + .github/workflows/notification-destroy-network.yml | 2 +- .github/workflows/notification-main.yml | 8 ++++++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index a3d2d59cda..cd3ac24ab5 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -110,6 +110,7 @@ jobs: if: success() || failure() with: environment: nightly + logs: false build_output: ${{ needs.build.outputs.workflow_output }} unit_test_output: ${{ needs.tests.outputs.unit-test }} e2e_polybft_test_output: ${{ needs.tests.outputs.e2e-polybft-test }} diff --git a/.github/workflows/notification-destroy-network.yml b/.github/workflows/notification-destroy-network.yml index 4c5c19c8fd..8219fd07c5 100644 --- a/.github/workflows/notification-destroy-network.yml +++ b/.github/workflows/notification-destroy-network.yml @@ -90,7 +90,7 @@ jobs: "type": "plain_text", "text": "${{ inputs.logs == true && inputs.destroy_network_upload_logs == '' && 'Logs' || 'No Logs' }}" }, - "style": "${{ inputs.destroy_network_upload_logs == '' && env.succeed_bnt || env.failed_bnt }}", + "style": "${{ inputs.logs == true && inputs.destroy_network_upload_logs == '' && env.succeed_bnt || env.failed_bnt }}", "url": "https://s3.console.aws.amazon.com/s3/buckets/${{ secrets.AWS_S3_BLADE_BUCKET }}?region=${{ vars.AWS_REGION }}&prefix=logs/${{ github.run_id }}/" } ] diff --git a/.github/workflows/notification-main.yml b/.github/workflows/notification-main.yml index 8d36ceae45..6d613ebcfa 100644 --- a/.github/workflows/notification-main.yml +++ b/.github/workflows/notification-main.yml @@ -7,6 +7,10 @@ on: # yamllint disable-line rule:truthy description: The environment to run against type: string required: true + logs: + description: Upload Logs + type: boolean + required: true build_output: description: Build output type: string @@ -135,9 +139,9 @@ jobs: "type": "button", "text": { "type": "plain_text", - "text": "${{ inputs.destroy_network_logs_output == '' && 'Logs' || 'No Logs' }}" + "text": "${{ inputs.logs == true && inputs.destroy_network_logs_output == '' && 'Logs' || 'No Logs' }}" }, - "style": "${{ inputs.destroy_network_logs_output == '' && env.succeed_bnt || env.failed_bnt }}", + "style": "${{ inputs.logs == true && inputs.destroy_network_logs_output == '' && env.succeed_bnt || env.failed_bnt }}", "url": "https://s3.console.aws.amazon.com/s3/buckets/${{ secrets.AWS_S3_BLADE_BUCKET }}?region=${{ vars.AWS_REGION }}&prefix=logs/${{ github.run_id }}/" } ] From 86b0450d23d8de37ecf348c5a3ee73776a41d918 Mon Sep 17 00:00:00 2001 From: Branislav Kojic Date: Fri, 26 Jan 2024 07:36:13 +0100 Subject: [PATCH 29/67] Minor changes (#30) * Deploy Network * Add Permissions * Minor changes * Concurrency change * Destroy Network * Minor changes * Minor changes * Fix commit sha * Minor changes * Add Tests * Disable Tests temporarily * Nightly Build * Minor fixes * Big changes * Minor changes * Minor changes * Minor changes * Notification fixes * Notification changes * Minor changes * Permissions fixes * Minor changes * Notification changes * Minor changes * Display commit on notifications * Minor changes * Minor fixes * Logs notification fixes * Minor changes * Minor changes --- .github/workflows/deploy-network.yml | 2 +- .github/workflows/destroy-network.yml | 2 +- .github/workflows/load-test.yml | 2 +- .github/workflows/notification-main.yml | 2 +- .github/workflows/tests.yml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/deploy-network.yml b/.github/workflows/deploy-network.yml index 8c59fe700e..3420729f6b 100644 --- a/.github/workflows/deploy-network.yml +++ b/.github/workflows/deploy-network.yml @@ -139,7 +139,7 @@ jobs: name: Deploy Notification needs: deploy_network uses: ./.github/workflows/notification-deploy-network.yml - if: always() && github.event_name == 'workflow_dispatch' + if: github.event_name == 'workflow_dispatch' with: environment: ${{ inputs.environment }} deploy_network_terraform_output: ${{ needs.deploy_network.outputs.terraform_output }} diff --git a/.github/workflows/destroy-network.yml b/.github/workflows/destroy-network.yml index 4836c23ab3..7c30228d04 100644 --- a/.github/workflows/destroy-network.yml +++ b/.github/workflows/destroy-network.yml @@ -134,7 +134,7 @@ jobs: name: Network Notifications uses: ./.github/workflows/notification-destroy-network.yml needs: [upload_logs, destroy_network] - if: always() && github.event_name == 'workflow_dispatch' + if: github.event_name == 'workflow_dispatch' with: environment: ${{ inputs.environment }} logs: ${{ inputs.logs }} diff --git a/.github/workflows/load-test.yml b/.github/workflows/load-test.yml index fd839825b0..28cb5bed36 100644 --- a/.github/workflows/load-test.yml +++ b/.github/workflows/load-test.yml @@ -203,7 +203,7 @@ jobs: name: Load Test Notification needs: load_test_scenario uses: ./.github/workflows/notification-load-test.yml - if: success() && github.event_name == 'workflow_dispatch' + if: github.event_name == 'workflow_dispatch' with: environment: ${{ inputs.environment }} scenario: ${{ inputs.scenario }} diff --git a/.github/workflows/notification-main.yml b/.github/workflows/notification-main.yml index 6d613ebcfa..e0c848b567 100644 --- a/.github/workflows/notification-main.yml +++ b/.github/workflows/notification-main.yml @@ -197,7 +197,7 @@ jobs: ] }, { - "color": "${{ inputs.destroy_network_logs_output && inputs.destroy_network_terraform_output == '' && env.green_color || env.red_color }}", + "color": "${{ inputs.destroy_network_logs_output == '' && inputs.destroy_network_terraform_output == '' && env.green_color || env.red_color }}", "blocks": [ { "type": "section", diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 72f207579b..2bf5e8ca5b 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -87,7 +87,7 @@ jobs: name: Tests Notification needs: [unit-test, e2e-polybft-test, e2e-legacy-test, property-polybft-test, fuzz-test] uses: ./.github/workflows/notification-tests.yml - if: always() && github.event_name == 'workflow_dispatch' + if: github.event_name == 'workflow_dispatch' with: unit_test_output: ${{ needs.unit-test.outputs.workflow_output }} e2e_polybft_test_output: ${{ needs.e2e-polybft-test.outputs.workflow_output }} From 57c319283c389e1bcc3f7d310c19fc607a30d648 Mon Sep 17 00:00:00 2001 From: Branislav Kojic Date: Fri, 26 Jan 2024 07:41:47 +0100 Subject: [PATCH 30/67] Minor changes (#31) * Deploy Network * Add Permissions * Minor changes * Concurrency change * Destroy Network * Minor changes * Minor changes * Fix commit sha * Minor changes * Add Tests * Disable Tests temporarily * Nightly Build * Minor fixes * Big changes * Minor changes * Minor changes * Minor changes * Notification fixes * Notification changes * Minor changes * Permissions fixes * Minor changes * Notification changes * Minor changes * Display commit on notifications * Minor changes * Minor fixes * Logs notification fixes * Minor changes * Minor changes * Minor changes --- .github/workflows/nightly.yml | 2 +- .github/workflows/notification-main.yml | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index cd3ac24ab5..8f3aa1fc49 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -110,7 +110,7 @@ jobs: if: success() || failure() with: environment: nightly - logs: false + logs: true build_output: ${{ needs.build.outputs.workflow_output }} unit_test_output: ${{ needs.tests.outputs.unit-test }} e2e_polybft_test_output: ${{ needs.tests.outputs.e2e-polybft-test }} diff --git a/.github/workflows/notification-main.yml b/.github/workflows/notification-main.yml index e0c848b567..545db13c17 100644 --- a/.github/workflows/notification-main.yml +++ b/.github/workflows/notification-main.yml @@ -9,7 +9,7 @@ on: # yamllint disable-line rule:truthy required: true logs: description: Upload Logs - type: boolean + type: string required: true build_output: description: Build output @@ -139,9 +139,9 @@ jobs: "type": "button", "text": { "type": "plain_text", - "text": "${{ inputs.logs == true && inputs.destroy_network_logs_output == '' && 'Logs' || 'No Logs' }}" + "text": "${{ inputs.logs == 'true' && inputs.destroy_network_logs_output == '' && 'Logs' || 'No Logs' }}" }, - "style": "${{ inputs.logs == true && inputs.destroy_network_logs_output == '' && env.succeed_bnt || env.failed_bnt }}", + "style": "${{ inputs.logs == 'true' && inputs.destroy_network_logs_output == '' && env.succeed_bnt || env.failed_bnt }}", "url": "https://s3.console.aws.amazon.com/s3/buckets/${{ secrets.AWS_S3_BLADE_BUCKET }}?region=${{ vars.AWS_REGION }}&prefix=logs/${{ github.run_id }}/" } ] From 4d9491d964b81595e017c85296ee27f71130f40f Mon Sep 17 00:00:00 2001 From: Branislav Kojic Date: Fri, 26 Jan 2024 10:11:43 +0100 Subject: [PATCH 31/67] Blade 83 blade GitHub workflows (#32) * Deploy Network * Add Permissions * Minor changes * Concurrency change * Destroy Network * Minor changes * Minor changes * Fix commit sha * Minor changes * Add Tests * Disable Tests temporarily * Nightly Build * Minor fixes * Big changes * Minor changes * Minor changes * Minor changes * Notification fixes * Notification changes * Minor changes * Permissions fixes * Minor changes * Notification changes * Minor changes * Display commit on notifications * Minor changes * Minor fixes * Logs notification fixes * Minor changes * Minor changes * Minor changes * Notifications fixes --- .github/workflows/deploy-network.yml | 10 +++++++++- .github/workflows/destroy-network.yml | 10 +++++++++- .github/workflows/load-test.yml | 10 +++++++++- .github/workflows/nightly.yml | 5 +++++ .github/workflows/tests.yml | 10 +++++++++- 5 files changed, 41 insertions(+), 4 deletions(-) diff --git a/.github/workflows/deploy-network.yml b/.github/workflows/deploy-network.yml index 3420729f6b..b9d726b08a 100644 --- a/.github/workflows/deploy-network.yml +++ b/.github/workflows/deploy-network.yml @@ -22,6 +22,10 @@ on: # yamllint disable-line rule:truthy description: With Bridge type: boolean default: true + notification: + description: Send Notification + type: boolean + default: true workflow_call: inputs: environment: @@ -40,6 +44,10 @@ on: # yamllint disable-line rule:truthy description: With Bridge type: boolean required: true + notification: + description: Send Notification + type: boolean + required: true outputs: terraform_output: description: "Terraform output" @@ -139,7 +147,7 @@ jobs: name: Deploy Notification needs: deploy_network uses: ./.github/workflows/notification-deploy-network.yml - if: github.event_name == 'workflow_dispatch' + if: ${{ inputs.notification == true }} with: environment: ${{ inputs.environment }} deploy_network_terraform_output: ${{ needs.deploy_network.outputs.terraform_output }} diff --git a/.github/workflows/destroy-network.yml b/.github/workflows/destroy-network.yml index 7c30228d04..9adc4dfbca 100644 --- a/.github/workflows/destroy-network.yml +++ b/.github/workflows/destroy-network.yml @@ -12,6 +12,10 @@ on: # yamllint disable-line rule:truthy description: Upload Logs type: boolean default: false + notification: + description: Send Notification + type: boolean + default: true workflow_call: inputs: environment: @@ -22,6 +26,10 @@ on: # yamllint disable-line rule:truthy description: Upload Logs type: boolean required: true + notification: + description: Send Notification + type: boolean + required: true outputs: logs_output: description: Upload Logs output @@ -134,7 +142,7 @@ jobs: name: Network Notifications uses: ./.github/workflows/notification-destroy-network.yml needs: [upload_logs, destroy_network] - if: github.event_name == 'workflow_dispatch' + if: ${{ inputs.notification == true }} with: environment: ${{ inputs.environment }} logs: ${{ inputs.logs }} diff --git a/.github/workflows/load-test.yml b/.github/workflows/load-test.yml index 28cb5bed36..794cb18c65 100644 --- a/.github/workflows/load-test.yml +++ b/.github/workflows/load-test.yml @@ -42,6 +42,10 @@ on: # yamllint disable-line rule:truthy type: string default: "60" required: true + notification: + description: Send Notification + type: boolean + default: true workflow_call: inputs: environment: @@ -76,6 +80,10 @@ on: # yamllint disable-line rule:truthy description: Max VUs type: string required: true + notification: + description: Send Notification + type: boolean + required: true outputs: load_test_output: description: "Load Test output" @@ -203,7 +211,7 @@ jobs: name: Load Test Notification needs: load_test_scenario uses: ./.github/workflows/notification-load-test.yml - if: github.event_name == 'workflow_dispatch' + if: ${{ inputs.notification == true }} with: environment: ${{ inputs.environment }} scenario: ${{ inputs.scenario }} diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 8f3aa1fc49..12e5420a52 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -33,6 +33,7 @@ jobs: e2e-legacy-test: true property-polybft-test: true fuzz-test: true + notification: false deploy_network: name: Deploy Network uses: ./.github/workflows/deploy-network.yml @@ -43,6 +44,7 @@ jobs: block_gas_limit: "200000000" block_time: "2" is_bridge_active: true + notification: false secrets: AWS_ROLE_ARN: ${{ secrets.AWS_ROLE_ARN }} AWS_S3_BLADE_BUCKET: ${{ secrets.AWS_S3_BLADE_BUCKET }} @@ -60,6 +62,7 @@ jobs: duration: "10m" preAllocatedVUs: "60" maxVUs: "60" + notification: false secrets: AWS_ROLE_ARN: ${{ secrets.AWS_ROLE_ARN }} AWS_S3_BLADE_BUCKET: ${{ secrets.AWS_S3_BLADE_BUCKET }} @@ -82,6 +85,7 @@ jobs: duration: "10m" preAllocatedVUs: "60" maxVUs: "60" + notification: false secrets: AWS_ROLE_ARN: ${{ secrets.AWS_ROLE_ARN }} AWS_S3_BLADE_BUCKET: ${{ secrets.AWS_S3_BLADE_BUCKET }} @@ -99,6 +103,7 @@ jobs: with: environment: nightly logs: true + notification: false secrets: AWS_ROLE_ARN: ${{ secrets.AWS_ROLE_ARN }} AWS_S3_BLADE_BUCKET: ${{ secrets.AWS_S3_BLADE_BUCKET }} diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 2bf5e8ca5b..f9c4684708 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -23,6 +23,10 @@ on: # yamllint disable-line rule:truthy description: Fuzz Tests type: boolean default: true + notification: + description: Send Notification + type: boolean + default: true workflow_call: inputs: unit-test: @@ -45,6 +49,10 @@ on: # yamllint disable-line rule:truthy description: Fuzz Tests type: boolean required: true + notification: + description: Send Notification + type: boolean + required: true outputs: unit-test: description: Unit Tests output @@ -87,7 +95,7 @@ jobs: name: Tests Notification needs: [unit-test, e2e-polybft-test, e2e-legacy-test, property-polybft-test, fuzz-test] uses: ./.github/workflows/notification-tests.yml - if: github.event_name == 'workflow_dispatch' + if: ${{ inputs.notification == true }} with: unit_test_output: ${{ needs.unit-test.outputs.workflow_output }} e2e_polybft_test_output: ${{ needs.e2e-polybft-test.outputs.workflow_output }} From 63143a79744e37bc134667bc8b1792715d8c1f2a Mon Sep 17 00:00:00 2001 From: Branislav Kojic Date: Fri, 26 Jan 2024 11:32:14 +0100 Subject: [PATCH 32/67] Minor changes (#33) * Deploy Network * Add Permissions * Minor changes * Concurrency change * Destroy Network * Minor changes * Minor changes * Fix commit sha * Minor changes * Add Tests * Disable Tests temporarily * Nightly Build * Minor fixes * Big changes * Minor changes * Minor changes * Minor changes * Notification fixes * Notification changes * Minor changes * Permissions fixes * Minor changes * Notification changes * Minor changes * Display commit on notifications * Minor changes * Minor fixes * Logs notification fixes * Minor changes * Minor changes * Minor changes * Notifications fixes * Minor changes --- .github/workflows/deploy-network.yml | 4 ++-- .github/workflows/destroy-network.yml | 4 ++-- .github/workflows/load-test.yml | 4 ++-- .github/workflows/notification-load-test.yml | 7 +------ .github/workflows/tests.yml | 4 ++-- 5 files changed, 9 insertions(+), 14 deletions(-) diff --git a/.github/workflows/deploy-network.yml b/.github/workflows/deploy-network.yml index b9d726b08a..73040f3132 100644 --- a/.github/workflows/deploy-network.yml +++ b/.github/workflows/deploy-network.yml @@ -23,7 +23,7 @@ on: # yamllint disable-line rule:truthy type: boolean default: true notification: - description: Send Notification + description: Notification type: boolean default: true workflow_call: @@ -45,7 +45,7 @@ on: # yamllint disable-line rule:truthy type: boolean required: true notification: - description: Send Notification + description: Notification type: boolean required: true outputs: diff --git a/.github/workflows/destroy-network.yml b/.github/workflows/destroy-network.yml index 9adc4dfbca..6f340aa391 100644 --- a/.github/workflows/destroy-network.yml +++ b/.github/workflows/destroy-network.yml @@ -13,7 +13,7 @@ on: # yamllint disable-line rule:truthy type: boolean default: false notification: - description: Send Notification + description: Notification type: boolean default: true workflow_call: @@ -27,7 +27,7 @@ on: # yamllint disable-line rule:truthy type: boolean required: true notification: - description: Send Notification + description: Notification type: boolean required: true outputs: diff --git a/.github/workflows/load-test.yml b/.github/workflows/load-test.yml index 794cb18c65..10b50a0d82 100644 --- a/.github/workflows/load-test.yml +++ b/.github/workflows/load-test.yml @@ -43,7 +43,7 @@ on: # yamllint disable-line rule:truthy default: "60" required: true notification: - description: Send Notification + description: Notification type: boolean default: true workflow_call: @@ -81,7 +81,7 @@ on: # yamllint disable-line rule:truthy type: string required: true notification: - description: Send Notification + description: Notification type: boolean required: true outputs: diff --git a/.github/workflows/notification-load-test.yml b/.github/workflows/notification-load-test.yml index fd5a222d6e..7005983952 100644 --- a/.github/workflows/notification-load-test.yml +++ b/.github/workflows/notification-load-test.yml @@ -100,12 +100,7 @@ jobs: "url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" } ] - } - ] - }, - { - "color": "${{ env.green_color }}", - "blocks": [ + }, { "type": "section", "fields": [ diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index f9c4684708..cf9c48475e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -24,7 +24,7 @@ on: # yamllint disable-line rule:truthy type: boolean default: true notification: - description: Send Notification + description: Notification type: boolean default: true workflow_call: @@ -50,7 +50,7 @@ on: # yamllint disable-line rule:truthy type: boolean required: true notification: - description: Send Notification + description: Notification type: boolean required: true outputs: From 3a8f4b73ae9803e8f46a094c4317d6d22e538249 Mon Sep 17 00:00:00 2001 From: Branislav Kojic Date: Thu, 1 Feb 2024 00:29:08 +0100 Subject: [PATCH 33/67] Update actions versions (#34) * Deploy Network * Add Permissions * Minor changes * Concurrency change * Destroy Network * Minor changes * Minor changes * Fix commit sha * Minor changes * Add Tests * Disable Tests temporarily * Nightly Build * Minor fixes * Big changes * Minor changes * Minor changes * Minor changes * Notification fixes * Notification changes * Minor changes * Permissions fixes * Minor changes * Notification changes * Minor changes * Display commit on notifications * Minor changes * Minor fixes * Logs notification fixes * Minor changes * Minor changes * Minor changes * Notifications fixes * Minor changes * Update actions version --- .github/workflows/build.yml | 10 +++++----- .github/workflows/deploy-network.yml | 6 +++--- .github/workflows/destroy-network.yml | 12 ++++++------ .github/workflows/e2e-legacy-test.yml | 6 +++--- .github/workflows/e2e-polybft-test.yml | 4 ++-- .github/workflows/fuzz-test.yml | 4 ++-- .github/workflows/load-test.yml | 12 ++++++------ .github/workflows/nightly.yml | 2 +- .github/workflows/notification-deploy-network.yml | 2 +- .github/workflows/notification-destroy-network.yml | 2 +- .github/workflows/notification-load-test.yml | 2 +- .github/workflows/notification-main.yml | 2 +- .github/workflows/notification-tests.yml | 2 +- .github/workflows/property-polybft-test.yml | 6 +++--- .github/workflows/unit-test.yml | 4 ++-- 15 files changed, 38 insertions(+), 38 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 959bb24d3a..8fb5408ae4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,9 +17,9 @@ jobs: build_output_failure: ${{ steps.blade_build_failure.outputs.build_output }} steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4.1.1 - name: Setup Go environment - uses: actions/setup-go@v3 + uses: actions/setup-go@v5 with: go-version: 1.20.x - name: Build Blade @@ -32,7 +32,7 @@ jobs: id: blade_build_failure run: echo "build_output=false" >> $GITHUB_OUTPUT - name: "Upload Artifact" - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4.3.0 with: name: blade path: blade.tar.gz @@ -43,9 +43,9 @@ jobs: continue-on-error: true steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4.1.1 - name: Setup Go environment - uses: actions/setup-go@v3 + uses: actions/setup-go@v5 with: go-version: 1.20.x - name: Reproduce builds diff --git a/.github/workflows/deploy-network.yml b/.github/workflows/deploy-network.yml index 73040f3132..6e28dda8cd 100644 --- a/.github/workflows/deploy-network.yml +++ b/.github/workflows/deploy-network.yml @@ -81,17 +81,17 @@ jobs: rpc_url: ${{ steps.rpc_url.outputs.url }} steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4.1.1 with: repository: Ethernal-Tech/blade-deployment ref: changes - name: Configure AWS Credentials - uses: aws-actions/configure-aws-credentials@v3 + uses: aws-actions/configure-aws-credentials@v4.0.1 with: aws-region: ${{ vars.AWS_REGION }} role-to-assume: ${{ secrets.AWS_ROLE_ARN }} - name: Install Terraform - uses: hashicorp/setup-terraform@v2.0.3 + uses: hashicorp/setup-terraform@v3 with: terraform_version: 1.4.5 - name: Configure Terraform for ${{ inputs.environment }} diff --git a/.github/workflows/destroy-network.yml b/.github/workflows/destroy-network.yml index 6f340aa391..c891ffe3a2 100644 --- a/.github/workflows/destroy-network.yml +++ b/.github/workflows/destroy-network.yml @@ -60,17 +60,17 @@ jobs: logs_output: ${{ steps.logs_failure.outputs.logs_output }} steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4.1.1 with: repository: Ethernal-Tech/blade-deployment ref: changes - name: Configure AWS Credentials - uses: aws-actions/configure-aws-credentials@v3 + uses: aws-actions/configure-aws-credentials@v4.0.1 with: aws-region: ${{ vars.AWS_REGION }} role-to-assume: ${{ secrets.AWS_ROLE_ARN }} - name: Install Terraform - uses: hashicorp/setup-terraform@v2.0.3 + uses: hashicorp/setup-terraform@v3 with: terraform_version: 1.4.5 - name: Configure Terraform for ${{ inputs.environment }} @@ -112,17 +112,17 @@ jobs: terraform_output: ${{ steps.terraform_failure.outputs.terraform_output }} steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4.1.1 with: repository: Ethernal-Tech/blade-deployment ref: changes - name: Configure AWS Credentials - uses: aws-actions/configure-aws-credentials@v3 + uses: aws-actions/configure-aws-credentials@v4.0.1 with: aws-region: ${{ vars.AWS_REGION }} role-to-assume: ${{ secrets.AWS_ROLE_ARN }} - name: Install Terraform - uses: hashicorp/setup-terraform@v2.0.3 + uses: hashicorp/setup-terraform@v3 with: terraform_version: 1.4.5 - name: Configure Terraform for ${{ inputs.environment }} diff --git a/.github/workflows/e2e-legacy-test.yml b/.github/workflows/e2e-legacy-test.yml index 4b129f9368..424f46f2b9 100644 --- a/.github/workflows/e2e-legacy-test.yml +++ b/.github/workflows/e2e-legacy-test.yml @@ -26,11 +26,11 @@ jobs: e2e_legacy_output_failure: ${{ steps.run_e2e_legacy_failure.outputs.test_output }} steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4.1.1 with: submodules: recursive - name: Install Go - uses: actions/setup-go@v3 + uses: actions/setup-go@v5 with: go-version: 1.20.x - name: Run tests @@ -41,7 +41,7 @@ jobs: run: echo "test_output=false" >> $GITHUB_OUTPUT - name: Archive test logs if: always() - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4.3.0 with: name: e2e-logs path: e2e-logs-*/ diff --git a/.github/workflows/e2e-polybft-test.yml b/.github/workflows/e2e-polybft-test.yml index dff16df83a..5924936712 100644 --- a/.github/workflows/e2e-polybft-test.yml +++ b/.github/workflows/e2e-polybft-test.yml @@ -26,7 +26,7 @@ jobs: e2e_polybft_output_failure: ${{ steps.run_e2e_polybft_failure.outputs.test_output }} steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4.1.1 - name: Install Go uses: actions/setup-go@v4 with: @@ -41,7 +41,7 @@ jobs: run: echo "test_output=false" >> $GITHUB_OUTPUT - name: Archive test logs if: always() - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4.3.0 with: name: e2e-logs path: e2e-logs-*/ diff --git a/.github/workflows/fuzz-test.yml b/.github/workflows/fuzz-test.yml index 73a03c786a..77a0817060 100644 --- a/.github/workflows/fuzz-test.yml +++ b/.github/workflows/fuzz-test.yml @@ -21,11 +21,11 @@ jobs: fuzz_output_failure: ${{ steps.run_fuzz_failure.outputs.test_output }} steps: - name: Setup Go - uses: actions/setup-go@v3 + uses: actions/setup-go@v5 with: go-version: 1.20.x - name: Checkout Code - uses: actions/checkout@v3 + uses: actions/checkout@v4.1.1 - name: Run Fuzz Test run: make fuzz-test - name: Run fuzz tests failed diff --git a/.github/workflows/load-test.yml b/.github/workflows/load-test.yml index 10b50a0d82..dd62b391e3 100644 --- a/.github/workflows/load-test.yml +++ b/.github/workflows/load-test.yml @@ -142,13 +142,13 @@ jobs: load_test_runner_instance_id: ${{ steps.start_load_teste_runner.outputs.ec2-instance-id }} steps: - name: Configure AWS credentials - uses: aws-actions/configure-aws-credentials@v2 + uses: aws-actions/configure-aws-credentials@v4.0.1 with: aws-region: ${{ vars.AWS_REGION }} role-to-assume: ${{ secrets.AWS_ROLE_ARN }} - name: Start Load Test Runner id: start_load_teste_runner - uses: machulav/ec2-github-runner@v2 + uses: machulav/ec2-github-runner@v2.3.4 with: mode: start ec2-instance-type: ${{ vars.AWS_INSTANCE_TYPE }} @@ -171,9 +171,9 @@ jobs: gas_max: ${{ steps.load_test_results.outputs.gas_max }} steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4.1.1 - name: Configure AWS credentials - uses: aws-actions/configure-aws-credentials@v2 + uses: aws-actions/configure-aws-credentials@v4.0.1 with: aws-region: ${{ vars.AWS_REGION }} role-to-assume: ${{ secrets.AWS_ROLE_ARN }} @@ -232,12 +232,12 @@ jobs: runs-on: ubuntu-latest steps: - name: Configure AWS credentials - uses: aws-actions/configure-aws-credentials@v2 + uses: aws-actions/configure-aws-credentials@v4.0.1 with: aws-region: ${{ vars.AWS_REGION }} role-to-assume: ${{ secrets.AWS_ROLE_ARN }} - name: Stop Load Test Runner - uses: machulav/ec2-github-runner@v2 + uses: machulav/ec2-github-runner@v2.3.4 with: mode: stop label: ${{ needs.load_test_runner.outputs.load_test_runner_label }} diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 12e5420a52..2147619a43 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -14,7 +14,7 @@ jobs: new_commit_count: ${{ steps.get_new_commits.outputs.commit_count }} steps: - name: Checkout Code - uses: actions/checkout@v3 + uses: actions/checkout@v4.1.1 - name: Get new commits id: get_new_commits run: echo "commit_count=$(git log --oneline --since '24 hours ago' | wc -l | tr -d ' ')" >> $GITHUB_OUTPUT diff --git a/.github/workflows/notification-deploy-network.yml b/.github/workflows/notification-deploy-network.yml index 1b0d5582d8..0014342412 100644 --- a/.github/workflows/notification-deploy-network.yml +++ b/.github/workflows/notification-deploy-network.yml @@ -32,7 +32,7 @@ jobs: id: short_sha run: echo "value=`echo ${{ github.sha }} | cut -c1-7`" >> $GITHUB_OUTPUT - name: Notify Slack - uses: slackapi/slack-github-action@v1.23.0 + uses: slackapi/slack-github-action@v1.25.0 env: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK diff --git a/.github/workflows/notification-destroy-network.yml b/.github/workflows/notification-destroy-network.yml index 8219fd07c5..4a6fbc3493 100644 --- a/.github/workflows/notification-destroy-network.yml +++ b/.github/workflows/notification-destroy-network.yml @@ -31,7 +31,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Notify Slack - uses: slackapi/slack-github-action@v1.23.0 + uses: slackapi/slack-github-action@v1.25.0 env: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK diff --git a/.github/workflows/notification-load-test.yml b/.github/workflows/notification-load-test.yml index 7005983952..7f68da9f86 100644 --- a/.github/workflows/notification-load-test.yml +++ b/.github/workflows/notification-load-test.yml @@ -49,7 +49,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Notify Slack - uses: slackapi/slack-github-action@v1.23.0 + uses: slackapi/slack-github-action@v1.25.0 env: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK diff --git a/.github/workflows/notification-main.yml b/.github/workflows/notification-main.yml index 545db13c17..108df67302 100644 --- a/.github/workflows/notification-main.yml +++ b/.github/workflows/notification-main.yml @@ -74,7 +74,7 @@ jobs: id: short_sha run: echo "value=`echo ${{ github.sha }} | cut -c1-7`" >> $GITHUB_OUTPUT - name: Notify Slack - uses: slackapi/slack-github-action@v1.23.0 + uses: slackapi/slack-github-action@v1.25.0 env: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK diff --git a/.github/workflows/notification-tests.yml b/.github/workflows/notification-tests.yml index 063e1b31fb..746c0029e5 100644 --- a/.github/workflows/notification-tests.yml +++ b/.github/workflows/notification-tests.yml @@ -36,7 +36,7 @@ jobs: id: short_sha run: echo "value=`echo ${{ github.sha }} | cut -c1-7`" >> $GITHUB_OUTPUT - name: Notify Slack - uses: slackapi/slack-github-action@v1.23.0 + uses: slackapi/slack-github-action@v1.25.0 env: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK diff --git a/.github/workflows/property-polybft-test.yml b/.github/workflows/property-polybft-test.yml index 614a16f76d..26309eb2a0 100644 --- a/.github/workflows/property-polybft-test.yml +++ b/.github/workflows/property-polybft-test.yml @@ -25,9 +25,9 @@ jobs: property_output_failure: ${{ steps.run_property_failure.outputs.test_output }} steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4.1.1 - name: Install Go - uses: actions/setup-go@v3 + uses: actions/setup-go@v5 with: go-version: 1.20.x - name: Run tests @@ -38,7 +38,7 @@ jobs: run: echo "test_output=false" >> $GITHUB_OUTPUT - name: Archive test logs if: always() - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4.3.0 with: name: e2e-logs path: e2e-logs-*/ diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index 2fc3dc0fa1..75dbcce632 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -17,11 +17,11 @@ jobs: test_output_failure: ${{ steps.run_tests_failure.outputs.test_output }} steps: - name: Setup Go - uses: actions/setup-go@v3 + uses: actions/setup-go@v5 with: go-version: 1.20.x - name: Checkout Code - uses: actions/checkout@v3 + uses: actions/checkout@v4.1.1 with: submodules: recursive fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis From ed9766880edf913441b6067a18496cb5714747c8 Mon Sep 17 00:00:00 2001 From: Branislav Kojic Date: Thu, 1 Feb 2024 00:38:43 +0100 Subject: [PATCH 34/67] Deployment fixes (#35) * Deploy Network * Add Permissions * Minor changes * Concurrency change * Destroy Network * Minor changes * Minor changes * Fix commit sha * Minor changes * Add Tests * Disable Tests temporarily * Nightly Build * Minor fixes * Big changes * Minor changes * Minor changes * Minor changes * Notification fixes * Notification changes * Minor changes * Permissions fixes * Minor changes * Notification changes * Minor changes * Display commit on notifications * Minor changes * Minor fixes * Logs notification fixes * Minor changes * Minor changes * Minor changes * Notifications fixes * Minor changes * Update actions version * Deployment fixes --- .github/workflows/deploy-network.yml | 2 +- .github/workflows/destroy-network.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/deploy-network.yml b/.github/workflows/deploy-network.yml index 6e28dda8cd..457e74132c 100644 --- a/.github/workflows/deploy-network.yml +++ b/.github/workflows/deploy-network.yml @@ -84,7 +84,7 @@ jobs: uses: actions/checkout@v4.1.1 with: repository: Ethernal-Tech/blade-deployment - ref: changes + ref: ce286ca480bbc661f1acea2fddae25a0bfd6d839 - name: Configure AWS Credentials uses: aws-actions/configure-aws-credentials@v4.0.1 with: diff --git a/.github/workflows/destroy-network.yml b/.github/workflows/destroy-network.yml index c891ffe3a2..48a7195863 100644 --- a/.github/workflows/destroy-network.yml +++ b/.github/workflows/destroy-network.yml @@ -63,7 +63,7 @@ jobs: uses: actions/checkout@v4.1.1 with: repository: Ethernal-Tech/blade-deployment - ref: changes + ref: ce286ca480bbc661f1acea2fddae25a0bfd6d839 - name: Configure AWS Credentials uses: aws-actions/configure-aws-credentials@v4.0.1 with: @@ -115,7 +115,7 @@ jobs: uses: actions/checkout@v4.1.1 with: repository: Ethernal-Tech/blade-deployment - ref: changes + ref: ce286ca480bbc661f1acea2fddae25a0bfd6d839 - name: Configure AWS Credentials uses: aws-actions/configure-aws-credentials@v4.0.1 with: From 396eb4c02514dacbceb5aa4cf4b67b5f172c4a17 Mon Sep 17 00:00:00 2001 From: Branislav Kojic Date: Thu, 1 Feb 2024 01:02:20 +0100 Subject: [PATCH 35/67] Minor changes (#36) * Deploy Network * Add Permissions * Minor changes * Concurrency change * Destroy Network * Minor changes * Minor changes * Fix commit sha * Minor changes * Add Tests * Disable Tests temporarily * Nightly Build * Minor fixes * Big changes * Minor changes * Minor changes * Minor changes * Notification fixes * Notification changes * Minor changes * Permissions fixes * Minor changes * Notification changes * Minor changes * Display commit on notifications * Minor changes * Minor fixes * Logs notification fixes * Minor changes * Minor changes * Minor changes * Notifications fixes * Minor changes * Update actions version * Deployment fixes * Minor changes --- .github/workflows/build.yml | 2 ++ .github/workflows/e2e-legacy-test.yml | 3 ++- .github/workflows/e2e-polybft-test.yml | 6 +++--- .github/workflows/fuzz-test.yml | 1 + .github/workflows/property-polybft-test.yml | 3 ++- .github/workflows/unit-test.yml | 1 + 6 files changed, 11 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8fb5408ae4..3ef134f62b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -22,6 +22,7 @@ jobs: uses: actions/setup-go@v5 with: go-version: 1.20.x + cache: false - name: Build Blade run: go build -o blade -tags netgo -ldflags="-s -w -X \"github.com/bane/blade/versioning.Version=${GITHUB_REF_NAME}\" -X \"github.com/bane/blade/versioning.Commit=${GITHUB_SHA}\"" && tar -czvf blade.tar.gz blade env: @@ -48,6 +49,7 @@ jobs: uses: actions/setup-go@v5 with: go-version: 1.20.x + cache: false - name: Reproduce builds continue-on-error: true run: | diff --git a/.github/workflows/e2e-legacy-test.yml b/.github/workflows/e2e-legacy-test.yml index 424f46f2b9..29f30b1e56 100644 --- a/.github/workflows/e2e-legacy-test.yml +++ b/.github/workflows/e2e-legacy-test.yml @@ -33,6 +33,7 @@ jobs: uses: actions/setup-go@v5 with: go-version: 1.20.x + cache: false - name: Run tests run: make test-e2e-legacy - name: Run tests failed @@ -43,6 +44,6 @@ jobs: if: always() uses: actions/upload-artifact@v4.3.0 with: - name: e2e-logs + name: e2e-legacy-logs path: e2e-logs-*/ retention-days: 30 diff --git a/.github/workflows/e2e-polybft-test.yml b/.github/workflows/e2e-polybft-test.yml index 5924936712..ad26c46545 100644 --- a/.github/workflows/e2e-polybft-test.yml +++ b/.github/workflows/e2e-polybft-test.yml @@ -28,11 +28,11 @@ jobs: - name: Checkout code uses: actions/checkout@v4.1.1 - name: Install Go - uses: actions/setup-go@v4 + uses: actions/setup-go@v5 with: go-version: 1.20.x check-latest: true - cache-dependency-path: go.sum + cache: false - name: Run tests run: make test-e2e-polybft - name: Run tests failed @@ -43,6 +43,6 @@ jobs: if: always() uses: actions/upload-artifact@v4.3.0 with: - name: e2e-logs + name: e2e-polybft-logs path: e2e-logs-*/ retention-days: 30 diff --git a/.github/workflows/fuzz-test.yml b/.github/workflows/fuzz-test.yml index 77a0817060..12095fd743 100644 --- a/.github/workflows/fuzz-test.yml +++ b/.github/workflows/fuzz-test.yml @@ -24,6 +24,7 @@ jobs: uses: actions/setup-go@v5 with: go-version: 1.20.x + cache: false - name: Checkout Code uses: actions/checkout@v4.1.1 - name: Run Fuzz Test diff --git a/.github/workflows/property-polybft-test.yml b/.github/workflows/property-polybft-test.yml index 26309eb2a0..2fd46ced13 100644 --- a/.github/workflows/property-polybft-test.yml +++ b/.github/workflows/property-polybft-test.yml @@ -30,6 +30,7 @@ jobs: uses: actions/setup-go@v5 with: go-version: 1.20.x + cache: false - name: Run tests run: make test-property-polybft - name: Run tests failed @@ -40,6 +41,6 @@ jobs: if: always() uses: actions/upload-artifact@v4.3.0 with: - name: e2e-logs + name: property-polybft-logs path: e2e-logs-*/ retention-days: 30 diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index 75dbcce632..83d3ad48e2 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -20,6 +20,7 @@ jobs: uses: actions/setup-go@v5 with: go-version: 1.20.x + cache: false - name: Checkout Code uses: actions/checkout@v4.1.1 with: From 19cc72e8a4d00fd732bf493cb8945c7cd8a2bbb1 Mon Sep 17 00:00:00 2001 From: Branislav Kojic Date: Thu, 1 Feb 2024 01:55:10 +0100 Subject: [PATCH 36/67] Minor changes (#37) * Deploy Network * Add Permissions * Minor changes * Concurrency change * Destroy Network * Minor changes * Minor changes * Fix commit sha * Minor changes * Add Tests * Disable Tests temporarily * Nightly Build * Minor fixes * Big changes * Minor changes * Minor changes * Minor changes * Notification fixes * Notification changes * Minor changes * Permissions fixes * Minor changes * Notification changes * Minor changes * Display commit on notifications * Minor changes * Minor fixes * Logs notification fixes * Minor changes * Minor changes * Minor changes * Notifications fixes * Minor changes * Update actions version * Deployment fixes * Minor changes * Minor changes --- .github/workflows/load-test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/load-test.yml b/.github/workflows/load-test.yml index dd62b391e3..0b0ffd46df 100644 --- a/.github/workflows/load-test.yml +++ b/.github/workflows/load-test.yml @@ -148,7 +148,7 @@ jobs: role-to-assume: ${{ secrets.AWS_ROLE_ARN }} - name: Start Load Test Runner id: start_load_teste_runner - uses: machulav/ec2-github-runner@v2.3.4 + uses: bane/ec2-github-runner@v2.3.4.nodejs20 with: mode: start ec2-instance-type: ${{ vars.AWS_INSTANCE_TYPE }} @@ -237,7 +237,7 @@ jobs: aws-region: ${{ vars.AWS_REGION }} role-to-assume: ${{ secrets.AWS_ROLE_ARN }} - name: Stop Load Test Runner - uses: machulav/ec2-github-runner@v2.3.4 + uses: bane/ec2-github-runner@v2.3.4.nodejs20 with: mode: stop label: ${{ needs.load_test_runner.outputs.load_test_runner_label }} From 21cd311db3e0427f968767c4d1f8198a9d76c7ef Mon Sep 17 00:00:00 2001 From: Branislav Kojic Date: Thu, 1 Feb 2024 02:38:12 +0100 Subject: [PATCH 37/67] Build repository fixes (#38) * Deploy Network * Add Permissions * Minor changes * Concurrency change * Destroy Network * Minor changes * Minor changes * Fix commit sha * Minor changes * Add Tests * Disable Tests temporarily * Nightly Build * Minor fixes * Big changes * Minor changes * Minor changes * Minor changes * Notification fixes * Notification changes * Minor changes * Permissions fixes * Minor changes * Notification changes * Minor changes * Display commit on notifications * Minor changes * Minor fixes * Logs notification fixes * Minor changes * Minor changes * Minor changes * Notifications fixes * Minor changes * Update actions version * Deployment fixes * Minor changes * Minor changes * Build repository fixes --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3ef134f62b..0a412ea24d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -24,7 +24,7 @@ jobs: go-version: 1.20.x cache: false - name: Build Blade - run: go build -o blade -tags netgo -ldflags="-s -w -X \"github.com/bane/blade/versioning.Version=${GITHUB_REF_NAME}\" -X \"github.com/bane/blade/versioning.Commit=${GITHUB_SHA}\"" && tar -czvf blade.tar.gz blade + run: go build -o blade -tags netgo -ldflags="-s -w -X \"github.com/${GITHUB_REPOSITORY}/versioning.Version=${GITHUB_REF_NAME}\" -X \"github.com/${GITHUB_REPOSITORY}/versioning.Commit=${GITHUB_SHA}\"" && tar -czvf blade.tar.gz blade env: GOARC: amd64 GOOS: linux From ea0106f7b59d4f54aa793f8fbb45afd0523288cd Mon Sep 17 00:00:00 2001 From: Branislav Kojic Date: Tue, 6 Feb 2024 21:51:59 +0100 Subject: [PATCH 38/67] Restore Blade Data (#39) * Deploy Network * Add Permissions * Minor changes * Concurrency change * Destroy Network * Minor changes * Minor changes * Fix commit sha * Minor changes * Add Tests * Disable Tests temporarily * Nightly Build * Minor fixes * Big changes * Minor changes * Minor changes * Minor changes * Notification fixes * Notification changes * Minor changes * Permissions fixes * Minor changes * Notification changes * Minor changes * Display commit on notifications * Minor changes * Minor fixes * Logs notification fixes * Minor changes * Minor changes * Minor changes * Notifications fixes * Minor changes * Update actions version * Deployment fixes * Minor changes * Minor changes * Build repository fixes * Load Test notification text changes * EIP-1559; Check if the network is already deployed; Restore Blade Data --- .github/workflows/deploy-network.yml | 59 +++++++++++++++++--- .github/workflows/destroy-network.yml | 47 +++++++--------- .github/workflows/load-test.yml | 6 +- .github/workflows/nightly.yml | 5 +- .github/workflows/notification-load-test.yml | 2 +- .github/workflows/tests.yml | 16 ++---- 6 files changed, 82 insertions(+), 53 deletions(-) diff --git a/.github/workflows/deploy-network.yml b/.github/workflows/deploy-network.yml index 457e74132c..6bb660824d 100644 --- a/.github/workflows/deploy-network.yml +++ b/.github/workflows/deploy-network.yml @@ -18,12 +18,12 @@ on: # yamllint disable-line rule:truthy type: string default: "2" required: true - is_bridge_active: - description: With Bridge + is_london_fork_active: + description: EIP-1559 type: boolean default: true - notification: - description: Notification + is_bridge_active: + description: With Bridge type: boolean default: true workflow_call: @@ -40,6 +40,10 @@ on: # yamllint disable-line rule:truthy description: Block Time type: string required: true + is_london_fork_active: + description: EIP-1559 + type: boolean + required: true is_bridge_active: description: With Bridge type: boolean @@ -69,9 +73,35 @@ permissions: security-events: write jobs: + check_network: + name: Check if ${{ inputs.environment }} is already deployed + runs-on: ubuntu-latest + outputs: + check_output: ${{ steps.check_state_file.outputs.resources }} + steps: + - name: Checkout code + uses: actions/checkout@v4.1.1 + - name: Install jq and aws-cli + run: | + sudo apt-get update + sudo apt-get install jq + sudo apt-get install awscli + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v4.0.1 + with: + aws-region: ${{ vars.AWS_REGION }} + role-to-assume: ${{ secrets.AWS_ROLE_ARN }} + - name: Retrieve state file from s3 + run: aws s3 cp s3://${{ secrets.AWS_S3_BLADE_BUCKET }}/states/${{ inputs.environment }} state.json + - name: Check state file + if: success() + id: check_state_file + run: echo "resources=$(cat state.json | jq -r ".resources" | jq length)" >> $GITHUB_OUTPUT deploy_network: name: Deploy ${{ inputs.environment }} runs-on: ubuntu-latest + needs: check_network + if: failure() || needs.check_network.outputs.check_output == 0 environment: name: ${{ inputs.environment }} url: ${{ steps.rpc_url.outputs.url }} @@ -84,7 +114,7 @@ jobs: uses: actions/checkout@v4.1.1 with: repository: Ethernal-Tech/blade-deployment - ref: ce286ca480bbc661f1acea2fddae25a0bfd6d839 + ref: changes - name: Configure AWS Credentials uses: aws-actions/configure-aws-credentials@v4.0.1 with: @@ -130,12 +160,23 @@ jobs: sed 's/devnet/${{ inputs.environment }}/g' inventory/aws_ec2.yml > inventory/aws_ec2.yml.tmp && mv inventory/aws_ec2.yml.tmp inventory/aws_ec2.yml sed 's/blade_tag: .*/blade_tag: ${{ github.sha }}/g' group_vars/all.yml > group_vars/all.yml.tmp && mv group_vars/all.yml.tmp group_vars/all.yml sed 's/INFO/${{ vars.LOG_LEVEL }}/g' roles/blade/templates/blade.service > roles/blade/templates/blade.service.tmp && mv roles/blade/templates/blade.service.tmp roles/blade/templates/blade.service - - name: Run Ansible + - name: Check previous blade data + id: previous_data + if: inputs.environment == 'test' + run: echo "previous_data_output=$(aws s3 cp s3://${{ secrets.AWS_S3_BLADE_BUCKET }}/states/${{ inputs.environment }}.data.tar.gz .)" >> $GITHUB_OUTPUT + - name: Setup Ansible working-directory: ansible run: | ansible-inventory --graph ansible-galaxy install -r requirements.yml - ansible-playbook site.yml --extra-vars "clean_deploy_title=${{ inputs.environment }} block_gas_limit=${{ inputs.block_gas_limit }} block_time=${{ inputs.block_time }} is_bridge_active=${{ inputs.is_bridge_active }}" + - name: Run Ansible (Bootstrap blade) + if: steps.previous_data.outputs.previous_data_output == '' || contains(steps.previous_data.outputs.previous_data_output, 'error') + working-directory: ansible + run: ansible-playbook site.yml --extra-vars "clean_deploy_title=${{ inputs.environment }} block_gas_limit=${{ inputs.block_gas_limit }} block_time=${{ inputs.block_time }} is_london_fork_active=${{ inputs.is_london_fork_active }} is_bridge_active=${{ inputs.is_bridge_active }}" + - name: Run Ansible (Restore data) + if: steps.previous_data.outputs.previous_data_output != '' && ${{ !contains(steps.previous_data.outputs.previous_data_output, 'error') }} + working-directory: ansible + run: ansible-playbook site.yml --extra-vars "clean_deploy_title=${{ inputs.environment }} block_gas_limit=${{ inputs.block_gas_limit }} block_time=${{ inputs.block_time }} s3_bucket=${{ secrets.AWS_S3_BLADE_BUCKET }} restore_data=true" - name: Ansible Failed if: failure() id: ansible_failure @@ -145,9 +186,9 @@ jobs: run: echo "url=http://$(terraform output -raw aws_lb_ext_domain | grep -o -E '^ext[^:]*')" >> $GITHUB_OUTPUT notification: name: Deploy Notification - needs: deploy_network + needs: [check_network, deploy_network] uses: ./.github/workflows/notification-deploy-network.yml - if: ${{ inputs.notification == true }} + if: inputs.notification == true && needs.check_network.outputs.check_output == 0 with: environment: ${{ inputs.environment }} deploy_network_terraform_output: ${{ needs.deploy_network.outputs.terraform_output }} diff --git a/.github/workflows/destroy-network.yml b/.github/workflows/destroy-network.yml index 48a7195863..8555573fe6 100644 --- a/.github/workflows/destroy-network.yml +++ b/.github/workflows/destroy-network.yml @@ -12,10 +12,6 @@ on: # yamllint disable-line rule:truthy description: Upload Logs type: boolean default: false - notification: - description: Notification - type: boolean - default: true workflow_call: inputs: environment: @@ -33,7 +29,7 @@ on: # yamllint disable-line rule:truthy outputs: logs_output: description: Upload Logs output - value: ${{ jobs.upload_logs.outputs.logs_output }} + value: ${{ jobs.upload_logs_and_data.outputs.logs_output }} terraform_output: description: Terraform output value: ${{ jobs.destroy_network.outputs.terraform_output }} @@ -51,11 +47,11 @@ permissions: security-events: write jobs: - upload_logs: - name: Upload Logs + upload_logs_and_data: + name: Upload Logs and Data runs-on: ubuntu-latest environment: ${{ inputs.environment }} - if: ${{ inputs.logs == true }} + if: inputs.logs == true || inputs.environment == 'test' outputs: logs_output: ${{ steps.logs_failure.outputs.logs_output }} steps: @@ -63,7 +59,7 @@ jobs: uses: actions/checkout@v4.1.1 with: repository: Ethernal-Tech/blade-deployment - ref: ce286ca480bbc661f1acea2fddae25a0bfd6d839 + ref: changes - name: Configure AWS Credentials uses: aws-actions/configure-aws-credentials@v4.0.1 with: @@ -96,26 +92,30 @@ jobs: sed 's/devnet/${{ inputs.environment }}/g' roles/upload-logs/tasks/logs.yml > roles/upload-logs/tasks/logs.yml.tmp && mv roles/upload-logs/tasks/logs.yml.tmp roles/upload-logs/tasks/logs.yml sed 's/{{ current_datetime\.stdout }}/${{ github.run_id }}/g' roles/upload-logs/tasks/logs.yml > roles/upload-logs/tasks/logs.yml.tmp && mv roles/upload-logs/tasks/logs.yml.tmp roles/upload-logs/tasks/logs.yml - name: Upload Logs + if: inputs.logs == true working-directory: ansible run: ansible-playbook upload-logs.yml --extra-vars "clean_deploy_title=${{ inputs.environment }}" - name: Logs Failed if: failure() id: logs_failure run: echo "logs_output=false" >> $GITHUB_OUTPUT + - name: Upload Data + if: inputs.environment == 'test' + working-directory: ansible + run: ansible-playbook upload-data.yml --extra-vars "clean_deploy_title=${{ inputs.environment }} s3_bucket=${{ secrets.AWS_S3_BLADE_BUCKET }}" + - name: Data Failed + if: failure() + id: data_failure + run: echo "data_output=false" >> $GITHUB_OUTPUT destroy_network: name: Destroy ${{ inputs.environment }} runs-on: ubuntu-latest environment: ${{ inputs.environment }} - needs: upload_logs + needs: upload_logs_and_data if: always() outputs: terraform_output: ${{ steps.terraform_failure.outputs.terraform_output }} steps: - - name: Checkout code - uses: actions/checkout@v4.1.1 - with: - repository: Ethernal-Tech/blade-deployment - ref: ce286ca480bbc661f1acea2fddae25a0bfd6d839 - name: Configure AWS Credentials uses: aws-actions/configure-aws-credentials@v4.0.1 with: @@ -125,15 +125,10 @@ jobs: uses: hashicorp/setup-terraform@v3 with: terraform_version: 1.4.5 - - name: Configure Terraform for ${{ inputs.environment }} - run: | - sed 's/# backend "s3" {}/backend "s3" {}/' main.tf > main.tf.tmp && mv main.tf.tmp main.tf - - name: Terraform Init - id: init - run: terraform init -backend-config="bucket=${{ secrets.AWS_S3_BLADE_BUCKET }}" -backend-config="key=states/${{ inputs.environment }}" -backend-config="region=${{ vars.AWS_REGION }}" + - name: Retrieve state file from s3 + run: aws s3 cp s3://${{ secrets.AWS_S3_BLADE_BUCKET }}/states/${{ inputs.environment }} state.json - name: Terraform Destroy - id: destroy - run: terraform destroy -auto-approve + run: terraform destroy -auto-approve -state=state.json - name: Terraform Failed if: failure() id: terraform_failure @@ -141,12 +136,12 @@ jobs: notification: name: Network Notifications uses: ./.github/workflows/notification-destroy-network.yml - needs: [upload_logs, destroy_network] - if: ${{ inputs.notification == true }} + needs: [upload_logs_and_data, destroy_network] + if: inputs.notification == true with: environment: ${{ inputs.environment }} logs: ${{ inputs.logs }} - destroy_network_upload_logs: ${{ needs.upload_logs.outputs.logs_output }} + destroy_network_upload_logs: ${{ needs.upload_logs_and_data.outputs.logs_output }} destroy_network_terraform_logs: ${{ needs.destroy_network.outputs.terraform_output }} secrets: AWS_S3_BLADE_BUCKET: ${{ secrets.AWS_S3_BLADE_BUCKET }} diff --git a/.github/workflows/load-test.yml b/.github/workflows/load-test.yml index 0b0ffd46df..187d14d4f5 100644 --- a/.github/workflows/load-test.yml +++ b/.github/workflows/load-test.yml @@ -42,10 +42,6 @@ on: # yamllint disable-line rule:truthy type: string default: "60" required: true - notification: - description: Notification - type: boolean - default: true workflow_call: inputs: environment: @@ -211,7 +207,7 @@ jobs: name: Load Test Notification needs: load_test_scenario uses: ./.github/workflows/notification-load-test.yml - if: ${{ inputs.notification == true }} + if: inputs.notification == true with: environment: ${{ inputs.environment }} scenario: ${{ inputs.scenario }} diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 2147619a43..490b75178d 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -22,7 +22,7 @@ jobs: name: Build Blade uses: ./.github/workflows/build.yml needs: check - if: ${{ needs.check.outputs.new_commit_count > 0 }} + if: needs.check.outputs.new_commit_count > 0 tests: name: Tests uses: ./.github/workflows/tests.yml @@ -38,11 +38,12 @@ jobs: name: Deploy Network uses: ./.github/workflows/deploy-network.yml needs: check - if: ${{ needs.check.outputs.new_commit_count > 0 }} + if: needs.check.outputs.new_commit_count > 0 with: environment: nightly block_gas_limit: "200000000" block_time: "2" + is_london_fork_active: true is_bridge_active: true notification: false secrets: diff --git a/.github/workflows/notification-load-test.yml b/.github/workflows/notification-load-test.yml index 7f68da9f86..08ff91b53f 100644 --- a/.github/workflows/notification-load-test.yml +++ b/.github/workflows/notification-load-test.yml @@ -66,7 +66,7 @@ jobs: "type": "header", "text": { "type": "plain_text", - "text": "K6 Load Test: ${{ inputs.scenario }}" + "text": "Load Test: ${{ inputs.scenario }}" } }, { diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index cf9c48475e..e6197a20c9 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -23,10 +23,6 @@ on: # yamllint disable-line rule:truthy description: Fuzz Tests type: boolean default: true - notification: - description: Notification - type: boolean - default: true workflow_call: inputs: unit-test: @@ -74,28 +70,28 @@ jobs: unit-test: name: Unit Tests uses: ./.github/workflows/unit-test.yml - if: ${{ inputs.unit-test == true }} + if: inputs.unit-test == true e2e-polybft-test: name: E2E PolyBFT Tests uses: ./.github/workflows/e2e-polybft-test.yml - if: ${{ inputs.e2e-polybft-test == true }} + if: inputs.e2e-polybft-test == true e2e-legacy-test: name: E2E Legacy Tests uses: ./.github/workflows/e2e-legacy-test.yml - if: ${{ inputs.e2e-legacy-test == true }} + if: inputs.e2e-legacy-test == true property-polybft-test: name: Property PolyBFT Tests uses: ./.github/workflows/property-polybft-test.yml - if: ${{ inputs.property-polybft-test == true }} + if: inputs.property-polybft-test == true fuzz-test: name: Fuzz Tests uses: ./.github/workflows/fuzz-test.yml - if: ${{ inputs.fuzz-test == true }} + if: inputs.fuzz-test == true notification: name: Tests Notification needs: [unit-test, e2e-polybft-test, e2e-legacy-test, property-polybft-test, fuzz-test] uses: ./.github/workflows/notification-tests.yml - if: ${{ inputs.notification == true }} + if: inputs.notification == true with: unit_test_output: ${{ needs.unit-test.outputs.workflow_output }} e2e_polybft_test_output: ${{ needs.e2e-polybft-test.outputs.workflow_output }} From d721b5af47e85872019c1a92a892bcf5f953d7c4 Mon Sep 17 00:00:00 2001 From: Branislav Kojic Date: Wed, 7 Feb 2024 07:37:56 +0100 Subject: [PATCH 39/67] Pass blade_repository when deploying the network (#40) * Deploy Network * Add Permissions * Minor changes * Concurrency change * Destroy Network * Minor changes * Minor changes * Fix commit sha * Minor changes * Add Tests * Disable Tests temporarily * Nightly Build * Minor fixes * Big changes * Minor changes * Minor changes * Minor changes * Notification fixes * Notification changes * Minor changes * Permissions fixes * Minor changes * Notification changes * Minor changes * Display commit on notifications * Minor changes * Minor fixes * Logs notification fixes * Minor changes * Minor changes * Minor changes * Notifications fixes * Minor changes * Update actions version * Deployment fixes * Minor changes * Minor changes * Build repository fixes * Load Test notification text changes * EIP-1559; Check if the network is already deployed; Restore Blade Data * Notifications fixes; Pass blade_repository when deploying the network --- .github/workflows/deploy-network.yml | 6 +++--- .github/workflows/destroy-network.yml | 2 +- .github/workflows/load-test.yml | 2 +- .github/workflows/tests.yml | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/deploy-network.yml b/.github/workflows/deploy-network.yml index 6bb660824d..a530daa7a9 100644 --- a/.github/workflows/deploy-network.yml +++ b/.github/workflows/deploy-network.yml @@ -172,11 +172,11 @@ jobs: - name: Run Ansible (Bootstrap blade) if: steps.previous_data.outputs.previous_data_output == '' || contains(steps.previous_data.outputs.previous_data_output, 'error') working-directory: ansible - run: ansible-playbook site.yml --extra-vars "clean_deploy_title=${{ inputs.environment }} block_gas_limit=${{ inputs.block_gas_limit }} block_time=${{ inputs.block_time }} is_london_fork_active=${{ inputs.is_london_fork_active }} is_bridge_active=${{ inputs.is_bridge_active }}" + run: ansible-playbook site.yml --extra-vars "clean_deploy_title=${{ inputs.environment }} blade_repository=${{ github.repository }} block_gas_limit=${{ inputs.block_gas_limit }} block_time=${{ inputs.block_time }} is_london_fork_active=${{ inputs.is_london_fork_active }} is_bridge_active=${{ inputs.is_bridge_active }}" - name: Run Ansible (Restore data) if: steps.previous_data.outputs.previous_data_output != '' && ${{ !contains(steps.previous_data.outputs.previous_data_output, 'error') }} working-directory: ansible - run: ansible-playbook site.yml --extra-vars "clean_deploy_title=${{ inputs.environment }} block_gas_limit=${{ inputs.block_gas_limit }} block_time=${{ inputs.block_time }} s3_bucket=${{ secrets.AWS_S3_BLADE_BUCKET }} restore_data=true" + run: ansible-playbook site.yml --extra-vars "clean_deploy_title=${{ inputs.environment }} blade_repository=${{ github.repository }} block_gas_limit=${{ inputs.block_gas_limit }} block_time=${{ inputs.block_time }} s3_bucket=${{ secrets.AWS_S3_BLADE_BUCKET }} restore_data=true" - name: Ansible Failed if: failure() id: ansible_failure @@ -188,7 +188,7 @@ jobs: name: Deploy Notification needs: [check_network, deploy_network] uses: ./.github/workflows/notification-deploy-network.yml - if: inputs.notification == true && needs.check_network.outputs.check_output == 0 + if: inputs.notification != false && needs.check_network.outputs.check_output == 0 with: environment: ${{ inputs.environment }} deploy_network_terraform_output: ${{ needs.deploy_network.outputs.terraform_output }} diff --git a/.github/workflows/destroy-network.yml b/.github/workflows/destroy-network.yml index 8555573fe6..98d6c34f72 100644 --- a/.github/workflows/destroy-network.yml +++ b/.github/workflows/destroy-network.yml @@ -137,7 +137,7 @@ jobs: name: Network Notifications uses: ./.github/workflows/notification-destroy-network.yml needs: [upload_logs_and_data, destroy_network] - if: inputs.notification == true + if: inputs.notification != false with: environment: ${{ inputs.environment }} logs: ${{ inputs.logs }} diff --git a/.github/workflows/load-test.yml b/.github/workflows/load-test.yml index 187d14d4f5..10f78c61f1 100644 --- a/.github/workflows/load-test.yml +++ b/.github/workflows/load-test.yml @@ -207,7 +207,7 @@ jobs: name: Load Test Notification needs: load_test_scenario uses: ./.github/workflows/notification-load-test.yml - if: inputs.notification == true + if: inputs.notification != false with: environment: ${{ inputs.environment }} scenario: ${{ inputs.scenario }} diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index e6197a20c9..9cc6b494ed 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -91,7 +91,7 @@ jobs: name: Tests Notification needs: [unit-test, e2e-polybft-test, e2e-legacy-test, property-polybft-test, fuzz-test] uses: ./.github/workflows/notification-tests.yml - if: inputs.notification == true + if: inputs.notification != false with: unit_test_output: ${{ needs.unit-test.outputs.workflow_output }} e2e_polybft_test_output: ${{ needs.e2e-polybft-test.outputs.workflow_output }} From 6b49292363398c111b54d3db48b08bac17f7bdb5 Mon Sep 17 00:00:00 2001 From: Branislav Kojic Date: Wed, 7 Feb 2024 07:46:22 +0100 Subject: [PATCH 40/67] Terraform fixes (#41) * Deploy Network * Add Permissions * Minor changes * Concurrency change * Destroy Network * Minor changes * Minor changes * Fix commit sha * Minor changes * Add Tests * Disable Tests temporarily * Nightly Build * Minor fixes * Big changes * Minor changes * Minor changes * Minor changes * Notification fixes * Notification changes * Minor changes * Permissions fixes * Minor changes * Notification changes * Minor changes * Display commit on notifications * Minor changes * Minor fixes * Logs notification fixes * Minor changes * Minor changes * Minor changes * Notifications fixes * Minor changes * Update actions version * Deployment fixes * Minor changes * Minor changes * Build repository fixes * Load Test notification text changes * EIP-1559; Check if the network is already deployed; Restore Blade Data * Notifications fixes; Pass blade_repository when deploying the network * Terraform fixes * Minor changes --- .github/workflows/destroy-network.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/destroy-network.yml b/.github/workflows/destroy-network.yml index 98d6c34f72..e8cd2359f7 100644 --- a/.github/workflows/destroy-network.yml +++ b/.github/workflows/destroy-network.yml @@ -125,10 +125,13 @@ jobs: uses: hashicorp/setup-terraform@v3 with: terraform_version: 1.4.5 - - name: Retrieve state file from s3 - run: aws s3 cp s3://${{ secrets.AWS_S3_BLADE_BUCKET }}/states/${{ inputs.environment }} state.json + - name: Configure Terraform for ${{ inputs.environment }} + run: sed 's/# backend "s3" {}/backend "s3" {}/' main.tf > main.tf.tmp && mv main.tf.tmp main.tf + - name: Terraform Init + id: init + run: terraform init -backend-config="bucket=${{ secrets.AWS_S3_BLADE_BUCKET }}" -backend-config="key=states/${{ inputs.environment }}" -backend-config="region=${{ vars.AWS_REGION }}" - name: Terraform Destroy - run: terraform destroy -auto-approve -state=state.json + run: terraform destroy -auto-approve - name: Terraform Failed if: failure() id: terraform_failure From d5727a37fc354a6e8d77370c88571e47a63c4566 Mon Sep 17 00:00:00 2001 From: Branislav Kojic Date: Wed, 7 Feb 2024 07:48:44 +0100 Subject: [PATCH 41/67] Terraform fixes (#42) * Deploy Network * Add Permissions * Minor changes * Concurrency change * Destroy Network * Minor changes * Minor changes * Fix commit sha * Minor changes * Add Tests * Disable Tests temporarily * Nightly Build * Minor fixes * Big changes * Minor changes * Minor changes * Minor changes * Notification fixes * Notification changes * Minor changes * Permissions fixes * Minor changes * Notification changes * Minor changes * Display commit on notifications * Minor changes * Minor fixes * Logs notification fixes * Minor changes * Minor changes * Minor changes * Notifications fixes * Minor changes * Update actions version * Deployment fixes * Minor changes * Minor changes * Build repository fixes * Load Test notification text changes * EIP-1559; Check if the network is already deployed; Restore Blade Data * Notifications fixes; Pass blade_repository when deploying the network * Terraform fixes * Minor changes * Minor changes --- .github/workflows/destroy-network.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/destroy-network.yml b/.github/workflows/destroy-network.yml index e8cd2359f7..da4ca83cd6 100644 --- a/.github/workflows/destroy-network.yml +++ b/.github/workflows/destroy-network.yml @@ -116,6 +116,11 @@ jobs: outputs: terraform_output: ${{ steps.terraform_failure.outputs.terraform_output }} steps: + - name: Checkout code + uses: actions/checkout@v4.1.1 + with: + repository: Ethernal-Tech/blade-deployment + ref: changes - name: Configure AWS Credentials uses: aws-actions/configure-aws-credentials@v4.0.1 with: From b228c89110f7d75bc6abbf6ffcb2f13336b3efab Mon Sep 17 00:00:00 2001 From: Branislav Kojic Date: Wed, 7 Feb 2024 10:50:25 +0100 Subject: [PATCH 42/67] Restore data fixes (#43) * Deploy Network * Add Permissions * Minor changes * Concurrency change * Destroy Network * Minor changes * Minor changes * Fix commit sha * Minor changes * Add Tests * Disable Tests temporarily * Nightly Build * Minor fixes * Big changes * Minor changes * Minor changes * Minor changes * Notification fixes * Notification changes * Minor changes * Permissions fixes * Minor changes * Notification changes * Minor changes * Display commit on notifications * Minor changes * Minor fixes * Logs notification fixes * Minor changes * Minor changes * Minor changes * Notifications fixes * Minor changes * Update actions version * Deployment fixes * Minor changes * Minor changes * Build repository fixes * Load Test notification text changes * EIP-1559; Check if the network is already deployed; Restore Blade Data * Notifications fixes; Pass blade_repository when deploying the network * Terraform fixes * Minor changes * Minor changes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Restore data fixes --- .github/workflows/deploy-network.yml | 14 +++++++------- .github/workflows/destroy-network.yml | 2 +- .github/workflows/load-test.yml | 2 +- .github/workflows/tests.yml | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/deploy-network.yml b/.github/workflows/deploy-network.yml index a530daa7a9..6af6cd147a 100644 --- a/.github/workflows/deploy-network.yml +++ b/.github/workflows/deploy-network.yml @@ -160,21 +160,21 @@ jobs: sed 's/devnet/${{ inputs.environment }}/g' inventory/aws_ec2.yml > inventory/aws_ec2.yml.tmp && mv inventory/aws_ec2.yml.tmp inventory/aws_ec2.yml sed 's/blade_tag: .*/blade_tag: ${{ github.sha }}/g' group_vars/all.yml > group_vars/all.yml.tmp && mv group_vars/all.yml.tmp group_vars/all.yml sed 's/INFO/${{ vars.LOG_LEVEL }}/g' roles/blade/templates/blade.service > roles/blade/templates/blade.service.tmp && mv roles/blade/templates/blade.service.tmp roles/blade/templates/blade.service - - name: Check previous blade data - id: previous_data - if: inputs.environment == 'test' - run: echo "previous_data_output=$(aws s3 cp s3://${{ secrets.AWS_S3_BLADE_BUCKET }}/states/${{ inputs.environment }}.data.tar.gz .)" >> $GITHUB_OUTPUT - name: Setup Ansible working-directory: ansible run: | ansible-inventory --graph ansible-galaxy install -r requirements.yml + - name: Check previous blade data + id: previous_data + if: inputs.environment == 'test' + run: echo "previous_data_output=$(aws s3 cp s3://${{ secrets.AWS_S3_BLADE_BUCKET }}/states/${{ inputs.environment }}.data.tar.gz .)" >> $GITHUB_OUTPUT - name: Run Ansible (Bootstrap blade) - if: steps.previous_data.outputs.previous_data_output == '' || contains(steps.previous_data.outputs.previous_data_output, 'error') + if: steps.previous_data.outputs.previous_data_output == '' && contains(steps.previous_data.outputs.previous_data_output, 'error') working-directory: ansible run: ansible-playbook site.yml --extra-vars "clean_deploy_title=${{ inputs.environment }} blade_repository=${{ github.repository }} block_gas_limit=${{ inputs.block_gas_limit }} block_time=${{ inputs.block_time }} is_london_fork_active=${{ inputs.is_london_fork_active }} is_bridge_active=${{ inputs.is_bridge_active }}" - name: Run Ansible (Restore data) - if: steps.previous_data.outputs.previous_data_output != '' && ${{ !contains(steps.previous_data.outputs.previous_data_output, 'error') }} + if: contains(steps.previous_data.outputs.previous_data_output, 'download') working-directory: ansible run: ansible-playbook site.yml --extra-vars "clean_deploy_title=${{ inputs.environment }} blade_repository=${{ github.repository }} block_gas_limit=${{ inputs.block_gas_limit }} block_time=${{ inputs.block_time }} s3_bucket=${{ secrets.AWS_S3_BLADE_BUCKET }} restore_data=true" - name: Ansible Failed @@ -188,7 +188,7 @@ jobs: name: Deploy Notification needs: [check_network, deploy_network] uses: ./.github/workflows/notification-deploy-network.yml - if: inputs.notification != false && needs.check_network.outputs.check_output == 0 + if: (always() && (inputs.notification || true)) with: environment: ${{ inputs.environment }} deploy_network_terraform_output: ${{ needs.deploy_network.outputs.terraform_output }} diff --git a/.github/workflows/destroy-network.yml b/.github/workflows/destroy-network.yml index da4ca83cd6..e42f58c2be 100644 --- a/.github/workflows/destroy-network.yml +++ b/.github/workflows/destroy-network.yml @@ -145,7 +145,7 @@ jobs: name: Network Notifications uses: ./.github/workflows/notification-destroy-network.yml needs: [upload_logs_and_data, destroy_network] - if: inputs.notification != false + if: (always() && (inputs.notification || true)) with: environment: ${{ inputs.environment }} logs: ${{ inputs.logs }} diff --git a/.github/workflows/load-test.yml b/.github/workflows/load-test.yml index 10f78c61f1..48f8c79f9c 100644 --- a/.github/workflows/load-test.yml +++ b/.github/workflows/load-test.yml @@ -207,7 +207,7 @@ jobs: name: Load Test Notification needs: load_test_scenario uses: ./.github/workflows/notification-load-test.yml - if: inputs.notification != false + if: (always() && (inputs.notification || true)) with: environment: ${{ inputs.environment }} scenario: ${{ inputs.scenario }} diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 9cc6b494ed..278a9a668c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -91,7 +91,7 @@ jobs: name: Tests Notification needs: [unit-test, e2e-polybft-test, e2e-legacy-test, property-polybft-test, fuzz-test] uses: ./.github/workflows/notification-tests.yml - if: inputs.notification != false + if: (always() && (inputs.notification || true)) with: unit_test_output: ${{ needs.unit-test.outputs.workflow_output }} e2e_polybft_test_output: ${{ needs.e2e-polybft-test.outputs.workflow_output }} From 159c825efed4a973dda7c867200ab2aeb2eb98cb Mon Sep 17 00:00:00 2001 From: Branislav Kojic Date: Wed, 7 Feb 2024 11:00:28 +0100 Subject: [PATCH 43/67] Fix condition (#44) * Deploy Network * Add Permissions * Minor changes * Concurrency change * Destroy Network * Minor changes * Minor changes * Fix commit sha * Minor changes * Add Tests * Disable Tests temporarily * Nightly Build * Minor fixes * Big changes * Minor changes * Minor changes * Minor changes * Notification fixes * Notification changes * Minor changes * Permissions fixes * Minor changes * Notification changes * Minor changes * Display commit on notifications * Minor changes * Minor fixes * Logs notification fixes * Minor changes * Minor changes * Minor changes * Notifications fixes * Minor changes * Update actions version * Deployment fixes * Minor changes * Minor changes * Build repository fixes * Load Test notification text changes * EIP-1559; Check if the network is already deployed; Restore Blade Data * Notifications fixes; Pass blade_repository when deploying the network * Terraform fixes * Minor changes * Minor changes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Restore data fixes * Fix condition From 0de1616c26490b939669b54d8852ea82af87e521 Mon Sep 17 00:00:00 2001 From: Branislav Kojic Date: Thu, 8 Feb 2024 07:40:34 +0100 Subject: [PATCH 44/67] Minor fixes (#45) * Deploy Network * Add Permissions * Minor changes * Concurrency change * Destroy Network * Minor changes * Minor changes * Fix commit sha * Minor changes * Add Tests * Disable Tests temporarily * Nightly Build * Minor fixes * Big changes * Minor changes * Minor changes * Minor changes * Notification fixes * Notification changes * Minor changes * Permissions fixes * Minor changes * Notification changes * Minor changes * Display commit on notifications * Minor changes * Minor fixes * Logs notification fixes * Minor changes * Minor changes * Minor changes * Notifications fixes * Minor changes * Update actions version * Deployment fixes * Minor changes * Minor changes * Build repository fixes * Load Test notification text changes * EIP-1559; Check if the network is already deployed; Restore Blade Data * Notifications fixes; Pass blade_repository when deploying the network * Terraform fixes * Minor changes * Minor changes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Restore data fixes * Fix condition * Fix the RPC URL when the network is already deployed * Fix the RPC URL when the network is already deployed * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fixed when the network is first time deploying * Fixed upload logs * Fix: null URL if the network is destroyed but the state file exists * Main notification changes * Fix RPC URL; Fix Logs and Data upload * Minor fix * Minor fix * Notification fixes --- .github/workflows/deploy-network.yml | 39 ++++++++++--------- .github/workflows/destroy-network.yml | 27 ++++++++----- .github/workflows/load-test.yml | 6 ++- .../workflows/notification-deploy-network.yml | 4 +- .../notification-destroy-network.yml | 2 +- .github/workflows/notification-main.yml | 2 +- .github/workflows/tests.yml | 6 ++- 7 files changed, 52 insertions(+), 34 deletions(-) diff --git a/.github/workflows/deploy-network.yml b/.github/workflows/deploy-network.yml index 6af6cd147a..029d20adda 100644 --- a/.github/workflows/deploy-network.yml +++ b/.github/workflows/deploy-network.yml @@ -26,6 +26,10 @@ on: # yamllint disable-line rule:truthy description: With Bridge type: boolean default: true + notification: + description: Notification + type: boolean + default: true workflow_call: inputs: environment: @@ -74,37 +78,36 @@ permissions: jobs: check_network: - name: Check if ${{ inputs.environment }} is already deployed + name: Check if the network is already deployed runs-on: ubuntu-latest + environment: ${{ inputs.environment }} outputs: check_output: ${{ steps.check_state_file.outputs.resources }} + rpc_url: ${{ steps.rpc_url.outputs.url }} steps: - name: Checkout code uses: actions/checkout@v4.1.1 - - name: Install jq and aws-cli - run: | - sudo apt-get update - sudo apt-get install jq - sudo apt-get install awscli - name: Configure AWS Credentials uses: aws-actions/configure-aws-credentials@v4.0.1 with: aws-region: ${{ vars.AWS_REGION }} role-to-assume: ${{ secrets.AWS_ROLE_ARN }} - name: Retrieve state file from s3 - run: aws s3 cp s3://${{ secrets.AWS_S3_BLADE_BUCKET }}/states/${{ inputs.environment }} state.json + id: retrieve_state + run: echo "retrieve_state_output=$(aws s3 cp s3://${{ secrets.AWS_S3_BLADE_BUCKET }}/states/${{ inputs.environment }} state.json)" >> $GITHUB_OUTPUT - name: Check state file - if: success() id: check_state_file run: echo "resources=$(cat state.json | jq -r ".resources" | jq length)" >> $GITHUB_OUTPUT + - name: Set RPC URL + id: rpc_url + if: contains(steps.retrieve_state.outputs.retrieve_state_output, 'download') + run: echo "url=$(cat state.json | jq -r '.outputs.aws_lb_ext_domain.value // empty')" >> $GITHUB_OUTPUT deploy_network: - name: Deploy ${{ inputs.environment }} + name: Deploy the network runs-on: ubuntu-latest needs: check_network - if: failure() || needs.check_network.outputs.check_output == 0 - environment: - name: ${{ inputs.environment }} - url: ${{ steps.rpc_url.outputs.url }} + if: needs.check_network.outputs.check_output == 0 + environment: ${{ inputs.environment }} outputs: terraform_output: ${{ steps.terraform_failure.outputs.terraform_output }} ansible_output: ${{ steps.ansible_failure.outputs.ansible_output }} @@ -124,7 +127,7 @@ jobs: uses: hashicorp/setup-terraform@v3 with: terraform_version: 1.4.5 - - name: Configure Terraform for ${{ inputs.environment }} + - name: Configure Terraform run: sed 's/# backend "s3" {}/backend "s3" {}/' main.tf > main.tf.tmp && mv main.tf.tmp main.tf - name: Terraform Init run: terraform init -backend-config="bucket=${{ secrets.AWS_S3_BLADE_BUCKET }}" -backend-config="key=states/${{ inputs.environment }}" -backend-config="region=${{ vars.AWS_REGION }}" @@ -153,7 +156,7 @@ jobs: run: | python3 -m pip install --user ansible python3 -m pip install boto3 botocore - - name: Configure Ansible for ${{ inputs.environment }} + - name: Configure Ansible working-directory: ansible run: | echo "${{ secrets.VAULT_PASSWORD }}" > password.txt @@ -183,16 +186,16 @@ jobs: run: echo "ansible_output=false" >> $GITHUB_OUTPUT - name: Set RPC URL id: rpc_url - run: echo "url=http://$(terraform output -raw aws_lb_ext_domain | grep -o -E '^ext[^:]*')" >> $GITHUB_OUTPUT + run: echo "url=$(terraform output -raw aws_lb_ext_domain | grep -o -E '^ext[^:]*')" >> $GITHUB_OUTPUT notification: name: Deploy Notification needs: [check_network, deploy_network] uses: ./.github/workflows/notification-deploy-network.yml - if: (always() && (inputs.notification || true)) + if: (always() && inputs.notification == true) with: environment: ${{ inputs.environment }} deploy_network_terraform_output: ${{ needs.deploy_network.outputs.terraform_output }} deploy_network_ansible_output: ${{ needs.deploy_network.outputs.ansible_output }} - rpc_url: ${{ needs.deploy_network.outputs.rpc_url }} + rpc_url: ${{ needs.check_network.outputs.rpc_url || needs.deploy_network.outputs.rpc_url }} secrets: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} diff --git a/.github/workflows/destroy-network.yml b/.github/workflows/destroy-network.yml index e42f58c2be..3a609e8203 100644 --- a/.github/workflows/destroy-network.yml +++ b/.github/workflows/destroy-network.yml @@ -12,6 +12,10 @@ on: # yamllint disable-line rule:truthy description: Upload Logs type: boolean default: false + notification: + description: Notification + type: boolean + default: true workflow_call: inputs: environment: @@ -69,12 +73,16 @@ jobs: uses: hashicorp/setup-terraform@v3 with: terraform_version: 1.4.5 - - name: Configure Terraform for ${{ inputs.environment }} + - name: Configure Terraform run: sed 's/# backend "s3" {}/backend "s3" {}/' main.tf > main.tf.tmp && mv main.tf.tmp main.tf - name: Terraform Init id: init run: terraform init -backend-config="bucket=${{ secrets.AWS_S3_BLADE_BUCKET }}" -backend-config="key=states/${{ inputs.environment }}" -backend-config="region=${{ vars.AWS_REGION }}" + - name: Check if the network is already deployed + id: check_network + run: echo "pk_output=$(terraform output -json | jq -r '.pk_ansible.value // empty' | wc -c | tr -d ' ')" >> $GITHUB_OUTPUT - name: Configure private keys + if: steps.check_network.outputs.pk_output != 0 run: | terraform output pk_ansible > ~/private.key chmod 600 ~/private.key @@ -84,23 +92,22 @@ jobs: run: | python3 -m pip install --user ansible python3 -m pip install boto3 botocore - - name: Configure Ansible for ${{ inputs.environment }} + - name: Configure Ansible working-directory: ansible run: | echo "${{ secrets.VAULT_PASSWORD }}" > password.txt sed 's/devnet/${{ inputs.environment }}/g' inventory/aws_ec2.yml > inventory/aws_ec2.yml.tmp && mv inventory/aws_ec2.yml.tmp inventory/aws_ec2.yml - sed 's/devnet/${{ inputs.environment }}/g' roles/upload-logs/tasks/logs.yml > roles/upload-logs/tasks/logs.yml.tmp && mv roles/upload-logs/tasks/logs.yml.tmp roles/upload-logs/tasks/logs.yml - sed 's/{{ current_datetime\.stdout }}/${{ github.run_id }}/g' roles/upload-logs/tasks/logs.yml > roles/upload-logs/tasks/logs.yml.tmp && mv roles/upload-logs/tasks/logs.yml.tmp roles/upload-logs/tasks/logs.yml + sed 's/{{ current_datetime\.stdout }}/${{ github.run_id }}/g' roles/upload-logs/tasks/main.yml > roles/upload-logs/tasks/main.yml.tmp && mv roles/upload-logs/tasks/main.yml.tmp roles/upload-logs/tasks/main.yml - name: Upload Logs - if: inputs.logs == true + if: (steps.check_network.outputs.pk_output != 0 && inputs.logs == true) working-directory: ansible - run: ansible-playbook upload-logs.yml --extra-vars "clean_deploy_title=${{ inputs.environment }}" + run: ansible-playbook upload-logs.yml --extra-vars "clean_deploy_title=${{ inputs.environment }} s3_bucket=${{ secrets.AWS_S3_BLADE_BUCKET }}" - name: Logs Failed if: failure() id: logs_failure run: echo "logs_output=false" >> $GITHUB_OUTPUT - name: Upload Data - if: inputs.environment == 'test' + if: (always() && steps.check_network.outputs.pk_output != 0 && inputs.environment == 'test') working-directory: ansible run: ansible-playbook upload-data.yml --extra-vars "clean_deploy_title=${{ inputs.environment }} s3_bucket=${{ secrets.AWS_S3_BLADE_BUCKET }}" - name: Data Failed @@ -108,7 +115,7 @@ jobs: id: data_failure run: echo "data_output=false" >> $GITHUB_OUTPUT destroy_network: - name: Destroy ${{ inputs.environment }} + name: Destroy the network runs-on: ubuntu-latest environment: ${{ inputs.environment }} needs: upload_logs_and_data @@ -130,7 +137,7 @@ jobs: uses: hashicorp/setup-terraform@v3 with: terraform_version: 1.4.5 - - name: Configure Terraform for ${{ inputs.environment }} + - name: Configure Terraform run: sed 's/# backend "s3" {}/backend "s3" {}/' main.tf > main.tf.tmp && mv main.tf.tmp main.tf - name: Terraform Init id: init @@ -145,7 +152,7 @@ jobs: name: Network Notifications uses: ./.github/workflows/notification-destroy-network.yml needs: [upload_logs_and_data, destroy_network] - if: (always() && (inputs.notification || true)) + if: (always() && inputs.notification == true) with: environment: ${{ inputs.environment }} logs: ${{ inputs.logs }} diff --git a/.github/workflows/load-test.yml b/.github/workflows/load-test.yml index 48f8c79f9c..347cf3ba35 100644 --- a/.github/workflows/load-test.yml +++ b/.github/workflows/load-test.yml @@ -42,6 +42,10 @@ on: # yamllint disable-line rule:truthy type: string default: "60" required: true + notification: + description: Notification + type: boolean + default: true workflow_call: inputs: environment: @@ -207,7 +211,7 @@ jobs: name: Load Test Notification needs: load_test_scenario uses: ./.github/workflows/notification-load-test.yml - if: (always() && (inputs.notification || true)) + if: (always() && inputs.notification == true) with: environment: ${{ inputs.environment }} scenario: ${{ inputs.scenario }} diff --git a/.github/workflows/notification-deploy-network.yml b/.github/workflows/notification-deploy-network.yml index 0014342412..f3f366db42 100644 --- a/.github/workflows/notification-deploy-network.yml +++ b/.github/workflows/notification-deploy-network.yml @@ -51,7 +51,7 @@ jobs: "type": "header", "text": { "type": "plain_text", - "text": "Deploy ${{ inputs.environment }}" + "text": "Deploy ${{ inputs.environment }}net" } }, { @@ -99,7 +99,7 @@ jobs: "type": "plain_text", "text": "JSON-RPC" }, - "url": "${{ inputs.rpc_url }}" + "url": "http://${{ inputs.rpc_url }}" } ] } diff --git a/.github/workflows/notification-destroy-network.yml b/.github/workflows/notification-destroy-network.yml index 4a6fbc3493..64a9ffdc7b 100644 --- a/.github/workflows/notification-destroy-network.yml +++ b/.github/workflows/notification-destroy-network.yml @@ -51,7 +51,7 @@ jobs: "type": "header", "text": { "type": "plain_text", - "text": "Destroy ${{ inputs.environment }}" + "text": "Destroy ${{ inputs.environment }}net" } }, { diff --git a/.github/workflows/notification-main.yml b/.github/workflows/notification-main.yml index 108df67302..e600282fd7 100644 --- a/.github/workflows/notification-main.yml +++ b/.github/workflows/notification-main.yml @@ -93,7 +93,7 @@ jobs: "type": "header", "text": { "type": "plain_text", - "text": "Build: ${{ inputs.environment }}" + "text": "${{ inputs.environment }} build" } }, { diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 278a9a668c..16feb76db9 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -23,6 +23,10 @@ on: # yamllint disable-line rule:truthy description: Fuzz Tests type: boolean default: true + notification: + description: Notification + type: boolean + default: true workflow_call: inputs: unit-test: @@ -91,7 +95,7 @@ jobs: name: Tests Notification needs: [unit-test, e2e-polybft-test, e2e-legacy-test, property-polybft-test, fuzz-test] uses: ./.github/workflows/notification-tests.yml - if: (always() && (inputs.notification || true)) + if: (always() && inputs.notification == true) with: unit_test_output: ${{ needs.unit-test.outputs.workflow_output }} e2e_polybft_test_output: ${{ needs.e2e-polybft-test.outputs.workflow_output }} From 792d39a57af0ad4ef1c8eeae724df1c9ba9a7cbd Mon Sep 17 00:00:00 2001 From: Branislav Kojic Date: Thu, 8 Feb 2024 09:49:35 +0100 Subject: [PATCH 45/67] Final changes (#46) * Deploy Network * Add Permissions * Minor changes * Concurrency change * Destroy Network * Minor changes * Minor changes * Fix commit sha * Minor changes * Add Tests * Disable Tests temporarily * Nightly Build * Minor fixes * Big changes * Minor changes * Minor changes * Minor changes * Notification fixes * Notification changes * Minor changes * Permissions fixes * Minor changes * Notification changes * Minor changes * Display commit on notifications * Minor changes * Minor fixes * Logs notification fixes * Minor changes * Minor changes * Minor changes * Notifications fixes * Minor changes * Update actions version * Deployment fixes * Minor changes * Minor changes * Build repository fixes * Load Test notification text changes * EIP-1559; Check if the network is already deployed; Restore Blade Data * Notifications fixes; Pass blade_repository when deploying the network * Terraform fixes * Minor changes * Minor changes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Restore data fixes * Fix condition * Fix the RPC URL when the network is already deployed * Fix the RPC URL when the network is already deployed * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fixed when the network is first time deploying * Fixed upload logs * Fix: null URL if the network is destroyed but the state file exists * Main notification changes * Fix RPC URL; Fix Logs and Data upload * Minor fix * Minor fix * Notification fixes * Deploy fixes * Big changes --- .github/dependabot.yml | 15 +++++ .github/issue_template.md | 30 +++++++++ .github/pull_request_template.md | 39 ++++++++++++ .github/workflows/build.yml | 3 - .github/workflows/cla.yml | 27 ++++++++ .github/workflows/deploy-network.yml | 5 +- .github/workflows/destroy-network.yml | 10 +-- .github/workflows/e2e-legacy-test.yml | 8 --- .github/workflows/e2e-polybft-test.yml | 8 --- .github/workflows/fuzz-test.yml | 7 --- .github/workflows/lint.yml | 20 ++++++ .github/workflows/load-test.yml | 2 +- .github/workflows/nightly.yml | 14 ++--- .../notification-destroy-network.yml | 4 +- .github/workflows/notification-main.yml | 10 +-- .github/workflows/property-polybft-test.yml | 7 --- .github/workflows/release.yml | 62 +++++++++++++++++++ .github/workflows/tests.yml | 49 ++++++++++++--- .github/workflows/unit-test.yml | 1 - 19 files changed, 256 insertions(+), 65 deletions(-) create mode 100644 .github/dependabot.yml create mode 100644 .github/issue_template.md create mode 100644 .github/pull_request_template.md create mode 100644 .github/workflows/cla.yml create mode 100644 .github/workflows/lint.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000000..2d4f711a31 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,15 @@ +version: 2 +updates: + - package-ecosystem: gomod + directory: / + target-branch: "develop" + schedule: + interval: monthly + ignore: + - dependency-name: "github.com/aws/aws-sdk-go" + update-types: [ "version-update:semver-patch" ] + open-pull-requests-limit: 20 + pull-request-branch-name: + separator: "-" + reviewers: + - "Ethernal-Tech/blade-devs" diff --git a/.github/issue_template.md b/.github/issue_template.md new file mode 100644 index 0000000000..9ab09bbe93 --- /dev/null +++ b/.github/issue_template.md @@ -0,0 +1,30 @@ +# [ Subject of the issue ] +## Description +Describe your issue in as much detail as possible here. + +## Your environment +- OS and version. +- The version of the Polygon Edge. + (*Confirm the version of your Polygon edge client by running the following command: `polygon-edge version --grpc-address GRPC_ADDRESS`*) +- The branch that causes this issue. +- Locally or Cloud hosted (which provider). +- Please confirm if the validators are running under containerized environment (K8s, Docker, etc.). + +## Steps to reproduce +- Tell us how to reproduce this issue. +- Where the issue is, if you know. +- Which commands triggered the issue, if any. +- Provide us with the content of your genesis file. +- Provide us with commands that you used to start your validators. +- Provide us with the peer list of each of your validators by running the following command: `polygon-edge peers list --grpc-address GRPC_ADDRESS`. +- Is the chain producing blocks and serving customers atm? + +## Expected behavior +- Tell us what should happen. +- Tell us what happened instead. + +## Logs +Provide us with debug logs from all of your validators by setting logging to `debug` output with: `server --log-level debug` + +## Proposed solution +If you have an idea on how to fix this issue, please write it down here, so we can begin discussing it diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000000..8038dfd032 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,39 @@ +# Description + +Please provide a detailed description of what was done in this PR + +# Changes include + +- [ ] Bugfix (non-breaking change that solves an issue) +- [ ] Hotfix (change that solves an urgent issue, and requires immediate attention) +- [ ] New feature (non-breaking change that adds functionality) +- [ ] Breaking change (change that is not backwards-compatible and/or changes current functionality) + +# Breaking changes + +Please complete this section if any breaking changes have been made, otherwise delete it + +# Checklist + +- [ ] I have assigned this PR to myself +- [ ] I have added at least 1 reviewer +- [ ] I have added the relevant labels +- [ ] I have updated the official documentation +- [ ] I have added sufficient documentation in code + +## Testing + +- [ ] I have tested this code with the official test suite +- [ ] I have tested this code manually + +### Manual tests + +Please complete this section if you ran manual tests for this functionality, otherwise delete it + +# Documentation update + +Please link the documentation update PR in this section if it's present, otherwise delete it + +# Additional comments + +Please post additional comments in this section if you have them, otherwise delete it diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0a412ea24d..4163da6954 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,7 +1,6 @@ --- name: Build Blade on: # yamllint disable-line rule:truthy - workflow_dispatch: workflow_call: # Map the workflow outputs to job outputs outputs: @@ -22,7 +21,6 @@ jobs: uses: actions/setup-go@v5 with: go-version: 1.20.x - cache: false - name: Build Blade run: go build -o blade -tags netgo -ldflags="-s -w -X \"github.com/${GITHUB_REPOSITORY}/versioning.Version=${GITHUB_REF_NAME}\" -X \"github.com/${GITHUB_REPOSITORY}/versioning.Commit=${GITHUB_SHA}\"" && tar -czvf blade.tar.gz blade env: @@ -49,7 +47,6 @@ jobs: uses: actions/setup-go@v5 with: go-version: 1.20.x - cache: false - name: Reproduce builds continue-on-error: true run: | diff --git a/.github/workflows/cla.yml b/.github/workflows/cla.yml new file mode 100644 index 0000000000..9e43327c7a --- /dev/null +++ b/.github/workflows/cla.yml @@ -0,0 +1,27 @@ +--- +name: CLA Assistant +on: # yamllint disable-line rule:truthy + issue_comment: + types: + - created + pull_request_target: + types: + - opened + - synchronize + +jobs: + cla-assistant: + runs-on: ubuntu-latest + steps: + - name: "Check CLA" + if: (github.event.comment.body == 'recheck' || github.event.comment.body == 'I have read the CLA Document and I hereby sign the CLA') || github.event_name == 'pull_request_target' + uses: contributor-assistant/github-action@v2.3.1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # the below token should have repo scope and must be manually added by you in the repository's secret + PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} + with: + path-to-signatures: "cla.json" + path-to-document: "https://github.com/Ethernal-Tech/blade/blob/develop/CLA.md" + branch: "cla-signatures" + allowlist: dependabot[bot],dependabot-preview[bot] diff --git a/.github/workflows/deploy-network.yml b/.github/workflows/deploy-network.yml index 029d20adda..f110483d2b 100644 --- a/.github/workflows/deploy-network.yml +++ b/.github/workflows/deploy-network.yml @@ -170,10 +170,9 @@ jobs: ansible-galaxy install -r requirements.yml - name: Check previous blade data id: previous_data - if: inputs.environment == 'test' run: echo "previous_data_output=$(aws s3 cp s3://${{ secrets.AWS_S3_BLADE_BUCKET }}/states/${{ inputs.environment }}.data.tar.gz .)" >> $GITHUB_OUTPUT - name: Run Ansible (Bootstrap blade) - if: steps.previous_data.outputs.previous_data_output == '' && contains(steps.previous_data.outputs.previous_data_output, 'error') + if: contains(steps.previous_data.outputs.previous_data_output, 'error') working-directory: ansible run: ansible-playbook site.yml --extra-vars "clean_deploy_title=${{ inputs.environment }} blade_repository=${{ github.repository }} block_gas_limit=${{ inputs.block_gas_limit }} block_time=${{ inputs.block_time }} is_london_fork_active=${{ inputs.is_london_fork_active }} is_bridge_active=${{ inputs.is_bridge_active }}" - name: Run Ansible (Restore data) @@ -191,7 +190,7 @@ jobs: name: Deploy Notification needs: [check_network, deploy_network] uses: ./.github/workflows/notification-deploy-network.yml - if: (always() && inputs.notification == true) + if: (always() && inputs.notification) with: environment: ${{ inputs.environment }} deploy_network_terraform_output: ${{ needs.deploy_network.outputs.terraform_output }} diff --git a/.github/workflows/destroy-network.yml b/.github/workflows/destroy-network.yml index 3a609e8203..7a8b9bd66e 100644 --- a/.github/workflows/destroy-network.yml +++ b/.github/workflows/destroy-network.yml @@ -55,7 +55,7 @@ jobs: name: Upload Logs and Data runs-on: ubuntu-latest environment: ${{ inputs.environment }} - if: inputs.logs == true || inputs.environment == 'test' + if: (inputs.logs || inputs.environment == 'test') outputs: logs_output: ${{ steps.logs_failure.outputs.logs_output }} steps: @@ -82,7 +82,7 @@ jobs: id: check_network run: echo "pk_output=$(terraform output -json | jq -r '.pk_ansible.value // empty' | wc -c | tr -d ' ')" >> $GITHUB_OUTPUT - name: Configure private keys - if: steps.check_network.outputs.pk_output != 0 + if: steps.check_network.outputs.pk_output > 0 run: | terraform output pk_ansible > ~/private.key chmod 600 ~/private.key @@ -99,7 +99,7 @@ jobs: sed 's/devnet/${{ inputs.environment }}/g' inventory/aws_ec2.yml > inventory/aws_ec2.yml.tmp && mv inventory/aws_ec2.yml.tmp inventory/aws_ec2.yml sed 's/{{ current_datetime\.stdout }}/${{ github.run_id }}/g' roles/upload-logs/tasks/main.yml > roles/upload-logs/tasks/main.yml.tmp && mv roles/upload-logs/tasks/main.yml.tmp roles/upload-logs/tasks/main.yml - name: Upload Logs - if: (steps.check_network.outputs.pk_output != 0 && inputs.logs == true) + if: (steps.check_network.outputs.pk_output > 0 && inputs.logs) working-directory: ansible run: ansible-playbook upload-logs.yml --extra-vars "clean_deploy_title=${{ inputs.environment }} s3_bucket=${{ secrets.AWS_S3_BLADE_BUCKET }}" - name: Logs Failed @@ -107,7 +107,7 @@ jobs: id: logs_failure run: echo "logs_output=false" >> $GITHUB_OUTPUT - name: Upload Data - if: (always() && steps.check_network.outputs.pk_output != 0 && inputs.environment == 'test') + if: (always() && steps.check_network.outputs.pk_output > 0 && inputs.environment == 'test') working-directory: ansible run: ansible-playbook upload-data.yml --extra-vars "clean_deploy_title=${{ inputs.environment }} s3_bucket=${{ secrets.AWS_S3_BLADE_BUCKET }}" - name: Data Failed @@ -152,7 +152,7 @@ jobs: name: Network Notifications uses: ./.github/workflows/notification-destroy-network.yml needs: [upload_logs_and_data, destroy_network] - if: (always() && inputs.notification == true) + if: (always() && inputs.notification) with: environment: ${{ inputs.environment }} logs: ${{ inputs.logs }} diff --git a/.github/workflows/e2e-legacy-test.yml b/.github/workflows/e2e-legacy-test.yml index 29f30b1e56..f299697082 100644 --- a/.github/workflows/e2e-legacy-test.yml +++ b/.github/workflows/e2e-legacy-test.yml @@ -1,14 +1,7 @@ --- name: E2E Legacy Tests on: # yamllint disable-line rule:truthy - # push: - # branches: - # - main - # - develop - # pull_request: - workflow_dispatch: workflow_call: - # Map the workflow outputs to job outputs outputs: workflow_output: description: "E2E Legacy Tests output" @@ -33,7 +26,6 @@ jobs: uses: actions/setup-go@v5 with: go-version: 1.20.x - cache: false - name: Run tests run: make test-e2e-legacy - name: Run tests failed diff --git a/.github/workflows/e2e-polybft-test.yml b/.github/workflows/e2e-polybft-test.yml index ad26c46545..1ccac84719 100644 --- a/.github/workflows/e2e-polybft-test.yml +++ b/.github/workflows/e2e-polybft-test.yml @@ -1,14 +1,7 @@ --- name: E2E PolyBFT Tests on: # yamllint disable-line rule:truthy - # push: - # branches: - # - main - # - develop - # pull_request: - workflow_dispatch: workflow_call: - # Map the workflow outputs to job outputs outputs: workflow_output: description: "E2E PolyBFT Tests output" @@ -32,7 +25,6 @@ jobs: with: go-version: 1.20.x check-latest: true - cache: false - name: Run tests run: make test-e2e-polybft - name: Run tests failed diff --git a/.github/workflows/fuzz-test.yml b/.github/workflows/fuzz-test.yml index 12095fd743..ad9ceb2673 100644 --- a/.github/workflows/fuzz-test.yml +++ b/.github/workflows/fuzz-test.yml @@ -1,13 +1,7 @@ --- name: Fuzz Tests on: # yamllint disable-line rule:truthy - # push: - # branches: - # - main - # - develop - workflow_dispatch: workflow_call: - # Map the workflow outputs to job outputs outputs: workflow_output: description: "Fuzz Tests output" @@ -24,7 +18,6 @@ jobs: uses: actions/setup-go@v5 with: go-version: 1.20.x - cache: false - name: Checkout Code uses: actions/checkout@v4.1.1 - name: Run Fuzz Test diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000000..f0cece84f1 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,20 @@ +--- +name: Lint +on: # yamllint disable-line rule:truthy + workflow_call: {} + +jobs: + golangci_lint: + name: Linter + runs-on: ubuntu-latest + steps: + - name: Install Go + uses: actions/setup-go@v5 + with: + go-version: 1.20.x + - name: Checkout code + uses: actions/checkout@v4.1.1 + - name: Lint + uses: golangci/golangci-lint-action@v3 + with: + args: --timeout 10m --verbose diff --git a/.github/workflows/load-test.yml b/.github/workflows/load-test.yml index 347cf3ba35..ab49e53e83 100644 --- a/.github/workflows/load-test.yml +++ b/.github/workflows/load-test.yml @@ -211,7 +211,7 @@ jobs: name: Load Test Notification needs: load_test_scenario uses: ./.github/workflows/notification-load-test.yml - if: (always() && inputs.notification == true) + if: (always() && inputs.notification) with: environment: ${{ inputs.environment }} scenario: ${{ inputs.scenario }} diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 490b75178d..8e975974ee 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -18,16 +18,14 @@ jobs: - name: Get new commits id: get_new_commits run: echo "commit_count=$(git log --oneline --since '24 hours ago' | wc -l | tr -d ' ')" >> $GITHUB_OUTPUT - build: - name: Build Blade - uses: ./.github/workflows/build.yml - needs: check - if: needs.check.outputs.new_commit_count > 0 tests: name: Tests uses: ./.github/workflows/tests.yml - needs: build + needs: check + if: needs.check.outputs.new_commit_count > 0 with: + build-blade: true + lint: false unit-test: true e2e-polybft-test: true e2e-legacy-test: true @@ -112,12 +110,12 @@ jobs: notification_main: name: Nightly Notification uses: ./.github/workflows/notification-main.yml - needs: [build, tests, deploy_network, load_test_multiple_eoa, load_test_multiple_erc20, destroy_network] + needs: [tests, deploy_network, load_test_multiple_eoa, load_test_multiple_erc20, destroy_network] if: success() || failure() with: environment: nightly logs: true - build_output: ${{ needs.build.outputs.workflow_output }} + build_blade_output: ${{ needs.tests.outputs.build-blade }} unit_test_output: ${{ needs.tests.outputs.unit-test }} e2e_polybft_test_output: ${{ needs.tests.outputs.e2e-polybft-test }} e2e_legacy_test_output: ${{ needs.tests.outputs.e2e-legacy-test }} diff --git a/.github/workflows/notification-destroy-network.yml b/.github/workflows/notification-destroy-network.yml index 64a9ffdc7b..17ab05558f 100644 --- a/.github/workflows/notification-destroy-network.yml +++ b/.github/workflows/notification-destroy-network.yml @@ -88,9 +88,9 @@ jobs: "type": "button", "text": { "type": "plain_text", - "text": "${{ inputs.logs == true && inputs.destroy_network_upload_logs == '' && 'Logs' || 'No Logs' }}" + "text": "${{ inputs.logs && inputs.destroy_network_upload_logs == '' && 'Logs' || 'No Logs' }}" }, - "style": "${{ inputs.logs == true && inputs.destroy_network_upload_logs == '' && env.succeed_bnt || env.failed_bnt }}", + "style": "${{ inputs.logs && inputs.destroy_network_upload_logs == '' && env.succeed_bnt || env.failed_bnt }}", "url": "https://s3.console.aws.amazon.com/s3/buckets/${{ secrets.AWS_S3_BLADE_BUCKET }}?region=${{ vars.AWS_REGION }}&prefix=logs/${{ github.run_id }}/" } ] diff --git a/.github/workflows/notification-main.yml b/.github/workflows/notification-main.yml index e600282fd7..6c427e0f6b 100644 --- a/.github/workflows/notification-main.yml +++ b/.github/workflows/notification-main.yml @@ -11,8 +11,8 @@ on: # yamllint disable-line rule:truthy description: Upload Logs type: string required: true - build_output: - description: Build output + build_blade_output: + description: Build Blade output type: string required: true unit_test_output: @@ -87,7 +87,7 @@ jobs: { "attachments": [ { - "color": "${{ inputs.build_output == '' && inputs.unit_test_output == '' && inputs.e2e_polybft_test_output == '' && inputs.e2e_legacy_test_output == '' && inputs.property_polybft_test_output == '' && inputs.fuzz_test_output == '' && inputs.deploy_network_terraform_output == '' && inputs.deploy_network_ansible_output == '' && inputs.load_test_multiple_eoa_output == 'true' && inputs.load_test_multiple_erc20_output == 'true' && inputs.destroy_network_logs_output == '' && inputs.destroy_network_terraform_output == '' && env.green_color || env.red_color }}", + "color": "${{ inputs.build_blade_output == '' && inputs.unit_test_output == '' && inputs.e2e_polybft_test_output == '' && inputs.e2e_legacy_test_output == '' && inputs.property_polybft_test_output == '' && inputs.fuzz_test_output == '' && inputs.deploy_network_terraform_output == '' && inputs.deploy_network_ansible_output == '' && inputs.load_test_multiple_eoa_output == 'true' && inputs.load_test_multiple_erc20_output == 'true' && inputs.destroy_network_logs_output == '' && inputs.destroy_network_terraform_output == '' && env.green_color || env.red_color }}", "blocks": [ { "type": "header", @@ -132,7 +132,7 @@ jobs: "type": "plain_text", "text": "Workflow Run" }, - "style": "${{ inputs.build_output == '' && inputs.unit_test_output == '' && inputs.e2e_polybft_test_output == '' && inputs.e2e_legacy_test_output == '' && inputs.property_polybft_test_output == '' && inputs.fuzz_test_output == '' && inputs.deploy_network_terraform_output == '' && inputs.deploy_network_ansible_output == '' && inputs.load_test_multiple_eoa_output == 'true' && inputs.load_test_multiple_erc20_output == 'true' && inputs.destroy_network_logs_output == '' && inputs.destroy_network_terraform_output == '' && env.succeed_bnt || env.failed_bnt }}", + "style": "${{ inputs.build_blade_output == '' && inputs.unit_test_output == '' && inputs.e2e_polybft_test_output == '' && inputs.e2e_legacy_test_output == '' && inputs.property_polybft_test_output == '' && inputs.fuzz_test_output == '' && inputs.deploy_network_terraform_output == '' && inputs.deploy_network_ansible_output == '' && inputs.load_test_multiple_eoa_output == 'true' && inputs.load_test_multiple_erc20_output == 'true' && inputs.destroy_network_logs_output == '' && inputs.destroy_network_terraform_output == '' && env.succeed_bnt || env.failed_bnt }}", "url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" }, { @@ -149,7 +149,7 @@ jobs: ] }, { - "color": "${{ inputs.build_output == '' && env.green_color || env.red_color }}", + "color": "${{ inputs.build_blade_output == '' && env.green_color || env.red_color }}", "blocks": [ { "type": "section", diff --git a/.github/workflows/property-polybft-test.yml b/.github/workflows/property-polybft-test.yml index 2fd46ced13..9e8146f5ac 100644 --- a/.github/workflows/property-polybft-test.yml +++ b/.github/workflows/property-polybft-test.yml @@ -1,13 +1,7 @@ --- name: Property PolyBFT Tests on: # yamllint disable-line rule:truthy - # push: - # branches: - # - main - # - develop - workflow_dispatch: workflow_call: - # Map the workflow outputs to job outputs outputs: workflow_output: description: "Property PolyBFT Tests output" @@ -30,7 +24,6 @@ jobs: uses: actions/setup-go@v5 with: go-version: 1.20.x - cache: false - name: Run tests run: make test-property-polybft - name: Run tests failed diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000000..ab3b3be8d6 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,62 @@ +--- +name: Release +on: # yamllint disable-line rule:truthy + push: + branches-ignore: + - '**' + tags: + - 'v*.*.*' + # to be used by fork patch-releases ^^ + - 'v*.*.*-*' + +jobs: + goreleaser: + runs-on: ubuntu-latest + env: + DOCKER_CONFIG: $HOME/.docker + steps: + - name: Checkout + uses: actions/checkout@v4.1.1 + with: + fetch-depth: 0 + + - name: Set up Go + uses: actions/setup-go@v5.0.0 + with: + go-version: 1.20.x + + - name: Prepare + id: prepare + run: | + TAG=${GITHUB_REF#refs/tags/} + echo tag_name=${TAG} >> $GITHUB_OUTPUT + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Login to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Run GoReleaser + run: | + docker run \ + --rm \ + --privileged \ + -e CGO_ENABLED=1 \ + -e GITHUB_TOKEN \ + -e SLACK_WEBHOOK \ + -e DOCKER_CONFIG \ + -v /var/run/docker.sock:/var/run/docker.sock \ + -v `pwd`:/go/src/$(PACKAGE_NAME) \ + -w /go/src/$(PACKAGE_NAME) \ + ghcr.io/goreleaser/goreleaser-cross:${GOLANG_CROSS_VERSION} \ + --rm-dist --skip-validate + env: + PACKAGE_NAME: github.com/Ethernal-Tech/blade + GOLANG_CROSS_VERSION: v1.20.5 + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + VERSION: ${{ steps.prepare.outputs.tag_name }} + SLACK_WEBHOOK: ${{ secrets.SLACK_BLADE_GITHUB_URL }} diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 16feb76db9..46736410f0 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,8 +1,21 @@ --- name: Tests on: # yamllint disable-line rule:truthy + push: + branches: + - main + - develop + pull_request: workflow_dispatch: inputs: + build-blade: + description: Build Blade + type: boolean + default: true + lint: + description: Lint + type: boolean + default: true unit-test: description: Unit Tests type: boolean @@ -26,9 +39,19 @@ on: # yamllint disable-line rule:truthy notification: description: Notification type: boolean - default: true + default: false workflow_call: inputs: + build-blade: + description: Build Blade + type: boolean + default: true + required: true + lint: + description: Lint + type: boolean + default: false + required: true unit-test: description: Unit Tests type: boolean @@ -53,7 +76,11 @@ on: # yamllint disable-line rule:truthy description: Notification type: boolean required: true + default: false outputs: + build-blade: + description: Build Blade output + value: ${{ jobs.build-blade.outputs.workflow_output }} unit-test: description: Unit Tests output value: ${{ jobs.unit-test.outputs.workflow_output }} @@ -71,31 +98,39 @@ on: # yamllint disable-line rule:truthy value: ${{ jobs.fuzz-test.outputs.workflow_output }} jobs: + build-blade: + name: Build Blade + uses: ./.github/workflows/build.yml + if: inputs.build-blade + lint: + name: Lint + uses: ./.github/workflows/lint.yml + if: inputs.lint unit-test: name: Unit Tests uses: ./.github/workflows/unit-test.yml - if: inputs.unit-test == true + if: inputs.unit-test e2e-polybft-test: name: E2E PolyBFT Tests uses: ./.github/workflows/e2e-polybft-test.yml - if: inputs.e2e-polybft-test == true + if: inputs.e2e-polybft-test e2e-legacy-test: name: E2E Legacy Tests uses: ./.github/workflows/e2e-legacy-test.yml - if: inputs.e2e-legacy-test == true + if: inputs.e2e-legacy-test property-polybft-test: name: Property PolyBFT Tests uses: ./.github/workflows/property-polybft-test.yml - if: inputs.property-polybft-test == true + if: inputs.property-polybft-test fuzz-test: name: Fuzz Tests uses: ./.github/workflows/fuzz-test.yml - if: inputs.fuzz-test == true + if: inputs.fuzz-test notification: name: Tests Notification needs: [unit-test, e2e-polybft-test, e2e-legacy-test, property-polybft-test, fuzz-test] uses: ./.github/workflows/notification-tests.yml - if: (always() && inputs.notification == true) + if: (always() && inputs.notification) with: unit_test_output: ${{ needs.unit-test.outputs.workflow_output }} e2e_polybft_test_output: ${{ needs.e2e-polybft-test.outputs.workflow_output }} diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index 83d3ad48e2..75dbcce632 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -20,7 +20,6 @@ jobs: uses: actions/setup-go@v5 with: go-version: 1.20.x - cache: false - name: Checkout Code uses: actions/checkout@v4.1.1 with: From f65ce98382f0610c557e166011d5538c5e55611e Mon Sep 17 00:00:00 2001 From: Branislav Kojic Date: Thu, 8 Feb 2024 11:33:34 +0100 Subject: [PATCH 46/67] Minor fixes (#47) * Deploy Network * Add Permissions * Minor changes * Concurrency change * Destroy Network * Minor changes * Minor changes * Fix commit sha * Minor changes * Add Tests * Disable Tests temporarily * Nightly Build * Minor fixes * Big changes * Minor changes * Minor changes * Minor changes * Notification fixes * Notification changes * Minor changes * Permissions fixes * Minor changes * Notification changes * Minor changes * Display commit on notifications * Minor changes * Minor fixes * Logs notification fixes * Minor changes * Minor changes * Minor changes * Notifications fixes * Minor changes * Update actions version * Deployment fixes * Minor changes * Minor changes * Build repository fixes * Load Test notification text changes * EIP-1559; Check if the network is already deployed; Restore Blade Data * Notifications fixes; Pass blade_repository when deploying the network * Terraform fixes * Minor changes * Minor changes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Restore data fixes * Fix condition * Fix the RPC URL when the network is already deployed * Fix the RPC URL when the network is already deployed * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fixed when the network is first time deploying * Fixed upload logs * Fix: null URL if the network is destroyed but the state file exists * Main notification changes * Fix RPC URL; Fix Logs and Data upload * Minor fix * Minor fix * Notification fixes * Deploy fixes * Big changes * Condition fixes * Version changes --- .github/workflows/build.yml | 4 ++-- .github/workflows/deploy-network.yml | 4 ++-- .github/workflows/destroy-network.yml | 4 ++-- .github/workflows/e2e-legacy-test.yml | 2 +- .github/workflows/e2e-polybft-test.yml | 2 +- .github/workflows/fuzz-test.yml | 2 +- .github/workflows/lint.yml | 4 ++-- .github/workflows/property-polybft-test.yml | 2 +- .github/workflows/unit-test.yml | 2 +- 9 files changed, 13 insertions(+), 13 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4163da6954..ad7e43faad 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -18,7 +18,7 @@ jobs: - name: Checkout code uses: actions/checkout@v4.1.1 - name: Setup Go environment - uses: actions/setup-go@v5 + uses: actions/setup-go@v5.0.0 with: go-version: 1.20.x - name: Build Blade @@ -44,7 +44,7 @@ jobs: - name: Checkout code uses: actions/checkout@v4.1.1 - name: Setup Go environment - uses: actions/setup-go@v5 + uses: actions/setup-go@v5.0.0 with: go-version: 1.20.x - name: Reproduce builds diff --git a/.github/workflows/deploy-network.yml b/.github/workflows/deploy-network.yml index f110483d2b..82e842b2e8 100644 --- a/.github/workflows/deploy-network.yml +++ b/.github/workflows/deploy-network.yml @@ -124,7 +124,7 @@ jobs: aws-region: ${{ vars.AWS_REGION }} role-to-assume: ${{ secrets.AWS_ROLE_ARN }} - name: Install Terraform - uses: hashicorp/setup-terraform@v3 + uses: hashicorp/setup-terraform@v3.0.0 with: terraform_version: 1.4.5 - name: Configure Terraform @@ -172,7 +172,7 @@ jobs: id: previous_data run: echo "previous_data_output=$(aws s3 cp s3://${{ secrets.AWS_S3_BLADE_BUCKET }}/states/${{ inputs.environment }}.data.tar.gz .)" >> $GITHUB_OUTPUT - name: Run Ansible (Bootstrap blade) - if: contains(steps.previous_data.outputs.previous_data_output, 'error') + if: (steps.previous_data.outputs.previous_data_output == '' || contains(steps.previous_data.outputs.previous_data_output, 'error')) working-directory: ansible run: ansible-playbook site.yml --extra-vars "clean_deploy_title=${{ inputs.environment }} blade_repository=${{ github.repository }} block_gas_limit=${{ inputs.block_gas_limit }} block_time=${{ inputs.block_time }} is_london_fork_active=${{ inputs.is_london_fork_active }} is_bridge_active=${{ inputs.is_bridge_active }}" - name: Run Ansible (Restore data) diff --git a/.github/workflows/destroy-network.yml b/.github/workflows/destroy-network.yml index 7a8b9bd66e..0f43bf08da 100644 --- a/.github/workflows/destroy-network.yml +++ b/.github/workflows/destroy-network.yml @@ -70,7 +70,7 @@ jobs: aws-region: ${{ vars.AWS_REGION }} role-to-assume: ${{ secrets.AWS_ROLE_ARN }} - name: Install Terraform - uses: hashicorp/setup-terraform@v3 + uses: hashicorp/setup-terraform@v3.0.0 with: terraform_version: 1.4.5 - name: Configure Terraform @@ -134,7 +134,7 @@ jobs: aws-region: ${{ vars.AWS_REGION }} role-to-assume: ${{ secrets.AWS_ROLE_ARN }} - name: Install Terraform - uses: hashicorp/setup-terraform@v3 + uses: hashicorp/setup-terraform@v3.0.0 with: terraform_version: 1.4.5 - name: Configure Terraform diff --git a/.github/workflows/e2e-legacy-test.yml b/.github/workflows/e2e-legacy-test.yml index f299697082..31cbdd0404 100644 --- a/.github/workflows/e2e-legacy-test.yml +++ b/.github/workflows/e2e-legacy-test.yml @@ -23,7 +23,7 @@ jobs: with: submodules: recursive - name: Install Go - uses: actions/setup-go@v5 + uses: actions/setup-go@v5.0.0 with: go-version: 1.20.x - name: Run tests diff --git a/.github/workflows/e2e-polybft-test.yml b/.github/workflows/e2e-polybft-test.yml index 1ccac84719..e79937f4e0 100644 --- a/.github/workflows/e2e-polybft-test.yml +++ b/.github/workflows/e2e-polybft-test.yml @@ -21,7 +21,7 @@ jobs: - name: Checkout code uses: actions/checkout@v4.1.1 - name: Install Go - uses: actions/setup-go@v5 + uses: actions/setup-go@v5.0.0 with: go-version: 1.20.x check-latest: true diff --git a/.github/workflows/fuzz-test.yml b/.github/workflows/fuzz-test.yml index ad9ceb2673..88f309edc4 100644 --- a/.github/workflows/fuzz-test.yml +++ b/.github/workflows/fuzz-test.yml @@ -15,7 +15,7 @@ jobs: fuzz_output_failure: ${{ steps.run_fuzz_failure.outputs.test_output }} steps: - name: Setup Go - uses: actions/setup-go@v5 + uses: actions/setup-go@v5.0.0 with: go-version: 1.20.x - name: Checkout Code diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index f0cece84f1..9027b45e1b 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -9,12 +9,12 @@ jobs: runs-on: ubuntu-latest steps: - name: Install Go - uses: actions/setup-go@v5 + uses: actions/setup-go@v5.0.0 with: go-version: 1.20.x - name: Checkout code uses: actions/checkout@v4.1.1 - name: Lint - uses: golangci/golangci-lint-action@v3 + uses: golangci/golangci-lint-action@v3.7.0 with: args: --timeout 10m --verbose diff --git a/.github/workflows/property-polybft-test.yml b/.github/workflows/property-polybft-test.yml index 9e8146f5ac..515fe0a024 100644 --- a/.github/workflows/property-polybft-test.yml +++ b/.github/workflows/property-polybft-test.yml @@ -21,7 +21,7 @@ jobs: - name: Checkout code uses: actions/checkout@v4.1.1 - name: Install Go - uses: actions/setup-go@v5 + uses: actions/setup-go@v5.0.0 with: go-version: 1.20.x - name: Run tests diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index 75dbcce632..4e58d7b95c 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -17,7 +17,7 @@ jobs: test_output_failure: ${{ steps.run_tests_failure.outputs.test_output }} steps: - name: Setup Go - uses: actions/setup-go@v5 + uses: actions/setup-go@v5.0.0 with: go-version: 1.20.x - name: Checkout Code From b07e507f7ad5ac7ff5ea8afc5d06ace65453857f Mon Sep 17 00:00:00 2001 From: Branislav Kojic Date: Thu, 8 Feb 2024 12:24:09 +0100 Subject: [PATCH 47/67] Test fixes (#48) * Deploy Network * Add Permissions * Minor changes * Concurrency change * Destroy Network * Minor changes * Minor changes * Fix commit sha * Minor changes * Add Tests * Disable Tests temporarily * Nightly Build * Minor fixes * Big changes * Minor changes * Minor changes * Minor changes * Notification fixes * Notification changes * Minor changes * Permissions fixes * Minor changes * Notification changes * Minor changes * Display commit on notifications * Minor changes * Minor fixes * Logs notification fixes * Minor changes * Minor changes * Minor changes * Notifications fixes * Minor changes * Update actions version * Deployment fixes * Minor changes * Minor changes * Build repository fixes * Load Test notification text changes * EIP-1559; Check if the network is already deployed; Restore Blade Data * Notifications fixes; Pass blade_repository when deploying the network * Terraform fixes * Minor changes * Minor changes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Restore data fixes * Fix condition * Fix the RPC URL when the network is already deployed * Fix the RPC URL when the network is already deployed * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fixed when the network is first time deploying * Fixed upload logs * Fix: null URL if the network is destroyed but the state file exists * Main notification changes * Fix RPC URL; Fix Logs and Data upload * Minor fix * Minor fix * Notification fixes * Deploy fixes * Big changes * Condition fixes * Version changes * Test fixes * Change golangci-lint-action source --- .github/workflows/lint.yml | 2 +- .github/workflows/tests.yml | 37 +++++++++++++++++++++++++++++-------- 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 9027b45e1b..9168b77d9c 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -15,6 +15,6 @@ jobs: - name: Checkout code uses: actions/checkout@v4.1.1 - name: Lint - uses: golangci/golangci-lint-action@v3.7.0 + uses: bane/golangci-lint-action@v4.0.0 with: args: --timeout 10m --verbose diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 46736410f0..f1c5292d38 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -75,8 +75,8 @@ on: # yamllint disable-line rule:truthy notification: description: Notification type: boolean - required: true default: false + required: true outputs: build-blade: description: Build Blade output @@ -101,31 +101,52 @@ jobs: build-blade: name: Build Blade uses: ./.github/workflows/build.yml - if: inputs.build-blade + if: | + inputs.build-blade || + github.event_name == 'pull_request' || + (github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop')) lint: name: Lint uses: ./.github/workflows/lint.yml - if: inputs.lint + if: | + inputs.lint || + github.event_name == 'pull_request' || + (github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop')) unit-test: name: Unit Tests uses: ./.github/workflows/unit-test.yml - if: inputs.unit-test + if: | + inputs.unit-test || + github.event_name == 'pull_request' || + (github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop')) e2e-polybft-test: name: E2E PolyBFT Tests uses: ./.github/workflows/e2e-polybft-test.yml - if: inputs.e2e-polybft-test + if: | + inputs.e2e-polybft-test || + github.event_name == 'pull_request' || + (github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop')) e2e-legacy-test: name: E2E Legacy Tests uses: ./.github/workflows/e2e-legacy-test.yml - if: inputs.e2e-legacy-test + if: | + inputs.e2e-legacy-test || + github.event_name == 'pull_request' || + (github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop')) property-polybft-test: name: Property PolyBFT Tests uses: ./.github/workflows/property-polybft-test.yml - if: inputs.property-polybft-test + if: | + inputs.property-polybft-test || + github.event_name == 'pull_request' || + (github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop')) fuzz-test: name: Fuzz Tests uses: ./.github/workflows/fuzz-test.yml - if: inputs.fuzz-test + if: | + inputs.fuzz-test || + github.event_name == 'pull_request' || + (github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop')) notification: name: Tests Notification needs: [unit-test, e2e-polybft-test, e2e-legacy-test, property-polybft-test, fuzz-test] From 7a10e40e95455dc0859cfa6aa5330352907ef063 Mon Sep 17 00:00:00 2001 From: Branislav Kojic Date: Thu, 8 Feb 2024 13:22:45 +0100 Subject: [PATCH 48/67] Test fixes (#49) * Deploy Network * Add Permissions * Minor changes * Concurrency change * Destroy Network * Minor changes * Minor changes * Fix commit sha * Minor changes * Add Tests * Disable Tests temporarily * Nightly Build * Minor fixes * Big changes * Minor changes * Minor changes * Minor changes * Notification fixes * Notification changes * Minor changes * Permissions fixes * Minor changes * Notification changes * Minor changes * Display commit on notifications * Minor changes * Minor fixes * Logs notification fixes * Minor changes * Minor changes * Minor changes * Notifications fixes * Minor changes * Update actions version * Deployment fixes * Minor changes * Minor changes * Build repository fixes * Load Test notification text changes * EIP-1559; Check if the network is already deployed; Restore Blade Data * Notifications fixes; Pass blade_repository when deploying the network * Terraform fixes * Minor changes * Minor changes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Restore data fixes * Fix condition * Fix the RPC URL when the network is already deployed * Fix the RPC URL when the network is already deployed * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fixed when the network is first time deploying * Fixed upload logs * Fix: null URL if the network is destroyed but the state file exists * Main notification changes * Fix RPC URL; Fix Logs and Data upload * Minor fix * Minor fix * Notification fixes * Deploy fixes * Big changes * Condition fixes * Version changes * Test fixes * Change golangci-lint-action source * Change ec2-github-runner version; Always execute Build Blade * Minor changes --- .github/workflows/build.yml | 1 - .github/workflows/lint.yml | 2 +- .github/workflows/load-test.yml | 4 ++-- .github/workflows/nightly.yml | 2 -- .github/workflows/tests.yml | 19 ++++++------------- .github/workflows/unit-test.yml | 2 -- 6 files changed, 9 insertions(+), 21 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ad7e43faad..59311c3271 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,7 +2,6 @@ name: Build Blade on: # yamllint disable-line rule:truthy workflow_call: - # Map the workflow outputs to job outputs outputs: workflow_output: description: "Build output" diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 9168b77d9c..ec5301a53e 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,7 +1,7 @@ --- name: Lint on: # yamllint disable-line rule:truthy - workflow_call: {} + workflow_call: jobs: golangci_lint: diff --git a/.github/workflows/load-test.yml b/.github/workflows/load-test.yml index ab49e53e83..4752709561 100644 --- a/.github/workflows/load-test.yml +++ b/.github/workflows/load-test.yml @@ -148,7 +148,7 @@ jobs: role-to-assume: ${{ secrets.AWS_ROLE_ARN }} - name: Start Load Test Runner id: start_load_teste_runner - uses: bane/ec2-github-runner@v2.3.4.nodejs20 + uses: bane/ec2-github-runner@v3.0.0 with: mode: start ec2-instance-type: ${{ vars.AWS_INSTANCE_TYPE }} @@ -237,7 +237,7 @@ jobs: aws-region: ${{ vars.AWS_REGION }} role-to-assume: ${{ secrets.AWS_ROLE_ARN }} - name: Stop Load Test Runner - uses: bane/ec2-github-runner@v2.3.4.nodejs20 + uses: bane/ec2-github-runner@v3.0.0 with: mode: stop label: ${{ needs.load_test_runner.outputs.load_test_runner_label }} diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 8e975974ee..dee2536282 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -1,7 +1,6 @@ --- name: Nightly Build on: # yamllint disable-line rule:truthy - workflow_dispatch: schedule: # * is a special character in YAML so you have to quote this string - cron: '0 0 * * *' @@ -24,7 +23,6 @@ jobs: needs: check if: needs.check.outputs.new_commit_count > 0 with: - build-blade: true lint: false unit-test: true e2e-polybft-test: true diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index f1c5292d38..38ff479481 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -8,10 +8,6 @@ on: # yamllint disable-line rule:truthy pull_request: workflow_dispatch: inputs: - build-blade: - description: Build Blade - type: boolean - default: true lint: description: Lint type: boolean @@ -42,11 +38,6 @@ on: # yamllint disable-line rule:truthy default: false workflow_call: inputs: - build-blade: - description: Build Blade - type: boolean - default: true - required: true lint: description: Lint type: boolean @@ -101,13 +92,10 @@ jobs: build-blade: name: Build Blade uses: ./.github/workflows/build.yml - if: | - inputs.build-blade || - github.event_name == 'pull_request' || - (github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop')) lint: name: Lint uses: ./.github/workflows/lint.yml + needs: build-blade if: | inputs.lint || github.event_name == 'pull_request' || @@ -115,6 +103,7 @@ jobs: unit-test: name: Unit Tests uses: ./.github/workflows/unit-test.yml + needs: build-blade if: | inputs.unit-test || github.event_name == 'pull_request' || @@ -122,6 +111,7 @@ jobs: e2e-polybft-test: name: E2E PolyBFT Tests uses: ./.github/workflows/e2e-polybft-test.yml + needs: build-blade if: | inputs.e2e-polybft-test || github.event_name == 'pull_request' || @@ -129,6 +119,7 @@ jobs: e2e-legacy-test: name: E2E Legacy Tests uses: ./.github/workflows/e2e-legacy-test.yml + needs: build-blade if: | inputs.e2e-legacy-test || github.event_name == 'pull_request' || @@ -136,6 +127,7 @@ jobs: property-polybft-test: name: Property PolyBFT Tests uses: ./.github/workflows/property-polybft-test.yml + needs: build-blade if: | inputs.property-polybft-test || github.event_name == 'pull_request' || @@ -143,6 +135,7 @@ jobs: fuzz-test: name: Fuzz Tests uses: ./.github/workflows/fuzz-test.yml + needs: build-blade if: | inputs.fuzz-test || github.event_name == 'pull_request' || diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index 4e58d7b95c..32c9d44092 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -1,9 +1,7 @@ --- name: Unit Tests on: # yamllint disable-line rule:truthy - workflow_dispatch: workflow_call: - # Map the workflow outputs to job outputs outputs: workflow_output: description: "Unit Tests output" From 0d396000bae431ca1d217de4884c7a70bdf2f447 Mon Sep 17 00:00:00 2001 From: Branislav Kojic Date: Thu, 8 Feb 2024 13:33:28 +0100 Subject: [PATCH 49/67] Lint fixes (#50) * Deploy Network * Add Permissions * Minor changes * Concurrency change * Destroy Network * Minor changes * Minor changes * Fix commit sha * Minor changes * Add Tests * Disable Tests temporarily * Nightly Build * Minor fixes * Big changes * Minor changes * Minor changes * Minor changes * Notification fixes * Notification changes * Minor changes * Permissions fixes * Minor changes * Notification changes * Minor changes * Display commit on notifications * Minor changes * Minor fixes * Logs notification fixes * Minor changes * Minor changes * Minor changes * Notifications fixes * Minor changes * Update actions version * Deployment fixes * Minor changes * Minor changes * Build repository fixes * Load Test notification text changes * EIP-1559; Check if the network is already deployed; Restore Blade Data * Notifications fixes; Pass blade_repository when deploying the network * Terraform fixes * Minor changes * Minor changes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Restore data fixes * Fix condition * Fix the RPC URL when the network is already deployed * Fix the RPC URL when the network is already deployed * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fixed when the network is first time deploying * Fixed upload logs * Fix: null URL if the network is destroyed but the state file exists * Main notification changes * Fix RPC URL; Fix Logs and Data upload * Minor fix * Minor fix * Notification fixes * Deploy fixes * Big changes * Condition fixes * Version changes * Test fixes * Change golangci-lint-action source * Change ec2-github-runner version; Always execute Build Blade * Minor changes * Lint fixes --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 38ff479481..4203fe6ce6 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -142,7 +142,7 @@ jobs: (github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop')) notification: name: Tests Notification - needs: [unit-test, e2e-polybft-test, e2e-legacy-test, property-polybft-test, fuzz-test] + needs: [lint, unit-test, e2e-polybft-test, e2e-legacy-test, property-polybft-test, fuzz-test] uses: ./.github/workflows/notification-tests.yml if: (always() && inputs.notification) with: From 5dcbdf3cd1977585ed196d5cf65e3da93a1d87b9 Mon Sep 17 00:00:00 2001 From: Branislav Kojic Date: Fri, 9 Feb 2024 07:18:22 +0100 Subject: [PATCH 50/67] Nightly test (#51) * Deploy Network * Add Permissions * Minor changes * Concurrency change * Destroy Network * Minor changes * Minor changes * Fix commit sha * Minor changes * Add Tests * Disable Tests temporarily * Nightly Build * Minor fixes * Big changes * Minor changes * Minor changes * Minor changes * Notification fixes * Notification changes * Minor changes * Permissions fixes * Minor changes * Notification changes * Minor changes * Display commit on notifications * Minor changes * Minor fixes * Logs notification fixes * Minor changes * Minor changes * Minor changes * Notifications fixes * Minor changes * Update actions version * Deployment fixes * Minor changes * Minor changes * Build repository fixes * Load Test notification text changes * EIP-1559; Check if the network is already deployed; Restore Blade Data * Notifications fixes; Pass blade_repository when deploying the network * Terraform fixes * Minor changes * Minor changes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Restore data fixes * Fix condition * Fix the RPC URL when the network is already deployed * Fix the RPC URL when the network is already deployed * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fixed when the network is first time deploying * Fixed upload logs * Fix: null URL if the network is destroyed but the state file exists * Main notification changes * Fix RPC URL; Fix Logs and Data upload * Minor fix * Minor fix * Notification fixes * Deploy fixes * Big changes * Condition fixes * Version changes * Test fixes * Change golangci-lint-action source * Change ec2-github-runner version; Always execute Build Blade * Minor changes * Lint fixes * Nightly test --- .github/workflows/deploy-network.yml | 1 + .github/workflows/load-test.yml | 47 ++++++++++++++++++---------- .github/workflows/nightly.yml | 12 +++---- 3 files changed, 37 insertions(+), 23 deletions(-) diff --git a/.github/workflows/deploy-network.yml b/.github/workflows/deploy-network.yml index 82e842b2e8..7b424403d8 100644 --- a/.github/workflows/deploy-network.yml +++ b/.github/workflows/deploy-network.yml @@ -97,6 +97,7 @@ jobs: run: echo "retrieve_state_output=$(aws s3 cp s3://${{ secrets.AWS_S3_BLADE_BUCKET }}/states/${{ inputs.environment }} state.json)" >> $GITHUB_OUTPUT - name: Check state file id: check_state_file + if: contains(steps.retrieve_state.outputs.retrieve_state_output, 'download') run: echo "resources=$(cat state.json | jq -r ".resources" | jq length)" >> $GITHUB_OUTPUT - name: Set RPC URL id: rpc_url diff --git a/.github/workflows/load-test.yml b/.github/workflows/load-test.yml index 4752709561..9ad30b77e1 100644 --- a/.github/workflows/load-test.yml +++ b/.github/workflows/load-test.yml @@ -12,8 +12,8 @@ on: # yamllint disable-line rule:truthy description: The scenario to run type: choice options: [EOA, ERC20] - setupTimeOut: - description: Setup TimeOut + timeout: + description: Time Out type: string default: "220s" required: true @@ -56,8 +56,8 @@ on: # yamllint disable-line rule:truthy description: The scenario to run type: string required: true - setupTimeOut: - description: Setup TimeOut + timeout: + description: Time Out type: string required: true rate: @@ -133,10 +133,33 @@ permissions: security-events: write jobs: + check_network: + name: Check if the network is already deployed + runs-on: ubuntu-latest + environment: ${{ inputs.environment }} + outputs: + rpc_url: ${{ steps.rpc_url.outputs.url }} + steps: + - name: Checkout code + uses: actions/checkout@v4.1.1 + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v4.0.1 + with: + aws-region: ${{ vars.AWS_REGION }} + role-to-assume: ${{ secrets.AWS_ROLE_ARN }} + - name: Retrieve state file from s3 + id: retrieve_state + run: echo "retrieve_state_output=$(aws s3 cp s3://${{ secrets.AWS_S3_BLADE_BUCKET }}/states/${{ inputs.environment }} state.json)" >> $GITHUB_OUTPUT + - name: Set RPC URL + id: rpc_url + if: contains(steps.retrieve_state.outputs.retrieve_state_output, 'download') + run: echo "url=$(cat state.json | jq -r '.outputs.aws_lb_ext_domain.value // empty')" >> $GITHUB_OUTPUT load_test_runner: name: Deploy Load Test Runner runs-on: ubuntu-latest environment: ${{ inputs.environment }} + needs: check_network + if: needs.check_network.outputs.rpc_url != '' outputs: load_test_runner_label: ${{ steps.start_load_teste_runner.outputs.label }} load_test_runner_instance_id: ${{ steps.start_load_teste_runner.outputs.ec2-instance-id }} @@ -159,7 +182,7 @@ jobs: load_test_scenario: name: Run Load Test ${{ inputs.scenario }} Scenario runs-on: ${{ needs.load_test_runner.outputs.load_test_runner_label }} - needs: load_test_runner + needs: [check_network, load_test_runner] outputs: test_output_success: ${{ steps.load_test_results_success.outputs.test_output }} tps_avg: ${{ steps.load_test_results.outputs.tps_avg }} @@ -172,16 +195,6 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v4.1.1 - - name: Configure AWS credentials - uses: aws-actions/configure-aws-credentials@v4.0.1 - with: - aws-region: ${{ vars.AWS_REGION }} - role-to-assume: ${{ secrets.AWS_ROLE_ARN }} - - name: Retrieve state file from s3 - run: aws s3 cp s3://${{ secrets.AWS_S3_BLADE_BUCKET }}/states/${{ inputs.environment }} state.json - - name: Set RPC URL - id: set_rpc_url - run: echo "rpc_url_value=http://$(cat state.json | jq -r '.outputs.aws_lb_ext_domain.value')" >> $GITHUB_OUTPUT - name: Run scenario id: load_test_results run: | @@ -195,14 +208,14 @@ jobs: echo "gas_max=$(cat summary.json | jq -r '.metrics.ethereum_gas_used.values.max')" >> $GITHUB_OUTPUT env: K6_STATSD_ENABLE_TAGS: true - SETUP_TIMEOUT: ${{ inputs.setupTimeOut }} + SETUP_TIMEOUT: ${{ inputs.timeout }} RATE: ${{ inputs.rate }} TIME_UNIT: ${{ inputs.timeUnit }} DURATION: ${{ inputs.duration }} PREALLOCATED_VUS: ${{ inputs.preAllocatedVUs }} MAX_VUS: ${{ inputs.maxVUs }} LOADTEST_MNEMONIC: ${{ secrets.AWS_LOADTESTRUNNER_MNEMONIC }} - RPC_URL: ${{ steps.set_rpc_url.outputs.rpc_url_value }} + RPC_URL: "http://${{ needs.check_network.outputs.rpc_url }}" - name: Run tests success if: success() id: load_test_results_success diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index dee2536282..a686245930 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -53,10 +53,10 @@ jobs: with: environment: nightly scenario: EOA - setupTimeOut: "220s" - rate: "3000" + timeout: "220s" + rate: "500" timeUnit: "1s" - duration: "10m" + duration: "5m" preAllocatedVUs: "60" maxVUs: "60" notification: false @@ -76,10 +76,10 @@ jobs: with: environment: nightly scenario: ERC20 - setupTimeOut: "220s" - rate: "1500" + timeout: "220s" + rate: "300" timeUnit: "1s" - duration: "10m" + duration: "5m" preAllocatedVUs: "60" maxVUs: "60" notification: false From 3fd7041fd6edd7ccc7d8fee276867fa34cecfec9 Mon Sep 17 00:00:00 2001 From: Branislav Kojic Date: Fri, 9 Feb 2024 07:26:03 +0100 Subject: [PATCH 51/67] Nightly test (#52) * Deploy Network * Add Permissions * Minor changes * Concurrency change * Destroy Network * Minor changes * Minor changes * Fix commit sha * Minor changes * Add Tests * Disable Tests temporarily * Nightly Build * Minor fixes * Big changes * Minor changes * Minor changes * Minor changes * Notification fixes * Notification changes * Minor changes * Permissions fixes * Minor changes * Notification changes * Minor changes * Display commit on notifications * Minor changes * Minor fixes * Logs notification fixes * Minor changes * Minor changes * Minor changes * Notifications fixes * Minor changes * Update actions version * Deployment fixes * Minor changes * Minor changes * Build repository fixes * Load Test notification text changes * EIP-1559; Check if the network is already deployed; Restore Blade Data * Notifications fixes; Pass blade_repository when deploying the network * Terraform fixes * Minor changes * Minor changes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Restore data fixes * Fix condition * Fix the RPC URL when the network is already deployed * Fix the RPC URL when the network is already deployed * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fixed when the network is first time deploying * Fixed upload logs * Fix: null URL if the network is destroyed but the state file exists * Main notification changes * Fix RPC URL; Fix Logs and Data upload * Minor fix * Minor fix * Notification fixes * Deploy fixes * Big changes * Condition fixes * Version changes * Test fixes * Change golangci-lint-action source * Change ec2-github-runner version; Always execute Build Blade * Minor changes * Lint fixes * Nightly test From 4bd2f5929a7d4185333e346eff8a2fc804b75eb1 Mon Sep 17 00:00:00 2001 From: Branislav Kojic Date: Fri, 9 Feb 2024 07:29:35 +0100 Subject: [PATCH 52/67] Minor fixes (#53) * Deploy Network * Add Permissions * Minor changes * Concurrency change * Destroy Network * Minor changes * Minor changes * Fix commit sha * Minor changes * Add Tests * Disable Tests temporarily * Nightly Build * Minor fixes * Big changes * Minor changes * Minor changes * Minor changes * Notification fixes * Notification changes * Minor changes * Permissions fixes * Minor changes * Notification changes * Minor changes * Display commit on notifications * Minor changes * Minor fixes * Logs notification fixes * Minor changes * Minor changes * Minor changes * Notifications fixes * Minor changes * Update actions version * Deployment fixes * Minor changes * Minor changes * Build repository fixes * Load Test notification text changes * EIP-1559; Check if the network is already deployed; Restore Blade Data * Notifications fixes; Pass blade_repository when deploying the network * Terraform fixes * Minor changes * Minor changes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Restore data fixes * Fix condition * Fix the RPC URL when the network is already deployed * Fix the RPC URL when the network is already deployed * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fixed when the network is first time deploying * Fixed upload logs * Fix: null URL if the network is destroyed but the state file exists * Main notification changes * Fix RPC URL; Fix Logs and Data upload * Minor fix * Minor fix * Notification fixes * Deploy fixes * Big changes * Condition fixes * Version changes * Test fixes * Change golangci-lint-action source * Change ec2-github-runner version; Always execute Build Blade * Minor changes * Lint fixes * Nightly test * Minor fixes --- .github/workflows/nightly.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index a686245930..741ef820d1 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -1,6 +1,7 @@ --- name: Nightly Build on: # yamllint disable-line rule:truthy + workflow_dispatch: {} schedule: # * is a special character in YAML so you have to quote this string - cron: '0 0 * * *' From f38a752fa589b832e80963b93c480a2388cdf6ff Mon Sep 17 00:00:00 2001 From: Branislav Kojic Date: Fri, 9 Feb 2024 08:43:16 +0100 Subject: [PATCH 53/67] Fix Linter bug (#54) * Deploy Network * Add Permissions * Minor changes * Concurrency change * Destroy Network * Minor changes * Minor changes * Fix commit sha * Minor changes * Add Tests * Disable Tests temporarily * Nightly Build * Minor fixes * Big changes * Minor changes * Minor changes * Minor changes * Notification fixes * Notification changes * Minor changes * Permissions fixes * Minor changes * Notification changes * Minor changes * Display commit on notifications * Minor changes * Minor fixes * Logs notification fixes * Minor changes * Minor changes * Minor changes * Notifications fixes * Minor changes * Update actions version * Deployment fixes * Minor changes * Minor changes * Build repository fixes * Load Test notification text changes * EIP-1559; Check if the network is already deployed; Restore Blade Data * Notifications fixes; Pass blade_repository when deploying the network * Terraform fixes * Minor changes * Minor changes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Restore data fixes * Fix condition * Fix the RPC URL when the network is already deployed * Fix the RPC URL when the network is already deployed * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fixed when the network is first time deploying * Fixed upload logs * Fix: null URL if the network is destroyed but the state file exists * Main notification changes * Fix RPC URL; Fix Logs and Data upload * Minor fix * Minor fix * Notification fixes * Deploy fixes * Big changes * Condition fixes * Version changes * Test fixes * Change golangci-lint-action source * Change ec2-github-runner version; Always execute Build Blade * Minor changes * Lint fixes * Nightly test * Minor fixes * Fix Linter bug --- .github/workflows/lint.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index ec5301a53e..ec4ff2252a 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -14,6 +14,8 @@ jobs: go-version: 1.20.x - name: Checkout code uses: actions/checkout@v4.1.1 + with: + fetch-depth: 0 - name: Lint uses: bane/golangci-lint-action@v4.0.0 with: From bf49ce1ffcacc14f9d8a8f5ebd9cc29844c039a6 Mon Sep 17 00:00:00 2001 From: Branislav Kojic Date: Fri, 9 Feb 2024 10:55:03 +0100 Subject: [PATCH 54/67] Release changes (#55) * Deploy Network * Add Permissions * Minor changes * Concurrency change * Destroy Network * Minor changes * Minor changes * Fix commit sha * Minor changes * Add Tests * Disable Tests temporarily * Nightly Build * Minor fixes * Big changes * Minor changes * Minor changes * Minor changes * Notification fixes * Notification changes * Minor changes * Permissions fixes * Minor changes * Notification changes * Minor changes * Display commit on notifications * Minor changes * Minor fixes * Logs notification fixes * Minor changes * Minor changes * Minor changes * Notifications fixes * Minor changes * Update actions version * Deployment fixes * Minor changes * Minor changes * Build repository fixes * Load Test notification text changes * EIP-1559; Check if the network is already deployed; Restore Blade Data * Notifications fixes; Pass blade_repository when deploying the network * Terraform fixes * Minor changes * Minor changes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Restore data fixes * Fix condition * Fix the RPC URL when the network is already deployed * Fix the RPC URL when the network is already deployed * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fixed when the network is first time deploying * Fixed upload logs * Fix: null URL if the network is destroyed but the state file exists * Main notification changes * Fix RPC URL; Fix Logs and Data upload * Minor fix * Minor fix * Notification fixes * Deploy fixes * Big changes * Condition fixes * Version changes * Test fixes * Change golangci-lint-action source * Change ec2-github-runner version; Always execute Build Blade * Minor changes * Lint fixes * Nightly test * Minor fixes * Fix Linter bug * Release changes --- .github/workflows/release.yml | 12 ++++-------- Dockerfile.release | 6 +++--- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ab3b3be8d6..1c2312f4bd 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -19,23 +19,19 @@ jobs: uses: actions/checkout@v4.1.1 with: fetch-depth: 0 - - name: Set up Go uses: actions/setup-go@v5.0.0 with: go-version: 1.20.x - - name: Prepare id: prepare run: | TAG=${GITHUB_REF#refs/tags/} echo tag_name=${TAG} >> $GITHUB_OUTPUT - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - + uses: docker/setup-qemu-action@v3.0.0 - name: Login to Docker Hub - uses: docker/login-action@v2 + uses: docker/login-action@v3.0.0 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} @@ -56,7 +52,7 @@ jobs: --rm-dist --skip-validate env: PACKAGE_NAME: github.com/Ethernal-Tech/blade - GOLANG_CROSS_VERSION: v1.20.5 + GOLANG_CROSS_VERSION: v1.21.5 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} VERSION: ${{ steps.prepare.outputs.tag_name }} - SLACK_WEBHOOK: ${{ secrets.SLACK_BLADE_GITHUB_URL }} + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }} diff --git a/Dockerfile.release b/Dockerfile.release index 12b3941e80..25bf33c1eb 100644 --- a/Dockerfile.release +++ b/Dockerfile.release @@ -8,9 +8,9 @@ COPY blade /usr/local/bin/ EXPOSE 8545 9632 1478 -RUN addgroup -S edge \ - && adduser -S edge -G edge +RUN addgroup -S blade \ + && adduser -S blade -G blade-group -USER edge +USER blade ENTRYPOINT ["blade"] From 9be32b4e859a7b0dd3a7b6a4b76b581a71bc15cb Mon Sep 17 00:00:00 2001 From: Branislav Kojic Date: Fri, 9 Feb 2024 11:03:54 +0100 Subject: [PATCH 55/67] Release changes (#56) * Deploy Network * Add Permissions * Minor changes * Concurrency change * Destroy Network * Minor changes * Minor changes * Fix commit sha * Minor changes * Add Tests * Disable Tests temporarily * Nightly Build * Minor fixes * Big changes * Minor changes * Minor changes * Minor changes * Notification fixes * Notification changes * Minor changes * Permissions fixes * Minor changes * Notification changes * Minor changes * Display commit on notifications * Minor changes * Minor fixes * Logs notification fixes * Minor changes * Minor changes * Minor changes * Notifications fixes * Minor changes * Update actions version * Deployment fixes * Minor changes * Minor changes * Build repository fixes * Load Test notification text changes * EIP-1559; Check if the network is already deployed; Restore Blade Data * Notifications fixes; Pass blade_repository when deploying the network * Terraform fixes * Minor changes * Minor changes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Restore data fixes * Fix condition * Fix the RPC URL when the network is already deployed * Fix the RPC URL when the network is already deployed * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fixed when the network is first time deploying * Fixed upload logs * Fix: null URL if the network is destroyed but the state file exists * Main notification changes * Fix RPC URL; Fix Logs and Data upload * Minor fix * Minor fix * Notification fixes * Deploy fixes * Big changes * Condition fixes * Version changes * Test fixes * Change golangci-lint-action source * Change ec2-github-runner version; Always execute Build Blade * Minor changes * Lint fixes * Nightly test * Minor fixes * Fix Linter bug * Release changes * goreleaser fixes --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1c2312f4bd..a83dd4d0a3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -49,7 +49,7 @@ jobs: -v `pwd`:/go/src/$(PACKAGE_NAME) \ -w /go/src/$(PACKAGE_NAME) \ ghcr.io/goreleaser/goreleaser-cross:${GOLANG_CROSS_VERSION} \ - --rm-dist --skip-validate + --clean --skip=validate env: PACKAGE_NAME: github.com/Ethernal-Tech/blade GOLANG_CROSS_VERSION: v1.21.5 From df10c6e0bf2a17ea37d6a69159533205f8729dff Mon Sep 17 00:00:00 2001 From: Branislav Kojic Date: Fri, 9 Feb 2024 13:01:04 +0100 Subject: [PATCH 56/67] Establishe Release (#57) * Deploy Network * Add Permissions * Minor changes * Concurrency change * Destroy Network * Minor changes * Minor changes * Fix commit sha * Minor changes * Add Tests * Disable Tests temporarily * Nightly Build * Minor fixes * Big changes * Minor changes * Minor changes * Minor changes * Notification fixes * Notification changes * Minor changes * Permissions fixes * Minor changes * Notification changes * Minor changes * Display commit on notifications * Minor changes * Minor fixes * Logs notification fixes * Minor changes * Minor changes * Minor changes * Notifications fixes * Minor changes * Update actions version * Deployment fixes * Minor changes * Minor changes * Build repository fixes * Load Test notification text changes * EIP-1559; Check if the network is already deployed; Restore Blade Data * Notifications fixes; Pass blade_repository when deploying the network * Terraform fixes * Minor changes * Minor changes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Restore data fixes * Fix condition * Fix the RPC URL when the network is already deployed * Fix the RPC URL when the network is already deployed * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fixed when the network is first time deploying * Fixed upload logs * Fix: null URL if the network is destroyed but the state file exists * Main notification changes * Fix RPC URL; Fix Logs and Data upload * Minor fix * Minor fix * Notification fixes * Deploy fixes * Big changes * Condition fixes * Version changes * Test fixes * Change golangci-lint-action source * Change ec2-github-runner version; Always execute Build Blade * Minor changes * Lint fixes * Nightly test * Minor fixes * Fix Linter bug * Release changes * goreleaser fixes * goreleaser fixes * goreleaser fixes * goreleaser fixes * goreleaser fixes * docker repository name fixes * Minor fixes * Warrning fixes * docker repository name fixes --- .github/workflows/release.yml | 10 +++++----- .goreleaser.yml | 26 +++++++++++++------------- Dockerfile.release | 2 +- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a83dd4d0a3..edec12f492 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -46,13 +46,13 @@ jobs: -e SLACK_WEBHOOK \ -e DOCKER_CONFIG \ -v /var/run/docker.sock:/var/run/docker.sock \ - -v `pwd`:/go/src/$(PACKAGE_NAME) \ - -w /go/src/$(PACKAGE_NAME) \ + -v `pwd`:/go/src/${PACKAGE_NAME} \ + -w /go/src/${PACKAGE_NAME} \ ghcr.io/goreleaser/goreleaser-cross:${GOLANG_CROSS_VERSION} \ - --clean --skip=validate + --clean --skip-validate env: - PACKAGE_NAME: github.com/Ethernal-Tech/blade - GOLANG_CROSS_VERSION: v1.21.5 + PACKAGE_NAME: github.com/${GITHUB_REPOSITORY} + GOLANG_CROSS_VERSION: v1.20.5 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} VERSION: ${{ steps.prepare.outputs.tag_name }} SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }} diff --git a/.goreleaser.yml b/.goreleaser.yml index f51a3094ff..32988d1094 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -1,4 +1,4 @@ -project_name: polygon-edge +project_name: blade release: disable: false @@ -17,7 +17,7 @@ builds: - CC=o64-clang - CXX=o64-clang++ ldflags: - -s -w -X 'github.com/0xPolygon/polygon-edge/versioning.Version=v{{ .Version }}' + -s -w -X 'github.com/${GITHUB_REPOSITORY}/versioning.Version=v{{ .Version }}' - id: darwin-arm64 main: ./main.go @@ -30,7 +30,7 @@ builds: - CC=oa64-clang - CXX=oa64-clang++ ldflags: - -s -w -X 'github.com/0xPolygon/polygon-edge/versioning.Version=v{{ .Version }}' + -s -w -X 'github.com/${GITHUB_REPOSITORY}/versioning.Version=v{{ .Version }}' - id: linux-amd64 main: ./main.go @@ -44,7 +44,7 @@ builds: - CXX=g++ ldflags: # We need to build a static binary because we are building in a glibc based system and running in a musl container - -s -w -linkmode external -extldflags "-static" -X 'github.com/0xPolygon/polygon-edge/versioning.Version=v{{ .Version }}' + -s -w -linkmode external -extldflags "-static" -X 'github.com/${GITHUB_REPOSITORY}/versioning.Version=v{{ .Version }}' tags: - netgo - osusergo @@ -61,7 +61,7 @@ builds: - CXX=aarch64-linux-gnu-g++ ldflags: # We need to build a static binary because we are building in a glibc based system and running in a musl container - -s -w -linkmode external -extldflags "-static" -X 'github.com/0xPolygon/polygon-edge/versioning.Version=v{{ .Version }}' + -s -w -linkmode external -extldflags "-static" -X 'github.com/${GITHUB_REPOSITORY}/versioning.Version=v{{ .Version }}' tags: - netgo - osusergo @@ -77,7 +77,7 @@ snapshot: dockers: - image_templates: - - 0xpolygon/{{ .ProjectName }}:{{ .Version }}-amd64 + - b4n3/{{ .ProjectName }}:{{ .Version }}-amd64 dockerfile: Dockerfile.release use: buildx goarch: amd64 @@ -88,7 +88,7 @@ dockers: skip_push: false - image_templates: - - 0xpolygon/{{ .ProjectName }}:{{ .Version }}-arm64 + - b4n3/{{ .ProjectName }}:{{ .Version }}-arm64 dockerfile: Dockerfile.release use: buildx goarch: arm64 @@ -99,14 +99,14 @@ dockers: skip_push: false docker_manifests: - - name_template: 0xpolygon/{{ .ProjectName }}:{{ .Version }} + - name_template: b4n3/{{ .ProjectName }}:{{ .Version }} image_templates: - - 0xpolygon/{{ .ProjectName }}:{{ .Version }}-amd64 - - 0xpolygon/{{ .ProjectName }}:{{ .Version }}-arm64 + - b4n3/{{ .ProjectName }}:{{ .Version }}-amd64 + - b4n3/{{ .ProjectName }}:{{ .Version }}-arm64 skip_push: false - - name_template: 0xpolygon/{{ .ProjectName }}:latest + - name_template: b4n3/{{ .ProjectName }}:latest image_templates: - - 0xpolygon/{{ .ProjectName }}:{{ .Version }}-amd64 - - 0xpolygon/{{ .ProjectName }}:{{ .Version }}-arm64 + - b4n3/{{ .ProjectName }}:{{ .Version }}-amd64 + - b4n3/{{ .ProjectName }}:{{ .Version }}-arm64 skip_push: auto diff --git a/Dockerfile.release b/Dockerfile.release index 25bf33c1eb..9100d7eb4a 100644 --- a/Dockerfile.release +++ b/Dockerfile.release @@ -8,7 +8,7 @@ COPY blade /usr/local/bin/ EXPOSE 8545 9632 1478 -RUN addgroup -S blade \ +RUN addgroup -S blade-group \ && adduser -S blade -G blade-group USER blade From 1b87f37958b8067abc3cf88b883488e5a5c45d1a Mon Sep 17 00:00:00 2001 From: Branislav Kojic Date: Mon, 12 Feb 2024 18:48:10 +0100 Subject: [PATCH 57/67] Rename Tests to CI (#58) * Deploy Network * Add Permissions * Minor changes * Concurrency change * Destroy Network * Minor changes * Minor changes * Fix commit sha * Minor changes * Add Tests * Disable Tests temporarily * Nightly Build * Minor fixes * Big changes * Minor changes * Minor changes * Minor changes * Notification fixes * Notification changes * Minor changes * Permissions fixes * Minor changes * Notification changes * Minor changes * Display commit on notifications * Minor changes * Minor fixes * Logs notification fixes * Minor changes * Minor changes * Minor changes * Notifications fixes * Minor changes * Update actions version * Deployment fixes * Minor changes * Minor changes * Build repository fixes * Load Test notification text changes * EIP-1559; Check if the network is already deployed; Restore Blade Data * Notifications fixes; Pass blade_repository when deploying the network * Terraform fixes * Minor changes * Minor changes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Restore data fixes * Fix condition * Fix the RPC URL when the network is already deployed * Fix the RPC URL when the network is already deployed * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fixed when the network is first time deploying * Fixed upload logs * Fix: null URL if the network is destroyed but the state file exists * Main notification changes * Fix RPC URL; Fix Logs and Data upload * Minor fix * Minor fix * Notification fixes * Deploy fixes * Big changes * Condition fixes * Version changes * Test fixes * Change golangci-lint-action source * Change ec2-github-runner version; Always execute Build Blade * Minor changes * Lint fixes * Nightly test * Minor fixes * Fix Linter bug * Release changes * goreleaser fixes * goreleaser fixes * goreleaser fixes * goreleaser fixes * goreleaser fixes * docker repository name fixes * Minor fixes * Warrning fixes * docker repository name fixes * Add organization variable * Rename Tests to CI; Minor changes --- .github/workflows/build.yml | 2 +- .github/workflows/{tests.yml => ci.yml} | 39 +++---- .github/workflows/cla.yml | 2 +- .github/workflows/lint.yml | 12 +- .github/workflows/load-test.yml | 2 +- .github/workflows/nightly.yml | 25 ++-- .../workflows/notification-deploy-network.yml | 7 +- .../notification-destroy-network.yml | 5 +- .github/workflows/notification-load-test.yml | 1 - .github/workflows/notification-main.yml | 11 +- .github/workflows/notification-tests.yml | 108 ------------------ .github/workflows/release.yml | 3 +- .goreleaser.yml | 16 +-- 13 files changed, 64 insertions(+), 169 deletions(-) rename .github/workflows/{tests.yml => ci.yml} (81%) delete mode 100644 .github/workflows/notification-tests.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 59311c3271..e7b73e206a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,7 +4,7 @@ on: # yamllint disable-line rule:truthy workflow_call: outputs: workflow_output: - description: "Build output" + description: "Build Blade output" value: ${{ jobs.go_build.outputs.build_output_failure }} jobs: diff --git a/.github/workflows/tests.yml b/.github/workflows/ci.yml similarity index 81% rename from .github/workflows/tests.yml rename to .github/workflows/ci.yml index 4203fe6ce6..6df137d078 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/ci.yml @@ -1,5 +1,5 @@ --- -name: Tests +name: CI on: # yamllint disable-line rule:truthy push: branches: @@ -8,6 +8,10 @@ on: # yamllint disable-line rule:truthy pull_request: workflow_dispatch: inputs: + build-blade: + description: Build Blade + type: boolean + default: true lint: description: Lint type: boolean @@ -32,16 +36,14 @@ on: # yamllint disable-line rule:truthy description: Fuzz Tests type: boolean default: true - notification: - description: Notification - type: boolean - default: false workflow_call: inputs: + build-blade: + description: Build Blade + type: boolean lint: description: Lint type: boolean - default: false required: true unit-test: description: Unit Tests @@ -63,15 +65,13 @@ on: # yamllint disable-line rule:truthy description: Fuzz Tests type: boolean required: true - notification: - description: Notification - type: boolean - default: false - required: true outputs: build-blade: description: Build Blade output value: ${{ jobs.build-blade.outputs.workflow_output }} + lint: + description: Lint output + value: ${{ jobs.lint.outputs.workflow_output }} unit-test: description: Unit Tests output value: ${{ jobs.unit-test.outputs.workflow_output }} @@ -92,6 +92,10 @@ jobs: build-blade: name: Build Blade uses: ./.github/workflows/build.yml + if: | + inputs.build-blade || + github.event_name == 'pull_request' || + (github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop')) lint: name: Lint uses: ./.github/workflows/lint.yml @@ -140,16 +144,3 @@ jobs: inputs.fuzz-test || github.event_name == 'pull_request' || (github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop')) - notification: - name: Tests Notification - needs: [lint, unit-test, e2e-polybft-test, e2e-legacy-test, property-polybft-test, fuzz-test] - uses: ./.github/workflows/notification-tests.yml - if: (always() && inputs.notification) - with: - unit_test_output: ${{ needs.unit-test.outputs.workflow_output }} - e2e_polybft_test_output: ${{ needs.e2e-polybft-test.outputs.workflow_output }} - e2e_legacy_test_output: ${{ needs.e2e-legacy-test.outputs.workflow_output }} - property_polybft_test_output: ${{ needs.property-polybft-test.outputs.workflow_output }} - fuzz_test_output: ${{ needs.fuzz-test.outputs.workflow_output }} - secrets: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} diff --git a/.github/workflows/cla.yml b/.github/workflows/cla.yml index 9e43327c7a..a68d5ac0b8 100644 --- a/.github/workflows/cla.yml +++ b/.github/workflows/cla.yml @@ -22,6 +22,6 @@ jobs: PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} with: path-to-signatures: "cla.json" - path-to-document: "https://github.com/Ethernal-Tech/blade/blob/develop/CLA.md" + path-to-document: "https://github.com/${GITHUB_REPOSITORY}/blob/develop/CLA.md" branch: "cla-signatures" allowlist: dependabot[bot],dependabot-preview[bot] diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index ec4ff2252a..6c2a367b62 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -2,11 +2,17 @@ name: Lint on: # yamllint disable-line rule:truthy workflow_call: + outputs: + workflow_output: + description: "Lint output" + value: ${{ jobs.golangci_lint.outputs.lint_output_failure }} jobs: golangci_lint: - name: Linter + name: Run Lint runs-on: ubuntu-latest + outputs: + lint_output_failure: ${{ steps.lint_failure.outputs.lint_output }} steps: - name: Install Go uses: actions/setup-go@v5.0.0 @@ -20,3 +26,7 @@ jobs: uses: bane/golangci-lint-action@v4.0.0 with: args: --timeout 10m --verbose + - name: Lint Failed + if: failure() + id: lint_failure + run: echo "lint_output=false" >> $GITHUB_OUTPUT diff --git a/.github/workflows/load-test.yml b/.github/workflows/load-test.yml index 9ad30b77e1..ca20bf0795 100644 --- a/.github/workflows/load-test.yml +++ b/.github/workflows/load-test.yml @@ -224,7 +224,7 @@ jobs: name: Load Test Notification needs: load_test_scenario uses: ./.github/workflows/notification-load-test.yml - if: (always() && inputs.notification) + if: (needs.load_test_scenario.outputs.test_output_success == 'true' && inputs.notification) with: environment: ${{ inputs.environment }} scenario: ${{ inputs.scenario }} diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 741ef820d1..985d53e2d2 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -18,19 +18,19 @@ jobs: - name: Get new commits id: get_new_commits run: echo "commit_count=$(git log --oneline --since '24 hours ago' | wc -l | tr -d ' ')" >> $GITHUB_OUTPUT - tests: - name: Tests - uses: ./.github/workflows/tests.yml + ci: + name: CI + uses: ./.github/workflows/ci.yml needs: check if: needs.check.outputs.new_commit_count > 0 with: - lint: false + build-blade: true + lint: true unit-test: true e2e-polybft-test: true e2e-legacy-test: true property-polybft-test: true fuzz-test: true - notification: false deploy_network: name: Deploy Network uses: ./.github/workflows/deploy-network.yml @@ -109,17 +109,18 @@ jobs: notification_main: name: Nightly Notification uses: ./.github/workflows/notification-main.yml - needs: [tests, deploy_network, load_test_multiple_eoa, load_test_multiple_erc20, destroy_network] + needs: [ci, deploy_network, load_test_multiple_eoa, load_test_multiple_erc20, destroy_network] if: success() || failure() with: environment: nightly logs: true - build_blade_output: ${{ needs.tests.outputs.build-blade }} - unit_test_output: ${{ needs.tests.outputs.unit-test }} - e2e_polybft_test_output: ${{ needs.tests.outputs.e2e-polybft-test }} - e2e_legacy_test_output: ${{ needs.tests.outputs.e2e-legacy-test }} - property_polybft_test_output: ${{ needs.tests.outputs.property-polybft-test }} - fuzz_test_output: ${{ needs.tests.outputs.fuzz-test }} + build_blade_output: ${{ needs.ci.outputs.build-blade }} + lint_output: ${{ needs.ci.outputs.lint }} + unit_test_output: ${{ needs.ci.outputs.unit-test }} + e2e_polybft_test_output: ${{ needs.ci.outputs.e2e-polybft-test }} + e2e_legacy_test_output: ${{ needs.ci.outputs.e2e-legacy-test }} + property_polybft_test_output: ${{ needs.ci.outputs.property-polybft-test }} + fuzz_test_output: ${{ needs.ci.outputs.fuzz-test }} deploy_network_terraform_output: ${{ needs.deploy_network.outputs.terraform_output }} deploy_network_ansible_output: ${{ needs.deploy_network.outputs.ansible_output }} load_test_multiple_eoa_output: ${{ needs.load_test_multiple_eoa.outputs.load_test_output }} diff --git a/.github/workflows/notification-deploy-network.yml b/.github/workflows/notification-deploy-network.yml index f3f366db42..bbae04c529 100644 --- a/.github/workflows/notification-deploy-network.yml +++ b/.github/workflows/notification-deploy-network.yml @@ -8,15 +8,15 @@ on: # yamllint disable-line rule:truthy type: string required: true deploy_network_terraform_output: - description: "Deploy Network - Terraform output" + description: Deploy Network - Terraform output type: string required: true deploy_network_ansible_output: - description: "Deploy Network - Ansible output" + description: Deploy Network - Ansible output type: string required: true rpc_url: - description: "JSON-RPC URL" + description: JSON-RPC URL type: string required: true secrets: @@ -90,7 +90,6 @@ jobs: "type": "plain_text", "text": "Workflow Run" }, - "style": "${{ inputs.deploy_network_terraform_output == '' && inputs.deploy_network_ansible_output == '' && env.succeed_bnt || env.failed_bnt }}", "url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" }, { diff --git a/.github/workflows/notification-destroy-network.yml b/.github/workflows/notification-destroy-network.yml index 17ab05558f..1f53823765 100644 --- a/.github/workflows/notification-destroy-network.yml +++ b/.github/workflows/notification-destroy-network.yml @@ -12,11 +12,11 @@ on: # yamllint disable-line rule:truthy type: boolean required: true destroy_network_upload_logs: - description: "Destory Network - Upload Logs" + description: Destory Network - Upload Logs type: string required: true destroy_network_terraform_logs: - description: "Deploy Network - Terraform output" + description: Deploy Network - Terraform output type: string required: true secrets: @@ -81,7 +81,6 @@ jobs: "type": "plain_text", "text": "Workflow Run" }, - "style": "${{ inputs.destroy_network_upload_logs == '' && inputs.destroy_network_terraform_logs == '' && env.succeed_bnt || env.failed_bnt }}", "url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" }, { diff --git a/.github/workflows/notification-load-test.yml b/.github/workflows/notification-load-test.yml index 08ff91b53f..519cc151af 100644 --- a/.github/workflows/notification-load-test.yml +++ b/.github/workflows/notification-load-test.yml @@ -96,7 +96,6 @@ jobs: "type": "plain_text", "text": "Workflow Run" }, - "style": "${{ env.succeed_bnt }}", "url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" } ] diff --git a/.github/workflows/notification-main.yml b/.github/workflows/notification-main.yml index 6c427e0f6b..9ea20fb8b7 100644 --- a/.github/workflows/notification-main.yml +++ b/.github/workflows/notification-main.yml @@ -15,6 +15,10 @@ on: # yamllint disable-line rule:truthy description: Build Blade output type: string required: true + lint_output: + description: Lint output + type: string + required: true unit_test_output: description: Unit Tests output type: string @@ -87,7 +91,7 @@ jobs: { "attachments": [ { - "color": "${{ inputs.build_blade_output == '' && inputs.unit_test_output == '' && inputs.e2e_polybft_test_output == '' && inputs.e2e_legacy_test_output == '' && inputs.property_polybft_test_output == '' && inputs.fuzz_test_output == '' && inputs.deploy_network_terraform_output == '' && inputs.deploy_network_ansible_output == '' && inputs.load_test_multiple_eoa_output == 'true' && inputs.load_test_multiple_erc20_output == 'true' && inputs.destroy_network_logs_output == '' && inputs.destroy_network_terraform_output == '' && env.green_color || env.red_color }}", + "color": "${{ inputs.build_blade_output == '' && inputs.lint_output == '' && inputs.unit_test_output == '' && inputs.e2e_polybft_test_output == '' && inputs.e2e_legacy_test_output == '' && inputs.property_polybft_test_output == '' && inputs.fuzz_test_output == '' && inputs.deploy_network_terraform_output == '' && inputs.deploy_network_ansible_output == '' && inputs.load_test_multiple_eoa_output == 'true' && inputs.load_test_multiple_erc20_output == 'true' && inputs.destroy_network_logs_output == '' && inputs.destroy_network_terraform_output == '' && env.green_color || env.red_color }}", "blocks": [ { "type": "header", @@ -132,7 +136,6 @@ jobs: "type": "plain_text", "text": "Workflow Run" }, - "style": "${{ inputs.build_blade_output == '' && inputs.unit_test_output == '' && inputs.e2e_polybft_test_output == '' && inputs.e2e_legacy_test_output == '' && inputs.property_polybft_test_output == '' && inputs.fuzz_test_output == '' && inputs.deploy_network_terraform_output == '' && inputs.deploy_network_ansible_output == '' && inputs.load_test_multiple_eoa_output == 'true' && inputs.load_test_multiple_erc20_output == 'true' && inputs.destroy_network_logs_output == '' && inputs.destroy_network_terraform_output == '' && env.succeed_bnt || env.failed_bnt }}", "url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" }, { @@ -161,13 +164,13 @@ jobs: ] }, { - "color": "${{ inputs.unit_test_output == '' && inputs.fuzz_test_output == '' && inputs.e2e_legacy_test_output == '' && inputs.e2e_polybft_test_output == '' && inputs.property_polybft_test_output == '' && env.green_color || env.red_color }}", + "color": "${{ inputs.lint_output == '' && inputs.unit_test_output == '' && inputs.fuzz_test_output == '' && inputs.e2e_legacy_test_output == '' && inputs.e2e_polybft_test_output == '' && inputs.property_polybft_test_output == '' && env.green_color || env.red_color }}", "blocks": [ { "type": "section", "text": { "type": "mrkdwn", - "text": "*Tests*\n${{ inputs.unit_test_output == '' && 'Unit' || '~Unit~' }}, ${{ inputs.fuzz_test_output == '' && 'Fuzz' || '~Fuzz~' }},\n${{ inputs.e2e_legacy_test_output == '' && 'E2E Legacy' || '~E2E Legacy~' }}, ${{ inputs.e2e_polybft_test_output == '' && 'E2E PolyBFT' || '~E2E PolyBFT~' }},\n${{ inputs.property_polybft_test_output == '' && 'Property PolyBFT' || '~Property PolyBFT~' }}" + "text": "*CI*\n${{ inputs.lint_output == '' && 'Lint' || '~Lint~' }}, ${{ inputs.unit_test_output == '' && 'Unit' || '~Unit~' }}, ${{ inputs.fuzz_test_output == '' && 'Fuzz' || '~Fuzz~' }},\n${{ inputs.e2e_legacy_test_output == '' && 'E2E Legacy' || '~E2E Legacy~' }}, ${{ inputs.e2e_polybft_test_output == '' && 'E2E PolyBFT' || '~E2E PolyBFT~' }},\n${{ inputs.property_polybft_test_output == '' && 'Property PolyBFT' || '~Property PolyBFT~' }}" } } ] diff --git a/.github/workflows/notification-tests.yml b/.github/workflows/notification-tests.yml deleted file mode 100644 index 746c0029e5..0000000000 --- a/.github/workflows/notification-tests.yml +++ /dev/null @@ -1,108 +0,0 @@ ---- -name: Notification - Tests -on: # yamllint disable-line rule:truthy - workflow_call: - inputs: - unit_test_output: - description: Unit Tests output - type: string - required: true - e2e_polybft_test_output: - description: E2E PolyBFT Tests output - type: string - required: true - e2e_legacy_test_output: - description: E2E Legacy Tests output - type: string - required: true - property_polybft_test_output: - description: Property PolyBFT Tests output - type: string - required: true - fuzz_test_output: - description: Fuzz Tests output - type: string - required: true - secrets: - SLACK_WEBHOOK_URL: - required: true - -jobs: - notification: - name: Notification - runs-on: ubuntu-latest - steps: - - name: Short SHA - id: short_sha - run: echo "value=`echo ${{ github.sha }} | cut -c1-7`" >> $GITHUB_OUTPUT - - name: Notify Slack - uses: slackapi/slack-github-action@v1.25.0 - env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} - SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK - green_color: '#03C03C' - red_color: '#E60012' - succeed_bnt: 'primary' - failed_bnt: 'danger' - with: - payload: | - { - "attachments": [ - { - "color": "${{ inputs.unit_test_output == '' && inputs.fuzz_test_output == '' && inputs.e2e_legacy_test_output == '' && inputs.e2e_polybft_test_output == '' && inputs.property_polybft_test_output == '' && env.green_color || env.red_color }}", - "blocks": [ - { - "type": "header", - "text": { - "type": "plain_text", - "text": "Tests" - } - }, - { - "type": "context", - "elements": [ - { - "type": "mrkdwn", - "text": "Commit: **" - } - ] - }, - { - "type": "context", - "elements": [ - { - "type": "mrkdwn", - "text": "Triggered by: *${{ github.triggering_actor }}*" - } - ] - }, - { - "type": "actions", - "elements": [ - { - "type": "button", - "text": { - "type": "plain_text", - "text": "Workflow Run" - }, - "style": "${{ inputs.unit_test_output == '' && inputs.fuzz_test_output == '' && inputs.e2e_legacy_test_output == '' && inputs.e2e_polybft_test_output == '' && inputs.property_polybft_test_output == '' && env.succeed_bnt || env.failed_bnt }}", - "url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" - } - ] - } - ] - }, - { - "color": "${{ inputs.unit_test_output == '' && inputs.fuzz_test_output == '' && inputs.e2e_legacy_test_output == '' && inputs.e2e_polybft_test_output == '' && inputs.property_polybft_test_output == '' && env.green_color || env.red_color }}", - "blocks": [ - { - "type": "section", - "text": { - "type": "mrkdwn", - "text": "${{ inputs.unit_test_output == '' && 'Unit' || '~Unit~' }}, ${{ inputs.fuzz_test_output == '' && 'Fuzz' || '~Fuzz~' }},\n${{ inputs.e2e_legacy_test_output == '' && 'E2E Legacy' || '~E2E Legacy~' }}, ${{ inputs.e2e_polybft_test_output == '' && 'E2E PolyBFT' || '~E2E PolyBFT~' }},\n${{ inputs.property_polybft_test_output == '' && 'Property PolyBFT' || '~Property PolyBFT~' }}" - } - } - ] - } - ] - } diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index edec12f492..a4cc388ac4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -28,6 +28,8 @@ jobs: run: | TAG=${GITHUB_REF#refs/tags/} echo tag_name=${TAG} >> $GITHUB_OUTPUT + - name: Set Dockerhub organization + run: sed 's/DOCKERHUB_ORGANIZATION/${{ vars.DOCKERHUB_ORGANIZATION }}/g' .goreleaser.yml > .goreleaser.yml.tmp && mv .goreleaser.yml.tmp .goreleaser.yml - name: Set up QEMU uses: docker/setup-qemu-action@v3.0.0 - name: Login to Docker Hub @@ -35,7 +37,6 @@ jobs: with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Run GoReleaser run: | docker run \ diff --git a/.goreleaser.yml b/.goreleaser.yml index 32988d1094..80af36859d 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -77,7 +77,7 @@ snapshot: dockers: - image_templates: - - b4n3/{{ .ProjectName }}:{{ .Version }}-amd64 + - DOCKERHUB_ORGANIZATION/{{ .ProjectName }}:{{ .Version }}-amd64 dockerfile: Dockerfile.release use: buildx goarch: amd64 @@ -88,7 +88,7 @@ dockers: skip_push: false - image_templates: - - b4n3/{{ .ProjectName }}:{{ .Version }}-arm64 + - DOCKERHUB_ORGANIZATION/{{ .ProjectName }}:{{ .Version }}-arm64 dockerfile: Dockerfile.release use: buildx goarch: arm64 @@ -99,14 +99,14 @@ dockers: skip_push: false docker_manifests: - - name_template: b4n3/{{ .ProjectName }}:{{ .Version }} + - name_template: DOCKERHUB_ORGANIZATION/{{ .ProjectName }}:{{ .Version }} image_templates: - - b4n3/{{ .ProjectName }}:{{ .Version }}-amd64 - - b4n3/{{ .ProjectName }}:{{ .Version }}-arm64 + - DOCKERHUB_ORGANIZATION/{{ .ProjectName }}:{{ .Version }}-amd64 + - DOCKERHUB_ORGANIZATION/{{ .ProjectName }}:{{ .Version }}-arm64 skip_push: false - - name_template: b4n3/{{ .ProjectName }}:latest + - name_template: DOCKERHUB_ORGANIZATION/{{ .ProjectName }}:latest image_templates: - - b4n3/{{ .ProjectName }}:{{ .Version }}-amd64 - - b4n3/{{ .ProjectName }}:{{ .Version }}-arm64 + - DOCKERHUB_ORGANIZATION/{{ .ProjectName }}:{{ .Version }}-amd64 + - DOCKERHUB_ORGANIZATION/{{ .ProjectName }}:{{ .Version }}-arm64 skip_push: auto From 826f1981df23e4cae5fa3cd9ee62299b69da7270 Mon Sep 17 00:00:00 2001 From: Branislav Kojic Date: Mon, 12 Feb 2024 20:16:36 +0100 Subject: [PATCH 58/67] Fix Load Test notifications (#59) * Deploy Network * Add Permissions * Minor changes * Concurrency change * Destroy Network * Minor changes * Minor changes * Fix commit sha * Minor changes * Add Tests * Disable Tests temporarily * Nightly Build * Minor fixes * Big changes * Minor changes * Minor changes * Minor changes * Notification fixes * Notification changes * Minor changes * Permissions fixes * Minor changes * Notification changes * Minor changes * Display commit on notifications * Minor changes * Minor fixes * Logs notification fixes * Minor changes * Minor changes * Minor changes * Notifications fixes * Minor changes * Update actions version * Deployment fixes * Minor changes * Minor changes * Build repository fixes * Load Test notification text changes * EIP-1559; Check if the network is already deployed; Restore Blade Data * Notifications fixes; Pass blade_repository when deploying the network * Terraform fixes * Minor changes * Minor changes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Restore data fixes * Fix condition * Fix the RPC URL when the network is already deployed * Fix the RPC URL when the network is already deployed * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fixed when the network is first time deploying * Fixed upload logs * Fix: null URL if the network is destroyed but the state file exists * Main notification changes * Fix RPC URL; Fix Logs and Data upload * Minor fix * Minor fix * Notification fixes * Deploy fixes * Big changes * Condition fixes * Version changes * Test fixes * Change golangci-lint-action source * Change ec2-github-runner version; Always execute Build Blade * Minor changes * Lint fixes * Nightly test * Minor fixes * Fix Linter bug * Release changes * goreleaser fixes * goreleaser fixes * goreleaser fixes * goreleaser fixes * goreleaser fixes * docker repository name fixes * Minor fixes * Warrning fixes * docker repository name fixes * Add organization variable * Rename Tests to CI; Minor changes * Fix Load Test notifications * Fix Load Test notifications --- .github/workflows/nightly.yml | 10 +++++---- .../workflows/notification-deploy-network.yml | 4 ++-- .../notification-destroy-network.yml | 4 ++-- .github/workflows/notification-load-test.yml | 2 +- ...tion-main.yml => notification-nightly.yml} | 22 +++++-------------- 5 files changed, 16 insertions(+), 26 deletions(-) rename .github/workflows/{notification-main.yml => notification-nightly.yml} (86%) diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 985d53e2d2..c22c49b8be 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -106,9 +106,9 @@ jobs: AWS_ROLE_ARN: ${{ secrets.AWS_ROLE_ARN }} AWS_S3_BLADE_BUCKET: ${{ secrets.AWS_S3_BLADE_BUCKET }} VAULT_PASSWORD: ${{ secrets.VAULT_PASSWORD }} - notification_main: + notification_nightly: name: Nightly Notification - uses: ./.github/workflows/notification-main.yml + uses: ./.github/workflows/notification-nightly.yml needs: [ci, deploy_network, load_test_multiple_eoa, load_test_multiple_erc20, destroy_network] if: success() || failure() with: @@ -133,7 +133,8 @@ jobs: notification_load_test_multiple_eoa: name: Load Test EOA Notification uses: ./.github/workflows/notification-load-test.yml - needs: [load_test_multiple_eoa, notification_main] + needs: [load_test_multiple_eoa, notification_nightly] + if: needs.load_test_multiple_eoa.outputs.load_test_output == 'true' with: environment: nightly scenario: EOA @@ -149,7 +150,8 @@ jobs: notification_load_test_multiple_erc20: name: Load Test ERC20 Notification uses: ./.github/workflows/notification-load-test.yml - needs: [load_test_multiple_erc20, notification_main] + needs: [load_test_multiple_erc20, notification_nightly] + if: needs.load_test_multiple_erc20.outputs.load_test_output with: environment: nightly scenario: ERC20 diff --git a/.github/workflows/notification-deploy-network.yml b/.github/workflows/notification-deploy-network.yml index bbae04c529..3efc3a9ff8 100644 --- a/.github/workflows/notification-deploy-network.yml +++ b/.github/workflows/notification-deploy-network.yml @@ -36,8 +36,8 @@ jobs: env: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK - green_color: '#03C03C' - red_color: '#E60012' + green_color: '#007651' + red_color: '#E21550' succeed_bnt: 'primary' failed_bnt: 'danger' with: diff --git a/.github/workflows/notification-destroy-network.yml b/.github/workflows/notification-destroy-network.yml index 1f53823765..90d4e5760f 100644 --- a/.github/workflows/notification-destroy-network.yml +++ b/.github/workflows/notification-destroy-network.yml @@ -35,8 +35,8 @@ jobs: env: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK - green_color: '#03C03C' - red_color: '#E60012' + green_color: '#007651' + red_color: '#E21550' succeed_bnt: 'primary' failed_bnt: 'danger' url: https://s3.console.aws.amazon.com/s3/buckets/${{ secrets.AWS_S3_BLADE_BUCKET }}?region=${{ vars.AWS_REGION }}&prefix=logs/${{ github.run_id }}/ diff --git a/.github/workflows/notification-load-test.yml b/.github/workflows/notification-load-test.yml index 519cc151af..8c1f747414 100644 --- a/.github/workflows/notification-load-test.yml +++ b/.github/workflows/notification-load-test.yml @@ -53,7 +53,7 @@ jobs: env: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK - green_color: '#03C03C' + green_color: '#007651' succeed_bnt: 'primary' with: payload: | diff --git a/.github/workflows/notification-main.yml b/.github/workflows/notification-nightly.yml similarity index 86% rename from .github/workflows/notification-main.yml rename to .github/workflows/notification-nightly.yml index 9ea20fb8b7..14243b6055 100644 --- a/.github/workflows/notification-main.yml +++ b/.github/workflows/notification-nightly.yml @@ -82,8 +82,8 @@ jobs: env: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK - green_color: '#03C03C' - red_color: '#E60012' + green_color: '#007651' + red_color: '#E21550' succeed_bnt: 'primary' failed_bnt: 'danger' with: @@ -97,7 +97,7 @@ jobs: "type": "header", "text": { "type": "plain_text", - "text": "${{ inputs.environment }} build" + "text": "Nightly build" } }, { @@ -152,25 +152,13 @@ jobs: ] }, { - "color": "${{ inputs.build_blade_output == '' && env.green_color || env.red_color }}", + "color": "${{ inputs.build_blade_output == '' && inputs.lint_output == '' && inputs.unit_test_output == '' && inputs.fuzz_test_output == '' && inputs.e2e_legacy_test_output == '' && inputs.e2e_polybft_test_output == '' && inputs.property_polybft_test_output == '' && env.green_color || env.red_color }}", "blocks": [ { "type": "section", "text": { "type": "mrkdwn", - "text": "*Build Blade*" - } - } - ] - }, - { - "color": "${{ inputs.lint_output == '' && inputs.unit_test_output == '' && inputs.fuzz_test_output == '' && inputs.e2e_legacy_test_output == '' && inputs.e2e_polybft_test_output == '' && inputs.property_polybft_test_output == '' && env.green_color || env.red_color }}", - "blocks": [ - { - "type": "section", - "text": { - "type": "mrkdwn", - "text": "*CI*\n${{ inputs.lint_output == '' && 'Lint' || '~Lint~' }}, ${{ inputs.unit_test_output == '' && 'Unit' || '~Unit~' }}, ${{ inputs.fuzz_test_output == '' && 'Fuzz' || '~Fuzz~' }},\n${{ inputs.e2e_legacy_test_output == '' && 'E2E Legacy' || '~E2E Legacy~' }}, ${{ inputs.e2e_polybft_test_output == '' && 'E2E PolyBFT' || '~E2E PolyBFT~' }},\n${{ inputs.property_polybft_test_output == '' && 'Property PolyBFT' || '~Property PolyBFT~' }}" + "text": "*CI*\n${{ inputs.build_blade_output == '' && 'Build Blade' || '~Build Blade~' }}, ${{ inputs.lint_output == '' && 'Lint' || '~Lint~' }}, ${{ inputs.unit_test_output == '' && 'Unit Tests' || '~Unit Tests~' }},\n${{ inputs.fuzz_test_output == '' && 'Fuzz Tests' || '~Fuzz Tests~' }}, ${{ inputs.e2e_legacy_test_output == '' && 'E2E Legacy Tests' || '~E2E Legacy Tests~' }},\n${{ inputs.e2e_polybft_test_output == '' && 'E2E PolyBFT Tests' || '~E2E PolyBFT Tests~' }}, ${{ inputs.property_polybft_test_output == '' && 'Property PolyBFT Tests' || '~Property PolyBFT Tests~' }}" } } ] From c085a567ee8cc4c4bcfa57d4a2a2c8ce2ac903ac Mon Sep 17 00:00:00 2001 From: Branislav Kojic Date: Mon, 12 Feb 2024 20:29:09 +0100 Subject: [PATCH 59/67] Minor fixes (#60) * Deploy Network * Add Permissions * Minor changes * Concurrency change * Destroy Network * Minor changes * Minor changes * Fix commit sha * Minor changes * Add Tests * Disable Tests temporarily * Nightly Build * Minor fixes * Big changes * Minor changes * Minor changes * Minor changes * Notification fixes * Notification changes * Minor changes * Permissions fixes * Minor changes * Notification changes * Minor changes * Display commit on notifications * Minor changes * Minor fixes * Logs notification fixes * Minor changes * Minor changes * Minor changes * Notifications fixes * Minor changes * Update actions version * Deployment fixes * Minor changes * Minor changes * Build repository fixes * Load Test notification text changes * EIP-1559; Check if the network is already deployed; Restore Blade Data * Notifications fixes; Pass blade_repository when deploying the network * Terraform fixes * Minor changes * Minor changes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Restore data fixes * Fix condition * Fix the RPC URL when the network is already deployed * Fix the RPC URL when the network is already deployed * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fixed when the network is first time deploying * Fixed upload logs * Fix: null URL if the network is destroyed but the state file exists * Main notification changes * Fix RPC URL; Fix Logs and Data upload * Minor fix * Minor fix * Notification fixes * Deploy fixes * Big changes * Condition fixes * Version changes * Test fixes * Change golangci-lint-action source * Change ec2-github-runner version; Always execute Build Blade * Minor changes * Lint fixes * Nightly test * Minor fixes * Fix Linter bug * Release changes * goreleaser fixes * goreleaser fixes * goreleaser fixes * goreleaser fixes * goreleaser fixes * docker repository name fixes * Minor fixes * Warrning fixes * docker repository name fixes * Add organization variable * Rename Tests to CI; Minor changes * Fix Load Test notifications * Fix Load Test notifications * Minor changes --- .github/workflows/notification-nightly.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/notification-nightly.yml b/.github/workflows/notification-nightly.yml index 14243b6055..49c7949632 100644 --- a/.github/workflows/notification-nightly.yml +++ b/.github/workflows/notification-nightly.yml @@ -1,5 +1,5 @@ --- -name: Notification - Main +name: Notification - Nightly on: # yamllint disable-line rule:truthy workflow_call: inputs: From 8065e3d9ab380689a338b55cecda51bd299661a8 Mon Sep 17 00:00:00 2001 From: Branislav Kojic Date: Mon, 12 Feb 2024 20:57:42 +0100 Subject: [PATCH 60/67] Minor fixes (#61) * Deploy Network * Add Permissions * Minor changes * Concurrency change * Destroy Network * Minor changes * Minor changes * Fix commit sha * Minor changes * Add Tests * Disable Tests temporarily * Nightly Build * Minor fixes * Big changes * Minor changes * Minor changes * Minor changes * Notification fixes * Notification changes * Minor changes * Permissions fixes * Minor changes * Notification changes * Minor changes * Display commit on notifications * Minor changes * Minor fixes * Logs notification fixes * Minor changes * Minor changes * Minor changes * Notifications fixes * Minor changes * Update actions version * Deployment fixes * Minor changes * Minor changes * Build repository fixes * Load Test notification text changes * EIP-1559; Check if the network is already deployed; Restore Blade Data * Notifications fixes; Pass blade_repository when deploying the network * Terraform fixes * Minor changes * Minor changes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Restore data fixes * Fix condition * Fix the RPC URL when the network is already deployed * Fix the RPC URL when the network is already deployed * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fixed when the network is first time deploying * Fixed upload logs * Fix: null URL if the network is destroyed but the state file exists * Main notification changes * Fix RPC URL; Fix Logs and Data upload * Minor fix * Minor fix * Notification fixes * Deploy fixes * Big changes * Condition fixes * Version changes * Test fixes * Change golangci-lint-action source * Change ec2-github-runner version; Always execute Build Blade * Minor changes * Lint fixes * Nightly test * Minor fixes * Fix Linter bug * Release changes * goreleaser fixes * goreleaser fixes * goreleaser fixes * goreleaser fixes * goreleaser fixes * docker repository name fixes * Minor fixes * Warrning fixes * docker repository name fixes * Add organization variable * Rename Tests to CI; Minor changes * Fix Load Test notifications * Fix Load Test notifications * Minor changes * Minor fixes --- .github/workflows/nightly.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index c22c49b8be..0c3648097d 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -151,7 +151,7 @@ jobs: name: Load Test ERC20 Notification uses: ./.github/workflows/notification-load-test.yml needs: [load_test_multiple_erc20, notification_nightly] - if: needs.load_test_multiple_erc20.outputs.load_test_output + if: needs.load_test_multiple_erc20.outputs.load_test_output == 'true' with: environment: nightly scenario: ERC20 From 9e828c4b8d874ae328dc31e33d45644c9dc0b45e Mon Sep 17 00:00:00 2001 From: Branislav Kojic Date: Tue, 13 Feb 2024 07:21:06 +0100 Subject: [PATCH 61/67] Fix Load Tests Notifications (#62) * Deploy Network * Add Permissions * Minor changes * Concurrency change * Destroy Network * Minor changes * Minor changes * Fix commit sha * Minor changes * Add Tests * Disable Tests temporarily * Nightly Build * Minor fixes * Big changes * Minor changes * Minor changes * Minor changes * Notification fixes * Notification changes * Minor changes * Permissions fixes * Minor changes * Notification changes * Minor changes * Display commit on notifications * Minor changes * Minor fixes * Logs notification fixes * Minor changes * Minor changes * Minor changes * Notifications fixes * Minor changes * Update actions version * Deployment fixes * Minor changes * Minor changes * Build repository fixes * Load Test notification text changes * EIP-1559; Check if the network is already deployed; Restore Blade Data * Notifications fixes; Pass blade_repository when deploying the network * Terraform fixes * Minor changes * Minor changes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Notification fixes * Restore data fixes * Fix condition * Fix the RPC URL when the network is already deployed * Fix the RPC URL when the network is already deployed * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fix condition * Fixed when the network is first time deploying * Fixed upload logs * Fix: null URL if the network is destroyed but the state file exists * Main notification changes * Fix RPC URL; Fix Logs and Data upload * Minor fix * Minor fix * Notification fixes * Deploy fixes * Big changes * Condition fixes * Version changes * Test fixes * Change golangci-lint-action source * Change ec2-github-runner version; Always execute Build Blade * Minor changes * Lint fixes * Nightly test * Minor fixes * Fix Linter bug * Release changes * goreleaser fixes * goreleaser fixes * goreleaser fixes * goreleaser fixes * goreleaser fixes * docker repository name fixes * Minor fixes * Warrning fixes * docker repository name fixes * Add organization variable * Rename Tests to CI; Minor changes * Fix Load Test notifications * Fix Load Test notifications * Minor changes * Minor fixes * Fix Load Tests notifications --- .github/workflows/nightly.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 0c3648097d..0b75770a36 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -134,7 +134,7 @@ jobs: name: Load Test EOA Notification uses: ./.github/workflows/notification-load-test.yml needs: [load_test_multiple_eoa, notification_nightly] - if: needs.load_test_multiple_eoa.outputs.load_test_output == 'true' + if: always() && needs.load_test_multiple_eoa.outputs.load_test_output == 'true' with: environment: nightly scenario: EOA @@ -151,7 +151,7 @@ jobs: name: Load Test ERC20 Notification uses: ./.github/workflows/notification-load-test.yml needs: [load_test_multiple_erc20, notification_nightly] - if: needs.load_test_multiple_erc20.outputs.load_test_output == 'true' + if: always() && needs.load_test_multiple_erc20.outputs.load_test_output == 'true' with: environment: nightly scenario: ERC20 From 9f22d1a93eadcf6ac3111a3f002bfc3189489df3 Mon Sep 17 00:00:00 2001 From: Branislav Kojic Date: Thu, 22 Feb 2024 11:49:10 +0100 Subject: [PATCH 62/67] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index b6ab6b3662..75fb6520ec 100644 --- a/README.md +++ b/README.md @@ -11,3 +11,5 @@ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + +. From 0e1c35f464af8bb97d58b607d8a7a17f0d287c6e Mon Sep 17 00:00:00 2001 From: Branislav Kojic Date: Fri, 8 Mar 2024 14:32:40 +0100 Subject: [PATCH 63/67] Change ID of `blade` user --- Dockerfile.release | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Dockerfile.release b/Dockerfile.release index 9100d7eb4a..739b1b0447 100644 --- a/Dockerfile.release +++ b/Dockerfile.release @@ -9,7 +9,9 @@ COPY blade /usr/local/bin/ EXPOSE 8545 9632 1478 RUN addgroup -S blade-group \ - && adduser -S blade -G blade-group + && adduser -S blade -G blade-group \ + && apk add --no-cache shadow \ + && usermod -u 1001 blade USER blade From eda36ff95ca298ccf9d11ddb578996731ef987ec Mon Sep 17 00:00:00 2001 From: Branislav Kojic Date: Tue, 12 Mar 2024 07:24:02 +0100 Subject: [PATCH 64/67] Minor changes --- Dockerfile.release | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Dockerfile.release b/Dockerfile.release index 739b1b0447..217268c613 100644 --- a/Dockerfile.release +++ b/Dockerfile.release @@ -9,9 +9,7 @@ COPY blade /usr/local/bin/ EXPOSE 8545 9632 1478 RUN addgroup -S blade-group \ - && adduser -S blade -G blade-group \ - && apk add --no-cache shadow \ - && usermod -u 1001 blade + && adduser -S -u 1001 blade -G blade-group USER blade From e1d1dce469c18bafbf70f6e5f08153b3f674f6ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Negovanovi=C4=87?= <93934272+Stefan-Ethernal@users.noreply.github.com> Date: Wed, 13 Mar 2024 09:23:42 +0100 Subject: [PATCH 65/67] Execute EVM benchmark subtests independently (#150) * Change the way EVM benchmark subtests are ran * Remove redundant listFolders call * Do not execute EVM state tests multiple times * Remove listFolders function --- tests/evm_benchmark_test.go | 57 +++++++++++++++-------------- tests/state_test.go | 73 +++++++++++++++++-------------------- tests/state_test_util.go | 56 +++++++--------------------- 3 files changed, 76 insertions(+), 110 deletions(-) diff --git a/tests/evm_benchmark_test.go b/tests/evm_benchmark_test.go index 01e94bd90d..3c333f8526 100644 --- a/tests/evm_benchmark_test.go +++ b/tests/evm_benchmark_test.go @@ -5,6 +5,8 @@ import ( "fmt" "math/big" "os" + "path/filepath" + "strings" "testing" "time" @@ -18,48 +20,47 @@ import ( ) const ( - benchmarksDir = "evm-benchmarks/benchmarks" - chainID = 10 + benchmarksDir = "evm-benchmarks" + testsExtension = ".json" + chainID = 10 ) func BenchmarkEVM(b *testing.B) { - folders, err := listFolders([]string{benchmarksDir}) + files, err := listFiles(benchmarksDir, testsExtension) require.NoError(b, err) - for _, folder := range folders { - files, err := listFiles(folder, ".json") - require.NoError(b, err) + for _, file := range files { + name := filepath.ToSlash(strings.TrimPrefix(strings.TrimSuffix(file, testsExtension), benchmarksDir+string(filepath.Separator))) - for _, file := range files { - name := getTestName(file) + b.Run(name, func(b *testing.B) { + data, err := os.ReadFile(file) + require.NoError(b, err) - b.Run(name, func(b *testing.B) { - data, err := os.ReadFile(file) - require.NoError(b, err) + var testCases map[string]testCase + if err = json.Unmarshal(data, &testCases); err != nil { + b.Fatalf("failed to unmarshal %s: %v", file, err) + } - var testCases map[string]testCase - if err = json.Unmarshal(data, &testCases); err != nil { - b.Fatalf("failed to unmarshal %s: %v", file, err) - } - - for _, tc := range testCases { - for fork, postState := range tc.Post { - forks, exists := Forks[fork] - if !exists { - b.Logf("%s fork is not supported, skipping test case.", fork) - continue - } + for _, tc := range testCases { + for fork, postState := range tc.Post { + forks, exists := Forks[fork] + if !exists { + b.Logf("%s fork is not supported, skipping test case.", fork) + continue + } - fc := &forkConfig{name: fork, forks: forks} + fc := &forkConfig{name: fork, forks: forks} - for idx, postStateEntry := range postState { + for idx, postStateEntry := range postState { + key := fmt.Sprintf("%s/%d", fork, idx) + b.Run(key, func(b *testing.B) { err := runBenchmarkTest(b, tc, fc, postStateEntry) require.NoError(b, err, fmt.Sprintf("test %s (case#%d) execution failed", name, idx)) - } + }) } } - }) - } + } + }) } } diff --git a/tests/state_test.go b/tests/state_test.go index e4fe770177..ebc6a287c7 100644 --- a/tests/state_test.go +++ b/tests/state_test.go @@ -52,60 +52,55 @@ func TestState(t *testing.T) { "CALLBlake2f_MaxRounds", } - folders, err := listFolders([]string{stateTestsDir}) + files, err := listFiles(stateTestsDir, ".json") require.NoError(t, err) - for _, folder := range folders { - files, err := listFiles(folder, ".json") - require.NoError(t, err) + for _, file := range files { + if contains(long, file) && testing.Short() { + t.Logf("Long test '%s' is skipped in short mode\n", file) - for _, file := range files { - if contains(long, file) && testing.Short() { - t.Logf("Long test '%s' is skipped in short mode\n", file) - - continue - } + continue + } - if contains(skip, file) { - t.Logf("Test '%s' is skipped\n", file) + if contains(skip, file) { + t.Logf("Test '%s' is skipped\n", file) - continue - } + continue + } - file := file - t.Run(file, func(t *testing.T) { - t.Parallel() + file := file + t.Run(file, func(t *testing.T) { + t.Parallel() - data, err := os.ReadFile(file) - require.NoError(t, err) + data, err := os.ReadFile(file) + require.NoError(t, err) - var testCases map[string]testCase - if err = json.Unmarshal(data, &testCases); err != nil { - t.Fatalf("failed to unmarshal %s: %v", file, err) - } + var testCases map[string]testCase + if err = json.Unmarshal(data, &testCases); err != nil { + t.Fatalf("failed to unmarshal %s: %v", file, err) + } - for _, tc := range testCases { - for fork, postState := range tc.Post { - forks, exists := Forks[fork] - if !exists { - t.Logf("%s fork is not supported, skipping test case.", fork) - continue - } + for _, tc := range testCases { + for fork, postState := range tc.Post { + forks, exists := Forks[fork] + if !exists { + t.Logf("%s fork is not supported, skipping test case.", fork) + continue + } - fc := &forkConfig{name: fork, forks: forks} + fc := &forkConfig{name: fork, forks: forks} - for idx, postStateEntry := range postState { - start := time.Now() - err := runSpecificTestCase(t, file, tc, fc, idx, postStateEntry) + for idx, postStateEntry := range postState { + start := time.Now() + err := runSpecificTestCase(t, file, tc, fc, idx, postStateEntry) - t.Logf("'%s' executed. Fork: %s. Case: %d, Duration=%v\n", file, fork, idx, time.Since(start)) + t.Logf("'%s' executed. Fork: %s. Case: %d, Duration=%v\n", file, fork, idx, time.Since(start)) - require.NoError(t, tc.checkError(fork, idx, err)) - } + require.NoError(t, tc.checkError(fork, idx, err)) } } - }) - } + } + }) } } diff --git a/tests/state_test_util.go b/tests/state_test_util.go index 43f0be030a..cedc8db5cb 100644 --- a/tests/state_test_util.go +++ b/tests/state_test_util.go @@ -6,7 +6,6 @@ import ( "fmt" "io/fs" "math/big" - "os" "path/filepath" "strings" "testing" @@ -615,57 +614,28 @@ func contains(l []string, name string) bool { return false } -func listFolders(paths []string) ([]string, error) { - var folders []string - - for _, rootPath := range paths { - err := filepath.WalkDir(rootPath, func(path string, d fs.DirEntry, err error) error { - if err != nil { - return err - } - - if d.IsDir() { - files, err := os.ReadDir(path) - if err != nil { - return err - } - - if len(files) > 0 { - folders = append(folders, path) - } - } - - return nil - }) - - if err != nil { - return nil, err - } - } - - return folders, nil -} - func listFiles(folder string, extensions ...string) ([]string, error) { var files []string - err := filepath.WalkDir(folder, func(path string, d fs.DirEntry, err error) error { + err := filepath.Walk(folder, func(path string, info fs.FileInfo, err error) error { if err != nil { return err } - if !d.IsDir() { - if len(extensions) > 0 { - // filter files by extensions - for _, ext := range extensions { - if strings.HasSuffix(path, ext) { - files = append(files, path) - } + if info.IsDir() { + return nil + } + + if len(extensions) > 0 { + // filter files by extensions + for _, ext := range extensions { + if fileExt := filepath.Ext(path); fileExt == ext { + files = append(files, path) } - } else { - // if no extensions filter is provided, add all files - files = append(files, path) } + } else { + // if no extensions filter is provided, add all files + files = append(files, path) } return nil From 65015161002d71ccda5405cf42251a0e3a601804 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Du=C5=A1an=20Nosovi=C4=87?= <118283942+dusannosovic-ethernal@users.noreply.github.com> Date: Thu, 14 Mar 2024 09:44:17 +0100 Subject: [PATCH 66/67] added constructor for all types of transactions (#153) * added contructor for all types of transactions * legacy transaction test fix * other transactions test fix * legacy test fix * state test fix * comment fix --- blockchain/blockchain_test.go | 67 +++++------ blockchain/storage/leveldb/leveldb_test.go | 18 ++- blockchain/storage/testing.go | 54 ++++----- consensus/polybft/block_builder_test.go | 16 ++- consensus/polybft/fsm.go | 16 ++- consensus/polybft/fsm_test.go | 13 +-- crypto/txsigner_eip155_test.go | 24 ++-- crypto/txsigner_frontier_test.go | 13 +-- crypto/txsigner_london_test.go | 72 +++++------- e2e/framework/testserver.go | 20 ++-- e2e/txpool_test.go | 111 +++++++++--------- gasprice/feehistory_test.go | 14 +-- gasprice/gasprice_test.go | 36 +++--- helper/tests/testing.go | 23 ++-- jsonrpc/debug_endpoint_test.go | 22 ++-- jsonrpc/eth_blockchain_test.go | 4 +- jsonrpc/eth_endpoint_test.go | 124 ++++++++++----------- jsonrpc/eth_txpool_test.go | 24 ++-- jsonrpc/filter_manager_fuzz_test.go | 30 ++--- jsonrpc/filter_manager_test.go | 6 +- jsonrpc/helper_test.go | 122 +++++++++----------- jsonrpc/txpool_endpoint_test.go | 52 ++++----- jsonrpc/types_test.go | 52 ++++----- state/executor_test.go | 40 +++---- state/transition_test.go | 12 +- tests/state_test_util.go | 67 ++++++----- types/access_list_tx.go | 12 +- types/dynamic_fee_tx.go | 12 +- types/legacy_tx.go | 12 +- types/state_tx.go | 12 +- types/transaction.go | 88 ++++++++++++++- 31 files changed, 585 insertions(+), 603 deletions(-) diff --git a/blockchain/blockchain_test.go b/blockchain/blockchain_test.go index 1932060ac3..8b66c81b80 100644 --- a/blockchain/blockchain_test.go +++ b/blockchain/blockchain_test.go @@ -590,13 +590,8 @@ func TestBlockchainWriteBody(t *testing.T) { t.Run("should succeed if tx has from field", func(t *testing.T) { t.Parallel() - tx := types.NewTx(&types.LegacyTx{ - BaseTx: &types.BaseTx{ - Value: big.NewInt(10), - V: big.NewInt(1), - From: addr, - }, - }) + tx := types.NewTx(types.NewLegacyTx(types.WithValue(big.NewInt(10)), + types.WithSignatureValues(big.NewInt(1), nil, nil), types.WithFrom(addr))) block := &types.Block{ Header: &types.Header{}, @@ -624,12 +619,8 @@ func TestBlockchainWriteBody(t *testing.T) { t.Run("should return error if tx doesn't have from and recovering address fails", func(t *testing.T) { t.Parallel() - tx := types.NewTx(&types.LegacyTx{ - BaseTx: &types.BaseTx{ - Value: big.NewInt(10), - V: big.NewInt(1), - }, - }) + tx := types.NewTx(types.NewLegacyTx(types.WithValue(big.NewInt(10)), + types.WithSignatureValues(big.NewInt(1), nil, nil))) block := &types.Block{ Header: &types.Header{}, @@ -658,12 +649,8 @@ func TestBlockchainWriteBody(t *testing.T) { t.Run("should recover from address and store to storage", func(t *testing.T) { t.Parallel() - tx := types.NewTx(&types.LegacyTx{ - BaseTx: &types.BaseTx{ - Value: big.NewInt(10), - V: big.NewInt(1), - }, - }) + tx := types.NewTx(types.NewLegacyTx(types.WithValue(big.NewInt(10)), + types.WithSignatureValues(big.NewInt(1), nil, nil))) block := &types.Block{ Header: &types.Header{}, @@ -721,8 +708,8 @@ func Test_recoverFromFieldsInBlock(t *testing.T) { }, } - tx1 := types.NewTx(&types.LegacyTx{BaseTx: &types.BaseTx{Nonce: 0, From: addr1}}) - tx2 := types.NewTx(&types.LegacyTx{BaseTx: &types.BaseTx{Nonce: 1, From: types.ZeroAddress}}) + tx1 := types.NewTx(types.NewLegacyTx(types.WithNonce(0), types.WithFrom(addr1))) + tx2 := types.NewTx(types.NewLegacyTx(types.WithNonce(1), types.WithFrom(types.ZeroAddress))) computeTxHashes(tx1, tx2) @@ -751,9 +738,9 @@ func Test_recoverFromFieldsInBlock(t *testing.T) { }, } - tx1 := types.NewTx(&types.LegacyTx{BaseTx: &types.BaseTx{Nonce: 0, From: types.ZeroAddress}}) - tx2 := types.NewTx(&types.LegacyTx{BaseTx: &types.BaseTx{Nonce: 1, From: types.ZeroAddress}}) - tx3 := types.NewTx(&types.LegacyTx{BaseTx: &types.BaseTx{Nonce: 2, From: types.ZeroAddress}}) + tx1 := types.NewTx(types.NewLegacyTx(types.WithNonce(0), types.WithFrom(types.ZeroAddress))) + tx2 := types.NewTx(types.NewLegacyTx(types.WithNonce(1), types.WithFrom(types.ZeroAddress))) + tx3 := types.NewTx(types.NewLegacyTx(types.WithNonce(2), types.WithFrom(types.ZeroAddress))) computeTxHashes(tx1, tx2, tx3) @@ -807,8 +794,8 @@ func Test_recoverFromFieldsInTransactions(t *testing.T) { }, } - tx1 := types.NewTx(&types.LegacyTx{BaseTx: &types.BaseTx{Nonce: 0, From: addr1}}) - tx2 := types.NewTx(&types.LegacyTx{BaseTx: &types.BaseTx{Nonce: 1, From: types.ZeroAddress}}) + tx1 := types.NewTx(types.NewLegacyTx(types.WithNonce(0), types.WithFrom(addr1))) + tx2 := types.NewTx(types.NewLegacyTx(types.WithNonce(1), types.WithFrom(types.ZeroAddress))) computeTxHashes(tx1, tx2) @@ -836,9 +823,9 @@ func Test_recoverFromFieldsInTransactions(t *testing.T) { }, } - tx1 := types.NewTx(&types.LegacyTx{BaseTx: &types.BaseTx{Nonce: 0, From: types.ZeroAddress}}) - tx2 := types.NewTx(&types.LegacyTx{BaseTx: &types.BaseTx{Nonce: 1, From: types.ZeroAddress}}) - tx3 := types.NewTx(&types.LegacyTx{BaseTx: &types.BaseTx{Nonce: 2, From: types.ZeroAddress}}) + tx1 := types.NewTx(types.NewLegacyTx(types.WithNonce(0), types.WithFrom(types.ZeroAddress))) + tx2 := types.NewTx(types.NewLegacyTx(types.WithNonce(1), types.WithFrom(types.ZeroAddress))) + tx3 := types.NewTx(types.NewLegacyTx(types.WithNonce(2), types.WithFrom(types.ZeroAddress))) computeTxHashes(tx1, tx2, tx3) @@ -870,8 +857,8 @@ func Test_recoverFromFieldsInTransactions(t *testing.T) { }, } - tx1 := types.NewTx(&types.LegacyTx{BaseTx: &types.BaseTx{Nonce: 0, From: addr1}}) - tx2 := types.NewTx(&types.LegacyTx{BaseTx: &types.BaseTx{Nonce: 1, From: addr2}}) + tx1 := types.NewTx(types.NewLegacyTx(types.WithNonce(0), types.WithFrom(addr1))) + tx2 := types.NewTx(types.NewLegacyTx(types.WithNonce(1), types.WithFrom(addr2))) computeTxHashes(tx1, tx2) @@ -906,12 +893,10 @@ func TestBlockchainReadBody(t *testing.T) { batchWriter := storage.NewBatchWriter(b.db) - tx := types.NewTx(&types.LegacyTx{ - BaseTx: &types.BaseTx{ - Value: big.NewInt(10), - V: big.NewInt(1), - }, - }) + tx := types.NewTx(types.NewLegacyTx( + types.WithValue(big.NewInt(10)), + types.WithSignatureValues(big.NewInt(1), nil, nil), + )) tx.ComputeHash() @@ -1610,11 +1595,9 @@ func TestBlockchain_WriteFullBlock(t *testing.T) { {GasUsed: 100}, {GasUsed: 200}, } - tx := types.NewTx(&types.LegacyTx{ - BaseTx: &types.BaseTx{ - Value: big.NewInt(1), - }, - }) + tx := types.NewTx(types.NewLegacyTx( + types.WithValue(big.NewInt(1)), + )) tx.ComputeHash() header.ComputeHash() diff --git a/blockchain/storage/leveldb/leveldb_test.go b/blockchain/storage/leveldb/leveldb_test.go index 17fe6418d0..d149c65c6a 100644 --- a/blockchain/storage/leveldb/leveldb_test.go +++ b/blockchain/storage/leveldb/leveldb_test.go @@ -54,16 +54,14 @@ func generateTxs(t *testing.T, startNonce, count int, from types.Address, to *ty txs := make([]*types.Transaction, count) for i := range txs { - tx := types.NewTx(&types.DynamicFeeTx{ - GasFeeCap: big.NewInt(100), - GasTipCap: big.NewInt(10), - BaseTx: &types.BaseTx{ - Gas: types.StateTransactionGasLimit, - Nonce: uint64(startNonce + i), - To: to, - Value: big.NewInt(2000), - }, - }) + tx := types.NewTx(types.NewDynamicFeeTx( + types.WithGasFeeCap(big.NewInt(100)), + types.WithGasTipCap(big.NewInt(10)), + types.WithGas(types.StateTransactionGasLimit), + types.WithNonce(uint64(startNonce+1)), + types.WithTo(to), + types.WithValue(big.NewInt(2000)), + )) input := make([]byte, 1000) _, err := rand.Read(input) diff --git a/blockchain/storage/testing.go b/blockchain/storage/testing.go index 6e243aa8e3..f6ce56840e 100644 --- a/blockchain/storage/testing.go +++ b/blockchain/storage/testing.go @@ -270,31 +270,27 @@ func testBody(t *testing.T, m PlaceholderStorage) { require.NoError(t, batch.WriteBatch()) addr1 := types.StringToAddress("11") - t0 := types.NewTx(&types.LegacyTx{ - GasPrice: big.NewInt(11), - BaseTx: &types.BaseTx{ - Nonce: 0, - To: &addr1, - Value: big.NewInt(1), - Gas: 11, - Input: []byte{1, 2}, - V: big.NewInt(1), - }, - }) + t0 := types.NewTx(types.NewLegacyTx( + types.WithGasPrice(big.NewInt(11)), + types.WithNonce(0), + types.WithTo(&addr1), + types.WithValue(big.NewInt(1)), + types.WithGas(11), + types.WithInput([]byte{1, 2}), + types.WithSignatureValues(big.NewInt(1), nil, nil), + )) t0.ComputeHash() addr2 := types.StringToAddress("22") - t1 := types.NewTx(&types.LegacyTx{ - GasPrice: big.NewInt(11), - BaseTx: &types.BaseTx{ - Nonce: 0, - To: &addr2, - Value: big.NewInt(1), - Gas: 22, - Input: []byte{4, 5}, - V: big.NewInt(2), - }, - }) + t1 := types.NewTx(types.NewLegacyTx( + types.WithGasPrice(big.NewInt(11)), + types.WithNonce(0), + types.WithTo(&addr2), + types.WithValue(big.NewInt(1)), + types.WithGas(22), + types.WithInput([]byte{4, 5}), + types.WithSignatureValues(big.NewInt(2), nil, nil), + )) t1.ComputeHash() block := types.Block{ @@ -342,14 +338,12 @@ func testReceipts(t *testing.T, m PlaceholderStorage) { body := &types.Body{ Transactions: []*types.Transaction{ - types.NewTx(&types.StateTx{ - GasPrice: new(big.Int).SetUint64(100), - BaseTx: &types.BaseTx{ - Nonce: 1000, - Gas: 50, - V: big.NewInt(11), - }, - }), + types.NewTx(types.NewStateTx( + types.WithGasPrice(new(big.Int).SetUint64(100)), + types.WithNonce(1000), + types.WithGas(50), + types.WithSignatureValues(big.NewInt(11), nil, nil), + )), }, } receipts := []*types.Receipt{ diff --git a/consensus/polybft/block_builder_test.go b/consensus/polybft/block_builder_test.go index 4dbd7df083..041ddfb30a 100644 --- a/consensus/polybft/block_builder_test.go +++ b/consensus/polybft/block_builder_test.go @@ -93,15 +93,13 @@ func TestBlockBuilder_BuildBlockTxOneFailedTxAndOneTakesTooMuchGas(t *testing.T) gas = blockGasLimit - 1 } - tx := types.NewTx(&types.LegacyTx{ - GasPrice: big.NewInt(gasPrice), - BaseTx: &types.BaseTx{ - Value: big.NewInt(amount), - Gas: gas, - Nonce: 0, - To: &acc.address, - }, - }) + tx := types.NewTx(types.NewLegacyTx( + types.WithGasPrice(big.NewInt(gasPrice)), + types.WithValue(big.NewInt(amount)), + types.WithGas(gas), + types.WithNonce(0), + types.WithTo(&acc.address), + )) tx, err = signer.SignTx(tx, acc.privKey) require.NoError(t, err) diff --git a/consensus/polybft/fsm.go b/consensus/polybft/fsm.go index 994d5c29e1..e754c8920f 100644 --- a/consensus/polybft/fsm.go +++ b/consensus/polybft/fsm.go @@ -716,15 +716,13 @@ func validateHeaderFields(parent *types.Header, header *types.Header, blockTimeD // createStateTransactionWithData creates a state transaction // with provided target address and inputData parameter which is ABI encoded byte array. func createStateTransactionWithData(target types.Address, inputData []byte) *types.Transaction { - tx := types.NewTx(&types.StateTx{ - GasPrice: big.NewInt(0), - BaseTx: &types.BaseTx{ - From: contracts.SystemCaller, - To: &target, - Input: inputData, - Gas: types.StateTransactionGasLimit, - }, - }) + tx := types.NewTx(types.NewStateTx( + types.WithGasPrice(big.NewInt(0)), + types.WithFrom(contracts.SystemCaller), + types.WithTo(&target), + types.WithInput(inputData), + types.WithGas(types.StateTransactionGasLimit), + )) return tx.ComputeHash() } diff --git a/consensus/polybft/fsm_test.go b/consensus/polybft/fsm_test.go index 5ae5440f42..4f588dd03e 100644 --- a/consensus/polybft/fsm_test.go +++ b/consensus/polybft/fsm_test.go @@ -100,13 +100,12 @@ func TestFSM_verifyCommitEpochTx(t *testing.T) { assert.NoError(t, fsm.verifyCommitEpochTx(commitEpochTx)) // submit tampered commit epoch transaction to the epoch ending block - alteredCommitEpochTx := types.NewTx(&types.StateTx{ - BaseTx: &types.BaseTx{ - To: &contracts.EpochManagerContract, - Input: []byte{}, - Gas: 0, - }, - }) + alteredCommitEpochTx := types.NewTx(types.NewStateTx( + types.WithTo(&contracts.EpochManagerContract), + types.WithInput([]byte{}), + types.WithGas(0), + )) + assert.ErrorContains(t, fsm.verifyCommitEpochTx(alteredCommitEpochTx), "invalid commit epoch transaction") // submit validators commit epoch transaction to the non-epoch ending block diff --git a/crypto/txsigner_eip155_test.go b/crypto/txsigner_eip155_test.go index fdb88ef9b0..6489b6d110 100644 --- a/crypto/txsigner_eip155_test.go +++ b/crypto/txsigner_eip155_test.go @@ -70,13 +70,11 @@ func TestEIP155Signer_Sender(t *testing.T) { t.Fatalf("Unable to generate key") } - txn := types.NewTx(&types.LegacyTx{ - GasPrice: big.NewInt(0), - BaseTx: &types.BaseTx{ - To: &toAddress, - Value: big.NewInt(1), - }, - }) + txn := types.NewTx(types.NewLegacyTx( + types.WithGasPrice(big.NewInt(0)), + types.WithTo(&toAddress), + types.WithValue(big.NewInt(1)), + )) signer := NewEIP155Signer( testCase.chainID.Uint64(), @@ -107,13 +105,11 @@ func TestEIP155Signer_ChainIDMismatch(t *testing.T) { t.Fatalf("Unable to generate key") } - txn := types.NewTx(&types.LegacyTx{ - GasPrice: big.NewInt(0), - BaseTx: &types.BaseTx{ - To: &toAddress, - Value: big.NewInt(1), - }, - }) + txn := types.NewTx(types.NewLegacyTx( + types.WithGasPrice(big.NewInt(0)), + types.WithTo(&toAddress), + types.WithValue(big.NewInt(1)), + )) signer := NewEIP155Signer(chainIDTop) diff --git a/crypto/txsigner_frontier_test.go b/crypto/txsigner_frontier_test.go index 07ffda27ac..80dba4c6af 100644 --- a/crypto/txsigner_frontier_test.go +++ b/crypto/txsigner_frontier_test.go @@ -15,13 +15,12 @@ func TestFrontierSigner(t *testing.T) { key, err := GenerateECDSAKey() assert.NoError(t, err) - txn := types.NewTx(&types.LegacyTx{ - GasPrice: big.NewInt(0), - BaseTx: &types.BaseTx{ - To: &toAddress, - Value: big.NewInt(10), - }, - }) + txn := types.NewTx(types.NewLegacyTx( + types.WithGasPrice(big.NewInt(0)), + types.WithTo(&toAddress), + types.WithValue(big.NewInt(10)), + )) + signedTx, err := signer.SignTx(txn, key) assert.NoError(t, err) diff --git a/crypto/txsigner_london_test.go b/crypto/txsigner_london_test.go index 5f42c3a147..48067deb1e 100644 --- a/crypto/txsigner_london_test.go +++ b/crypto/txsigner_london_test.go @@ -74,38 +74,30 @@ func TestLondonSignerSender(t *testing.T) { switch tc.txType { case types.AccessListTxType: - txn = types.NewTx(&types.AccessListTxn{ - GasPrice: big.NewInt(5), - ChainID: tc.chainID, - BaseTx: &types.BaseTx{ - To: &recipient, - Value: big.NewInt(1), - }, - }) + txn = types.NewTx(types.NewAccessListTx( + types.WithGasPrice(big.NewInt(5)), + types.WithChainID(tc.chainID), + types.WithTo(&recipient), + types.WithValue(big.NewInt(1)), + )) case types.LegacyTxType: - txn = types.NewTx(&types.LegacyTx{ - GasPrice: big.NewInt(5), - BaseTx: &types.BaseTx{ - To: &recipient, - Value: big.NewInt(1), - }, - }) + txn = types.NewTx(types.NewLegacyTx( + types.WithGasPrice(big.NewInt(5)), + types.WithTo(&recipient), + types.WithValue(big.NewInt(1)), + )) case types.StateTxType: - txn = types.NewTx(&types.StateTx{ - GasPrice: big.NewInt(5), - BaseTx: &types.BaseTx{ - To: &recipient, - Value: big.NewInt(1), - }, - }) + txn = types.NewTx(types.NewStateTx( + types.WithGasPrice(big.NewInt(5)), + types.WithTo(&recipient), + types.WithValue(big.NewInt(1)), + )) case types.DynamicFeeTxType: - txn = types.NewTx(&types.DynamicFeeTx{ - ChainID: tc.chainID, - BaseTx: &types.BaseTx{ - To: &recipient, - Value: big.NewInt(1), - }, - }) + txn = types.NewTx(types.NewDynamicFeeTx( + types.WithChainID(tc.chainID), + types.WithTo(&recipient), + types.WithValue(big.NewInt(1)), + )) } chainID := tc.chainID.Uint64() @@ -142,19 +134,15 @@ func Test_LondonSigner_Sender(t *testing.T) { }{ { name: "sender is 0x85dA99c8a7C2C95964c8EfD687E95E632Fc533D6", - tx: types.NewTx(&types.DynamicFeeTx{ - ChainID: big.NewInt(100), - GasTipCap: ethgo.Gwei(1), - GasFeeCap: ethgo.Gwei(10), - BaseTx: &types.BaseTx{ - Gas: 21000, - To: &to, - Value: big.NewInt(100000000000000), - V: big.NewInt(0), - R: r, - S: s, - }, - }), + tx: types.NewTx(types.NewDynamicFeeTx( + types.WithChainID(big.NewInt(100)), + types.WithGasTipCap(ethgo.Gwei(1)), + types.WithGasFeeCap(ethgo.Gwei(10)), + types.WithGas(21000), + types.WithTo(&to), + types.WithValue(big.NewInt(100000000000000)), + types.WithSignatureValues(big.NewInt(0), r, s), + )), sender: types.StringToAddress("0x85dA99c8a7C2C95964c8EfD687E95E632Fc533D6"), }, } diff --git a/e2e/framework/testserver.go b/e2e/framework/testserver.go index f9bb407383..450ce6a6b0 100644 --- a/e2e/framework/testserver.go +++ b/e2e/framework/testserver.go @@ -520,17 +520,15 @@ func (t *TestServer) SendRawTx( return nil, err } - signedTx, err := t.SignTx(types.NewTx(&types.LegacyTx{ - GasPrice: tx.GasPrice, - BaseTx: &types.BaseTx{ - Gas: tx.Gas, - To: tx.To, - Value: tx.Value, - Input: tx.Input, - Nonce: nextNonce, - From: tx.From, - }, - }), signerKey) + signedTx, err := t.SignTx(types.NewTx(types.NewLegacyTx( + types.WithGasPrice(tx.GasPrice), + types.WithGas(tx.Gas), + types.WithTo(tx.To), + types.WithValue(tx.Value), + types.WithInput(tx.Input), + types.WithNonce(nextNonce), + types.WithFrom(tx.From), + )), signerKey) if err != nil { return nil, err } diff --git a/e2e/txpool_test.go b/e2e/txpool_test.go index 1762bdd178..1c744011bd 100644 --- a/e2e/txpool_test.go +++ b/e2e/txpool_test.go @@ -46,25 +46,21 @@ func generateTx(params generateTxReqParams) *types.Transaction { var unsignedTx *types.Transaction if params.gasPrice != nil { - unsignedTx = types.NewTx(&types.LegacyTx{ - BaseTx: &types.BaseTx{ - Nonce: params.nonce, - To: ¶ms.toAddress, - Gas: 1000000, - Value: params.value, - }, - }) + unsignedTx = types.NewTx(types.NewLegacyTx( + types.WithNonce(params.nonce), + types.WithTo(¶ms.toAddress), + types.WithGas(1000000), + types.WithValue(params.value), + )) unsignedTx.SetGasPrice(params.gasPrice) } else { - unsignedTx = types.NewTx(&types.DynamicFeeTx{ - ChainID: new(big.Int).SetUint64(defaultChainID), - BaseTx: &types.BaseTx{ - Nonce: params.nonce, - To: ¶ms.toAddress, - Gas: 1000000, - Value: params.value, - }, - }) + unsignedTx = types.NewTx(types.NewDynamicFeeTx( + types.WithChainID(new(big.Int).SetUint64(defaultChainID)), + types.WithNonce(params.nonce), + types.WithTo(¶ms.toAddress), + types.WithGas(1000000), + types.WithValue(params.value), + )) unsignedTx.SetGasFeeCap(params.gasFeeCap) unsignedTx.SetGasTipCap(params.gasTipCap) } @@ -245,39 +241,33 @@ func TestTxPool_RecoverableError(t *testing.T) { _, receiverAddress := tests.GenerateKeyAndAddr(t) transactions := []*types.Transaction{ - types.NewTx(&types.LegacyTx{ - GasPrice: big.NewInt(framework.DefaultGasPrice), - BaseTx: &types.BaseTx{ - Nonce: 0, - Gas: 22000, - To: &receiverAddress, - Value: oneEth, - V: big.NewInt(27), - From: senderAddress, - }, - }), - types.NewTx(&types.LegacyTx{ - GasPrice: big.NewInt(framework.DefaultGasPrice), - BaseTx: &types.BaseTx{ - Nonce: 1, - Gas: 22000, - To: &receiverAddress, - Value: oneEth, - V: big.NewInt(27), - }, - }), - types.NewTx(&types.DynamicFeeTx{ - ChainID: new(big.Int).SetUint64(defaultChainID), - GasFeeCap: big.NewInt(framework.DefaultGasPrice), - GasTipCap: big.NewInt(1000000000), - BaseTx: &types.BaseTx{ - Nonce: 2, - Gas: 22000, - To: &receiverAddress, - Value: oneEth, - V: big.NewInt(27), - }, - }), + types.NewTx(types.NewLegacyTx( + types.WithGasPrice(big.NewInt(framework.DefaultGasPrice)), + types.WithNonce(0), + types.WithGas(22000), + types.WithTo(&receiverAddress), + types.WithValue(oneEth), + types.WithSignatureValues(big.NewInt(27), nil, nil), + types.WithFrom(senderAddress), + )), + types.NewTx(types.NewLegacyTx( + types.WithGasPrice(big.NewInt(framework.DefaultGasPrice)), + types.WithNonce(1), + types.WithGas(22000), + types.WithTo(&receiverAddress), + types.WithValue(oneEth), + types.WithSignatureValues(big.NewInt(27), nil, nil), + )), + types.NewTx(types.NewDynamicFeeTx( + types.WithChainID(new(big.Int).SetUint64(defaultChainID)), + types.WithGasFeeCap(big.NewInt(framework.DefaultGasPrice)), + types.WithGasTipCap(big.NewInt(1000000000)), + types.WithNonce(2), + types.WithGas(22000), + types.WithTo(&receiverAddress), + types.WithValue(oneEth), + types.WithSignatureValues(big.NewInt(27), nil, nil), + )), } server := framework.NewTestServers(t, 1, func(config *framework.TestServerConfig) { @@ -359,17 +349,16 @@ func TestTxPool_GetPendingTx(t *testing.T) { operator := server.TxnPoolOperator() client := server.JSONRPC() - signedTx, err := signer.SignTx(types.NewTx(&types.LegacyTx{ - GasPrice: big.NewInt(1000000000), - BaseTx: &types.BaseTx{ - Nonce: 0, - Gas: framework.DefaultGasLimit - 1, - To: &receiverAddress, - Value: oneEth, - V: big.NewInt(1), - From: types.ZeroAddress, - }, - }), senderKey) + signedTx, err := signer.SignTx(types.NewTx(types.NewLegacyTx( + types.WithGasPrice(big.NewInt(1000000000)), + types.WithNonce(0), + types.WithGas(framework.DefaultGasLimit-1), + types.WithTo(&receiverAddress), + types.WithValue(oneEth), + types.WithSignatureValues(big.NewInt(1), nil, nil), + types.WithFrom(types.ZeroAddress), + ), + ), senderKey) assert.NoError(t, err, "failed to sign transaction") // Add the transaction diff --git a/gasprice/feehistory_test.go b/gasprice/feehistory_test.go index a0251c74d2..68f2115168 100644 --- a/gasprice/feehistory_test.go +++ b/gasprice/feehistory_test.go @@ -194,14 +194,12 @@ func TestGasHelper_FeeHistory(t *testing.T) { b.Header.Miner = sender.Bytes() for i := 0; i < 3; i++ { - tx := types.NewTx(&types.DynamicFeeTx{ - GasTipCap: ethgo.Gwei(uint64(200)), - GasFeeCap: ethgo.Gwei(uint64(200 + 200)), - BaseTx: &types.BaseTx{ - Value: ethgo.Ether(1), - To: &types.ZeroAddress, - }, - }) + tx := types.NewTx(types.NewDynamicFeeTx( + types.WithGasTipCap(ethgo.Gwei(200)), + types.WithGasFeeCap(ethgo.Gwei(200+200)), + types.WithValue(ethgo.Ether(1)), + types.WithTo(&types.ZeroAddress), + )) tx, err := signer.SignTx(tx, senderKey) require.NoError(t, err) diff --git a/gasprice/gasprice_test.go b/gasprice/gasprice_test.go index a9ed00d8e7..aba8a0c274 100644 --- a/gasprice/gasprice_test.go +++ b/gasprice/gasprice_test.go @@ -84,16 +84,14 @@ func TestGasHelper_MaxPriorityFeePerGas(t *testing.T) { b.Header.Miner = sender.Bytes() for i := 0; i < 3; i++ { - tx := types.NewTx(&types.DynamicFeeTx{ - GasTipCap: ethgo.Gwei(uint64(rand.Intn(200))), - GasFeeCap: ethgo.Gwei(uint64(rand.Intn(200) + 200)), - ChainID: big.NewInt(backend.Config().ChainID), - BaseTx: &types.BaseTx{ - From: sender, - Value: ethgo.Ether(1), - To: &types.ZeroAddress, - }, - }) + tx := types.NewTx(types.NewDynamicFeeTx( + types.WithGasTipCap(ethgo.Gwei(uint64(rand.Intn(200)))), + types.WithGasFeeCap(ethgo.Gwei(uint64(rand.Intn(200)+200))), + types.WithChainID(big.NewInt(backend.Config().ChainID)), + types.WithFrom(sender), + types.WithValue(ethgo.Ether(1)), + types.WithTo(&types.ZeroAddress), + )) tx, err := signer.SignTx(tx, senderKey) require.NoError(t, err) @@ -221,16 +219,14 @@ func createTestTxs(t *testing.T, backend *backendMock, numOfTxsPerBlock, txCap i for i := 0; i < numOfTxsPerBlock; i++ { senderKey, sender := tests.GenerateKeyAndAddr(t) - tx := types.NewTx(&types.DynamicFeeTx{ - GasTipCap: ethgo.Gwei(uint64(rand.Intn(txCap))), - GasFeeCap: ethgo.Gwei(uint64(rand.Intn(txCap) + txCap)), - ChainID: big.NewInt(backend.Config().ChainID), - BaseTx: &types.BaseTx{ - From: sender, - Value: ethgo.Ether(1), - To: &types.ZeroAddress, - }, - }) + tx := types.NewTx(types.NewDynamicFeeTx( + types.WithGasTipCap(ethgo.Gwei(uint64(rand.Intn(txCap)))), + types.WithGasFeeCap(ethgo.Gwei(uint64(rand.Intn(txCap)+txCap))), + types.WithChainID(big.NewInt(backend.Config().ChainID)), + types.WithFrom(sender), + types.WithValue(ethgo.Ether(1)), + types.WithTo(&types.ZeroAddress), + )) tx, err := signer.SignTx(tx, senderKey) require.NoError(t, err) diff --git a/helper/tests/testing.go b/helper/tests/testing.go index d9c6f2ee15..f781e2ef85 100644 --- a/helper/tests/testing.go +++ b/helper/tests/testing.go @@ -238,19 +238,16 @@ type GenerateTxReqParams struct { func generateTx(params GenerateTxReqParams) (*types.Transaction, error) { signer := crypto.NewEIP155Signer(100) - signedTx, signErr := signer.SignTx(types.NewTx(&types.LegacyTx{ - GasPrice: params.GasPrice, - BaseTx: &types.BaseTx{ - Nonce: params.Nonce, - From: params.ReferenceAddr, - To: ¶ms.ToAddress, - Gas: 1000000, - Value: params.Value, - Input: params.Input, - V: big.NewInt(27), // it is necessary to encode in rlp - }, - }), params.ReferenceKey) - + signedTx, signErr := signer.SignTx(types.NewTx(types.NewLegacyTx( + types.WithGasPrice(params.GasPrice), + types.WithNonce(params.Nonce), + types.WithFrom(params.ReferenceAddr), + types.WithTo(¶ms.ToAddress), + types.WithGas(1000000), + types.WithValue(params.Value), + types.WithInput(params.Input), + types.WithSignatureValues(big.NewInt(27), nil, nil), + )), params.ReferenceKey) if signErr != nil { return nil, fmt.Errorf("unable to sign transaction, %w", signErr) } diff --git a/jsonrpc/debug_endpoint_test.go b/jsonrpc/debug_endpoint_test.go index 778ce207f0..35a2a3653a 100644 --- a/jsonrpc/debug_endpoint_test.go +++ b/jsonrpc/debug_endpoint_test.go @@ -605,18 +605,16 @@ func TestTraceCall(t *testing.T) { Nonce: &nonce, Type: toArgUint64Ptr(uint64(types.DynamicFeeTxType)), } - decodedTx = types.NewTx(&types.DynamicFeeTx{ - GasTipCap: new(big.Int).SetBytes([]byte(gasTipCap)), - GasFeeCap: new(big.Int).SetBytes([]byte(gasFeeCap)), - BaseTx: &types.BaseTx{ - Nonce: uint64(nonce), - Gas: uint64(gas), - To: &to, - Value: new(big.Int).SetBytes([]byte(value)), - Input: data, - From: from, - }, - }) + decodedTx = types.NewTx(types.NewDynamicFeeTx( + types.WithGasTipCap(new(big.Int).SetBytes([]byte(gasTipCap))), + types.WithGasFeeCap(new(big.Int).SetBytes([]byte(gasFeeCap))), + types.WithNonce(uint64(nonce)), + types.WithGas(uint64(gas)), + types.WithTo(&to), + types.WithValue(new(big.Int).SetBytes([]byte(value))), + types.WithInput(data), + types.WithFrom(from), + )) ) decodedTx.ComputeHash() diff --git a/jsonrpc/eth_blockchain_test.go b/jsonrpc/eth_blockchain_test.go index ad1f1c2e0a..d4448af7be 100644 --- a/jsonrpc/eth_blockchain_test.go +++ b/jsonrpc/eth_blockchain_test.go @@ -89,7 +89,7 @@ func TestEth_Block_GetBlockTransactionCountByHash(t *testing.T) { for i := 0; i < 10; i++ { block.Transactions = append(block.Transactions, []*types.Transaction{ - types.NewTx(&types.LegacyTx{BaseTx: &types.BaseTx{Nonce: 0, From: addr0}})}...) + types.NewTx(types.NewLegacyTx(types.WithNonce(0), types.WithFrom(addr0)))}...) } store.add(block) @@ -108,7 +108,7 @@ func TestEth_Block_GetBlockTransactionCountByNumber(t *testing.T) { for i := 0; i < 10; i++ { block.Transactions = append(block.Transactions, []*types.Transaction{ - types.NewTx(&types.LegacyTx{BaseTx: &types.BaseTx{Nonce: 0, From: addr0}})}...) + types.NewTx(types.NewLegacyTx(types.WithNonce(0), types.WithFrom(addr0)))}...) } store.add(block) diff --git a/jsonrpc/eth_endpoint_test.go b/jsonrpc/eth_endpoint_test.go index 1954dd3c0e..c35dd3694d 100644 --- a/jsonrpc/eth_endpoint_test.go +++ b/jsonrpc/eth_endpoint_test.go @@ -46,18 +46,16 @@ func TestEth_DecodeTxn(t *testing.T) { Nonce: toArgUint64Ptr(0), Type: toArgUint64Ptr(uint64(types.DynamicFeeTxType)), }, - res: types.NewTx(&types.DynamicFeeTx{ - GasTipCap: big.NewInt(10000), - GasFeeCap: big.NewInt(10000), - BaseTx: &types.BaseTx{ - From: addr1, - To: &addr2, - Gas: 21000, - Value: oneEther, - Input: []byte{}, - Nonce: 0, - }, - }), + res: types.NewTx(types.NewDynamicFeeTx( + types.WithGasTipCap(big.NewInt(10000)), + types.WithGasFeeCap(big.NewInt(10000)), + types.WithFrom(addr1), + types.WithTo(&addr2), + types.WithGas(21000), + types.WithValue(oneEther), + types.WithInput([]byte{}), + types.WithNonce(0), + )), err: nil, }, { @@ -69,17 +67,15 @@ func TestEth_DecodeTxn(t *testing.T) { Value: toArgBytesPtr(oneEther.Bytes()), Data: nil, }, - res: types.NewTx(&types.LegacyTx{ - GasPrice: big.NewInt(10000), - BaseTx: &types.BaseTx{ - From: types.ZeroAddress, - To: &addr2, - Gas: 21000, - Value: oneEther, - Input: []byte{}, - Nonce: 0, - }, - }), + res: types.NewTx(types.NewLegacyTx( + types.WithGasPrice(big.NewInt(10000)), + types.WithFrom(types.ZeroAddress), + types.WithTo(&addr2), + types.WithGas(21000), + types.WithValue(oneEther), + types.WithInput([]byte{}), + types.WithNonce(0), + )), err: nil, }, { @@ -97,17 +93,15 @@ func TestEth_DecodeTxn(t *testing.T) { Value: toArgBytesPtr(oneEther.Bytes()), Data: nil, }, - res: types.NewTx(&types.LegacyTx{ - GasPrice: big.NewInt(10000), - BaseTx: &types.BaseTx{ - From: addr1, - To: &addr2, - Gas: 21000, - Value: oneEther, - Input: []byte{}, - Nonce: 10, - }, - }), + res: types.NewTx(types.NewLegacyTx( + types.WithGasPrice(big.NewInt(10000)), + types.WithFrom(addr1), + types.WithTo(&addr2), + types.WithGas(21000), + types.WithValue(oneEther), + types.WithInput([]byte{}), + types.WithNonce(10), + )), err: nil, }, { @@ -120,17 +114,15 @@ func TestEth_DecodeTxn(t *testing.T) { Data: nil, Nonce: toArgUint64Ptr(1), }, - res: types.NewTx(&types.LegacyTx{ - GasPrice: big.NewInt(10000), - BaseTx: &types.BaseTx{ - From: addr1, - To: &addr2, - Gas: 21000, - Value: new(big.Int).SetBytes([]byte{}), - Input: []byte{}, - Nonce: 1, - }, - }), + res: types.NewTx(types.NewLegacyTx( + types.WithGasPrice(big.NewInt(10000)), + types.WithFrom(addr1), + types.WithTo(&addr2), + types.WithGas(21000), + types.WithValue(new(big.Int).SetBytes([]byte{})), + types.WithInput([]byte{}), + types.WithNonce(1), + )), err: nil, }, { @@ -142,17 +134,15 @@ func TestEth_DecodeTxn(t *testing.T) { Data: nil, Nonce: toArgUint64Ptr(1), }, - res: types.NewTx(&types.LegacyTx{ - GasPrice: big.NewInt(10000), - BaseTx: &types.BaseTx{ - Value: new(big.Int).SetBytes([]byte{}), - Input: []byte{}, - Nonce: 1, - From: addr1, - To: &addr2, - Gas: 0, - }, - }), + res: types.NewTx(types.NewLegacyTx( + types.WithGasPrice(big.NewInt(10000)), + types.WithValue(new(big.Int).SetBytes([]byte{})), + types.WithInput([]byte{}), + types.WithNonce(1), + types.WithFrom(addr1), + types.WithTo(&addr2), + types.WithGas(0), + )), err: nil, }, } @@ -279,18 +269,16 @@ func TestEth_TxnType(t *testing.T) { Type: toArgUint64Ptr(uint64(types.DynamicFeeTxType)), } - expectedRes := types.NewTx(&types.DynamicFeeTx{ - GasTipCap: big.NewInt(10000), - GasFeeCap: big.NewInt(10000), - BaseTx: &types.BaseTx{ - From: addr1, - To: &addr2, - Gas: 21000, - Value: oneEther, - Input: []byte{}, - Nonce: 0, - }, - }) + expectedRes := types.NewTx(types.NewDynamicFeeTx( + types.WithGasTipCap(big.NewInt(10000)), + types.WithGasFeeCap(big.NewInt(10000)), + types.WithFrom(addr1), + types.WithTo(&addr2), + types.WithGas(21000), + types.WithValue(oneEther), + types.WithInput([]byte{}), + types.WithNonce(0), + )) res, err := DecodeTxn(args, 1, store, false) expectedRes.ComputeHash() diff --git a/jsonrpc/eth_txpool_test.go b/jsonrpc/eth_txpool_test.go index c850c9287f..3e2aa54f2c 100644 --- a/jsonrpc/eth_txpool_test.go +++ b/jsonrpc/eth_txpool_test.go @@ -11,12 +11,10 @@ import ( func TestEth_TxnPool_SendRawTransaction(t *testing.T) { store := &mockStoreTxn{} eth := newTestEthEndpoint(store) - txn := types.NewTx(&types.LegacyTx{ - BaseTx: &types.BaseTx{ - From: addr0, - V: big.NewInt(1), - }, - }) + txn := types.NewTx(types.NewLegacyTx( + types.WithFrom(addr0), + types.WithSignatureValues(big.NewInt(1), nil, nil), + )) txn.ComputeHash() data := txn.MarshalRLP() @@ -34,14 +32,12 @@ func TestEth_TxnPool_SendTransaction(t *testing.T) { store := &mockStoreTxn{} store.AddAccount(addr0) eth := newTestEthEndpoint(store) - txToSend := types.NewTx(&types.LegacyTx{ - GasPrice: big.NewInt(int64(1)), - BaseTx: &types.BaseTx{ - From: addr0, - To: argAddrPtr(addr0), - Nonce: uint64(0), - }, - }) + txToSend := types.NewTx(types.NewLegacyTx( + types.WithGasPrice(big.NewInt(1)), + types.WithFrom(addr0), + types.WithTo(argAddrPtr(addr0)), + types.WithNonce(0), + )) _, err := eth.SendRawTransaction(txToSend.MarshalRLP()) assert.NoError(t, err) diff --git a/jsonrpc/filter_manager_fuzz_test.go b/jsonrpc/filter_manager_fuzz_test.go index 49b46d27dc..d9e7d68da9 100644 --- a/jsonrpc/filter_manager_fuzz_test.go +++ b/jsonrpc/filter_manager_fuzz_test.go @@ -33,27 +33,15 @@ func FuzzGetLogsForQuery(f *testing.F) { Hash: types.StringToHash(strconv.Itoa(i)), }, Transactions: []*types.Transaction{ - { - Inner: &types.LegacyTx{ - BaseTx: &types.BaseTx{ - Value: big.NewInt(10), - }, - }, - }, - { - Inner: &types.LegacyTx{ - BaseTx: &types.BaseTx{ - Value: big.NewInt(11), - }, - }, - }, - { - Inner: &types.LegacyTx{ - BaseTx: &types.BaseTx{ - Value: big.NewInt(12), - }, - }, - }, + types.NewTx(types.NewLegacyTx( + types.WithValue(big.NewInt(10)), + )), + types.NewTx(types.NewLegacyTx( + types.WithValue(big.NewInt(11)), + )), + types.NewTx(types.NewLegacyTx( + types.WithValue(big.NewInt(12)), + )), }, } } diff --git a/jsonrpc/filter_manager_test.go b/jsonrpc/filter_manager_test.go index 00693147e2..48e43aca9c 100644 --- a/jsonrpc/filter_manager_test.go +++ b/jsonrpc/filter_manager_test.go @@ -114,9 +114,9 @@ func Test_GetLogsForQuery(t *testing.T) { Hash: types.StringToHash(strconv.Itoa(i)), }, Transactions: []*types.Transaction{ - types.NewTx(&types.LegacyTx{BaseTx: &types.BaseTx{Value: big.NewInt(10)}}), - types.NewTx(&types.LegacyTx{BaseTx: &types.BaseTx{Value: big.NewInt(11)}}), - types.NewTx(&types.LegacyTx{BaseTx: &types.BaseTx{Value: big.NewInt(12)}}), + types.NewTx(types.NewLegacyTx(types.WithValue(big.NewInt(10)))), + types.NewTx(types.NewLegacyTx(types.WithValue(big.NewInt(11)))), + types.NewTx(types.NewLegacyTx(types.WithValue(big.NewInt(12)))), }, } } diff --git a/jsonrpc/helper_test.go b/jsonrpc/helper_test.go index fcb28b8464..19f521d6c7 100644 --- a/jsonrpc/helper_test.go +++ b/jsonrpc/helper_test.go @@ -14,18 +14,14 @@ import ( func createTestTransaction(hash types.Hash) *types.Transaction { recipient := types.StringToAddress("2") - return types.NewTx(&types.LegacyTx{ - GasPrice: big.NewInt(400), - BaseTx: &types.BaseTx{ - Hash: hash, - From: types.StringToAddress("1"), - To: &recipient, - Value: big.NewInt(100), - V: big.NewInt(1), - R: big.NewInt(2), - S: big.NewInt(3), - }, - }) + return types.NewTx(types.NewLegacyTx( + types.WithGasPrice(big.NewInt(400)), + types.WithHash(hash), + types.WithFrom(types.StringToAddress("1")), + types.WithTo(&recipient), + types.WithValue(big.NewInt(100)), + types.WithSignatureValues(big.NewInt(1), big.NewInt(2), big.NewInt(3)), + )) } func createTestHeader(height uint64, setterFn func(h *types.Header)) *types.Header { @@ -710,18 +706,16 @@ func TestDecodeTxn(t *testing.T) { Type: toArgUint64Ptr(uint64(types.DynamicFeeTxType)), }, store: &debugEndpointMockStore{}, - expected: types.NewTx(&types.DynamicFeeTx{ - GasTipCap: new(big.Int).SetBytes([]byte(gasTipCap)), - GasFeeCap: new(big.Int).SetBytes([]byte(gasFeeCap)), - BaseTx: &types.BaseTx{ - Value: new(big.Int).SetBytes([]byte(value)), - Input: input, - Nonce: uint64(nonce), - From: from, - To: &to, - Gas: uint64(gas), - }, - }), + expected: types.NewTx(types.NewDynamicFeeTx( + types.WithGasTipCap(new(big.Int).SetBytes([]byte(gasTipCap))), + types.WithGasFeeCap(new(big.Int).SetBytes([]byte(gasFeeCap))), + types.WithValue(new(big.Int).SetBytes([]byte(value))), + types.WithInput(input), + types.WithNonce(uint64(nonce)), + types.WithFrom(from), + types.WithTo(&to), + types.WithGas(uint64(gas)), + )), err: false, }, { @@ -735,17 +729,15 @@ func TestDecodeTxn(t *testing.T) { Nonce: &nonce, }, store: &debugEndpointMockStore{}, - expected: types.NewTx(&types.LegacyTx{ - GasPrice: new(big.Int).SetBytes([]byte(gasPrice)), - BaseTx: &types.BaseTx{ - From: types.ZeroAddress, - To: &to, - Gas: uint64(gas), - Value: new(big.Int).SetBytes([]byte(value)), - Input: input, - Nonce: uint64(0), - }, - }), + expected: types.NewTx(types.NewLegacyTx( + types.WithGasPrice(new(big.Int).SetBytes([]byte(gasPrice))), + types.WithFrom(types.ZeroAddress), + types.WithTo(&to), + types.WithGas(uint64(gas)), + types.WithValue(new(big.Int).SetBytes([]byte(value))), + types.WithInput(input), + types.WithNonce(0), + )), err: false, }, { @@ -770,17 +762,15 @@ func TestDecodeTxn(t *testing.T) { }, nil }, }, - expected: types.NewTx(&types.LegacyTx{ - GasPrice: new(big.Int).SetBytes([]byte(gasPrice)), - BaseTx: &types.BaseTx{ - From: from, - To: &to, - Gas: uint64(gas), - Value: new(big.Int).SetBytes([]byte(value)), - Input: input, - Nonce: uint64(stateNonce), - }, - }), + expected: types.NewTx(types.NewLegacyTx( + types.WithGasPrice(new(big.Int).SetBytes([]byte(gasPrice))), + types.WithFrom(from), + types.WithTo(&to), + types.WithGas(uint64(gas)), + types.WithValue(new(big.Int).SetBytes([]byte(value))), + types.WithInput(input), + types.WithNonce(uint64(stateNonce)), + )), err: false, }, { @@ -796,17 +786,15 @@ func TestDecodeTxn(t *testing.T) { Nonce: &nonce, }, store: &debugEndpointMockStore{}, - expected: types.NewTx(&types.LegacyTx{ - GasPrice: new(big.Int).SetBytes([]byte(gasPrice)), - BaseTx: &types.BaseTx{ - From: from, - To: &to, - Gas: uint64(gas), - Value: new(big.Int).SetBytes([]byte(value)), - Input: data, - Nonce: uint64(nonce), - }, - }), + expected: types.NewTx(types.NewLegacyTx( + types.WithGasPrice(new(big.Int).SetBytes([]byte(gasPrice))), + types.WithFrom(from), + types.WithTo(&to), + types.WithGas(uint64(gas)), + types.WithValue(new(big.Int).SetBytes([]byte(value))), + types.WithInput(data), + types.WithNonce(uint64(nonce)), + )), err: false, }, { @@ -817,17 +805,15 @@ func TestDecodeTxn(t *testing.T) { Nonce: &nonce, }, store: &debugEndpointMockStore{}, - expected: types.NewTx(&types.LegacyTx{ - GasPrice: new(big.Int), - BaseTx: &types.BaseTx{ - From: from, - To: &to, - Gas: uint64(0), - Value: new(big.Int), - Input: []byte{}, - Nonce: uint64(nonce), - }, - }), + expected: types.NewTx(types.NewLegacyTx( + types.WithGasPrice(new(big.Int)), + types.WithFrom(from), + types.WithTo(&to), + types.WithGas(uint64(0)), + types.WithValue(new(big.Int)), + types.WithInput([]byte{}), + types.WithNonce(uint64(nonce)), + )), err: false, }, { diff --git a/jsonrpc/txpool_endpoint_test.go b/jsonrpc/txpool_endpoint_test.go index 3b935f0aef..a46dae8e17 100644 --- a/jsonrpc/txpool_endpoint_test.go +++ b/jsonrpc/txpool_endpoint_test.go @@ -294,20 +294,16 @@ func (s *mockTxPoolStore) GetBaseFee() uint64 { } func newTestTransaction(nonce uint64, from types.Address) *types.Transaction { - txn := types.NewTx(&types.LegacyTx{ - GasPrice: big.NewInt(1), - BaseTx: &types.BaseTx{ - Nonce: nonce, - Gas: nonce * 100, - Value: big.NewInt(200), - Input: []byte{0xff}, - From: from, - To: &addr1, - V: big.NewInt(1), - R: big.NewInt(1), - S: big.NewInt(1), - }, - }) + txn := types.NewTx(types.NewLegacyTx( + types.WithGasPrice(big.NewInt(1)), + types.WithNonce(nonce), + types.WithGas(nonce*100), + types.WithValue(big.NewInt(200)), + types.WithInput([]byte{0xff}), + types.WithFrom(from), + types.WithTo(&addr1), + types.WithSignatureValues(big.NewInt(1), big.NewInt(1), big.NewInt(1)), + )) txn.ComputeHash() @@ -315,22 +311,18 @@ func newTestTransaction(nonce uint64, from types.Address) *types.Transaction { } func newTestDynamicFeeTransaction(nonce uint64, from types.Address) *types.Transaction { - txn := types.NewTx(&types.DynamicFeeTx{ - GasTipCap: big.NewInt(2), - GasFeeCap: big.NewInt(4), - ChainID: big.NewInt(100), - BaseTx: &types.BaseTx{ - Nonce: nonce, - Gas: nonce * 100, - Value: big.NewInt(200), - Input: []byte{0xff}, - From: from, - To: &addr1, - V: big.NewInt(1), - R: big.NewInt(1), - S: big.NewInt(1), - }, - }) + txn := types.NewTx(types.NewDynamicFeeTx( + types.WithGasTipCap(big.NewInt(2)), + types.WithGasFeeCap(big.NewInt(4)), + types.WithChainID(big.NewInt(100)), + types.WithNonce(nonce), + types.WithGas(nonce*100), + types.WithValue(big.NewInt(200)), + types.WithInput([]byte{0xff}), + types.WithFrom(from), + types.WithTo(&addr1), + types.WithSignatureValues(big.NewInt(1), big.NewInt(1), big.NewInt(1)), + )) txn.ComputeHash() diff --git a/jsonrpc/types_test.go b/jsonrpc/types_test.go index 3b6cd06e57..3b6da3a0ba 100644 --- a/jsonrpc/types_test.go +++ b/jsonrpc/types_test.go @@ -103,21 +103,17 @@ func TestToTransaction_Returns_V_R_S_ValuesWithoutLeading0(t *testing.T) { v, _ := hex.DecodeHex(hexWithLeading0) r, _ := hex.DecodeHex(hexWithLeading0) s, _ := hex.DecodeHex(hexWithLeading0) - txn := types.NewTx(&types.LegacyTx{ - GasPrice: big.NewInt(0), - BaseTx: &types.BaseTx{ - Nonce: 0, - Gas: 0, - To: nil, - Value: big.NewInt(0), - Input: nil, - V: new(big.Int).SetBytes(v), - R: new(big.Int).SetBytes(r), - S: new(big.Int).SetBytes(s), - Hash: types.Hash{}, - From: types.Address{}, - }, - }) + txn := types.NewTx(types.NewLegacyTx( + types.WithGasPrice(big.NewInt(0)), + types.WithNonce(0), + types.WithGas(0), + types.WithTo(nil), + types.WithValue(big.NewInt(0)), + types.WithInput(nil), + types.WithSignatureValues(new(big.Int).SetBytes(v), new(big.Int).SetBytes(r), new(big.Int).SetBytes(s)), + types.WithHash(types.Hash{}), + types.WithFrom(types.Address{}), + )) jsonTx := toTransaction(txn, nil, nil, nil) @@ -136,22 +132,16 @@ func TestToTransaction_EIP1559(t *testing.T) { v, _ := hex.DecodeHex(hexWithLeading0) r, _ := hex.DecodeHex(hexWithLeading0) s, _ := hex.DecodeHex(hexWithLeading0) - txn := types.NewTx(&types.DynamicFeeTx{ - GasTipCap: big.NewInt(10), - GasFeeCap: big.NewInt(10), - BaseTx: &types.BaseTx{ - Nonce: 0, - Gas: 0, - To: nil, - Value: big.NewInt(0), - Input: nil, - V: new(big.Int).SetBytes(v), - R: new(big.Int).SetBytes(r), - S: new(big.Int).SetBytes(s), - Hash: types.Hash{}, - From: types.Address{}, - }, - }) + txn := types.NewTx(types.NewDynamicFeeTx( + types.WithGasTipCap(big.NewInt(10)), + types.WithGasFeeCap(big.NewInt(10)), + types.WithNonce(0), + types.WithGas(0), + types.WithValue(big.NewInt(0)), + types.WithSignatureValues(new(big.Int).SetBytes(v), new(big.Int).SetBytes(r), new(big.Int).SetBytes(s)), + types.WithHash(types.Hash{}), + types.WithFrom(types.Address{}), + )) jsonTx := toTransaction(txn, nil, nil, nil) diff --git a/state/executor_test.go b/state/executor_test.go index 42e5eb4237..1ad4cb6c16 100644 --- a/state/executor_test.go +++ b/state/executor_test.go @@ -80,11 +80,11 @@ func Test_Transition_checkDynamicFees(t *testing.T) { { name: "happy path", baseFee: big.NewInt(100), - tx: types.NewTx(&types.DynamicFeeTx{ - GasFeeCap: big.NewInt(100), - GasTipCap: big.NewInt(100), - BaseTx: &types.BaseTx{From: types.ZeroAddress}, - }), + tx: types.NewTx(types.NewDynamicFeeTx( + types.WithGasFeeCap(big.NewInt(100)), + types.WithGasTipCap(big.NewInt(100)), + types.WithFrom(types.ZeroAddress), + )), wantErr: func(t assert.TestingT, err error, i ...interface{}) bool { assert.NoError(t, err, i) @@ -94,11 +94,11 @@ func Test_Transition_checkDynamicFees(t *testing.T) { { name: "happy path with empty values", baseFee: big.NewInt(0), - tx: types.NewTx(&types.DynamicFeeTx{ - GasFeeCap: big.NewInt(0), - GasTipCap: big.NewInt(0), - BaseTx: &types.BaseTx{From: types.ZeroAddress}, - }), + tx: types.NewTx(types.NewDynamicFeeTx( + types.WithGasFeeCap(big.NewInt(0)), + types.WithGasTipCap(big.NewInt(0)), + types.WithFrom(types.ZeroAddress), + )), wantErr: func(t assert.TestingT, err error, i ...interface{}) bool { assert.NoError(t, err, i) @@ -108,11 +108,11 @@ func Test_Transition_checkDynamicFees(t *testing.T) { { name: "gas fee cap less than base fee", baseFee: big.NewInt(20), - tx: types.NewTx(&types.DynamicFeeTx{ - GasFeeCap: big.NewInt(10), - GasTipCap: big.NewInt(0), - BaseTx: &types.BaseTx{From: types.ZeroAddress}, - }), + tx: types.NewTx(types.NewDynamicFeeTx( + types.WithGasFeeCap(big.NewInt(10)), + types.WithGasTipCap(big.NewInt(0)), + types.WithFrom(types.ZeroAddress), + )), wantErr: func(t assert.TestingT, err error, i ...interface{}) bool { expectedError := fmt.Sprintf("max fee per gas less than block base fee: "+ "address %s, GasFeeCap/GasPrice: 10, BaseFee: 20", types.ZeroAddress) @@ -124,11 +124,11 @@ func Test_Transition_checkDynamicFees(t *testing.T) { { name: "gas fee cap less than tip cap", baseFee: big.NewInt(5), - tx: types.NewTx(&types.DynamicFeeTx{ - GasFeeCap: big.NewInt(10), - GasTipCap: big.NewInt(15), - BaseTx: &types.BaseTx{From: types.ZeroAddress}, - }), + tx: types.NewTx(types.NewDynamicFeeTx( + types.WithGasFeeCap(big.NewInt(10)), + types.WithGasTipCap(big.NewInt(15)), + types.WithFrom(types.ZeroAddress), + )), wantErr: func(t assert.TestingT, err error, i ...interface{}) bool { expectedError := fmt.Sprintf("max priority fee per gas higher than max fee per gas: "+ "address %s, GasTipCap: 15, GasFeeCap: 10", types.ZeroAddress) diff --git a/state/transition_test.go b/state/transition_test.go index 47a33ea978..c225652b87 100644 --- a/state/transition_test.go +++ b/state/transition_test.go @@ -70,13 +70,11 @@ func TestSubGasLimitPrice(t *testing.T) { t.Parallel() transition := newTestTransition(tt.preState) - msg := types.NewTx(&types.LegacyTx{ - GasPrice: big.NewInt(tt.gasPrice), - BaseTx: &types.BaseTx{ - From: tt.from, - Gas: tt.gas, - }, - }) + msg := types.NewTx(types.NewLegacyTx( + types.WithGasPrice(big.NewInt(tt.gasPrice)), + types.WithFrom(tt.from), + types.WithGas(tt.gas), + )) err := transition.subGasLimitPrice(msg) diff --git a/tests/state_test_util.go b/tests/state_test_util.go index cedc8db5cb..88fad90f35 100644 --- a/tests/state_test_util.go +++ b/tests/state_test_util.go @@ -328,47 +328,42 @@ func (t *stTransaction) At(i indexes, baseFee *big.Int) (*types.Transaction, err // if tx is not dynamic and accessList is not nil, create an access list transaction if !isDynamiFeeTx && accessList != nil { - txData = &types.AccessListTxn{ - GasPrice: gasPrice, - AccessList: accessList, - BaseTx: &types.BaseTx{ - From: t.From, - To: t.To, - Nonce: t.Nonce, - Value: value, - Gas: t.GasLimit[i.Gas], - Input: hex.MustDecodeHex(t.Data[i.Data]), - }, - } + txData = types.NewAccessListTx( + types.WithGasPrice(gasPrice), + types.WithAccessList(accessList), + types.WithFrom(t.From), + types.WithTo(t.To), + types.WithNonce(t.Nonce), + types.WithValue(value), + types.WithGas(t.GasLimit[i.Gas]), + types.WithInput(hex.MustDecodeHex(t.Data[i.Data])), + ) } if txData == nil { if isDynamiFeeTx { - txData = &types.DynamicFeeTx{ - GasFeeCap: t.MaxFeePerGas, - GasTipCap: t.MaxPriorityFeePerGas, - AccessList: accessList, - BaseTx: &types.BaseTx{ - From: t.From, - To: t.To, - Nonce: t.Nonce, - Value: value, - Gas: t.GasLimit[i.Gas], - Input: hex.MustDecodeHex(t.Data[i.Data]), - }, - } + txData = + types.NewDynamicFeeTx( + types.WithGasFeeCap(t.MaxFeePerGas), + types.WithGasTipCap(t.MaxPriorityFeePerGas), + types.WithAccessList(accessList), + types.WithFrom(t.From), + types.WithTo(t.To), + types.WithNonce(t.Nonce), + types.WithValue(value), + types.WithGas(t.GasLimit[i.Gas]), + types.WithInput(hex.MustDecodeHex(t.Data[i.Data])), + ) } else { - txData = &types.LegacyTx{ - GasPrice: gasPrice, - BaseTx: &types.BaseTx{ - From: t.From, - To: t.To, - Nonce: t.Nonce, - Value: value, - Gas: t.GasLimit[i.Gas], - Input: hex.MustDecodeHex(t.Data[i.Data]), - }, - } + txData = types.NewLegacyTx( + types.WithGasPrice(gasPrice), + types.WithFrom(t.From), + types.WithTo(t.To), + types.WithNonce(t.Nonce), + types.WithValue(value), + types.WithGas(t.GasLimit[i.Gas]), + types.WithInput(hex.MustDecodeHex(t.Data[i.Data])), + ) } } diff --git a/types/access_list_tx.go b/types/access_list_tx.go index e0b47b76ae..1df0b26bf7 100644 --- a/types/access_list_tx.go +++ b/types/access_list_tx.go @@ -112,6 +112,16 @@ type AccessListTxn struct { AccessList TxAccessList } +func NewAccessListTx(options ...TxOption) *AccessListTxn { + accessListTx := &AccessListTxn{BaseTx: &BaseTx{}} + + for _, opt := range options { + opt(accessListTx) + } + + return accessListTx +} + func (tx *AccessListTxn) transactionType() TxType { return AccessListTxType } func (tx *AccessListTxn) chainID() *big.Int { return tx.ChainID } func (tx *AccessListTxn) gasPrice() *big.Int { return tx.GasPrice } @@ -297,7 +307,7 @@ func (tx *AccessListTxn) marshalRLPWith(arena *fastrlp.Arena) *fastrlp.Value { } func (tx *AccessListTxn) copy() TxData { - cpy := &AccessListTxn{} + cpy := NewAccessListTx() if tx.chainID() != nil { chainID := new(big.Int) diff --git a/types/dynamic_fee_tx.go b/types/dynamic_fee_tx.go index eeaa43ee28..b5c33eefd8 100644 --- a/types/dynamic_fee_tx.go +++ b/types/dynamic_fee_tx.go @@ -16,6 +16,16 @@ type DynamicFeeTx struct { AccessList TxAccessList } +func NewDynamicFeeTx(options ...TxOption) *DynamicFeeTx { + dynamicTx := &DynamicFeeTx{BaseTx: &BaseTx{}} + + for _, opt := range options { + opt(dynamicTx) + } + + return dynamicTx +} + func (tx *DynamicFeeTx) transactionType() TxType { return DynamicFeeTxType } func (tx *DynamicFeeTx) chainID() *big.Int { return tx.ChainID } func (tx *DynamicFeeTx) gasPrice() *big.Int { return nil } @@ -208,7 +218,7 @@ func (tx *DynamicFeeTx) marshalRLPWith(arena *fastrlp.Arena) *fastrlp.Value { } func (tx *DynamicFeeTx) copy() TxData { - cpy := &DynamicFeeTx{} + cpy := NewDynamicFeeTx() if tx.chainID() != nil { chainID := new(big.Int) diff --git a/types/legacy_tx.go b/types/legacy_tx.go index e9d9cd23ef..668d905e3b 100644 --- a/types/legacy_tx.go +++ b/types/legacy_tx.go @@ -12,6 +12,16 @@ type LegacyTx struct { GasPrice *big.Int } +func NewLegacyTx(options ...TxOption) *LegacyTx { + legacyTx := &LegacyTx{BaseTx: &BaseTx{}} + + for _, opt := range options { + opt(legacyTx) + } + + return legacyTx +} + func (tx *LegacyTx) transactionType() TxType { return LegacyTxType } func (tx *LegacyTx) chainID() *big.Int { return deriveChainID(tx.v()) } func (tx *LegacyTx) gasPrice() *big.Int { return tx.GasPrice } @@ -159,7 +169,7 @@ func (tx *LegacyTx) marshalRLPWith(arena *fastrlp.Arena) *fastrlp.Value { } func (tx *LegacyTx) copy() TxData { //nolint:dupl - cpy := &LegacyTx{BaseTx: &BaseTx{}} + cpy := NewLegacyTx() if tx.gasPrice() != nil { gasPrice := new(big.Int) diff --git a/types/state_tx.go b/types/state_tx.go index c6f7b6b150..0ff7c48fa2 100644 --- a/types/state_tx.go +++ b/types/state_tx.go @@ -12,6 +12,16 @@ type StateTx struct { GasPrice *big.Int } +func NewStateTx(options ...TxOption) *StateTx { + stateTx := &StateTx{BaseTx: &BaseTx{}} + + for _, opt := range options { + opt(stateTx) + } + + return stateTx +} + func (tx *StateTx) transactionType() TxType { return StateTxType } func (tx *StateTx) chainID() *big.Int { return deriveChainID(tx.v()) } func (tx *StateTx) gasPrice() *big.Int { return tx.GasPrice } @@ -175,7 +185,7 @@ func (tx *StateTx) marshalRLPWith(arena *fastrlp.Arena) *fastrlp.Value { } func (tx *StateTx) copy() TxData { //nolint:dupl - cpy := &StateTx{} + cpy := NewStateTx() if tx.gasPrice() != nil { gasPrice := new(big.Int) diff --git a/types/transaction.go b/types/transaction.go index 00a6bc07e5..e5bb986234 100644 --- a/types/transaction.go +++ b/types/transaction.go @@ -74,13 +74,13 @@ func NewTx(inner TxData) *Transaction { func (t *Transaction) InitInnerData(txType TxType) { switch txType { case AccessListTxType: - t.Inner = &AccessListTxn{BaseTx: &BaseTx{}} + t.Inner = NewAccessListTx() case StateTxType: - t.Inner = &StateTx{BaseTx: &BaseTx{}} + t.Inner = NewStateTx() case LegacyTxType: - t.Inner = &LegacyTx{BaseTx: &BaseTx{}} + t.Inner = NewLegacyTx() default: - t.Inner = &DynamicFeeTx{BaseTx: &BaseTx{}} + t.Inner = NewDynamicFeeTx() } } @@ -391,3 +391,83 @@ func NewTxWithType(txType TxType) *Transaction { return tx } + +type TxOption func(TxData) + +func WithGasPrice(gasPrice *big.Int) TxOption { + return func(td TxData) { + td.setGasPrice(gasPrice) + } +} + +func WithNonce(nonce uint64) TxOption { + return func(td TxData) { + td.setNonce(nonce) + } +} + +func WithGas(gas uint64) TxOption { + return func(td TxData) { + td.setGas(gas) + } +} + +func WithTo(to *Address) TxOption { + return func(td TxData) { + td.setTo(to) + } +} + +func WithValue(value *big.Int) TxOption { + return func(td TxData) { + td.setValue(value) + } +} + +func WithInput(input []byte) TxOption { + return func(td TxData) { + td.setInput(input) + } +} + +func WithSignatureValues(v, r, s *big.Int) TxOption { + return func(td TxData) { + td.setSignatureValues(v, r, s) + } +} + +func WithHash(hash Hash) TxOption { + return func(td TxData) { + td.setHash(hash) + } +} + +func WithFrom(from Address) TxOption { + return func(td TxData) { + td.setFrom(from) + } +} + +func WithGasTipCap(gasTipCap *big.Int) TxOption { + return func(td TxData) { + td.setGasTipCap(gasTipCap) + } +} + +func WithGasFeeCap(gasFeeCap *big.Int) TxOption { + return func(td TxData) { + td.setGasFeeCap(gasFeeCap) + } +} + +func WithChainID(chainID *big.Int) TxOption { + return func(td TxData) { + td.setChainID(chainID) + } +} + +func WithAccessList(accessList TxAccessList) TxOption { + return func(td TxData) { + td.setAccessList(accessList) + } +} From ccea3a862068dcd03bf4b2c532c3128ca827f2fc Mon Sep 17 00:00:00 2001 From: Goran Rojovic Date: Thu, 14 Mar 2024 14:00:37 +0100 Subject: [PATCH 67/67] Revert "Merge branch 'develop' into develop" This reverts commit 23c746e365a0c22ec709bb3294dad71d0fe607fb, reversing changes made to 65015161002d71ccda5405cf42251a0e3a601804. --- .github/workflows/lint.yml | 2 +- .github/workflows/load-test.yml | 2 +- .github/workflows/nightly.yml | 2 +- .github/workflows/notification-deploy-network.yml | 2 +- .github/workflows/notification-destroy-network.yml | 2 +- .github/workflows/notification-load-test.yml | 2 +- .github/workflows/notification-nightly.yml | 2 +- .github/workflows/unit-test.yml | 2 +- .goreleaser.yml | 1 + Dockerfile.release | 2 +- README.md | 2 -- loadtest/scenarios/multiple_EOA.js | 2 +- loadtest/scenarios/multiple_ERC20.js | 2 +- 13 files changed, 12 insertions(+), 13 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 9e82515e09..dc28e1178b 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -30,4 +30,4 @@ jobs: - name: Lint Failed if: failure() id: lint_failure - run: echo "lint_output=false" >> $GITHUB_OUTPUT \ No newline at end of file + run: echo "lint_output=false" >> $GITHUB_OUTPUT diff --git a/.github/workflows/load-test.yml b/.github/workflows/load-test.yml index bb4f8bbdc9..6fa0c7938d 100644 --- a/.github/workflows/load-test.yml +++ b/.github/workflows/load-test.yml @@ -255,4 +255,4 @@ jobs: mode: stop label: ${{ needs.load_test_runner.outputs.load_test_runner_label }} ec2-instance-id: ${{ needs.load_test_runner.outputs.load_test_runner_instance_id }} - github-token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} \ No newline at end of file + github-token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index a9850dda7b..93b311bfda 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -164,4 +164,4 @@ jobs: gas_avg: ${{ needs.load_test_multiple_erc20.outputs.gas_avg }} gas_max: ${{ needs.load_test_multiple_erc20.outputs.gas_max }} secrets: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} \ No newline at end of file + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} diff --git a/.github/workflows/notification-deploy-network.yml b/.github/workflows/notification-deploy-network.yml index a3414699f7..bbae04c529 100644 --- a/.github/workflows/notification-deploy-network.yml +++ b/.github/workflows/notification-deploy-network.yml @@ -105,4 +105,4 @@ jobs: ] } ] - } \ No newline at end of file + } diff --git a/.github/workflows/notification-destroy-network.yml b/.github/workflows/notification-destroy-network.yml index 63d89749dc..1f53823765 100644 --- a/.github/workflows/notification-destroy-network.yml +++ b/.github/workflows/notification-destroy-network.yml @@ -97,4 +97,4 @@ jobs: ] } ] - } \ No newline at end of file + } diff --git a/.github/workflows/notification-load-test.yml b/.github/workflows/notification-load-test.yml index 08dfee4225..519cc151af 100644 --- a/.github/workflows/notification-load-test.yml +++ b/.github/workflows/notification-load-test.yml @@ -136,4 +136,4 @@ jobs: ] } ] - } \ No newline at end of file + } diff --git a/.github/workflows/notification-nightly.yml b/.github/workflows/notification-nightly.yml index cf73b09d35..8bdf8967be 100644 --- a/.github/workflows/notification-nightly.yml +++ b/.github/workflows/notification-nightly.yml @@ -204,4 +204,4 @@ jobs: ] } ] - } \ No newline at end of file + } diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index 71083bf4da..2d7cfeab75 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -30,4 +30,4 @@ jobs: - name: Run Go Test Failed if: failure() id: run_tests_failure - run: echo "test_output=false" >> $GITHUB_OUTPUT \ No newline at end of file + run: echo "test_output=false" >> $GITHUB_OUTPUT diff --git a/.goreleaser.yml b/.goreleaser.yml index 7f4f9f6d6a..cfcdcf844a 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -126,3 +126,4 @@ docker_manifests: - DOCKERHUB_ORGANIZATION/{{ .ProjectName }}:{{ .Version }}-amd64 - DOCKERHUB_ORGANIZATION/{{ .ProjectName }}:{{ .Version }}-arm64 skip_push: auto + \ No newline at end of file diff --git a/Dockerfile.release b/Dockerfile.release index 217268c613..9100d7eb4a 100644 --- a/Dockerfile.release +++ b/Dockerfile.release @@ -9,7 +9,7 @@ COPY blade /usr/local/bin/ EXPOSE 8545 9632 1478 RUN addgroup -S blade-group \ - && adduser -S -u 1001 blade -G blade-group + && adduser -S blade -G blade-group USER blade diff --git a/README.md b/README.md index 75fb6520ec..b6ab6b3662 100644 --- a/README.md +++ b/README.md @@ -11,5 +11,3 @@ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. - -. diff --git a/loadtest/scenarios/multiple_EOA.js b/loadtest/scenarios/multiple_EOA.js index fcf83cb9f6..60ee16bd3e 100644 --- a/loadtest/scenarios/multiple_EOA.js +++ b/loadtest/scenarios/multiple_EOA.js @@ -103,4 +103,4 @@ export function handleSummary(data) { 'stdout': textSummary(data, { indent: ' ', enableColors: true }), // Show the text summary to stdout... 'summary.json': JSON.stringify(data), }; -} \ No newline at end of file +} diff --git a/loadtest/scenarios/multiple_ERC20.js b/loadtest/scenarios/multiple_ERC20.js index e05d107d1b..4db5d0763a 100644 --- a/loadtest/scenarios/multiple_ERC20.js +++ b/loadtest/scenarios/multiple_ERC20.js @@ -105,4 +105,4 @@ export function handleSummary(data) { 'stdout': textSummary(data, { indent: ' ', enableColors: true }), // Show the text summary to stdout... 'summary.json': JSON.stringify(data), }; -} \ No newline at end of file +}