Skip to content

Commit ec6dbad

Browse files
committed
add generate_withdrawal_requests task
1 parent 1c3e206 commit ec6dbad

File tree

5 files changed

+525
-4
lines changed

5 files changed

+525
-4
lines changed

pkg/coordinator/tasks/generate_consolidations/task.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import (
2020
"github.com/ethpandaops/assertoor/pkg/coordinator/clients/consensus"
2121
"github.com/ethpandaops/assertoor/pkg/coordinator/clients/execution"
2222
"github.com/ethpandaops/assertoor/pkg/coordinator/types"
23-
"github.com/protolambda/zrnt/eth2/beacon/common"
2423
"github.com/sirupsen/logrus"
2524
"github.com/tyler-smith/go-bip39"
2625
util "github.com/wealdtech/go-eth2-util"
@@ -36,8 +35,6 @@ var (
3635
}
3736
)
3837

39-
var DomainConsolidation = common.BLSDomainType{0x0B, 0x00, 0x00, 0x00}
40-
4138
type Task struct {
4239
ctx *types.TaskContext
4340
options *types.TaskOptions
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
## `generate_withdrawal_requests` Task
2+
3+
### Description
4+
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.
5+
6+
### Configuration Parameters
7+
8+
- **`limitPerSlot`**:
9+
Specifies the maximum number of withdrawal requests allowed per slot, managing network load and ensuring efficient processing.
10+
11+
- **`limitTotal`**:
12+
Sets an upper limit on the total number of withdrawal requests that can be generated by this task.
13+
14+
- **`limitPending`**:
15+
Defines the maximum number of pending withdrawal requests allowed at any given time.
16+
17+
- **`sourceMnemonic`**:
18+
The mnemonic used to derive source validator keys from which withdrawals will be requested.
19+
20+
- **`sourceStartIndex`**:
21+
The starting index for key derivation from the source mnemonic.
22+
23+
- **`sourceStartValidatorIndex`**:
24+
An alternative to using `sourceMnemonic` and `sourceStartIndex`, this directly specifies the starting validator index for withdrawal requests.
25+
26+
- **`sourceIndexCount`**:
27+
The number of validators to include in the withdrawal process from the specified starting index.
28+
29+
- **`withdrawAmount`**:
30+
The amount in gwei to be withdrawn per request. Setting this to `0` triggers a full exit for the validator.
31+
32+
- **`walletPrivkey`**:
33+
The private key of the wallet initiating the withdrawal requests, necessary for transaction authorization.
34+
35+
- **`withdrawalContract`**:
36+
The address of the smart contract that handles the withdrawal requests on the blockchain.
37+
38+
- **`txAmount`**, **`txFeeCap`**, **`txTipCap`**, **`txGasLimit`**:
39+
Transaction parameters including the amount to be transferred, fee cap, tip cap, and gas limit, which dictate the economic aspects of the withdrawal transactions.
40+
41+
- **`clientPattern`**, **`excludeClientPattern`**:
42+
Regular expressions for selecting or excluding specific client endpoints for sending the withdrawal requests.
43+
44+
- **`awaitReceipt`**:
45+
Specifies whether to wait for a receipt confirmation for each transaction, confirming execution on the network.
46+
47+
- **`failOnReject`**:
48+
Determines if the task should fail upon transaction rejection, enhancing error handling and response strategies.
49+
50+
### Outputs
51+
52+
- **`transactionHashes`**:
53+
A list of hashes for the transactions that have been sent. This output provides identifiers for tracking the transactions on the blockchain.
54+
55+
- **`transactionReceipts`**:
56+
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.
57+
58+
### Defaults
59+
60+
Default settings for the `generate_withdrawal_requests` task:
61+
62+
```yaml
63+
- name: generate_withdrawal_requests
64+
config:
65+
limitPerSlot: 0
66+
limitTotal: 0
67+
limitPending: 0
68+
sourceMnemonic: ""
69+
sourceStartIndex: 0
70+
sourceStartValidatorIndex: null
71+
sourceIndexCount: 0
72+
withdrawAmount: 0
73+
walletPrivkey: ""
74+
withdrawalContract: 0x00A3ca265EBcb825B45F985A16CEFB49958cE017
75+
txAmount: "500000000000000000"
76+
txFeeCap: "100000000000"
77+
txTipCap: "1000000000"
78+
txGasLimit: 200000
79+
clientPattern: ""
80+
excludeClientPattern: ""
81+
awaitReceipt: false
82+
failOnReject: false
83+
```
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package generatewithdrawalrequests
2+
3+
import (
4+
"errors"
5+
"math/big"
6+
)
7+
8+
type Config struct {
9+
LimitPerSlot int `yaml:"limitPerSlot" json:"limitPerSlot"`
10+
LimitTotal int `yaml:"limitTotal" json:"limitTotal"`
11+
LimitPending int `yaml:"limitPending" json:"limitPending"`
12+
SourceMnemonic string `yaml:"sourceMnemonic" json:"sourceMnemonic"`
13+
SourceStartIndex int `yaml:"sourceStartIndex" json:"sourceStartIndex"`
14+
SourceStartValidatorIndex *uint64 `yaml:"sourceStartValidatorIndex" json:"sourceStartValidatorIndex"`
15+
SourceIndexCount int `yaml:"sourceIndexCount" json:"sourceIndexCount"`
16+
WithdrawAmount uint64 `yaml:"withdrawAmount" json:"withdrawAmount"`
17+
WalletPrivkey string `yaml:"walletPrivkey" json:"walletPrivkey"`
18+
WithdrawalContract string `yaml:"withdrawalContract" json:"withdrawalContract"`
19+
TxAmount *big.Int `yaml:"txAmount" json:"txAmount"`
20+
TxFeeCap *big.Int `yaml:"txFeeCap" json:"txFeeCap"`
21+
TxTipCap *big.Int `yaml:"txTipCap" json:"txTipCap"`
22+
TxGasLimit uint64 `yaml:"txGasLimit" json:"txGasLimit"`
23+
ClientPattern string `yaml:"clientPattern" json:"clientPattern"`
24+
ExcludeClientPattern string `yaml:"excludeClientPattern" json:"excludeClientPattern"`
25+
AwaitReceipt bool `yaml:"awaitReceipt" json:"awaitReceipt"`
26+
FailOnReject bool `yaml:"failOnReject" json:"failOnReject"`
27+
}
28+
29+
func DefaultConfig() Config {
30+
return Config{
31+
WithdrawalContract: "0x00A3ca265EBcb825B45F985A16CEFB49958cE017",
32+
TxAmount: big.NewInt(500000000000000000), // 0.5 ETH
33+
TxFeeCap: big.NewInt(100000000000), // 100 Gwei
34+
TxTipCap: big.NewInt(1000000000), // 1 Gwei
35+
TxGasLimit: 200000,
36+
}
37+
}
38+
39+
func (c *Config) Validate() error {
40+
if c.LimitTotal == 0 && c.LimitPerSlot == 0 {
41+
return errors.New("either limitTotal or limitPerSlot must be set")
42+
}
43+
44+
if c.SourceMnemonic == "" && c.SourceStartValidatorIndex == nil {
45+
return errors.New("either sourceMnemonic with sourceStartIndex or sourceStartValidatorIndex must be set")
46+
}
47+
48+
return nil
49+
}

0 commit comments

Comments
 (0)