|
14 | 14 |
|
15 | 15 | import requests
|
16 | 16 |
|
| 17 | +from ethereum_test_exceptions import ( |
| 18 | + EOFException, |
| 19 | + ExceptionMapper, |
| 20 | + ExceptionMessage, |
| 21 | + TransactionException, |
| 22 | +) |
17 | 23 | from ethereum_test_forks import Fork
|
18 | 24 | from ethereum_test_types import Alloc, Environment, Transaction
|
19 | 25 |
|
@@ -41,7 +47,7 @@ def __init__(
|
41 | 47 | binary: Optional[Path] = None,
|
42 | 48 | trace: bool = False,
|
43 | 49 | ):
|
44 |
| - super().__init__(binary=binary, trace=trace) |
| 50 | + super().__init__(exception_mapper=BesuExceptionMapper(), binary=binary, trace=trace) |
45 | 51 | args = [str(self.binary), "t8n", "--help"]
|
46 | 52 | try:
|
47 | 53 | result = subprocess.run(args, capture_output=True, text=True)
|
@@ -201,3 +207,137 @@ def is_fork_supported(self, fork: Fork) -> bool:
|
201 | 207 | Returns True if the fork is supported by the tool
|
202 | 208 | """
|
203 | 209 | return fork.transition_tool_name() in self.help_string
|
| 210 | + |
| 211 | + |
| 212 | +class BesuExceptionMapper(ExceptionMapper): |
| 213 | + """ |
| 214 | + Translate between EEST exceptions and error strings returned by nimbus. |
| 215 | + """ |
| 216 | + |
| 217 | + @property |
| 218 | + def _mapping_data(self): |
| 219 | + return [ |
| 220 | + ExceptionMessage( |
| 221 | + TransactionException.TYPE_4_TX_CONTRACT_CREATION, |
| 222 | + "set code transaction must not be a create transaction", |
| 223 | + ), |
| 224 | + ExceptionMessage( |
| 225 | + TransactionException.INSUFFICIENT_ACCOUNT_FUNDS, |
| 226 | + "exceeds transaction sender account balance", |
| 227 | + ), |
| 228 | + ExceptionMessage( |
| 229 | + TransactionException.TYPE_3_TX_MAX_BLOB_GAS_ALLOWANCE_EXCEEDED, |
| 230 | + "would exceed block maximum", |
| 231 | + ), |
| 232 | + ExceptionMessage( |
| 233 | + TransactionException.INSUFFICIENT_MAX_FEE_PER_BLOB_GAS, |
| 234 | + "max fee per blob gas less than block blob gas fee", |
| 235 | + ), |
| 236 | + ExceptionMessage( |
| 237 | + TransactionException.INSUFFICIENT_MAX_FEE_PER_GAS, |
| 238 | + "gasPrice is less than the current BaseFee", |
| 239 | + ), |
| 240 | + ExceptionMessage( |
| 241 | + TransactionException.TYPE_3_TX_PRE_FORK, |
| 242 | + "Transaction type BLOB is invalid, accepted transaction types are [EIP1559, ACCESS_LIST, FRONTIER]", # noqa: E501 |
| 243 | + ), |
| 244 | + ExceptionMessage( |
| 245 | + TransactionException.TYPE_3_TX_INVALID_BLOB_VERSIONED_HASH, |
| 246 | + "Only supported hash version is 0x01, sha256 hash.", |
| 247 | + ), |
| 248 | + # This message is the same as TYPE_3_TX_MAX_BLOB_GAS_ALLOWANCE_EXCEEDED |
| 249 | + ExceptionMessage( |
| 250 | + TransactionException.TYPE_3_TX_BLOB_COUNT_EXCEEDED, |
| 251 | + "exceed block maximum", |
| 252 | + ), |
| 253 | + ExceptionMessage( |
| 254 | + TransactionException.TYPE_3_TX_ZERO_BLOBS, |
| 255 | + "Blob transaction must have at least one versioned hash", |
| 256 | + ), |
| 257 | + ExceptionMessage( |
| 258 | + TransactionException.INTRINSIC_GAS_TOO_LOW, |
| 259 | + "intrinsic gas too low", |
| 260 | + ), |
| 261 | + ExceptionMessage( |
| 262 | + TransactionException.INITCODE_SIZE_EXCEEDED, |
| 263 | + "max initcode size exceeded", |
| 264 | + ), |
| 265 | + # TODO EVMONE needs to differentiate when the section is missing in the header or body |
| 266 | + ExceptionMessage(EOFException.MISSING_STOP_OPCODE, "err: no_terminating_instruction"), |
| 267 | + ExceptionMessage(EOFException.MISSING_CODE_HEADER, "err: code_section_missing"), |
| 268 | + ExceptionMessage(EOFException.MISSING_TYPE_HEADER, "err: type_section_missing"), |
| 269 | + # TODO EVMONE these exceptions are too similar, this leeds to ambiguity |
| 270 | + ExceptionMessage(EOFException.MISSING_TERMINATOR, "err: header_terminator_missing"), |
| 271 | + ExceptionMessage( |
| 272 | + EOFException.MISSING_HEADERS_TERMINATOR, "err: section_headers_not_terminated" |
| 273 | + ), |
| 274 | + ExceptionMessage(EOFException.INVALID_VERSION, "err: eof_version_unknown"), |
| 275 | + ExceptionMessage( |
| 276 | + EOFException.INVALID_NON_RETURNING_FLAG, "err: invalid_non_returning_flag" |
| 277 | + ), |
| 278 | + ExceptionMessage(EOFException.INVALID_MAGIC, "err: invalid_prefix"), |
| 279 | + ExceptionMessage( |
| 280 | + EOFException.INVALID_FIRST_SECTION_TYPE, "err: invalid_first_section_type" |
| 281 | + ), |
| 282 | + ExceptionMessage( |
| 283 | + EOFException.INVALID_SECTION_BODIES_SIZE, "err: invalid_section_bodies_size" |
| 284 | + ), |
| 285 | + ExceptionMessage( |
| 286 | + EOFException.INVALID_TYPE_SECTION_SIZE, "err: invalid_type_section_size" |
| 287 | + ), |
| 288 | + ExceptionMessage(EOFException.INCOMPLETE_SECTION_SIZE, "err: incomplete_section_size"), |
| 289 | + ExceptionMessage( |
| 290 | + EOFException.INCOMPLETE_SECTION_NUMBER, "err: incomplete_section_number" |
| 291 | + ), |
| 292 | + ExceptionMessage(EOFException.TOO_MANY_CODE_SECTIONS, "err: too_many_code_sections"), |
| 293 | + ExceptionMessage(EOFException.ZERO_SECTION_SIZE, "err: zero_section_size"), |
| 294 | + ExceptionMessage(EOFException.MISSING_DATA_SECTION, "err: data_section_missing"), |
| 295 | + ExceptionMessage(EOFException.UNDEFINED_INSTRUCTION, "err: undefined_instruction"), |
| 296 | + ExceptionMessage( |
| 297 | + EOFException.INPUTS_OUTPUTS_NUM_ABOVE_LIMIT, "err: inputs_outputs_num_above_limit" |
| 298 | + ), |
| 299 | + ExceptionMessage( |
| 300 | + EOFException.UNREACHABLE_INSTRUCTIONS, "err: unreachable_instructions" |
| 301 | + ), |
| 302 | + ExceptionMessage( |
| 303 | + EOFException.INVALID_RJUMP_DESTINATION, "err: invalid_rjump_destination" |
| 304 | + ), |
| 305 | + ExceptionMessage( |
| 306 | + EOFException.UNREACHABLE_CODE_SECTIONS, "err: unreachable_code_sections" |
| 307 | + ), |
| 308 | + ExceptionMessage(EOFException.STACK_UNDERFLOW, "err: stack_underflow"), |
| 309 | + ExceptionMessage( |
| 310 | + EOFException.MAX_STACK_HEIGHT_ABOVE_LIMIT, "err: max_stack_height_above_limit" |
| 311 | + ), |
| 312 | + ExceptionMessage( |
| 313 | + EOFException.STACK_HIGHER_THAN_OUTPUTS, "err: stack_higher_than_outputs_required" |
| 314 | + ), |
| 315 | + ExceptionMessage( |
| 316 | + EOFException.JUMPF_DESTINATION_INCOMPATIBLE_OUTPUTS, |
| 317 | + "err: jumpf_destination_incompatible_outputs", |
| 318 | + ), |
| 319 | + ExceptionMessage( |
| 320 | + EOFException.INVALID_MAX_STACK_HEIGHT, "err: invalid_max_stack_height" |
| 321 | + ), |
| 322 | + ExceptionMessage(EOFException.INVALID_DATALOADN_INDEX, "err: invalid_dataloadn_index"), |
| 323 | + ExceptionMessage(EOFException.TRUNCATED_INSTRUCTION, "err: truncated_instruction"), |
| 324 | + ExceptionMessage( |
| 325 | + EOFException.TOPLEVEL_CONTAINER_TRUNCATED, "err: toplevel_container_truncated" |
| 326 | + ), |
| 327 | + ExceptionMessage(EOFException.ORPHAN_SUBCONTAINER, "err: unreferenced_subcontainer"), |
| 328 | + ExceptionMessage( |
| 329 | + EOFException.CONTAINER_SIZE_ABOVE_LIMIT, "err: container_size_above_limit" |
| 330 | + ), |
| 331 | + ExceptionMessage( |
| 332 | + EOFException.INVALID_CONTAINER_SECTION_INDEX, |
| 333 | + "err: invalid_container_section_index", |
| 334 | + ), |
| 335 | + ExceptionMessage( |
| 336 | + EOFException.INCOMPATIBLE_CONTAINER_KIND, "err: incompatible_container_kind" |
| 337 | + ), |
| 338 | + ExceptionMessage(EOFException.STACK_HEIGHT_MISMATCH, "err: stack_height_mismatch"), |
| 339 | + ExceptionMessage(EOFException.TOO_MANY_CONTAINERS, "err: too_many_container_sections"), |
| 340 | + ExceptionMessage( |
| 341 | + EOFException.INVALID_CODE_SECTION_INDEX, "err: invalid_code_section_index" |
| 342 | + ), |
| 343 | + ] |
0 commit comments