Skip to content

Commit

Permalink
Merge branch 'moonbeam-stg' into moonbeam
Browse files Browse the repository at this point in the history
  • Loading branch information
datradito committed Aug 19, 2022
2 parents dbde1cc + 4a1bf2a commit 4b3d687
Show file tree
Hide file tree
Showing 47 changed files with 697 additions and 390 deletions.
1 change: 0 additions & 1 deletion .env.dev
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
PYTHONPATH=/app/
DJANGO_SETTINGS_MODULE=config.settings.local
C_FORCE_ROOT=true
DEBUG=0
DATABASE_URL=psql://postgres:postgres@db:5432/postgres
ETHEREUM_NODE_URL=http://ganache:8545
Expand Down
2 changes: 0 additions & 2 deletions .env.l2.sample
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
PYTHONPATH=/app/
DJANGO_SETTINGS_MODULE=config.settings.production
# DJANGO_SETTINGS_MODULE=config.settings.local
DJANGO_SECRET_KEY='Very-secure-secret-string'
C_FORCE_ROOT=true
DEBUG=0
DATABASE_URL=psql://postgres:postgres@db:5432/postgres
ETHEREUM_NODE_URL=https://polygon-rpc.com/
Expand Down
1 change: 0 additions & 1 deletion .env.local
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
PYTHONPATH=/app/
DJANGO_SETTINGS_MODULE=config.settings.local
C_FORCE_ROOT=true
DEBUG=0
DATABASE_URL=psql://postgres:postgres@db:5432/postgres
ETHEREUM_NODE_URL=http://172.17.0.1:8545
Expand Down
4 changes: 1 addition & 3 deletions .env.test
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# Test project outside docker
PYTHONPATH=/app/
C_FORCE_ROOT=true
DEBUG=0
USE_DOCKER=False
DJANGO_SETTINGS_MODULE=config.settings.test
DJANGO_SECRET_KEY=test-secret#-!key
DATABASE_URL=psql://postgres:postgres@localhost:5432/postgres
Expand All @@ -11,4 +9,4 @@ CELERY_BROKER_URL=redis://localhost/0
# ETHEREUM_MAINNET_NODE= # Set it to test some features with a real node
ETHEREUM_NODE_URL=http://localhost:8545
ETHEREUM_TRACING_NODE_URL=http://localhost:8545
DOCKER_DB_PORT=5432
ETH_HASH_BACKEND=pysha3
1 change: 0 additions & 1 deletion .env.tracing.sample
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ PYTHONPATH=/app/
DJANGO_SETTINGS_MODULE=config.settings.production
# DJANGO_SETTINGS_MODULE=config.settings.local
DJANGO_SECRET_KEY='Very-secure-secret-string'
C_FORCE_ROOT=true
DEBUG=0
DATABASE_URL=psql://postgres:postgres@db:5432/postgres
ETHEREUM_NODE_URL=https://polygon-mainnet.infura.io/v3/your-infura-id
Expand Down
1 change: 0 additions & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ name: Bug report
about: Create a report to help us improve
title: ''
labels: bug
assignees: Uxio0

---

Expand Down
1 change: 0 additions & 1 deletion .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ name: Feature request
about: Suggest an idea for this project
title: ''
labels: enhancement
assignees: Uxio0

---

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cla.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- 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.1.3-beta
uses: cla-assistant/github-action@v2.2.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
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,15 @@ jobs:
coverage run --source=$SOURCE_FOLDER -m py.test -rxXs --reruns 3
env:
SOURCE_FOLDER: safe_transaction_service
DJANGO_SETTINGS_MODULE: config.settings.test
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
CELERY_BROKER_URL: redis://localhost:6379/0
ETHEREUM_MAINNET_NODE: ${{ secrets.ETHEREUM_MAINNET_NODE }}
COINMARKETCAP_API_TOKEN: ${{ secrets.COINMARKETCAP_API_TOKEN }}
- name: Send results to coveralls
continue-on-error: true # Ignore coveralls problems
run: coveralls --service=github
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ repos:
hooks:
- id: black
- repo: https://github.com/PyCQA/flake8
rev: 4.0.1
rev: 5.0.3
hooks:
- id: flake8
- repo: https://github.com/pre-commit/pre-commit-hooks
Expand Down
1 change: 0 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"args": [
"--lf",
"-rxXs",
"--disable-warnings",
"${file}"
],
"django": true,
Expand Down
42 changes: 15 additions & 27 deletions config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,10 @@
},
]


# CORS
CORS_ORIGIN_ALLOW_ALL = True
# ------------------------------------------------------------------------------
CORS_ALLOW_ALL_ORIGINS = True
CORS_ALLOW_HEADERS = list(default_cors_headers) + [
"if-match",
"if-modified-since",
Expand All @@ -186,23 +188,10 @@
# https://docs.djangoproject.com/en/dev/ref/settings/#fixture-dirs
FIXTURE_DIRS = (str(APPS_DIR / "fixtures"),)

# EMAIL
# ------------------------------------------------------------------------------
# https://docs.djangoproject.com/en/dev/ref/settings/#email-backend
EMAIL_BACKEND = env(
"DJANGO_EMAIL_BACKEND", default="django.core.mail.backends.smtp.EmailBackend"
)

# ADMIN
# ------------------------------------------------------------------------------
# Django Admin URL regex.
ADMIN_URL = "admin/"
# https://docs.djangoproject.com/en/dev/ref/settings/#admins
ADMINS = [
("Gnosis Safe team", "safe@gnosis.io"),
]
# https://docs.djangoproject.com/en/dev/ref/settings/#managers
MANAGERS = ADMINS

# Celery
# ------------------------------------------------------------------------------
Expand Down Expand Up @@ -374,12 +363,12 @@

REDIS_URL = env("REDIS_URL", default="redis://localhost:6379/0")

# Ethereum
# Ethereum RPC
# ------------------------------------------------------------------------------
ETHEREUM_NODE_URL = env("ETHEREUM_NODE_URL", default=None)
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=10000
"ETH_INTERNAL_TXS_BLOCK_PROCESS_LIMIT", default=10_000
)
ETH_INTERNAL_NO_FILTER = env.bool("ETH_INTERNAL_NO_FILTER", default=False)
ETH_INTERNAL_TRACE_TXS_BATCH_SIZE = env.int(
Expand All @@ -395,26 +384,24 @@
"ETH_EVENTS_BLOCK_PROCESS_LIMIT_MAX", default=0
) # Maximum number of blocks to process together when searching for events. 0 == no limit.
ETH_EVENTS_QUERY_CHUNK_SIZE = env.int(
"ETH_EVENTS_QUERY_CHUNK_SIZE", default=0
) # Number of addresses 'almost updated' to update together. 0 == no limit
"ETH_EVENTS_QUERY_CHUNK_SIZE", default=5_000
) # Number of addresses to use as `getLogs` parameter. `0 == no limit`. By testing `5000` looks like a good default
ETH_EVENTS_UPDATED_BLOCK_BEHIND = env.int(
"ETH_EVENTS_UPDATED_BLOCK_BEHIND", default=24 * 60 * 60 // 15
) # Number of blocks to consider an address 'almost updated'.

# Safe
# ------------------------------------------------------------------------------
# Number of blocks from the current block number needed to consider a transaction valid/stable
ETH_REORG_BLOCKS = env.int(
"ETH_REORG_BLOCKS", default=100 if ETH_L2_NETWORK else 10
) # L2 Networks have more reorgs
) # Number of blocks from the current block number needed to consider a block valid/stable

# Tokens
# ------------------------------------------------------------------------------
TOKENS_LOGO_BASE_URI = env(
"TOKENS_LOGO_BASE_URI", default="https://gnosis-safe-token-logos.s3.amazonaws.com/"
)
TOKENS_LOGO_EXTENSION = env("TOKENS_LOGO_EXTENSION", default=".png")

# Slack notifications
# Notifications
# ------------------------------------------------------------------------------
SLACK_API_WEBHOOK = env("SLACK_API_WEBHOOK", default=None)

# Notifications
Expand All @@ -430,12 +417,13 @@
)
)

# Percentage of Safes allowed to be out of sync without alerting. By default 10%
ALERT_OUT_OF_SYNC_EVENTS_THRESHOLD = env.float(
"ALERT_OUT_OF_SYNC_EVENTS_THRESHOLD", default=0.1
)
) # Percentage of Safes allowed to be out of sync without alerting. By default 10%


# AWS S3 https://github.com/etianen/django-s3-storage
# ------------------------------------------------------------------------------
# AWS_QUERYSTRING_AUTH = False # Remove query parameter authentication from generated URLs
AWS_ACCESS_KEY_ID = env("AWS_ACCESS_KEY_ID", default=None)
AWS_S3_PUBLIC_URL = env(
Expand All @@ -450,7 +438,7 @@
)

ETHERSCAN_API_KEY = env("ETHERSCAN_API_KEY", default=None)
IPFS_GATEWAY = env("IPFS_GATEWAY", default="https://cloudflare-ipfs.com/ipfs/")
IPFS_GATEWAY = env("IPFS_GATEWAY", default="https://ipfs.io/ipfs/")

SWAGGER_SETTINGS = {
"SECURITY_DEFINITIONS": {
Expand Down
49 changes: 13 additions & 36 deletions config/settings/local.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import socket

from .base import * # noqa
from .base import env

# GENERAL
# ------------------------------------------------------------------------------
# https://docs.djangoproject.com/en/dev/ref/settings/#debug
DEBUG = env.bool("DEBUG", default=True)
DEBUG = True
# https://docs.djangoproject.com/en/dev/ref/settings/#secret-key
SECRET_KEY = env(
"DJANGO_SECRET_KEY",
Expand All @@ -15,27 +13,24 @@
# https://docs.djangoproject.com/en/dev/ref/settings/#allowed-hosts
ALLOWED_HOSTS = env.list("DJANGO_ALLOWED_HOSTS", default=["*"])

REDIS_URL = env.str("REDIS_URL")

# CACHES
# ------------------------------------------------------------------------------
# https://docs.djangoproject.com/en/dev/ref/settings/#caches
CACHES = {
"default": {
"BACKEND": "django.core.cache.backends.locmem.LocMemCache",
"LOCATION": "",
"BACKEND": "django_redis.cache.RedisCache",
"LOCATION": REDIS_URL,
"OPTIONS": {
"CLIENT_CLASS": "django_redis.client.DefaultClient",
# Mimicing memcache behavior.
# http://niwinz.github.io/django-redis/latest/#_memcached_exceptions_behavior
"IGNORE_EXCEPTIONS": True,
},
}
}

# EMAIL
# ------------------------------------------------------------------------------
# https://docs.djangoproject.com/en/dev/ref/settings/#email-backend
EMAIL_BACKEND = env(
"DJANGO_EMAIL_BACKEND", default="django.core.mail.backends.console.EmailBackend"
)
# https://docs.djangoproject.com/en/dev/ref/settings/#email-host
EMAIL_HOST = "localhost"
# https://docs.djangoproject.com/en/dev/ref/settings/#email-port
EMAIL_PORT = 1025

# django-debug-toolbar
# ------------------------------------------------------------------------------
# https://django-debug-toolbar.readthedocs.io/en/latest/installation.html#prerequisites
Expand All @@ -56,24 +51,6 @@
# https://django-debug-toolbar.readthedocs.io/en/latest/installation.html#internal-ips
INTERNAL_IPS = ["127.0.0.1", "10.0.2.2"]

# Celery
# CELERY
# ------------------------------------------------------------------------------
# http://docs.celeryproject.org/en/latest/userguide/configuration.html#std:setting-task_always_eager
CELERY_ALWAYS_EAGER = False

if env.bool("USE_DOCKER", default=False):
hostname, _, ips = socket.gethostbyname_ex(socket.gethostname())
INTERNAL_IPS += [ip[:-1] + "1" for ip in ips]

CACHES = {
"default": {
"BACKEND": "django_redis.cache.RedisCache",
"LOCATION": env("REDIS_URL"),
"OPTIONS": {
"CLIENT_CLASS": "django_redis.client.DefaultClient",
# Mimicing memcache behavior.
# http://niwinz.github.io/django-redis/latest/#_memcached_exceptions_behavior
"IGNORE_EXCEPTIONS": True,
},
}
}
CELERY_RESULT_BACKEND = env("CELERY_RESULT_BACKEND", default=REDIS_URL)
60 changes: 5 additions & 55 deletions config/settings/production.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,39 +30,12 @@
}
}

CELERY_RESULT_BACKEND = env("CELERY_RESULT_BACKEND", default=REDIS_URL)
# SECURITY
# ------------------------------------------------------------------------------
# https://docs.djangoproject.com/en/dev/ref/settings/#secure-proxy-ssl-header
SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https")
# https://docs.djangoproject.com/en/dev/ref/settings/#secure-ssl-redirect
SECURE_SSL_REDIRECT = env.bool("DJANGO_SECURE_SSL_REDIRECT", default=False)
# https://docs.djangoproject.com/en/dev/ref/settings/#session-cookie-secure
SESSION_COOKIE_SECURE = True
# https://docs.djangoproject.com/en/dev/ref/settings/#session-cookie-httponly
SESSION_COOKIE_HTTPONLY = True
# https://docs.djangoproject.com/en/dev/ref/settings/#csrf-cookie-secure
CSRF_COOKIE_SECURE = True
# https://docs.djangoproject.com/en/dev/ref/settings/#csrf-cookie-httponly
CSRF_COOKIE_HTTPONLY = True
# https://docs.djangoproject.com/en/dev/topics/security/#ssl-https
# https://docs.djangoproject.com/en/dev/ref/settings/#secure-hsts-seconds
# TODO: set this to 60 seconds first and then to 518400 once you prove the former works
SECURE_HSTS_SECONDS = 60
# https://docs.djangoproject.com/en/dev/ref/settings/#secure-hsts-include-subdomains
SECURE_HSTS_INCLUDE_SUBDOMAINS = env.bool(
"DJANGO_SECURE_HSTS_INCLUDE_SUBDOMAINS", default=True
)
# https://docs.djangoproject.com/en/dev/ref/settings/#secure-hsts-preload
SECURE_HSTS_PRELOAD = env.bool("DJANGO_SECURE_HSTS_PRELOAD", default=True)
# https://docs.djangoproject.com/en/dev/ref/middleware/#x-content-type-options-nosniff
SECURE_CONTENT_TYPE_NOSNIFF = env.bool(
"DJANGO_SECURE_CONTENT_TYPE_NOSNIFF", default=True
)
# https://docs.djangoproject.com/en/dev/ref/settings/#secure-browser-xss-filter
SECURE_BROWSER_XSS_FILTER = True
# https://docs.djangoproject.com/en/dev/ref/settings/#x-frame-options
X_FRAME_OPTIONS = "DENY"
# https://docs.djangoproject.com/en/3.2/ref/settings/#csrf-trusted-origins
CSRF_TRUSTED_ORIGINS = env.list("CSRF_TRUSTED_ORIGINS", default=[])

Expand All @@ -85,40 +58,17 @@
# "django.contrib.auth.backends.ModelBackend",
]
# When creating a user, give superuser permissions if username is in SSO_ADMIN
SSO_ADMINS = env.list("SSO_ADMINS", default=["richard", "uxio.fuentefria"])

# TEMPLATES
# ------------------------------------------------------------------------------
# https://docs.djangoproject.com/en/dev/ref/settings/#templates
TEMPLATES[0]["OPTIONS"]["loaders"] = [ # noqa F405
(
"django.template.loaders.cached.Loader",
[
"django.template.loaders.filesystem.Loader",
"django.template.loaders.app_directories.Loader",
],
),
]

# EMAIL
# ------------------------------------------------------------------------------
# https://docs.djangoproject.com/en/dev/ref/settings/#default-from-email
DEFAULT_FROM_EMAIL = env(
"DJANGO_DEFAULT_FROM_EMAIL",
default="Gnosis Safe Transaction Service <noreply@gnosis.pm>",
)
# https://docs.djangoproject.com/en/dev/ref/settings/#server-email
SERVER_EMAIL = env("DJANGO_SERVER_EMAIL", default=DEFAULT_FROM_EMAIL)
# https://docs.djangoproject.com/en/dev/ref/settings/#email-subject-prefix
EMAIL_SUBJECT_PREFIX = env(
"DJANGO_EMAIL_SUBJECT_PREFIX", default="[Gnosis Safe Push Service]"
)
SSO_ADMINS = env.list("SSO_ADMINS", default=["richard", "uxio"])

# ADMIN
# ------------------------------------------------------------------------------
# Django Admin URL regex.
ADMIN_URL = env("DJANGO_ADMIN_URL", default="admin/")

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

# Gunicorn
# ------------------------------------------------------------------------------
INSTALLED_APPS += ["gunicorn"] # noqa F405
9 changes: 0 additions & 9 deletions config/settings/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,6 @@
# https://docs.djangoproject.com/en/dev/ref/settings/#password-hashers
PASSWORD_HASHERS = ["django.contrib.auth.hashers.MD5PasswordHasher"]

# EMAIL
# ------------------------------------------------------------------------------
# https://docs.djangoproject.com/en/dev/ref/settings/#email-backend
EMAIL_BACKEND = "django.core.mail.backends.locmem.EmailBackend"
# https://docs.djangoproject.com/en/dev/ref/settings/#email-host
EMAIL_HOST = "localhost"
# https://docs.djangoproject.com/en/dev/ref/settings/#email-port
EMAIL_PORT = 1025

# CELERY
CELERY_ALWAYS_EAGER = True

Expand Down

0 comments on commit 4b3d687

Please sign in to comment.