Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -347,3 +347,65 @@ def fund_via_withdrawals(
new_payload,
payload_attributes.parent_beacon_block_root,
)

def bump_block_gas_limit(
self,
block_count: int,
) -> List[EnginePayloadMetadata]:
"""
Build empty block to increase the block gas limit to target.
"""
if block_count <= 0:
return []
assert self.testing_rpc is not None, (
"bump_block_gas_limit requires testing_rpc"
)
captured: List[EnginePayloadMetadata] = []
with self.block_building_lock:
for _ in range(block_count):
head_block = self.get_block_by_number("latest")
assert head_block is not None
next_timestamp = int(HexNumber(head_block["timestamp"]) + 1)
payload_attributes = self._payload_attributes(
next_timestamp=next_timestamp,
)
new_payload = self.testing_rpc.build_block(
parent_block_hash=Hash(head_block["hash"]),
payload_attributes=payload_attributes,
transactions=[],
extra_data=Bytes(b""),
)
captured.append(
self._finalize_payload(
new_payload,
payload_attributes.parent_beacon_block_root,
)
)
return captured

def set_canonical_head(self, head_block_hash: Hash) -> None:
"""
Reorg the canonical head to head_block_hash via
``engine_forkchoiceUpdated``.
"""
head_block = self.get_block_by_hash(head_block_hash)
assert head_block is not None, (
f"cannot reset head to unknown block {head_block_hash}"
)
head_fork = self.fork.fork_at(
block_number=HexNumber(head_block["number"]),
timestamp=HexNumber(head_block["timestamp"]),
)
fcu_version = head_fork.engine_forkchoice_updated_version()
assert fcu_version is not None, (
"Fork does not support engine forkchoice_updated"
)
response = self.engine_rpc.forkchoice_updated(
ForkchoiceState(head_block_hash=head_block_hash),
None,
version=fcu_version,
)
assert response.payload_status.status == PayloadStatusEnum.VALID, (
f"forkchoice_updated reset to {head_block_hash} was not VALID "
f"(got {response.payload_status.status})"
)
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import io
import json
import time
from dataclasses import asdict, replace
from pathlib import Path
from random import randint
Expand All @@ -13,6 +14,8 @@
from hive.simulation import Simulation
from hive.testing import HiveTest, HiveTestResult, HiveTestSuite

from ...shared import profile as _profile

from execution_testing.base_types import (
Account,
EmptyOmmersRoot,
Expand Down Expand Up @@ -150,7 +153,13 @@ def build_genesis_header(
pre_alloc = Alloc.merge(pre_alloc, base_pre)
if empty_accounts := pre_alloc.empty_accounts():
raise Exception(f"Empty accounts in pre state: {empty_accounts}")
_state_root_t0 = time.perf_counter()
state_root = pre_alloc.state_root()
_profile.write(
"Alloc.state_root",
accounts=len(pre_alloc.root),
elapsed_s=f"{time.perf_counter() - _state_root_t0:.3f}",
)
genesis = FixtureHeader(
parent_hash=0,
ommers_hash=EmptyOmmersRoot,
Expand Down
Loading
Loading