Ethereum Test Types package¶
Common definitions and types.
EOA
¶
Bases: Address
An Externally Owned Account (EOA) is an account controlled by a private key.
The EOA is defined by its address and (optionally) by its corresponding private key.
Source code in src/ethereum_test_types/account_types.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
|
__new__(address=None, *, key=None, nonce=0)
¶
Init the EOA.
Source code in src/ethereum_test_types/account_types.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
|
get_nonce()
¶
Return current nonce of the EOA and increments it by one.
Source code in src/ethereum_test_types/account_types.py
63 64 65 66 67 |
|
copy()
¶
Return copy of the EOA.
Source code in src/ethereum_test_types/account_types.py
69 70 71 |
|
Alloc
¶
Bases: Alloc
Allocation of accounts in the state, pre and post test execution.
Source code in src/ethereum_test_types/account_types.py
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 |
|
UnexpectedAccountError
dataclass
¶
Bases: Exception
Unexpected account found in the allocation.
Source code in src/ethereum_test_types/account_types.py
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
|
__init__(address, account, *args)
¶
Initialize the exception.
Source code in src/ethereum_test_types/account_types.py
86 87 88 89 90 |
|
__str__()
¶
Print exception string.
Source code in src/ethereum_test_types/account_types.py
92 93 94 |
|
MissingAccountError
dataclass
¶
Bases: Exception
Expected account not found in the allocation.
Source code in src/ethereum_test_types/account_types.py
96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
|
__init__(address, *args)
¶
Initialize the exception.
Source code in src/ethereum_test_types/account_types.py
102 103 104 105 |
|
__str__()
¶
Print exception string.
Source code in src/ethereum_test_types/account_types.py
107 108 109 |
|
merge(alloc_1, alloc_2, allow_key_collision=True)
classmethod
¶
Return merged allocation of two sources.
Source code in src/ethereum_test_types/account_types.py
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
|
__iter__()
¶
Return iterator over the allocation.
Source code in src/ethereum_test_types/account_types.py
132 133 134 |
|
items()
¶
Return iterator over the allocation items.
Source code in src/ethereum_test_types/account_types.py
136 137 138 |
|
__getitem__(address)
¶
Return account associated with an address.
Source code in src/ethereum_test_types/account_types.py
140 141 142 143 144 |
|
__setitem__(address, account)
¶
Set account associated with an address.
Source code in src/ethereum_test_types/account_types.py
146 147 148 149 150 |
|
__delitem__(address)
¶
Delete account associated with an address.
Source code in src/ethereum_test_types/account_types.py
152 153 154 155 156 |
|
__eq__(other)
¶
Return True if both allocations are equal.
Source code in src/ethereum_test_types/account_types.py
158 159 160 161 162 |
|
__contains__(address)
¶
Check if an account is in the allocation.
Source code in src/ethereum_test_types/account_types.py
164 165 166 167 168 |
|
empty_accounts()
¶
Return list of addresses of empty accounts.
Source code in src/ethereum_test_types/account_types.py
170 171 172 |
|
state_root()
¶
Return state root of the allocation.
Source code in src/ethereum_test_types/account_types.py
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 |
|
verify_post_alloc(got_alloc)
¶
Verify that the allocation matches the expected post in the test. Raises exception on unexpected values.
Source code in src/ethereum_test_types/account_types.py
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 |
|
deploy_contract(code, *, storage=None, balance=0, nonce=1, address=None, evm_code_type=None, label=None)
¶
Deploy a contract to the allocation.
Source code in src/ethereum_test_types/account_types.py
219 220 221 222 223 224 225 226 227 228 229 230 231 |
|
fund_eoa(amount=None, label=None, storage=None, delegation=None, nonce=None)
¶
Add a previously unused EOA to the pre-alloc with the balance specified by amount
.
Source code in src/ethereum_test_types/account_types.py
233 234 235 236 237 238 239 240 241 242 |
|
fund_address(address, amount)
¶
Fund an address with a given amount.
If the address is already present in the pre-alloc the amount will be added to its existing balance.
Source code in src/ethereum_test_types/account_types.py
244 245 246 247 248 249 250 251 |
|
empty_account()
¶
Return a previously unused account guaranteed to be empty.
This ensures the account has zero balance, zero nonce, no code, and no storage. The account is not a precompile or a system contract.
Source code in src/ethereum_test_types/account_types.py
253 254 255 256 257 258 259 260 |
|
Environment
¶
Bases: EnvironmentGeneric[ZeroPaddedHexNumber]
Structure used to keep track of the context in which a block must be executed.
Source code in src/ethereum_test_types/block_types.py
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 |
|
parent_hash: Hash | None
cached
property
¶
Obtains the latest hash according to the highest block number in
block_hashes
.
set_fork_requirements(fork)
¶
Fill required fields in an environment depending on the fork.
Source code in src/ethereum_test_types/block_types.py
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
|
__hash__()
¶
Hashes the environment object.
Source code in src/ethereum_test_types/block_types.py
177 178 179 180 181 182 183 184 185 |
|
__eq__(other)
¶
Check if two environment objects are equal.
Source code in src/ethereum_test_types/block_types.py
187 188 189 190 191 192 193 194 195 196 197 198 |
|
EnvironmentDefaults
dataclass
¶
Default environment values.
Source code in src/ethereum_test_types/block_types.py
31 32 33 34 35 36 37 38 |
|
Withdrawal
¶
Bases: WithdrawalGeneric[HexNumber]
Withdrawal type.
Source code in src/ethereum_test_types/block_types.py
70 71 72 73 |
|
TestParameterGroup
¶
Bases: BaseModel
Base class for grouping test parameters in a dataclass. Provides a generic repr method to generate clean test ids, including only non-default optional fields.
Source code in src/ethereum_test_types/helpers.py
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
|
__repr__()
¶
Generate repr string, intended to be used as a test id, based on the class name and the values of the non-default optional fields.
Source code in src/ethereum_test_types/helpers.py
107 108 109 110 111 112 113 114 115 116 117 118 119 |
|
add_kzg_version(b_hashes, kzg_version)
¶
Add Kzg Version to each blob hash.
Source code in src/ethereum_test_types/helpers.py
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
|
ceiling_division(a, b)
¶
Calculate ceil without using floating point. Used by many of the EVM's formulas.
Source code in src/ethereum_test_types/helpers.py
20 21 22 23 24 25 |
|
compute_create2_address(address, salt, initcode)
¶
Compute address of the resulting contract created using the CREATE2
opcode.
Source code in src/ethereum_test_types/helpers.py
55 56 57 58 59 60 61 62 63 64 65 |
|
compute_create_address(*, address, nonce=None, salt=0, initcode=b'', opcode=Op.CREATE)
¶
Compute address of the resulting contract created using a transaction
or the CREATE
opcode.
Source code in src/ethereum_test_types/helpers.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
|
compute_eofcreate_address(address, salt)
¶
Compute address of the resulting contract created using the EOFCREATE
opcode.
Source code in src/ethereum_test_types/helpers.py
68 69 70 71 72 73 |
|
TransactionReceipt
¶
Bases: CamelModel
Transaction receipt.
Source code in src/ethereum_test_types/receipt_types.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
|
ConsolidationRequest
¶
Bases: RequestBase
, CamelModel
Consolidation Request type.
Source code in src/ethereum_test_types/request_types.py
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
|
source_address: Address = Address(0)
class-attribute
instance-attribute
¶
The address of the execution layer account that made the consolidation request.
source_pubkey: BLSPublicKey
instance-attribute
¶
The public key of the source validator as it currently is in the beacon state.
target_pubkey: BLSPublicKey
instance-attribute
¶
The public key of the target validator as it currently is in the beacon state.
__bytes__()
¶
Return consolidation's attributes as bytes.
Source code in src/ethereum_test_types/request_types.py
112 113 114 |
|
DepositRequest
¶
Bases: RequestBase
, CamelModel
Deposit Request type.
Source code in src/ethereum_test_types/request_types.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
|
pubkey: BLSPublicKey
instance-attribute
¶
The public key of the beacon chain validator.
withdrawal_credentials: Hash
instance-attribute
¶
The withdrawal credentials of the beacon chain validator.
amount: HexNumber
instance-attribute
¶
The amount in gwei of the deposit.
signature: BLSSignature
instance-attribute
¶
The signature of the deposit using the validator's private key that matches the
pubkey
.
index: HexNumber
instance-attribute
¶
The index of the deposit.
__bytes__()
¶
Return deposit's attributes as bytes.
Source code in src/ethereum_test_types/request_types.py
56 57 58 59 60 61 62 63 64 |
|
Requests
¶
Requests for the transition tool.
Source code in src/ethereum_test_types/request_types.py
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
|
__init__(*requests, requests_lists=None)
¶
Initialize requests object.
Source code in src/ethereum_test_types/request_types.py
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
|
__bytes__()
¶
Return requests hash.
Source code in src/ethereum_test_types/request_types.py
151 152 153 154 |
|
WithdrawalRequest
¶
Bases: RequestBase
, CamelModel
Withdrawal Request type.
Source code in src/ethereum_test_types/request_types.py
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
|
source_address: Address = Address(0)
class-attribute
instance-attribute
¶
The address of the execution layer account that made the withdrawal request.
validator_pubkey: BLSPublicKey
instance-attribute
¶
The current public key of the validator as it currently is in the beacon state.
amount: HexNumber
instance-attribute
¶
The amount in gwei to be withdrawn on the beacon chain.
__bytes__()
¶
Return withdrawal's attributes as bytes.
Source code in src/ethereum_test_types/request_types.py
85 86 87 88 89 90 91 |
|
AuthorizationTuple
¶
Bases: AuthorizationTupleGeneric[HexNumber]
Authorization tuple for transactions.
Source code in src/ethereum_test_types/transaction_types.py
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
|
model_post_init(__context)
¶
Automatically signs the authorization tuple if a secret key or sender are provided.
Source code in src/ethereum_test_types/transaction_types.py
106 107 108 109 |
|
sign()
¶
Signs the authorization tuple with a private key.
Source code in src/ethereum_test_types/transaction_types.py
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
|
Blob
¶
Bases: CamelModel
Class representing a full blob.
Source code in src/ethereum_test_types/blob_types.py
9 10 11 12 13 14 15 16 17 18 19 |
|
versioned_hash(version=1)
¶
Calculate versioned hash for a given blob.
Source code in src/ethereum_test_types/blob_types.py
17 18 19 |
|
NetworkWrappedTransaction
¶
Bases: CamelModel
, RLPSerializable
Network wrapped transaction as defined in EIP-4844.
Source code in src/ethereum_test_types/transaction_types.py
651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 |
|
blob_data: Sequence[Bytes]
property
¶
Return a list of blobs as bytes.
blob_kzg_commitments: Sequence[Bytes]
property
¶
Return a list of kzg commitments.
blob_kzg_proofs: Sequence[Bytes]
property
¶
Return a list of kzg proofs.
get_rlp_fields()
¶
Return an ordered list of field names to be included in RLP serialization.
Function can be overridden to customize the logic to return the fields.
By default, rlp_fields class variable is used.
The list can be nested list up to one extra level to represent nested fields.
Source code in src/ethereum_test_types/transaction_types.py
685 686 687 688 689 690 691 692 693 694 695 696 697 698 |
|
get_rlp_prefix()
¶
Return the transaction type as bytes to be appended at the beginning of the serialized transaction if type is not 0.
Source code in src/ethereum_test_types/transaction_types.py
700 701 702 703 704 705 706 707 |
|
Transaction
¶
Bases: TransactionGeneric[HexNumber]
, TransactionTransitionToolConverter
, SignableRLPSerializable
Generic object that can represent all Ethereum transaction types.
Source code in src/ethereum_test_types/transaction_types.py
233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 |
|
InvalidFeePaymentError
¶
Bases: Exception
Transaction described more than one fee payment type.
Source code in src/ethereum_test_types/transaction_types.py
257 258 259 260 261 262 |
|
__str__()
¶
Print exception string.
Source code in src/ethereum_test_types/transaction_types.py
260 261 262 |
|
InvalidSignaturePrivateKeyError
¶
Bases: Exception
Transaction describes both the signature and private key of source account.
Source code in src/ethereum_test_types/transaction_types.py
264 265 266 267 268 269 270 271 272 |
|
__str__()
¶
Print exception string.
Source code in src/ethereum_test_types/transaction_types.py
270 271 272 |
|
model_post_init(__context)
¶
Ensure transaction has no conflicting properties.
Source code in src/ethereum_test_types/transaction_types.py
274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 |
|
with_error(error)
¶
Create a copy of the transaction with an added error.
Source code in src/ethereum_test_types/transaction_types.py
345 346 347 348 349 |
|
with_nonce(nonce)
¶
Create a copy of the transaction with a modified nonce.
Source code in src/ethereum_test_types/transaction_types.py
351 352 353 |
|
signature_bytes: Bytes
cached
property
¶
Returns the serialized bytes of the transaction signature.
sign()
¶
Signs the authorization tuple with a private key.
Source code in src/ethereum_test_types/transaction_types.py
372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 |
|
with_signature_and_sender(*, keep_secret_key=False)
¶
Return signed version of the transaction using the private key.
Source code in src/ethereum_test_types/transaction_types.py
433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 |
|
get_rlp_signing_fields()
¶
Return the list of values included in the envelope used for signing depending on the transaction type.
Source code in src/ethereum_test_types/transaction_types.py
495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 |
|
get_rlp_fields()
¶
Return the list of values included in the list used for rlp encoding depending on the transaction type.
Source code in src/ethereum_test_types/transaction_types.py
584 585 586 587 588 589 590 591 592 |
|
get_rlp_prefix()
¶
Return the transaction type as bytes to be appended at the beginning of the serialized transaction if type is not 0.
Source code in src/ethereum_test_types/transaction_types.py
594 595 596 597 598 599 600 601 |
|
get_rlp_signing_prefix()
¶
Return the transaction type as bytes to be appended at the beginning of the serialized transaction signing envelope if type is not 0.
Source code in src/ethereum_test_types/transaction_types.py
603 604 605 606 607 608 609 610 |
|
hash: Hash
cached
property
¶
Returns hash of the transaction.
serializable_list: Any
cached
property
¶
Return list of values included in the transaction as a serializable object.
list_root(input_txs)
staticmethod
¶
Return transactions root of a list of transactions.
Source code in src/ethereum_test_types/transaction_types.py
622 623 624 625 626 627 628 |
|
list_blob_versioned_hashes(input_txs)
staticmethod
¶
Get list of ordered blob versioned hashes from a list of transactions.
Source code in src/ethereum_test_types/transaction_types.py
630 631 632 633 634 635 636 637 638 |
|
created_contract: Address
cached
property
¶
Return address of the contract created by the transaction.
TransactionDefaults
dataclass
¶
Default values for transactions.
Source code in src/ethereum_test_types/transaction_types.py
53 54 55 56 57 58 59 60 |
|
TransactionType
¶
Bases: IntEnum
Transaction types.
Source code in src/ethereum_test_types/transaction_types.py
43 44 45 46 47 48 49 50 |
|
Removable
¶
Sentinel class to detect if a parameter should be removed.
(None
normally means "do not modify").
Source code in src/ethereum_test_types/utils.py
22 23 24 25 26 27 28 29 30 31 32 |
|
__eq__(other)
¶
Return True for all Removable.
Source code in src/ethereum_test_types/utils.py
28 29 30 31 32 |
|
keccak256(data)
¶
Calculate keccak256 hash of the given data.
Source code in src/ethereum_test_types/utils.py
8 9 10 |
|