Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
8d079ed
introduce logged_based
Dec 27, 2021
4b609b1
Get used with logged_group
Dec 29, 2021
a63d17d
Provide logged group on the rest of code base
Dec 29, 2021
4c3ffad
Merge remote-tracking branch 'origin/develop' into 422_introduce_logg…
Dec 29, 2021
b4eda35
Add Airdropper logged_group
Dec 29, 2021
8275f07
Spit and polish
Dec 29, 2021
b3ecaae
Spit and polish
Dec 29, 2021
c8d51ff
Spit and polish
Dec 29, 2021
e5854f4
Spit and polish
Dec 29, 2021
1c36d89
Spit and polish
Dec 29, 2021
bea6cfa
Spit and polish
Dec 29, 2021
465754e
Spit and polish
Dec 29, 2021
f7a055a
rollback proxy.py
Dec 29, 2021
c345177
spit and polish
Dec 29, 2021
ab79eb0
Remove log_level param from airdropper
Dec 29, 2021
76f914e
Spit and polish
Dec 29, 2021
c5cbdba
Fix indexer base init error
Dec 29, 2021
ee87cb7
Fix indexer base init error
Dec 29, 2021
1218d78
Reduce Airdropper level
Dec 30, 2021
523e44f
roll back get_measurements prefix
Dec 30, 2021
dcdf481
Get logged-groups package from different place
Dec 30, 2021
13242b0
install git to resolve python dependency
Dec 30, 2021
b32b936
Spit on Dockerfile and polish
Dec 30, 2021
35a51b7
Fix get_measurements errors parsig command
Dec 30, 2021
5372136
Merge remote-tracking branch 'origin/develop' into 422_introduce_logg…
Dec 30, 2021
125c56e
Polish after merge
Dec 30, 2021
3f759ac
Fix
Dec 30, 2021
3862077
fix
Dec 30, 2021
a7b1de2
fix
Dec 30, 2021
ed83fe6
Merge branch 'develop' into 422_introduce_logged_groups
Jan 10, 2022
440ba11
fix
Jan 10, 2022
7989afb
fix
Jan 10, 2022
ccdd299
spit and polish
Jan 10, 2022
0b81aca
fix errors
Jan 11, 2022
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
Next Next commit
Spit and polish
  • Loading branch information
rozhkovdmitrii committed Dec 29, 2021
commit 76f914e001bf53e5208323e019084cd8315280c9
3 changes: 2 additions & 1 deletion proxy/common_neon/costs.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import base58
import psycopg2

from ..environment import EVM_LOADER_ID, WRITE_TRANSACTION_COST_IN_DB
from ..environment import EVM_LOADER_ID, WRITE_TRANSACTION_COST_IN_DB
from ..indexer.sql_dict import POSTGRES_USER, POSTGRES_HOST, POSTGRES_DB, POSTGRES_PASSWORD


class SQLCost():
def __init__(self):

Expand Down
7 changes: 5 additions & 2 deletions proxy/common_neon/emulator_interactor.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from .errors import EthereumError
from ..environment import neon_cli, ETH_TOKEN_MINT_ID


@logged_group("Proxy")
def call_emulated(contract_id, caller_id, data=None, value=None, *, logger):
output = emulator(contract_id, caller_id, data, value)
Expand All @@ -14,7 +15,8 @@ def call_emulated(contract_id, caller_id, data=None, value=None, *, logger):
return result


def check_emulated_exit_status(result: Dict[str, Any]):
@logged_group("Proxy")
def check_emulated_exit_status(result: Dict[str, Any], *, logger):
exit_status = result['exit_status']
if exit_status == 'revert':
revert_data = result['result']
Expand All @@ -30,7 +32,8 @@ def check_emulated_exit_status(result: Dict[str, Any]):
raise Exception("evm emulator error ", result)


def decode_revert_message(data: str) -> Optional[str]:
@logged_group("Proxy")
def decode_revert_message(data: str, *, logger) -> Optional[str]:
data_len = len(data)
if data_len == 0:
return None
Expand Down
12 changes: 6 additions & 6 deletions proxy/common_neon/erc20_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@
from solana.transaction import Transaction
import spl.token.instructions as spl_token
from typing import Union, Dict
from logging import getLogger
import struct

logger = getLogger('__name__')
from logged_groups import logged_group

install_solc(version='0.7.6')
from solcx import compile_source
Expand Down Expand Up @@ -78,6 +76,8 @@
}
'''


@logged_group("Proxy")
class ERC20Wrapper:
proxy: Web3
name: str
Expand Down Expand Up @@ -124,10 +124,10 @@ def deploy_wrapper(self):
tx_constructor = erc20.constructor(self.name, self.symbol, bytes(self.token.pubkey)).buildTransaction(tx)
tx_deploy = self.proxy.eth.account.sign_transaction(tx_constructor, self.admin.key)
tx_deploy_hash = self.proxy.eth.send_raw_transaction(tx_deploy.rawTransaction)
logger.debug(f'tx_deploy_hash: {tx_deploy_hash.hex()}')
self.debug(f'tx_deploy_hash: {tx_deploy_hash.hex()}')
tx_deploy_receipt = self.proxy.eth.wait_for_transaction_receipt(tx_deploy_hash)
logger.debug(f'tx_deploy_receipt: {tx_deploy_receipt}')
logger.debug(f'deploy status: {tx_deploy_receipt.status}')
self.debug(f'tx_deploy_receipt: {tx_deploy_receipt}')
self.debug(f'deploy status: {tx_deploy_receipt.status}')
self.neon_contract_address = tx_deploy_receipt.contractAddress
self.solana_contract_address = self.get_neon_account_address(self.neon_contract_address)

Expand Down
16 changes: 0 additions & 16 deletions proxy/common_neon/neon_instruction.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ def __init__(self, operator):
self.operator_account = operator
self.operator_neon_address = getTokenAddr(self.operator_account)


def init_eth_trx(self, eth_trx, eth_accounts, caller_token):
self.eth_accounts = eth_accounts
self.caller_token = caller_token
Expand All @@ -101,7 +100,6 @@ def init_eth_trx(self, eth_trx, eth_accounts, caller_token):

return self


def init_iterative(self, storage, holder, perm_accs_id):
self.storage = storage
self.holder = holder
Expand All @@ -115,7 +113,6 @@ def create_collateral_pool_address(collateral_pool_index):
seed = COLLATERAL_SEED_PREFIX + str(collateral_pool_index)
return accountWithSeed(PublicKey(COLLATERAL_POOL_BASE), str.encode(seed))


def create_account_with_seed_trx(self, account, seed, lamports, space):
seed_str = str(seed, 'utf8')
self.debug("createAccountWithSeedTrx base(%s) account(%s) seed(%s)", type(self.operator_account),account, seed_str)
Expand All @@ -129,7 +126,6 @@ def create_account_with_seed_trx(self, account, seed, lamports, space):
data=create_account_with_seed_layout(self.operator_account, seed_str, lamports, space)
)


def make_create_eth_account_trx(self, eth_address: EthereumAddress, code_acc=None) -> Tuple[Transaction, PublicKey]:
pda_account, nonce = ether2program(eth_address)
neon_token_account = getTokenAddr(PublicKey(pda_account))
Expand Down Expand Up @@ -169,7 +165,6 @@ def make_create_eth_account_trx(self, eth_address: EthereumAddress, code_acc=Non
]))
return trx, neon_token_account


def createERC20TokenAccountTrx(self, token_info) -> Transaction:
trx = Transaction()
trx.add(TransactionInstruction(
Expand All @@ -189,7 +184,6 @@ def createERC20TokenAccountTrx(self, token_info) -> Transaction:

return trx


def make_transfer_instruction(self, associated_token_account: PublicKey) -> TransactionInstruction:
transfer_instruction = transfer2(Transfer2Params(
source=self.operator_neon_address,
Expand All @@ -204,7 +198,6 @@ def make_transfer_instruction(self, associated_token_account: PublicKey) -> Tran
f"{associated_token_account}, owned by: {associated_token_account} , value: {NEW_USER_AIRDROP_AMOUNT}")
return transfer_instruction


def make_trx_with_create_and_airdrop(self, eth_account, code_acc=None) -> Transaction:
trx = Transaction()
create_trx, associated_token_account = self.make_create_eth_account_trx(eth_account, code_acc)
Expand All @@ -216,7 +209,6 @@ def make_trx_with_create_and_airdrop(self, eth_account, code_acc=None) -> Transa

return trx


def make_resize_instruction(self, acc_desc, code_account_new, seed) -> TransactionInstruction:
return TransactionInstruction(
program_id = EVM_LOADER_ID,
Expand All @@ -233,7 +225,6 @@ def make_resize_instruction(self, acc_desc, code_account_new, seed) -> Transacti
],
)


def make_write_transaction(self, offset: int, data: bytes) -> Transaction:
return Transaction().add(TransactionInstruction(
program_id=EVM_LOADER_ID,
Expand All @@ -244,7 +235,6 @@ def make_write_transaction(self, offset: int, data: bytes) -> Transaction:
]
))


def make_keccak_instruction(self, check_instruction_index, msg_len, data_start) -> TransactionInstruction:
return TransactionInstruction(
program_id=KECCAK_PROGRAM,
Expand All @@ -254,7 +244,6 @@ def make_keccak_instruction(self, check_instruction_index, msg_len, data_start)
]
)


def make_05_call_instruction(self) -> TransactionInstruction:
return TransactionInstruction(
program_id = EVM_LOADER_ID,
Expand All @@ -270,14 +259,12 @@ def make_05_call_instruction(self) -> TransactionInstruction:
] + self.eth_accounts + obligatory_accounts
)


def make_noniterative_call_transaction(self, length_before: int = 0) -> Transaction:
trx = Transaction()
trx.add(self.make_keccak_instruction(length_before + 1, len(self.eth_trx.unsigned_msg()), 5))
trx.add(self.make_05_call_instruction())
return trx


def make_cancel_transaction(self) -> Transaction:
return Transaction().add(TransactionInstruction(
program_id = EVM_LOADER_ID,
Expand All @@ -296,7 +283,6 @@ def make_cancel_transaction(self) -> Transaction:
] + obligatory_accounts
))


def make_partial_call_or_continue_instruction(self, steps: int = 0) -> TransactionInstruction:
data = bytearray.fromhex("0D") + self.collateral_pool_index_buf + steps.to_bytes(8, byteorder="little") + self.msg
return TransactionInstruction(
Expand All @@ -318,14 +304,12 @@ def make_partial_call_or_continue_instruction(self, steps: int = 0) -> Transacti
] + obligatory_accounts
)


def make_partial_call_or_continue_transaction(self, steps: int = 0, length_before: int = 0) -> Transaction:
trx = Transaction()
trx.add(self.make_keccak_instruction(length_before + 1, len(self.eth_trx.unsigned_msg()), 13))
trx.add(self.make_partial_call_or_continue_instruction(steps))
return trx


def make_partial_call_or_continue_from_account_data(self, steps, index=None) -> Transaction:
data = bytearray.fromhex("0E") + self.collateral_pool_index_buf + steps.to_bytes(8, byteorder='little')
if index:
Expand Down