Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update safe #3

Open
wants to merge 568 commits into
base: astra
Choose a base branch
from
Open

update safe #3

wants to merge 568 commits into from

Conversation

hoanguyenkh
Copy link
Collaborator

Make sure these boxes are checked! 📦✅

  • 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 and check network name
    exists in safe-eth-py

What was wrong? 👾

Closes #

How was it fixed? 🎯

moisses89 and others added 26 commits July 21, 2023 10:40
- For some tasks we use Redis Locks to prevent 2 celery workers executing the same task
- Previously, we waited 1 second to get the Lock (in case it was taken) before failing
- During that second, every 0.1 second the Lock was checked again
- So every time a Lock was taken 10 queries were done to Redis, instead of 1
- With the new solution Lock will return inmediately if the Lock is taken
- Closes #439
- Refactor gunicorn configuration to be set via envvar
Bumps [drf-yasg[validation]](https://github.com/axnsan12/drf-yasg) from 1.21.5 to 1.21.7.
- [Release notes](https://github.com/axnsan12/drf-yasg/releases)
- [Changelog](https://github.com/axnsan12/drf-yasg/blob/master/docs/changelog.rst)
- [Commits](axnsan12/drf-yasg@1.21.5...1.21.7)

---
updated-dependencies:
- dependency-name: drf-yasg[validation]
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [django-cors-headers](https://github.com/adamchainz/django-cors-headers) from 4.1.0 to 4.2.0.
- [Changelog](https://github.com/adamchainz/django-cors-headers/blob/main/CHANGELOG.rst)
- [Commits](adamchainz/django-cors-headers@4.1.0...4.2.0)

---
updated-dependencies:
- dependency-name: django-cors-headers
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [web3](https://github.com/ethereum/web3.py) from 6.5.0 to 6.6.1.
- [Release notes](https://github.com/ethereum/web3.py/releases)
- [Changelog](https://github.com/ethereum/web3.py/blob/main/docs/releases.rst)
- [Commits](ethereum/web3.py@v6.5.0...v6.6.1)

---
updated-dependencies:
- dependency-name: web3
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [factory-boy](https://github.com/FactoryBoy/factory_boy) from 3.2.1 to 3.3.0.
- [Changelog](https://github.com/FactoryBoy/factory_boy/blob/master/docs/changelog.rst)
- [Commits](FactoryBoy/factory_boy@3.2.1...3.3.0)

---
updated-dependencies:
- dependency-name: factory-boy
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
- Tx decoder could take a few minutes to be loaded
- Before it was done by the first query that reached the tx service
- If there were multiple concurrent queries, tx service will be doing the computation multiple times, even if just one will be used for the cache
- Add logging to `get_redis` to find out if the same could be happening
- Remove distinct from `ModuleTransaction`, as every `ModuleTransaction` is showed separated even if they share the same `ethereum txHash`
- Clean transaction_service, adding comments, renaming variables and refactoring typing
- Add logging to service and view
- Rename gevent variable for task locks (not very descriptive)
- Some links pointing to the old Safe Dev Docs were updated
- A link pointing to the old Safe Service Client package was updated to point to the Safe{Core} SDK API Kit
Bumps [faker](https://github.com/joke2k/faker) from 19.1.0 to 19.2.0.
- [Release notes](https://github.com/joke2k/faker/releases)
- [Changelog](https://github.com/joke2k/faker/blob/master/CHANGELOG.md)
- [Commits](joke2k/faker@v19.1.0...v19.2.0)

---
updated-dependencies:
- dependency-name: faker
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [web3](https://github.com/ethereum/web3.py) from 6.6.1 to 6.7.0.
- [Release notes](https://github.com/ethereum/web3.py/releases)
- [Changelog](https://github.com/ethereum/web3.py/blob/main/docs/releases.rst)
- [Commits](ethereum/web3.py@v6.6.1...v6.7.0)

---
updated-dependencies:
- dependency-name: web3
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [boto3](https://github.com/boto/boto3) from 1.26.151 to 1.28.15.
- [Release notes](https://github.com/boto/boto3/releases)
- [Changelog](https://github.com/boto/boto3/blob/develop/CHANGELOG.rst)
- [Commits](boto/boto3@1.26.151...1.28.15)

---
updated-dependencies:
- dependency-name: boto3
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [gunicorn[gevent]](https://github.com/benoitc/gunicorn) from 20.1.0 to 21.2.0.
- [Release notes](https://github.com/benoitc/gunicorn/releases)
- [Commits](benoitc/gunicorn@20.1.0...21.2.0)

---
updated-dependencies:
- dependency-name: gunicorn[gevent]
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
- Use official github action
Bumps [web3](https://github.com/ethereum/web3.py) from 6.7.0 to 6.8.0.
- [Release notes](https://github.com/ethereum/web3.py/releases)
- [Changelog](https://github.com/ethereum/web3.py/blob/main/docs/releases.rst)
- [Commits](ethereum/web3.py@v6.7.0...v6.8.0)

---
updated-dependencies:
- dependency-name: web3
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [django](https://github.com/django/django) from 4.2.3 to 4.2.4.
- [Commits](django/django@4.2.3...4.2.4)

---
updated-dependencies:
- dependency-name: django
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
dependabot bot and others added 29 commits February 8, 2024 10:36
Bumps [django](https://github.com/django/django) from 4.2.7 to 4.2.10.
- [Commits](django/django@4.2.7...4.2.10)

---
updated-dependencies:
- dependency-name: django
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
- Add Felipe to CLA allowlist
Bumps [pytest-django](https://github.com/pytest-dev/pytest-django) from 4.7.0 to 4.8.0.
- [Release notes](https://github.com/pytest-dev/pytest-django/releases)
- [Changelog](https://github.com/pytest-dev/pytest-django/blob/master/docs/changelog.rst)
- [Commits](pytest-dev/pytest-django@v4.7.0...v4.8.0)

---
updated-dependencies:
- dependency-name: pytest-django
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [web3](https://github.com/ethereum/web3.py) from 6.15.0 to 6.15.1.
- [Changelog](https://github.com/ethereum/web3.py/blob/v6.15.1/docs/releases.rst)
- [Commits](ethereum/web3.py@v6.15.0...v6.15.1)

---
updated-dependencies:
- dependency-name: web3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [faker](https://github.com/joke2k/faker) from 22.6.0 to 23.1.0.
- [Release notes](https://github.com/joke2k/faker/releases)
- [Changelog](https://github.com/joke2k/faker/blob/master/CHANGELOG.md)
- [Commits](joke2k/faker@v22.6.0...v23.1.0)

---
updated-dependencies:
- dependency-name: faker
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [faker](https://github.com/joke2k/faker) from 23.1.0 to 23.2.1.
- [Release notes](https://github.com/joke2k/faker/releases)
- [Changelog](https://github.com/joke2k/faker/blob/master/CHANGELOG.md)
- [Commits](joke2k/faker@v23.1.0...v23.2.1)

---
updated-dependencies:
- dependency-name: faker
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [boto3](https://github.com/boto/boto3) from 1.34.34 to 1.34.44.
- [Release notes](https://github.com/boto/boto3/releases)
- [Changelog](https://github.com/boto/boto3/blob/develop/CHANGELOG.rst)
- [Commits](boto/boto3@1.34.34...1.34.44)

---
updated-dependencies:
- dependency-name: boto3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [safe-eth-py[django]](https://github.com/safe-global/safe-eth-py) from 6.0.0b15 to 6.0.0b16.
- [Release notes](https://github.com/safe-global/safe-eth-py/releases)
- [Commits](safe-global/safe-eth-py@v6.0.0b15...v6.0.0b16)

---
updated-dependencies:
- dependency-name: safe-eth-py[django]
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
* Fix slow query when getting threshold for multisig-transactions

- Getting the threshold for executed transactions was slow, as sorting was done using multiple tables.
- Sorting was optimized to use the `internal_tx_id`. As traces are inserted in order and atomically, that should do it, otherwise is not a critical error.
- A index was created to optimize `MultisigTransaction` retrieval.

Another solution would be to use a Window function, but performance now is quite good.

Query went from

```sql
 Limit  (cost=2161.92..23561.22 rows=21 width=1993) (actual time=24695.459..29421.259 rows=21 loops=1)
   ->  Result  (cost=2161.92..83326974.35 rows=81770 width=1993) (actual time=24695.458..29421.247 rows=21 loops=1)
         ->  Incremental Sort  (cost=2161.92..8347228.91 rows=81770 width=1952) (actual time=177.971..177.991 rows=21 loops=1)
               Sort Key: history_multisigtransaction.nonce DESC, history_multisigtransaction.created DESC
               Presorted Key: history_multisigtransaction.nonce
               Full-sort Groups: 1  Sort Method: quicksort  Average Memory: 98kB  Peak Memory: 98kB
               ->  Nested Loop Left Join  (cost=1.42..8342967.85 rows=81770 width=1952) (actual time=13.972..177.805 rows=22 loops=1)
                     ->  Nested Loop Left Join  (cost=0.99..7839429.23 rows=81770 width=1862) (actual time=10.742..117.670 rows=22 loops=1)
                           ->  Index Scan Backward using history_multisigtransaction_nonce_a98eecaa on history_multisigtransaction  (cost=0.43..7227223.48 rows=81770 width=380) (actual time=5.918..11.412 rows=22 loops=1)
                                 Filter: (safe = '\xXXXXXXXXXXXXXXXXXXXXXX'::bytea)
                                 Rows Removed by Filter: 3
                           ->  Index Scan using history_ethereumtx_pkey on history_ethereumtx  (cost=0.56..7.49 rows=1 width=1482) (actual time=4.827..4.827 rows=1 loops=22)
                                 Index Cond: (tx_hash = history_multisigtransaction.ethereum_tx_id)
                     ->  Index Scan using history_ethereumblock_pkey on history_ethereumblock  (cost=0.43..6.16 rows=1 width=90) (actual time=2.730..2.730 rows=1 loops=22)
                           Index Cond: (number = history_ethereumtx.block_id)
         SubPlan 1
           ->  Limit  (cost=0.42..8.44 rows=1 width=5) (never executed)
                 ->  Index Scan using history_safelaststatus_pkey on history_safelaststatus u0  (cost=0.42..8.44 rows=1 width=5) (never executed)
                       Index Cond: (address = history_multisigtransaction.safe)
         SubPlan 2
           ->  Limit  (cost=606.17..908.51 rows=1 width=46) (actual time=1392.528..1392.528 rows=1 loops=21)
                 ->  Incremental Sort  (cost=606.17..1210.85 rows=2 width=46) (actual time=1392.526..1392.526 rows=1 loops=21)
                       Sort Key: u0_1.nonce, u1.block_number, u2.transaction_index, u0_1.internal_tx_id
                       Presorted Key: u0_1.nonce
                       Full-sort Groups: 21  Sort Method: quicksort  Average Memory: 25kB  Peak Memory: 25kB
                       ->  Nested Loop  (cost=1.55..1210.76 rows=1 width=46) (actual time=1392.407..1392.497 rows=1 loops=21)
                             ->  Nested Loop  (cost=0.99..1202.18 rows=1 width=75) (actual time=1392.254..1392.343 rows=1 loops=21)
                                   ->  Index Scan Backward using history_saf_address_aa71bd_idx on history_safestatus u0_1  (cost=0.56..390.22 rows=96 width=38) (actual time=0.378..182.739 rows=83301 loops=21)
                                         Index Cond: (address = history_multisigtransaction.safe)
                                   ->  Index Scan using history_internaltx_pkey on history_internaltx u1  (cost=0.44..8.46 rows=1 width=45) (actual time=0.014..0.014 rows=0 loops=1749321)
                                         Index Cond: (id = u0_1.internal_tx_id)
                                         Filter: (ethereum_tx_id = history_multisigtransaction.ethereum_tx_id)
                                         Rows Removed by Filter: 1
                             ->  Index Scan using history_ethereumtx_pkey on history_ethereumtx u2  (cost=0.56..8.57 rows=1 width=37) (actual time=0.150..0.150 rows=1 loops=21)
                                   Index Cond: (tx_hash = history_multisigtransaction.ethereum_tx_id)
 Planning Time: 84.834 ms
 Execution Time: 29421.447 ms
(37 rows)
```

to

```sql
 Limit  (cost=2161.92..4662.61 rows=21 width=1993) (actual time=0.377..0.485 rows=21 loops=1)
   ->  Result  (cost=2161.92..9739363.16 rows=81770 width=1993) (actual time=0.376..0.481 rows=21 loops=1)
         ->  Incremental Sort  (cost=2161.92..8347228.91 rows=81770 width=1952) (actual time=0.348..0.350 rows=21 loops=1)
               Sort Key: history_multisigtransaction.nonce DESC, history_multisigtransaction.created DESC
               Presorted Key: history_multisigtransaction.nonce
               Full-sort Groups: 1  Sort Method: quicksort  Average Memory: 98kB  Peak Memory: 98kB
               ->  Nested Loop Left Join  (cost=1.42..8342967.85 rows=81770 width=1952) (actual time=0.041..0.287 rows=22 loops=1)
                     ->  Nested Loop Left Join  (cost=0.99..7839429.23 rows=81770 width=1862) (actual time=0.032..0.213 rows=22 loops=1)
                           ->  Index Scan Backward using history_multisigtransaction_nonce_a98eecaa on history_multisigtransaction  (cost=0.43..7227223.48 rows=81770 width=380) (actual time=0.017..0.049 rows=22 loops=1)
                                 Filter: (safe = '\xXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXx'::bytea)
                                 Rows Removed by Filter: 3
                           ->  Index Scan using history_ethereumtx_pkey on history_ethereumtx  (cost=0.56..7.49 rows=1 width=1482) (actual time=0.007..0.007 rows=1 loops=22)
                                 Index Cond: (tx_hash = history_multisigtransaction.ethereum_tx_id)
                     ->  Index Scan using history_ethereumblock_pkey on history_ethereumblock  (cost=0.43..6.16 rows=1 width=90) (actual time=0.003..0.003 rows=1 loops=22)
                           Index Cond: (number = history_ethereumtx.block_id)
         SubPlan 1
           ->  Limit  (cost=0.42..8.44 rows=1 width=5) (never executed)
                 ->  Index Scan using history_safelaststatus_pkey on history_safelaststatus u0  (cost=0.42..8.44 rows=1 width=5) (never executed)
                       Index Cond: (address = history_multisigtransaction.safe)
         SubPlan 2
           ->  Limit  (cost=0.56..8.57 rows=1 width=13) (actual time=0.005..0.005 rows=1 loops=21)
                 ->  Index Scan Backward using history_saf_address_1c362b_idx on history_safestatus u0_1  (cost=0.56..8.57 rows=1 width=13) (actual time=0.005..0.005 rows=1 loops=21)
                       Index Cond: ((address = history_multisigtransaction.safe) AND (nonce = history_multisigtransaction.nonce))
 Planning Time: 0.577 ms
 Execution Time: 0.580 ms
(25 rows)
```

* Fix tests

---------

Co-authored-by: Uxio Fuentefria <6909403+Uxio0@users.noreply.github.com>
---------

Co-authored-by: Uxío <Uxio0@users.noreply.github.com>
Bumps [coverage](https://github.com/nedbat/coveragepy) from 7.4.1 to 7.4.3.
- [Release notes](https://github.com/nedbat/coveragepy/releases)
- [Changelog](https://github.com/nedbat/coveragepy/blob/master/CHANGES.rst)
- [Commits](nedbat/coveragepy@7.4.1...7.4.3)

---
updated-dependencies:
- dependency-name: coverage
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [pytest-sugar](https://github.com/Teemu/pytest-sugar) from 0.9.7 to 1.0.0.
- [Release notes](https://github.com/Teemu/pytest-sugar/releases)
- [Changelog](https://github.com/Teemu/pytest-sugar/blob/main/CHANGES.rst)
- [Commits](Teemu/pytest-sugar@v0.9.7...v1.0.0)

---
updated-dependencies:
- dependency-name: pytest-sugar
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [django-model-utils](https://github.com/jazzband/django-model-utils) from 4.3.1 to 4.4.0.
- [Release notes](https://github.com/jazzband/django-model-utils/releases)
- [Changelog](https://github.com/jazzband/django-model-utils/blob/master/CHANGES.rst)
- [Commits](jazzband/django-model-utils@4.3.1...4.4.0)

---
updated-dependencies:
- dependency-name: django-model-utils
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [pytest](https://github.com/pytest-dev/pytest) from 8.0.0 to 8.1.0.
- [Release notes](https://github.com/pytest-dev/pytest/releases)
- [Changelog](https://github.com/pytest-dev/pytest/blob/main/CHANGELOG.rst)
- [Commits](pytest-dev/pytest@8.0.0...8.1.0)

---
updated-dependencies:
- dependency-name: pytest
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [cachetools](https://github.com/tkem/cachetools) from 5.3.2 to 5.3.3.
- [Changelog](https://github.com/tkem/cachetools/blob/master/CHANGELOG.rst)
- [Commits](tkem/cachetools@v5.3.2...v5.3.3)

---
updated-dependencies:
- dependency-name: cachetools
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [redis](https://github.com/redis/redis-py) from 5.0.1 to 5.0.2.
- [Release notes](https://github.com/redis/redis-py/releases)
- [Changelog](https://github.com/redis/redis-py/blob/master/CHANGES)
- [Commits](redis/redis-py@v5.0.1...v5.0.2)

---
updated-dependencies:
- dependency-name: redis
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
@Uxio0 Uxio0 deleted the master branch March 5, 2024 13:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants