Skip to content

Commit 0b56fc2

Browse files
committed
feat: mass (un)delegation in stake table contract
1 parent 0f9da7c commit 0b56fc2

File tree

6 files changed

+1616
-52
lines changed

6 files changed

+1616
-52
lines changed

staking-cli/README.md

Lines changed: 77 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ This CLI helps users interact with the Espresso staking contract, either as a de
2626
- [Updating your metadata URL](#updating-your-metadata-url)
2727
- [De-registering your validator](#de-registering-your-validator)
2828
- [Rotating your consensus keys](#rotating-your-consensus-keys)
29+
- [Exporting Node Signatures](#exporting-node-signatures)
30+
- [Demo Commands](#demo-commands)
2931

3032
<!-- markdown-toc end -->
3133

@@ -82,7 +84,7 @@ Commands:
8284
token-allowance Check ESP token allowance of stake table contract
8385
transfer Transfer ESP tokens
8486
export-node-signatures Export validator node signatures for address validation
85-
stake-for-demo Register the validators and delegates for the local demo
87+
demo Demo commands for testing (stake, delegate, undelegate, churn)
8688
help Print this message or the help of the given subcommand(s)
8789
8890
Options:
@@ -379,13 +381,17 @@ Format handling:
379381
- Stdin defaults to JSON: `cat signatures.json | staking-cli register-validator --node-signatures - --commission 4.99`
380382
- Explicit format for stdin: `cat signatures.toml | staking-cli register-validator --node-signatures - --format toml --commission 4.99`
381383

382-
### Native Demo Staking
384+
### Demo Commands
383385

384-
The `stake-for-demo` command is used to set up validators and delegators for testing purposes.
386+
The `demo` subcommand provides tools for testing and demonstration purposes.
385387

386-
staking-cli stake-for-demo --num-validators 5
388+
#### `demo stake`
387389

388-
Configuration options:
390+
Register validators and create delegators for testing (formerly `stake-for-demo`).
391+
392+
staking-cli demo stake --num-validators 5
393+
394+
Options:
389395

390396
- `--num-validators`: Number of validators to register (default: 5)
391397
- `--num-delegators-per-validator`: Number of delegators per validator (default: random 2-5, max: 100,000)
@@ -395,15 +401,73 @@ Configuration options:
395401
- `multiple-delegators`: Multiple delegators per validator
396402
- `no-self-delegation`: Validators do not self-delegate
397403

398-
Environment variables:
404+
Example:
405+
406+
staking-cli demo stake --num-validators 10 --num-delegators-per-validator 50
407+
408+
#### `demo delegate`
409+
410+
Mass delegate to existing validators with deterministic delegator generation.
411+
412+
staking-cli demo delegate \
413+
--validators 0xAAA,0xBBB,0xCCC \
414+
--delegator-start-index 0 \
415+
--num-delegators 100 \
416+
--min-amount 100 \
417+
--max-amount 500
418+
419+
Options:
420+
421+
- `--validators`: Comma-separated validator addresses to delegate to
422+
- `--delegator-start-index`: Starting index for deterministic delegator generation
423+
- `--num-delegators`: Number of delegators to create
424+
- `--min-amount`: Minimum delegation amount in ESP
425+
- `--max-amount`: Maximum delegation amount in ESP
426+
- `--batch-size`: Number of transactions to submit per batch (default: all at once)
427+
- `--delay`: Delay between batches (e.g., "1s", "500ms"); requires `--batch-size`
428+
429+
Delegators are distributed round-robin across validators.
399430

400-
- `NUM_DELEGATORS_PER_VALIDATOR`: Set the number of delegators per validator
401-
- `DELEGATION_CONFIG`: Set the delegation configuration mode
431+
#### `demo undelegate`
402432

403-
Example usage:
433+
Mass undelegate from validators. Queries on-chain delegation amounts and undelegates everything.
434+
435+
staking-cli demo undelegate \
436+
--validators 0xAAA,0xBBB \
437+
--delegator-start-index 0 \
438+
--num-delegators 100
439+
440+
Options:
441+
442+
- `--validators`: Comma-separated validator addresses to undelegate from
443+
- `--delegator-start-index`: Starting index for delegator generation
444+
- `--num-delegators`: Number of delegators
445+
- `--batch-size`: Number of transactions to submit per batch (default: all at once)
446+
- `--delay`: Delay between batches (e.g., "1s", "500ms"); requires `--batch-size`
447+
448+
Skips delegators with zero delegation to a validator.
449+
450+
#### `demo churn`
451+
452+
Continuous delegation/undelegation activity forever. Useful for testing stake table changes.
453+
454+
staking-cli demo churn \
455+
--validator-start-index 20 \
456+
--num-validators 5 \
457+
--delegator-start-index 0 \
458+
--num-delegators 50 \
459+
--min-amount 100 \
460+
--max-amount 500 \
461+
--delay 2s
462+
463+
Options:
404464

405-
# Create 10 validators with 50 delegators each
406-
staking-cli stake-for-demo --num-validators 10 --num-delegators-per-validator 50
465+
- `--validator-start-index`: Starting mnemonic index for validators (default: 20)
466+
- `--num-validators`: Number of validators to target
467+
- `--delegator-start-index`: Starting index for delegator generation
468+
- `--num-delegators`: Number of delegators in the pool
469+
- `--min-amount`: Minimum delegation amount in ESP
470+
- `--max-amount`: Maximum delegation amount in ESP
471+
- `--delay`: Delay between operations (default: "1s")
407472

408-
# Using environment variables with native demo
409-
env NUM_DELEGATORS_PER_VALIDATOR=1000 DELEGATION_CONFIG=no-self-delegation just demo-native-drb-header
473+
The churn loop picks random delegators and either delegates (if idle) or undelegates (if delegated).

0 commit comments

Comments
 (0)