From 0e79a2a14bb38861f1e11dcc8f0ece90e0a1eb2e Mon Sep 17 00:00:00 2001 From: praveen-klaytn Date: Sun, 17 Mar 2024 19:07:48 +0800 Subject: [PATCH] updated CI/CD to support klaytn safe --- .github/CODEOWNERS | 2 +- .github/ISSUE_TEMPLATE/bug_report.md | 10 +- .github/ISSUE_TEMPLATE/feature_request.md | 32 ++-- .github/PULL_REQUEST_TEMPLATE.md | 3 - .github/dependabot.yml | 25 --- .github/release.yml | 15 -- .github/workflows/cla.yml | 36 ----- .github/workflows/develop_deploy.yml | 36 +++++ .github/workflows/production.yml | 36 +++++ .github/workflows/python.yml | 178 ---------------------- LICENSE | 1 + README.md | 20 +-- 12 files changed, 96 insertions(+), 298 deletions(-) delete mode 100644 .github/dependabot.yml delete mode 100644 .github/release.yml delete mode 100644 .github/workflows/cla.yml create mode 100644 .github/workflows/develop_deploy.yml create mode 100644 .github/workflows/production.yml delete mode 100644 .github/workflows/python.yml diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 26d7482a2..3fbbf7e5f 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,3 +1,3 @@ # These owners will be the default owners for everything in # the repo. Unless a later match takes precedence. -* @safe-global/core-api +* @praveen-klaytn diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 5504f1ca6..120b2c960 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -3,6 +3,7 @@ name: Bug report about: Create a report to help us improve title: '' labels: bug +assignees: '' --- @@ -11,10 +12,9 @@ A clear and concise description of what the bug is. **To Reproduce** Steps to reproduce the behavior: -1. Do POST on '...' - - Provide `json` you are submitting to the service (if it applies) -2. Then GET on '....' -3. Links to issues in other repos (if possible) +- Call url `...` +- Provide `json` you are submitting to the service (if it applies) +- Links to issues in other repos (if possible) **Expected behavior** A clear and concise description of what you expected to happen. @@ -27,4 +27,4 @@ A clear and concise description of what you expected to happen. - Version [e.g. 22] **Additional context** -Add any other context about the problem here. +Add any other context about the problem here. \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index 67a2881a4..a07b52076 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -2,33 +2,25 @@ name: Feature request about: Suggest an idea for this project title: '' -labels: enhancement +labels: '' +assignees: '' --- -# What is needed? -A clear and concise description of what you want to happen. - -# Background -More information about the feature needed +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] -# Related issues -Paste here the related links for the issues on the clients/safe project if applicable. Please provide at least one of the following: +**Provide references to the feature you are implementing that requires this change** +Provide at least one of the following: - Links to epics in your repository - Images taken from mocks - Gitbook or any form of written documentation links, etc. Any of these alternatives will help us contextualise your request. -# Endpoint -If applicable, description on the endpoint and the result you expect: +**Describe the solution you'd like** +A clear and concise description of what you want to happen. -## URL -`GET /api/v1/safes/
/creation/` +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. -## Response -``` -{ - created: "", - transactionHash: "", - creator: "" -} -``` +**Additional context** +Add any other context or screenshots about the feature request here. \ No newline at end of file diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index cbd58a88c..32d5f19c4 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -2,9 +2,6 @@ - [ ] You ran `./run_tests.sh` - [ ] You ran `pre-commit run -a` -- [ ] If you want to add your network to `setup_service.py`, provide a link to your - [safe-deployments PR](https://github.com/safe-global/safe-deployments/pulls) and check network name - exists in [safe-eth-py](https://github.com/safe-global/safe-eth-py/blob/master/gnosis/eth/ethereum_network.py) ### What was wrong? 👾 diff --git a/.github/dependabot.yml b/.github/dependabot.yml deleted file mode 100644 index 52f8d8893..000000000 --- a/.github/dependabot.yml +++ /dev/null @@ -1,25 +0,0 @@ -version: 2 -updates: - - package-ecosystem: pip - directory: "/" - schedule: - interval: weekly - day: monday - reviewers: - - "uxio0" - - - package-ecosystem: docker - directory: "/docker/web" - schedule: - interval: weekly - day: monday - reviewers: - - "uxio0" - - - package-ecosystem: github-actions - directory: "/" - schedule: - interval: weekly - day: monday - reviewers: - - "uxio0" diff --git a/.github/release.yml b/.github/release.yml deleted file mode 100644 index 1c0307d05..000000000 --- a/.github/release.yml +++ /dev/null @@ -1,15 +0,0 @@ -changelog: - categories: - - title: 🏕 Features - labels: - - '*' - exclude: - labels: - - dependencies - - breaking_change - - title: 🛠 Breaking Changes - labels: - - breaking_change - - title: 👒 Dependencies - labels: - - dependencies diff --git a/.github/workflows/cla.yml b/.github/workflows/cla.yml deleted file mode 100644 index 1ca08e4ec..000000000 --- a/.github/workflows/cla.yml +++ /dev/null @@ -1,36 +0,0 @@ -name: "CLA Assistant" -on: - issue_comment: - types: [ created ] - pull_request_target: - types: [ opened,closed,synchronize ] - -jobs: - CLAssistant: - runs-on: ubuntu-latest - steps: - - name: "CLA Assistant" - 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' - # Beta Release - uses: cla-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: 'signatures/version1/cla.json' - path-to-document: 'https://safe.global/cla' - # branch should not be protected - branch: 'cla-signatures' - allowlist: falvaradorodriguez,hectorgomezv,moisses89,luarx,fmrsabino,luarx,rmeissner,Uxio0,*bot # may need to update this expression if we add new bots - - #below are the optional inputs - If the optional inputs are not given, then default values will be taken - #remote-organization-name: enter the remote organization name where the signatures should be stored (Default is storing the signatures in the same repository) - #remote-repository-name: enter the remote repository name where the signatures should be stored (Default is storing the signatures in the same repository) - #create-file-commit-message: 'For example: Creating file for storing CLA Signatures' - #signed-commit-message: 'For example: $contributorName has signed the CLA in #$pullRequestNo' - #custom-notsigned-prcomment: 'pull request comment with Introductory message to ask new contributors to sign' - #custom-pr-sign-comment: 'The signature to be committed in order to sign the CLA' - #custom-allsigned-prcomment: 'pull request comment when all contributors has signed, defaults to **CLA Assistant Lite bot** All Contributors have signed the CLA.' - #lock-pullrequest-aftermerge: false - if you don't want this bot to automatically lock the pull request after merging (default - true) - #use-dco-flag: true - If you are using DCO instead of CLA diff --git a/.github/workflows/develop_deploy.yml b/.github/workflows/develop_deploy.yml new file mode 100644 index 000000000..1d8d81e02 --- /dev/null +++ b/.github/workflows/develop_deploy.yml @@ -0,0 +1,36 @@ +name: klaytn-safe-txn deploy workflow +on: + push: + branches: + - main + +jobs: + deploy: + permissions: + id-token: write + contents: read + runs-on: ubuntu-latest + + steps: + - name: Checkout source code + uses: actions/checkout@v3 + + - name: Get AWS credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + role-to-assume: ${{ secrets.AWS_IAM_ROLE_ARN_DEV }} + role-session-name: SessionForKlaytnActions + aws-region: ${{ secrets.AWS_REGION_DEV }} + + - name: Login to Amazon ECR + uses: aws-actions/amazon-ecr-login@v1 + id: login-ecr + + - name: Build, tag, and push image to Amazon ECR + env: + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + ECR_REPOSITORY: ${{ secrets.ECR_REPOSITORY_DEV }} + run: | + git_hash=$(git rev-parse --short "$GITHUB_SHA") + docker build -t $ECR_REPOSITORY:${GITHUB_REF_NAME}.${git_hash} -t $ECR_REPOSITORY:latest -f docker/web/Dockerfile . + docker push $ECR_REPOSITORY --all-tags \ No newline at end of file diff --git a/.github/workflows/production.yml b/.github/workflows/production.yml new file mode 100644 index 000000000..d757dca5c --- /dev/null +++ b/.github/workflows/production.yml @@ -0,0 +1,36 @@ +name: Build & public container image in main +on: + push: + tags: + - v[0-9]+.[0-9]+.[0-9]+ + +jobs: + build-and-push: + permissions: + id-token: write + contents: read + runs-on: ubuntu-latest + + steps: + - name: Checkout source code + uses: actions/checkout@v3 + + - name: Get AWS credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + role-to-assume: ${{ secrets.AWS_IAM_ROLE_ARN_PROD }} + role-session-name: SessionForKlaytnActions + aws-region: ${{ secrets.AWS_REGION_PROD }} + + - name: Login to Amazon ECR + uses: aws-actions/amazon-ecr-login@v1 + id: login-ecr + + - name: Build, tag, and push image to Amazon ECR + env: + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + ECR_REPOSITORY: ${{ secrets.ECR_REPOSITORY_PROD }} + IMAGE_TAG: ${{ github.ref_name }} + run: | + docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -f docker/web/Dockerfile . + docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG \ No newline at end of file diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml deleted file mode 100644 index 942c551a6..000000000 --- a/.github/workflows/python.yml +++ /dev/null @@ -1,178 +0,0 @@ -name: Python CI -on: - push: - branches: - - main - - develop - pull_request: - release: - types: [ released ] - -jobs: - linting: - runs-on: ubuntu-latest - strategy: - matrix: - python-version: ["3.12"] - - steps: - - uses: actions/checkout@v4 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: pip install pre-commit - - name: Run pre-commit - run: pre-commit run --all-files - - test-app: - runs-on: ubuntu-latest - strategy: - matrix: - python-version: ["3.12"] - services: - redis: - image: redis - options: >- - --health-cmd "redis-cli ping" - --health-interval 10s - --health-timeout 5s - --health-retries 5 - ports: - - 6379:6379 - postgres: - image: postgres:14 - env: - POSTGRES_USER: postgres - POSTGRES_PASSWORD: postgres - options: >- - --health-cmd pg_isready - --health-interval 10s - --health-timeout 5s - --health-retries 5 - ports: - - 5432:5432 - rabbitmq: - image: rabbitmq:alpine - options: >- - --health-cmd "rabbitmqctl await_startup" - --health-interval 10s - --health-timeout 5s - --health-retries 5 - ports: - - "5672:5672" - steps: - - name: Setup and run ganache - run: | - docker run --detach --publish 8545:8545 --network-alias ganache -e DOCKER=true trufflesuite/ganache:latest --defaultBalanceEther 10000 --gasLimit 10000000 -a 30 --chain.chainId 1337 --chain.networkId 1337 -d - - uses: actions/checkout@v4 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - cache: 'pip' - cache-dependency-path: 'requirements*.txt' - - name: Install dependencies - run: | - pip install wheel setuptools - pip install -r requirements-test.txt - env: - PIP_USE_MIRRORS: true - - name: Run tests and coverage - run: | - python manage.py check - python manage.py makemigrations --check --dry-run - coverage run --source=$SOURCE_FOLDER -m pytest -rxXs --reruns 3 - env: - SOURCE_FOLDER: safe_transaction_service - CELERY_BROKER_URL: redis://localhost:6379/0 - COINMARKETCAP_API_TOKEN: ${{ secrets.COINMARKETCAP_API_TOKEN }} - DATABASE_URL: psql://postgres:postgres@localhost/postgres - DJANGO_SETTINGS_MODULE: config.settings.test - ETHEREUM_MAINNET_NODE: ${{ secrets.ETHEREUM_MAINNET_NODE }} - ETHEREUM_NODE_URL: http://localhost:8545 - ETHEREUM_TRACING_NODE_URL: http://localhost:8545 - ETH_HASH_BACKEND: pysha3 - REDIS_URL: redis://localhost:6379/0 - EVENTS_QUEUE_URL: amqp://guest:guest@localhost:5672/ - - name: Coveralls - uses: coverallsapp/github-action@v2 - docker-deploy: - runs-on: ubuntu-latest - needs: - - linting - - test-app - if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' || (github.event_name == 'release' && github.event.action == 'released') - steps: - - uses: actions/checkout@v4 - - uses: docker/setup-qemu-action@v3 - with: - platforms: arm64 - - uses: docker/setup-buildx-action@v3 - - name: Dockerhub login - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKER_USER }} - password: ${{ secrets.DOCKER_PASSWORD }} - - name: Deploy Master - if: github.ref == 'refs/heads/main' - uses: docker/build-push-action@v5 - with: - context: . - file: docker/web/Dockerfile - push: true - tags: safeglobal/safe-transaction-service:staging - platforms: | - linux/amd64 - linux/arm64 - cache-from: type=gha - cache-to: type=gha,mode=max - - name: Deploy Develop - if: github.ref == 'refs/heads/develop' - uses: docker/build-push-action@v5 - with: - context: . - file: docker/web/Dockerfile - push: true - tags: safeglobal/safe-transaction-service:develop - platforms: | - linux/amd64 - linux/arm64 - cache-from: type=gha - cache-to: type=gha,mode=max - - name: Deploy Tag - if: (github.event_name == 'release' && github.event.action == 'released') - uses: docker/build-push-action@v5 - with: - context: . - file: docker/web/Dockerfile - push: true - tags: | - safeglobal/safe-transaction-service:${{ github.event.release.tag_name }} - safeglobal/safe-transaction-service:latest - platforms: | - linux/amd64 - linux/arm64 - cache-from: type=gha - cache-to: type=gha,mode=max - autodeploy: - runs-on: ubuntu-latest - needs: [docker-deploy] - if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' - steps: - - uses: actions/checkout@v4 - - name: Deploy Staging - if: github.ref == 'refs/heads/main' - run: bash scripts/autodeploy.sh - env: - AUTODEPLOY_URL: ${{ secrets.AUTODEPLOY_URL }} - AUTODEPLOY_TOKEN: ${{ secrets.AUTODEPLOY_TOKEN }} - TARGET_ENV: "staging" - - name: Deploy Develop - if: github.ref == 'refs/heads/develop' - run: bash scripts/autodeploy.sh - env: - AUTODEPLOY_URL: ${{ secrets.AUTODEPLOY_URL }} - AUTODEPLOY_TOKEN: ${{ secrets.AUTODEPLOY_TOKEN }} - TARGET_ENV: "develop" diff --git a/LICENSE b/LICENSE index 86aa6415b..5ea72c112 100644 --- a/LICENSE +++ b/LICENSE @@ -1,5 +1,6 @@ MIT License +Modifications Copyright (c) 2022 Klaytn Foundation Copyright (c) 2018 Safe Ecosystem Foundation Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/README.md b/README.md index 53bb0a991..512daa5ce 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,4 @@ -![Build Status](https://github.com/safe-global/safe-transaction-service/workflows/Python%20CI/badge.svg?branch=main) -[![Coverage Status](https://coveralls.io/repos/github/safe-global/safe-transaction-service/badge.svg?branch=main)](https://coveralls.io/github/safe-global/safe-transaction-service?branch=main) -[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit) -![Python 3.12](https://img.shields.io/badge/Python-3.12-blue.svg) -![Django 5](https://img.shields.io/badge/Django-5-blue.svg) -[![Docker Image Version (latest semver)](https://img.shields.io/docker/v/safeglobal/safe-transaction-service?label=Docker&sort=semver)](https://hub.docker.com/r/safeglobal/safe-transaction-service) - -# Safe Transaction Service +# Klaytn Safe Transaction Service Keeps track of transactions sent via Safe contracts. It uses events and [tracing](https://openethereum.github.io/JSONRPC-trace-module) to index the txs. @@ -15,13 +8,10 @@ as in previous versions of the *Transaction Service*. Transactions can also be sent to the service to allow offchain collecting of signatures or informing the owners about a transaction that is pending to be sent to the blockchain. -[Swagger (Mainnet version)](https://safe-transaction-mainnet.safe.global/) -[More networks](https://docs.safe.global/api-supported-networks) - ## Index of contents - [Docs](https://docs.safe.global/safe-core-api/service-architecture) -- [Deploying the service](https://github.com/safe-global/safe-infrastructure) +- [Deploying the service](https://github.com/klaytn/klaytn-safe-infrastructure) ## Setup for development Use a virtualenv if possible: @@ -148,7 +138,7 @@ Service can run into some issues when running in production: ### Indexing issues You can tell there are indexing issues if: -- Executed transactions are missing from the API (`all-transactions`, `multisig-transactions`, `module-transactions`... endpoints). If you use the [Safe{Wallet} Web client](https://github.com/safe-global/safe-wallet-web) you should check what is the current state of the Safe Client Gateway cache as it might have outdated data. +- Executed transactions are missing from the API (`all-transactions`, `multisig-transactions`, `module-transactions`... endpoints). If you use the [Safe{Wallet} Web client](https://github.com/klaytn/klaytn-safe-wallet-web) you should check what is the current state of the Safe Client Gateway cache as it might have outdated data. - Asset transfers (ERC20/721) are missing from `all-transactions` or `transfers` endpoints. - You see error logs such as "Cannot remove owner" or similar inconsistent errors when `worker-indexer` is processing decoded data. @@ -187,7 +177,7 @@ Aside from using standard HTTP requests: - [Safe CLI](https://github.com/safe-global/safe-cli): It has a `tx-service` mode to gather offchain signatures. ### What chains do you officially support? -https://docs.safe.global/api-supported-networks +Klaytn Cypress and Baobab ### What means banned field in SafeContract model? The `banned` field in the `SafeContract` model is used to prevent indexing of certain Safes that have an unsupported `MasterCopy` or unverified proxies that have issues during indexing. This field does not remove the banned Safe and indexing can be resumed once the issue has been resolved. @@ -199,4 +189,4 @@ The `banned` field in the `SafeContract` model is used to prevent indexing of ce If you face issues installing the `grpc` dependency locally (required by this project) on a M1 chip, set `GRPC_PYTHON_BUILD_SYSTEM_OPENSSL=1` and `GRPC_PYTHON_BUILD_SYSTEM_ZLIB=1` and then try to install the dependency again. ## Contributors -[See contributors](https://github.com/safe-global/safe-transaction-service/graphs/contributors) +[See contributors](https://github.com/klaytn/klaytn-safe-transaction-service/graphs/contributors)