Skip to content

Commit

Permalink
Problem: configs are baked in testground (#1561)
Browse files Browse the repository at this point in the history
* Problem: configs are baked in testground

allow overwrite config and app patch

* Apply suggestions from code review

* compatible with old testground

* cleanup

* cleanup

* cleanup

* fix

* cleanup

---------

Co-authored-by: huangyi <huang@crypto.com>
  • Loading branch information
mmsqe and yihuang authored Sep 12, 2024
1 parent 7b402ef commit 5c507d5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 19 deletions.
26 changes: 14 additions & 12 deletions testground/benchmark/benchmark/peer.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def bootstrap(ctx: Context, cli) -> PeerPacket:
cli("genesis", "validate", home=home)

p2p_peers = connect_all(peer, peers)
patch_configs(home, ctx.params.test_group_id, p2p_peers, "block-stm")
patch_configs(home, p2p_peers, {}, {})
return peer


Expand Down Expand Up @@ -116,30 +116,32 @@ def gen_genesis(cli: ChainCommand, leader_home: Path, peers: List[PeerPacket]):
)


def patch_configs(home: Path, group: str, peers: str, block_executor: str):
# update persistent_peers and other configs in config.toml
config_patch = {
def patch_configs(home: Path, peers: str, config_patch: dict, app_patch: dict):
default_config_patch = {
"db_backend": "rocksdb",
"p2p.persistent_peers": peers,
"p2p.addr_book_strict": False,
"mempool.recheck": "false",
"mempool.recheck": False,
"mempool.size": MEMPOOL_SIZE,
"consensus.timeout_commit": "1s",
"tx_index.indexer": "null",
}

app_patch = {
default_app_patch = {
"minimum-gas-prices": "0basecro",
"index-events": ["ethereum_tx.ethereumTxHash"],
"memiavl.enable": True,
"mempool.max-txs": MEMPOOL_SIZE,
"evm.block-executor": block_executor,
"evm.block-executor": "block-stm", # or "sequential"
"evm.block-stm-workers": 0,
"evm.block-stm-pre-estimate": True,
"json-rpc.enable-indexer": True,
}
if block_executor == "block-stm":
app_patch["memiavl.cache-size"] = 0

# update persistent_peers and other configs in config.toml
config_patch = {
**default_config_patch,
**config_patch,
"p2p.persistent_peers": peers,
}
app_patch = {**default_app_patch, **app_patch}
patch_toml(home / "config" / "config.toml", config_patch)
patch_toml(home / "config" / "app.toml", app_patch)

Expand Down
15 changes: 8 additions & 7 deletions testground/benchmark/benchmark/stateless.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ def gen(
hostname_template=HOSTNAME_TEMPLATE,
num_accounts=10,
num_txs=1000,
block_executor="block-stm", # or "sequential"
config_patch={},
app_patch={},
):
outdir = Path(outdir)
cli = ChainCommand(LOCAL_CRONOSD_PATH)
Expand All @@ -72,7 +73,7 @@ def gen(
# write genesis file and patch config files
for i in range(validators):
patch_configs_local(
peers, genesis, outdir, VALIDATOR_GROUP, i, i, block_executor
peers, genesis, outdir, VALIDATOR_GROUP, i, config_patch, app_patch
)
for i in range(fullnodes):
patch_configs_local(
Expand All @@ -81,8 +82,8 @@ def gen(
outdir,
FULLNODE_GROUP,
i,
i + validators,
block_executor,
config_patch,
app_patch,
)

print("write config")
Expand Down Expand Up @@ -272,13 +273,13 @@ def patch_configs_local(
outdir: Path,
group: str,
i: int,
group_seq: int,
block_executor: str,
config_patch,
app_patch,
):
home = outdir / group / str(i)
(home / "config" / "genesis.json").write_text(json.dumps(genesis))
p2p_peers = connect_all(peers[i], peers)
patch_configs(home, group, p2p_peers, block_executor)
patch_configs(home, p2p_peers, config_patch, app_patch)


def node_index() -> int:
Expand Down

0 comments on commit 5c507d5

Please sign in to comment.