Skip to content

Commit

Permalink
Adds handling for POA middleware without env var. (#1007)
Browse files Browse the repository at this point in the history
  • Loading branch information
calina-c authored Apr 7, 2023
1 parent 37d7e1e commit e313e77
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 10 deletions.
1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ ENV AQUARIUS_BIND_URL='http://0.0.0.0:5000'
ENV ALLOW_FREE_ASSETS_ONLY='false'
# docker-entrypoint.sh configuration file variables
ENV AQUARIUS_WORKERS='8'
ENV USE_POA_MIDDLEWARE='1'
ENV EVENTS_ALLOW=''
ENV RUN_EVENTS_MONITOR='1'
#ENV ASSET_PURGATORY_URL="https://raw.githubusercontent.com/oceanprotocol/list-purgatory/main/list-assets.json"
Expand Down
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,6 @@ METADATA_CONTRACT_ADDRESS
# The block number of `Metadata` contract deployment
METADATA_CONTRACT_BLOCK

# Enable the use of poa_middleware if the network is a POA network such as Rinkeby. (no need to set for rinkeby specifically, since that is already treated in the code, but any other POA network should have this flag setup)
USE_POA_MIDDLEWARE

# if set to 1, read events from the first Metadata and BFactory block number, or a specific block number (used for debugging)
IGNORE_LAST_BLOCK

Expand Down
10 changes: 4 additions & 6 deletions aquarius/events/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
from pathlib import Path

from web3 import Web3
from web3.exceptions import ExtraDataLengthError

import addresses
from aquarius.app.util import get_bool_env_value
from aquarius.events.http_provider import get_web3_connection_provider
from web3.logs import DISCARD

Expand Down Expand Up @@ -266,11 +266,9 @@ def setup_web3(_logger=None):
provider = get_web3_connection_provider(network_rpc)
web3 = Web3(provider)

if (
get_bool_env_value("USE_POA_MIDDLEWARE", 0)
or get_network_name().lower() == "rinkeby"
or get_network_name().lower() == "mumbai"
):
try:
web3.eth.get_block("latest")
except ExtraDataLengthError:
from web3.middleware import geth_poa_middleware

web3.middleware_onion.inject(geth_poa_middleware, layer=0)
Expand Down

0 comments on commit e313e77

Please sign in to comment.