Skip to content

Commit

Permalink
added some logs
Browse files Browse the repository at this point in the history
  • Loading branch information
AnastasiyaTarasova committed Nov 29, 2024
1 parent 2650b23 commit 6e93be4
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 1 deletion.
10 changes: 10 additions & 0 deletions common/http/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ async def _send_client_request(

request.path = path
request.header_dict = self._header_dict

_LOG.info("_send_client_request, self._header_dict = %v", self._header_dict)
return await _send_client_request(self, base_url_list, request)

def _exception_handler(self, url: HttpURL, request: HttpClientRequest, retry: int, exc: BaseException) -> None:
Expand Down Expand Up @@ -185,11 +187,19 @@ async def _send_client_request(self: HttpClient, base_url_list: Sequence[HttpURL
try:
if request.data:
resp = await self.session.post(request_url.value, data=request.data, headers=request.header_dict)
_LOG.info("self.session.post, request_url.value = %v", request_url.value)
_LOG.info("self.session.post, request.data = %v", request.data)
_LOG.info("self.session.post, request.header_dict = %v", request.header_dict)
else:
resp = await self.session.get(request_url.value, headers=request.header_dict)

_LOG.info("_send_client_request, resp.content = %v", resp.content)

if self._raise_for_status:
resp.raise_for_status()

respjson = await resp.json()
_LOG.info("_send_client_request, resp.json = %v", respjson)
return await resp.text()
except BaseException as exc:
# Can reraise exception inside
Expand Down
20 changes: 19 additions & 1 deletion common/neon_rpc/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ async def get_state_tx_cnt(self, account: NeonAccount, block: NeonBlockHdrModel
async def get_neon_contract(self, account: NeonAccount, block: NeonBlockHdrModel | None) -> NeonContractModel:
req = NeonContractRequest(contract=account.eth_address, slot=self._get_slot(block))
resp: CoreApiResp = await self._send_request("contract", req)
_LOG.info("emulate_neon_call, resp = %v", resp)
return NeonContractModel.from_dict(resp.value[0], account=account)

async def get_storage_at(self, contract: EthAddress, index: int, block: NeonBlockHdrModel | None) -> EthHash32:
Expand Down Expand Up @@ -273,7 +274,11 @@ async def emulate_neon_call(
sol_account_dict=emul_sol_acct_dict,
slot=self._get_slot(block),
)
_LOG.info("emulate_neon_call, req = %+v", req)

resp: EmulNeonCallResp = await self._send_request("emulate", req, EmulNeonCallResp)
_LOG.info("emulate_neon_call, resp = %v", resp)

if check_result:
self._check_emulator_result(resp)
return resp
Expand Down Expand Up @@ -309,6 +314,8 @@ async def _send_request(
method=method,
)

_LOG.info("_send_request, request = %v", request)

with request:
for retry in itertools.count():
if retry >= self._max_retry_cnt:
Expand All @@ -318,8 +325,10 @@ async def _send_request(

request.start_timer()
resp_json = await self._send_client_request(request, path=HttpURL(method))
_LOG.info("_send_request, resp_json = %v", resp_json)
try:
resp = CoreApiResp.from_json(resp_json)
_LOG.info("_send_request, CoreApiResp.from_json resp.result = %v", resp.result)

except PydanticValidationError as exc:
_LOG.debug("bad response from neon-core-api", exc_info=exc, extra=self._msg_filter)
Expand All @@ -337,7 +346,16 @@ async def _send_request(
elif resp.error:
raise EthError(resp.error)

return resp_type.from_dict(resp.value)
_LOG.info("_send_request, resp.value = %v", resp.value)
_LOG.info("_send_request, resp.result = %v", resp.result) #0x
_LOG.info("_send_request, resp.error = %v", resp.error)
_LOG.info("_send_request, resp.error_code = %v", resp.error_code)
_LOG.info("_send_request, resp.logs = %v", resp.logs)

_LOG.info("_send_request, resp_type = %v", resp_type)
result = resp_type.from_dict(resp.value)
_LOG.info("_send_request, resp_type.from_dict(resp.value) = %v", result)
return result

@ttl_cached_method(ttl_sec=60)
async def _get_evm_exec_addr(self) -> SolPubKey:
Expand Down
3 changes: 3 additions & 0 deletions common/utils/pydantic.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@

from .cached import cached_method, cached_property, reset_cached_method
from .format import hex_to_uint, str_fmt_object
import logging

_LOG = logging.getLogger(__name__)

class BaseModel(_PydanticBaseModel):
model_config = ConfigDict(
Expand All @@ -32,6 +34,7 @@ def __deepcopy__(self, memo: dict[int, Any] | None = None) -> Self:

@classmethod
def from_json(cls, json_data: str) -> Self:
_LOG.info("BaseModel, from_json = %v", json_data)
return cls.model_validate_json(json_data)

@classmethod
Expand Down
6 changes: 6 additions & 0 deletions proxy/rpc/np_call_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
from .server_abc import NeonProxyApi
from ..base.rpc_api import RpcEthTxRequest
from ..base.rpc_gas_limit_calculator import RpcNeonGasLimitCalculator
import logging

_LOG = logging.getLogger(__name__)

class _RpcEthAccountModel(BaseJsonRpcModel):
nonce: HexUIntField = Field(0)
Expand Down Expand Up @@ -109,14 +111,18 @@ async def eth_call(
) -> EthBinStrField:
_ = object_state
chain_id = self._get_tx_chain_id(ctx, tx)
_LOG.info("eth_call, chain_id = %d", chain_id)
block = await self.get_block_by_tag(block_tag)
_LOG.info("eth_call, block.slot = %d", block.slot)
evm_cfg = await self._get_evm_cfg()
resp = await self._core_api_client.emulate_neon_call(
evm_cfg,
tx.to_core_tx(chain_id),
check_result=True,
block=block,
)
_LOG.info("eth_call, resp.result = %d", resp.result)
_LOG.info("eth_call, resp.result = %d", resp.result)
return resp.result

@NeonProxyApi.method(name="eth_estimateGas")
Expand Down

0 comments on commit 6e93be4

Please sign in to comment.