Skip to content

Commit

Permalink
Fix recursion (#292)
Browse files Browse the repository at this point in the history
* Fix recursion

* Remove metrics from onchain web3
  • Loading branch information
hweawer authored Dec 10, 2024
1 parent e2694eb commit f8c3d56
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 6 deletions.
3 changes: 0 additions & 3 deletions src/blockchain/web3_extentions/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ def add_requests_metric_middleware(web3: Web3) -> Web3:

def metrics_collector(make_request: Callable[[RPCEndpoint, Any], RPCResponse], w3: Web3) -> Callable[[RPCEndpoint, Any], RPCResponse]:
"""Constructs a middleware which measure requests parameters"""
chain_id = w3.eth.chain_id

def middleware(method: RPCEndpoint, params: Any) -> RPCResponse:
try:
Expand All @@ -33,7 +32,6 @@ def middleware(method: RPCEndpoint, params: Any) -> RPCResponse:
method=method,
code=failed.status_code,
domain=urlparse(web3.provider.endpoint_uri).netloc, # pyright: ignore
chain_id=chain_id,
).inc()
raise

Expand All @@ -48,7 +46,6 @@ def middleware(method: RPCEndpoint, params: Any) -> RPCResponse:
method=method,
code=code,
domain=urlparse(web3.provider.endpoint_uri).netloc, # pyright: ignore
chain_id=chain_id,
).inc()
return response

Expand Down
2 changes: 1 addition & 1 deletion src/metrics/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
ETH_RPC_REQUESTS = Counter(
'eth_rpc_requests',
'Total count of requests to ETH1 RPC',
['method', 'code', 'domain', 'chain_id'],
['method', 'code', 'domain'],
namespace=PROMETHEUS_PREFIX,
)

Expand Down
4 changes: 2 additions & 2 deletions src/transport/msg_providers/onchain_transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from typing import Callable, List, Optional

import variables
from blockchain.web3_extentions.middleware import add_cache_middleware, add_requests_metric_middleware
from blockchain.web3_extentions.middleware import add_cache_middleware
from eth_typing import ChecksumAddress
from eth_utils import to_bytes
from schema import Schema
Expand Down Expand Up @@ -326,4 +326,4 @@ def _parse_log(self, log: LogReceipt) -> Optional[dict]:

@staticmethod
def create_ochain_transport_w3() -> Web3:
return add_requests_metric_middleware(add_cache_middleware(Web3(FallbackProvider(variables.ONCHAIN_TRANSPORT_RPC_ENDPOINTS))))
return add_cache_middleware(Web3(FallbackProvider(variables.ONCHAIN_TRANSPORT_RPC_ENDPOINTS)))

0 comments on commit f8c3d56

Please sign in to comment.