blockchain

package
v1.16.37 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2025 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Blockchain

type Blockchain struct {
	ID          string
	Name        string
	Type        BlockchainType
	VMType      VMType
	ChainID     types.ID
	Genesis     []byte
	ChainConfig []byte
	Status      BlockchainStatus
	CreatedAt   time.Time
	DeployedAt  *time.Time
	NetworkID   string
}

Blockchain represents a Lux blockchain

type BlockchainStatus

type BlockchainStatus string

BlockchainStatus defines the status of a blockchain

const (
	StatusCreated   BlockchainStatus = "created"
	StatusDeploying BlockchainStatus = "deploying"
	StatusDeployed  BlockchainStatus = "deployed"
	StatusRunning   BlockchainStatus = "running"
	StatusStopped   BlockchainStatus = "stopped"
	StatusError     BlockchainStatus = "error"
)

type BlockchainType

type BlockchainType string

BlockchainType defines the type of blockchain

const (
	TypeL1 BlockchainType = "L1"
	TypeL2 BlockchainType = "L2"
	TypeL3 BlockchainType = "L3"
)

type Builder

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

Builder handles blockchain creation and deployment

func NewBuilder

func NewBuilder(logger log.Logger) *Builder

NewBuilder creates a new blockchain builder

func (*Builder) CreateBlockchain

func (b *Builder) CreateBlockchain(ctx context.Context, params *CreateParams) (*Blockchain, error)

CreateBlockchain creates a new blockchain

func (*Builder) Deploy

func (b *Builder) Deploy(ctx context.Context, blockchain *Blockchain, network *network.Network) error

Deploy deploys a blockchain to a network

func (*Builder) GenerateGenesis

func (b *Builder) GenerateGenesis(params *GenesisParams) ([]byte, error)

GenerateGenesis generates a genesis file for a blockchain

func (*Builder) GetBlockchain

func (b *Builder) GetBlockchain(blockchainID string) (*Blockchain, error)

GetBlockchain returns a blockchain by ID

func (*Builder) ListBlockchains

func (b *Builder) ListBlockchains() []*Blockchain

ListBlockchains returns all blockchains

func (*Builder) ValidateConfig

func (b *Builder) ValidateConfig(config []byte) error

ValidateConfig validates a chain configuration

type CreateParams

type CreateParams struct {
	Name          string
	Type          BlockchainType
	VMType        VMType
	ChainID       *big.Int
	Genesis       []byte
	ChainConfig   []byte
	VMConfig      map[string]interface{}
	Allocations   map[common.Address]GenesisAccount
	ValidatorSet  []Validator
	InitialSupply *big.Int
	L2Config      *L2Config
	L3Config      *L3Config
}

CreateParams defines parameters for creating a blockchain

type GenesisAccount

type GenesisAccount struct {
	Balance *big.Int                    `json:"balance"`
	Code    []byte                      `json:"code,omitempty"`
	Storage map[common.Hash]common.Hash `json:"storage,omitempty"`
}

GenesisAccount defines an account in genesis

type GenesisParams

type GenesisParams struct {
	VMType        VMType
	ChainID       *big.Int
	Allocations   map[common.Address]GenesisAccount
	ValidatorSet  []Validator
	InitialSupply *big.Int
}

GenesisParams defines parameters for genesis generation

type GenesisValidator added in v1.3.8

type GenesisValidator struct {
	NodeID string `json:"nodeId"`
	Weight uint64 `json:"weight"`
}

GenesisValidator defines a validator in the genesis Uses simplified fields for genesis configuration

type L1Params

type L1Params struct {
	VMType      VMType
	Genesis     []byte
	ChainConfig []byte
}

L1Params defines parameters for L1 creation

type L2Config

type L2Config struct {
	SequencerType   string
	DALayer         string
	SettlementChain string
	BridgeContract  string
}

L2Config defines L2-specific configuration

type L2Params

type L2Params struct {
	VMType          VMType
	Genesis         []byte
	ChainConfig     []byte
	SequencerType   string
	DALayer         string
	SettlementChain string
}

L2Params defines parameters for L2 creation

type L3Config

type L3Config struct {
	L2Chain   string
	AppType   string
	AppConfig map[string]interface{}
}

L3Config defines L3-specific configuration

type L3Params

type L3Params struct {
	VMType      VMType
	Genesis     []byte
	ChainConfig []byte
	L2Chain     string
	AppType     string
	AppConfig   map[string]interface{}
}

L3Params defines parameters for L3 creation

type Metrics

type Metrics struct {

	// Block metrics
	BlocksProduced   uint64
	LastBlockTime    time.Time
	AverageBlockTime time.Duration

	// Transaction metrics
	TxProcessed uint64
	TxFailed    uint64
	TPS         float64

	// Network metrics
	PeersConnected int
	NetworkLatency time.Duration

	// Resource metrics
	CPUUsage    float64
	MemoryUsage uint64
	DiskUsage   uint64
	// contains filtered or unexported fields
}

Metrics tracks blockchain performance metrics

func NewMetrics

func NewMetrics() *Metrics

NewMetrics creates a new metrics instance

func (*Metrics) GetSnapshot

func (m *Metrics) GetSnapshot() map[string]interface{}

GetSnapshot returns a snapshot of current metrics

func (*Metrics) RecordBlock

func (m *Metrics) RecordBlock(blockTime time.Time)

RecordBlock records a new block

func (*Metrics) RecordTransaction

func (m *Metrics) RecordTransaction(success bool)

RecordTransaction records a transaction

func (*Metrics) UpdateNetwork

func (m *Metrics) UpdateNetwork(peers int, latency time.Duration)

UpdateNetwork updates network metrics

func (*Metrics) UpdateResources

func (m *Metrics) UpdateResources(cpu float64, memory, disk uint64)

UpdateResources updates resource usage metrics

func (*Metrics) UpdateTPS

func (m *Metrics) UpdateTPS(tps float64)

UpdateTPS updates transactions per second

type Net added in v1.3.8

type Net struct {
	NetID               interface{} `json:"netId"` // ids.ID
	BlockchainID        interface{} // ids.ID
	OwnerAddress        *common.Address
	RPC                 string
	BootstrapValidators []interface{} // []Validator
}

Net represents a blockchain network with validator management capabilities As above, so below - unified across all network layers (primary, L1, L2, L3)

func (*Net) InitializeProofOfAuthority added in v1.3.8

func (s *Net) InitializeProofOfAuthority(
	log interface{},
	network interface{},
	privateKey string,
	aggregatorLogger interface{},
	validatorManagerAddress string,
	v2_0_0 bool,
	signatureAggregatorEndpoint string,
) error

InitializeProofOfAuthority initializes a PoA validator manager

func (*Net) InitializeProofOfStake added in v1.3.8

func (s *Net) InitializeProofOfStake(
	log interface{},
	network interface{},
	privateKey string,
	aggregatorLogger interface{},
	posParams interface{},
	managerAddress string,
	signatureAggregatorEndpoint string,
) error

InitializeProofOfStake initializes a PoS validator manager

type VMType

type VMType string

VMType defines the virtual machine type

const (
	VMTypeEVM        VMType = "evm"
	VMTypeWASM       VMType = "wasm"
	VMTypeCustom     VMType = "custom"
	VMTypeTokenVM    VMType = "tokenvm"
	VMTypeMorpheusVM VMType = "morpheusvm"
)

type Validator

type Validator = GenesisValidator

Validator is an alias for backward compatibility

Jump to

Keyboard shortcuts

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