Skip to content

Commit d33b90d

Browse files
committed
necessary changes to rename types.py to eest_types.py without breaking anything
1 parent c128049 commit d33b90d

File tree

13 files changed

+91
-113
lines changed

13 files changed

+91
-113
lines changed

src/cli/eofwrap.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
from ethereum_test_specs.eof import EOFParse
3333
from ethereum_test_tools import Opcodes as Op
3434
from ethereum_test_types import Transaction
35+
from ethereum_test_types.eest_types import Environment
3536
from ethereum_test_types.eof.v1 import Container
36-
from ethereum_test_types.types import Environment
3737
from ethereum_test_vm.bytecode import Bytecode
3838

3939

src/ethereum_test_fixtures/blockchain.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
)
3434
from ethereum_test_exceptions import EngineAPIError, ExceptionInstanceOrList
3535
from ethereum_test_forks import Fork, Paris
36-
from ethereum_test_types.types import (
36+
from ethereum_test_types.eest_types import (
3737
Transaction,
3838
TransactionFixtureConverter,
3939
TransactionGeneric,

src/ethereum_test_fixtures/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
SignableRLPSerializable,
1212
ZeroPaddedHexNumber,
1313
)
14-
from ethereum_test_types.types import Address, AuthorizationTupleGeneric
14+
from ethereum_test_types.eest_types import Address, AuthorizationTupleGeneric
1515

1616

1717
class FixtureForkBlobSchedule(CamelModel):

src/ethereum_test_fixtures/state.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
ZeroPaddedHexNumber,
1414
)
1515
from ethereum_test_exceptions import TransactionExceptionInstanceOrList
16-
from ethereum_test_types.types import (
16+
from ethereum_test_types.eest_types import (
1717
CamelModel,
1818
EnvironmentGeneric,
1919
Transaction,

src/ethereum_test_fixtures/transaction.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
from ethereum_test_base_types import Address, Bytes, Hash, ZeroPaddedHexNumber
88
from ethereum_test_exceptions import TransactionExceptionInstanceOrList
9-
from ethereum_test_types.types import CamelModel
9+
from ethereum_test_types.eest_types import CamelModel
1010

1111
from .base import BaseFixture
1212

src/ethereum_test_forks/forks/forks.py

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from hashlib import sha256
55
from os.path import realpath
66
from pathlib import Path
7-
from typing import List, Literal, Mapping, Optional, Sized, Tuple
7+
from typing import List, Mapping, Optional, Sized, Tuple
88

99
from semver import Version
1010

@@ -27,26 +27,6 @@
2727
CURRENT_FILE = Path(realpath(__file__))
2828
CURRENT_FOLDER = CURRENT_FILE.parent
2929

30-
# blob-related constants
31-
FIELD_ELEMENTS_PER_BLOB = 4096
32-
BYTES_PER_FIELD_ELEMENT = 32
33-
BYTES_PER_BLOB = FIELD_ELEMENTS_PER_BLOB * BYTES_PER_FIELD_ELEMENT # 131072
34-
CELL_LENGTH = 2048
35-
BLS_MODULUS = 0x73EDA753299D7D483339D80809A1D80553BDA402FFFE5BFEFFFFFFFF00000001 # EIP-2537: Main subgroup order = q # noqa: E501
36-
# due to BLS_MODULUS every blob byte (uint256) must be smaller than 116
37-
38-
# deneb constants that have not changed (https://github.com/ethereum/consensus-specs/blob/cc6996c22692d70e41b7a453d925172ee4b719ad/specs/deneb/polynomial-commitments.md?plain=1#L78)
39-
BYTES_PER_PROOF = 48
40-
BYTES_PER_COMMITMENT = 48
41-
KZG_ENDIANNESS: Literal["big"] = "big"
42-
43-
# eip-7691
44-
MAX_BLOBS_PER_BLOCK_ELECTRA = 9
45-
TARGET_BLOBS_PER_BLOCK_ELECTRA = 6
46-
MAX_BLOB_GAS_PER_BLOCK = 1179648
47-
TARGET_BLOB_GAS_PER_BLOCK = 786432
48-
BLOB_BASE_FEE_UPDATE_FRACTION_PRAGUE = 5007716
49-
5030

5131
# All forks must be listed here !!! in the order they were introduced !!!
5232
class Frontier(BaseFork, solc_name="homestead"):

src/ethereum_test_types/__init__.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,11 @@
11
"""Common definitions and types."""
22

3-
from .helpers import (
4-
TestParameterGroup,
5-
add_kzg_version,
6-
ceiling_division,
7-
compute_create2_address,
8-
compute_create_address,
9-
compute_eofcreate_address,
10-
)
11-
from .types import (
3+
from .eest_types import (
124
EOA,
135
Account,
146
Alloc,
157
AuthorizationTuple,
8+
# Blob,
169
CamelModel,
1710
ConsolidationRequest,
1811
DepositRequest,
@@ -29,6 +22,14 @@
2922
WithdrawalRequest,
3023
keccak256,
3124
)
25+
from .helpers import (
26+
TestParameterGroup,
27+
add_kzg_version,
28+
ceiling_division,
29+
compute_create2_address,
30+
compute_create_address,
31+
compute_eofcreate_address,
32+
)
3233

3334
__all__ = (
3435
"Account",

src/ethereum_test_types/blob.py

Lines changed: 70 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
"""
2-
abstract: Tests [EIP-7594: PeerDAS - Peer Data Availability Sampling](https://eips.ethereum.org/EIPS/eip-7594)
3-
Tests [EIP-7594: PeerDAS - Peer Data Availability Sampling](https://eips.ethereum.org/EIPS/eip-7594).
4-
""" # noqa: E501
1+
"""Blob class and functionality."""
52

63
import random
74
from enum import Enum
@@ -403,72 +400,72 @@ def corrupt_byte(b: bytes) -> Bytes:
403400
# static_blob.write_to_file()
404401
# --------------------------------------------
405402

406-
# myosaka: Fork = Osaka
407-
# myprague: Fork = Prague
408-
# mycancun: Fork = Cancun
409-
# myseed: int = 1337 # fork+seed is the unique ID of a blob
410-
# mytimestamp: int = 168123123
411-
# b: Blob = Blob.NewBlob(myosaka, myseed, mytimestamp)
412-
# json_str: str = b.model_dump_json()
413-
# restored: Blob = Blob.model_validate_json(json_str)
414-
# assert b.data == restored.data
415-
# assert b.commitment == restored.commitment
416-
# assert b.proof == restored.proof
417-
# assert b.cells == restored.cells
418-
# assert b.versioned_hash == restored.versioned_hash
419-
# assert b.name == restored.name
420-
# assert b.fork == restored.fork
421-
# assert b.timestamp == restored.timestamp
422-
# print(type(b.proof), len(b.proof))
423-
# print(BYTES_PER_FIELD_ELEMENT)
424-
# print(len(b.data))
425-
# b.write_to_file()
426-
# c: Blob = Blob.LoadBlobFromFile("blob_" + "osaka" + "_" + str(myseed) + "_" + str(mytimestamp))
427-
# assert b.data == c.data
428-
# assert b.commitment == c.commitment
429-
# assert b.proof == c.proof
430-
# assert b.cells == c.cells
431-
# assert b.versioned_hash == c.versioned_hash
432-
# assert b.name == c.name
433-
# assert b.fork == c.fork
434-
# assert b.timestamp == c.timestamp
435-
# d: Blob = Blob.NewBlob(myprague, myseed, 123)
436-
# d.write_to_file()
437-
# e: Blob = Blob.NewBlob(myprague, myseed, 123)
438-
# print("Line above should say blob already existed and was loaded from file")
439-
# ee: Blob = Blob.NewBlob(myprague, myseed, 1234)
440-
# newtimestamp = 999999
441-
# f: Blob = Blob.NewBlob(mycancun, 1337, newtimestamp)
442-
# f.write_to_file()
443-
# h: Blob = Blob.NewBlob(myosaka, myseed)
444-
# h.write_to_file()
445-
# zz: Blob = Blob.NewBlob(myosaka, myseed)
446-
# print("Line above should say blob already existed and was loaded from file")
447-
# # you can load a blob either via just filename or via absolute path or via relative path (cwd is ./src/ethereum_test_types) # noqa: E501
448-
# yyy: Blob = Blob.LoadBlobFromFile("blob_cancun_1337_999999.json")
449-
# # yyyy: Blob = Blob.LoadBlobFromFile(
450-
# # "/home/user/Documents/execution-spec-tests/tests/cancun/eip4844_blobs/static_blobs/blob_cancun_1337.json" # noqa: E501
451-
# # ) # you must replace user with ur actual username as $USER not supported here
452-
# yyyyy: Blob = Blob.LoadBlobFromFile(
453-
# "tests/cancun/eip4844_blobs/static_blobs/blob_cancun_1337_999999.json"
454-
# )
455-
# zzzzzzz: Blob = Blob.LoadBlobFromFile(
456-
# "./tests/cancun/eip4844_blobs/static_blobs/blob_cancun_1337_999999.json"
457-
# )
458-
459-
460-
# # test proof corruption
461-
# # osaka
462-
# testseed = 55
463-
# ddd: Blob = Blob.NewBlob(Osaka, testseed + 10)
464-
# oldValue = ddd.proof[0][5]
465-
# for m in Blob.ProofCorruptionMode:
466-
# ddd.corrupt_proof(m)
467-
# print("proof corruption works (osaka):", oldValue != ddd.proof[0][5])
468-
# # prague
469-
# eeeeeeeeee: Blob = Blob.NewBlob(Prague, testseed + 11)
470-
# oldValue = eeeeeeeeee.proof[5]
471-
# for m in Blob.ProofCorruptionMode:
472-
# eeeeeeeeee.corrupt_proof(m)
473-
# print("proof corruption works (prague):", oldValue != eeeeeeeeee.proof[5])
474-
# print("pydantic model works")
403+
myosaka: Fork = Osaka
404+
myprague: Fork = Prague
405+
mycancun: Fork = Cancun
406+
myseed: int = 1337 # fork+seed is the unique ID of a blob
407+
mytimestamp: int = 168123123
408+
b: Blob = Blob.NewBlob(myosaka, myseed, mytimestamp)
409+
json_str: str = b.model_dump_json()
410+
restored: Blob = Blob.model_validate_json(json_str)
411+
assert b.data == restored.data
412+
assert b.commitment == restored.commitment
413+
assert b.proof == restored.proof
414+
assert b.cells == restored.cells
415+
assert b.versioned_hash == restored.versioned_hash
416+
assert b.name == restored.name
417+
assert b.fork == restored.fork
418+
assert b.timestamp == restored.timestamp
419+
print(type(b.proof), len(b.proof))
420+
print(BYTES_PER_FIELD_ELEMENT)
421+
print(len(b.data))
422+
b.write_to_file()
423+
c: Blob = Blob.LoadBlobFromFile("blob_" + "osaka" + "_" + str(myseed) + "_" + str(mytimestamp))
424+
assert b.data == c.data
425+
assert b.commitment == c.commitment
426+
assert b.proof == c.proof
427+
assert b.cells == c.cells
428+
assert b.versioned_hash == c.versioned_hash
429+
assert b.name == c.name
430+
assert b.fork == c.fork
431+
assert b.timestamp == c.timestamp
432+
d: Blob = Blob.NewBlob(myprague, myseed, 123)
433+
d.write_to_file()
434+
e: Blob = Blob.NewBlob(myprague, myseed, 123)
435+
print("Line above should say blob already existed and was loaded from file")
436+
ee: Blob = Blob.NewBlob(myprague, myseed, 1234)
437+
newtimestamp = 999999
438+
f: Blob = Blob.NewBlob(mycancun, 1337, newtimestamp)
439+
f.write_to_file()
440+
h: Blob = Blob.NewBlob(myosaka, myseed)
441+
h.write_to_file()
442+
zz: Blob = Blob.NewBlob(myosaka, myseed)
443+
print("Line above should say blob already existed and was loaded from file")
444+
# you can load a blob either via just filename or via absolute path or via relative path (cwd is ./src/ethereum_test_types) # noqa: E501
445+
yyy: Blob = Blob.LoadBlobFromFile("blob_cancun_1337_999999.json")
446+
# yyyy: Blob = Blob.LoadBlobFromFile(
447+
# "/home/user/Documents/execution-spec-tests/tests/cancun/eip4844_blobs/static_blobs/blob_cancun_1337.json" # noqa: E501
448+
# ) # you must replace user with ur actual username as $USER not supported here
449+
yyyyy: Blob = Blob.LoadBlobFromFile(
450+
"tests/cancun/eip4844_blobs/static_blobs/blob_cancun_1337_999999.json"
451+
)
452+
zzzzzzz: Blob = Blob.LoadBlobFromFile(
453+
"./tests/cancun/eip4844_blobs/static_blobs/blob_cancun_1337_999999.json"
454+
)
455+
456+
457+
# test proof corruption
458+
# osaka
459+
testseed = 55
460+
ddd: Blob = Blob.NewBlob(Osaka, testseed + 10)
461+
oldValue = ddd.proof[0][5]
462+
for m in Blob.ProofCorruptionMode:
463+
ddd.corrupt_proof(m)
464+
print("proof corruption works (osaka):", oldValue != ddd.proof[0][5])
465+
# prague
466+
eeeeeeeeee: Blob = Blob.NewBlob(Prague, testseed + 11)
467+
oldValue = eeeeeeeeee.proof[5]
468+
for m in Blob.ProofCorruptionMode:
469+
eeeeeeeeee.corrupt_proof(m)
470+
print("proof corruption works (prague):", oldValue != eeeeeeeeee.proof[5])
471+
print("pydantic model works")

src/ethereum_test_types/helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from ethereum_test_base_types.conversions import BytesConvertible, FixedSizeBytesConvertible
1010
from ethereum_test_vm import Opcodes as Op
1111

12-
from .types import EOA, int_to_bytes
12+
from .eest_types import EOA, int_to_bytes
1313

1414
"""
1515
Helper functions

src/ethereum_test_types/tests/test_transactions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import pytest
66

7-
from ..types import AccessList, Hash, Transaction
7+
from ..eest_types import AccessList, Hash, Transaction
88

99

1010
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)