Skip to content

coinbase-samples/eth-queue-timing-scripts-py

Repository files navigation

eth-queue-timing-scripts-py

Two sample scripts for estimating Ethereum validator timing:

  1. validator_activation_time.py - Estimate activation time for new validators
  2. validator_unstaking_time.py - Estimate withdrawal timing (all three types)

Quick Start

# Install dependencies
pip install requests python-dotenv

# Check activation time
python validator_activation_time.py 0xa8553ad...

# Check withdrawal status
python validator_unstaking_time.py 2103348

1. Activation Time Calculator

File: validator_activation_time.py

Estimate how long until a new validator activates.

Usage

# By validator pubkey
python validator_activation_time.py 0xa8553ad...

# With custom beacon node
python validator_activation_time.py --beacon-node https://your-node.com 0xa8553...

What It Shows

  • Position in pending deposits queue
  • ETH ahead in queue
  • Time until activation (includes churn + 5-epoch delay)
  • Estimated activation timestamp

Example Output

Validator position in queue: 1,945 of 3,664
ETH in queue ahead: 129,999.19 ETH

Activation estimate:
  Epochs until activation: 513
  Time until activation: 2 days, 6 hours, 43 minutes
  Estimated activation: 2025-10-09 19:50:48

2. Withdrawal Status Calculator

File: validator_unstaking_time.py

Calculates withdrawal timing. Automatically detects and displays timing for all three withdrawal types.

Usage

# By validator index (recommended)
python validator_unstaking_time.py 2103348

# By validator pubkey
python validator_unstaking_time.py 0xa8553ad...

# With custom beacon node
python validator_unstaking_time.py --beacon-node https://your-node.com 2103348

Three Withdrawal Types (Auto-Detected)

Automatic Partial Withdrawals

  • When: Balance > effective balance
  • Time: Sweep only (typically minutes to hours)
  • Validator: Stays active
  • 0x01: Auto-sweeps above 32 ETH
  • 0x02: Auto-sweeps above MaxEB (configurable, 32-2048 ETH)

Requested Partial Withdrawals (EIP-7002)

  • When: User submits withdrawal request transaction
  • Time: Churn queue + 256 epochs + sweep (typically days)
  • Validator: Stays active
  • 0x02 only: Compounding validators only

Full Exits

  • When: User submits exit request
  • Time: Churn queue + 256 epochs + sweep (typically days)
  • Validator: Becomes inactive

Example Output

======================================================================
WITHDRAWAL STATUS
======================================================================

✅ AUTOMATIC PARTIAL WITHDRAWAL
   Compounding (0x02): 0.0058 ETH excess above 34.0 ETH MaxEB
   Amount: 0.0058 ETH
   Time: less than 1 minute (sweep only)
   Validator stays active: YES ✓

⚠️  REQUESTED PARTIAL WITHDRAWAL(S) PENDING

   Request #1:
   Amount: 1.0000 ETH
   Withdrawable epoch: 408,147
   Time until withdrawable: 42 days, 10 hours
   Sweep time after: less than 1 minute
   Total time: 42 days, 10 hours, 27 minutes
   Estimated completion: 2025-11-19 04:46:41
   Validator stays active: YES ✓

❌ No Full Exit
   Validator is not exiting

======================================================================

Key Concepts (Pectra)

MaxEB (Maximum Effective Balance)

  • Each validator can set MaxEB from 32 to 2048 ETH
  • MaxEB is configurable per validator
  • View as effective_balance in validator data

Withdrawal Credentials

Prefix Type Behavior
0x01 Non-compounding Auto-sweeps above 32 ETH
0x02 Compounding Auto-sweeps above MaxEB, can submit partial withdrawal requests

Churn Rate (EIP-7251)

Post-Pectra, churn is balance-based (Gwei per epoch), not validator count:

churn = max(128 ETH, total_active_balance / 131,072)
churn = min(churn, 256 ETH)

With current network conditions (~35M ETH staked), churn is 256 ETH/epoch (capped at maximum).

Timing Constants

Constant Value Description
Slot 12 seconds One block
Epoch 32 slots 6.4 minutes
Withdrawability delay 256 epochs ~27.3 hours (after exit)
Sweep throughput 16/slot Max 115,200 withdrawals/day

API Endpoints Used

Both Scripts

  • /eth/v1/beacon/headers/head - Current slot/epoch
  • /eth/v1/beacon/states/head/validators - Validator data

Activation Script

  • /eth/v1/beacon/states/head/pending_deposits - Pending deposits queue

Withdrawal Script

  • /eth/v1/beacon/states/head/pending_partial_withdrawals - Requested partial withdrawals (EIP-7002)
  • /eth/v1/beacon/states/head/validators?status=active_exiting - Exit queue
  • /eth/v2/beacon/blocks/{slot} - Recent blocks (for sweep position)

Accuracy

Variations occur due to:

  • Queue size changes (new validators entering/exiting)
  • Churn rate fluctuations (total active balance changes)
  • Network conditions
  • API synchronization delays

These are meant to be estimation scripts, and times can vary depending on the factors listed above. Do not rely on this for systems that need true accuracy on entry and exit times.


Requirements

  • Python 3.7+
  • requests library
  • python-dotenv library
pip install requests python-dotenv

References

EIPs

  • EIP-6110 - Supply validator deposits on chain
  • EIP-7251 - Increase MAX_EFFECTIVE_BALANCE (MaxEB)
  • EIP-7002 - Execution layer triggerable exits/withdrawals
  • EIP-4895 - Beacon chain push withdrawals

Documentation

Tools


Examples

Check a new validator's activation time

python validator_activation_time.py <YOUR VALIDATOR PUBLIC KEY HERE>

Check if validator has automatic partial withdrawal eligible

python validator_unstaking_time.py <VALIDATOR_INDEX_OR_PUBKEY>
# Will show "✅ AUTOMATIC PARTIAL WITHDRAWAL" if balance > effective_balance

Check for requested partial withdrawal (EIP-7002)

python validator_unstaking_time.py <VALIDATOR_INDEX_OR_PUBKEY>
# Will show "⚠️ REQUESTED PARTIAL WITHDRAWAL(S) PENDING" if request exists

Check full exit status

python validator_unstaking_time.py <VALIDATOR_INDEX_OR_PUBKEY>
# Will show "🚨 FULL EXIT IN PROGRESS" if validator is exiting

License

The ETH Queue Timing Scripts are free and open source and released under the Apache License, Version 2.0.

The application and code are only available for demonstration purposes.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages