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
- Remove provider from transaction enum variants
- Remove token and stake table addresses from transaction enum variants
- Consume transaction inputs when creating transactions
This works much better with ownership. Make code cleaner and we don't
have to use `take` anymore.
sveitser added a commit that referenced this pull request Oct 10, 2025
improve services dependencies:

- stake-for-demo only needs stake-table to be deployed
- sequencers should wait for stake-for-demo so that we don't
  race between the epoch root block arriving and the stake
  table funding having completed. This currently leads to a bit
  of a delay but should be much less of an issue once we have
  concurrent funding transactions from:

  #3639
Copy link
Contributor

@rob-maron rob-maron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything looks good high-level and usage-wise

Comment on lines +40 to +50
#[derive(Debug, Error)]
pub enum CreateTransactionsError {
#[error(
"insufficient ESP balance: have {have} ESP, need {need} ESP to fund {delegators} \
delegators"
)]
InsufficientEsp {
have: String,
need: String,
delegators: usize,
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love these

Comment on lines +132 to +133
.success()
.stdout(str::contains("ValidatorRegistered"));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, I like these tests

@sveitser sveitser merged commit d3269ac into main Oct 10, 2025
145 of 147 checks passed
@sveitser sveitser deleted the ma/stake-for-demo-concurrent-txns branch October 10, 2025 21:11
sveitser added a commit that referenced this pull request Oct 13, 2025
* feat: local demo on protocol v4 (drb and header)

improve services dependencies:

- stake-for-demo only needs stake-table to be deployed
- sequencers should wait for stake-for-demo so that we don't
  race between the epoch root block arriving and the stake
  table funding having completed. This currently leads to a bit
  of a delay but should be much less of an issue once we have
  concurrent funding transactions from:

  #3639
jbearer pushed a commit that referenced this pull request Oct 14, 2025
* feat: concurrent txns, better output

- 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

* fix: don't use deprecated method

* test: demo deploy without instant mining

(currently fails)

* fix: wait for dependent txns to finalize

* stake for demo with planned transactions

- 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.

* add missing "event" prefix

* fix: approval txns fail with geth in demo

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.

* fix: nonce errors due to duplicate provider

* remove unnecessary pending block ID

* cleanup: centralize receipt status check

* remove some useless variables

* update docs

* simplify types

- Remove provider from transaction enum variants
- Remove token and stake table addresses from transaction enum variants
- Consume transaction inputs when creating transactions

* separate processor and data types

This works much better with ownership. Make code cleaner and we don't
have to use `take` anymore.
jbearer pushed a commit that referenced this pull request Oct 14, 2025
* feat: local demo on protocol v4 (drb and header)

improve services dependencies:

- stake-for-demo only needs stake-table to be deployed
- sequencers should wait for stake-for-demo so that we don't
  race between the epoch root block arriving and the stake
  table funding having completed. This currently leads to a bit
  of a delay but should be much less of an issue once we have
  concurrent funding transactions from:

  #3639
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.

2 participants