|
1 | 1 | """JSON-RPC methods and helper functions for EEST consume based hive simulators.""" |
2 | 2 |
|
| 3 | +import json |
3 | 4 | import time |
4 | 5 | from itertools import count |
5 | 6 | from pprint import pprint |
|
11 | 12 |
|
12 | 13 | from ethereum_test_base_types import Address, Bytes, Hash, to_json |
13 | 14 | from ethereum_test_types import Transaction |
| 15 | +from pytest_plugins.logging import get_logger |
14 | 16 |
|
15 | 17 | from .types import ( |
16 | 18 | ForkchoiceState, |
|
24 | 26 | ) |
25 | 27 |
|
26 | 28 | BlockNumberType = Union[int, Literal["latest", "earliest", "pending"]] |
| 29 | +logger = get_logger(__name__) |
27 | 30 |
|
28 | 31 |
|
29 | 32 | class SendTransactionExceptionError(Exception): |
@@ -94,6 +97,11 @@ def post_request(self, method: str, *params: Any, extra_headers: Dict | None = N |
94 | 97 | } |
95 | 98 | headers = base_header | self.extra_headers | extra_headers |
96 | 99 |
|
| 100 | + # debugging, estimate payload size |
| 101 | + payload_json = json.dumps(payload) # pydantic.json |
| 102 | + payload_size_mb = len(payload_json.encode("utf-8")) / (1024 * 1024) |
| 103 | + logger.info(f"I am about to send an RPC of approximated size: {payload_size_mb:.2f} MB") |
| 104 | + |
97 | 105 | response = requests.post(self.url, json=payload, headers=headers) |
98 | 106 | response.raise_for_status() |
99 | 107 | response_json = response.json() |
@@ -181,8 +189,9 @@ def gas_price(self) -> int: |
181 | 189 | def send_raw_transaction(self, transaction_rlp: Bytes) -> Hash: |
182 | 190 | """`eth_sendRawTransaction`: Send a transaction to the client.""" |
183 | 191 | try: |
184 | | - result_hash = Hash(self.post_request("sendRawTransaction", f"{transaction_rlp.hex()}")) |
185 | | - assert result_hash is not None |
| 192 | + tx_rlp_hex = transaction_rlp.hex() |
| 193 | + result_hash = Hash(self.post_request("sendRawTransaction", f"{tx_rlp_hex}")) |
| 194 | + assert result_hash is not None, "result_hash seems to be None, critical error!" |
186 | 195 | return result_hash |
187 | 196 | except Exception as e: |
188 | 197 | shortened_rlp_error_message = str(e) # signal in console that you don't see full rlp |
|
0 commit comments