feat(cli): add localnet command for cluster lifecycle and faucet#666
Draft
ByteYue wants to merge 2 commits into
Draft
feat(cli): add localnet command for cluster lifecycle and faucet#666ByteYue wants to merge 2 commits into
ByteYue wants to merge 2 commits into
Conversation
`gravity-cli localnet` wraps the existing `cluster/*.sh` scripts so the
common dev-loop tasks are one command away instead of bash invocations
with a remembered working directory:
- `localnet start [--nodes ...] [--wait-ready]` shells out to
`cluster/start.sh` and optionally polls `eth_blockNumber` until the
chain is producing blocks.
- `localnet stop [--nodes ...]` shells out to `cluster/stop.sh`.
- `localnet faucet --to <addr> --amount <eth>` sends a direct transfer
via alloy. Default funding key is the well-known anvil test account
(matches `cluster/faucet.sh`); can be overridden with `--from-key`
or `GRAVITY_LOCALNET_FAUCET_KEY`. Supports `--wei` for raw amounts
and `--output json` for scripting.
- `localnet reset [--force]` stops the cluster and removes the
configured `base_dir`. Prompts before deleting paths outside /tmp
unless `--force` is given.
The cluster scripts directory auto-discovers by walking up from CWD
looking for `cluster/start.sh` (up to 6 levels); `--cluster-dir` and
`GRAVITY_CLUSTER_DIR` override. `cluster.toml` is parsed for base_dir
and the first node's host/port so RPC URL derives automatically.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
gravity-cli localnetwraps the existingcluster/*.shscripts and adds a one-shot faucet so the common dev-loop is accessible without bash invocations and remembered working directories:localnet start [--nodes ...] [--wait-ready]— shells out tocluster/start.shand (optionally) pollseth_blockNumberuntil the chain produces blocks.localnet stop [--nodes ...]— shells out tocluster/stop.sh.localnet faucet --to <addr> --amount <eth>— direct alloy transfer. Default funding key is the well-known anvil test account (matchescluster/faucet.sh); overridable via--from-keyorGRAVITY_LOCALNET_FAUCET_KEY. Supports--weifor raw amounts and--output json.localnet reset [--force]— stops the cluster and removesbase_dir. Prompts before deleting paths outside/tmpunless--forceis given.Design notes
cluster/start.sh(up to 6 levels).--cluster-dir/GRAVITY_CLUSTER_DIRoverride.<cluster_dir>/cluster.toml. We parse onlycluster.base_dirandnodes[0].host/rpc_port— other keys are ignored.DEFAULT_ANVIL_FAUCET_KEY, the same anvil test accountcluster/faucet.shuses. Precedence:--from-key>GRAVITY_LOCALNET_FAUCET_KEY> default.Test plan
cargo build -p gravity_cli --profile quick-releasecleanlocalnet stopfrom/tmp→ clear "Could not locate cluster/start.sh" errorlocalnet stopfrom repo root → invokes stop.sh, reports no PID foundlocalnet faucet --to 0x... --amount 0.5against running localnet → tx submitted, receipt received, exit 0localnet faucet ... --wei 100→ treats amount as weiGRAVITY_LOCALNET_FAUCET_KEY=<anvil_1>override → tx sent from anvil account 1--output json localnet faucet→ structured receiptlocalnet reset --forcewith no cluster running → stops (no-op), reports base_dir missing, exits 0--to→ clear error, no tx submitted