Skip to content

Conversation

sveitser
Copy link
Collaborator

@sveitser sveitser commented Oct 3, 2025

Concurrent transaction submission for demo staking

  • Add a type to represent planned transactions.
  • Give caller control over submission and awaiting of transactions
    while enforcing that dependencies are respected.
  • Add balance check.
  • Add tests.

staking-cli improvments:

  • output events
  • check for events in tests
  • add test to inspect output manually
  • when used as CLI: output to stdout/stderr consistently, use stdout for CLI output, stderr for errors and diagnostics
  • (unchanged) always use tracing if RUST_LOG_FORMAT=json

Example:

cargo test -p staking-cli -- manual --nocapture
...
2025-10-06T11:04:47.753947Z  INFO staking_cli: Deregistering validator 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266
Success! transaction hash: 0x0245b8666169efe6500be3b737cf15de4c5ba0fc52924f15c16f37d46d854d77
event: ValidatorExit { validator: 0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266 }

2025-10-06T11:04:47.771906Z  INFO staking_cli: Claiming withdrawal for 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266
Success! transaction hash: 0xd712b4fcf5d5b1a0d2fbb223f2c3cb3b456ef9611b7c1539b8d3eecc74777e32
event: Transfer { from: 0x0dcd1bf9a1b36ce34237eeafef220932846bcd82, to: 0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266, value: 200000000000000000000 }
event: Withdrawal { account: 0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266, amount: 200000000000000000000 }

2025-10-06T11:04:47.815836Z  INFO staking_cli: Claiming validator exit for 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266
Success! transaction hash: 0x645408098515f9b29c210987c4a3602cc36dcd1565bbc118dd41b0972e75db5d
event: Transfer { from: 0x0dcd1bf9a1b36ce34237eeafef220932846bcd82, to: 0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266, value: 300000000000000000000 }
event: Withdrawal { account: 0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266, amount: 300000000000000000000 }

Notes for reviewers

The changeset is large but most of the code changes don't change behaviour. Everything demo.rs is only used for tests or private testnet setup.

To run the staking-cli tests: cargo test -p staking-cli


- allow broadcasting txns without awaiting
- output events
- check for events in tests
- add test to inspect output manually
- output to stdout/stderr consistently
- always use tracing if RUST_LOG_FORMAT=json
@sveitser sveitser changed the title feat: concurrent txns, better output feat: staking-cli: concurrent txns, better output Oct 3, 2025
- Add a type to represent planned transactions.
- Give caller control over submission and awaiting of transactions
  while enforcing that dependencies are respected.
- Add balance check.
- Add tests.
For some reason the behaviour is different than anvil. I'm not sure if
this always fails due to how geth works or if it's just a race
condition. In any event it seems adding another transaction receipt
await point for approvals seems easier than getting to the bottom of
this.

If this turns out to be too slow we should just manually track nonces.
@sveitser sveitser marked this pull request as ready for review October 6, 2025 14:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant