Skip to content

Commit

Permalink
Add auto relayer endpoint (#426)
Browse files Browse the repository at this point in the history
  • Loading branch information
evgeny-stakewise authored Nov 12, 2024
1 parent f618743 commit f9ba048
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/commands/start_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from src.common.utils import log_verbose
from src.common.validators import validate_eth_address
from src.common.vault_config import VaultConfig
from src.config.networks import AVAILABLE_NETWORKS
from src.config.networks import AVAILABLE_NETWORKS, NETWORKS
from src.config.settings import (
DEFAULT_MAX_FEE_PER_GAS_GWEI,
DEFAULT_METRICS_HOST,
Expand All @@ -26,6 +26,10 @@
logger = logging.getLogger(__name__)


# Special value used to dynamically determine option value
AUTO = 'AUTO'


@click.option(
'--data-dir',
default=str(Path.home() / '.stakewise'),
Expand Down Expand Up @@ -183,6 +187,7 @@
help='Relayer endpoint.',
prompt='Enter the relayer endpoint',
envvar='RELAYER_ENDPOINT',
default=AUTO,
)
@click.command(help='Start operator service')
# pylint: disable-next=too-many-arguments,too-many-locals
Expand Down Expand Up @@ -214,6 +219,13 @@ def start_api(
vault_config.load()
network = vault_config.network

if relayer_endpoint == AUTO and relayer_type == RelayerTypes.DVT:
network_config = NETWORKS[network]
relayer_endpoint = network_config.DEFAULT_DVT_RELAYER_ENDPOINT

if relayer_endpoint == AUTO and relayer_type == RelayerTypes.DEFAULT:
raise click.ClickException('Relayer endpoint must be specified for default relayer type')

validators_registration_mode = ValidatorsRegistrationMode.API

settings.set(
Expand Down
5 changes: 5 additions & 0 deletions src/config/networks.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class NetworkConfig:
STAKEWISE_API_URL: str
RATED_API_URL: str
CONFIG_UPDATE_EVENT_BLOCK: BlockNumber
DEFAULT_DVT_RELAYER_ENDPOINT: str

@property
def SHAPELLA_FORK(self) -> ConsensusFork:
Expand Down Expand Up @@ -109,6 +110,7 @@ def IS_SUPPORT_V2_MIGRATION(self) -> bool:
STAKEWISE_API_URL='https://mainnet-api.stakewise.io/graphql',
RATED_API_URL='https://api.rated.network',
CONFIG_UPDATE_EVENT_BLOCK=BlockNumber(18470104),
DEFAULT_DVT_RELAYER_ENDPOINT='https://mainnet-dvt-relayer.stakewise.io',
),
HOLESKY: NetworkConfig(
CHAIN_ID=17000,
Expand Down Expand Up @@ -154,6 +156,7 @@ def IS_SUPPORT_V2_MIGRATION(self) -> bool:
STAKEWISE_API_URL='https://holesky-api.stakewise.io/graphql',
RATED_API_URL='https://api.rated.network',
CONFIG_UPDATE_EVENT_BLOCK=BlockNumber(215397),
DEFAULT_DVT_RELAYER_ENDPOINT='https://holesky-dvt-relayer.stakewise.io',
),
GNOSIS: NetworkConfig(
CHAIN_ID=100,
Expand Down Expand Up @@ -201,6 +204,7 @@ def IS_SUPPORT_V2_MIGRATION(self) -> bool:
STAKEWISE_API_URL='https://gnosis-api.stakewise.io/graphql',
RATED_API_URL='https://api.rated.network',
CONFIG_UPDATE_EVENT_BLOCK=BlockNumber(34778569),
DEFAULT_DVT_RELAYER_ENDPOINT='gnosis-dvt-relayer.stakewise.io',
),
CHIADO: NetworkConfig(
CHAIN_ID=10200,
Expand Down Expand Up @@ -246,5 +250,6 @@ def IS_SUPPORT_V2_MIGRATION(self) -> bool:
STAKEWISE_API_URL='https://chiado-api.stakewise.io/graphql',
RATED_API_URL='https://api.rated.network',
CONFIG_UPDATE_EVENT_BLOCK=BlockNumber(10627606),
DEFAULT_DVT_RELAYER_ENDPOINT='chiado-dvt-relayer.stakewise.io',
),
}

0 comments on commit f9ba048

Please sign in to comment.