rpc

package
v4.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 26, 2024 License: GPL-3.0 Imports: 80 Imported by: 5

Documentation

Index

Constants

View Source
const (
	AuthTokenFileName = "auth-token"
)

Variables

This section is empty.

Functions

func CreateAuthToken

func CreateAuthToken(walletDirPath, validatorWebAddr string) error

CreateAuthToken generates a new jwt key, token and writes them to a file in the specified directory. Also, it logs out a prepared URL for the user to navigate to and authenticate with the Prysm web interface.

Types

type Account added in v4.2.0

type Account struct {
	ValidatingPublicKey string `json:"validating_public_key"`
	AccountName         string `json:"account_name"`
	DepositTxData       string `json:"deposit_tx_data"`
	DerivationPath      string `json:"derivation_path"`
}

type BackupAccountsRequest added in v4.2.0

type BackupAccountsRequest struct {
	PublicKeys     []string `json:"public_keys"`
	BackupPassword string   `json:"backup_password"`
}

type BackupAccountsResponse added in v4.2.0

type BackupAccountsResponse struct {
	ZipFile string `json:"zip_file"`
}

type BeaconStatusResponse added in v4.2.0

type BeaconStatusResponse struct {
	BeaconNodeEndpoint     string     `json:"beacon_node_endpoint"`
	Connected              bool       `json:"connected"`
	Syncing                bool       `json:"syncing"`
	GenesisTime            string     `json:"genesis_time"`
	DepositContractAddress string     `json:"deposit_contract_address"`
	ChainHead              *ChainHead `json:"chain_head"`
}

type ChainHead added in v4.2.0

type ChainHead struct {
	HeadSlot                   string `json:"head_slot"`
	HeadEpoch                  string `json:"head_epoch"`
	HeadBlockRoot              string `json:"head_block_root"`
	FinalizedSlot              string `json:"finalized_slot"`
	FinalizedEpoch             string `json:"finalized_epoch"`
	FinalizedBlockRoot         string `json:"finalized_block_root"`
	JustifiedSlot              string `json:"justified_slot"`
	JustifiedEpoch             string `json:"justified_epoch"`
	JustifiedBlockRoot         string `json:"justified_block_root"`
	PreviousJustifiedSlot      string `json:"previous_justified_slot"`
	PreviousJustifiedEpoch     string `json:"previous_justified_epoch"`
	PreviousJustifiedBlockRoot string `json:"previous_justified_block_root"`
	OptimisticStatus           bool   `json:"optimistic_status"`
}

ChainHead is the response for api endpoint /beacon/chainhead

func ChainHeadResponseFromConsensus added in v4.2.0

func ChainHeadResponseFromConsensus(e *eth.ChainHead) *ChainHead

func (*ChainHead) ToConsensus added in v4.2.0

func (m *ChainHead) ToConsensus() (*eth.ChainHead, error)

type Config

type Config struct {
	ValidatorGatewayHost     string
	ValidatorGatewayPort     int
	ValidatorMonitoringHost  string
	ValidatorMonitoringPort  int
	BeaconClientEndpoint     string
	ClientMaxCallRecvMsgSize int
	ClientGrpcRetries        uint
	ClientGrpcRetryDelay     time.Duration
	ClientGrpcHeaders        []string
	ClientWithCert           string
	Host                     string
	Port                     string
	CertFlag                 string
	KeyFlag                  string
	ValDB                    db.Database
	WalletDir                string
	ValidatorService         *client.ValidatorService
	SyncChecker              client.SyncChecker
	GenesisFetcher           client.GenesisFetcher
	WalletInitializedFeed    *event.Feed
	NodeGatewayEndpoint      string
	Router                   *mux.Router
	Wallet                   *wallet.Wallet
}

Config options for the gRPC server.

type CreateWalletRequest added in v4.2.0

type CreateWalletRequest struct {
	Keymanager       KeymanagerKind `json:"keymanager"`
	WalletPassword   string         `json:"wallet_password"`
	Mnemonic         string         `json:"mnemonic"`
	NumAccounts      uint64         `json:"num_accounts"`
	MnemonicLanguage string         `json:"mnemonic_language"`
}

type CreateWalletResponse added in v4.2.0

type CreateWalletResponse struct {
	Wallet *WalletResponse `json:"wallet"`
}

type DeleteKeystoresRequest added in v4.2.0

type DeleteKeystoresRequest struct {
	Pubkeys []string `json:"pubkeys"`
}

type DeleteKeystoresResponse added in v4.2.0

type DeleteKeystoresResponse struct {
	Data               []*keymanager.KeyStatus `json:"data"`
	SlashingProtection string                  `json:"slashing_protection"`
}

type DeleteRemoteKeysRequest added in v4.2.0

type DeleteRemoteKeysRequest struct {
	Pubkeys []string `json:"pubkeys"`
}

type ExportSlashingProtectionResponse added in v4.2.0

type ExportSlashingProtectionResponse struct {
	File string `json:"file"`
}

type FeeRecipient added in v4.2.0

type FeeRecipient struct {
	Pubkey     string `json:"pubkey"`
	Ethaddress string `json:"ethaddress"`
}

Fee Recipient keymanager api

type GasLimitMetaData added in v4.2.0

type GasLimitMetaData struct {
	Pubkey   string `json:"pubkey"`
	GasLimit string `json:"gas_limit"`
}

gas limit keymanager api

type GenerateMnemonicResponse added in v4.2.0

type GenerateMnemonicResponse struct {
	Mnemonic string `json:"mnemonic"`
}

type GetFeeRecipientByPubkeyResponse added in v4.2.0

type GetFeeRecipientByPubkeyResponse struct {
	Data *FeeRecipient `json:"data"`
}

type GetGasLimitResponse added in v4.2.0

type GetGasLimitResponse struct {
	Data *GasLimitMetaData `json:"data"`
}

type ImportKeystoresRequest added in v4.2.0

type ImportKeystoresRequest struct {
	Keystores          []string `json:"keystores"`
	Passwords          []string `json:"passwords"`
	SlashingProtection string   `json:"slashing_protection"`
}

type ImportKeystoresResponse added in v4.2.0

type ImportKeystoresResponse struct {
	Data []*keymanager.KeyStatus `json:"data"`
}

type ImportRemoteKeysRequest added in v4.2.0

type ImportRemoteKeysRequest struct {
	RemoteKeys []*RemoteKey `json:"remote_keys"`
}

type ImportSlashingProtectionRequest added in v4.2.0

type ImportSlashingProtectionRequest struct {
	SlashingProtectionJson string `json:"slashing_protection_json"`
}

type InitializeAuthResponse added in v4.2.0

type InitializeAuthResponse struct {
	HasSignedUp bool `json:"has_signed_up"`
	HasWallet   bool `json:"has_wallet"`
}

type KeymanagerKind added in v4.2.0

type KeymanagerKind string

KeymanagerKind is a type of key manager for the wallet

type Keystore added in v4.2.0

type Keystore struct {
	ValidatingPubkey string `json:"validating_pubkey"`
	DerivationPath   string `json:"derivation_path"`
}

type ListAccountsResponse added in v4.2.0

type ListAccountsResponse struct {
	Accounts      []*Account `json:"accounts"`
	NextPageToken string     `json:"next_page_token"`
	TotalSize     int32      `json:"total_size"`
}

type ListKeystoresResponse added in v4.2.0

type ListKeystoresResponse struct {
	Data []*Keystore `json:"data"`
}

local keymanager api

type ListRemoteKeysResponse added in v4.2.0

type ListRemoteKeysResponse struct {
	Data []*RemoteKey `json:"data"`
}

remote keymanager api

type RecoverWalletRequest added in v4.2.0

type RecoverWalletRequest struct {
	Mnemonic         string `json:"mnemonic"`
	NumAccounts      uint64 `json:"num_accounts"`
	WalletPassword   string `json:"wallet_password"`
	Language         string `json:"language"`
	Mnemonic25ThWord string `json:"mnemonic25th_word"`
}

type RemoteKey added in v4.2.0

type RemoteKey struct {
	Pubkey   string `json:"pubkey"`
	Url      string `json:"url"`
	Readonly bool   `json:"readonly"`
}

type RemoteKeysResponse added in v4.2.0

type RemoteKeysResponse struct {
	Data []*keymanager.KeyStatus `json:"data"`
}

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server defining a gRPC server for the remote signer API.

func NewServer

func NewServer(ctx context.Context, cfg *Config) *Server

NewServer instantiates a new gRPC server.

func (*Server) BackupAccounts

func (s *Server) BackupAccounts(w http.ResponseWriter, r *http.Request)

BackupAccounts creates a zip file containing EIP-2335 keystores for the user's specified public keys by encrypting them with the specified password.

func (*Server) CreateWallet

func (s *Server) CreateWallet(w http.ResponseWriter, r *http.Request)

CreateWallet via an API request, allowing a user to save a new

func (*Server) DeleteFeeRecipientByPubkey

func (s *Server) DeleteFeeRecipientByPubkey(w http.ResponseWriter, r *http.Request)

DeleteFeeRecipientByPubkey updates the eth address mapped to the public key to the default fee recipient listed

func (*Server) DeleteGasLimit

func (s *Server) DeleteGasLimit(w http.ResponseWriter, r *http.Request)

DeleteGasLimit deletes the gas limit by public key

func (*Server) DeleteKeystores

func (s *Server) DeleteKeystores(w http.ResponseWriter, r *http.Request)

DeleteKeystores allows for deleting specified public keys from Prysm.

func (*Server) DeleteRemoteKeys

func (s *Server) DeleteRemoteKeys(w http.ResponseWriter, r *http.Request)

DeleteRemoteKeys deletes a list of public keys defined for web3signer keymanager type.

func (*Server) ExportSlashingProtection

func (s *Server) ExportSlashingProtection(w http.ResponseWriter, r *http.Request)

ExportSlashingProtection handles the rpc call returning the json slashing history. The format of the export follows the EIP-3076 standard which makes it easy to migrate machines or Ethereum consensus clients.

Steps:

  1. Call the function which exports the data from the validator's db into an EIP standard slashing protection format.
  2. Format and send JSON in the response.

func (*Server) GetBeaconStatus

func (s *Server) GetBeaconStatus(w http.ResponseWriter, r *http.Request)

GetBeaconStatus retrieves information about the beacon node gRPC connection and certain chain metadata, such as the genesis time, the chain head, and the deposit contract address.

func (*Server) GetGasLimit

func (s *Server) GetGasLimit(w http.ResponseWriter, r *http.Request)

GetGasLimit returns the gas limit measured in gwei defined for the custom mev builder by public key

func (*Server) GetPeers

func (s *Server) GetPeers(w http.ResponseWriter, r *http.Request)

GetPeers is a wrapper around the /eth/v1alpha1 endpoint of the same name.

func (*Server) GetValidatorBalances

func (s *Server) GetValidatorBalances(w http.ResponseWriter, r *http.Request)

GetValidatorBalances is a wrapper around the /eth/v1alpha1 endpoint of the same name.

func (*Server) GetValidatorPerformance

func (s *Server) GetValidatorPerformance(w http.ResponseWriter, r *http.Request)

GetValidatorPerformance is a wrapper around the /eth/v1alpha1 endpoint of the same name.

func (*Server) GetValidators

func (s *Server) GetValidators(w http.ResponseWriter, r *http.Request)

GetValidators is a wrapper around the /eth/v1alpha1 endpoint of the same name.

func (*Server) GetVersion

func (s *Server) GetVersion(w http.ResponseWriter, r *http.Request)

GetVersion returns the beacon node and validator client versions

func (*Server) ImportKeystores

func (s *Server) ImportKeystores(w http.ResponseWriter, r *http.Request)

ImportKeystores allows for importing keystores into Prysm with their slashing protection history.

func (*Server) ImportRemoteKeys

func (s *Server) ImportRemoteKeys(w http.ResponseWriter, r *http.Request)

ImportRemoteKeys imports a list of public keys defined for web3signer keymanager type.

func (*Server) ImportSlashingProtection

func (s *Server) ImportSlashingProtection(w http.ResponseWriter, r *http.Request)

ImportSlashingProtection reads an input slashing protection EIP-3076 standard JSON string and inserts the data into validator DB.

Read the JSON string passed through rpc, then call the func which actually imports the data from the JSON file into our database. Use the Keymanager APIs if an API is required.

func (*Server) Initialize

func (s *Server) Initialize(w http.ResponseWriter, r *http.Request)

Initialize returns metadata regarding whether the caller has authenticated and has a wallet.

func (*Server) InitializeRoutes added in v4.2.0

func (s *Server) InitializeRoutes() error

InitializeRoutes initializes pure HTTP REST endpoints for the validator client. needs to be called before the Serve function

func (*Server) JWTInterceptor

func (s *Server) JWTInterceptor() grpc.UnaryServerInterceptor

JWTInterceptor is a gRPC unary interceptor to authorize incoming requests.

func (*Server) JwtHttpInterceptor added in v4.2.0

func (s *Server) JwtHttpInterceptor(next http.Handler) http.Handler

JwtHttpInterceptor is an HTTP handler to authorize a route.

func (*Server) ListAccounts

func (s *Server) ListAccounts(w http.ResponseWriter, r *http.Request)

ListAccounts allows retrieval of validating keys and their petnames for a user's wallet via RPC.

func (*Server) ListFeeRecipientByPubkey

func (s *Server) ListFeeRecipientByPubkey(w http.ResponseWriter, r *http.Request)

ListFeeRecipientByPubkey returns the public key to eth address mapping object to the end user.

func (*Server) ListKeystores

func (s *Server) ListKeystores(w http.ResponseWriter, r *http.Request)

ListKeystores implements the standard validator key management API.

func (*Server) ListRemoteKeys

func (s *Server) ListRemoteKeys(w http.ResponseWriter, r *http.Request)

ListRemoteKeys returns a list of all public keys defined for web3signer keymanager type.

func (*Server) RecoverWallet

func (s *Server) RecoverWallet(w http.ResponseWriter, r *http.Request)

RecoverWallet via an API request, allowing a user to recover a derived wallet. Generate the seed from the mnemonic + language + 25th passphrase(optional). Create N validator keystores from the seed specified by req.NumAccounts. Set the wallet password to req.WalletPassword, then create the wallet from the provided Mnemonic and return CreateWalletResponse. DEPRECATED: this endpoint will be removed to improve the safety and security of interacting with wallets

func (*Server) SetFeeRecipientByPubkey

func (s *Server) SetFeeRecipientByPubkey(w http.ResponseWriter, r *http.Request)

SetFeeRecipientByPubkey updates the eth address mapped to the public key.

func (*Server) SetGasLimit

func (s *Server) SetGasLimit(w http.ResponseWriter, r *http.Request)

SetGasLimit updates the gas limit by public key

func (*Server) SetVoluntaryExit added in v4.0.7

func (s *Server) SetVoluntaryExit(w http.ResponseWriter, r *http.Request)

SetVoluntaryExit creates a signed voluntary exit message and returns a VoluntaryExit object.

func (*Server) Start

func (s *Server) Start()

Start the gRPC server.

func (*Server) Status

func (s *Server) Status() error

Status returns nil or credentialError.

func (*Server) Stop

func (s *Server) Stop() error

Stop the gRPC server.

func (*Server) StreamBeaconLogs

func (s *Server) StreamBeaconLogs(w http.ResponseWriter, r *http.Request)

StreamBeaconLogs from the beacon node via server-side events.

func (*Server) StreamValidatorLogs

func (s *Server) StreamValidatorLogs(w http.ResponseWriter, r *http.Request)

StreamValidatorLogs from the validator client via server-side events.

func (*Server) ValidateKeystores

func (*Server) ValidateKeystores(w http.ResponseWriter, r *http.Request)

ValidateKeystores checks whether a set of EIP-2335 keystores in the request can indeed be decrypted using a password in the request. If there is no issue, we return an empty response with no error. If the password is incorrect for a single keystore, we return an appropriate error.

func (*Server) VoluntaryExit

func (s *Server) VoluntaryExit(w http.ResponseWriter, r *http.Request)

VoluntaryExit performs a voluntary exit for the validator keys specified in a request.

func (*Server) WalletConfig

func (s *Server) WalletConfig(w http.ResponseWriter, r *http.Request)

WalletConfig returns the wallet's configuration. If no wallet exists, we return an empty response.

type SetFeeRecipientByPubkeyRequest added in v4.2.0

type SetFeeRecipientByPubkeyRequest struct {
	Ethaddress string `json:"ethaddress"`
}

type SetGasLimitRequest added in v4.2.0

type SetGasLimitRequest struct {
	GasLimit string `json:"gas_limit"`
}

type SetVoluntaryExitResponse added in v4.2.0

type SetVoluntaryExitResponse struct {
	Data *shared.SignedVoluntaryExit `json:"data"`
}

voluntary exit keymanager api

type ValidateKeystoresRequest added in v4.2.0

type ValidateKeystoresRequest struct {
	Keystores         []string `json:"keystores"`
	KeystoresPassword string   `json:"keystores_password"`
}

type Validator added in v4.2.0

type Validator struct {
	PublicKey                  string `json:"public_key,omitempty"`
	WithdrawalCredentials      string `json:"withdrawal_credentials"`
	EffectiveBalance           uint64 `json:"effective_balance"`
	Slashed                    bool   `json:"slashed"`
	ActivationEligibilityEpoch uint64 `json:"activation_eligibility_epoch"`
	ActivationEpoch            uint64 `json:"activation_epoch"`
	ExitEpoch                  uint64 `json:"exit_epoch"`
	WithdrawableEpoch          uint64 `json:"withdrawable_epoch"`
}

type ValidatorBalance added in v4.2.0

type ValidatorBalance struct {
	PublicKey string `json:"public_key"`
	Index     uint64 `json:"index"`
	Balance   uint64 `json:"balance"`
	Status    string `json:"status"`
}

type ValidatorBalancesResponse added in v4.2.0

type ValidatorBalancesResponse struct {
	Epoch         uint64              `json:"epoch"`
	Balances      []*ValidatorBalance `json:"balances"`
	NextPageToken string              `json:"next_page_token"`
	TotalSize     int32               `json:"total_size,omitempty"`
}

func ValidatorBalancesResponseFromConsensus added in v4.2.0

func ValidatorBalancesResponseFromConsensus(e *eth.ValidatorBalances) (*ValidatorBalancesResponse, error)

type ValidatorContainer added in v4.2.0

type ValidatorContainer struct {
	Index     uint64     `json:"index"`
	Validator *Validator `json:"validator"`
}

type ValidatorPerformanceResponse added in v4.2.0

type ValidatorPerformanceResponse struct {
	CurrentEffectiveBalances      []uint64 `json:"current_effective_balances"`
	InclusionSlots                []uint64 `json:"inclusion_slots"`
	InclusionDistances            []uint64 `json:"inclusion_distances"`
	CorrectlyVotedSource          []bool   `json:"correctly_voted_source"`
	CorrectlyVotedTarget          []bool   `json:"correctly_voted_target"`
	CorrectlyVotedHead            []bool   `json:"correctly_voted_head"`
	BalancesBeforeEpochTransition []uint64 `json:"balances_before_epoch_transition"`
	BalancesAfterEpochTransition  []uint64 `json:"balances_after_epoch_transition"`
	MissingValidators             []string `json:"missing_validators"`
	AverageActiveValidatorBalance float32  `json:"average_active_validator_balance"`
	PublicKeys                    []string `json:"public_keys"`
	InactivityScores              []uint64 `json:"inactivity_scores"`
}

func ValidatorPerformanceResponseFromConsensus added in v4.2.0

func ValidatorPerformanceResponseFromConsensus(e *eth.ValidatorPerformanceResponse) *ValidatorPerformanceResponse

type ValidatorsResponse added in v4.2.0

type ValidatorsResponse struct {
	Epoch         uint64                `json:"epoch"`
	ValidatorList []*ValidatorContainer `json:"validator_list"`
	NextPageToken string                `json:"next_page_token"`
	TotalSize     int32                 `json:"total_size"`
}

func ValidatorsResponseFromConsensus added in v4.2.0

func ValidatorsResponseFromConsensus(e *eth.Validators) (*ValidatorsResponse, error)

type VoluntaryExitRequest added in v4.2.0

type VoluntaryExitRequest struct {
	PublicKeys []string `json:"public_keys"`
}

type VoluntaryExitResponse added in v4.2.0

type VoluntaryExitResponse struct {
	ExitedKeys [][]byte `protobuf:"bytes,1,rep,name=exited_keys,json=exitedKeys,proto3" json:"exited_keys,omitempty"`
}

type WalletResponse added in v4.2.0

type WalletResponse struct {
	WalletPath     string         `json:"wallet_path"`
	KeymanagerKind KeymanagerKind `json:"keymanager_kind"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL