Documentation
¶
Overview ¶
Package plugin provides HashiCorp go-plugin based network module plugin system.
Package plugin provides HashiCorp go-plugin based network module plugin system.
Architecture:
devnet-builder (Host) Network Plugins ┌─────────────────────┐ ┌─────────────────────┐ │ Plugin Manager │ gRPC/RPC │ stable plugin │ │ │◄────────────────►│ (stable deps only) │ │ - Discovery │ └─────────────────────┘ │ - Loading │ ┌─────────────────────┐ │ - Communication │◄────────────────►│ ault plugin │ │ │ │ (ault deps only) │ └─────────────────────┘ └─────────────────────┘
Benefits:
- Each network plugin is a separate binary with its own dependencies
- No cross-contamination of go.mod replace directives
- Dynamic loading at runtime
- New networks can be added without recompiling the host
Index ¶
- Variables
- func Serve(impl NetworkModule)
- type BinarySource
- type GRPCClient
- func (c *GRPCClient) AvailableNetworks() []string
- func (c *GRPCClient) BaseDenom() string
- func (c *GRPCClient) Bech32Prefix() string
- func (c *GRPCClient) BinaryName() string
- func (c *GRPCClient) BinarySource() BinarySource
- func (c *GRPCClient) DefaultBinaryVersion() string
- func (c *GRPCClient) DefaultChainID() stringdeprecated
- func (c *GRPCClient) DefaultGeneratorConfig() GeneratorConfig
- func (c *GRPCClient) DefaultNodeHome() string
- func (c *GRPCClient) DefaultPorts() PortConfig
- func (c *GRPCClient) DisplayName() string
- func (c *GRPCClient) DockerHomeDir() string
- func (c *GRPCClient) DockerImage() string
- func (c *GRPCClient) DockerImageTag(version string) string
- func (c *GRPCClient) ExportCommand(homeDir string) []string
- func (c *GRPCClient) GenerateDevnet(ctx context.Context, config GeneratorConfig, genesisFile string) error
- func (c *GRPCClient) GenesisConfig() GenesisConfig
- func (c *GRPCClient) GetCodec() ([]byte, error)
- func (c *GRPCClient) InitCommand(homeDir, chainID, moniker string) []string
- func (c *GRPCClient) LogFileName() string
- func (c *GRPCClient) ModifyGenesis(genesis []byte, opts GenesisOptions) ([]byte, error)
- func (c *GRPCClient) Name() string
- func (c *GRPCClient) PIDFileName() string
- func (c *GRPCClient) ProcessPattern() string
- func (c *GRPCClient) RPCEndpoint(networkType string) string
- func (c *GRPCClient) SnapshotURL(networkType string) string
- func (c *GRPCClient) StartCommand(homeDir string) []string
- func (c *GRPCClient) Validate() error
- func (c *GRPCClient) Version() string
- type GRPCServer
- func (s *GRPCServer) AvailableNetworks(ctx context.Context, req *pb.Empty) (*pb.StringListResponse, error)
- func (s *GRPCServer) BaseDenom(ctx context.Context, req *pb.Empty) (*pb.StringResponse, error)
- func (s *GRPCServer) Bech32Prefix(ctx context.Context, req *pb.Empty) (*pb.StringResponse, error)
- func (s *GRPCServer) BinaryName(ctx context.Context, req *pb.Empty) (*pb.StringResponse, error)
- func (s *GRPCServer) BinarySource(ctx context.Context, req *pb.Empty) (*pb.BinarySourceResponse, error)
- func (s *GRPCServer) DefaultBinaryVersion(ctx context.Context, req *pb.Empty) (*pb.StringResponse, error)
- func (s *GRPCServer) DefaultChainID(ctx context.Context, req *pb.Empty) (*pb.StringResponse, error)deprecated
- func (s *GRPCServer) DefaultGeneratorConfig(ctx context.Context, req *pb.Empty) (*pb.GeneratorConfigResponse, error)
- func (s *GRPCServer) DefaultNodeHome(ctx context.Context, req *pb.Empty) (*pb.StringResponse, error)
- func (s *GRPCServer) DefaultPorts(ctx context.Context, req *pb.Empty) (*pb.PortConfigResponse, error)
- func (s *GRPCServer) DisplayName(ctx context.Context, req *pb.Empty) (*pb.StringResponse, error)
- func (s *GRPCServer) DockerHomeDir(ctx context.Context, req *pb.Empty) (*pb.StringResponse, error)
- func (s *GRPCServer) DockerImage(ctx context.Context, req *pb.Empty) (*pb.StringResponse, error)
- func (s *GRPCServer) DockerImageTag(ctx context.Context, req *pb.StringRequest) (*pb.StringResponse, error)
- func (s *GRPCServer) ExportCommand(ctx context.Context, req *pb.StringRequest) (*pb.StringListResponse, error)
- func (s *GRPCServer) GenerateDevnet(ctx context.Context, req *pb.GenerateDevnetRequest) (*pb.ErrorResponse, error)
- func (s *GRPCServer) GenesisConfig(ctx context.Context, req *pb.Empty) (*pb.GenesisConfigResponse, error)
- func (s *GRPCServer) GetCodec(ctx context.Context, req *pb.Empty) (*pb.BytesResponse, error)
- func (s *GRPCServer) InitCommand(ctx context.Context, req *pb.InitCommandRequest) (*pb.StringListResponse, error)
- func (s *GRPCServer) LogFileName(ctx context.Context, req *pb.Empty) (*pb.StringResponse, error)
- func (s *GRPCServer) ModifyGenesis(ctx context.Context, req *pb.ModifyGenesisRequest) (*pb.BytesResponse, error)
- func (s *GRPCServer) Name(ctx context.Context, req *pb.Empty) (*pb.StringResponse, error)
- func (s *GRPCServer) PIDFileName(ctx context.Context, req *pb.Empty) (*pb.StringResponse, error)
- func (s *GRPCServer) ProcessPattern(ctx context.Context, req *pb.Empty) (*pb.StringResponse, error)
- func (s *GRPCServer) RPCEndpoint(ctx context.Context, req *pb.StringRequest) (*pb.StringResponse, error)
- func (s *GRPCServer) SnapshotURL(ctx context.Context, req *pb.StringRequest) (*pb.StringResponse, error)
- func (s *GRPCServer) StartCommand(ctx context.Context, req *pb.StringRequest) (*pb.StringListResponse, error)
- func (s *GRPCServer) Validate(ctx context.Context, req *pb.Empty) (*pb.ErrorResponse, error)
- func (s *GRPCServer) Version(ctx context.Context, req *pb.Empty) (*pb.StringResponse, error)
- type GeneratorConfig
- type GenesisConfig
- type GenesisOptions
- type NetworkModule
- type NetworkModuleGRPCPlugin
- type PluginManager
- type PortConfig
Constants ¶
This section is empty.
Variables ¶
var Handshake = plugin.HandshakeConfig{
ProtocolVersion: 1,
MagicCookieKey: "DEVNET_BUILDER_PLUGIN",
MagicCookieValue: "network_module_v1",
}
Handshake is the handshake config for plugins. This ensures that the host and plugin are compatible.
var PluginMap = map[string]plugin.Plugin{ "network": &NetworkModuleGRPCPlugin{}, }
PluginMap is the map of plugins we can dispense.
Functions ¶
func Serve ¶
func Serve(impl NetworkModule)
Serve is called by plugin binaries to serve the NetworkModule implementation.
Types ¶
type BinarySource ¶
BinarySource defines how to acquire the network binary.
type GRPCClient ¶
type GRPCClient struct {
// contains filtered or unexported fields
}
GRPCClient is the gRPC client that the host uses to communicate with plugins.
func (*GRPCClient) AvailableNetworks ¶
func (c *GRPCClient) AvailableNetworks() []string
func (*GRPCClient) BaseDenom ¶
func (c *GRPCClient) BaseDenom() string
func (*GRPCClient) Bech32Prefix ¶
func (c *GRPCClient) Bech32Prefix() string
func (*GRPCClient) BinarySource ¶
func (c *GRPCClient) BinarySource() BinarySource
func (*GRPCClient) DefaultBinaryVersion ¶
func (c *GRPCClient) DefaultBinaryVersion() string
func (*GRPCClient) DefaultChainID
deprecated
func (c *GRPCClient) DefaultChainID() string
Deprecated: DefaultChainID will be removed in v2.0.0
func (*GRPCClient) DefaultGeneratorConfig ¶
func (c *GRPCClient) DefaultGeneratorConfig() GeneratorConfig
func (*GRPCClient) DefaultPorts ¶
func (c *GRPCClient) DefaultPorts() PortConfig
func (*GRPCClient) DisplayName ¶
func (c *GRPCClient) DisplayName() string
func (*GRPCClient) DockerHomeDir ¶
func (c *GRPCClient) DockerHomeDir() string
func (*GRPCClient) DockerImageTag ¶
func (c *GRPCClient) DockerImageTag(version string) string
func (*GRPCClient) ExportCommand ¶
func (c *GRPCClient) ExportCommand(homeDir string) []string
func (*GRPCClient) GenerateDevnet ¶
func (c *GRPCClient) GenerateDevnet(ctx context.Context, config GeneratorConfig, genesisFile string) error
func (*GRPCClient) GenesisConfig ¶
func (c *GRPCClient) GenesisConfig() GenesisConfig
Configuration methods
func (*GRPCClient) GetCodec ¶
func (c *GRPCClient) GetCodec() ([]byte, error)
func (*GRPCClient) InitCommand ¶
func (c *GRPCClient) InitCommand(homeDir, chainID, moniker string) []string
Command methods
func (*GRPCClient) LogFileName ¶
func (c *GRPCClient) LogFileName() string
func (*GRPCClient) ModifyGenesis ¶
func (c *GRPCClient) ModifyGenesis(genesis []byte, opts GenesisOptions) ([]byte, error)
Operation methods
func (*GRPCClient) PIDFileName ¶
func (c *GRPCClient) PIDFileName() string
func (*GRPCClient) ProcessPattern ¶
func (c *GRPCClient) ProcessPattern() string
func (*GRPCClient) RPCEndpoint ¶
func (c *GRPCClient) RPCEndpoint(networkType string) string
func (*GRPCClient) SnapshotURL ¶
func (c *GRPCClient) SnapshotURL(networkType string) string
Snapshot methods
func (*GRPCClient) StartCommand ¶
func (c *GRPCClient) StartCommand(homeDir string) []string
func (*GRPCClient) Validate ¶
func (c *GRPCClient) Validate() error
func (*GRPCClient) Version ¶
func (c *GRPCClient) Version() string
type GRPCServer ¶
type GRPCServer struct {
pb.UnimplementedNetworkModuleServer
Impl NetworkModule
}
GRPCServer is the gRPC server that plugins use to implement NetworkModule.
func (*GRPCServer) AvailableNetworks ¶
func (s *GRPCServer) AvailableNetworks(ctx context.Context, req *pb.Empty) (*pb.StringListResponse, error)
func (*GRPCServer) BaseDenom ¶
func (s *GRPCServer) BaseDenom(ctx context.Context, req *pb.Empty) (*pb.StringResponse, error)
func (*GRPCServer) Bech32Prefix ¶
func (s *GRPCServer) Bech32Prefix(ctx context.Context, req *pb.Empty) (*pb.StringResponse, error)
func (*GRPCServer) BinaryName ¶
func (s *GRPCServer) BinaryName(ctx context.Context, req *pb.Empty) (*pb.StringResponse, error)
Binary methods
func (*GRPCServer) BinarySource ¶
func (s *GRPCServer) BinarySource(ctx context.Context, req *pb.Empty) (*pb.BinarySourceResponse, error)
func (*GRPCServer) DefaultBinaryVersion ¶
func (s *GRPCServer) DefaultBinaryVersion(ctx context.Context, req *pb.Empty) (*pb.StringResponse, error)
func (*GRPCServer) DefaultChainID
deprecated
func (s *GRPCServer) DefaultChainID(ctx context.Context, req *pb.Empty) (*pb.StringResponse, error)
Deprecated: DefaultChainID will be removed in v2.0.0
func (*GRPCServer) DefaultGeneratorConfig ¶
func (s *GRPCServer) DefaultGeneratorConfig(ctx context.Context, req *pb.Empty) (*pb.GeneratorConfigResponse, error)
func (*GRPCServer) DefaultNodeHome ¶
func (s *GRPCServer) DefaultNodeHome(ctx context.Context, req *pb.Empty) (*pb.StringResponse, error)
Path methods
func (*GRPCServer) DefaultPorts ¶
func (s *GRPCServer) DefaultPorts(ctx context.Context, req *pb.Empty) (*pb.PortConfigResponse, error)
func (*GRPCServer) DisplayName ¶
func (s *GRPCServer) DisplayName(ctx context.Context, req *pb.Empty) (*pb.StringResponse, error)
func (*GRPCServer) DockerHomeDir ¶
func (s *GRPCServer) DockerHomeDir(ctx context.Context, req *pb.Empty) (*pb.StringResponse, error)
func (*GRPCServer) DockerImage ¶
func (s *GRPCServer) DockerImage(ctx context.Context, req *pb.Empty) (*pb.StringResponse, error)
Docker methods
func (*GRPCServer) DockerImageTag ¶
func (s *GRPCServer) DockerImageTag(ctx context.Context, req *pb.StringRequest) (*pb.StringResponse, error)
func (*GRPCServer) ExportCommand ¶
func (s *GRPCServer) ExportCommand(ctx context.Context, req *pb.StringRequest) (*pb.StringListResponse, error)
func (*GRPCServer) GenerateDevnet ¶
func (s *GRPCServer) GenerateDevnet(ctx context.Context, req *pb.GenerateDevnetRequest) (*pb.ErrorResponse, error)
func (*GRPCServer) GenesisConfig ¶
func (s *GRPCServer) GenesisConfig(ctx context.Context, req *pb.Empty) (*pb.GenesisConfigResponse, error)
Configuration methods
func (*GRPCServer) GetCodec ¶
func (s *GRPCServer) GetCodec(ctx context.Context, req *pb.Empty) (*pb.BytesResponse, error)
func (*GRPCServer) InitCommand ¶
func (s *GRPCServer) InitCommand(ctx context.Context, req *pb.InitCommandRequest) (*pb.StringListResponse, error)
Command methods
func (*GRPCServer) LogFileName ¶
func (s *GRPCServer) LogFileName(ctx context.Context, req *pb.Empty) (*pb.StringResponse, error)
func (*GRPCServer) ModifyGenesis ¶
func (s *GRPCServer) ModifyGenesis(ctx context.Context, req *pb.ModifyGenesisRequest) (*pb.BytesResponse, error)
Operation methods
func (*GRPCServer) Name ¶
func (s *GRPCServer) Name(ctx context.Context, req *pb.Empty) (*pb.StringResponse, error)
Identity methods
func (*GRPCServer) PIDFileName ¶
func (s *GRPCServer) PIDFileName(ctx context.Context, req *pb.Empty) (*pb.StringResponse, error)
func (*GRPCServer) ProcessPattern ¶
func (s *GRPCServer) ProcessPattern(ctx context.Context, req *pb.Empty) (*pb.StringResponse, error)
func (*GRPCServer) RPCEndpoint ¶
func (s *GRPCServer) RPCEndpoint(ctx context.Context, req *pb.StringRequest) (*pb.StringResponse, error)
func (*GRPCServer) SnapshotURL ¶
func (s *GRPCServer) SnapshotURL(ctx context.Context, req *pb.StringRequest) (*pb.StringResponse, error)
Snapshot methods
func (*GRPCServer) StartCommand ¶
func (s *GRPCServer) StartCommand(ctx context.Context, req *pb.StringRequest) (*pb.StringListResponse, error)
func (*GRPCServer) Validate ¶
func (s *GRPCServer) Validate(ctx context.Context, req *pb.Empty) (*pb.ErrorResponse, error)
func (*GRPCServer) Version ¶
func (s *GRPCServer) Version(ctx context.Context, req *pb.Empty) (*pb.StringResponse, error)
type GeneratorConfig ¶
type GeneratorConfig struct {
NumValidators int
NumAccounts int
AccountBalance string
ValidatorBalance string
ValidatorStake string
OutputDir string
ChainID string
}
GeneratorConfig contains devnet generator configuration.
type GenesisConfig ¶
type GenesisConfig struct {
ChainIDPattern string
EVMChainID int64
BaseDenom string
DenomExponent int
DisplayDenom string
BondDenom string
MinSelfDelegation string
UnbondingTime time.Duration
MaxValidators uint32
MinDeposit string
VotingPeriod time.Duration
MaxDepositPeriod time.Duration
CommunityTax string
}
GenesisConfig contains genesis parameters.
type GenesisOptions ¶
GenesisOptions contains genesis modification options.
type NetworkModule ¶
type NetworkModule interface {
Name() string
DisplayName() string
Version() string
BinaryName() string
BinarySource() BinarySource
DefaultBinaryVersion() string
DefaultChainID() string
Bech32Prefix() string
BaseDenom() string
GenesisConfig() GenesisConfig
DefaultPorts() PortConfig
DefaultGeneratorConfig() GeneratorConfig
DockerImage() string
DockerImageTag(version string) string
DockerHomeDir() string
InitCommand(homeDir, chainID, moniker string) []string
StartCommand(homeDir string) []string
ExportCommand(homeDir string) []string
DefaultNodeHome() string
PIDFileName() string
LogFileName() string
ProcessPattern() string
ModifyGenesis(genesis []byte, opts GenesisOptions) ([]byte, error)
GenerateDevnet(ctx context.Context, config GeneratorConfig, genesisFile string) error
GetCodec() ([]byte, error)
Validate() error
// Snapshot methods
SnapshotURL(networkType string) string
RPCEndpoint(networkType string) string
AvailableNetworks() []string
}
NetworkModule is the interface that plugins must implement.
type NetworkModuleGRPCPlugin ¶
type NetworkModuleGRPCPlugin struct {
plugin.Plugin
Impl NetworkModule
}
NetworkModuleGRPCPlugin is the plugin.GRPCPlugin implementation.
func (*NetworkModuleGRPCPlugin) GRPCClient ¶
func (p *NetworkModuleGRPCPlugin) GRPCClient(ctx context.Context, broker *plugin.GRPCBroker, c *grpc.ClientConn) (interface{}, error)
GRPCClient returns a gRPC client for the plugin.
func (*NetworkModuleGRPCPlugin) GRPCServer ¶
func (p *NetworkModuleGRPCPlugin) GRPCServer(broker *plugin.GRPCBroker, s *grpc.Server) error
GRPCServer returns a gRPC server for the plugin.
type PluginManager ¶
type PluginManager struct {
// contains filtered or unexported fields
}
PluginManager handles discovery and loading of network plugins.
func NewPluginManager ¶
func NewPluginManager(pluginDir string) *PluginManager
NewPluginManager creates a new plugin manager.
func (*PluginManager) DiscoverPlugins ¶
func (m *PluginManager) DiscoverPlugins() ([]string, error)
DiscoverPlugins finds all available network plugins in the plugin directory.
func (*PluginManager) GetModule ¶
func (m *PluginManager) GetModule(networkName string) (NetworkModule, bool)
GetModule returns a loaded module by name.
func (*PluginManager) ListModules ¶
func (m *PluginManager) ListModules() []string
ListModules returns all loaded module names.
func (*PluginManager) LoadPlugin ¶
func (m *PluginManager) LoadPlugin(networkName string) (NetworkModule, error)
LoadPlugin loads a specific network plugin.