Skip to content

Commit 6ff497e

Browse files
committed
Major refactoring on users and batch requests
- added batch request support for Solana - enabled batch request mode to be enabled and batch size can also be configured via cli argument - added batch request support for single method tests, all profiles (except Oasis) - added support for trace_call, trace_callMany and trace_filter in EvmUser
1 parent ebfe5b4 commit 6ff497e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+2051
-2096
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ This will run a load test with a general BSC profile.
123123
- `-E, --exclude-tags`: Exclude tasks tagged with custom tags from the test. You may specify this option multiple times.
124124
- `--use-latest-blocks`: Use latest blocks for test data generation and runs a background process to update the test data with latest blocks.
125125
- `--size`: Specifies the test data size. Available values are XS, S, M, L, XL. Default is S.
126+
- '--batch': Runs the test using batch requests. This will send multiple requests in a single batch request. The number of requests in a batch can be specified using the `--batch-size` flag. Default batch size is 10.
126127

127128
You may also run `chainbench start --help` for the full list of parameters and flags.
128129

chainbench/main.py

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
import gevent.pool
1111
from click import Context, Parameter
1212

13-
from chainbench.user.tasks import all_method_classes, all_methods, get_subclass_tasks
13+
from chainbench.user import get_subclass_tasks
14+
from chainbench.user.common import all_method_classes, all_methods
1415
from chainbench.util.cli import (
1516
ContextData,
1617
LocustOptions,
@@ -147,6 +148,17 @@ def validate_profile(ctx: Context, param: Parameter, value: str) -> str:
147148
type=click.Choice(["head-lag-monitor"], case_sensitive=False),
148149
multiple=True,
149150
)
151+
@click.option(
152+
"--batch",
153+
is_flag=True,
154+
help="Run tests in batch mode. This will make requests in batches for json-rpc methods. The number of requests in "
155+
"a batch can be specified using the `--batch-size` flag",
156+
)
157+
@click.option(
158+
"--batch-size",
159+
default=10,
160+
help="The number of requests in " "a batch for json-rpc methods. This flag is only used when `--batch` flag is set",
161+
)
150162
@click.option(
151163
"--debug-trace-methods",
152164
is_flag=True,
@@ -190,6 +202,8 @@ def start(
190202
run_id: str | None,
191203
notify: str | None,
192204
monitor: list[str],
205+
batch: bool,
206+
batch_size: int,
193207
debug_trace_methods: bool,
194208
exclude_tags: list[str],
195209
timescale: bool,
@@ -290,7 +304,18 @@ def start(
290304
custom_exclude_tags.append(tag)
291305

292306
if not debug_trace_methods:
293-
custom_exclude_tags = custom_exclude_tags + ["trace", "debug"]
307+
custom_exclude_tags.extend(["trace", "debug"])
308+
309+
custom_tags: list[str] = []
310+
311+
if batch:
312+
custom_tags = ["batch_single" if method else "batch"]
313+
else:
314+
if method:
315+
custom_tags.append("single")
316+
else:
317+
custom_exclude_tags.append("single")
318+
custom_exclude_tags.extend(["batch", "batch_single"])
294319

295320
locust_options = LocustOptions(
296321
profile_path=profile_path,
@@ -304,6 +329,7 @@ def start(
304329
workers=workers,
305330
headless=headless,
306331
target=target,
332+
custom_tags=custom_tags,
307333
exclude_tags=custom_exclude_tags,
308334
timescale=timescale,
309335
pg_host=pg_host,
@@ -315,6 +341,7 @@ def start(
315341
size=size,
316342
method=method,
317343
enable_class_picker=enable_class_picker,
344+
batch_size=batch_size,
318345
)
319346
# Start the Locust master
320347
master_command = locust_options.get_master_command()

chainbench/profile/arbitrum/general.py

Lines changed: 31 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4,38 +4,37 @@
44

55
from locust import constant_pacing
66

7-
from chainbench.user.tasks import EvmTasks
8-
from chainbench.user.tasks.common import expand_tasks
7+
from chainbench.user.protocol.evm import EvmUser
98

109

11-
class ArbitrumProfile(EvmTasks):
10+
class ArbitrumProfile(EvmUser):
1211
wait_time = constant_pacing(1)
13-
tasks = expand_tasks(
14-
{
15-
EvmTasks.eth_call_task: 1007,
16-
EvmTasks.eth_get_block_by_number_task: 592,
17-
EvmTasks.eth_get_logs_task: 397,
18-
EvmTasks.eth_chain_id_task: 186,
19-
EvmTasks.eth_get_transaction_receipt_task: 168,
20-
EvmTasks.eth_block_number_task: 165,
21-
EvmTasks.eth_get_block_by_hash_task: 61,
22-
EvmTasks.eth_get_balance_task: 50,
23-
EvmTasks.debug_trace_transaction_task: 48,
24-
EvmTasks.eth_estimate_gas_task: 28,
25-
EvmTasks.eth_gas_price_task: 22,
26-
EvmTasks.eth_get_transaction_count_task: 17,
27-
EvmTasks.eth_get_transaction_by_hash_task: 14,
28-
EvmTasks.eth_get_block_receipts_task: 12,
29-
EvmTasks.debug_trace_block_by_number_task: 12,
30-
EvmTasks.eth_get_code_task: 7,
31-
EvmTasks.eth_max_priority_fee_per_gas_task: 5,
32-
EvmTasks.web3_client_version_task: 3,
33-
EvmTasks.debug_trace_block_by_hash_task: 3,
34-
EvmTasks.net_listening_task: 2,
35-
EvmTasks.net_version_task: 2,
36-
EvmTasks.eth_syncing_task: 1,
37-
EvmTasks.eth_fee_history_task: 1,
38-
EvmTasks.eth_get_transaction_by_block_hash_and_index_task: 1,
39-
EvmTasks.debug_trace_call_task: 1,
40-
}
41-
)
12+
rpc_calls = {
13+
EvmUser.eth_call: 1007,
14+
EvmUser.eth_get_block_by_number: 592,
15+
EvmUser.eth_get_logs: 397,
16+
EvmUser.eth_chain_id: 186,
17+
EvmUser.eth_get_transaction_receipt: 168,
18+
EvmUser.eth_block_number: 165,
19+
EvmUser.eth_get_block_by_hash: 61,
20+
EvmUser.eth_get_balance: 50,
21+
EvmUser.debug_trace_transaction: 48,
22+
EvmUser.eth_estimate_gas: 28,
23+
EvmUser.eth_gas_price: 22,
24+
EvmUser.eth_get_transaction_count: 17,
25+
EvmUser.eth_get_transaction_by_hash: 14,
26+
EvmUser.eth_get_block_receipts: 12,
27+
EvmUser.debug_trace_block_by_number: 12,
28+
EvmUser.eth_get_code: 7,
29+
EvmUser.eth_max_priority_fee_per_gas: 5,
30+
EvmUser.web3_client_version: 3,
31+
EvmUser.debug_trace_block_by_hash: 3,
32+
EvmUser.net_listening: 2,
33+
EvmUser.net_version: 2,
34+
EvmUser.eth_syncing: 1,
35+
EvmUser.eth_fee_history: 1,
36+
EvmUser.eth_get_transaction_by_block_hash_and_index: 1,
37+
EvmUser.debug_trace_call: 1,
38+
}
39+
40+
tasks = EvmUser.expand_tasks(rpc_calls)

chainbench/profile/avalanche/archive.py

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,34 +4,33 @@
44

55
from locust import constant_pacing
66

7-
from chainbench.user.tasks import EvmTasks
8-
from chainbench.user.tasks.common import expand_tasks
7+
from chainbench.user.protocol.evm import EvmUser
98

109

11-
class AvalancheArchiveProfile(EvmTasks):
10+
class AvalancheArchiveProfile(EvmUser):
1211
wait_time = constant_pacing(1)
13-
tasks = expand_tasks(
14-
{
15-
EvmTasks.eth_call_task: 1474,
16-
EvmTasks.eth_get_block_by_number_task: 502,
17-
EvmTasks.eth_get_transaction_receipt_task: 281,
18-
EvmTasks.eth_get_logs_task: 234,
19-
EvmTasks.eth_block_number_task: 218,
20-
EvmTasks.eth_chain_id_task: 102,
21-
EvmTasks.eth_get_code_task: 81,
22-
EvmTasks.debug_trace_block_by_number_task: 70,
23-
EvmTasks.debug_trace_block_by_hash_task: 42,
24-
EvmTasks.eth_get_block_by_hash_task: 41,
25-
EvmTasks.eth_syncing_task: 38,
26-
EvmTasks.eth_estimate_gas_task: 33,
27-
EvmTasks.debug_trace_call_task: 12,
28-
EvmTasks.eth_get_transaction_by_hash_task: 12,
29-
EvmTasks.web3_client_version_task: 7,
30-
EvmTasks.eth_get_balance_task: 6,
31-
EvmTasks.eth_get_block_receipts_task: 3,
32-
EvmTasks.net_version_task: 3,
33-
EvmTasks.eth_get_transaction_count_task: 1,
34-
EvmTasks.debug_trace_transaction_task: 1,
35-
EvmTasks.eth_gas_price_task: 1,
36-
}
37-
)
12+
rpc_calls = {
13+
EvmUser.eth_call: 1474,
14+
EvmUser.eth_get_block_by_number: 502,
15+
EvmUser.eth_get_transaction_receipt: 281,
16+
EvmUser.eth_get_logs: 234,
17+
EvmUser.eth_block_number: 218,
18+
EvmUser.eth_chain_id: 102,
19+
EvmUser.eth_get_code: 81,
20+
EvmUser.debug_trace_block_by_number: 70,
21+
EvmUser.debug_trace_block_by_hash: 42,
22+
EvmUser.eth_get_block_by_hash: 41,
23+
EvmUser.eth_syncing: 38,
24+
EvmUser.eth_estimate_gas: 33,
25+
EvmUser.debug_trace_call: 12,
26+
EvmUser.eth_get_transaction_by_hash: 12,
27+
EvmUser.web3_client_version: 7,
28+
EvmUser.eth_get_balance: 6,
29+
EvmUser.eth_get_block_receipts: 3,
30+
EvmUser.net_version: 3,
31+
EvmUser.eth_get_transaction_count: 1,
32+
EvmUser.debug_trace_transaction: 1,
33+
EvmUser.eth_gas_price: 1,
34+
}
35+
36+
tasks = EvmUser.expand_tasks(rpc_calls)

chainbench/profile/avalanche/general.py

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,36 +4,35 @@
44

55
from locust import constant_pacing
66

7-
from chainbench.user.tasks import EvmTasks
8-
from chainbench.user.tasks.common import expand_tasks
7+
from chainbench.user.protocol.evm import EvmUser
98

109

11-
class AvalancheProfile(EvmTasks):
10+
class AvalancheProfile(EvmUser):
1211
wait_time = constant_pacing(1)
13-
tasks = expand_tasks(
14-
{
15-
EvmTasks.eth_call_task: 976,
16-
EvmTasks.eth_get_block_by_number_task: 516,
17-
EvmTasks.eth_get_logs_task: 404,
18-
EvmTasks.eth_get_transaction_receipt_task: 223,
19-
EvmTasks.eth_block_number_task: 174,
20-
EvmTasks.eth_chain_id_task: 155,
21-
EvmTasks.eth_get_balance_task: 134,
22-
EvmTasks.eth_get_transaction_by_hash_task: 70,
23-
EvmTasks.eth_get_block_by_hash_task: 30,
24-
EvmTasks.web3_client_version_task: 23,
25-
EvmTasks.eth_gas_price_task: 15,
26-
EvmTasks.eth_syncing_task: 14,
27-
EvmTasks.net_version_task: 7,
28-
EvmTasks.eth_get_transaction_count_task: 6,
29-
EvmTasks.eth_get_block_receipts_task: 5,
30-
EvmTasks.eth_get_code_task: 3,
31-
EvmTasks.eth_max_priority_fee_per_gas_task: 2,
32-
EvmTasks.eth_estimate_gas_task: 2,
33-
EvmTasks.eth_fee_history_task: 2,
34-
EvmTasks.debug_trace_transaction_task: 2,
35-
EvmTasks.debug_trace_block_by_number_task: 1,
36-
EvmTasks.debug_trace_block_by_hash_task: 1,
37-
EvmTasks.net_listening_task: 1,
38-
}
39-
)
12+
rpc_calls = {
13+
EvmUser.eth_call: 976,
14+
EvmUser.eth_get_block_by_number: 516,
15+
EvmUser.eth_get_logs: 404,
16+
EvmUser.eth_get_transaction_receipt: 223,
17+
EvmUser.eth_block_number: 174,
18+
EvmUser.eth_chain_id: 155,
19+
EvmUser.eth_get_balance: 134,
20+
EvmUser.eth_get_transaction_by_hash: 70,
21+
EvmUser.eth_get_block_by_hash: 30,
22+
EvmUser.web3_client_version: 23,
23+
EvmUser.eth_gas_price: 15,
24+
EvmUser.eth_syncing: 14,
25+
EvmUser.net_version: 7,
26+
EvmUser.eth_get_transaction_count: 6,
27+
EvmUser.eth_get_block_receipts: 5,
28+
EvmUser.eth_get_code: 3,
29+
EvmUser.eth_max_priority_fee_per_gas: 2,
30+
EvmUser.eth_estimate_gas: 2,
31+
EvmUser.eth_fee_history: 2,
32+
EvmUser.debug_trace_transaction: 2,
33+
EvmUser.debug_trace_block_by_number: 1,
34+
EvmUser.debug_trace_block_by_hash: 1,
35+
EvmUser.net_listening: 1,
36+
}
37+
38+
tasks = EvmUser.expand_tasks(rpc_calls)

chainbench/profile/base/archive.py

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,31 @@
44

55
from locust import constant_pacing
66

7-
from chainbench.user.tasks import EvmTasks
8-
from chainbench.user.tasks.common import expand_tasks
7+
from chainbench.user.protocol.evm import EvmUser
98

109

11-
class BaseArchiveProfile(EvmTasks):
10+
class BaseArchiveProfile(EvmUser):
1211
wait_time = constant_pacing(1)
13-
tasks = expand_tasks(
14-
{
15-
EvmTasks.eth_get_transaction_receipt_task: 1015,
16-
EvmTasks.eth_call_task: 211,
17-
EvmTasks.eth_get_block_by_number_task: 73,
18-
EvmTasks.debug_trace_transaction_task: 36,
19-
EvmTasks.eth_block_number_task: 12,
20-
EvmTasks.eth_get_transaction_by_hash_task: 9,
21-
EvmTasks.eth_chain_id_task: 8,
22-
EvmTasks.eth_get_logs_task: 7,
23-
EvmTasks.trace_block_task: 6,
24-
EvmTasks.eth_get_block_by_hash_task: 6,
25-
EvmTasks.eth_get_balance_task: 4,
26-
EvmTasks.eth_get_code_task: 2,
27-
EvmTasks.eth_get_block_receipts_task: 2,
28-
EvmTasks.debug_trace_block_by_hash_task: 1,
29-
EvmTasks.debug_trace_block_by_number_task: 1,
30-
EvmTasks.net_version_task: 1,
31-
EvmTasks.eth_gas_price_task: 1,
32-
EvmTasks.eth_max_priority_fee_per_gas_task: 1,
33-
EvmTasks.net_listening_task: 1,
34-
}
35-
)
12+
rpc_calls = {
13+
EvmUser.eth_get_transaction_receipt: 1015,
14+
EvmUser.eth_call: 211,
15+
EvmUser.eth_get_block_by_number: 73,
16+
EvmUser.debug_trace_transaction: 36,
17+
EvmUser.eth_block_number: 12,
18+
EvmUser.eth_get_transaction_by_hash: 9,
19+
EvmUser.eth_chain_id: 8,
20+
EvmUser.eth_get_logs: 7,
21+
EvmUser.trace_block: 6,
22+
EvmUser.eth_get_block_by_hash: 6,
23+
EvmUser.eth_get_balance: 4,
24+
EvmUser.eth_get_code: 2,
25+
EvmUser.eth_get_block_receipts: 2,
26+
EvmUser.debug_trace_block_by_hash: 1,
27+
EvmUser.debug_trace_block_by_number: 1,
28+
EvmUser.net_version: 1,
29+
EvmUser.eth_gas_price: 1,
30+
EvmUser.eth_max_priority_fee_per_gas: 1,
31+
EvmUser.net_listening: 1,
32+
}
33+
34+
tasks = EvmUser.expand_tasks(rpc_calls)

0 commit comments

Comments
 (0)