diff --git a/.gitignore b/.gitignore index b618432..703d661 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,4 @@ local* # Python venv __pycache__ +.coverage diff --git a/config/exporter_example/config.yml b/config/exporter_example/config.yml index 3434510..2f06a12 100644 --- a/config/exporter_example/config.yml +++ b/config/exporter_example/config.yml @@ -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 @@ -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 @@ -25,4 +28,4 @@ endpoints: # List of endpoints with their metadata. -## \ No newline at end of file +## diff --git a/requirements-dev.txt b/requirements-dev.txt index e1b6799..74e208a 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -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 diff --git a/src/configuration.py b/src/configuration.py index 2b8acb2..284fd27 100644 --- a/src/configuration.py +++ b/src/configuration.py @@ -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'): { diff --git a/src/exporter.py b/src/exporter.py index cb99228..6676253 100644 --- a/src/exporter.py +++ b/src/exporter.py @@ -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) diff --git a/src/metrics.py b/src/metrics.py index ead4747..af0f8da 100644 --- a/src/metrics.py +++ b/src/metrics.py @@ -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' ] diff --git a/src/registries.py b/src/registries.py index c1f0482..1e4b7c8 100644 --- a/src/registries.py +++ b/src/registries.py @@ -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 @@ -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 diff --git a/src/test_configuration.py b/src/test_configuration.py index 407d349..3b9449a 100644 --- a/src/test_configuration.py +++ b/src/test_configuration.py @@ -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": [{ diff --git a/src/test_metrics.py b/src/test_metrics.py index 7a6220a..f16b3ee 100644 --- a/src/test_metrics.py +++ b/src/test_metrics.py @@ -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): diff --git a/src/test_registries.py b/src/test_registries.py index a728962..838cce4 100644 --- a/src/test_registries.py +++ b/src/test_registries.py @@ -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): @@ -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) diff --git a/src/tests/fixtures/configuration.yaml b/src/tests/fixtures/configuration.yaml index 53734a2..55b3538 100644 --- a/src/tests/fixtures/configuration.yaml +++ b/src/tests/fixtures/configuration.yaml @@ -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 diff --git a/src/tests/fixtures/configuration_aptos.yaml b/src/tests/fixtures/configuration_aptos.yaml index 6daf57b..0318217 100644 --- a/src/tests/fixtures/configuration_aptos.yaml +++ b/src/tests/fixtures/configuration_aptos.yaml @@ -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 diff --git a/src/tests/fixtures/configuration_bitcoin.yaml b/src/tests/fixtures/configuration_bitcoin.yaml index 3e390cc..0d7b7d7 100644 --- a/src/tests/fixtures/configuration_bitcoin.yaml +++ b/src/tests/fixtures/configuration_bitcoin.yaml @@ -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 diff --git a/src/tests/fixtures/configuration_cardano.yaml b/src/tests/fixtures/configuration_cardano.yaml index f536d37..3c6e04d 100644 --- a/src/tests/fixtures/configuration_cardano.yaml +++ b/src/tests/fixtures/configuration_cardano.yaml @@ -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 diff --git a/src/tests/fixtures/configuration_conflux.yaml b/src/tests/fixtures/configuration_conflux.yaml index e410731..1d99be1 100644 --- a/src/tests/fixtures/configuration_conflux.yaml +++ b/src/tests/fixtures/configuration_conflux.yaml @@ -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 diff --git a/src/tests/fixtures/configuration_conn_params.yaml b/src/tests/fixtures/configuration_conn_params.yaml index e3569af..9d1bf67 100644 --- a/src/tests/fixtures/configuration_conn_params.yaml +++ b/src/tests/fixtures/configuration_conn_params.yaml @@ -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 diff --git a/src/tests/fixtures/configuration_evm.yaml b/src/tests/fixtures/configuration_evm.yaml index 80f3ac7..96cfd6f 100644 --- a/src/tests/fixtures/configuration_evm.yaml +++ b/src/tests/fixtures/configuration_evm.yaml @@ -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 diff --git a/src/tests/fixtures/configuration_filecoin.yaml b/src/tests/fixtures/configuration_filecoin.yaml index f051de5..6ec9461 100644 --- a/src/tests/fixtures/configuration_filecoin.yaml +++ b/src/tests/fixtures/configuration_filecoin.yaml @@ -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 diff --git a/src/tests/fixtures/configuration_invalid.yaml b/src/tests/fixtures/configuration_invalid.yaml index 10bfd0c..64e13a4 100644 --- a/src/tests/fixtures/configuration_invalid.yaml +++ b/src/tests/fixtures/configuration_invalid.yaml @@ -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 diff --git a/src/tests/fixtures/configuration_solana.yaml b/src/tests/fixtures/configuration_solana.yaml index 3f9e1a4..24dd7d3 100644 --- a/src/tests/fixtures/configuration_solana.yaml +++ b/src/tests/fixtures/configuration_solana.yaml @@ -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 diff --git a/src/tests/fixtures/configuration_starknet.yaml b/src/tests/fixtures/configuration_starknet.yaml index 6ac2d45..f7a6fc1 100644 --- a/src/tests/fixtures/configuration_starknet.yaml +++ b/src/tests/fixtures/configuration_starknet.yaml @@ -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 diff --git a/src/tests/fixtures/configuration_tron.yaml b/src/tests/fixtures/configuration_tron.yaml index aa4f380..7b65723 100644 --- a/src/tests/fixtures/configuration_tron.yaml +++ b/src/tests/fixtures/configuration_tron.yaml @@ -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 diff --git a/src/tests/fixtures/configuration_unsupported_blockchain.yaml b/src/tests/fixtures/configuration_unsupported_blockchain.yaml index 4a157a7..e1454db 100644 --- a/src/tests/fixtures/configuration_unsupported_blockchain.yaml +++ b/src/tests/fixtures/configuration_unsupported_blockchain.yaml @@ -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