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

Add new labels: integration_maturity, canonical_name and chain_selector #65

Merged
merged 1 commit into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ local*
# Python
venv
__pycache__
.coverage
7 changes: 5 additions & 2 deletions config/exporter_example/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ blockchain: "Example Chain" # Name of blockchain i.e "Ethereum"
chain_id: 1 # Chain ID, can be found at https://chainlist.org/
network_name: "Example" # Name of the blokckchain network i.e Rinkeby
network_type: "Example" # Type of the blockchain network, only two values allowed (Mainnet|Testnet)
integration_maturity: "development" # Integration Maturity - (production|development)
canonical_name: "example-chain-testnet" # Canonical name as set by BIX
chain_selector: 121212 # CCIP chain selector, use -1 if absent
connection_parameters:
open_timeout: 6 # Timeout when opening websocket connection
close_timeout: 1 # Timeout when closing websocket connection
Expand All @@ -11,7 +14,7 @@ connection_parameters:
collector: "evm" # This will load different collectors based on what mode exporter will run with Supported modes are: "evm", "solana", "conflux", "cardano", "bitcoin"
endpoints: # List of endpoints with their metadata.
- url: wss://example-rpc-1.com/ws # RPC Endpoint websocket endpoint (Must start with wss:// or https://)
provider: Provider1 # Provider (Must be present in allowed providers list. Please check src/settings.py line 24) The purpose is to make sure we do not have same providers spelled differently
provider: Provider1 # Provider (Must be present in allowed providers list. Please check src/settings.py line 24) The purpose is to make sure we do not have same providers spelled differently
- url: wss://example-rpc-2.com/ws
provider: Provider2
- url: wss://example-rpc-3.com/ws
Expand All @@ -25,4 +28,4 @@ endpoints: # List of endpoints with their metadata.



##
##
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pytest==7.2.1
pylint==2.16.2
pylint==3.3.1
coverage==7.1.0
requests==2.28.2
requests_mock==1.10.0
6 changes: 6 additions & 0 deletions src/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ def _load_configuration(self):
And(str),
'network_type':
And(str, lambda s: s in ('Testnet', 'Mainnet')),
'integration_maturity':
And(str, lambda s: s in ('production', 'development')),
'canonical_name':
And(str),
'chain_selector':
And(int),
'collector':
And(str, lambda s: s in supported_collectors),
Optional('connection_parameters'): {
Expand Down
2 changes: 1 addition & 1 deletion src/exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def exporter(environ, start_fn): # pylint: disable=inconsistent-return-statemen
"""Web-server endpoints routing."""
match environ['PATH_INFO']:
case '/metrics':
return metrics_app(environ, start_fn)
return metrics_app(environ, start_fn) # pylint: disable=possibly-used-before-assignment
case _:
return return404(environ, start_fn)

Expand Down
1 change: 1 addition & 0 deletions src/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class MetricsLoader():
def __init__(self):
self._labels = [
'url', 'provider', 'blockchain', 'network_name', 'network_type',
'integration_maturity', 'canonical_name', 'chain_selector',
'evmChainID'
]

Expand Down
11 changes: 8 additions & 3 deletions src/registries.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@
class Endpoint(): # pylint: disable=too-few-public-methods
"""RPC Endpoint class, to store metadata."""

def __init__( # pylint: disable=too-many-arguments
self, url, provider, blockchain, network_name, network_type,
def __init__( # pylint: disable=too-many-arguments,too-many-positional-arguments
self, url, provider, blockchain, network_name, network_type, integration_maturity,
canonical_name, chain_selector,
chain_id, **client_parameters):
self.url = url
self.chain_id = chain_id
self.labels = [
url, provider, blockchain, network_name, network_type,
url, provider, blockchain, network_name, network_type, integration_maturity,
canonical_name, str(chain_selector),
str(chain_id)
]
self.client_parameters = client_parameters
Expand Down Expand Up @@ -50,6 +52,9 @@ def get_endpoint_registry(self) -> list:
self.blockchain,
self.get_property('network_name'),
self.get_property('network_type'),
self.get_property('integration_maturity'),
self.get_property('canonical_name'),
self.get_property('chain_selector'),
self.get_property('chain_id'),
**self.client_parameters))
return endpoints_list
Expand Down
6 changes: 6 additions & 0 deletions src/test_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ def test_configuration_attribute(self):
"TestNetwork",
"network_type":
"Mainnet",
"integration_maturity":
"development",
"canonical_name":
"test-network-mainnet",
"chain_selector":
121212,
"collector":
"evm",
"endpoints": [{
Expand Down
4 changes: 3 additions & 1 deletion src/test_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ class TestMetricsLoader(TestCase):
def setUp(self):
self.metrics_loader = MetricsLoader()
self.labels = [
'url', 'provider', 'blockchain', 'network_name', 'network_type', 'evmChainID'
'url', 'provider', 'blockchain', 'network_name', 'network_type',
'integration_maturity', 'canonical_name', 'chain_selector',
'evmChainID'
]

def test_labels(self):
Expand Down
10 changes: 9 additions & 1 deletion src/test_registries.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,15 @@ def setUp(self):
self.blockchain = "test_chain"
self.network_name = "test_network"
self.network_type = "ETH"
self.integration_maturity = "development"
self.canonical_name = "test-chain-network"
self.chain_selector = 121212
self.chain_id = 123
self.client_params = {"dummy": "data"}
self.endpoint = Endpoint(self.url, self.provider, self.blockchain,
self.network_name, self.network_type,
self.integration_maturity, self.canonical_name,
self.chain_selector,
self.chain_id, **self.client_params)

def test_url_attribute(self):
Expand All @@ -34,7 +39,10 @@ def test_chain_id_attribute(self):
def test_labels_attribute(self):
"""Tests the labels attribute is set correctly"""
labels = [self.url, self.provider, self.blockchain,
self.network_name, self.network_type, str(self.chain_id)]
self.network_name, self.network_type,
self.integration_maturity, self.canonical_name,
str(self.chain_selector),
str(self.chain_id)]
self.assertEqual(labels, self.endpoint.labels)


Expand Down
3 changes: 3 additions & 0 deletions src/tests/fixtures/configuration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ blockchain: "TestChain"
chain_id: 1234
network_name: "TestNetwork"
network_type: "Mainnet"
integration_maturity: "development"
canonical_name: "test-network-mainnet"
chain_selector: 121212
collector: "evm"
endpoints:
- url: wss://test1.com
Expand Down
3 changes: 3 additions & 0 deletions src/tests/fixtures/configuration_aptos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ blockchain: "Aptos"
chain_id: 1234
network_name: "Testnet"
network_type: "Testnet"
integration_maturity: "development"
canonical_name: "test-network-testnet"
chain_selector: 121212
collector: "aptos"
endpoints:
- url: https://test1.com
Expand Down
3 changes: 3 additions & 0 deletions src/tests/fixtures/configuration_bitcoin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ blockchain: "Bitcoin"
chain_id: 1234
network_name: "TestNetwork"
network_type: "Mainnet"
integration_maturity: "development"
canonical_name: "test-network-mainnet"
chain_selector: 121212
collector: "bitcoin"
endpoints:
- url: wss://test1.com
Expand Down
3 changes: 3 additions & 0 deletions src/tests/fixtures/configuration_cardano.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ blockchain: "cardano"
chain_id: 1234
network_name: "TestNetwork"
network_type: "Mainnet"
integration_maturity: "development"
canonical_name: "test-network-mainnet"
chain_selector: 121212
collector: "cardano"
endpoints:
- url: wss://test1.com
Expand Down
3 changes: 3 additions & 0 deletions src/tests/fixtures/configuration_conflux.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ blockchain: "conflux"
chain_id: 1234
network_name: "TestNetwork"
network_type: "Mainnet"
integration_maturity: "development"
canonical_name: "test-network-mainnet"
chain_selector: 121212
collector: "conflux"
endpoints:
- url: wss://test1.com
Expand Down
3 changes: 3 additions & 0 deletions src/tests/fixtures/configuration_conn_params.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ blockchain: "TestChain"
chain_id: 1234
network_name: "TestNetwork"
network_type: "Mainnet"
integration_maturity: "development"
canonical_name: "test-network-mainnet"
chain_selector: 121212
collector: "evm"
connection_parameters:
open_timeout: 1
Expand Down
3 changes: 3 additions & 0 deletions src/tests/fixtures/configuration_evm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ blockchain: "other"
chain_id: 1234
network_name: "TestNetwork"
network_type: "Mainnet"
integration_maturity: "development"
canonical_name: "test-network-mainnet"
chain_selector: 121212
collector: "evm"
endpoints:
- url: wss://test1.com
Expand Down
3 changes: 3 additions & 0 deletions src/tests/fixtures/configuration_filecoin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ blockchain: "filecoin"
chain_id: 1234
network_name: "TestNetwork"
network_type: "Mainnet"
integration_maturity: "development"
canonical_name: "test-network-mainnet"
chain_selector: 121212
collector: "filecoin"
endpoints:
- url: wss://test1.com
Expand Down
3 changes: 3 additions & 0 deletions src/tests/fixtures/configuration_invalid.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ blockchain: "TestChain"
chain_id: '1234' # str instead of int
network_name: "TestNetwork"
network_type: "Mainnet"
integration_maturity: "development"
canonical_name: "test-network-mainnet"
chain_selector: 121212
collector: "evm"
endpoints:
- url: wss://test1.com
Expand Down
3 changes: 3 additions & 0 deletions src/tests/fixtures/configuration_solana.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ blockchain: "solana"
chain_id: 1234
network_name: "TestNetwork"
network_type: "Mainnet"
integration_maturity: "development"
canonical_name: "test-network-mainnet"
chain_selector: 121212
collector: "solana"
endpoints:
- url: wss://test1.com
Expand Down
3 changes: 3 additions & 0 deletions src/tests/fixtures/configuration_starknet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ blockchain: "starknet"
chain_id: 1234
network_name: "TestNetwork"
network_type: "Mainnet"
integration_maturity: "development"
canonical_name: "test-network-mainnet"
chain_selector: 121212
collector: "starknet"
endpoints:
- url: wss://test1.com
Expand Down
3 changes: 3 additions & 0 deletions src/tests/fixtures/configuration_tron.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ blockchain: "Tron"
chain_id: 1234
network_name: "Testnet"
network_type: "Testnet"
integration_maturity: "development"
canonical_name: "test-network-testnet"
chain_selector: 121212
collector: "tron"
endpoints:
- url: https://test1.com
Expand Down
3 changes: 3 additions & 0 deletions src/tests/fixtures/configuration_unsupported_blockchain.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ blockchain: "bitcoin"
chain_id: 1234
network_name: "TestNetwork"
network_type: "Mainnet"
integration_maturity: "development"
canonical_name: "test-network-mainnet"
chain_selector: 121212
collector: "cardano"
endpoints:
- url: wss://test1.com
Expand Down
Loading