-
Notifications
You must be signed in to change notification settings - Fork 1
Add Arbitrum and BNB Smart Chain #28
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| __pycache__ | ||
| .ruff_cache | ||
|
|
||
| .vercel | ||
| *.vercel | ||
|
|
@@ -11,4 +12,4 @@ venv | |
|
|
||
| api/test | ||
| endpoints*.json | ||
| endpoints | ||
| endpoints | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| from common.metrics_handler import BaseVercelHandler, MetricsHandler | ||
| from config.defaults import MetricsServiceConfig | ||
| from metrics.arbitrum import ( | ||
| HTTPAccBalanceLatencyMetric, | ||
| HTTPBlockNumberLatencyMetric, | ||
| HTTPDebugTraceBlockByNumberLatencyMetric, | ||
| HTTPDebugTraceTxLatencyMetric, | ||
| HTTPEthCallLatencyMetric, | ||
| HTTPTxReceiptLatencyMetric, | ||
| ) | ||
| from metrics.ethereum import ( | ||
| WSBlockLatencyMetric, | ||
| ) | ||
|
|
||
| metric_name = f"{MetricsServiceConfig.METRIC_PREFIX}response_latency_seconds" | ||
|
|
||
| METRICS = [ | ||
| (WSBlockLatencyMetric, metric_name), | ||
| (HTTPBlockNumberLatencyMetric, metric_name), | ||
| (HTTPEthCallLatencyMetric, metric_name), | ||
| (HTTPAccBalanceLatencyMetric, metric_name), | ||
| (HTTPDebugTraceBlockByNumberLatencyMetric, metric_name), | ||
| (HTTPDebugTraceTxLatencyMetric, metric_name), | ||
| (HTTPTxReceiptLatencyMetric, metric_name), | ||
| ] | ||
|
|
||
|
|
||
| class handler(BaseVercelHandler): | ||
| metrics_handler = MetricsHandler("Arbitrum", METRICS) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| from common.metrics_handler import BaseVercelHandler, MetricsHandler | ||
| from config.defaults import MetricsServiceConfig | ||
| from metrics.bnbsc import ( | ||
| HTTPAccBalanceLatencyMetric, | ||
| HTTPBlockNumberLatencyMetric, | ||
| HTTPDebugTraceBlockByNumberLatencyMetric, | ||
| HTTPDebugTraceTxLatencyMetric, | ||
| HTTPEthCallLatencyMetric, | ||
| HTTPTxReceiptLatencyMetric, | ||
| ) | ||
| from metrics.ethereum import ( | ||
| WSBlockLatencyMetric, | ||
| ) | ||
|
|
||
| metric_name = f"{MetricsServiceConfig.METRIC_PREFIX}response_latency_seconds" | ||
|
|
||
| METRICS = [ | ||
| (WSBlockLatencyMetric, metric_name), | ||
| (HTTPBlockNumberLatencyMetric, metric_name), | ||
| (HTTPEthCallLatencyMetric, metric_name), | ||
| (HTTPAccBalanceLatencyMetric, metric_name), | ||
| (HTTPDebugTraceBlockByNumberLatencyMetric, metric_name), | ||
| (HTTPDebugTraceTxLatencyMetric, metric_name), | ||
| (HTTPTxReceiptLatencyMetric, metric_name), | ||
| ] | ||
|
|
||
|
|
||
| class handler(BaseVercelHandler): | ||
| metrics_handler = MetricsHandler("BNB Smart Chain", METRICS) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| """Base EVM metrics implementation for HTTP endpoints.""" | ||
|
|
||
| from common.metric_types import HttpCallLatencyMetricBase | ||
|
|
||
|
|
||
| class HTTPEthCallLatencyMetric(HttpCallLatencyMetricBase): | ||
| """Collects response time for eth_call simulation.""" | ||
|
|
||
| @property | ||
| def method(self) -> str: | ||
| return "eth_call" | ||
|
|
||
| @staticmethod | ||
| def get_params_from_state(state_data: dict) -> list: | ||
| """Get eth_call parameters for Aave Pool Addresses Provider query.""" | ||
| return [ | ||
| { | ||
| "to": "0xa97684ead0e402dC232d5A977953DF7ECBaB3CDb", | ||
| "data": "0x026b1d5f0000000000000000000000000000000000000000000000000000000000000000", | ||
| }, | ||
| "latest", | ||
| ] | ||
|
|
||
|
|
||
| class HTTPTxReceiptLatencyMetric(HttpCallLatencyMetricBase): | ||
| """Collects latency for transaction receipt retrieval.""" | ||
|
|
||
| @property | ||
| def method(self) -> str: | ||
| return "eth_getTransactionReceipt" | ||
|
|
||
| @staticmethod | ||
| def validate_state(state_data: dict) -> bool: | ||
| """Validate blockchain state contains transaction hash.""" | ||
| return bool(state_data and state_data.get("tx")) | ||
|
|
||
| @staticmethod | ||
| def get_params_from_state(state_data: dict) -> list: | ||
| """Get parameters using transaction hash from state.""" | ||
| return [state_data["tx"]] | ||
|
|
||
|
|
||
| class HTTPAccBalanceLatencyMetric(HttpCallLatencyMetricBase): | ||
| """Collects latency for account balance queries.""" | ||
|
|
||
| @property | ||
| def method(self) -> str: | ||
| return "eth_getBalance" | ||
|
|
||
| @staticmethod | ||
| def validate_state(state_data: dict) -> bool: | ||
| """Validates that required block number (hex) exists in state data.""" | ||
| return bool(state_data and state_data.get("old_block")) | ||
|
|
||
| @staticmethod | ||
| def get_params_from_state(state_data: dict) -> list: | ||
| """Get parameters with fixed monitoring address.""" | ||
| return ["0x794a61358D6845594F94dc1DB02A252b5b4814aD", state_data["old_block"]] | ||
|
|
||
|
|
||
| class HTTPDebugTraceTxLatencyMetric(HttpCallLatencyMetricBase): | ||
| """Collects latency for transaction tracing.""" | ||
|
|
||
| @property | ||
| def method(self) -> str: | ||
| return "debug_traceTransaction" | ||
|
|
||
| @staticmethod | ||
| def validate_state(state_data: dict) -> bool: | ||
| """Validate blockchain state contains transaction hash.""" | ||
| return bool(state_data and state_data.get("tx")) | ||
|
|
||
| @staticmethod | ||
| def get_params_from_state(state_data: dict) -> list: | ||
| """Get parameters using transaction hash from state.""" | ||
| return [state_data["tx"], {"tracer": "callTracer"}] | ||
|
|
||
|
|
||
| class HTTPDebugTraceBlockByNumberLatencyMetric(HttpCallLatencyMetricBase): | ||
| """Collects call latency for the `debug_traceBlockByNumber` method.""" | ||
|
|
||
| @property | ||
| def method(self) -> str: | ||
| return "debug_traceBlockByNumber" | ||
|
|
||
| @staticmethod | ||
| def get_params_from_state(state_data: dict) -> list: | ||
| """Get fixed parameters for latest block tracing.""" | ||
| return ["latest", {"tracer": "callTracer"}] | ||
|
|
||
|
|
||
| class HTTPBlockNumberLatencyMetric(HttpCallLatencyMetricBase): | ||
| """Collects call latency for the `eth_blockNumber` method.""" | ||
|
|
||
| @property | ||
| def method(self) -> str: | ||
| return "eth_blockNumber" | ||
|
|
||
| @staticmethod | ||
| def get_params_from_state(state_data: dict) -> list: | ||
| """Get empty parameter list for block number query.""" | ||
| return [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| """Base EVM metrics implementation for HTTP endpoints.""" | ||
|
|
||
| from common.metric_types import HttpCallLatencyMetricBase | ||
|
|
||
|
|
||
| class HTTPEthCallLatencyMetric(HttpCallLatencyMetricBase): | ||
| """Collects response time for eth_call simulation.""" | ||
|
|
||
| @property | ||
| def method(self) -> str: | ||
| return "eth_call" | ||
|
|
||
| @staticmethod | ||
| def get_params_from_state(state_data: dict) -> list: | ||
| """Get eth_call parameters for Aave Pool Addresses Provider query.""" | ||
| return [ | ||
| { | ||
| "to": "0xff75B6da14FfbbfD355Daf7a2731456b3562Ba6D", | ||
| "data": "0x026b1d5f0000000000000000000000000000000000000000000000000000000000000000", | ||
| }, | ||
| "latest", | ||
| ] | ||
|
|
||
|
|
||
| class HTTPTxReceiptLatencyMetric(HttpCallLatencyMetricBase): | ||
| """Collects latency for transaction receipt retrieval.""" | ||
|
|
||
| @property | ||
| def method(self) -> str: | ||
| return "eth_getTransactionReceipt" | ||
|
|
||
| @staticmethod | ||
| def validate_state(state_data: dict) -> bool: | ||
| """Validate blockchain state contains transaction hash.""" | ||
| return bool(state_data and state_data.get("tx")) | ||
|
|
||
| @staticmethod | ||
| def get_params_from_state(state_data: dict) -> list: | ||
| """Get parameters using transaction hash from state.""" | ||
| return [state_data["tx"]] | ||
|
|
||
|
|
||
| class HTTPAccBalanceLatencyMetric(HttpCallLatencyMetricBase): | ||
| """Collects latency for account balance queries.""" | ||
|
|
||
| @property | ||
| def method(self) -> str: | ||
| return "eth_getBalance" | ||
|
|
||
| @staticmethod | ||
| def validate_state(state_data: dict) -> bool: | ||
| """Validates that required block number (hex) exists in state data.""" | ||
| return bool(state_data and state_data.get("old_block")) | ||
|
|
||
| @staticmethod | ||
| def get_params_from_state(state_data: dict) -> list: | ||
| """Get parameters with fixed monitoring address.""" | ||
| return ["0x6807dc923806fE8Fd134338EABCA509979a7e0cB", state_data["old_block"]] | ||
|
|
||
|
|
||
| class HTTPDebugTraceTxLatencyMetric(HttpCallLatencyMetricBase): | ||
| """Collects latency for transaction tracing.""" | ||
|
|
||
| @property | ||
| def method(self) -> str: | ||
| return "debug_traceTransaction" | ||
|
|
||
| @staticmethod | ||
| def validate_state(state_data: dict) -> bool: | ||
| """Validate blockchain state contains transaction hash.""" | ||
| return bool(state_data and state_data.get("tx")) | ||
|
|
||
| @staticmethod | ||
| def get_params_from_state(state_data: dict) -> list: | ||
| """Get parameters using transaction hash from state.""" | ||
| return [state_data["tx"], {"tracer": "callTracer"}] | ||
|
|
||
|
|
||
| class HTTPDebugTraceBlockByNumberLatencyMetric(HttpCallLatencyMetricBase): | ||
| """Collects call latency for the `debug_traceBlockByNumber` method.""" | ||
|
|
||
| @property | ||
| def method(self) -> str: | ||
| return "debug_traceBlockByNumber" | ||
|
|
||
| @staticmethod | ||
| def get_params_from_state(state_data: dict) -> list: | ||
| """Get fixed parameters for latest block tracing.""" | ||
| return ["latest", {"tracer": "callTracer"}] | ||
|
|
||
|
|
||
| class HTTPBlockNumberLatencyMetric(HttpCallLatencyMetricBase): | ||
| """Collects call latency for the `eth_blockNumber` method.""" | ||
|
|
||
| @property | ||
| def method(self) -> str: | ||
| return "eth_blockNumber" | ||
|
|
||
| @staticmethod | ||
| def get_params_from_state(state_data: dict) -> list: | ||
| """Get empty parameter list for block number query.""" | ||
| return [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.