mpcvm

package
v2.0.0-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2025 License: BSD-3-Clause Imports: 36 Imported by: 0

Documentation

Index

Constants

View Source
const Version = "v0.1.0"

Version

Variables

View Source
var (
	// MPCVMID is the ID of the MPCVM
	MPCVMID = ids.ID{'m', 'p', 'c', 'v', 'm'}
)

Functions

This section is empty.

Types

type APIServer

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

API Server

func NewAPIServer

func NewAPIServer(vm *VM) *APIServer

func (*APIServer) CreateHandlers

func (a *APIServer) CreateHandlers() (map[string]http.Handler, error)

func (*APIServer) CreateStaticHandlers

func (a *APIServer) CreateStaticHandlers() (map[string]http.Handler, error)

func (*APIServer) Shutdown

func (a *APIServer) Shutdown()

type Asset

type Asset struct {
	ID              ids.ID
	Symbol          string
	Name            string
	Type            AssetType
	ContractAddress string
	TokenID         string
	Metadata        map[string]interface{}
}

Asset represents a teleportable asset

type AssetIdentifier

type AssetIdentifier struct {
	ChainID         ids.ID
	AssetID         ids.ID
	ContractAddress common.Address
	TokenID         *big.Int // For NFTs
}

AssetIdentifier uniquely identifies an asset across chains

type AssetMetadata

type AssetMetadata struct {
	Name           string
	Symbol         string
	Description    string
	ImageURI       string
	ExternalURI    string
	Attributes     map[string]interface{}
	ValidatorPower *big.Int // For validator NFTs
}

AssetMetadata contains metadata about an asset

type AssetRegistry

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

func NewAssetRegistry

func NewAssetRegistry(db database.Database) *AssetRegistry

func (*AssetRegistry) GetAsset

func (ar *AssetRegistry) GetAsset(assetID ids.ID) (*Asset, error)

GetAsset retrieves an asset by its ID

func (*AssetRegistry) UpdateAssetLocation

func (ar *AssetRegistry) UpdateAssetLocation(assetID ids.ID, chainID ids.ID) error

UpdateAssetLocation updates the current location of an asset

type AssetType

type AssetType uint8

AssetType defines the type of asset

const (
	AssetTypeFungible AssetType = iota
	AssetTypeNFT
	AssetTypeSemiNFT      // For fractional NFTs
	AssetTypeValidatorNFT // Special NFT that can be staked on P-Chain
)

type Block

type Block struct {
	ParentID  ids.ID
	Timestamp uint64
	BlockID   ids.ID

	// Block content
	Header *BlockHeader
	Body   *BlockBody
	// contains filtered or unexported fields
}

Block represents a block in the M-Chain

func (*Block) Accept

func (b *Block) Accept() error

Accept marks the block as accepted

func (*Block) Bytes

func (b *Block) Bytes() []byte

Bytes returns the byte representation of the block

func (*Block) Height

func (b *Block) Height() uint64

Height returns the block height

func (*Block) ID

func (b *Block) ID() string

ID returns the block ID

func (*Block) Parent

func (b *Block) Parent() ids.ID

Parent returns the parent block ID

func (*Block) Reject

func (b *Block) Reject() error

Reject marks the block as rejected

func (*Block) Status

func (b *Block) Status() choices.Status

Status returns the block's status

func (*Block) Time

func (b *Block) Time() uint64

Time returns the block timestamp

func (*Block) Verify

func (b *Block) Verify(context.Context) error

Verify verifies the block's validity

type BlockBody

type BlockBody struct {
	// Regular transactions
	Transactions []*Transaction

	// Teleport operations
	TeleportOps []*TeleportOperation

	// MPC operations
	MPCOps []*MPCOperation

	// Validator updates
	ValidatorOps []*ValidatorOperation

	// Cross-chain messages
	WarpPayloads [][]byte
}

BlockBody contains the block transactions and operations

type BlockChain

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

BlockChain manages the blockchain state

func NewBlockChain

func NewBlockChain(blockDB, stateDB database.Database, genesis *Genesis, config Config) *BlockChain

func (*BlockChain) AcceptBlock

func (bc *BlockChain) AcceptBlock(b *Block) error

func (*BlockChain) BuildBlock

func (bc *BlockChain) BuildBlock() (block.Block, error)

func (*BlockChain) GetBlock

func (bc *BlockChain) GetBlock(blockID ids.ID) (block.Block, error)

func (*BlockChain) IsSynced

func (bc *BlockChain) IsSynced() bool

func (*BlockChain) LastAccepted

func (bc *BlockChain) LastAccepted() (ids.ID, error)

func (*BlockChain) ParseBlock

func (bc *BlockChain) ParseBlock(blockBytes []byte) (block.Block, error)

func (*BlockChain) SetPreference

func (bc *BlockChain) SetPreference(blockID ids.ID) error

type BlockHeader

type BlockHeader struct {
	ParentHash    common.Hash
	StateRoot     common.Hash
	TxRoot        common.Hash
	ReceiptRoot   common.Hash
	TeleportRoot  common.Hash // Root of teleport operations
	ValidatorRoot common.Hash // Root of validator set changes
	Height        uint64
	Timestamp     uint64
	Extra         []byte

	// MPC signatures
	MPCSignature []byte
	SignerBitmap []byte // Bitmap of which validators signed

	// Warp messages
	WarpMessages []*warp.UnsignedMessage
}

BlockHeader contains the block header information

type CChainClient

type CChainClient interface {
	GetHeight(ctx context.Context) (uint64, error)
	GetBlockByNumber(ctx context.Context, blockNumber uint64) (interface{}, error)
	GetTransactionReceipt(ctx context.Context, txHash string) (interface{}, error)
}

CChainClient interface for interacting with C-Chain

type CGG21KeyGen

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

CGG21KeyGen implements the Canetti-Gennaro-Goldfeder 2021 key generation protocol

func (*CGG21KeyGen) Run

func (kg *CGG21KeyGen) Run(session *MPCSession)

Run executes the key generation protocol

type CGG21Reshare

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

CGG21Reshare implements the CGG21 resharing protocol

type CGG21Sign

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

CGG21Sign implements the CGG21 signing protocol

func (*CGG21Sign) Sign

func (cs *CGG21Sign) Sign(ctx context.Context, session *MPCSession, message []byte) error

Sign executes the CGG21 signing protocol

type Config

type Config struct {
	// General
	MempoolSize        int           `json:"mempoolSize"`
	BlockBuildInterval time.Duration `json:"blockBuildInterval"`

	// MPC
	MPCEnabled bool      `json:"mpcEnabled"`
	MPCConfig  MPCConfig `json:"mpcConfig"`

	// ZK
	ZKEnabled bool `json:"zkEnabled"`

	// Teleport
	TeleportEnabled bool           `json:"teleportEnabled"`
	IntentPoolSize  int            `json:"intentPoolSize"`
	ExecutorConfig  ExecutorConfig `json:"executorConfig"`

	// Warp
	WarpConfig interface{} `json:"warpConfig"`

	// P2P
	P2PConfig interface{} `json:"p2pConfig"`
}

Config contains the configuration for the MVM

func (*Config) Parse

func (c *Config) Parse(configBytes []byte) error

Parse parses the configuration from bytes

type ExecutorConfig

type ExecutorConfig struct {
	MaxConcurrentExecutions int           `json:"maxConcurrentExecutions"`
	ExecutionTimeout        time.Duration `json:"executionTimeout"`
}

ExecutorConfig contains executor-specific configuration

type ExecutorEngine

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

func NewExecutorEngine

func NewExecutorEngine(wallet *MPCWallet, assetRegistry *AssetRegistry, zkProver *ZKProver, config ExecutorConfig) *ExecutorEngine

type Factory

type Factory struct{}

Factory implements vms.Factory

func (*Factory) New

func (f *Factory) New(log.Logger) (interface{}, error)

New creates a new MPCVM instance

type Genesis

type Genesis struct {
	Config GenesisConfig `json:"config"`
}

Genesis

func ParseGenesis

func ParseGenesis(genesisBytes []byte) (*Genesis, error)

func (*Genesis) Hash

func (g *Genesis) Hash() common.Hash

type GenesisConfig

type GenesisConfig struct {
}

type Health

type Health struct {
	Healthy        bool   `json:"healthy"`
	BlockchainSync bool   `json:"blockchainSync"`
	MPCStatus      string `json:"mpcStatus"`
	TeleportStatus string `json:"teleportStatus"`
}

Health

type IntentPool

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

func NewIntentPool

func NewIntentPool(maxSize int) *IntentPool

func (*IntentPool) AddIntent

func (ip *IntentPool) AddIntent(intent *TeleportIntent) error

func (*IntentPool) Len

func (ip *IntentPool) Len() int

func (*IntentPool) RemoveIntent

func (ip *IntentPool) RemoveIntent(intentID ids.ID)

type IntentType

type IntentType uint8

IntentType defines the type of teleport intent

const (
	IntentTypeTransfer IntentType = iota
	IntentTypeSwap
	IntentTypeStake // For staking NFTs on P-Chain
	IntentTypeBridge
)

type KeyGenProtocol

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

func NewKeyGenProtocol

func NewKeyGenProtocol(manager *MPCManager) *KeyGenProtocol

type KeyGenRequest

type KeyGenRequest struct {
	RequestID    ids.ID
	Participants []ids.NodeID
	Purpose      string
}

type KeyShare

type KeyShare struct {
	KeyID        ids.ID
	PartyID      ids.NodeID
	Share        []byte
	PublicKey    *ecdsa.PublicKey
	Threshold    uint32
	TotalParties uint32
	CreatedAt    time.Time
	LastUsed     time.Time
}

KeyShare represents a party's share of an MPC key

type MPCConfig

type MPCConfig struct {
	Threshold             int           `json:"threshold"`
	SessionTimeout        time.Duration `json:"sessionTimeout"`
	KeyGenTimeout         time.Duration `json:"keyGenTimeout"`
	SignTimeout           time.Duration `json:"signTimeout"`
	MaxSessions           int           `json:"maxSessions"`
	MaxConcurrentSessions int           `json:"maxConcurrentSessions"`
}

MPCConfig contains MPC-specific configuration

type MPCManager

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

MPCManager manages MPC operations for the M-Chain

func NewMPCManager

func NewMPCManager(db database.Database, config MPCConfig) *MPCManager

NewMPCManager creates a new MPC manager

func (*MPCManager) CleanupSession

func (m *MPCManager) CleanupSession(sessionID ids.ID)

CleanupSession cleans up a session

func (*MPCManager) HasPendingOperations

func (m *MPCManager) HasPendingOperations() bool

HasPendingOperations returns true if there are pending MPC operations

func (*MPCManager) HealthStatus

func (m *MPCManager) HealthStatus() string

HealthStatus returns the health status of the MPC manager

func (*MPCManager) InitiateKeyGen

func (m *MPCManager) InitiateKeyGen(data []byte) error

InitiateKeyGen starts a new key generation session

func (*MPCManager) Run

func (m *MPCManager) Run(shutdown <-chan struct{}, wg *sync.WaitGroup)

Run starts the MPC manager background tasks

func (*MPCManager) SignXChainTx

func (m *MPCManager) SignXChainTx(tx interface{}) (interface{}, error)

SignXChainTx signs an X-Chain transaction using MPC

func (*MPCManager) StoreKeyGenResult

func (m *MPCManager) StoreKeyGenResult(sessionID ids.ID, result []byte) error

StoreKeyGenResult stores the result of key generation

func (*MPCManager) StoreSignature

func (m *MPCManager) StoreSignature(sessionID ids.ID, signature []byte) error

StoreSignature stores a signature result

func (*MPCManager) UpdateKeyShares

func (m *MPCManager) UpdateKeyShares(sessionID ids.ID, newShares []byte) error

UpdateKeyShares updates key shares after resharing

func (*MPCManager) VerifyBlockSignature

func (m *MPCManager) VerifyBlockSignature(message []byte, signature []byte, signerBitmap []byte) error

VerifyBlockSignature verifies an MPC signature on a block

type MPCOpType

type MPCOpType uint8

MPCOpType defines the type of MPC operation

const (
	MPCOpTypeKeyGen MPCOpType = iota
	MPCOpTypeSign
	MPCOpTypeReshare
	MPCOpTypeRefresh
)

type MPCOperation

type MPCOperation struct {
	Type         MPCOpType
	SessionID    ids.ID
	Participants []ids.NodeID
	Threshold    uint32

	// Operation-specific data
	Data []byte

	// Results
	Result     []byte
	Signatures [][]byte
}

MPCOperation represents an MPC operation in a block

type MPCSession

type MPCSession struct {
	SessionID    ids.ID
	Type         MPCSessionType
	KeyID        ids.ID
	Participants []ids.NodeID
	Threshold    uint32
	State        SessionState
	StartTime    time.Time
	LastUpdate   time.Time
	Result       []byte
	Error        error
	// contains filtered or unexported fields
}

MPCSession represents an active MPC session

type MPCSessionType

type MPCSessionType uint8

MPCSessionType defines the type of MPC session

const (
	SessionTypeKeyGen MPCSessionType = iota
	SessionTypeSign
	SessionTypeReshare
	SessionTypeRefresh
)

type MPCWallet

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

func NewMPCWallet

func NewMPCWallet(manager *MPCManager) *MPCWallet

type Mempool

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

Mempool manages pending transactions

func NewMempool

func NewMempool(size int) *Mempool

func (*Mempool) Len

func (m *Mempool) Len() int

type Message

type Message struct {
	From      ids.NodeID
	To        ids.NodeID
	Round     uint32
	Content   []byte
	Signature []byte
}

Message represents a message in the MPC protocol

type NFTHandler

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

NFTHandler manages NFT-specific teleport operations

func NewNFTHandler

func NewNFTHandler(registry *AssetRegistry, zkProver *ZKProver) *NFTHandler

NewNFTHandler creates a new NFT handler

func (*NFTHandler) ActivateValidatorNFT

func (nh *NFTHandler) ActivateValidatorNFT(assetID ids.ID, validatorTxID ids.ID)

ActivateValidatorNFT marks a validator NFT as active

func (*NFTHandler) GetValidatorNFT

func (nh *NFTHandler) GetValidatorNFT(assetID ids.ID) (*ValidatorNFT, error)

GetValidatorNFT returns validator NFT information

type NetworkHandler

type NetworkHandler interface {
	Run(shutdownChan <-chan struct{}, wg *sync.WaitGroup)
}

NetworkHandler handles network communication

func NewNetworkHandler

func NewNetworkHandler(vm *VM, appSender core.AppSender) NetworkHandler

type PChainClient

type PChainClient interface {
	GetHeight(ctx context.Context) (uint64, error)
	// TODO: Fix GetValidatorOutput type
	// GetValidatorSet(ctx context.Context, height uint64, subnetID ids.ID) (map[ids.NodeID]*api.GetValidatorOutput, error)
	GetCurrentValidators(ctx context.Context, subnetID ids.ID) ([]interface{}, error)
}

PChainClient interface for interacting with P-Chain

type PublicKey

type PublicKey struct {
	KeyID        ids.ID
	PublicKey    *ecdsa.PublicKey
	Threshold    uint32
	TotalParties uint32
	CreatedAt    time.Time
}

PublicKey represents an MPC public key

type ReshareProtocol

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

func NewReshareProtocol

func NewReshareProtocol(manager *MPCManager) *ReshareProtocol

type SessionState

type SessionState uint8

SessionState defines the state of an MPC session

const (
	SessionStatePending SessionState = iota
	SessionStateActive
	SessionStateCompleted
	SessionStateFailed
	SessionStateAborted
)

type Settlement

type Settlement struct {
	ID            ids.ID
	Type          SettlementType
	AssetID       ids.ID
	Amount        uint64
	SourceChain   ids.ID
	DestChain     ids.ID
	Recipient     common.Address
	TeleportProof *TeleportProof
	Status        SettlementStatus
	CreatedAt     time.Time
	CompletedAt   time.Time
	XChainTxID    ids.ID
}

Settlement represents a pending X-Chain settlement

type SettlementStatus

type SettlementStatus uint8
const (
	SettlementStatusPending SettlementStatus = iota
	SettlementStatusInProgress
	SettlementStatusCompleted
	SettlementStatusFailed
)

type SettlementType

type SettlementType uint8
const (
	SettlementTypeMint SettlementType = iota
	SettlementTypeBurn
)

type SignProtocol

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

func NewSignProtocol

func NewSignProtocol(manager *MPCManager) *SignProtocol

type TeleportAsset

type TeleportAsset struct {
	ID              ids.ID
	Type            AssetType
	OriginChain     ids.ID
	CurrentChain    ids.ID
	ContractAddress common.Address
	TokenID         *big.Int // For NFTs
	Metadata        AssetMetadata
	TotalSupply     *big.Int
	Decimals        uint8
}

TeleportAsset represents an asset that can be teleported

type TeleportConfig

type TeleportConfig struct {
	MaxTransferAmount    uint64 `json:"maxTransferAmount"`
	MinTransferAmount    uint64 `json:"minTransferAmount"`
	TransferFeePercent   uint64 `json:"transferFeePercent"`
	SettlementBatchSize  int    `json:"settlementBatchSize"`
	SettlementTimeout    int64  `json:"settlementTimeout"`
	MaxPendingTransfers  int    `json:"maxPendingTransfers"`
	ProofValidationDelay int64  `json:"proofValidationDelay"`
}

TeleportConfig contains teleport-specific configuration

type TeleportEngine

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

TeleportEngine orchestrates cross-chain transfers via the Teleport Protocol

func NewTeleportEngine

func NewTeleportEngine(
	intentPool *IntentPool,
	executorEngine *ExecutorEngine,
	assetRegistry *AssetRegistry,
	zkVerifier *ZKVerifier,
	xchainSettlement *XChainSettlement,
	config TeleportConfig,
) *TeleportEngine

NewTeleportEngine creates a new Teleport Protocol engine

func (*TeleportEngine) HealthStatus

func (te *TeleportEngine) HealthStatus() string

HealthStatus returns the health status of the teleport engine

func (*TeleportEngine) ProcessIntent

func (te *TeleportEngine) ProcessIntent(ctx context.Context, intent *TeleportIntent) (*TeleportTransfer, error)

ProcessIntent processes a new teleport intent

func (*TeleportEngine) Run

func (te *TeleportEngine) Run(shutdown <-chan struct{}, wg *sync.WaitGroup)

Run starts the teleport engine background services

type TeleportIntent

type TeleportIntent struct {
	ID          ids.ID
	Version     uint8
	IntentType  IntentType
	SourceAsset AssetIdentifier
	DestAsset   AssetIdentifier
	Amount      *big.Int
	Sender      common.Address
	Recipient   common.Address
	MaxSlippage *big.Int
	Deadline    time.Time
	Signature   []byte
	Metadata    map[string]interface{}
}

TeleportIntent represents a user's intent to transfer assets

type TeleportOpType

type TeleportOpType uint8

TeleportOpType defines the type of teleport operation

const (
	TeleportOpTypeInitiate TeleportOpType = iota
	TeleportOpTypeSettle
	TeleportOpTypeComplete
	TeleportOpTypeRefund
)

type TeleportOperation

type TeleportOperation struct {
	Type       TeleportOpType
	TransferID ids.ID
	IntentID   ids.ID
	Status     TransferStatus

	// Settlement info
	SettlementType SettlementType
	XChainTxID     *ids.ID

	// Proofs
	ZKProof       []byte
	ValidatorSigs [][]byte
}

TeleportOperation represents a teleport operation in a block

func (*TeleportOperation) Hash

func (op *TeleportOperation) Hash() common.Hash

Hash returns the hash of a teleport operation

type TeleportProof

type TeleportProof struct {
	// Cross-chain transfer proof
	TransferProof []byte

	// State transition proofs
	SourceStateProof []byte
	DestStateProof   []byte

	// Asset registry proof
	AssetValidityProof []byte

	// Execution proof (for intents)
	ExecutionProof []byte

	// Aggregated validator signatures
	ValidatorSigs [][]byte

	// Metadata
	ProofType   string
	GeneratedAt time.Time
}

TeleportProof contains the ZK proof for a teleport operation

type TeleportTransfer

type TeleportTransfer struct {
	ID          ids.ID
	Intent      *TeleportIntent
	Status      TransferStatus
	SourceChain ids.ID
	DestChain   ids.ID
	Asset       *TeleportAsset
	Amount      *big.Int
	Sender      common.Address
	Recipient   common.Address
	ExecutorID  ids.ID
	Proofs      *TeleportProof
	CreatedAt   time.Time
	CompletedAt time.Time
	Error       error
}

TeleportTransfer represents an active cross-chain transfer

type Transaction

type Transaction struct {
	Type      TxType
	Nonce     uint64
	From      common.Address
	To        common.Address
	Value     []byte // Encoded amount
	Data      []byte
	Signature []byte

	// Teleport-specific fields
	IntentID    *ids.ID
	SourceChain *ids.ID
	DestChain   *ids.ID
}

Transaction represents a transaction in the M-Chain

func (*Transaction) Hash

func (tx *Transaction) Hash() common.Hash

Hash returns the hash of a transaction

type TransferStatus

type TransferStatus uint8

TransferStatus tracks the status of a transfer

const (
	TransferStatusPending TransferStatus = iota
	TransferStatusExecuting
	TransferStatusSettling
	TransferStatusCompleted
	TransferStatusFailed
	TransferStatusRefunded
)

type TxType

type TxType uint8

TxType defines the type of transaction

const (
	TxTypeTransfer TxType = iota
	TxTypeTeleportIntent
	TxTypeMPCKeyGen
	TxTypeMPCSign
	TxTypeValidatorUpdate
	TxTypeAssetRegistry
)

type VM

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

VM implements the MPC-Chain Virtual Machine

func NewVM

func NewVM() (*VM, error)

NewVM creates a new MPCVM instance

func (*VM) BuildBlock

func (vm *VM) BuildBlock(context.Context) (block.Block, error)

BuildBlock implements the block.ChainVM interface

func (*VM) CreateHandlers

func (vm *VM) CreateHandlers(context.Context) (map[string]interface{}, error)

CreateHandlers implements the common.VM interface

func (*VM) CreateStaticHandlers

func (vm *VM) CreateStaticHandlers(context.Context) (map[string]interface{}, error)

CreateStaticHandlers implements the common.VM interface

func (*VM) GetBlock

func (vm *VM) GetBlock(ctx context.Context, blockID ids.ID) (block.Block, error)

GetBlock implements the block.ChainVM interface

func (*VM) GetBlockSignature

func (vm *VM) GetBlockSignature(blockID ids.ID) ([bls.SignatureLen]byte, error)

GetBlockSignature returns the BLS signature for a block

func (*VM) GetLastStateSummary

func (vm *VM) GetLastStateSummary(context.Context) (block.StateSummary, error)

GetLastStateSummary implements block.StateSyncableVM

func (*VM) GetMessageSignature

func (vm *VM) GetMessageSignature(messageID ids.ID) ([bls.SignatureLen]byte, error)

GetMessageSignature returns the BLS signature for a Warp message

func (*VM) GetOngoingSyncStateSummary

func (vm *VM) GetOngoingSyncStateSummary(context.Context) (block.StateSummary, error)

GetOngoingSyncStateSummary implements block.StateSyncableVM

func (*VM) GetStateSummary

func (vm *VM) GetStateSummary(ctx context.Context, summaryHeight uint64) (block.StateSummary, error)

GetStateSummary implements block.StateSyncableVM

func (*VM) HealthCheck

func (vm *VM) HealthCheck(context.Context) (interface{}, error)

HealthCheck implements the common.VM interface

func (*VM) Initialize

func (vm *VM) Initialize(
	_ context.Context,
	ctx *quasar.Context,
	db database.Database,
	genesisBytes []byte,
	upgradeBytes []byte,
	configBytes []byte,
	fxs []*core.Fx,
	appSender core.AppSender,
) error

Initialize implements the block.ChainVM interface

func (*VM) LastAccepted

func (vm *VM) LastAccepted(context.Context) (ids.ID, error)

LastAccepted implements the block.ChainVM interface

func (*VM) ParseBlock

func (vm *VM) ParseBlock(ctx context.Context, blockBytes []byte) (block.Block, error)

ParseBlock implements the block.ChainVM interface

func (*VM) ParseStateSummary

func (vm *VM) ParseStateSummary(ctx context.Context, summaryBytes []byte) (block.StateSummary, error)

ParseStateSummary implements block.StateSyncableVM

func (*VM) SetPreference

func (vm *VM) SetPreference(ctx context.Context, blockID ids.ID) error

SetPreference implements the block.ChainVM interface

func (*VM) SetState

func (vm *VM) SetState(ctx context.Context, state quasar.State) error

SetState implements the block.ChainVM interface

func (*VM) Shutdown

func (vm *VM) Shutdown(context.Context) error

Shutdown implements the snowman.ChainVM interface

func (*VM) StateSyncEnabled

func (vm *VM) StateSyncEnabled(context.Context) (bool, error)

StateSyncEnabled implements block.StateSyncableVM

func (*VM) Version

func (vm *VM) Version(context.Context) (string, error)

Version implements the common.VM interface

func (*VM) WaitForEvent

func (vm *VM) WaitForEvent(ctx context.Context) (core.Message, error)

WaitForEvent implements the block.ChainVM interface

type ValidatorNFT

type ValidatorNFT struct {
	NFTAssetID      ids.ID
	ValidatorNodeID ids.NodeID
	StakeAmount     uint64
	StakeStartTime  time.Time
	StakeEndTime    time.Time
	DelegationFee   uint32
	RewardsOwner    ids.ID
	Active          bool
}

ValidatorNFT represents an NFT that can be used as a validator on P-Chain

type ValidatorOpType

type ValidatorOpType uint8

ValidatorOpType defines the type of validator operation

const (
	ValidatorOpTypeAdd ValidatorOpType = iota
	ValidatorOpTypeRemove
	ValidatorOpTypeUpdate
	ValidatorOpTypeNFTStake
	ValidatorOpTypeNFTUnstake
)

type ValidatorOperation

type ValidatorOperation struct {
	Type   ValidatorOpType
	NodeID ids.NodeID
	Weight uint64

	// For NFT validators
	NFTAssetID *ids.ID

	// Timing
	StartTime uint64
	EndTime   uint64
}

ValidatorOperation represents a validator set change

type ValidatorSet

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

ValidatorSet manages the validator set

func NewValidatorSet

func NewValidatorSet(db database.Database, state ValidatorState) *ValidatorSet

func (*ValidatorSet) AddNFTValidator

func (vs *ValidatorSet) AddNFTValidator(nodeID ids.NodeID, nftAssetID ids.ID, weight uint64) error

func (*ValidatorSet) AddValidator

func (vs *ValidatorSet) AddValidator(nodeID ids.NodeID, weight uint64, startTime, endTime uint64) error

func (*ValidatorSet) Count

func (vs *ValidatorSet) Count() int

func (*ValidatorSet) GetValidatorSet

func (vs *ValidatorSet) GetValidatorSet(height uint64) []interface{}

func (*ValidatorSet) ProcessUpdate

func (vs *ValidatorSet) ProcessUpdate(data []byte) error

func (*ValidatorSet) RemoveNFTValidator

func (vs *ValidatorSet) RemoveNFTValidator(nodeID ids.NodeID, nftAssetID ids.ID) error

func (*ValidatorSet) RemoveValidator

func (vs *ValidatorSet) RemoveValidator(nodeID ids.NodeID) error

type ValidatorState

type ValidatorState interface{}

type XChainClient

type XChainClient interface {
	GetUTXOs(ctx context.Context, addrs []string) ([]*lux.UTXO, error)
	IssueTx(ctx context.Context, tx []byte) (ids.ID, error)
	GetTx(ctx context.Context, txID ids.ID) ([]byte, error)
	GetBlockByHeight(ctx context.Context, height uint64) ([]byte, error)
	GetBalance(address ids.ShortID, assetID ids.ID) (uint64, error)
}

XChainClient interface for interacting with X-Chain

type XChainSettlement

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

XChainSettlement handles all X-Chain mint/burn operations for the Teleport Protocol

func NewXChainSettlement

func NewXChainSettlement(
	client XChainClient,
	mpcWallet *MPCWallet,
	zkProver *ZKProver,
	config XChainSettlementConfig,
) *XChainSettlement

NewXChainSettlement creates a new X-Chain settlement manager

func (*XChainSettlement) GetPendingSettlements

func (xs *XChainSettlement) GetPendingSettlements() []*Settlement

GetPendingSettlements returns all pending settlements

func (*XChainSettlement) GetSettlement

func (xs *XChainSettlement) GetSettlement(id ids.ID) (*Settlement, error)

GetSettlement returns a settlement by ID

func (*XChainSettlement) ProcessIncomingAssets

func (xs *XChainSettlement) ProcessIncomingAssets(
	ctx context.Context,
	sourceChain ids.ID,
	assetID ids.ID,
	amount uint64,
	recipient common.Address,
	proof *TeleportProof,
) (*Settlement, error)

ProcessIncomingAssets handles assets coming into the Lux ecosystem This MINTS new assets on the X-Chain backed by the locked assets on the source chain

func (*XChainSettlement) ProcessOutgoingAssets

func (xs *XChainSettlement) ProcessOutgoingAssets(
	ctx context.Context,
	destChain ids.ID,
	assetID ids.ID,
	amount uint64,
	sender common.Address,
	proof *TeleportProof,
) (*Settlement, error)

ProcessOutgoingAssets handles assets leaving the Lux ecosystem This BURNS assets on the X-Chain to release them on the destination chain

type XChainSettlementConfig

type XChainSettlementConfig struct {
	Endpoint           string
	BatchSize          int
	BatchInterval      time.Duration
	ConfirmationBlocks uint64
	MaxRetries         int
	RetryDelay         time.Duration
}

XChainSettlementConfig contains X-Chain settlement configuration

type ZKProver

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

func NewZKProver

func NewZKProver(db database.Database) *ZKProver

func (*ZKProver) VerifyProof

func (z *ZKProver) VerifyProof(proof interface{}) bool

VerifyProof verifies a zero-knowledge proof

type ZKVerifier

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

ZK Components

func NewZKVerifier

func NewZKVerifier(db database.Database) *ZKVerifier

func (*ZKVerifier) VerifyProof

func (z *ZKVerifier) VerifyProof(proofType string, proof []byte, publicInputs interface{}) error

Jump to

Keyboard shortcuts

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