prysm-pulse/validator/client/beacon-api/domain_data.go
Patrice Vignola dbeb3ee886
Onboard validator's Beacon REST API usage to e2e tests (#11704)
* WIP

* WIP

* WIP

* WIP

* WIP

* WIP

* WIP

* Onboard validator's Beacon REST API usage to e2e tests

* Remove unused variables

* Remove use_beacon_api tags

* Fix DeepSource errors

* Revert unneeded changes

* Revert evaluator changes

* Revert import reordering

* Address PR comments

* Remove all REST API e2e tests except minimal one

* Fix validator pointing to inexisting beacon node port

Co-authored-by: Radosław Kapka <rkapka@wp.pl>
2022-12-08 14:38:56 +00:00

41 lines
1.4 KiB
Go

package beacon_api
import (
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/pkg/errors"
"github.com/prysmaticlabs/prysm/v3/beacon-chain/core/signing"
types "github.com/prysmaticlabs/prysm/v3/consensus-types/primitives"
"github.com/prysmaticlabs/prysm/v3/network/forks"
ethpb "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1"
)
func (c beaconApiValidatorClient) getDomainData(epoch types.Epoch, domainType [4]byte) (*ethpb.DomainResponse, error) {
// Get the fork version from the given epoch
fork, err := forks.Fork(epoch)
if err != nil {
return nil, errors.Wrapf(err, "failed to get fork version for epoch %d", epoch)
}
// Get the genesis validator root
genesis, _, err := c.genesisProvider.GetGenesis()
if err != nil {
return nil, errors.Wrap(err, "failed to get genesis info")
}
if !validRoot(genesis.GenesisValidatorsRoot) {
return nil, errors.Errorf("invalid genesis validators root: %s", genesis.GenesisValidatorsRoot)
}
genesisValidatorRoot, err := hexutil.Decode(genesis.GenesisValidatorsRoot)
if err != nil {
return nil, errors.Wrap(err, "failed to decode genesis validators root")
}
signatureDomain, err := signing.Domain(fork, epoch, domainType, genesisValidatorRoot)
if err != nil {
return nil, errors.Wrap(err, "failed to compute signature domain")
}
return &ethpb.DomainResponse{SignatureDomain: signatureDomain}, nil
}