Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--tolerance on find-stale-pods #144

Merged
merged 5 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion cli/commands/findStalePods.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@ type TFindStalePodsCommandArgs struct {
EthNode string
BeaconNode string
Verbose bool
Tolerance float64
}

func FindStalePodsCommand(args TFindStalePodsCommandArgs) error {
ctx := context.Background()
eth, beacon, chainId, err := core.GetClients(ctx, args.EthNode, args.BeaconNode /* verbose */, args.Verbose)
core.PanicOnError("failed to dial clients", err)

results, err := core.FindStaleEigenpods(ctx, eth, args.EthNode, beacon, chainId, args.Verbose)
results, err := core.FindStaleEigenpods(ctx, eth, args.EthNode, beacon, chainId, args.Verbose, args.Tolerance)
core.PanicOnError("failed to find stale eigenpods", err)

if !args.Verbose {
Expand Down
8 changes: 3 additions & 5 deletions cli/core/findStalePods.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ type PodOwnerShare struct {
IsEigenpod bool
}

const ACCEPTABLE_BALANCE_DEVIATION = float64(0.95)

var cache Cache // valid for the duration of a command.

func isEigenpod(eth *ethclient.Client, chainId uint64, eigenpodAddress string) (bool, error) {
Expand Down Expand Up @@ -127,7 +125,7 @@ func executionWithdrawalAddress(withdrawalCredentials []byte) *string {
return &addr
}

func FindStaleEigenpods(ctx context.Context, eth *ethclient.Client, nodeUrl string, beacon BeaconClient, chainId *big.Int, verbose bool) (map[string][]ValidatorWithIndex, error) {
func FindStaleEigenpods(ctx context.Context, eth *ethclient.Client, nodeUrl string, beacon BeaconClient, chainId *big.Int, verbose bool, tolerance float64) (map[string][]ValidatorWithIndex, error) {
beaconState, err := beacon.GetBeaconState(ctx, "head")
if err != nil {
return nil, fmt.Errorf("error downloading beacon state: %s", err.Error())
Expand Down Expand Up @@ -246,7 +244,7 @@ func FindStaleEigenpods(ctx context.Context, eth *ethclient.Client, nodeUrl stri
return false
}
executionBalance := cache.PodOwnerShares[eigenpod].SharesWei
if balance <= uint64(float64(executionBalance)*ACCEPTABLE_BALANCE_DEVIATION) {
if balance <= uint64(float64(executionBalance)*(1-(tolerance/100))) {
if verbose {
log.Printf("[%s] %.2f%% deviation (beacon: %d -> execution: %d)\n", eigenpod, 100*(float64(executionBalance)-float64(balance))/float64(executionBalance), balance, executionBalance)
}
Expand All @@ -258,7 +256,7 @@ func FindStaleEigenpods(ctx context.Context, eth *ethclient.Client, nodeUrl stri

if len(unhealthyEigenpods) == 0 {
if verbose {
log.Println("All slashed eigenpods are within 5% of their expected balance.")
log.Printf("All slashed eigenpods are within %f%% of their expected balance.\n", tolerance)
}
return map[string][]ValidatorWithIndex{}, nil
}
Expand Down
10 changes: 10 additions & 0 deletions cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,15 @@
var estimateGas = false
var slashedValidatorIndex uint64

const DEFAULT_HEALTHCHECK_TOLERANCE = float64(5.0)

Check failure on line 19 in cli/main.go

View workflow job for this annotation

GitHub Actions / lint

var-naming: don't use ALL_CAPS in Go names; use CamelCase (revive)

func main() {
var batchSize uint64
var forceCheckpoint = false
var disableColor = false
var verbose = false
var noPrompt = false
var tolerance = DEFAULT_HEALTHCHECK_TOLERANCE

app := &cli.App{
Name: "Eigenlayer Proofs CLi",
Expand All @@ -38,12 +41,19 @@
Flags: []cli.Flag{
ExecNodeFlag,
BeaconNodeFlag,
&cli.Float64Flag{
Name: "tolerance",
Value: DEFAULT_HEALTHCHECK_TOLERANCE, // default: 5
Usage: "The percentage balance deviation to tolerate when deciding whether an eigenpod should be corrected. Default is 5% (e.g --tolerance 5).",
Destination: &tolerance,
},
},
Action: func(_ *cli.Context) error {
return commands.FindStalePodsCommand(commands.TFindStalePodsCommandArgs{
EthNode: node,
BeaconNode: beacon,
Verbose: verbose,
Tolerance: tolerance,
})
},
},
Expand Down
Loading