Skip to content

Commit 586b03b

Browse files
Shashwat-NautiyalSamWilsn
authored andcommitted
Update the type for blob_gas_used (#1161)
* type for blob_gas_used updated * type inconsitencies in op resolved
1 parent b22a46a commit 586b03b

File tree

6 files changed

+20
-20
lines changed

6 files changed

+20
-20
lines changed

src/ethereum/cancun/fork.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
"0x000F3df6D732807Ef1319fB7B8bB8522d0Beac02"
7777
)
7878
SYSTEM_TRANSACTION_GAS = Uint(30000000)
79-
MAX_BLOB_GAS_PER_BLOCK = Uint(786432)
79+
MAX_BLOB_GAS_PER_BLOCK = U64(786432)
8080
VERSIONED_HASH_VERSION_KZG = b"\x01"
8181

8282

@@ -350,7 +350,7 @@ def check_transaction(
350350
block_env: vm.BlockEnvironment,
351351
block_output: vm.BlockOutput,
352352
tx: Transaction,
353-
) -> Tuple[Address, Uint, Tuple[VersionedHash, ...], Uint]:
353+
) -> Tuple[Address, Uint, Tuple[VersionedHash, ...], U64]:
354354
"""
355355
Check if the transaction is includable in the block.
356356
@@ -423,7 +423,7 @@ def check_transaction(
423423
if Uint(tx.max_fee_per_blob_gas) < blob_gas_price:
424424
raise InvalidBlock
425425

426-
max_gas_fee += calculate_total_blob_gas(tx) * Uint(
426+
max_gas_fee += Uint(calculate_total_blob_gas(tx)) * Uint(
427427
tx.max_fee_per_blob_gas
428428
)
429429
blob_versioned_hashes = tx.blob_versioned_hashes

src/ethereum/cancun/vm/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class BlockOutput:
6969
block.
7070
withdrawals_trie : `ethereum.fork_types.Root`
7171
Trie root of all the withdrawals in the block.
72-
blob_gas_used : `ethereum.base_types.Uint`
72+
blob_gas_used : `ethereum.base_types.U64`
7373
Total blob gas used in the block.
7474
"""
7575

@@ -84,7 +84,7 @@ class BlockOutput:
8484
withdrawals_trie: Trie[Bytes, Optional[Union[Bytes, Withdrawal]]] = field(
8585
default_factory=lambda: Trie(secured=False, default=None)
8686
)
87-
blob_gas_used: Uint = Uint(0)
87+
blob_gas_used: U64 = U64(0)
8888

8989

9090
@dataclass

src/ethereum/cancun/vm/gas.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
GAS_POINT_EVALUATION = Uint(50000)
7070

7171
TARGET_BLOB_GAS_PER_BLOCK = U64(393216)
72-
GAS_PER_BLOB = Uint(2**17)
72+
GAS_PER_BLOB = U64(2**17)
7373
MIN_BLOB_GASPRICE = Uint(1)
7474
BLOB_BASE_FEE_UPDATE_FRACTION = Uint(3338477)
7575

@@ -300,7 +300,7 @@ def calculate_excess_blob_gas(parent_header: Header) -> U64:
300300
return parent_blob_gas - TARGET_BLOB_GAS_PER_BLOCK
301301

302302

303-
def calculate_total_blob_gas(tx: Transaction) -> Uint:
303+
def calculate_total_blob_gas(tx: Transaction) -> U64:
304304
"""
305305
Calculate the total blob gas for a transaction.
306306
@@ -315,9 +315,9 @@ def calculate_total_blob_gas(tx: Transaction) -> Uint:
315315
The total blob gas for the transaction.
316316
"""
317317
if isinstance(tx, BlobTransaction):
318-
return GAS_PER_BLOB * Uint(len(tx.blob_versioned_hashes))
318+
return GAS_PER_BLOB * U64(len(tx.blob_versioned_hashes))
319319
else:
320-
return Uint(0)
320+
return U64(0)
321321

322322

323323
def calculate_blob_gas_price(excess_blob_gas: U64) -> Uint:
@@ -357,6 +357,6 @@ def calculate_data_fee(excess_blob_gas: U64, tx: Transaction) -> Uint:
357357
data_fee: `Uint`
358358
The blob data fee.
359359
"""
360-
return calculate_total_blob_gas(tx) * calculate_blob_gas_price(
360+
return Uint(calculate_total_blob_gas(tx)) * calculate_blob_gas_price(
361361
excess_blob_gas
362362
)

src/ethereum/prague/fork.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
"0x000F3df6D732807Ef1319fB7B8bB8522d0Beac02"
8686
)
8787
SYSTEM_TRANSACTION_GAS = Uint(30000000)
88-
MAX_BLOB_GAS_PER_BLOCK = Uint(1179648)
88+
MAX_BLOB_GAS_PER_BLOCK = U64(1179648)
8989
VERSIONED_HASH_VERSION_KZG = b"\x01"
9090

9191
WITHDRAWAL_REQUEST_PREDEPLOY_ADDRESS = hex_to_address(
@@ -373,7 +373,7 @@ def check_transaction(
373373
block_env: vm.BlockEnvironment,
374374
block_output: vm.BlockOutput,
375375
tx: Transaction,
376-
) -> Tuple[Address, Uint, Tuple[VersionedHash, ...], Uint]:
376+
) -> Tuple[Address, Uint, Tuple[VersionedHash, ...], U64]:
377377
"""
378378
Check if the transaction is includable in the block.
379379
@@ -446,7 +446,7 @@ def check_transaction(
446446
if Uint(tx.max_fee_per_blob_gas) < blob_gas_price:
447447
raise InvalidBlock
448448

449-
max_gas_fee += calculate_total_blob_gas(tx) * Uint(
449+
max_gas_fee += Uint(calculate_total_blob_gas(tx)) * Uint(
450450
tx.max_fee_per_blob_gas
451451
)
452452
blob_versioned_hashes = tx.blob_versioned_hashes

src/ethereum/prague/vm/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class BlockOutput:
6969
block.
7070
withdrawals_trie : `ethereum.fork_types.Root`
7171
Trie root of all the withdrawals in the block.
72-
blob_gas_used : `ethereum.base_types.Uint`
72+
blob_gas_used : `ethereum.base_types.U64`
7373
Total blob gas used in the block.
7474
requests : `Bytes`
7575
Hash of all the requests in the block.
@@ -86,7 +86,7 @@ class BlockOutput:
8686
withdrawals_trie: Trie[Bytes, Optional[Union[Bytes, Withdrawal]]] = field(
8787
default_factory=lambda: Trie(secured=False, default=None)
8888
)
89-
blob_gas_used: Uint = Uint(0)
89+
blob_gas_used: U64 = U64(0)
9090
deposit_requests: Bytes = Bytes(b"")
9191
requests: List[Bytes] = field(default_factory=list)
9292

src/ethereum/prague/vm/gas.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
GAS_POINT_EVALUATION = Uint(50000)
7070

7171
TARGET_BLOB_GAS_PER_BLOCK = U64(786432)
72-
GAS_PER_BLOB = Uint(2**17)
72+
GAS_PER_BLOB = U64(2**17)
7373
MIN_BLOB_GASPRICE = Uint(1)
7474
BLOB_BASE_FEE_UPDATE_FRACTION = Uint(5007716)
7575

@@ -307,7 +307,7 @@ def calculate_excess_blob_gas(parent_header: Header) -> U64:
307307
return parent_blob_gas - TARGET_BLOB_GAS_PER_BLOCK
308308

309309

310-
def calculate_total_blob_gas(tx: Transaction) -> Uint:
310+
def calculate_total_blob_gas(tx: Transaction) -> U64:
311311
"""
312312
Calculate the total blob gas for a transaction.
313313
@@ -322,9 +322,9 @@ def calculate_total_blob_gas(tx: Transaction) -> Uint:
322322
The total blob gas for the transaction.
323323
"""
324324
if isinstance(tx, BlobTransaction):
325-
return GAS_PER_BLOB * Uint(len(tx.blob_versioned_hashes))
325+
return GAS_PER_BLOB * U64(len(tx.blob_versioned_hashes))
326326
else:
327-
return Uint(0)
327+
return U64(0)
328328

329329

330330
def calculate_blob_gas_price(excess_blob_gas: U64) -> Uint:
@@ -364,6 +364,6 @@ def calculate_data_fee(excess_blob_gas: U64, tx: Transaction) -> Uint:
364364
data_fee: `Uint`
365365
The blob data fee.
366366
"""
367-
return calculate_total_blob_gas(tx) * calculate_blob_gas_price(
367+
return Uint(calculate_total_blob_gas(tx)) * calculate_blob_gas_price(
368368
excess_blob_gas
369369
)

0 commit comments

Comments
 (0)