mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 04:47:18 +00:00
d17996f8b0
* Update V3 from V4 * Fix build v3 -> v4 * Update ssz * Update beacon_chain.pb.go * Fix formatter import * Update update-mockgen.sh comment to v4 * Fix conflicts. Pass build and tests * Fix test
43 lines
1.4 KiB
Go
43 lines
1.4 KiB
Go
package beacon_api
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/ethereum/go-ethereum/common/hexutil"
|
|
"github.com/pkg/errors"
|
|
"github.com/prysmaticlabs/prysm/v4/beacon-chain/core/signing"
|
|
"github.com/prysmaticlabs/prysm/v4/consensus-types/primitives"
|
|
"github.com/prysmaticlabs/prysm/v4/network/forks"
|
|
ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1"
|
|
)
|
|
|
|
func (c beaconApiValidatorClient) getDomainData(ctx context.Context, epoch primitives.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(ctx)
|
|
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 ðpb.DomainResponse{SignatureDomain: signatureDomain}, nil
|
|
}
|