Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
gofman8 committed Aug 9, 2024
2 parents 29ca08e + 57a0ce2 commit 63c5bdb
Show file tree
Hide file tree
Showing 278 changed files with 8,983 additions and 4,822 deletions.
3 changes: 2 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
.dockerignore
.gitignore
.git
.github
.env
.pylintrc
__pycache__
*.pyc
*.egg-info
.idea/

.vscode
1 change: 1 addition & 0 deletions .env.custom
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
APPLICATION_VERSION=5.0.0
1 change: 1 addition & 0 deletions .env.dev
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ ETHEREUM_TRACING_NODE_URL=
ETH_L2_NETWORK=1
REDIS_URL=redis://redis:6379/0
CELERY_BROKER_URL=amqp://guest:guest@rabbitmq/
CSRF_TRUSTED_ORIGINS="http://localhost:8000"
2 changes: 2 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
13c96f0b5c51b6f20b5f9c4370ae8141a2809156
b26efe58f1c4bf89c5461c38065bc3c51ba4af04
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# These owners will be the default owners for everything in
# the repo. Unless a later match takes precedence.
* @safe-global/safe-services
* @safe-global/core-api
17 changes: 9 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,28 @@
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
rev: 5.13.2
hooks:
- id: isort
- repo: https://github.com/psf/black
rev: 22.12.0
rev: 24.2.0
hooks:
- id: black
- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
rev: 7.0.0
hooks:
- id: flake8
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: check-added-large-files
- id: check-docstring-first
- id: check-merge-conflict
- id: check-symlinks
- id: check-yaml
- id: debug-statements
- id: detect-private-key
- id: requirements-txt-fixer
- id: trailing-whitespace
- id: end-of-file-fixer
types: [python]
- id: check-yaml
- id: check-added-large-files
- id: requirements-txt-fixer
- id: trailing-whitespace
1 change: 0 additions & 1 deletion CONTRIBUTORS.txt

This file was deleted.

20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
![Build Status](https://github.com/safe-global/safe-transaction-service/workflows/Python%20CI/badge.svg?branch=master)
[![Coverage Status](https://coveralls.io/repos/github/safe-global/safe-transaction-service/badge.svg?branch=master)](https://coveralls.io/github/safe-global/safe-transaction-service?branch=master)
[![CI/CD](https://github.com/safe-global/safe-transaction-service/actions/workflows/python.yml/badge.svg)](https://github.com/safe-global/safe-transaction-service/actions/workflows/python.yml)
[![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.10](https://img.shields.io/badge/Python-3.10-blue.svg)
![Django 4](https://img.shields.io/badge/Django-4-blue.svg)
![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
Expand All @@ -16,7 +16,7 @@ Transactions can also be sent to the service to allow offchain collecting of sig
a transaction that is pending to be sent to the blockchain.

[Swagger (Mainnet version)](https://safe-transaction-mainnet.safe.global/)
[Swagger (Göerli version)](https://safe-transaction-goerli.safe.global/)
[More networks](https://docs.safe.global/api-supported-networks)

## Index of contents

Expand Down Expand Up @@ -70,7 +70,7 @@ For more parameters check [base.py](config/settings/base.py) file.

- If the network is not supported yet [contracts can be deployed using the deployment instructions
](https://github.com/safe-global/safe-contracts/tree/v1.3.0/contracts)
and then a PR should be provided [adding the deployment block number and the address](https://github.com/safe-global/safe-eth-py/blob/master/gnosis/safe/addresses.py) (address will be the same for every network).
and then a PR should be provided [adding the deployment block number and the address](https://github.com/safe-global/safe-eth-py/blob/main/gnosis/safe/addresses.py) (address will be the same for every network).
- Only `ProxyFactory` and `GnosisSafeL2` must be configured. `+L2` must be added to the `Safe L2` contract versions, so the service knows the contract can be indexed using events. For us to accept the PR network must be on https://github.com/ethereum-lists/chains .
- You can always set this up later using the **admin panel** if your network is not supported, going to the **Master Copies** and **Proxy Factories**.
- **We recommend** using event indexing for every network where transaction fees are not relevant, so a tracing node is not required and everything can be indexed using events with the `Safe L2` version.
Expand Down Expand Up @@ -184,19 +184,19 @@ and [have a proper RPC](https://docs.safe.global/safe-core-api/rpc-requirements)
Aside from using standard HTTP requests:
- [Safe{Core} API Kit](https://github.com/safe-global/safe-core-sdk/tree/main/packages/api-kit)
- [Safe-eth-py](https://github.com/safe-global/safe-eth-py)
- [Safe CLI](https://github.com/5afe/safe-cli): It has a `tx-service` mode to gather offchain signatures.
- [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/safe-core-api/available-services
https://docs.safe.global/api-supported-networks

### 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.

## Troubleshooting

### Issues installing grpc on a Mac M1
### Issues installing grpc on an Apple silicon system

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.
If you face issues installing the `grpc` dependency locally (required by this project) on a Apple silicon 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)
1 change: 1 addition & 0 deletions config/gunicorn.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Store gunicorn variables in this file, so they can be read by Django
"""

import os

gunicorn_request_timeout = os.environ.get("WEB_WORKER_TIMEOUT", 60)
Expand Down
56 changes: 42 additions & 14 deletions config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@
SITE_ID = 1
# https://docs.djangoproject.com/en/dev/ref/settings/#use-i18n
USE_I18N = True
# https://docs.djangoproject.com/en/dev/ref/settings/#use-l10n
USE_L10N = True
# https://docs.djangoproject.com/en/dev/ref/settings/#use-tz
USE_TZ = True
# https://docs.djangoproject.com/en/3.2/ref/settings/#force-script-name
Expand Down Expand Up @@ -106,13 +104,14 @@
"rest_framework.authtoken",
]
LOCAL_APPS = [
"safe_transaction_service.account_abstraction.apps.AccountAbstractionConfig",
"safe_transaction_service.analytics.apps.AnalyticsConfig",
"safe_transaction_service.contracts.apps.ContractsConfig",
"safe_transaction_service.events.apps.EventsConfig",
"safe_transaction_service.history.apps.HistoryConfig",
"safe_transaction_service.notifications.apps.NotificationsConfig",
"safe_transaction_service.safe_messages.apps.SafeMessagesConfig",
"safe_transaction_service.tokens.apps.TokensConfig",
"safe_transaction_service.events.apps.EventsConfig",
]
# https://docs.djangoproject.com/en/dev/ref/settings/#installed-apps
INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + LOCAL_APPS
Expand Down Expand Up @@ -229,15 +228,21 @@
CELERY_BROKER_HEARTBEAT = env.int("CELERY_BROKER_HEARTBEAT", default=0)

# https://docs.celeryq.dev/en/stable/userguide/configuration.html#std-setting-broker_connection_max_retries
CELERY_BROKER_CONNECTION_MAX_RETRIES = env.int(
"CELERY_BROKER_CONNECTION_MAX_RETRIES", default=0
CELERY_BROKER_CONNECTION_MAX_RETRIES = (
value
if (value := env.int("CELERY_BROKER_CONNECTION_MAX_RETRIES", default=-1)) > 0
else None
)
# https://docs.celeryq.dev/en/stable/userguide/configuration.html#broker-channel-error-retry
CELERY_BROKER_CHANNEL_ERROR_RETRY = env.bool(
"CELERY_BROKER_CHANNEL_ERROR_RETRY", default=True
)
# http://docs.celeryproject.org/en/latest/userguide/configuration.html#std:setting-result_backend
CELERY_RESULT_BACKEND = env("CELERY_RESULT_BACKEND", default="redis://")
# https://docs.celeryq.dev/en/stable/userguide/configuration.html#broker-connection-retry-on-startup
CELERY_BROKER_CONNECTION_RETRY_ON_STARTUP = env.bool(
"CELERY_BROKER_CONNECTION_RETRY_ON_STARTUP", default=True
)
# https://docs.celeryq.dev/en/latest/userguide/configuration.html#task-result-backend-settings
CELERY_RESULT_BACKEND = env("CELERY_RESULT_BACKEND", default=None)
# http://docs.celeryproject.org/en/latest/userguide/configuration.html#std:setting-accept_content
CELERY_ACCEPT_CONTENT = ["json"]
# http://docs.celeryproject.org/en/latest/userguide/configuration.html#std:setting-task_serializer
Expand Down Expand Up @@ -421,6 +426,9 @@
"handlers": ["console", "mail_admins"],
"propagate": True,
},
"pika": {
"propagate": True if DEBUG else False,
},
},
}

Expand All @@ -430,14 +438,26 @@
# ------------------------------------------------------------------------------
ETHEREUM_NODE_URL = env("ETHEREUM_NODE_URL", default=None)

# Ethereum 4337 Bundler RPC
# ------------------------------------------------------------------------------
ETHEREUM_4337_BUNDLER_URL = env("ETHEREUM_4337_BUNDLER_URL", default=None)
ETHEREUM_4337_SUPPORTED_ENTRY_POINTS = env.list(
"ETHEREUM_4337_SUPPORTED_ENTRY_POINTS",
default=["0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789"],
)
ETHEREUM_4337_SUPPORTED_SAFE_MODULES = env.list(
"ETHEREUM_4337_SUPPORTED_SAFE_MODULES",
default=["0xa581c4A4DB7175302464fF3C06380BC3270b4037"],
)

# Tracing indexing configuration (not useful for L2 indexing)
# ------------------------------------------------------------------------------
ETHEREUM_TRACING_NODE_URL = env("ETHEREUM_TRACING_NODE_URL", default=None)
ETH_INTERNAL_TXS_BLOCK_PROCESS_LIMIT = env.int(
"ETH_INTERNAL_TXS_BLOCK_PROCESS_LIMIT", default=10_000
)
ETH_INTERNAL_TXS_BLOCKS_TO_REINDEX_AGAIN = env.int(
"ETH_INTERNAL_TXS_BLOCKS_TO_REINDEX_AGAIN", default=10
"ETH_INTERNAL_TXS_BLOCKS_TO_REINDEX_AGAIN", default=1
)
ETH_INTERNAL_TXS_NUMBER_TRACE_BLOCKS = env.int(
"ETH_INTERNAL_TXS_NUMBER_TRACE_BLOCKS", default=10
Expand All @@ -464,7 +484,7 @@
"ETH_EVENTS_BLOCK_PROCESS_LIMIT_MAX", default=0
) # Maximum number of blocks to process together when searching for events. 0 == no limit.
ETH_EVENTS_BLOCKS_TO_REINDEX_AGAIN = env.int(
"ETH_EVENTS_BLOCKS_TO_REINDEX_AGAIN", default=20
"ETH_EVENTS_BLOCKS_TO_REINDEX_AGAIN", default=2
) # Blocks to reindex again every indexer run when service is synced. Useful for RPCs not reliable
ETH_EVENTS_GET_LOGS_CONCURRENCY = env.int(
"ETH_EVENTS_GET_LOGS_CONCURRENCY", default=20
Expand Down Expand Up @@ -496,10 +516,6 @@
"TOKENS_ERC20_GET_BALANCES_BATCH", default=2_000
) # Number of tokens to get balances from in the same request. From 2_500 some nodes raise HTTP 413

TOKEN_ETH_PRICE_TTL = env.int(
"TOKEN_ETH_PRICE_TTL", default=60 * 30 # 30 minutes
) # Expiration time for token eth price

# Notifications
# ------------------------------------------------------------------------------
SLACK_API_WEBHOOK = env("SLACK_API_WEBHOOK", default=None)
Expand All @@ -524,8 +540,10 @@
# Events
# ------------------------------------------------------------------------------
EVENTS_QUEUE_URL = env("EVENTS_QUEUE_URL", default=None)
EVENTS_QUEUE_ASYNC_CONNECTION = env("EVENTS_QUEUE_ASYNC_CONNECTION", default=False)
EVENTS_QUEUE_EXCHANGE_NAME = env("EVENTS_QUEUE_EXCHANGE_NAME", default="amq.fanout")
EVENTS_QUEUE_POOL_CONNECTIONS_LIMIT = env.int(
"EVENTS_QUEUE_POOL_CONNECTIONS_LIMIT", default=0
)

# Cache
CACHE_ALL_TXS_VIEW = env.int(
Expand Down Expand Up @@ -554,4 +572,14 @@
"SECURITY_DEFINITIONS": {
"api_key": {"type": "apiKey", "in": "header", "name": "Authorization"}
},
"DEFAULT_AUTO_SCHEMA_CLASS": "safe_transaction_service.utils.swagger.CustomSwaggerSchema",
}

# Shell Plus
# ------------------------------------------------------------------------------
SHELL_PLUS_PRINT_SQL_TRUNCATE = env.int("SHELL_PLUS_PRINT_SQL_TRUNCATE", default=10_000)

# Endpoints
TX_SERVICE_ALL_TXS_ENDPOINT_LIMIT_TRANSFERS = env.int(
"TX_SERVICE_ALL_TXS_ENDPOINT_LIMIT_TRANSFERS", default=1_000
) # Don't return more than 1_000 transfers
9 changes: 5 additions & 4 deletions config/settings/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@

REDIS_URL = env.str("REDIS_URL")

# SECURITY
# ------------------------------------------------------------------------------
# https://docs.djangoproject.com/en/dev/ref/middleware/#x-content-type-options-nosniff
CSRF_TRUSTED_ORIGINS = env.list("CSRF_TRUSTED_ORIGINS", default=[])

# CACHES
# ------------------------------------------------------------------------------
# https://docs.djangoproject.com/en/dev/ref/settings/#caches
Expand Down Expand Up @@ -50,7 +55,3 @@
}
# https://django-debug-toolbar.readthedocs.io/en/latest/installation.html#internal-ips
INTERNAL_IPS = ["127.0.0.1", "10.0.2.2"]

# CELERY
# ------------------------------------------------------------------------------
CELERY_RESULT_BACKEND = env("CELERY_RESULT_BACKEND", default=REDIS_URL)
6 changes: 1 addition & 5 deletions config/settings/production.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
SECURE_CONTENT_TYPE_NOSNIFF = env.bool(
"DJANGO_SECURE_CONTENT_TYPE_NOSNIFF", default=True
)
# https://docs.djangoproject.com/en/3.2/ref/settings/#csrf-trusted-origins
# https://docs.djangoproject.com/en/5.0/ref/settings/#csrf-trusted-origins
CSRF_TRUSTED_ORIGINS = env.list("CSRF_TRUSTED_ORIGINS", default=[])

# SSO (tested with https://github.com/buzzfeed/sso)
Expand Down Expand Up @@ -66,10 +66,6 @@
ADMIN_URL = env("DJANGO_ADMIN_URL", default="admin/")
SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTOCOL", "https")

# CELERY
# ------------------------------------------------------------------------------
CELERY_RESULT_BACKEND = env("CELERY_RESULT_BACKEND", default=REDIS_URL)

# Gunicorn
# ------------------------------------------------------------------------------
INSTALLED_APPS += ["gunicorn"] # noqa F405
2 changes: 0 additions & 2 deletions config/settings/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,3 @@
"level": "DEBUG",
}
}

EVENTS_QUEUE_ASYNC_CONNECTION = False
9 changes: 8 additions & 1 deletion config/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
openapi.Info(
title="Safe Transaction Service API",
default_version="v1",
description="API to keep track of transactions sent via Gnosis Safe smart contracts",
description="API to keep track of transactions sent via Safe smart contracts",
license=openapi.License(name="MIT License"),
),
validators=["flex", "ssv"],
Expand Down Expand Up @@ -43,6 +43,13 @@

urlpatterns_v1 = [
path("", include("safe_transaction_service.history.urls", namespace="history")),
path(
"",
include(
"safe_transaction_service.account_abstraction.urls",
namespace="account_abstraction",
),
),
path(
"contracts/",
include("safe_transaction_service.contracts.urls", namespace="contracts"),
Expand Down
1 change: 1 addition & 0 deletions config/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
framework.
"""

import os
import sys

Expand Down
6 changes: 3 additions & 3 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: '3.5'

services:
web:
build:
Expand Down Expand Up @@ -30,6 +28,8 @@ services:

ganache:
image: trufflesuite/ganache:latest
command: --defaultBalanceEther 10000 --gasLimit 10000000 -a 10 --chain.chainId 1337 --chain.networkId 1337 -d --host 0.0.0.0
ports:
- "8545:8545"
command: --defaultBalanceEther 10000 --gasLimit 10000000 -a 10 --chain.chainId 1337 --chain.networkId 1337 -d --host 0.0.0.0
healthcheck:
test: bash -c "echo 'hello' > /dev/tcp/localhost/8545"
Loading

0 comments on commit 63c5bdb

Please sign in to comment.