Skip to content

Commit

Permalink
#705 Fix 'AccountInfoLayout' is not defined error
Browse files Browse the repository at this point in the history
  • Loading branch information
otselnik committed Apr 7, 2022
1 parent 9e80bec commit 21ddee2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
28 changes: 14 additions & 14 deletions proxy/common_neon/solana_interactor.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,19 +342,7 @@ def get_neon_account_info(self, eth_account: EthereumAddress) -> Optional[NeonAc
f"{len(info.data)} < {ACCOUNT_INFO_LAYOUT.sizeof()}")
return NeonAccountInfo.frombytes(info.data)

def get_storage_account_info(self, storage_account: PublicKey) -> Optional[StorageAccountInfo]:
info = self.get_account_info(storage_account, length=0)
if info is None:
return None
elif info.tag != 30:
self.debug(f'Storage account {str(storage_account)} has tag {info.tag}')
return None
elif len(info.data) < STORAGE_ACCOUNT_INFO_LAYOUT.sizeof():
raise RuntimeError(f"Wrong data length for storage data {storage_account}: " +
f"{len(info.data)} < {STORAGE_ACCOUNT_INFO_LAYOUT.sizeof()}")
return StorageAccountInfo.frombytes(info.data)

def get_account_info_layout_list(self, eth_accounts: List[EthereumAddress]) -> List[Optional[AccountInfoLayout]]:
def get_neon_account_info_list(self, eth_accounts: List[EthereumAddress]) -> List[Optional[NeonAccountInfo]]:
requests_list = []
for eth_account in eth_accounts:
account_sol, _nonce = ether2program(eth_account)
Expand All @@ -365,9 +353,21 @@ def get_account_info_layout_list(self, eth_accounts: List[EthereumAddress]) -> L
if info is None or len(info.data) < ACCOUNT_INFO_LAYOUT.sizeof():
accounts_list.append(None)
continue
accounts_list.append(AccountInfoLayout.frombytes(info.data))
accounts_list.append(NeonAccountInfo.frombytes(info.data))
return accounts_list

def get_storage_account_info(self, storage_account: PublicKey) -> Optional[StorageAccountInfo]:
info = self.get_account_info(storage_account, length=0)
if info is None:
return None
elif info.tag != 30:
self.debug(f'Storage account {str(storage_account)} has tag {info.tag}')
return None
elif len(info.data) < STORAGE_ACCOUNT_INFO_LAYOUT.sizeof():
raise RuntimeError(f"Wrong data length for storage data {storage_account}: " +
f"{len(info.data)} < {STORAGE_ACCOUNT_INFO_LAYOUT.sizeof()}")
return StorageAccountInfo.frombytes(info.data)

def get_multiple_rent_exempt_balances_for_size(self, size_list: [int], commitment='confirmed') -> [int]:
opts = {
"commitment": commitment
Expand Down
2 changes: 1 addition & 1 deletion proxy/statistics_exporter/prometheus_proxy_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def _stat_operator_balance(self):
self.stat_exporter.stat_commit_operator_sol_balance(str(account), Decimal(balance) / 1_000_000_000)

neon_accounts = [str(EthereumAddress.from_private_key(neon_account.secret_key())) for neon_account in operator_accounts]
neon_layouts = self._solana.get_account_info_layout_list(neon_accounts)
neon_layouts = self._solana.get_neon_account_info_list(neon_accounts)
for sol_account, neon_account, neon_layout in zip(operator_accounts, neon_accounts, neon_layouts):
if neon_layout:
neon_balance = Decimal(neon_layout.balance) / 1_000_000_000 / 1_000_000_000
Expand Down

0 comments on commit 21ddee2

Please sign in to comment.