Skip to content

Commit

Permalink
Merge pull request #238 from ethpandaops/pk910/warnings-for-invalid-o…
Browse files Browse the repository at this point in the history
…perations

add warnings for invalid el triggered consolidations & withdrawals
  • Loading branch information
pk910 authored Feb 17, 2025
2 parents 83f33f7 + 9f14bec commit 562267b
Show file tree
Hide file tree
Showing 9 changed files with 74 additions and 26 deletions.
1 change: 1 addition & 0 deletions clients/consensus/chainspec.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ type ChainSpec struct {
MaxWithdrawalRequestsPerPayload uint64 `yaml:"MAX_WITHDRAWAL_REQUESTS_PER_PAYLOAD" check-if-fork:"ElectraForkEpoch"`
DepositChainId uint64 `yaml:"DEPOSIT_CHAIN_ID"`
MinActivationBalance uint64 `yaml:"MIN_ACTIVATION_BALANCE"`
ShardCommitteePeriod uint64 `yaml:"SHARD_COMMITTEE_PERIOD"`

// EIP7594: PeerDAS
NumberOfColumns *uint64 `yaml:"NUMBER_OF_COLUMNS" check-if-fork:"Eip7594ForkEpoch"`
Expand Down
21 changes: 15 additions & 6 deletions handlers/submit_consolidation.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ import (
"time"

v1 "github.com/attestantio/go-eth2-client/api/v1"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/ethereum/go-ethereum/common"
"github.com/sirupsen/logrus"

"github.com/ethpandaops/dora/dbtypes"
"github.com/ethpandaops/dora/indexer/beacon"
"github.com/ethpandaops/dora/indexer/execution"
"github.com/ethpandaops/dora/services"
"github.com/ethpandaops/dora/templates"
Expand Down Expand Up @@ -105,9 +107,10 @@ func handleSubmitConsolidationPageDataAjax(w http.ResponseWriter, r *http.Reques

switch query.Get("ajax") {
case "load_validators":
chainState := services.GlobalBeaconService.GetChainState()
chainSpecs := chainState.GetSpecs()
address := query.Get("address")
addressBytes := common.HexToAddress(address)

validators, _ := services.GlobalBeaconService.GetFilteredValidatorSet(&dbtypes.ValidatorFilter{
WithdrawalAddress: addressBytes[:],
}, true)
Expand All @@ -131,12 +134,18 @@ func handleSubmitConsolidationPageDataAjax(w http.ResponseWriter, r *http.Reques
status = validator.Status.String()
}

consolidable := false
if validator.Validator.ActivationEpoch < beacon.FarFutureEpoch && validator.Validator.ActivationEpoch+phase0.Epoch(chainSpecs.ShardCommitteePeriod) > chainState.CurrentEpoch() {
consolidable = true
}

result = append(result, models.SubmitConsolidationPageDataValidator{
Index: uint64(validator.Index),
Pubkey: validator.Validator.PublicKey.String(),
Balance: uint64(validator.Balance),
CredType: fmt.Sprintf("%02x", validator.Validator.WithdrawalCredentials[0]),
Status: status,
Index: uint64(validator.Index),
Pubkey: validator.Validator.PublicKey.String(),
Balance: uint64(validator.Balance),
CredType: fmt.Sprintf("%02x", validator.Validator.WithdrawalCredentials[0]),
Status: status,
IsConsolidable: consolidable,
})
}

Expand Down
21 changes: 15 additions & 6 deletions handlers/submit_withdrawal.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ import (
"time"

v1 "github.com/attestantio/go-eth2-client/api/v1"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/ethereum/go-ethereum/common"
"github.com/sirupsen/logrus"

"github.com/ethpandaops/dora/dbtypes"
"github.com/ethpandaops/dora/indexer/beacon"
"github.com/ethpandaops/dora/indexer/execution"
"github.com/ethpandaops/dora/services"
"github.com/ethpandaops/dora/templates"
Expand Down Expand Up @@ -106,9 +108,10 @@ func handleSubmitWithdrawalPageDataAjax(w http.ResponseWriter, r *http.Request)

switch query.Get("ajax") {
case "load_validators":
chainState := services.GlobalBeaconService.GetChainState()
chainSpecs := chainState.GetSpecs()
address := query.Get("address")
addressBytes := common.HexToAddress(address)

validators, _ := services.GlobalBeaconService.GetFilteredValidatorSet(&dbtypes.ValidatorFilter{
WithdrawalAddress: addressBytes[:],
}, true)
Expand All @@ -132,12 +135,18 @@ func handleSubmitWithdrawalPageDataAjax(w http.ResponseWriter, r *http.Request)
status = validator.Status.String()
}

withdrawable := false
if validator.Validator.ActivationEpoch < beacon.FarFutureEpoch && validator.Validator.ActivationEpoch+phase0.Epoch(chainSpecs.ShardCommitteePeriod) > chainState.CurrentEpoch() {
withdrawable = true
}

result = append(result, models.SubmitWithdrawalPageDataValidator{
Index: uint64(validator.Index),
Pubkey: validator.Validator.PublicKey.String(),
Balance: uint64(validator.Balance),
CredType: fmt.Sprintf("%02x", validator.Validator.WithdrawalCredentials[0]),
Status: status,
Index: uint64(validator.Index),
Pubkey: validator.Validator.PublicKey.String(),
Balance: uint64(validator.Balance),
CredType: fmt.Sprintf("%02x", validator.Validator.WithdrawalCredentials[0]),
Status: status,
IsWithdrawable: withdrawable,
})
}

Expand Down
11 changes: 6 additions & 5 deletions types/models/submit_consolidation.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ type SubmitConsolidationPageData struct {
}

type SubmitConsolidationPageDataValidator struct {
Index uint64 `json:"index"`
Pubkey string `json:"pubkey"`
Balance uint64 `json:"balance"`
CredType string `json:"credtype"`
Status string `json:"status"`
Index uint64 `json:"index"`
Pubkey string `json:"pubkey"`
Balance uint64 `json:"balance"`
CredType string `json:"credtype"`
Status string `json:"status"`
IsConsolidable bool `json:"isconsolidable"`
}
11 changes: 6 additions & 5 deletions types/models/submit_withdrawal.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ type SubmitWithdrawalPageData struct {
}

type SubmitWithdrawalPageDataValidator struct {
Index uint64 `json:"index"`
Pubkey string `json:"pubkey"`
Balance uint64 `json:"balance"`
CredType string `json:"credtype"`
Status string `json:"status"`
Index uint64 `json:"index"`
Pubkey string `json:"pubkey"`
Balance uint64 `json:"balance"`
CredType string `json:"credtype"`
Status string `json:"status"`
IsWithdrawable bool `json:"iswithdrawable"`
}
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,18 @@ const ConsolidationReview = (props: IConsolidationReviewProps) => {
The network is not on Electra yet, so consolidation requests can not be submitted.
</div>
: <div>
{!props.sourceValidator.isconsolidable && (
<div className="alert alert-warning" role="alert">
<i className="fa-solid fa-triangle-exclamation me-2"></i>
This consolidation will fail because the source validator is not withdrawable yet. The validator must be withdrawable before it can be consolidated.
</div>
)}
{props.targetValidator.credtype !== "0x02" && props.targetValidator.index != props.sourceValidator.index && (
<div className="alert alert-warning" role="alert">
<i className="fa-solid fa-triangle-exclamation me-2"></i>
This consolidation will fail because the target validator does not have 0x02 withdrawal credentials. The target validator must first perform a self-consolidation to update its withdrawal credentials to 0x02.
</div>
)}
<div className="row">
<div className="col-3 col-lg-2">
Consolidation Contract:
Expand Down Expand Up @@ -231,7 +243,11 @@ const ConsolidationReview = (props: IConsolidationReviewProps) => {
</div>
<div className="row mt-3">
<div className="col-12">
<button className="btn btn-primary" disabled={submitRequest.isPending || submitRequest.isSuccess} onClick={() => submitConsolidation()}>
<button
className="btn btn-primary"
disabled={submitRequest.isPending || submitRequest.isSuccess}
onClick={() => submitConsolidation()}
>
{submitRequest.isSuccess ?
<span>Submitted</span> :
submitRequest.isPending ? (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

export interface ISubmitConsolidationsFormProps {
consolidationContract: string;
explorerUrl: string;
Expand All @@ -11,4 +10,5 @@ export interface IValidator {
credtype: string;
balance: number;
status: string;
isconsolidable: boolean;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

export interface ISubmitWithdrawalsFormProps {
withdrawalContract: string;
explorerUrl: string;
Expand All @@ -12,4 +11,5 @@ export interface IValidator {
credtype: string;
balance: number;
status: string;
iswithdrawable: boolean;
}
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,13 @@ const WithdrawalReview = (props: IWithdrawalReviewProps) => {
The network is not on Electra yet, so withdrawal requests can not be submitted.
</div>
: <div>
{!props.validator.iswithdrawable && (
<div className="alert alert-warning" role="alert">
<i className="fa-solid fa-triangle-exclamation me-2"></i>
This withdrawal will fail because the validator is not withdrawable yet. The validator must be withdrawable before funds can be withdrawn.
</div>
)}

<div className="row">
<div className="col-3 col-lg-2">
Withdrawal Contract:
Expand Down Expand Up @@ -231,7 +238,11 @@ const WithdrawalReview = (props: IWithdrawalReviewProps) => {
</div>
<div className="row mt-3">
<div className="col-12">
<button className="btn btn-primary" disabled={submitRequest.isPending || submitRequest.isSuccess} onClick={() => submitWithdrawal()}>
<button
className="btn btn-primary"
disabled={submitRequest.isPending || submitRequest.isSuccess}
onClick={() => submitWithdrawal()}
>
{submitRequest.isSuccess ?
<span>Submitted</span> :
submitRequest.isPending ? (
Expand Down

0 comments on commit 562267b

Please sign in to comment.