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

test(node-api): Introduce E2E tests for existing beacon endpoints #1983

Open
wants to merge 103 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 88 commits
Commits
Show all changes
103 commits
Select commit Hold shift + click to select a range
c0ac57d
add test for fork and others
nidhi-singh02 Aug 29, 2024
fa09476
clean
calbera Aug 29, 2024
23c153f
fix
calbera Aug 29, 2024
b313f6f
nit
calbera Aug 29, 2024
4204be8
uint64 -> math.Epoch
calbera Aug 29, 2024
adca130
undo
calbera Aug 29, 2024
2f56ea6
clean
calbera Aug 29, 2024
4069654
Add route
calbera Aug 29, 2024
a148aa6
route
calbera Aug 29, 2024
d3e2b2f
func for each endpoint
nidhi-singh02 Aug 30, 2024
65e4595
override fix
calbera Sep 3, 2024
0b3cfef
create func in consensus clients
nidhi-singh02 Sep 3, 2024
e7c4bea
adding validatorBalances in interface
nidhi-singh02 Sep 4, 2024
0648791
build is working now
nidhi-singh02 Sep 4, 2024
5a6d460
pass body to val balance
nidhi-singh02 Sep 4, 2024
d773ac3
validator balancer api working directly
nidhi-singh02 Sep 6, 2024
fb35087
randao response
nidhi-singh02 Sep 6, 2024
ca5cec3
enhance in rando - workingg
nidhi-singh02 Sep 6, 2024
f617612
validator status bug resolved
nidhi-singh02 Sep 6, 2024
45f66a3
nilaway go awayyy
nidhi-singh02 Sep 6, 2024
9b7be70
linter are you happy
nidhi-singh02 Sep 6, 2024
31f1e84
why are you suprising me linter
nidhi-singh02 Sep 6, 2024
9bab8a4
validator bal - correct tags
nidhi-singh02 Sep 6, 2024
af9a6e8
create customFork struct
nidhi-singh02 Sep 7, 2024
38b3e49
lint lint linter
nidhi-singh02 Sep 7, 2024
b599c2e
validator data format
nidhi-singh02 Sep 7, 2024
b4f095e
few optimization in val
nidhi-singh02 Sep 7, 2024
13bf5fa
tidy sync
nidhi-singh02 Sep 7, 2024
1d52853
directly use ValidatorData
nidhi-singh02 Sep 7, 2024
e7193ff
linting
nidhi-singh02 Sep 7, 2024
c0ba37c
bet
nidhi-singh02 Sep 7, 2024
674a627
refactor code
nidhi-singh02 Sep 7, 2024
aa44929
enchancements in fork
nidhi-singh02 Sep 8, 2024
09438ee
request type changes - cleanup
nidhi-singh02 Sep 8, 2024
76b432e
refactor validators bal
nidhi-singh02 Sep 8, 2024
294981f
more test assertions added
nidhi-singh02 Sep 8, 2024
05de47b
linter
nidhi-singh02 Sep 8, 2024
1ce1ee9
nits comments
nidhi-singh02 Sep 9, 2024
4b333b9
create interface type for fork
nidhi-singh02 Sep 10, 2024
942ad39
asserting to interface for ForkT
nidhi-singh02 Sep 10, 2024
6c32e57
Fork interface correct impl
nidhi-singh02 Sep 10, 2024
d87a851
generate check
nidhi-singh02 Sep 10, 2024
4ed066a
linter
nidhi-singh02 Sep 10, 2024
318739a
use fork wrapper
nidhi-singh02 Sep 10, 2024
77cfd3e
remove fork generic
calbera Sep 10, 2024
6f0a5d6
Remove custom MarshalJSON function in favor of json string tags
calbera Sep 10, 2024
a556242
make new func part of Fork interface
nidhi-singh02 Sep 10, 2024
f3020be
using fork interface
nidhi-singh02 Sep 10, 2024
8179a31
Revert "Remove custom MarshalJSON function in favor of json string tags"
nidhi-singh02 Sep 10, 2024
35c7e92
Merge branch 'main' into e2e-node-api
nidhi-singh02 Sep 12, 2024
84a170a
tidy sync
nidhi-singh02 Sep 7, 2024
4f31cb8
bet
nidhi-singh02 Sep 7, 2024
c2d62c6
validator using MarshalJSON
nidhi-singh02 Sep 12, 2024
c65706b
refactor - getters
nidhi-singh02 Sep 12, 2024
6205ab4
cleanup
nidhi-singh02 Sep 12, 2024
b9f9e95
Merge branch 'main' into e2e-node-api
nidhi-singh02 Sep 13, 2024
e739cde
few enhancements
nidhi-singh02 Sep 13, 2024
3187ef2
lint
nidhi-singh02 Sep 13, 2024
af1cd47
use types.Wrap and few enhancements
nidhi-singh02 Sep 13, 2024
a9e4cf3
linter fix
nidhi-singh02 Sep 13, 2024
34329f3
validator balance marshal as no tag
nidhi-singh02 Sep 13, 2024
0d965da
Merge branch 'main' into e2e-node-api
nidhi-singh02 Sep 14, 2024
b745f33
use ValidataData for response
nidhi-singh02 Sep 14, 2024
0e19a55
ValidatorT redundant - cleanup
nidhi-singh02 Sep 14, 2024
43d42c0
directly use validator
nidhi-singh02 Sep 14, 2024
759e772
validator generics
calbera Sep 16, 2024
101e3e1
gen
calbera Sep 16, 2024
3baca83
Merge branch 'main' of github.com:berachain/beacon-kit into e2e-node-api
calbera Sep 16, 2024
16b4232
undo
calbera Sep 16, 2024
23c994d
define type outside generic method
nidhi-singh02 Sep 17, 2024
79e09f7
generate check
nidhi-singh02 Sep 17, 2024
9a81b69
Update mod/node-api/handlers/debug/routes.go
calbera Sep 17, 2024
030b3bf
pointer
calbera Sep 17, 2024
01ee136
Merge branch 'main' of github.com:berachain/beacon-kit into e2e-node-api
calbera Sep 17, 2024
9107176
same pattern
calbera Sep 17, 2024
f374565
remove unneeded changes
calbera Sep 17, 2024
51e5376
pick constants from same package and use ptr
nidhi-singh02 Sep 20, 2024
5669ecf
do not use wrap - unnecessary changes remove
nidhi-singh02 Sep 23, 2024
f232fa8
make withdrawCredentails revert
nidhi-singh02 Sep 23, 2024
6850e67
generate check
nidhi-singh02 Sep 23, 2024
5413aa1
add comment for validator interface
nidhi-singh02 Sep 23, 2024
078ab60
rename fork
nidhi-singh02 Sep 23, 2024
db5e599
reverted constants changes in echo
nidhi-singh02 Sep 24, 2024
3aa512b
use validator with generic type
nidhi-singh02 Sep 24, 2024
81c9088
Merge branch 'main' into e2e-node-api
nidhi-singh02 Sep 24, 2024
2c8e6c3
generate check
nidhi-singh02 Sep 24, 2024
1b2792b
validator with generic type
nidhi-singh02 Sep 24, 2024
e3cec53
WithdrawalCredentialsT generic introduce - wip
nidhi-singh02 Sep 24, 2024
e10df63
withdrawal credentials building
calbera Sep 24, 2024
f6e5cdd
nits
nidhi-singh02 Sep 24, 2024
494d9d6
linter and generate
nidhi-singh02 Sep 24, 2024
d525150
comments
nidhi-singh02 Sep 24, 2024
a1d3834
Merge branch 'main' into e2e-node-api
nidhi-singh02 Sep 25, 2024
89ca105
Merge branch 'main' into e2e-node-api
nidhi-singh02 Sep 26, 2024
f4be7e8
Merge branch 'main' into e2e-node-api
nidhi-singh02 Sep 27, 2024
c1c5e46
Merge branch 'main' into e2e-node-api
nidhi-singh02 Sep 30, 2024
0dc0c1c
generate check
nidhi-singh02 Sep 30, 2024
c028c65
Merge branch 'main' into e2e-node-api
nidhi-singh02 Oct 1, 2024
99af839
Merge branch 'main' into e2e-node-api
nidhi-singh02 Oct 3, 2024
068f3c6
Merge branch 'main' into e2e-node-api
nidhi-singh02 Oct 4, 2024
30de37e
generate check
nidhi-singh02 Oct 4, 2024
d4caf1d
Merge branch 'main' into e2e-node-api
nidhi-singh02 Oct 8, 2024
dccfde1
Merge branch 'main' into e2e-node-api
nidhi-singh02 Oct 17, 2024
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
22 changes: 17 additions & 5 deletions examples/berad/pkg/consensus-types/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ type Validator struct {
// Pubkey is the validator's 48-byte BLS public key.
Pubkey crypto.BLSPubkey `json:"pubkey"`
// WithdrawalCredentials are an address that controls the validator.
WithdrawalCredentials types.WithdrawalCredentials `json:"withdrawalCredentials"`
WithdrawalCredentials types.WithdrawalCredentials `json:"withdrawal_credentials"`
nidhi-singh02 marked this conversation as resolved.
Show resolved Hide resolved
// EffectiveBalance is the validator's current effective balance in gwei.
EffectiveBalance math.Gwei `json:"effectiveBalance"`
EffectiveBalance math.Gwei `json:"effective_balance"`
// ActivationEpoch is the epoch in which the validator activated.
ActivationEpoch math.Epoch `json:"activationEpoch"`
ActivationEpoch math.Epoch `json:"activation_epoch"`
nidhi-singh02 marked this conversation as resolved.
Show resolved Hide resolved
// ExitEpoch is the epoch in which the validator exited.
ExitEpoch math.Epoch `json:"exitEpoch"`
ExitEpoch math.Epoch `json:"exit_epoch"`
// WithdrawableEpoch is the epoch in which the validator can withdraw.
WithdrawableEpoch math.Epoch `json:"withdrawableEpoch"`
WithdrawableEpoch math.Epoch `json:"withdrawable_epoch"`
}

/* -------------------------------------------------------------------------- */
Expand Down Expand Up @@ -233,3 +233,15 @@ func (v Validator) GetWithdrawableEpoch() math.Epoch {
func (v Validator) GetWithdrawalCredentials() types.WithdrawalCredentials {
return v.WithdrawalCredentials
}

// GetActivationEpoch returns the activation epoch of the validator.
func (v *Validator) GetActivationEpoch() math.Epoch {
return v.ActivationEpoch
}

// GetExitEpoch returns the exit epoch of the validator.
func (v *Validator) GetExitEpoch() math.Epoch {
return v.ExitEpoch
}

//
21 changes: 20 additions & 1 deletion mod/consensus-types/pkg/types/fork.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func (f *Fork) HashTreeRootWith(hh fastssz.HashWalker) error {
hh.PutBytes(f.CurrentVersion[:])

// Field (2) 'Epoch'
hh.PutUint64(uint64(f.Epoch))
hh.PutUint64(f.Epoch.Unwrap())

hh.Merkleize(indx)
return nil
Expand All @@ -139,3 +139,22 @@ func (f *Fork) HashTreeRootWith(hh fastssz.HashWalker) error {
func (f *Fork) GetTree() (*fastssz.Node, error) {
return fastssz.ProofTree(f)
}
nidhi-singh02 marked this conversation as resolved.
Show resolved Hide resolved

/* -------------------------------------------------------------------------- */
/* Getters */
/* -------------------------------------------------------------------------- */

// GetPreviousVersion returns the previous version of the fork.
func (f *Fork) GetPreviousVersion() common.Version {
return f.PreviousVersion
}

// GetCurrentVersion returns the current version of the fork.
func (f *Fork) GetCurrentVersion() common.Version {
return f.CurrentVersion
}

// GetEpoch returns the epoch at which the fork occurred.
func (f *Fork) GetEpoch() math.Epoch {
return f.Epoch
}
105 changes: 61 additions & 44 deletions mod/consensus-types/pkg/types/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
package types

import (
"github.com/berachain/beacon-kit/mod/node-api/handlers/beacon/types"
"github.com/berachain/beacon-kit/mod/primitives/pkg/common"
"github.com/berachain/beacon-kit/mod/primitives/pkg/constants"
"github.com/berachain/beacon-kit/mod/primitives/pkg/constraints"
Expand All @@ -35,32 +36,32 @@ const ValidatorSize = 121

// Compile-time checks for the Validator struct.
var (
_ ssz.StaticObject = (*Validator)(nil)
_ constraints.SSZMarshallableRootable = (*Validator)(nil)
_ ssz.StaticObject = (*Validator[types.WithdrawalCredentials])(nil)
_ constraints.SSZMarshallableRootable = (*Validator[types.WithdrawalCredentials])(nil)
)

// Validator as defined in the Ethereum 2.0 Spec
// https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/beacon-chain.md#validator
//
//nolint:lll
type Validator struct {
type Validator[WithdrawalCredentialsT types.WithdrawalCredentials] struct {
// Pubkey is the validator's 48-byte BLS public key.
Pubkey crypto.BLSPubkey `json:"pubkey"`
// WithdrawalCredentials are an address that controls the validator.
WithdrawalCredentials WithdrawalCredentials `json:"withdrawalCredentials"`
WithdrawalCredentials WithdrawalCredentialsT `json:"withdrawal_credentials"`
// EffectiveBalance is the validator's current effective balance in gwei.
EffectiveBalance math.Gwei `json:"effectiveBalance"`
EffectiveBalance math.Gwei `json:"effective_balance"`
// Slashed indicates whether the validator has been slashed.
Slashed bool `json:"slashed"`
// ActivationEligibilityEpoch is the epoch in which the validator became
// eligible for activation.
ActivationEligibilityEpoch math.Epoch `json:"activationEligibilityEpoch"`
ActivationEligibilityEpoch math.Epoch `json:"activation_eligibility_epoch"`
// ActivationEpoch is the epoch in which the validator activated.
ActivationEpoch math.Epoch `json:"activationEpoch"`
ActivationEpoch math.Epoch `json:"activation_epoch"`
// ExitEpoch is the epoch in which the validator exited.
ExitEpoch math.Epoch `json:"exitEpoch"`
ExitEpoch math.Epoch `json:"exit_epoch"`
// WithdrawableEpoch is the epoch in which the validator can withdraw.
WithdrawableEpoch math.Epoch `json:"withdrawableEpoch"`
WithdrawableEpoch math.Epoch `json:"withdrawable_epoch"`
nidhi-singh02 marked this conversation as resolved.
Show resolved Hide resolved
}

/* -------------------------------------------------------------------------- */
Expand All @@ -74,14 +75,14 @@ type Validator struct {
// https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/beacon-chain.md#deposits
//
//nolint:lll
func NewValidatorFromDeposit(
func NewValidatorFromDeposit[WithdrawalCredentialsT types.WithdrawalCredentials](
pubkey crypto.BLSPubkey,
withdrawalCredentials WithdrawalCredentials,
withdrawalCredentials WithdrawalCredentialsT,
amount math.Gwei,
effectiveBalanceIncrement math.Gwei,
maxEffectiveBalance math.Gwei,
) *Validator {
return &Validator{
) *Validator[WithdrawalCredentialsT] {
return &Validator[WithdrawalCredentialsT]{
Pubkey: pubkey,
WithdrawalCredentials: withdrawalCredentials,
EffectiveBalance: min(
Expand All @@ -97,20 +98,20 @@ func NewValidatorFromDeposit(
}

// Empty creates an empty Validator.
func (*Validator) Empty() *Validator {
return &Validator{}
func (*Validator[WithdrawalCredentialsT]) Empty() *Validator[WithdrawalCredentialsT] {
return &Validator[WithdrawalCredentialsT]{}
}

// New creates a new Validator with the given public key, withdrawal
// credentials,.
func (v *Validator) New(
func (v *Validator[WithdrawalCredentialsT]) New(
pubkey crypto.BLSPubkey,
withdrawalCredentials WithdrawalCredentials,
withdrawalCredentials WithdrawalCredentialsT,
amount math.Gwei,
effectiveBalanceIncrement math.Gwei,
maxEffectiveBalance math.Gwei,
) *Validator {
return NewValidatorFromDeposit(
) *Validator[WithdrawalCredentialsT] {
return NewValidatorFromDeposit[WithdrawalCredentialsT](
pubkey,
withdrawalCredentials,
amount,
Expand All @@ -124,14 +125,14 @@ func (v *Validator) New(
/* -------------------------------------------------------------------------- */

// SizeSSZ returns the size of the Validator object in SSZ encoding.
func (*Validator) SizeSSZ() uint32 {
func (*Validator[WithdrawalCredentialsT]) SizeSSZ() uint32 {
return ValidatorSize
}

// DefineSSZ defines the SSZ encoding for the Validator object.
func (v *Validator) DefineSSZ(codec *ssz.Codec) {
func (v *Validator[WithdrawalCredentialsT]) DefineSSZ(codec *ssz.Codec) {
ssz.DefineStaticBytes(codec, &v.Pubkey)
ssz.DefineStaticBytes(codec, &v.WithdrawalCredentials)
ssz.DefineStaticBytes(codec, (*[32]byte)(v.WithdrawalCredentials.Bytes()))
nidhi-singh02 marked this conversation as resolved.
Show resolved Hide resolved
ssz.DefineUint64(codec, &v.EffectiveBalance)
ssz.DefineBool(codec, &v.Slashed)
ssz.DefineUint64(codec, &v.ActivationEligibilityEpoch)
Expand All @@ -141,18 +142,18 @@ func (v *Validator) DefineSSZ(codec *ssz.Codec) {
}

// HashTreeRoot computes the SSZ hash tree root of the Validator object.
func (v *Validator) HashTreeRoot() common.Root {
func (v *Validator[WithdrawalCredentialsT]) HashTreeRoot() common.Root {
return ssz.HashSequential(v)
}

// MarshalSSZ marshals the Validator object to SSZ format.
func (v *Validator) MarshalSSZ() ([]byte, error) {
func (v *Validator[WithdrawalCredentialsT]) MarshalSSZ() ([]byte, error) {
buf := make([]byte, v.SizeSSZ())
return buf, ssz.EncodeToBytes(buf, v)
}

// UnmarshalSSZ unmarshals the Validator object from SSZ format.
func (v *Validator) UnmarshalSSZ(buf []byte) error {
func (v *Validator[WithdrawalCredentialsT]) UnmarshalSSZ(buf []byte) error {
return ssz.DecodeFromBytes(buf, v)
}

Expand All @@ -162,7 +163,7 @@ func (v *Validator) UnmarshalSSZ(buf []byte) error {

// MarshalSSZTo marshals the Validator object to SSZ format into the provided
// buffer.
func (v *Validator) MarshalSSZTo(dst []byte) ([]byte, error) {
func (v *Validator[WithdrawalCredentialsT]) MarshalSSZTo(dst []byte) ([]byte, error) {
bz, err := v.MarshalSSZ()
if err != nil {
return nil, err
Expand All @@ -172,14 +173,14 @@ func (v *Validator) MarshalSSZTo(dst []byte) ([]byte, error) {
}

// HashTreeRootWith ssz hashes the Validator object with a hasher.
func (v *Validator) HashTreeRootWith(hh fastssz.HashWalker) error {
func (v *Validator[WithdrawalCredentialsT]) HashTreeRootWith(hh fastssz.HashWalker) error {
indx := hh.Index()

// Field (0) 'Pubkey'
hh.PutBytes(v.Pubkey[:])

// Field (1) 'WithdrawalCredentials'
hh.PutBytes(v.WithdrawalCredentials[:])
hh.PutBytes(v.WithdrawalCredentials.Bytes())

// Field (2) 'EffectiveBalance'
hh.PutUint64(uint64(v.EffectiveBalance))
Expand All @@ -204,7 +205,7 @@ func (v *Validator) HashTreeRootWith(hh fastssz.HashWalker) error {
}

// GetTree ssz hashes the Validator object.
func (v *Validator) GetTree() (*fastssz.Node, error) {
func (v *Validator[WithdrawalCredentialsT]) GetTree() (*fastssz.Node, error) {
return fastssz.ProofTree(v)
}

Expand All @@ -213,28 +214,28 @@ func (v *Validator) GetTree() (*fastssz.Node, error) {
/* -------------------------------------------------------------------------- */

// GetPubkey returns the public key of the validator.
func (v *Validator) GetPubkey() crypto.BLSPubkey {
func (v Validator[WithdrawalCredentialsT]) GetPubkey() crypto.BLSPubkey {
return v.Pubkey
}

// GetEffectiveBalance returns the effective balance of the validator.
func (v *Validator) GetEffectiveBalance() math.Gwei {
func (v Validator[WithdrawalCredentialsT]) GetEffectiveBalance() math.Gwei {
return v.EffectiveBalance
}

// IsActive as defined in the Ethereum 2.0 Spec
// https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/beacon-chain.md#is_active_validator
//
//nolint:lll
func (v Validator) IsActive(epoch math.Epoch) bool {
func (v Validator[WithdrawalCredentialsT]) IsActive(epoch math.Epoch) bool {
return v.ActivationEpoch <= epoch && epoch < v.ExitEpoch
}

// IsEligibleForActivation as defined in the Ethereum 2.0 Spec
// https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/beacon-chain.md#is_eligible_for_activation_queue
//
//nolint:lll
func (v Validator) IsEligibleForActivation(
func (v Validator[WithdrawalCredentialsT]) IsEligibleForActivation(
finalizedEpoch math.Epoch,
) bool {
return v.ActivationEligibilityEpoch <= finalizedEpoch &&
Expand All @@ -245,7 +246,7 @@ func (v Validator) IsEligibleForActivation(
// https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/beacon-chain.md#is_eligible_for_activation_queue
//
//nolint:lll
func (v Validator) IsEligibleForActivationQueue(
func (v Validator[WithdrawalCredentialsT]) IsEligibleForActivationQueue(
maxEffectiveBalance math.Gwei,
) bool {
return v.ActivationEligibilityEpoch == math.Epoch(
Expand All @@ -258,21 +259,21 @@ func (v Validator) IsEligibleForActivationQueue(
// https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/beacon-chain.md#is_slashable_validator
//
//nolint:lll
func (v Validator) IsSlashable(epoch math.Epoch) bool {
func (v Validator[WithdrawalCredentialsT]) IsSlashable(epoch math.Epoch) bool {
return !v.Slashed && v.ActivationEpoch <= epoch &&
epoch < v.WithdrawableEpoch
}

// IsSlashed returns whether the validator has been slashed.
func (v Validator) IsSlashed() bool {
func (v Validator[WithdrawalCredentialsT]) IsSlashed() bool {
return v.Slashed
}

// IsFullyWithdrawable as defined in the Ethereum 2.0 specification:
// https://github.com/ethereum/consensus-specs/blob/dev/specs/capella/beacon-chain.md#is_fully_withdrawable_validator
//
//nolint:lll
func (v Validator) IsFullyWithdrawable(
func (v Validator[WithdrawalCredentialsT]) IsFullyWithdrawable(
balance math.Gwei,
epoch math.Epoch,
) bool {
Expand All @@ -284,7 +285,7 @@ func (v Validator) IsFullyWithdrawable(
// https://github.com/ethereum/consensus-specs/blob/dev/specs/capella/beacon-chain.md#is_partially_withdrawable_validator
//
//nolint:lll
func (v Validator) IsPartiallyWithdrawable(
func (v Validator[WithdrawalCredentialsT]) IsPartiallyWithdrawable(
balance, maxEffectiveBalance math.Gwei,
) bool {
hasExcessBalance := balance > maxEffectiveBalance
Expand All @@ -296,29 +297,45 @@ func (v Validator) IsPartiallyWithdrawable(
// https://github.com/ethereum/consensus-specs/blob/dev/specs/capella/beacon-chain.md#has_eth1_withdrawal_credential
//
//nolint:lll
func (v Validator) HasEth1WithdrawalCredentials() bool {
return v.WithdrawalCredentials[0] == EthSecp256k1CredentialPrefix
func (v Validator[WithdrawalCredentialsT]) HasEth1WithdrawalCredentials() bool {
return v.WithdrawalCredentials.Bytes()[0] == EthSecp256k1CredentialPrefix
}

// HasMaxEffectiveBalance determines if the validator has the maximum effective
// balance.
func (v Validator) HasMaxEffectiveBalance(
func (v Validator[WithdrawalCredentialsT]) HasMaxEffectiveBalance(
maxEffectiveBalance math.Gwei,
) bool {
return v.EffectiveBalance == maxEffectiveBalance
}

// SetEffectiveBalance sets the effective balance of the validator.
func (v *Validator) SetEffectiveBalance(balance math.Gwei) {
func (v *Validator[WithdrawalCredentialsT]) SetEffectiveBalance(balance math.Gwei) {
v.EffectiveBalance = balance
}

// GetWithdrawableEpoch returns the epoch when the validator can withdraw.
func (v Validator) GetWithdrawableEpoch() math.Epoch {
func (v Validator[WithdrawalCredentialsT]) GetWithdrawableEpoch() math.Epoch {
return v.WithdrawableEpoch
}

// GetWithdrawalCredentials returns the withdrawal credentials of the validator.
func (v Validator) GetWithdrawalCredentials() WithdrawalCredentials {
func (v Validator[WithdrawalCredentialsT]) GetWithdrawalCredentials() WithdrawalCredentialsT {
return v.WithdrawalCredentials
}

// GetActivationEligibilityEpoch returns the activation eligibility
// epoch of the validator.
func (v Validator[WithdrawalCredentialsT]) GetActivationEligibilityEpoch() math.Epoch {
return v.ActivationEligibilityEpoch
}

// GetActivationEpoch returns the activation epoch of the validator.
func (v Validator[WithdrawalCredentialsT]) GetActivationEpoch() math.Epoch {
return v.ActivationEpoch
}

// GetExitEpoch returns the exit epoch of the validator.
func (v Validator[WithdrawalCredentialsT]) GetExitEpoch() math.Epoch {
return v.ExitEpoch
}
Loading
Loading