rpc

package
v5.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2024 License: GPL-3.0 Imports: 82 Imported by: 0

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

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

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

type BackupAccountsResponse

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

type BeaconStatusResponse

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

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

func ChainHeadResponseFromConsensus(e *eth.ChainHead) *ChainHead

func (*ChainHead) ToConsensus

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
	BeaconApiEndpoint        string
	BeaconApiTimeout         time.Duration
	Router                   *mux.Router
	Wallet                   *wallet.Wallet
}

Config options for the gRPC server.

type CreateWalletRequest

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

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

type DeleteKeystoresRequest

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

type DeleteKeystoresResponse

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

type DeleteRemoteKeysRequest

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

type ExportSlashingProtectionResponse

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

type FeeRecipient

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

Fee Recipient keymanager api

type GasLimitMetaData

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

gas limit keymanager api

type GenerateMnemonicResponse

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

type GetFeeRecipientByPubkeyResponse

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

type GetGasLimitResponse

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

type GetGraffitiResponse added in v5.0.2

type GetGraffitiResponse struct {
	Data *GraffitiData `json:"data"`
}

Graffiti keymanager api

type GraffitiData added in v5.0.2

type GraffitiData struct {
	Pubkey   string `json:"pubkey"`
	Graffiti string `json:"graffiti"`
}

type ImportKeystoresRequest

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

type ImportKeystoresResponse

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

type ImportRemoteKeysRequest

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

type ImportSlashingProtectionRequest

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

type InitializeAuthResponse

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

type KeymanagerKind

type KeymanagerKind string

KeymanagerKind is a type of key manager for the wallet

type Keystore

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

type ListAccountsResponse

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

type ListKeystoresResponse

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

local keymanager api

type ListRemoteKeysResponse

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

remote keymanager api

type RecoverWalletRequest

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

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

type RemoteKeysResponse

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 wallet.

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) DeleteGraffiti added in v5.0.2

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

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) GetGraffiti added in v5.0.2

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

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

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

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) SetGraffiti added in v5.0.2

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

func (*Server) SetVoluntaryExit

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

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

type SetGasLimitRequest

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

type SetVoluntaryExitResponse

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

voluntary exit keymanager api

type ValidateKeystoresRequest

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

type Validator

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

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

type ValidatorBalancesResponse

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

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

type ValidatorContainer

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

type ValidatorPerformanceResponse

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"`
}

type ValidatorsResponse

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

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

type VoluntaryExitRequest

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

type VoluntaryExitResponse

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

type WalletResponse

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