Skip to content

Commit

Permalink
add generate_withdrawal_requests task
Browse files Browse the repository at this point in the history
  • Loading branch information
pk910 committed Oct 2, 2024
1 parent 1c3e206 commit ec6dbad
Show file tree
Hide file tree
Showing 5 changed files with 525 additions and 4 deletions.
3 changes: 0 additions & 3 deletions pkg/coordinator/tasks/generate_consolidations/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"github.com/ethpandaops/assertoor/pkg/coordinator/clients/consensus"
"github.com/ethpandaops/assertoor/pkg/coordinator/clients/execution"
"github.com/ethpandaops/assertoor/pkg/coordinator/types"
"github.com/protolambda/zrnt/eth2/beacon/common"
"github.com/sirupsen/logrus"
"github.com/tyler-smith/go-bip39"
util "github.com/wealdtech/go-eth2-util"
Expand All @@ -36,8 +35,6 @@ var (
}
)

var DomainConsolidation = common.BLSDomainType{0x0B, 0x00, 0x00, 0x00}

type Task struct {
ctx *types.TaskContext
options *types.TaskOptions
Expand Down
83 changes: 83 additions & 0 deletions pkg/coordinator/tasks/generate_withdrawal_requests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
## `generate_withdrawal_requests` Task

### Description
The `generate_withdrawal_requests` task facilitates the generation and submission of withdrawal requests to the Ethereum network. This task is crucial for simulating the process of withdrawing funds or exiting validators as part of execution layer triggered staking operations.

### Configuration Parameters

- **`limitPerSlot`**:
Specifies the maximum number of withdrawal requests allowed per slot, managing network load and ensuring efficient processing.

- **`limitTotal`**:
Sets an upper limit on the total number of withdrawal requests that can be generated by this task.

- **`limitPending`**:
Defines the maximum number of pending withdrawal requests allowed at any given time.

- **`sourceMnemonic`**:
The mnemonic used to derive source validator keys from which withdrawals will be requested.

- **`sourceStartIndex`**:
The starting index for key derivation from the source mnemonic.

- **`sourceStartValidatorIndex`**:
An alternative to using `sourceMnemonic` and `sourceStartIndex`, this directly specifies the starting validator index for withdrawal requests.

- **`sourceIndexCount`**:
The number of validators to include in the withdrawal process from the specified starting index.

- **`withdrawAmount`**:
The amount in gwei to be withdrawn per request. Setting this to `0` triggers a full exit for the validator.

- **`walletPrivkey`**:
The private key of the wallet initiating the withdrawal requests, necessary for transaction authorization.

- **`withdrawalContract`**:
The address of the smart contract that handles the withdrawal requests on the blockchain.

- **`txAmount`**, **`txFeeCap`**, **`txTipCap`**, **`txGasLimit`**:
Transaction parameters including the amount to be transferred, fee cap, tip cap, and gas limit, which dictate the economic aspects of the withdrawal transactions.

- **`clientPattern`**, **`excludeClientPattern`**:
Regular expressions for selecting or excluding specific client endpoints for sending the withdrawal requests.

- **`awaitReceipt`**:
Specifies whether to wait for a receipt confirmation for each transaction, confirming execution on the network.

- **`failOnReject`**:
Determines if the task should fail upon transaction rejection, enhancing error handling and response strategies.

### Outputs

- **`transactionHashes`**:
A list of hashes for the transactions that have been sent. This output provides identifiers for tracking the transactions on the blockchain.

- **`transactionReceipts`**:
If `awaitReceipt` is true, this will include the receipts for each transaction, providing details such as success status, gas used, and potentially logs if applicable.

### Defaults

Default settings for the `generate_withdrawal_requests` task:

```yaml
- name: generate_withdrawal_requests
config:
limitPerSlot: 0
limitTotal: 0
limitPending: 0
sourceMnemonic: ""
sourceStartIndex: 0
sourceStartValidatorIndex: null
sourceIndexCount: 0
withdrawAmount: 0
walletPrivkey: ""
withdrawalContract: 0x00A3ca265EBcb825B45F985A16CEFB49958cE017
txAmount: "500000000000000000"
txFeeCap: "100000000000"
txTipCap: "1000000000"
txGasLimit: 200000
clientPattern: ""
excludeClientPattern: ""
awaitReceipt: false
failOnReject: false
```
49 changes: 49 additions & 0 deletions pkg/coordinator/tasks/generate_withdrawal_requests/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package generatewithdrawalrequests

import (
"errors"
"math/big"
)

type Config struct {
LimitPerSlot int `yaml:"limitPerSlot" json:"limitPerSlot"`
LimitTotal int `yaml:"limitTotal" json:"limitTotal"`
LimitPending int `yaml:"limitPending" json:"limitPending"`
SourceMnemonic string `yaml:"sourceMnemonic" json:"sourceMnemonic"`
SourceStartIndex int `yaml:"sourceStartIndex" json:"sourceStartIndex"`
SourceStartValidatorIndex *uint64 `yaml:"sourceStartValidatorIndex" json:"sourceStartValidatorIndex"`
SourceIndexCount int `yaml:"sourceIndexCount" json:"sourceIndexCount"`
WithdrawAmount uint64 `yaml:"withdrawAmount" json:"withdrawAmount"`
WalletPrivkey string `yaml:"walletPrivkey" json:"walletPrivkey"`
WithdrawalContract string `yaml:"withdrawalContract" json:"withdrawalContract"`
TxAmount *big.Int `yaml:"txAmount" json:"txAmount"`
TxFeeCap *big.Int `yaml:"txFeeCap" json:"txFeeCap"`
TxTipCap *big.Int `yaml:"txTipCap" json:"txTipCap"`
TxGasLimit uint64 `yaml:"txGasLimit" json:"txGasLimit"`
ClientPattern string `yaml:"clientPattern" json:"clientPattern"`
ExcludeClientPattern string `yaml:"excludeClientPattern" json:"excludeClientPattern"`
AwaitReceipt bool `yaml:"awaitReceipt" json:"awaitReceipt"`
FailOnReject bool `yaml:"failOnReject" json:"failOnReject"`
}

func DefaultConfig() Config {
return Config{
WithdrawalContract: "0x00A3ca265EBcb825B45F985A16CEFB49958cE017",
TxAmount: big.NewInt(500000000000000000), // 0.5 ETH
TxFeeCap: big.NewInt(100000000000), // 100 Gwei
TxTipCap: big.NewInt(1000000000), // 1 Gwei
TxGasLimit: 200000,
}
}

func (c *Config) Validate() error {
if c.LimitTotal == 0 && c.LimitPerSlot == 0 {
return errors.New("either limitTotal or limitPerSlot must be set")
}

if c.SourceMnemonic == "" && c.SourceStartValidatorIndex == nil {
return errors.New("either sourceMnemonic with sourceStartIndex or sourceStartValidatorIndex must be set")
}

return nil
}
Loading

0 comments on commit ec6dbad

Please sign in to comment.