Skip to content

Commit 8967008

Browse files
authored
Fix/finalized tag (#110)
* add finalized tag to fetch_block function * Update dependencies * Update to version 0.8.5 * update poetry and mypy version * linting and formatting
1 parent 50b15d7 commit 8967008

File tree

6 files changed

+690
-574
lines changed

6 files changed

+690
-574
lines changed

.github/workflows/checks.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ jobs:
2727
uses: actions/cache@v4
2828
with:
2929
path: ~/.local # the path depends on the OS
30-
key: poetry-1.4.0-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}
30+
key: poetry-2.0.1-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}
3131
#----------------------------------------------
3232
# ----- install & configure poetry -----
3333
#----------------------------------------------
3434
- name: Install Poetry
3535
if: steps.cached-poetry.outputs.cache-hit != 'true'
3636
uses: snok/install-poetry@v1
3737
with:
38-
version: 1.4.0
38+
version: 2.0.1
3939
virtualenvs-create: true
4040
virtualenvs-in-project: true
4141
installer-parallel: true

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ repos:
55
- id: black
66
language_version: python3.10
77
- repo: https://github.com/pre-commit/mirrors-mypy
8-
rev: v1.13.0 # Updated to the desired version of mypy
8+
rev: v1.15.0 # Updated to the desired version of mypy
99
hooks:
1010
- id: mypy
1111
language_version: python3.10
1212
- repo: https://github.com/python-poetry/poetry
13-
rev: 1.8.2
13+
rev: 2.0.1
1414
hooks:
1515
- id: poetry-check
1616
- repo: https://github.com/pycqa/flake8

chainbench/test_data/evm.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,7 @@ def fetch_block(self, block_number: BlockNumber | str) -> EvmBlock:
469469
"latest",
470470
"earliest",
471471
"pending",
472+
"finalized",
472473
]:
473474
raise ValueError("Invalid block number")
474475
result: dict[str, t.Any] = self.client.make_rpc_call("eth_getBlockByNumber", [block_number, True])

chainbench/util/event.py

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -197,45 +197,45 @@ def on_init(environment: Environment, **_kwargs):
197197
test_data["chain_id"] = {test_data_class_name: chain_id}
198198
if environment.parsed_options:
199199
user_test_data.init_data(environment.parsed_options)
200-
test_data[test_data_class_name] = user_test_data.data.to_json()
201-
send_msg_to_workers(environment.runner, "test_data", test_data)
202-
print("Fetching blocks...")
203-
if environment.parsed_options.use_latest_blocks:
204-
print(f"Using latest {user_test_data.data.size.blocks_len} blocks as test data")
205-
logger.info(f"Using latest {user_test_data.data.size.blocks_len} blocks as test data")
206-
for block_number in range(
207-
user_test_data.data.block_range.start, user_test_data.data.block_range.end + 1
208-
):
209-
block = None
210-
try:
211-
block = user_test_data.fetch_block(block_number)
212-
except (BlockNotFoundError, InvalidBlockError):
213-
pass
214-
while block is None:
200+
test_data[test_data_class_name] = user_test_data.data.to_json()
201+
send_msg_to_workers(environment.runner, "test_data", test_data)
202+
print("Fetching blocks...")
203+
if environment.parsed_options.use_latest_blocks:
204+
print(f"Using latest {user_test_data.data.size.blocks_len} blocks as test data")
205+
logger.info(f"Using latest {user_test_data.data.size.blocks_len} blocks as test data")
206+
for block_number in range(
207+
user_test_data.data.block_range.start, user_test_data.data.block_range.end + 1
208+
):
209+
block = None
215210
try:
216-
block = user_test_data.fetch_latest_block()
211+
block = user_test_data.fetch_block(block_number)
217212
except (BlockNotFoundError, InvalidBlockError):
218213
pass
219-
user_test_data.data.push_block(block)
220-
block_data = {test_data_class_name: block.to_json()}
221-
send_msg_to_workers(environment.runner, "block_data", block_data)
222-
print(user_test_data.data.stats(), end="\r")
214+
while block is None:
215+
try:
216+
block = user_test_data.fetch_latest_block()
217+
except (BlockNotFoundError, InvalidBlockError):
218+
pass
219+
user_test_data.data.push_block(block)
220+
block_data = {test_data_class_name: block.to_json()}
221+
send_msg_to_workers(environment.runner, "block_data", block_data)
222+
print(user_test_data.data.stats(), end="\r")
223+
else:
224+
print(user_test_data.data.stats(), end="\r")
225+
print("\n") # new line after progress display upon exiting loop
223226
else:
224-
print(user_test_data.data.stats(), end="\r")
225-
print("\n") # new line after progress display upon exiting loop
226-
else:
227-
while user_test_data.data.size.blocks_len > len(user_test_data.data.blocks):
228-
try:
229-
block = user_test_data.fetch_random_block(user_test_data.data.block_numbers)
230-
except (BlockNotFoundError, InvalidBlockError):
231-
continue
232-
user_test_data.data.push_block(block)
233-
block_data = {test_data_class_name: block.to_json()}
234-
send_msg_to_workers(environment.runner, "block_data", block_data)
235-
print(user_test_data.data.stats(), end="\r")
236-
else:
237-
print(user_test_data.data.stats(), end="\r")
238-
print("\n") # new line after progress display upon exiting loop
227+
while user_test_data.data.size.blocks_len > len(user_test_data.data.blocks):
228+
try:
229+
block = user_test_data.fetch_random_block(user_test_data.data.block_numbers)
230+
except (BlockNotFoundError, InvalidBlockError):
231+
continue
232+
user_test_data.data.push_block(block)
233+
block_data = {test_data_class_name: block.to_json()}
234+
send_msg_to_workers(environment.runner, "block_data", block_data)
235+
print(user_test_data.data.stats(), end="\r")
236+
else:
237+
print(user_test_data.data.stats(), end="\r")
238+
print("\n") # new line after progress display upon exiting loop
239239
logger.info("Test data is ready")
240240
send_msg_to_workers(environment.runner, "release_lock", {})
241241
user_test_data.release_lock()

0 commit comments

Comments
 (0)