Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem: testground can't patch genesis #1574

Merged
merged 5 commits into from
Sep 13, 2024
Merged
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
23 changes: 18 additions & 5 deletions testground/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,30 @@ You need to have the `cronosd` in `PATH`.

```bash
$ nix run github:crypto-org-chain/cronos#stateless-testcase -- gen /tmp/data/out \
--validators 3 \
--fullnodes 7 \
--hostname_template "testplan-{index}" \
--num_accounts 10 \
--num_txs 1000
--options '{
"validators": 3,
"fullnodes": 7,
"num_accounts": 10,
"num_txs": 1000,
"config": {
"mempool.size": 10000
},
"app": {
"evm.block-stm-pre-estimate": true
},
"genesis": {
"consensus.params.block.max_gas": "163000000"
}
}'
```

* `validators`/`fullnodes` is the number of validators/full nodes.
* `hostname_template` is the hostname of each node that can communicate.
* `validators`/`fullnodes` is the number of validators/full nodes.
* `num_accounts` is the number of test accounts for each full node.
* `num_txs` is the number of test transactions to be sent for each test account.
* `config`/`app` is the config patch for config/app.toml.
* `genesis` is the patch for genesis.json.

## Embed the data directory

Expand Down
9 changes: 6 additions & 3 deletions testground/benchmark/benchmark/peer.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def bootstrap(ctx: Context, cli) -> PeerPacket:

if ctx.is_fullnode_leader:
# prepare genesis file and publish
genesis = gen_genesis(cli, home, peers)
genesis = gen_genesis(cli, home, peers, {})
ctx.sync.publish("genesis", genesis)
else:
genesis = ctx.sync.subscribe_simple("genesis", 1)[0]
Expand Down Expand Up @@ -94,7 +94,9 @@ def init_node(
return peer


def gen_genesis(cli: ChainCommand, leader_home: Path, peers: List[PeerPacket]):
def gen_genesis(
cli: ChainCommand, leader_home: Path, peers: List[PeerPacket], genesis_patch: dict
):
for peer in peers:
for account in peer.accounts:
cli(
Expand All @@ -109,9 +111,10 @@ def gen_genesis(cli: ChainCommand, leader_home: Path, peers: List[PeerPacket]):
return patch_json(
leader_home / "config" / "genesis.json",
{
"consensus.params.block.max_gas": "81500000",
"consensus.params.block.max_gas": "163000000",
"app_state.evm.params.evm_denom": "basecro",
"app_state.feemarket.params.no_base_fee": True,
**genesis_patch,
},
)

Expand Down
17 changes: 10 additions & 7 deletions testground/benchmark/benchmark/stateless.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,17 @@ class CLI:
def gen(
self,
outdir: str,
validators: int,
fullnodes: int,
hostname_template=HOSTNAME_TEMPLATE,
num_accounts=10,
num_txs=1000,
config_patch={},
app_patch={},
options={},
):
print("options", options)
validators = options.get("validators", 3)
fullnodes = options.get("fullnodes", 7)
num_accounts = options.get("num_accounts", 10)
num_txs = options.get("num_txs", 1000)
config_patch = options.get("config", {})
app_patch = options.get("app", {})
genesis_patch = options.get("genesis", {})
outdir = Path(outdir)
cli = ChainCommand(LOCAL_CRONOSD_PATH)
(outdir / VALIDATOR_GROUP).mkdir(parents=True, exist_ok=True)
Expand All @@ -67,7 +70,7 @@ def gen(

print("prepare genesis")
# use a full node directory to prepare the genesis file
genesis = gen_genesis(cli, outdir / FULLNODE_GROUP / "0", peers)
genesis = gen_genesis(cli, outdir / FULLNODE_GROUP / "0", peers, genesis_patch)

print("patch genesis")
# write genesis file and patch config files
Expand Down
Loading