Skip to content

Commit

Permalink
Merge pull request #1062 from marioevz/revert-1045-prague-eip-7742
Browse files Browse the repository at this point in the history
Revert "Implement EIP 7742 in Prague"
  • Loading branch information
petertdavies authored Dec 19, 2024
2 parents dfa792d + 804ac4d commit 5a3112c
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 45 deletions.
1 change: 0 additions & 1 deletion src/ethereum/prague/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ class Header:
excess_blob_gas: U64
parent_beacon_block_root: Root
requests_hash: Hash32
target_blobs_per_block: U64


@slotted_freezable
Expand Down
3 changes: 2 additions & 1 deletion src/ethereum/prague/fork.py
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,8 @@ def apply_body(

block_logs += logs
blob_gas_used += calculate_total_blob_gas(tx)

if blob_gas_used > MAX_BLOB_GAS_PER_BLOCK:
raise InvalidBlock
block_gas_used = block_gas_limit - gas_available

block_logs_bloom = logs_bloom(block_logs)
Expand Down
13 changes: 6 additions & 7 deletions src/ethereum/prague/vm/gas.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,10 @@
GAS_BLS_G2_MUL = Uint(22500)
GAS_BLS_G2_MAP = Uint(23800)

TARGET_BLOB_GAS_PER_BLOCK = U64(786432)
GAS_PER_BLOB = Uint(2**17)
MIN_BLOB_GASPRICE = Uint(1)
BLOB_BASE_FEE_UPDATE_FRACTION = Uint(5007716)
BLOB_GASPRICE_UPDATE_FRACTION = Uint(5007716)


@dataclass
Expand Down Expand Up @@ -276,8 +277,7 @@ def init_code_cost(init_code_length: Uint) -> Uint:
def calculate_excess_blob_gas(parent_header: Header) -> U64:
"""
Calculated the excess blob gas for the current block based
on the gas used in the parent block and the gas target set
in the current block.
on the gas used in the parent block.
Parameters
----------
Expand All @@ -292,11 +292,10 @@ def calculate_excess_blob_gas(parent_header: Header) -> U64:
parent_blob_gas = (
parent_header.excess_blob_gas + parent_header.blob_gas_used
)
target_blob_gas = GAS_PER_BLOB * parent_header.target_blobs_per_block
if parent_blob_gas < target_blob_gas:
if parent_blob_gas < TARGET_BLOB_GAS_PER_BLOCK:
return U64(0)
else:
return parent_blob_gas - target_blob_gas
return parent_blob_gas - TARGET_BLOB_GAS_PER_BLOCK


def calculate_total_blob_gas(tx: Transaction) -> Uint:
Expand Down Expand Up @@ -336,7 +335,7 @@ def calculate_blob_gas_price(excess_blob_gas: U64) -> Uint:
return taylor_exponential(
MIN_BLOB_GASPRICE,
Uint(excess_blob_gas),
BLOB_BASE_FEE_UPDATE_FRACTION,
BLOB_GASPRICE_UPDATE_FRACTION,
)


Expand Down
5 changes: 0 additions & 5 deletions src/ethereum_spec_tools/evm_tools/loaders/fork_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,6 @@ def HISTORY_SERVE_WINDOW(self) -> Any:
"""HISTORY_SERVE_WINDOW of the given fork."""
return self._module("fork").HISTORY_SERVE_WINDOW

@property
def GAS_PER_BLOB(self) -> Any:
"""GAS_PER_BLOB of the given fork."""
return self._module("vm.gas").GAS_PER_BLOB

@property
def process_general_purpose_requests(self) -> Any:
"""process_general_purpose_requests function of the given fork."""
Expand Down
5 changes: 2 additions & 3 deletions src/ethereum_spec_tools/evm_tools/t8n/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,9 +359,8 @@ def apply_body(self) -> None:

if self.fork.is_after_fork("ethereum.cancun"):
blob_gas_used += self.fork.calculate_total_blob_gas(tx)
if not self.fork.is_after_fork("ethereum.prague"):
if blob_gas_used > self.fork.MAX_BLOB_GAS_PER_BLOCK:
raise InvalidBlock
if blob_gas_used > self.fork.MAX_BLOB_GAS_PER_BLOCK:
raise InvalidBlock
except EthereumException as e:
# The tf tools expects some non-blank error message
# even in case e is blank.
Expand Down
26 changes: 3 additions & 23 deletions src/ethereum_spec_tools/evm_tools/t8n/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ class Env:
parent_blob_gas_used: Optional[U64]
excess_blob_gas: Optional[U64]
requests: Any
target_blobs_per_block: Optional[U64]
parent_target_blobs_per_block: Optional[U64]

def __init__(self, t8n: "T8N", stdin: Optional[Dict] = None):
if t8n.options.input_env == "stdin":
Expand Down Expand Up @@ -92,7 +90,6 @@ def read_excess_blob_gas(self, data: Any, t8n: "T8N") -> None:
self.parent_blob_gas_used = U64(0)
self.parent_excess_blob_gas = U64(0)
self.excess_blob_gas = None
self.parent_target_blobs_per_block = None

if not t8n.fork.is_after_fork("ethereum.cancun"):
return
Expand All @@ -117,28 +114,11 @@ def read_excess_blob_gas(self, data: Any, t8n: "T8N") -> None:
self.parent_excess_blob_gas + self.parent_blob_gas_used
)

if "parentTargetBlobsPerBlock" in data:
self.parent_target_blobs_per_block = parse_hex_or_int(
data["parentTargetBlobsPerBlock"], U64
)
parent_target_blob_gas_per_block = (
self.parent_target_blobs_per_block * t8n.fork.GAS_PER_BLOB
)
else:
parent_target_blob_gas_per_block = (
t8n.fork.TARGET_BLOB_GAS_PER_BLOCK
)
target_blob_gas_per_block = t8n.fork.TARGET_BLOB_GAS_PER_BLOCK

self.excess_blob_gas = U64(0)
if excess_blob_gas >= parent_target_blob_gas_per_block:
self.excess_blob_gas = (
excess_blob_gas - parent_target_blob_gas_per_block
)

if "currentTargetBlobsPerBlock" in data:
self.target_blobs_per_block = parse_hex_or_int(
data["currentTargetBlobsPerBlock"], U64
)
if excess_blob_gas >= target_blob_gas_per_block:
self.excess_blob_gas = excess_blob_gas - target_blob_gas_per_block

def read_base_fee_per_gas(self, data: Any, t8n: "T8N") -> None:
"""
Expand Down
4 changes: 0 additions & 4 deletions src/ethereum_spec_tools/evm_tools/t8n/t8n_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,6 @@ class Result:
blob_gas_used: Optional[Uint] = None
requests_hash: Optional[Hash32] = None
requests: Optional[List[Bytes]] = None
target_blobs_per_block: Optional[U64] = None

def to_json(self) -> Any:
"""Encode the result to JSON"""
Expand Down Expand Up @@ -359,7 +358,4 @@ def to_json(self) -> Any:
# request
data["requests"] = [encode_to_hex(req) for req in self.requests]

if self.target_blobs_per_block is not None:
data["currentBlobsPerBlock"] = hex(self.target_blobs_per_block)

return data
1 change: 0 additions & 1 deletion tests/prague/test_rlp.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@
blob_gas_used=U64(7),
excess_blob_gas=U64(8),
requests_hash=hash7,
target_blobs_per_block=U64(9),
)

block = Block(
Expand Down

0 comments on commit 5a3112c

Please sign in to comment.