Skip to content

Commit

Permalink
Problem: testground can't patch genesis (crypto-org-chain#1574)
Browse files Browse the repository at this point in the history
* Problem: testground can't patch genesis

* Apply suggestions from code review

* wrap options

* fix type

* Update testground/benchmark/benchmark/stateless.py

Signed-off-by: yihuang <[email protected]>

---------

Signed-off-by: yihuang <[email protected]>
Co-authored-by: mmsqe <[email protected]>
  • Loading branch information
yihuang and mmsqe authored Sep 13, 2024
1 parent 5c507d5 commit 753782d
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 15 deletions.
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

0 comments on commit 753782d

Please sign in to comment.