diff --git a/Dockerfile b/Dockerfile index 9cc8c092c..16212ad5d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -46,7 +46,7 @@ COPY . /opt ARG PROXY_REVISION ARG LOG_CFG=log_cfg.json RUN (cp -f /opt/${LOG_CFG} /opt/log_cfg.json || true) -RUN sed -i 's/NEON_PROXY_REVISION_TO_BE_REPLACED/'"$PROXY_REVISION"'/g' /opt/proxy/plugin/solana_rest_api.py +RUN sed -i 's/NEON_PROXY_REVISION_TO_BE_REPLACED/'"$PROXY_REVISION"'/g' /opt/proxy/plugin/neon_rpc_api_plugin.py COPY ./proxy/solana-py.patch /opt RUN cd /usr/local/lib/python3.8/dist-packages/ && patch -p0 Optional[str]: return None contract_addr = rlp.encode((self._sender(), self.nonce)) return keccak_256(contract_addr).digest()[-20:].hex() - - -#class JsonEncoder(json.JSONEncoder): -# def default(self, obj): -# if isinstance(obj, bytes): -# return obj.hex() -# return json.JSONEncoder.default(self.obj) -# -#trx = '0xf8af098539f98e7a0082bfd194b80102fd2d3d1be86823dd36f9c783ad0ee7d89880b844a9059cbb000000000000000000000000c1566af4699928fdf9be097ca3dc47ece39f8f8e00000000000000000000000000000000000000000000000000000000000000328602e92be91e86a0e2c683a38606033cf416cca55575b4080465f1a275aff080b2af1a264b24d56ca02e48a4cb63d8549610d070b02e272ab6a3a680e677c7d7f51045a9cbcf218f0d' -#trx = '0xf8af098539f98e7a0082bfd194b80102fd2d3d1be86823dd36f9c783ad0ee7d89880b844a9059cbb000000000000000000000000c1566af4699928fdf9be097ca3dc47ece39f8f8e00000000000000000000000000000000000000000000000000000000000000328602e92be91e86a0e2c683a38606033cf416cca55575b4080465f1a275aff080b2af1a264b24d56ca02e48a4cb63d8549610d070b02e272ab6a3a680e677c7d7f51045a9cbcf218f0d' -#trx = '0xf87202853946be1c0082520894c1566af4699928fdf9be097ca3dc47ece39f8f8e880de0b6b3a7640000808602e92be91e85a06f350382938df92b987681de78d81f0490ee1d26b18ea968ae42ee4a800711a6a0641672e91b735bd6badd2c51b6a6ecdcd740b78c8bf581aa3f1431cd0f8c02f3' -# -#_trx = Trx.fromString(bytearray.fromhex(trx[2:])) -#print(json.dumps(_trx.__dict__, cls=JsonEncoder, indent=3)) -#print(str(_trx)) -#print(trx[2:]) -# -#msgHash = _trx.hash() -#sig = keys.Signature(vrs=[1 if _trx.v%2==0 else 0, _trx.r, _trx.s]) -#pub = sig.recover_public_key_from_msg_hash(msgHash) -#print('SENDER', pub.to_canonical_address().hex()) -#print("VERIFY", sig.verify_msg_hash(msgHash, pub)) diff --git a/proxy/plugin/gas_price_calculator.py b/proxy/common_neon/gas_price_calculator.py similarity index 100% rename from proxy/plugin/gas_price_calculator.py rename to proxy/common_neon/gas_price_calculator.py diff --git a/proxy/common_neon/types.py b/proxy/common_neon/types.py new file mode 100644 index 000000000..433444a30 --- /dev/null +++ b/proxy/common_neon/types.py @@ -0,0 +1,9 @@ +class Result: + def __init__(self, reason: str = None): + self._reason = reason + + def __bool__(self) -> bool: + return self._reason is None + + def __str__(self) -> str: + return self._reason if self._reason is not None else "" diff --git a/proxy/common_neon/utils/__init__.py b/proxy/common_neon/utils/__init__.py new file mode 100644 index 000000000..320db8b9f --- /dev/null +++ b/proxy/common_neon/utils/__init__.py @@ -0,0 +1,2 @@ +from .utils import * + diff --git a/proxy/common_neon/utils.py b/proxy/common_neon/utils/utils.py similarity index 98% rename from proxy/common_neon/utils.py rename to proxy/common_neon/utils/utils.py index 9c4defdf6..2bc5764bd 100644 --- a/proxy/common_neon/utils.py +++ b/proxy/common_neon/utils/utils.py @@ -6,9 +6,10 @@ from eth_utils import big_endian_to_int -from ..environment import EVM_LOADER_ID +#TODO: move it out from here +from ...environment import EVM_LOADER_ID -from ..common_neon.eth_proto import Trx as EthTx +from ..eth_proto import Trx as EthTx def str_fmt_object(obj): diff --git a/proxy/neon_proxy_app.py b/proxy/neon_proxy_app.py new file mode 100644 index 000000000..48b832af9 --- /dev/null +++ b/proxy/neon_proxy_app.py @@ -0,0 +1,10 @@ +from .proxy import entry_point + +from .statistics_exporter.prometheus_proxy_server import PrometheusProxyServer + + +class NeonProxyApp: + + def start(self): + PrometheusProxyServer() + entry_point() diff --git a/proxy/neon_rpc_api_model/__init__.py b/proxy/neon_rpc_api_model/__init__.py new file mode 100644 index 000000000..16b7421f3 --- /dev/null +++ b/proxy/neon_rpc_api_model/__init__.py @@ -0,0 +1 @@ +from . neon_rpc_api_model import NeonRpcApiModel, NEON_PROXY_PKG_VERSION, NEON_PROXY_REVISION diff --git a/proxy/plugin/solana_rest_api.py b/proxy/neon_rpc_api_model/neon_rpc_api_model.py similarity index 76% rename from proxy/plugin/solana_rest_api.py rename to proxy/neon_rpc_api_model/neon_rpc_api_model.py index 6e830ee0d..a9b08617f 100644 --- a/proxy/plugin/solana_rest_api.py +++ b/proxy/neon_rpc_api_model/neon_rpc_api_model.py @@ -1,59 +1,43 @@ -# -*- coding: utf-8 -*- -""" - proxy.py - ~~~~~~~~ - ⚡⚡⚡ Fast, Lightweight, Pluggable, TLS interception capable proxy server focused on - Network monitoring, controls & Application development, testing, debugging. - - :copyright: (c) 2013-present by Abhinav Singh and contributors. - :license: BSD, see LICENSE for more details. -""" import json -import threading -import traceback -import time -import hashlib import multiprocessing -import sha3 - -from logged_groups import logged_group, logging_context +import traceback +from typing import Optional, Union -from ..common.utils import build_http_response -from ..http.codes import httpStatusCodes -from ..http.parser import HttpParser -from ..http.websocket import WebsocketFrame -from ..http.server import HttpWebServerBasePlugin, httpProtocolTypes -from typing import Union, List, Tuple, Optional +import sha3 +from logged_groups import logged_group +from web3.auto import w3 -from ..common_neon.transaction_sender import NeonTxSender -from ..common_neon.solana_interactor import SolanaInteractor -from ..common_neon.solana_receipt_parser import SolTxError from ..common_neon.address import EthereumAddress from ..common_neon.emulator_interactor import call_emulated from ..common_neon.errors import EthereumError, InvalidParamError, PendingTxError from ..common_neon.estimate import GasEstimate -from ..common_neon.utils import SolanaBlockInfo +from ..common_neon.eth_proto import Trx as EthTrx from ..common_neon.keys_storage import KeyStorage -from ..environment import SOLANA_URL, PP_SOLANA_URL, PYTH_MAPPING_ACCOUNT, EVM_STEP_COUNT, CHAIN_ID, ENABLE_PRIVATE_API -from ..environment import NEON_EVM_VERSION, NEON_EVM_REVISION -from ..environment import neon_cli +from ..common_neon.solana_interactor import SolanaInteractor +from ..common_neon.utils import SolanaBlockInfo +from ..environment import SOLANA_URL, PP_SOLANA_URL, PYTH_MAPPING_ACCOUNT, NEON_EVM_VERSION, NEON_EVM_REVISION, \ + CHAIN_ID, neon_cli, EVM_STEP_COUNT from ..memdb.memdb import MemDB -from .gas_price_calculator import GasPriceCalculator -from ..common_neon.eth_proto import Trx as EthTrx -from web3.auto import w3 - +from ..common_neon.gas_price_calculator import GasPriceCalculator from ..statistics_exporter.proxy_metrics_interface import StatisticsExporter -from ..statistics_exporter.prometheus_proxy_exporter import PrometheusExporter -modelInstanceLock = threading.Lock() -modelInstance = None +from .transaction_sender import NeonTxSender NEON_PROXY_PKG_VERSION = '0.7.15-dev' NEON_PROXY_REVISION = 'NEON_PROXY_REVISION_TO_BE_REPLACED' +class JsonEncoder(json.JSONEncoder): + def default(self, obj): + if isinstance(obj, bytearray): + return obj.hex() + if isinstance(obj, bytes): + return obj.hex() + return json.JSONEncoder.default(self, obj) + + @logged_group("neon.Proxy") -class EthereumModel: +class NeonRpcApiModel: proxy_id_glob = multiprocessing.Value('i', 0) def __init__(self): @@ -464,11 +448,9 @@ def eth_sendRawTransaction(self, rawTrx: str) -> str: return eth_signature except EthereumError: self._stat_tx_failed() - # self.debug(f"eth_sendRawTransaction EthereumError: {err}") raise except Exception: self._stat_tx_failed() - # self.error(f"eth_sendRawTransaction type(err): {type(err}}, Exception: {err}") raise def _stat_tx_begin(self): @@ -647,161 +629,3 @@ def net_listening() -> bool: def neon_getSolanaTransactionByNeonTransaction(self, NeonTxId: str) -> Union[str, list]: neon_sign = self._normalize_tx_id(NeonTxId) return self._db.get_sol_sign_list_by_neon_sign(neon_sign) - - -class JsonEncoder(json.JSONEncoder): - def default(self, obj): - if isinstance(obj, bytearray): - return obj.hex() - if isinstance(obj, bytes): - return obj.hex() - return json.JSONEncoder.default(self, obj) - - -@logged_group("neon.Proxy") -class SolanaProxyPlugin(HttpWebServerBasePlugin): - """Extend in-built Web Server to add Reverse Proxy capabilities. - """ - - SOLANA_PROXY_LOCATION: str = r'/solana$' - SOLANA_PROXY_PASS = [ - b'http://localhost:8545/' - ] - - def __init__(self, *args): - HttpWebServerBasePlugin.__init__(self, *args) - self._stat_exporter = PrometheusExporter() - self.model = SolanaProxyPlugin.getModel() - self.model.set_stat_exporter(self._stat_exporter) - - @classmethod - def getModel(cls): - global modelInstanceLock - global modelInstance - with modelInstanceLock: - if modelInstance is None: - modelInstance = EthereumModel() - return modelInstance - - def routes(self) -> List[Tuple[int, str]]: - return [ - (httpProtocolTypes.HTTP, SolanaProxyPlugin.SOLANA_PROXY_LOCATION), - (httpProtocolTypes.HTTPS, SolanaProxyPlugin.SOLANA_PROXY_LOCATION) - ] - - def process_request(self, request): - response = { - 'jsonrpc': '2.0', - 'id': request.get('id', None), - } - - def is_private_api(method_name: str) -> bool: - for prefix in ('eth_', 'net_', 'web3_', 'neon_'): - if method_name.startswith(prefix): - break - else: - return True - - if ENABLE_PRIVATE_API: - return False - - private_method_map = ( - "eth_accounts", - "eth_sign", - "eth_sendTransaction", - "eth_signTransaction", - ) - return method_name in private_method_map - - try: - if (not hasattr(self.model, request['method'])) or is_private_api(request["method"]): - response['error'] = {'code': -32601, 'message': f'method {request["method"]} is not supported'} - else: - method = getattr(self.model, request['method']) - params = request.get('params', []) - response['result'] = method(*params) - except SolTxError as err: - # traceback.print_exc() - response['error'] = {'code': -32000, 'message': err.error} - except EthereumError as err: - # traceback.print_exc() - response['error'] = err.getError() - except Exception as err: - err_tb = "".join(traceback.format_tb(err.__traceback__)) - self.error('Exception on process request. ' + - f'Type(err): {type(err)}, Error: {err}, Traceback: {err_tb}') - response['error'] = {'code': -32000, 'message': str(err)} - - return response - - def handle_request(self, request: HttpParser) -> None: - unique_req_id = self.get_unique_id() - with logging_context(req_id=unique_req_id): - self.handle_request_impl(request) - self.info("Request processed") - - @staticmethod - def get_unique_id(): - return hashlib.md5((time.time_ns()).to_bytes(16, 'big')).hexdigest()[:7] - - def handle_request_impl(self, request: HttpParser) -> None: - if request.method == b'OPTIONS': - self.client.queue(memoryview(build_http_response( - httpStatusCodes.OK, body=None, - headers={ - b'Access-Control-Allow-Origin': b'*', - b'Access-Control-Allow-Methods': b'POST, GET, OPTIONS', - b'Access-Control-Allow-Headers': b'Content-Type', - b'Access-Control-Max-Age': b'86400' - }))) - return - start_time = time.time() - - try: - self.info('handle_request <<< %s 0x%x %s', threading.get_ident(), id(self.model), - request.body.decode('utf8')) - request = json.loads(request.body) - if isinstance(request, list): - response = [] - if len(request) == 0: - raise Exception("Empty batch request") - for r in request: - response.append(self.process_request(r)) - elif isinstance(request, dict): - response = self.process_request(request) - else: - raise Exception("Invalid request") - except Exception as err: - # traceback.print_exc() - response = {'jsonrpc': '2.0', 'error': {'code': -32000, 'message': str(err)}} - - resp_time_ms = (time.time() - start_time)*1000 # convert this into milliseconds - - method = '---' - if isinstance(request, dict): - method = request.get('method', '---') - - self.info('handle_request >>> %s 0x%0x %s %s resp_time_ms= %s', - threading.get_ident(), - id(self.model), - json.dumps(response), - method, - resp_time_ms) - - self.client.queue(memoryview(build_http_response( - httpStatusCodes.OK, body=json.dumps(response).encode('utf8'), - headers={ - b'Content-Type': b'application/json', - b'Access-Control-Allow-Origin': b'*', - }))) - - self._stat_exporter.stat_commit_request_and_timeout(method, resp_time_ms) - - def on_websocket_open(self) -> None: - pass - - def on_websocket_message(self, frame: WebsocketFrame) -> None: - pass - - def on_websocket_close(self) -> None: - pass diff --git a/proxy/common_neon/transaction_sender.py b/proxy/neon_rpc_api_model/transaction_sender.py similarity index 98% rename from proxy/common_neon/transaction_sender.py rename to proxy/neon_rpc_api_model/transaction_sender.py index d2a8c007d..40dbea714 100644 --- a/proxy/common_neon/transaction_sender.py +++ b/proxy/neon_rpc_api_model/transaction_sender.py @@ -20,15 +20,14 @@ from solana.blockhash import Blockhash from solana.account import Account as SolanaAccount -from .address import accountWithSeed, EthereumAddress, ether2program -from .compute_budget import TransactionWithComputeBudget -from .constants import STORAGE_SIZE, EMPTY_STORAGE_TAG, FINALIZED_STORAGE_TAG, ACTIVE_STORAGE_TAG, ACCOUNT_SEED_VERSION -from .emulator_interactor import call_emulated -from .neon_instruction import NeonInstruction as NeonIxBuilder -from .solana_interactor import SolanaInteractor -from .solana_tx_list_sender import SolTxListSender -from .solana_receipt_parser import SolTxError, SolReceiptParser -from .transaction_validator import NeonTxValidator +from ..common_neon.address import accountWithSeed, EthereumAddress, ether2program +from ..common_neon.compute_budget import TransactionWithComputeBudget +from ..common_neon.constants import STORAGE_SIZE, EMPTY_STORAGE_TAG, FINALIZED_STORAGE_TAG, ACTIVE_STORAGE_TAG, ACCOUNT_SEED_VERSION +from ..common_neon.emulator_interactor import call_emulated +from ..common_neon.neon_instruction import NeonInstruction as NeonIxBuilder +from ..common_neon.solana_interactor import SolanaInteractor +from ..common_neon.solana_tx_list_sender import SolTxListSender +from ..common_neon.solana_receipt_parser import SolTxError, SolReceiptParser from ..common_neon.eth_proto import Trx as EthTx from ..common_neon.utils import NeonTxResultInfo, NeonTxInfo from ..common_neon.errors import EthereumError @@ -37,7 +36,9 @@ from ..environment import HOLDER_MSG_SIZE, CONTRACT_EXTRA_SPACE from ..memdb.memdb import MemDB, NeonPendingTxInfo from ..environment import get_solana_accounts -from proxy.common_neon.utils import get_holder_msg +from ..common_neon.utils import get_holder_msg + +from .transaction_validator import NeonTxValidator class NeonTxStage(metaclass=abc.ABCMeta): diff --git a/proxy/common_neon/transaction_validator.py b/proxy/neon_rpc_api_model/transaction_validator.py similarity index 93% rename from proxy/common_neon/transaction_validator.py rename to proxy/neon_rpc_api_model/transaction_validator.py index 3b8bcfeab..8612af592 100644 --- a/proxy/common_neon/transaction_validator.py +++ b/proxy/neon_rpc_api_model/transaction_validator.py @@ -1,15 +1,15 @@ from __future__ import annotations +from solana.account import Account as SolanaAccount from logged_groups import logged_group -from .eth_proto import Trx as EthTx -from .address import EthereumAddress -from .errors import EthereumError -from .account_whitelist import AccountWhitelist -from .solana_receipt_parser import SolReceiptParser -from .solana_interactor import SolanaInteractor -from .estimate import GasEstimate -from solana.account import Account as SolanaAccount +from ..common_neon.eth_proto import Trx as EthTx +from ..common_neon.address import EthereumAddress +from ..common_neon.errors import EthereumError +from ..common_neon.account_whitelist import AccountWhitelist +from ..common_neon.solana_receipt_parser import SolReceiptParser +from ..common_neon.solana_interactor import SolanaInteractor +from ..common_neon.estimate import GasEstimate from ..environment import ACCOUNT_PERMISSION_UPDATE_INT, CHAIN_ID diff --git a/proxy/plugin/__init__.py b/proxy/plugin/__init__.py index 5d931a199..cc1ee76c7 100644 --- a/proxy/plugin/__init__.py +++ b/proxy/plugin/__init__.py @@ -18,7 +18,7 @@ from .web_server_route import WebServerPlugin from .reverse_proxy import ReverseProxyPlugin from .proxy_pool import ProxyPoolPlugin -from .solana_rest_api import SolanaProxyPlugin +from .neon_rpc_api_plugin import NeonRpcApiPlugin __all__ = [ 'CacheResponsesPlugin', diff --git a/proxy/plugin/neon_rpc_api_plugin.py b/proxy/plugin/neon_rpc_api_plugin.py new file mode 100644 index 000000000..c7b3083b7 --- /dev/null +++ b/proxy/plugin/neon_rpc_api_plugin.py @@ -0,0 +1,181 @@ +# -*- coding: utf-8 -*- +""" + proxy.py + ~~~~~~~~ + ⚡⚡⚡ Fast, Lightweight, Pluggable, TLS interception capable proxy server focused on + Network monitoring, controls & Application development, testing, debugging. + + :copyright: (c) 2013-present by Abhinav Singh and contributors. + :license: BSD, see LICENSE for more details. +""" +import json +import threading +import traceback +import time +import hashlib +from typing import List, Tuple + +from logged_groups import logged_group, logging_context + +from ..common.utils import build_http_response +from ..http.codes import httpStatusCodes +from ..http.parser import HttpParser +from ..http.websocket import WebsocketFrame +from ..http.server import HttpWebServerBasePlugin, httpProtocolTypes +from ..common_neon.solana_receipt_parser import SolTxError +from ..common_neon.errors import EthereumError +from ..environment import ENABLE_PRIVATE_API +from ..neon_rpc_api_model import NeonRpcApiModel +from ..statistics_exporter.prometheus_proxy_exporter import PrometheusExporter + +modelInstanceLock = threading.Lock() +modelInstance = None + + +@logged_group("neon.Proxy") +class NeonRpcApiPlugin(HttpWebServerBasePlugin): + """Extend in-built Web Server to add Reverse Proxy capabilities. + """ + + SOLANA_PROXY_LOCATION: str = r'/solana$' + SOLANA_PROXY_PASS = [ + b'http://localhost:8545/' + ] + + def __init__(self, *args): + HttpWebServerBasePlugin.__init__(self, *args) + self._stat_exporter = PrometheusExporter() + self.model = NeonRpcApiPlugin.getModel() + self.model.set_stat_exporter(self._stat_exporter) + + @classmethod + def getModel(cls): + global modelInstanceLock + global modelInstance + with modelInstanceLock: + if modelInstance is None: + modelInstance = NeonRpcApiModel() + return modelInstance + + def routes(self) -> List[Tuple[int, str]]: + return [ + (httpProtocolTypes.HTTP, NeonRpcApiPlugin.SOLANA_PROXY_LOCATION), + (httpProtocolTypes.HTTPS, NeonRpcApiPlugin.SOLANA_PROXY_LOCATION) + ] + + def process_request(self, request): + response = { + 'jsonrpc': '2.0', + 'id': request.get('id', None), + } + + def is_private_api(method_name: str) -> bool: + for prefix in ('eth_', 'net_', 'web3_', 'neon_'): + if method_name.startswith(prefix): + break + else: + return True + + if ENABLE_PRIVATE_API: + return False + + private_method_map = ( + "eth_accounts", + "eth_sign", + "eth_sendTransaction", + "eth_signTransaction", + ) + return method_name in private_method_map + + try: + if (not hasattr(self.model, request['method'])) or is_private_api(request["method"]): + response['error'] = {'code': -32601, 'message': f'method {request["method"]} is not supported'} + else: + method = getattr(self.model, request['method']) + params = request.get('params', []) + response['result'] = method(*params) + except SolTxError as err: + # traceback.print_exc() + response['error'] = {'code': -32000, 'message': err.error} + except EthereumError as err: + # traceback.print_exc() + response['error'] = err.getError() + except Exception as err: + err_tb = "".join(traceback.format_tb(err.__traceback__)) + self.error('Exception on process request. ' + + f'Type(err): {type(err)}, Error: {err}, Traceback: {err_tb}') + response['error'] = {'code': -32000, 'message': str(err)} + + return response + + def handle_request(self, request: HttpParser) -> None: + unique_req_id = self.get_unique_id() + with logging_context(req_id=unique_req_id): + self.handle_request_impl(request) + self.info("Request processed") + + @staticmethod + def get_unique_id(): + return hashlib.md5((time.time_ns()).to_bytes(16, 'big')).hexdigest()[:7] + + def handle_request_impl(self, request: HttpParser) -> None: + if request.method == b'OPTIONS': + self.client.queue(memoryview(build_http_response( + httpStatusCodes.OK, body=None, + headers={ + b'Access-Control-Allow-Origin': b'*', + b'Access-Control-Allow-Methods': b'POST, GET, OPTIONS', + b'Access-Control-Allow-Headers': b'Content-Type', + b'Access-Control-Max-Age': b'86400' + }))) + return + start_time = time.time() + + try: + self.info('handle_request <<< %s 0x%x %s', threading.get_ident(), id(self.model), + request.body.decode('utf8')) + request = json.loads(request.body) + if isinstance(request, list): + response = [] + if len(request) == 0: + raise Exception("Empty batch request") + for r in request: + response.append(self.process_request(r)) + elif isinstance(request, dict): + response = self.process_request(request) + else: + raise Exception("Invalid request") + except Exception as err: + # traceback.print_exc() + response = {'jsonrpc': '2.0', 'error': {'code': -32000, 'message': str(err)}} + + resp_time_ms = (time.time() - start_time)*1000 # convert this into milliseconds + + method = '---' + if isinstance(request, dict): + method = request.get('method', '---') + + self.info('handle_request >>> %s 0x%0x %s %s resp_time_ms= %s', + threading.get_ident(), + id(self.model), + json.dumps(response), + method, + resp_time_ms) + + self.client.queue(memoryview(build_http_response( + httpStatusCodes.OK, body=json.dumps(response).encode('utf8'), + headers={ + b'Content-Type': b'application/json', + b'Access-Control-Allow-Origin': b'*', + }))) + + self._stat_exporter.stat_commit_request_and_timeout(method, resp_time_ms) + + def on_websocket_open(self) -> None: + pass + + def on_websocket_message(self, frame: WebsocketFrame) -> None: + pass + + def on_websocket_close(self) -> None: + pass diff --git a/proxy/run-proxy.sh b/proxy/run-proxy.sh index 206398105..81e574e4a 100755 --- a/proxy/run-proxy.sh +++ b/proxy/run-proxy.sh @@ -5,4 +5,4 @@ echo "$(date "+%F %X.%3N") I $(basename $0):${LINENO} $$ ${COMPONENT}:StartScrip source proxy/run-set-env.sh ${COMPONENT} echo "$(date "+%F %X.%3N") I $(basename $0):${LINENO} $$ ${COMPONENT}:StartScript {} run-proxy" -python3 -m proxy --hostname 0.0.0.0 --port 9090 --enable-web-server --plugins proxy.plugin.SolanaProxyPlugin $EXTRA_ARGS +python3 -m proxy --hostname 0.0.0.0 --port 9090 --enable-web-server --plugins proxy.plugin.NeonRpcApiPlugin $EXTRA_ARGS diff --git a/proxy/statistics_exporter/prometheus_proxy_server.py b/proxy/statistics_exporter/prometheus_proxy_server.py index aacb8ebe2..3c3f805f5 100644 --- a/proxy/statistics_exporter/prometheus_proxy_server.py +++ b/proxy/statistics_exporter/prometheus_proxy_server.py @@ -5,10 +5,10 @@ from multiprocessing import Process from prometheus_client import start_http_server -from proxy.common_neon.address import EthereumAddress -from proxy.common_neon.solana_interactor import SolanaInteractor -from proxy.environment import PP_SOLANA_URL, PYTH_MAPPING_ACCOUNT, SOLANA_URL, get_solana_accounts -from proxy.plugin.gas_price_calculator import GasPriceCalculator +from ..common_neon.address import EthereumAddress +from ..common_neon.solana_interactor import SolanaInteractor +from ..environment import PP_SOLANA_URL, PYTH_MAPPING_ACCOUNT, SOLANA_URL, get_solana_accounts +from ..common_neon.gas_price_calculator import GasPriceCalculator from .prometheus_proxy_exporter import PrometheusExporter diff --git a/proxy/testing/test_gas_price_calculator.py b/proxy/testing/test_gas_price_calculator.py index 11afff335..d18d7b624 100644 --- a/proxy/testing/test_gas_price_calculator.py +++ b/proxy/testing/test_gas_price_calculator.py @@ -1,13 +1,12 @@ import unittest from solana.publickey import PublicKey -from proxy.indexer.pythnetwork import PythNetworkClient -from proxy.plugin.gas_price_calculator import GasPriceCalculator +from ..indexer.pythnetwork import PythNetworkClient +from ..common_neon.gas_price_calculator import GasPriceCalculator from solana.rpc.api import Client as SolanaClient from unittest.mock import patch, call, Mock from decimal import Decimal -from ..environment import NEON_PRICE_USD, OPERATOR_FEE, GET_SOL_PRICE_MAX_RETRIES, SOL_PRICE_UPDATE_INTERVAL, \ - MINIMAL_GAS_PRICE +from ..environment import NEON_PRICE_USD, OPERATOR_FEE, GET_SOL_PRICE_MAX_RETRIES, SOL_PRICE_UPDATE_INTERVAL MINIMAL_GAS_PRICE = None diff --git a/proxy/testing/test_neon_proxy_version.py b/proxy/testing/test_neon_proxy_version.py index c5ed29e40..6e272e823 100644 --- a/proxy/testing/test_neon_proxy_version.py +++ b/proxy/testing/test_neon_proxy_version.py @@ -4,7 +4,7 @@ import json import inspect -from proxy.plugin.solana_rest_api import NEON_PROXY_PKG_VERSION, NEON_PROXY_REVISION +from ..neon_rpc_api_model import NEON_PROXY_PKG_VERSION, NEON_PROXY_REVISION proxy_url = os.environ.get('PROXY_URL', 'http://localhost:9090/solana') headers = {'Content-type': 'application/json'} diff --git a/proxy/testing/test_solana_resp_api.py b/proxy/testing/test_neon_rpc_api.py similarity index 97% rename from proxy/testing/test_solana_resp_api.py rename to proxy/testing/test_neon_rpc_api.py index 6493235cc..ee4342af7 100644 --- a/proxy/testing/test_solana_resp_api.py +++ b/proxy/testing/test_neon_rpc_api.py @@ -1,13 +1,13 @@ import unittest from logged_groups import logged_group -from ..plugin.solana_rest_api import EthereumModel +from ..neon_rpc_api_model import NeonRpcApiModel @logged_group("neon.TestCases") class SolanaContractTests(unittest.TestCase): def setUp(self): - self.model = EthereumModel() + self.model = NeonRpcApiModel() self.owner = '0xc1566af4699928fdf9be097ca3dc47ece39f8f8e' self.token1 = '0x49a449cd7fd8fbcf34d103d98f2c05245020e35b' diff --git a/proxy/testing/test_neon_tx_sender.py b/proxy/testing/test_neon_tx_sender.py index 21c378470..48355a144 100644 --- a/proxy/testing/test_neon_tx_sender.py +++ b/proxy/testing/test_neon_tx_sender.py @@ -5,7 +5,7 @@ from unittest.mock import Mock from ..common_neon.eth_proto import Trx as EthTrx -from ..common_neon.transaction_sender import NeonTxSender +from ..neon_rpc_api_model.transaction_sender import NeonTxSender from ..common_neon.solana_interactor import SolanaInteractor from ..memdb.memdb import MemDB