Skip to content
This repository was archived by the owner on Jul 23, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
NDEV-2963 op-resources: customize the operator token name
  • Loading branch information
alfiedotwtf committed May 7, 2024
commit 9afc1d3c8822aec94392ec151a18193a100b8ab8
2 changes: 1 addition & 1 deletion proxy-cli/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def _holder_accounts_info(self, _) -> None:
balance = Decimal(holder_info.lamports) / 1_000_000_000
holder_address = str(op_res_info.holder_account)
op_key = op_res_ident.public_key
print(f'{ holder_address }\t { op_key }:{ op_res_ident.res_id }\t { balance:,.9f} SOL')
print(f'{ holder_address }\t { op_key }:{ op_res_ident.res_id }\t { balance:,.9f} {self._config.operator_token_name}')

@staticmethod
def _solana_private_key_info(_) -> None:
Expand Down
7 changes: 6 additions & 1 deletion proxy/common_neon/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,11 @@ def __init__(self):
self._const_gas_price = self._env_num('CONST_GAS_PRICE', -1, min_gas_price, 100_000_000) * (10 ** 9)

# Operator resource settings
self._native_token_name = os.environ.get("NATIVE_TOKEN_NAME", "NEON")
self._holder_size = self._env_num('HOLDER_SIZE', 256 * 1024, 1024, 10 * 1024 * 1024)
self._min_op_balance_to_warn = self._env_num('MIN_OPERATOR_BALANCE_TO_WARN', 9_000_000_000, 1)
self._min_op_balance_to_err = self._env_num('MIN_OPERATOR_BALANCE_TO_ERR', 1_000_000_000, 1)
self._native_token_name = os.environ.get("NATIVE_TOKEN_NAME", "NEON")
self._operator_token_name = os.environ.get("OPERATOR_TOKEN_NAME", "SOL")
self._perm_account_id = self._env_num('PERM_ACCOUNT_ID', 1, 1, 128)
self._perm_account_limit = self._env_num('PERM_ACCOUNT_LIMIT', 2, 1, 128)
self._recheck_used_resource_sec = self._env_num('RECHECK_USED_RESOURCE_SEC', 60, 10, 24 * 60 * 60)
Expand Down Expand Up @@ -326,6 +327,10 @@ def _env_num(
def native_token_name(self) -> str:
return self._native_token_name

@property
def operator_token_name(self) -> str:
return self._operator_token_name

@property
def solana_url_list(self) -> List[str]:
return self._solana_url_list
Expand Down
7 changes: 3 additions & 4 deletions proxy/mempool/gas_price_calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@


class GasPriceCalculator:
_sol_price_symbol = 'Crypto.SOL/USD'

def __init__(self, config: Config, solana: SolInteractor) -> None:
self._config = config
self._pyth_network_client = PythNetworkClient(solana)
Expand All @@ -26,6 +24,7 @@ def __init__(self, config: Config, solana: SolInteractor) -> None:
self._min_gas_price: Optional[int] = None
self._suggested_gas_price: Optional[int] = None
self._neon_price_symbol = f"Crypto.{self._config.native_token_name}/USD"
self._sol_price_symbol = f"Crypto.{self._config.operator_token_name}/USD"

def set_price_account(self, sol_price_account: Optional[SolPubKey], neon_price_account: Optional[SolPubKey]):
if (sol_price_account is None) or (neon_price_account is None):
Expand Down Expand Up @@ -102,9 +101,9 @@ def _get_tokens_prices_from_net(self) -> None:
try:
self._sol_price_usd = self._get_token_price(self._sol_price_symbol)
except PythNetworkError as exc:
LOG.debug(f'Failed to retrieve SOL price: {str(exc)}')
LOG.debug(f'Failed to retrieve {self._config.operator_token_name} price: {str(exc)}')
except BaseException as exc:
LOG.error('Failed to retrieve SOL price', exc_info=exc)
LOG.error(f'Failed to retrieve {self._config.operator_token_name} price', exc_info=exc)

def _calc_gas_price_from_net(self) -> Optional[int]:
if (self._sol_price_usd is None) or (self._neon_price_usd is None):
Expand Down
2 changes: 1 addition & 1 deletion proxy/testing/test_gas_tank_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def create_account_instruction(cls, neon_address: str, payer: SolPubKey):

def create_sol_account(self):
account = SolAccount()
print(f"New solana account created: {account.pubkey()}. Airdropping SOL...")
print(f"New solana account created: {account.pubkey()}. Airdropping {self.config.operator_token_name}...")
self.solana.request_airdrop(account.pubkey(), 1000_000_000_000)
return account

Expand Down