Skip to content

Commit

Permalink
aded exitEpoch setting to generate_exits task
Browse files Browse the repository at this point in the history
  • Loading branch information
pk910 committed Feb 25, 2024
1 parent d5ec53c commit f91341b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
4 changes: 4 additions & 0 deletions pkg/coordinator/tasks/generate_exits/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ The `generate_exits` task is designed to create and send voluntary exit transact
- **`indexCount`**:\
The number of validator keys to generate from the mnemonic, determining how many unique exit transactions will be created.

- **`exitEpoch`**:\
The exit epoch number set within the exit message. (defaults to head epoch)

- **`clientPattern`**:\
A regex pattern for selecting specific client endpoints for sending the exit transactions. If left empty, any available endpoint will be used.

Expand All @@ -39,6 +42,7 @@ Default settings for the `generate_exits` task:
mnemonic: ""
startIndex: 0
indexCount: 0
exitEpoch: -1
clientPattern: ""
excludeClientPattern: ""
```
1 change: 1 addition & 0 deletions pkg/coordinator/tasks/generate_exits/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ type Config struct {
Mnemonic string `yaml:"mnemonic" json:"mnemonic"`
StartIndex int `yaml:"startIndex" json:"startIndex"`
IndexCount int `yaml:"indexCount" json:"indexCount"`
ExitEpoch int64 `yaml:"exitEpoch" json:"exitEpoch"`
ClientPattern string `yaml:"clientPattern" json:"clientPattern"`
ExcludeClientPattern string `yaml:"excludeClientPattern" json:"excludeClientPattern"`
}
Expand Down
10 changes: 7 additions & 3 deletions pkg/coordinator/tasks/generate_exits/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,14 +228,18 @@ func (t *Task) generateVoluntaryExit(ctx context.Context, accountIdx uint64, for
}

// build voluntary exit message
currentSlot, _ := client.GetLastHead()
specs := clientPool.GetConsensusPool().GetBlockCache().GetSpecs()
currentEpoch := phase0.Epoch(currentSlot / phase0.Slot(specs.SlotsPerEpoch))
operation := &phase0.VoluntaryExit{
Epoch: currentEpoch,
ValidatorIndex: validator.Index,
}

if t.config.ExitEpoch >= 0 {
operation.Epoch = phase0.Epoch(t.config.ExitEpoch)
} else {
currentSlot, _ := client.GetLastHead()
operation.Epoch = phase0.Epoch(currentSlot / phase0.Slot(specs.SlotsPerEpoch))
}

root, err := operation.HashTreeRoot()
if err != nil {
return fmt.Errorf("failed to generate root for exit operation: %w", err)
Expand Down

0 comments on commit f91341b

Please sign in to comment.