yvm

package
v1.20.2 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2025 License: BSD-3-Clause Imports: 23 Imported by: 0

Documentation

Overview

Package yvm implements the Y-Chain (Yield-Curve/Years-Proof) Quantum State Ledger A minimal-footprint chain for quantum-safe checkpointing and cross-version asset migration Supports multiple network versions simultaneously via quantum state superposition

Index

Constants

View Source
const CodecVersion = 0

Variables

View Source
var (
	Codec codec.Manager
)
View Source
var (
	Version = &version.Semantic{
		Major: 1,
		Minor: 0,
		Patch: 0,
	}
)

Functions

This section is empty.

Types

type AssetMigration

type AssetMigration struct {
	MigrationID    ids.ID      `json:"migrationId"`
	AssetID        ids.ID      `json:"assetId"`
	Owner          ids.ShortID `json:"owner"`
	SourceVersion  uint32      `json:"sourceVersion"`
	TargetVersion  uint32      `json:"targetVersion"`
	Amount         uint64      `json:"amount"`
	MigrationProof []byte      `json:"migrationProof"`
	ClaimedAt      *time.Time  `json:"claimedAt,omitempty"`
	Status         string      `json:"status"` // pending, migrated, claimed
}

AssetMigration tracks an individual asset migration

type Block

type Block struct {
	ParentID       ids.ID         `json:"parentId"`
	BlockHeight    uint64         `json:"height"`
	BlockTimestamp int64          `json:"timestamp"`
	Epoch          uint64         `json:"epoch"`
	EpochRoots     []*EpochRootTx `json:"epochRoots"`

	// Fork management
	NetworkVersion  uint32            `json:"networkVersion,omitempty"`
	ForkTransitions []*ForkTransition `json:"forkTransitions,omitempty"`
	AssetMigrations []*AssetMigration `json:"assetMigrations,omitempty"`
	QuantumState    *QuantumState     `json:"quantumState,omitempty"`

	// Cached values
	ID_ ids.ID
	// contains filtered or unexported fields
}

Block represents a block in the Y-Chain quantum checkpoint ledger

func (*Block) Accept

func (b *Block) Accept(ctx context.Context) error

Accept marks the block as accepted

func (*Block) Bytes

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

Bytes returns the block bytes

func (*Block) Height

func (b *Block) Height() uint64

Height returns the block height

func (*Block) ID

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

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(ctx context.Context) error

Reject marks the block as rejected

func (*Block) Status

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

Status returns the block's status

func (*Block) Timestamp

func (b *Block) Timestamp() time.Time

Timestamp returns the block timestamp

func (*Block) Verify

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

Verify verifies the block

type Entanglement

type Entanglement struct {
	Version1        uint32  `json:"version1"`
	Version2        uint32  `json:"version2"`
	EntanglementKey []byte  `json:"entanglementKey"`
	Strength        float64 `json:"strength"` // 0.0 to 1.0
}

Entanglement represents entangled states between versions

type EpochCheckpoint

type EpochCheckpoint struct {
	Epoch            uint64            `json:"epoch"`
	Timestamp        int64             `json:"timestamp"`
	ChainRoots       map[string][]byte `json:"chainRoots"`
	EpochRootHash    []byte            `json:"epochRootHash"`
	SPHINCSSignature []byte            `json:"sphincsSignature"`
	BitcoinTxID      string            `json:"bitcoinTxId,omitempty"`
	IPFSHash         string            `json:"ipfsHash,omitempty"`
}

EpochCheckpoint represents a checkpoint for one epoch

type EpochRootTx

type EpochRootTx struct {
	Epoch      uint64            `json:"epoch"`
	ChainRoots map[string][]byte `json:"chainRoots"`
	NodeID     ids.NodeID        `json:"nodeId"`
	SPHINCSig  []byte            `json:"sphincsSig"`
}

EpochRootTx is the only transaction type on Y-Chain

type ForkManager

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

ForkManager manages network versions and transitions

func NewForkManager

func NewForkManager(log log.Logger) *ForkManager

NewForkManager creates a new fork manager

func (*ForkManager) ClaimMigration

func (fm *ForkManager) ClaimMigration(migrationID ids.ID, claimer ids.ShortID) error

ClaimMigration processes a migration claim

func (*ForkManager) CreateForkTransition

func (fm *ForkManager) CreateForkTransition(transition *ForkTransition) error

CreateForkTransition creates a transition between versions

func (*ForkManager) GetMigrationPath

func (fm *ForkManager) GetMigrationPath(fromVersion, toVersion uint32) ([]uint32, error)

GetMigrationPath finds the optimal migration path between versions

func (*ForkManager) GetQuantumState

func (fm *ForkManager) GetQuantumState(epoch uint64) (*QuantumState, error)

GetQuantumState returns the quantum state for an epoch

func (*ForkManager) MigrateAsset

func (fm *ForkManager) MigrateAsset(
	assetID ids.ID,
	owner ids.ShortID,
	amount uint64,
	fromVersion, toVersion uint32,
) (*AssetMigration, error)

MigrateAsset creates an asset migration between versions

func (*ForkManager) RegisterVersion

func (fm *ForkManager) RegisterVersion(version *NetworkVersion) error

RegisterVersion registers a new network version

func (*ForkManager) UpdateQuantumState

func (fm *ForkManager) UpdateQuantumState(epoch uint64, chainStates map[string][]byte) error

UpdateQuantumState updates the quantum state for an epoch

type ForkTransition

type ForkTransition struct {
	FromVersion     uint32          `json:"fromVersion"`
	ToVersion       uint32          `json:"toVersion"`
	TransitionEpoch uint64          `json:"transitionEpoch"`
	MigrationRules  []MigrationRule `json:"migrationRules"`
	Status          string          `json:"status"` // pending, active, completed
}

ForkTransition represents a transition between network versions

type Genesis

type Genesis struct {
	Timestamp int64 `json:"timestamp"`
}

Genesis represents the genesis state

type MigrationRule

type MigrationRule struct {
	AssetType       string `json:"assetType"` // LUX, NFT, Contract, etc.
	SourceChain     string `json:"sourceChain"`
	TargetChain     string `json:"targetChain"`
	ConversionRatio string `json:"conversionRatio"` // e.g., "1:1", "1000:1"
	RequiresClaim   bool   `json:"requiresClaim"`   // Manual claim vs automatic
}

MigrationRule defines how assets migrate between versions

type NetworkVersion

type NetworkVersion struct {
	VersionID       uint32            `json:"versionId"`
	Name            string            `json:"name"`
	ActivationEpoch uint64            `json:"activationEpoch"`
	ParentVersion   uint32            `json:"parentVersion"`
	Features        []string          `json:"features"`
	ChainStates     map[string][]byte `json:"chainStates"` // chainID -> state root
}

NetworkVersion represents a specific version/fork of the network

type QuantumState

type QuantumState struct {
	ActiveVersions  []uint32           `json:"activeVersions"`
	StateVector     map[uint32]float64 `json:"stateVector"` // version -> probability
	Entanglements   []Entanglement     `json:"entanglements"`
	MeasurementTime time.Time          `json:"measurementTime"`
}

QuantumState represents the superposition of network states

type SPHINCSAggregator

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

SPHINCSAggregator handles SPHINCS+ signature aggregation

type VM

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

VM implements the Y-Chain Quantum Checkpoint Ledger

func (*VM) AppGossip

func (vm *VM) AppGossip(ctx context.Context, nodeID ids.NodeID, msg []byte) error

AppGossip implements the common.VM interface

func (*VM) AppRequest

func (vm *VM) AppRequest(ctx context.Context, nodeID ids.NodeID, requestID uint32, deadline time.Time, request []byte) error

AppRequest implements the common.VM interface

func (*VM) AppRequestFailed

func (vm *VM) AppRequestFailed(ctx context.Context, nodeID ids.NodeID, requestID uint32, appErr *common.AppError) error

AppRequestFailed implements the common.VM interface

func (*VM) AppResponse

func (vm *VM) AppResponse(ctx context.Context, nodeID ids.NodeID, requestID uint32, response []byte) error

AppResponse implements the common.VM interface

func (*VM) BuildBlock

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

BuildBlock implements the chain.ChainVM interface

func (*VM) Connected

func (vm *VM) Connected(ctx context.Context, nodeID ids.NodeID, nodeVersion *version.Application) error

Connected implements the common.VM interface

func (*VM) CreateHandlers

func (vm *VM) CreateHandlers(ctx context.Context) (map[string]http.Handler, error)

CreateHandlers implements the common.VM interface

func (*VM) CreateStaticHandlers

func (vm *VM) CreateStaticHandlers(ctx context.Context) (map[string]http.Handler, error)

CreateStaticHandlers implements the common.VM interface

func (*VM) CrossChainAppRequest

func (vm *VM) CrossChainAppRequest(ctx context.Context, chainID ids.ID, requestID uint32, deadline time.Time, request []byte) error

CrossChainAppRequest implements the common.VM interface

func (*VM) CrossChainAppRequestFailed

func (vm *VM) CrossChainAppRequestFailed(ctx context.Context, chainID ids.ID, requestID uint32, appErr *common.AppError) error

CrossChainAppRequestFailed implements the common.VM interface

func (*VM) CrossChainAppResponse

func (vm *VM) CrossChainAppResponse(ctx context.Context, chainID ids.ID, requestID uint32, response []byte) error

CrossChainAppResponse implements the common.VM interface

func (*VM) Disconnected

func (vm *VM) Disconnected(ctx context.Context, nodeID ids.NodeID) error

Disconnected implements the common.VM interface

func (*VM) GetBlock

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

GetBlock implements the chain.ChainVM interface

func (*VM) GetBlockIDAtHeight

func (vm *VM) GetBlockIDAtHeight(ctx context.Context, height uint64) (ids.ID, error)

GetBlockIDAtHeight implements the snowman.HeightIndexedChainVM interface

func (*VM) HealthCheck

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

HealthCheck implements the common.VM interface

func (*VM) Initialize

func (vm *VM) Initialize(
	ctx context.Context,
	chainCtx *snow.Context,
	db database.Database,
	genesisBytes []byte,
	upgradeBytes []byte,
	configBytes []byte,
	toEngine chan<- common.Message,
	fxs []*common.Fx,
	appSender common.AppSender,
) error

Initialize implements the chain.ChainVM interface

func (*VM) LastAccepted

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

LastAccepted implements the chain.ChainVM interface

func (*VM) ParseBlock

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

ParseBlock implements the chain.ChainVM interface

func (*VM) SetPreference

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

SetPreference implements the chain.ChainVM interface

func (*VM) SetState

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

SetState implements the common.VM interface

func (*VM) Shutdown

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

Shutdown implements the common.VM interface

func (*VM) SubmitEpochRoot

func (vm *VM) SubmitEpochRoot(nodeID ids.NodeID, tx *EpochRootTx) error

SubmitEpochRoot allows validators to submit epoch roots

func (*VM) Version

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

Version implements the common.VM interface

type YConfig

type YConfig struct {
	// Epoch configuration
	EpochDuration time.Duration `json:"epochDuration"`

	// Chains to checkpoint
	TrackedChains []string `json:"trackedChains"`

	// Bitcoin anchoring (optional)
	BitcoinEnabled bool   `json:"bitcoinEnabled"`
	BitcoinRPC     string `json:"bitcoinRPC,omitempty"`

	// IPFS archival (optional)
	IPFSEnabled bool   `json:"ipfsEnabled"`
	IPFSGateway string `json:"ipfsGateway,omitempty"`

	// Slashing configuration
	EnableSlashing bool   `json:"enableSlashing"`
	SlashingAmount uint64 `json:"slashingAmount"`

	// Fork management
	EnableForkManagement bool     `json:"enableForkManagement"`
	SupportedVersions    []uint32 `json:"supportedVersions"`
	CurrentVersion       uint32   `json:"currentVersion"`
}

YConfig contains VM configuration

Jump to

Keyboard shortcuts

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