platformvm

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2020 License: BSD-3-Clause Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// Delta is the synchrony bound used for safe decision making
	Delta = 10 * time.Second

	// BatchSize is the number of decision transaction to place into a block
	BatchSize = 30

	// NumberOfShares is the number of shares that a delegator is
	// rewarded
	NumberOfShares = 1000000

	// InflationRate is the maximum inflation rate of AVA from staking
	InflationRate = 1.04

	// MinimumStakeAmount is the minimum amount of $AVA one must bond to be a staker
	MinimumStakeAmount = 10 * units.MicroAva

	// MinimumStakingDuration is the shortest amount of time a staker can bond
	// their funds for.
	MinimumStakingDuration = 24 * time.Hour

	// MaximumStakingDuration is the longest amount of time a staker can bond
	// their funds for.
	MaximumStakingDuration = 365 * 24 * time.Hour
)

Variables

View Source
var Codec codec.Codec

Codec does serialization and deserialization

View Source
var (

	// DefaultSubnetID is the ID of the default subnet
	DefaultSubnetID = ids.Empty
)
View Source
var (
	ID = ids.NewID([32]byte{'p', 'l', 'a', 't', 'f', 'o', 'r', 'm', 'v', 'm'})
)

ID of the platform VM

Functions

This section is empty.

Types

type APIAccount

type APIAccount struct {
	Address ids.ShortID `json:"address"`
	Nonce   json.Uint64 `json:"nonce"`
	Balance json.Uint64 `json:"balance"`
}

APIAccount is an account on the Platform Chain that exists at the chain's genesis.

type APIBlockchain

type APIBlockchain struct {
	// Blockchain's ID
	ID ids.ID `json:"id"`

	// Blockchain's (non-unique) human-readable name
	Name string `json:"name"`

	// Subnet that validates the blockchain
	SubnetID ids.ID `json:"subnetID"`

	// Virtual Machine the blockchain runs
	VMID ids.ID `json:"vmID"`
}

APIBlockchain is the representation of a blockchain used in API calls

type APIChain

type APIChain struct {
	GenesisData formatting.CB58 `json:"genesisData"`
	VMID        ids.ID          `json:"vmID"`
	FxIDs       []ids.ID        `json:"fxIDs"`
	Name        string          `json:"name"`
	SubnetID    ids.ID          `json:"subnetID"`
}

APIChain defines a chain that exists at the network's genesis. [GenesisData] is the initial state of the chain. [VMID] is the ID of the VM this chain runs. [FxIDs] are the IDs of the Fxs the chain supports. [Name] is a human-readable, non-unique name for the chain. [SubnetID] is the ID of the subnet that validates the chain

type APIDefaultSubnetValidator

type APIDefaultSubnetValidator struct {
	APIValidator

	Destination       ids.ShortID `json:"destination"`
	DelegationFeeRate json.Uint32 `json:"delegationFeeRate"`
}

APIDefaultSubnetValidator is a validator of the default subnet

type APISubnet

type APISubnet struct {
	// ID of the subnet
	ID ids.ID `json:"id"`

	// Each element of [ControlKeys] the address of a public key.
	// A transaction to add a validator to this subnet requires
	// signatures from [Threshold] of these keys to be valid.
	ControlKeys []ids.ShortID `json:"controlKeys"`
	Threshold   json.Uint16   `json:"threshold"`
}

APISubnet is a representation of a subnet used in API calls

type APIValidator

type APIValidator struct {
	StartTime   json.Uint64  `json:"startTime"`
	EndTime     json.Uint64  `json:"endtime"`
	Weight      *json.Uint64 `json:"weight,omitempty"`
	StakeAmount *json.Uint64 `json:"stakeAmount,omitempty"`
	ID          ids.ShortID  `json:"id"`
}

APIValidator is a validator. [Amount] is the amount of $AVA being staked. [Endtime] is the Unix time repr. of when they are done staking ID is the node ID of the staker [Destination] is the address where the staked $AVA (and, if applicable, reward) is sent when this staker is done staking.

type Abort

type Abort struct {
	CommonDecisionBlock `serialize:"true"`
}

Abort being accepted results in the proposal of its parent (which must be a proposal block) being rejected.

func (*Abort) Verify

func (a *Abort) Verify() error

Verify this block performs a valid state transition.

The parent block must be a proposal

This function also sets onAcceptDB database if the verification passes.

type Account

type Account struct {
	// Address of this account
	// Its value is [privKey].PublicKey().Address() where privKey
	// is the private key that controls this account
	Address ids.ShortID `serialize:"true"`

	// Nonce this account was last spent with
	// Initially, this is set to 0. Therefore, the first nonce a transaction should
	// use for a new account is 1.
	Nonce uint64 `serialize:"true"`

	// Balance of $AVA held by this account
	Balance uint64 `serialize:"true"`
}

Account represents the Balance and nonce of a user's funds

func (Account) Add

func (a Account) Add(amount uint64) (Account, error)

Add returns the state of [a] after receiving the $AVA

func (Account) Bytes

func (a Account) Bytes() []byte

Bytes returns the byte representation of this account

func (Account) Remove

func (a Account) Remove(amount, nonce uint64) (Account, error)

Remove generates a new account state from removing [amount + txFee] from [a]'s balance. [nonce] is [a]'s next unused nonce

func (Account) Verify

func (a Account) Verify() error

Verify that this account is in a valid state

type AddDefaultSubnetDelegatorArgs

type AddDefaultSubnetDelegatorArgs struct {
	APIValidator

	Destination ids.ShortID `json:"destination"`

	// Next unused nonce of the account the staked $AVA and tx fee are paid from
	PayerNonce json.Uint64 `json:"payerNonce"`
}

AddDefaultSubnetDelegatorArgs are the arguments to AddDefaultSubnetDelegator

type AddDefaultSubnetValidatorArgs

type AddDefaultSubnetValidatorArgs struct {
	APIDefaultSubnetValidator

	// Next unused nonce of the account the staked $AVA and tx fee are paid from
	PayerNonce json.Uint64 `json:"payerNonce"`
}

AddDefaultSubnetValidatorArgs are the arguments to AddDefaultSubnetValidator

type AddNonDefaultSubnetValidatorArgs

type AddNonDefaultSubnetValidatorArgs struct {
	APIValidator

	// ID of subnet to validate
	SubnetID ids.ID `json:"subnetID"`

	// Next unused nonce of the account the tx fee is paid from
	PayerNonce json.Uint64 `json:"payerNonce"`
}

AddNonDefaultSubnetValidatorArgs are the arguments to AddNonDefaultSubnetValidator

type AtomicBlock

type AtomicBlock struct {
	CommonDecisionBlock `serialize:"true"`

	Tx AtomicTx `serialize:"true"`
	// contains filtered or unexported fields
}

AtomicBlock being accepted results in the transaction contained in the block to be accepted and committed to the chain.

func (*AtomicBlock) Accept

func (ab *AtomicBlock) Accept()

Accept implements the snowman.Block interface

func (*AtomicBlock) Verify

func (ab *AtomicBlock) Verify() error

Verify this block performs a valid state transition.

The parent block must be a proposal

This function also sets onAcceptDB database if the verification passes.

type AtomicTx

type AtomicTx interface {
	ID() ids.ID

	// UTXOs this tx consumes
	InputUTXOs() ids.Set

	// Attempt to verify this transaction with the provided state. The provided
	// database can be modified arbitrarily.
	SemanticVerify(database.Database) error

	Accept(database.Batch) error
	// contains filtered or unexported methods
}

AtomicTx is an operation that can be decided without being proposed, but must have special control over database commitment

type Block

type Block interface {
	snowman.Block
	// contains filtered or unexported methods
}

Block is the common interface that all staking blocks must have

type BuildGenesisArgs

type BuildGenesisArgs struct {
	NetworkID  json.Uint32                 `json:"address"`
	Accounts   []APIAccount                `json:"accounts"`
	Validators []APIDefaultSubnetValidator `json:"defaultSubnetValidators"`
	Chains     []APIChain                  `json:"chains"`
	Time       json.Uint64                 `json:"time"`
}

BuildGenesisArgs are the arguments used to create the genesis data of the Platform Chain. [NetworkID] is the ID of the network [Accounts] are the accounts on the Platform Chain that exists at genesis. [Validators] are the validators of the default subnet at genesis. [Chains] are the chains that exist at genesis. [Time] is the Platform Chain's time at network genesis.

type BuildGenesisReply

type BuildGenesisReply struct {
	Bytes formatting.CB58 `json:"bytes"`
}

BuildGenesisReply is the reply from BuildGenesis

type Commit

type Commit struct {
	CommonDecisionBlock `serialize:"true"`
}

Commit being accepted results in the proposal of its parent (which must be a proposal block) being enacted.

func (*Commit) Verify

func (c *Commit) Verify() error

Verify this block performs a valid state transition.

The parent block must either be a proposal

This function also sets the onCommit databases if the verification passes.

type CommonBlock

type CommonBlock struct {
	*core.Block `serialize:"true"`
	// contains filtered or unexported fields
}

CommonBlock contains the fields common to all blocks of the Platform Chain

func (*CommonBlock) Parent

func (cb *CommonBlock) Parent() snowman.Block

Parent returns this block's parent

func (*CommonBlock) Reject

func (cb *CommonBlock) Reject()

Reject implements the snowman.Block interface

type CommonDecisionBlock

type CommonDecisionBlock struct {
	CommonBlock `serialize:"true"`
	// contains filtered or unexported fields
}

CommonDecisionBlock contains the fields and methods common to all decision blocks (ie *Commit and *Abort)

func (*CommonDecisionBlock) Accept

func (cdb *CommonDecisionBlock) Accept()

Accept implements the snowman.Block interface

type CreateAccountArgs

type CreateAccountArgs struct {
	// User that will control the newly created account
	Username string `json:"username"`

	// That user's password
	Password string `json:"password"`

	// The private key that controls the new account.
	// If omitted, will generate a new private key belonging
	// to the user.
	PrivateKey string `json:"privateKey"`
}

CreateAccountArgs are the arguments for calling CreateAccount

type CreateAccountReply

type CreateAccountReply struct {
	// Address of the newly created account
	Address ids.ShortID `json:"address"`
}

CreateAccountReply are the response from calling CreateAccount

type CreateBlockchainArgs

type CreateBlockchainArgs struct {
	// ID of Subnet that validates the new blockchain
	SubnetID ids.ID `json:"subnetID"`

	// ID of the VM the new blockchain is running
	VMID string `json:"vmID"`

	// IDs of the FXs the VM is running
	FxIDs []string `json:"fxIDs"`

	// Human-readable name for the new blockchain, not necessarily unique
	Name string `json:"name"`

	// Next unused nonce of the account paying the transaction fee
	PayerNonce json.Uint64 `json:"payerNonce"`

	// Genesis state of the blockchain being created
	GenesisData formatting.CB58 `json:"genesisData"`
}

CreateBlockchainArgs is the arguments for calling CreateBlockchain

type CreateChainTx

type CreateChainTx struct {
	UnsignedCreateChainTx `serialize:"true"`

	// Address of the account that provides the transaction fee
	// Set in SemanticVerify
	PayerAddress ids.ShortID

	// Signatures from Subnet's control keys
	// Should not empty slice, not nil, if there are no control sigs
	ControlSigs [][crypto.SECP256K1RSigLen]byte `serialize:"true"`

	// Signature of key whose account provides the transaction fee
	PayerSig [crypto.SECP256K1RSigLen]byte `serialize:"true"`
	// contains filtered or unexported fields
}

CreateChainTx is a proposal to create a chain

func (*CreateChainTx) Bytes

func (tx *CreateChainTx) Bytes() []byte

Bytes returns the byte representation of a CreateChainTx

func (*CreateChainTx) ID

func (tx *CreateChainTx) ID() ids.ID

ID of this transaction

func (*CreateChainTx) SemanticVerify

func (tx *CreateChainTx) SemanticVerify(db database.Database) (func(), error)

SemanticVerify this transaction is valid.

func (*CreateChainTx) SyntacticVerify

func (tx *CreateChainTx) SyntacticVerify() error

SyntacticVerify this transaction is well-formed Also populates [tx.Key] with the public key that signed this transaction

type CreateSubnetArgs

type CreateSubnetArgs struct {
	// The ID member of APISubnet is ignored
	APISubnet

	// Nonce of the account that pays the transaction fee
	PayerNonce json.Uint64 `json:"payerNonce"`
}

CreateSubnetArgs are the arguments to CreateSubnet

type CreateSubnetTx

type CreateSubnetTx struct {
	UnsignedCreateSubnetTx `serialize:"true"`

	// Signature on the UnsignedCreateSubnetTx's byte repr
	Sig [crypto.SECP256K1RSigLen]byte `serialize:"true"`
	// contains filtered or unexported fields
}

CreateSubnetTx is a proposal to create a new subnet

func (*CreateSubnetTx) Bytes

func (tx *CreateSubnetTx) Bytes() []byte

Bytes returns the byte representation of [tx]

func (*CreateSubnetTx) ID

func (tx *CreateSubnetTx) ID() ids.ID

ID returns the ID of this transaction

func (*CreateSubnetTx) SemanticVerify

func (tx *CreateSubnetTx) SemanticVerify(db database.Database) (func(), error)

SemanticVerify returns nil if [tx] is valid given the state in [db]

func (*CreateSubnetTx) SyntacticVerify

func (tx *CreateSubnetTx) SyntacticVerify() error

SyntacticVerify nil iff [tx] is syntactically valid. If [tx] is valid, this method sets [tx.key]

type CreateSubnetTxList

type CreateSubnetTxList []*CreateSubnetTx

CreateSubnetTxList is a list of *CreateSubnetTx

func (CreateSubnetTxList) Bytes

func (lst CreateSubnetTxList) Bytes() []byte

Bytes returns the binary representation of [lst]

type CreateTxResponse

type CreateTxResponse struct {
	UnsignedTx formatting.CB58 `json:"unsignedTx"`
}

CreateTxResponse is the response from calls to create a transaction

type DecisionTx

type DecisionTx interface {
	ID() ids.ID

	// Attempt to verify this transaction with the provided state. The provided
	// database can be modified arbitrarily. If a nil error is returned, it is
	// assumped onAccept is non-nil.
	SemanticVerify(database.Database) (onAccept func(), err error)
	// contains filtered or unexported methods
}

DecisionTx is an operation that can be decided without being proposed

type DurationValidator

type DurationValidator struct {
	Validator `serialize:"true"`

	// Unix time this staker starts validating
	Start uint64 `serialize:"true"`

	// Unix time this staker stops validating
	End uint64 `serialize:"true"`
}

DurationValidator ...

func (*DurationValidator) BoundedBy

func (v *DurationValidator) BoundedBy(startTime, endTime time.Time) bool

BoundedBy returns true iff the period that [validator] validates is a (non-strict) subset of the time that [other] validates. Namely, startTime <= v.StartTime() <= v.EndTime() <= endTime

func (*DurationValidator) Duration

func (v *DurationValidator) Duration() time.Duration

Duration is the amount of time that this staker will be in the validator set

func (*DurationValidator) EndTime

func (v *DurationValidator) EndTime() time.Time

EndTime is the time that this staker will leave the validator set

func (*DurationValidator) StartTime

func (v *DurationValidator) StartTime() time.Time

StartTime is the time that this staker will enter the validator set

type EventHeap

type EventHeap struct {
	SortByStartTime bool      `serialize:"true"`
	Txs             []TimedTx `serialize:"true"`
}

EventHeap is a collection of timedTxs where elements are ordered by either their startTime or their endTime. If SortByStartTime == true, the first element of [Txs] is the tx in the heap with the earliest startTime. Otherwise the first element is the tx with earliest endTime. The default value of this struct will order transactions by endTime. This struct implements the heap interface.

func (*EventHeap) Add

func (h *EventHeap) Add(tx TimedTx)

Add ...

func (*EventHeap) Bytes

func (h *EventHeap) Bytes() []byte

Bytes returns the byte representation of this heap

func (*EventHeap) Len

func (h *EventHeap) Len() int

func (*EventHeap) Less

func (h *EventHeap) Less(i, j int) bool

func (*EventHeap) Peek

func (h *EventHeap) Peek() TimedTx

Peek ...

func (*EventHeap) Pop

func (h *EventHeap) Pop() interface{}

Pop implements the heap interface

func (*EventHeap) Push

func (h *EventHeap) Push(x interface{})

Push implements the heap interface

func (*EventHeap) Remove

func (h *EventHeap) Remove() TimedTx

Remove ...

func (*EventHeap) Swap

func (h *EventHeap) Swap(i, j int)

func (*EventHeap) Timestamp

func (h *EventHeap) Timestamp() time.Time

Timestamp returns the timestamp on the top transaction on the heap

type ExportAVAArgs

type ExportAVAArgs struct {
	// X-Chain address (without prepended X-) that will receive the exported AVA
	To ids.ShortID `json:"to"`

	// Nonce of the account that pays the transaction fee and provides the export AVA
	PayerNonce json.Uint64 `json:"payerNonce"`

	// Amount of nAVA to send
	Amount json.Uint64 `json:"amount"`
}

ExportAVAArgs are the arguments to ExportAVA

type ExportTx

type ExportTx struct {
	UnsignedExportTx `serialize:"true"`

	Sig [crypto.SECP256K1RSigLen]byte `serialize:"true"`
	// contains filtered or unexported fields
}

ExportTx exports funds to the AVM

func (*ExportTx) Accept

func (tx *ExportTx) Accept(batch database.Batch) error

Accept this transaction.

func (*ExportTx) Bytes

func (tx *ExportTx) Bytes() []byte

Bytes returns the byte representation of an ExportTx

func (*ExportTx) ID

func (tx *ExportTx) ID() ids.ID

ID of this transaction

func (*ExportTx) InputUTXOs

func (tx *ExportTx) InputUTXOs() ids.Set

InputUTXOs returns an empty set

func (*ExportTx) Key

func (tx *ExportTx) Key() crypto.PublicKey

Key returns the public key of the signer of this transaction Precondition: tx.Verify() has been called and returned nil

func (*ExportTx) SemanticVerify

func (tx *ExportTx) SemanticVerify(db database.Database) error

SemanticVerify this transaction is valid.

func (*ExportTx) SyntacticVerify

func (tx *ExportTx) SyntacticVerify() error

SyntacticVerify this transaction is well-formed Also populates [tx.Key] with the public key that signed this transaction

type Factory

type Factory struct {
	ChainManager   chains.Manager
	Validators     validators.Manager
	StakingEnabled bool
	AVA            ids.ID
	AVM            ids.ID
}

Factory can create new instances of the Platform Chain

func (*Factory) New

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

New returns a new instance of the Platform Chain

type Genesis

type Genesis struct {
	Accounts   []Account        `serialize:"true"`
	Validators *EventHeap       `serialize:"true"`
	Chains     []*CreateChainTx `serialize:"true"`
	Timestamp  uint64           `serialize:"true"`
}

Genesis represents a genesis state of the platform chain

func (*Genesis) Initialize

func (g *Genesis) Initialize() error

Initialize ...

type GetAccountArgs

type GetAccountArgs struct {
	// Address of the account we want the information about
	Address ids.ShortID `json:"address"`
}

GetAccountArgs are the arguments for calling GetAccount

type GetAccountReply

type GetAccountReply struct {
	Address ids.ShortID `json:"address"`
	Nonce   json.Uint64 `json:"nonce"`
	Balance json.Uint64 `json:"balance"`
}

GetAccountReply is the response from calling GetAccount

type GetBlockchainStatusArgs

type GetBlockchainStatusArgs struct {
	BlockchainID string `json:"blockchainID"`
}

GetBlockchainStatusArgs is the arguments for calling GetBlockchainStatus [BlockchainID] is the blockchain to get the status of.

type GetBlockchainStatusReply

type GetBlockchainStatusReply struct {
	Status Status `json:"status"`
}

GetBlockchainStatusReply is the reply from calling GetBlockchainStatus Status is the blockchain's status.

type GetBlockchainsResponse

type GetBlockchainsResponse struct {
	// blockchains that exist
	Blockchains []APIBlockchain `json:"blockchains"`
}

GetBlockchainsResponse is the response from a call to GetBlockchains

type GetCurrentValidatorsArgs

type GetCurrentValidatorsArgs struct {
	// Subnet we're listing the validators of
	// If omitted, defaults to default subnet
	SubnetID ids.ID `json:"subnetID"`
}

GetCurrentValidatorsArgs are the arguments for calling GetCurrentValidators

type GetCurrentValidatorsReply

type GetCurrentValidatorsReply struct {
	Validators []APIValidator `json:"validators"`
}

GetCurrentValidatorsReply are the results from calling GetCurrentValidators

type GetPendingValidatorsArgs

type GetPendingValidatorsArgs struct {
	// Subnet we're getting the pending validators of
	// If omitted, defaults to default subnet
	SubnetID ids.ID `json:"subnetID"`
}

GetPendingValidatorsArgs are the arguments for calling GetPendingValidators

type GetPendingValidatorsReply

type GetPendingValidatorsReply struct {
	Validators []APIValidator `json:"validators"`
}

GetPendingValidatorsReply are the results from calling GetPendingValidators

type GetSubnetsArgs

type GetSubnetsArgs struct {
	// IDs of the subnets to retrieve information about
	// If omitted, gets all subnets
	IDs []ids.ID `json:"ids"`
}

GetSubnetsArgs are the arguments to GetSubnet

type GetSubnetsResponse

type GetSubnetsResponse struct {
	// Each element is a subnet that exists
	// Null if there are no subnets other than the default subnet
	Subnets []APISubnet `json:"subnets"`
}

GetSubnetsResponse is the response from calling GetSubnets

type ImportAVAArgs

type ImportAVAArgs struct {
	// ID of the account that will receive the imported funds, and pay the transaction fee
	To ids.ShortID `json:"to"`

	// Next unused nonce of the account
	PayerNonce json.Uint64 `json:"payerNonce"`

	// User that controls the account
	Username string `json:"username"`
	Password string `json:"password"`
}

ImportAVAArgs are the arguments to ImportAVA

type ImportTx

type ImportTx struct {
	UnsignedImportTx `serialize:"true"`

	Sig   [crypto.SECP256K1RSigLen]byte `serialize:"true"`
	Creds []verify.Verifiable           `serialize:"true"` // The credentials of this transaction
	// contains filtered or unexported fields
}

ImportTx imports funds from the AVM

func (*ImportTx) Accept

func (tx *ImportTx) Accept(batch database.Batch) error

Accept this transaction.

func (*ImportTx) Bytes

func (tx *ImportTx) Bytes() []byte

Bytes returns the byte representation of an ImportTx

func (*ImportTx) ID

func (tx *ImportTx) ID() ids.ID

ID of this transaction

func (*ImportTx) InputUTXOs

func (tx *ImportTx) InputUTXOs() ids.Set

InputUTXOs returns an empty set

func (*ImportTx) Key

func (tx *ImportTx) Key() crypto.PublicKey

Key returns the public key of the signer of this transaction Precondition: tx.Verify() has been called and returned nil

func (*ImportTx) SemanticVerify

func (tx *ImportTx) SemanticVerify(db database.Database) error

SemanticVerify this transaction is valid.

func (*ImportTx) SyntacticVerify

func (tx *ImportTx) SyntacticVerify() error

SyntacticVerify this transaction is well-formed Also populates [tx.Key] with the public key that signed this transaction

func (*ImportTx) UnsignedBytes

func (tx *ImportTx) UnsignedBytes() []byte

UnsignedBytes returns the unsigned byte representation of an ImportTx

type IssueTxArgs

type IssueTxArgs struct {
	// Tx being sent to the network
	Tx formatting.CB58 `json:"tx"`
}

IssueTxArgs are the arguments to IssueTx

type IssueTxResponse

type IssueTxResponse struct {
	// ID of transaction being sent to network
	TxID ids.ID `json:"txID"`
}

IssueTxResponse is the response from IssueTx

type ListAccountsArgs

type ListAccountsArgs struct {
	// List all of the accounts controlled by this user
	Username string `json:"username"`
	Password string `json:"password"`
}

ListAccountsArgs are the arguments to ListAccounts

type ListAccountsReply

type ListAccountsReply struct {
	Accounts []APIAccount `json:"accounts"`
}

ListAccountsReply is the reply from ListAccounts

type ProposalBlock

type ProposalBlock struct {
	CommonBlock `serialize:"true"`

	Tx ProposalTx `serialize:"true"`
	// contains filtered or unexported fields
}

ProposalBlock is a proposal to change the chain's state. A proposal may be to:

  1. Advance the chain's timestamp (*AdvanceTimeTx)
  2. Remove a staker from the staker set (*RewardStakerTx)
  3. Add a new staker to the set of pending (future) stakers (*AddStakerTx)

The proposal will be enacted (change the chain's state) if the proposal block is accepted and followed by an accepted Commit block

func (*ProposalBlock) Options

func (pb *ProposalBlock) Options() [2]snowman.Block

Options returns the possible children of this block in preferential order.

func (*ProposalBlock) Verify

func (pb *ProposalBlock) Verify() error

Verify this block is valid.

The parent block must either be a Commit or an Abort block.

If this block is valid, this function also sets pas.onCommit and pas.onAbort.

type ProposalTx

type ProposalTx interface {

	// Attempts to verify this transaction with the provided state.
	SemanticVerify(database.Database) (onCommitDB *versiondb.Database, onAbortDB *versiondb.Database, onCommitFunc func(), onAbortFunc func(), err error)
	InitiallyPrefersCommit() bool
	// contains filtered or unexported methods
}

ProposalTx is an operation that can be proposed

type SampleValidatorsArgs

type SampleValidatorsArgs struct {
	// Number of validators in the sample
	Size json.Uint16 `json:"size"`

	// ID of subnet to sample validators from
	// If omitted, defaults to the default subnet
	SubnetID ids.ID `json:"subnetID"`
}

SampleValidatorsArgs are the arguments for calling SampleValidators

type SampleValidatorsReply

type SampleValidatorsReply struct {
	Validators []ids.ShortID `json:"validators"`
}

SampleValidatorsReply are the results from calling Sample

type Service

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

Service defines the API calls that can be made to the platform chain

func (*Service) AddDefaultSubnetDelegator

func (service *Service) AddDefaultSubnetDelegator(_ *http.Request, args *AddDefaultSubnetDelegatorArgs, reply *CreateTxResponse) error

AddDefaultSubnetDelegator returns an unsigned transaction to add a delegator to the default subnet The returned unsigned transaction should be signed using Sign()

func (*Service) AddDefaultSubnetValidator

func (service *Service) AddDefaultSubnetValidator(_ *http.Request, args *AddDefaultSubnetValidatorArgs, reply *CreateTxResponse) error

AddDefaultSubnetValidator returns an unsigned transaction to add a validator to the default subnet The returned unsigned transaction should be signed using Sign()

func (*Service) AddNonDefaultSubnetValidator

func (service *Service) AddNonDefaultSubnetValidator(_ *http.Request, args *AddNonDefaultSubnetValidatorArgs, response *CreateTxResponse) error

AddNonDefaultSubnetValidator adds a validator to a subnet other than the default subnet Returns the unsigned transaction, which must be signed using Sign

func (*Service) CreateAccount

func (service *Service) CreateAccount(_ *http.Request, args *CreateAccountArgs, reply *CreateAccountReply) error

CreateAccount creates a new account on the Platform Chain The account is controlled by [args.Username] The account's ID is [privKey].PublicKey().Address(), where [privKey] is a private key controlled by the user.

func (*Service) CreateBlockchain

func (service *Service) CreateBlockchain(_ *http.Request, args *CreateBlockchainArgs, response *CreateTxResponse) error

CreateBlockchain returns an unsigned transaction to create a new blockchain Must be signed with the Subnet's control keys and with a key that pays the transaction fee before issuance

func (*Service) CreateSubnet

func (service *Service) CreateSubnet(_ *http.Request, args *CreateSubnetArgs, response *CreateTxResponse) error

CreateSubnet returns an unsigned transaction to create a new subnet. The unsigned transaction must be signed with the key of [args.Payer]

func (*Service) ExportAVA

func (service *Service) ExportAVA(_ *http.Request, args *ExportAVAArgs, response *CreateTxResponse) error

ExportAVA returns an unsigned transaction to export AVA from the P-Chain to the X-Chain. After this tx is accepted, the AVA must be imported on the X-Chain side. The unsigned transaction must be signed with the key of the account exporting the AVA and paying the transaction fee

func (*Service) GetAccount

func (service *Service) GetAccount(_ *http.Request, args *GetAccountArgs, reply *GetAccountReply) error

GetAccount details given account ID

func (*Service) GetBlockchainStatus

func (service *Service) GetBlockchainStatus(_ *http.Request, args *GetBlockchainStatusArgs, reply *GetBlockchainStatusReply) error

GetBlockchainStatus gets the status of a blockchain with the ID [args.BlockchainID].

func (*Service) GetBlockchains

func (service *Service) GetBlockchains(_ *http.Request, args *struct{}, response *GetBlockchainsResponse) error

GetBlockchains returns all of the blockchains that exist

func (*Service) GetCurrentValidators

func (service *Service) GetCurrentValidators(_ *http.Request, args *GetCurrentValidatorsArgs, reply *GetCurrentValidatorsReply) error

GetCurrentValidators returns the list of current validators

func (*Service) GetPendingValidators

func (service *Service) GetPendingValidators(_ *http.Request, args *GetPendingValidatorsArgs, reply *GetPendingValidatorsReply) error

GetPendingValidators returns the list of current validators

func (*Service) GetSubnets

func (service *Service) GetSubnets(_ *http.Request, args *GetSubnetsArgs, response *GetSubnetsResponse) error

GetSubnets returns the subnets whose ID are in [args.IDs] The response will not contain the default subnet

func (*Service) ImportAVA

func (service *Service) ImportAVA(_ *http.Request, args *ImportAVAArgs, response *SignResponse) error

ImportAVA returns an unsigned transaction to import AVA from the X-Chain. The AVA must have already been exported from the X-Chain. The unsigned transaction must be signed with the key of the tx fee payer.

func (*Service) IssueTx

func (service *Service) IssueTx(_ *http.Request, args *IssueTxArgs, response *IssueTxResponse) error

IssueTx issues the transaction [args.Tx] to the network

func (*Service) ListAccounts

func (service *Service) ListAccounts(_ *http.Request, args *ListAccountsArgs, reply *ListAccountsReply) error

ListAccounts lists all of the accounts controlled by [args.Username]

func (*Service) SampleValidators

func (service *Service) SampleValidators(_ *http.Request, args *SampleValidatorsArgs, reply *SampleValidatorsReply) error

SampleValidators returns a sampling of the list of current validators

func (*Service) Sign

func (service *Service) Sign(_ *http.Request, args *SignArgs, reply *SignResponse) error

Sign [args.bytes]

func (*Service) ValidatedBy

func (service *Service) ValidatedBy(_ *http.Request, args *ValidatedByArgs, response *ValidatedByResponse) error

ValidatedBy returns the ID of the Subnet that validates [args.BlockchainID]

func (*Service) Validates

func (service *Service) Validates(_ *http.Request, args *ValidatesArgs, response *ValidatesResponse) error

Validates returns the IDs of the blockchains validated by [args.SubnetID]

type SignArgs

type SignArgs struct {
	// The bytes to sign
	// Must be the output of AddDefaultSubnetValidator
	Tx formatting.CB58 `json:"tx"`

	// The address of the key signing the bytes
	Signer ids.ShortID `json:"signer"`

	// User that controls Signer
	Username string `json:"username"`
	Password string `json:"password"`
}

SignArgs are the arguments to Sign

type SignResponse

type SignResponse struct {
	// The signed bytes
	Tx formatting.CB58 `json:"tx"`
}

SignResponse is the response from Sign

type StandardBlock

type StandardBlock struct {
	CommonDecisionBlock `serialize:"true"`

	Txs []DecisionTx `serialize:"true"`
}

StandardBlock being accepted results in the transactions contained in the block to be accepted and committed to the chain.

func (*StandardBlock) Verify

func (sb *StandardBlock) Verify() error

Verify this block performs a valid state transition.

The parent block must be a proposal

This function also sets onAcceptDB database if the verification passes.

type StaticService

type StaticService struct{}

StaticService defines the static API methods exposed by the platform VM

func (*StaticService) BuildGenesis

func (*StaticService) BuildGenesis(_ *http.Request, args *BuildGenesisArgs, reply *BuildGenesisReply) error

BuildGenesis build the genesis state of the Platform Chain (and thereby the AVA network.)

type Status

type Status uint32

Status ...

const (
	Unknown Status = iota
	Preferred
	Created
	Validating
)

List of possible status values Unknown Zero value, means the status is not known Preferred means the operation is known and preferred, but hasn't been decided yet Created means the operation occurred, but isn't managed locally Validating means the operation was accepted and is managed locally

func (Status) MarshalJSON

func (s Status) MarshalJSON() ([]byte, error)

MarshalJSON ...

func (Status) String

func (s Status) String() string

func (*Status) UnmarshalJSON

func (s *Status) UnmarshalJSON(b []byte) error

UnmarshalJSON ...

func (Status) Valid

func (s Status) Valid() error

Valid returns nil if the status is a valid status.

type Subnet

type Subnet interface {
	// ID returns this subnet's ID
	ID() ids.ID

	// Validators returns the validators that compose this subnet
	Validators() []validators.Validator
}

A Subnet is a set of validators that are validating a set of blockchains Each blockchain is validated by one subnet; one subnet may validate many blockchains

type SubnetValidator

type SubnetValidator struct {
	DurationValidator `serialize:"true"`

	// ID of the subnet this validator is validating
	Subnet ids.ID `serialize:"true"`
}

SubnetValidator validates a blockchain on the AVA network.

func (*SubnetValidator) SubnetID

func (v *SubnetValidator) SubnetID() ids.ID

SubnetID is the ID of the subnet this validator is validating

type TimedTx

type TimedTx interface {
	ProposalTx

	Vdr() validators.Validator

	ID() ids.ID
	StartTime() time.Time
	EndTime() time.Time
}

TimedTx ...

type UnsignedAddDefaultSubnetDelegatorTx

type UnsignedAddDefaultSubnetDelegatorTx struct {
	DurationValidator `serialize:"true"`
	NetworkID         uint32      `serialize:"true"`
	Nonce             uint64      `serialize:"true"`
	Destination       ids.ShortID `serialize:"true"`
}

UnsignedAddDefaultSubnetDelegatorTx is an unsigned addDefaultSubnetDelegatorTx

type UnsignedAddDefaultSubnetValidatorTx

type UnsignedAddDefaultSubnetValidatorTx struct {
	DurationValidator `serialize:"true"`
	NetworkID         uint32      `serialize:"true"`
	Nonce             uint64      `serialize:"true"`
	Destination       ids.ShortID `serialize:"true"`
	Shares            uint32      `serialize:"true"`
}

UnsignedAddDefaultSubnetValidatorTx is an unsigned addDefaultSubnetValidatorTx

type UnsignedAddNonDefaultSubnetValidatorTx

type UnsignedAddNonDefaultSubnetValidatorTx struct {
	// The validator
	SubnetValidator `serialize:"true"`

	// ID of the network
	NetworkID uint32 `serialize:"true"`

	// Next unused nonce of the account paying the tx fee
	Nonce uint64 `serialize:"true"`
}

UnsignedAddNonDefaultSubnetValidatorTx is an unsigned addNonDefaultSubnetValidatorTx

type UnsignedCreateChainTx

type UnsignedCreateChainTx struct {
	// ID of the network this blockchain exists on
	NetworkID uint32 `serialize:"true"`

	// ID of the Subnet that validates this blockchain
	SubnetID ids.ID `serialize:"true"`

	// Next unused nonce of account paying the transaction fee for this transaction.
	// Currently unused, as there are no tx fees.
	Nonce uint64 `serialize:"true"`

	// A human readable name for the chain; need not be unique
	ChainName string `serialize:"true"`

	// ID of the VM running on the new chain
	VMID ids.ID `serialize:"true"`

	// IDs of the feature extensions running on the new chain
	FxIDs []ids.ID `serialize:"true"`

	// Byte representation of genesis state of the new chain
	GenesisData []byte `serialize:"true"`
}

UnsignedCreateChainTx is an unsigned CreateChainTx

type UnsignedCreateSubnetTx

type UnsignedCreateSubnetTx struct {
	// NetworkID is the ID of the network this tx was issued on
	NetworkID uint32 `serialize:"true"`

	// Next unused nonce of account paying the transaction fee for this transaction.
	// Currently unused, as there are no tx fees.
	Nonce uint64 `serialize:"true"`

	// Each element in ControlKeys is the address of a public key
	// In order to add a validator to this subnet, a tx must be signed
	// with Threshold of these keys
	ControlKeys []ids.ShortID `serialize:"true"`
	Threshold   uint16        `serialize:"true"`
}

UnsignedCreateSubnetTx is an unsigned proposal to create a new subnet

type UnsignedExportTx

type UnsignedExportTx struct {
	// ID of the network this blockchain exists on
	NetworkID uint32 `serialize:"true"`

	// Next unused nonce of account paying for this transaction.
	Nonce uint64 `serialize:"true"`

	Outs []*ava.TransferableOutput `serialize:"true"` // The outputs of this transaction
}

UnsignedExportTx is an unsigned ExportTx

type UnsignedImportTx

type UnsignedImportTx struct {
	// ID of the network this blockchain exists on
	NetworkID uint32 `serialize:"true"`

	// Next unused nonce of account paying the transaction fee and receiving the
	// inputs of this transaction.
	Nonce uint64 `serialize:"true"`

	// Account that this transaction is being sent by. This is needed to ensure the Credentials are replay safe.
	Account ids.ShortID `serialize:"true"`

	Ins []*ava.TransferableInput `serialize:"true"` // The inputs to this transaction
}

UnsignedImportTx is an unsigned ImportTx

type VM

type VM struct {
	*core.SnowmanVM
	// contains filtered or unexported fields
}

VM implements the snowman.ChainVM interface

func (*VM) BuildBlock

func (vm *VM) BuildBlock() (snowman.Block, error)

BuildBlock builds a block to be added to consensus

func (*VM) Clock

func (vm *VM) Clock() *timer.Clock

Clock ...

func (*VM) Codec

func (vm *VM) Codec() codec.Codec

Codec ...

func (*VM) CreateHandlers

func (vm *VM) CreateHandlers() map[string]*common.HTTPHandler

CreateHandlers returns a map where: * keys are API endpoint extensions * values are API handlers See API documentation for more information

func (*VM) CreateStaticHandlers

func (vm *VM) CreateStaticHandlers() map[string]*common.HTTPHandler

CreateStaticHandlers implements the snowman.ChainVM interface

func (*VM) GetAtomicUTXOs

func (vm *VM) GetAtomicUTXOs(addrs ids.Set) ([]*ava.UTXO, error)

GetAtomicUTXOs returns the utxos that at least one of the provided addresses is referenced in.

func (*VM) GetBlock

func (vm *VM) GetBlock(blkID ids.ID) (snowman.Block, error)

GetBlock implements the snowman.ChainVM interface

func (*VM) Initialize

func (vm *VM) Initialize(
	ctx *snow.Context,
	db database.Database,
	genesisBytes []byte,
	msgs chan<- common.Message,
	fxs []*common.Fx,
) error

Initialize this blockchain. [vm.ChainManager] and [vm.Validators] must be set before this function is called.

func (*VM) Logger

func (vm *VM) Logger() logging.Logger

Logger ...

func (*VM) ParseBlock

func (vm *VM) ParseBlock(bytes []byte) (snowman.Block, error)

ParseBlock implements the snowman.ChainVM interface

func (*VM) SetPreference

func (vm *VM) SetPreference(blkID ids.ID)

SetPreference sets the preferred block to be the one with ID [blkID]

func (*VM) Shutdown

func (vm *VM) Shutdown()

Shutdown this blockchain

type ValidatedByArgs

type ValidatedByArgs struct {
	// ValidatedBy returns the ID of the Subnet validating the blockchain with this ID
	BlockchainID ids.ID `json:"blockchainID"`
}

ValidatedByArgs is the arguments for calling ValidatedBy

type ValidatedByResponse

type ValidatedByResponse struct {
	// ID of the Subnet validating the specified blockchain
	SubnetID ids.ID `json:"subnetID"`
}

ValidatedByResponse is the reply from calling ValidatedBy

type ValidatesArgs

type ValidatesArgs struct {
	SubnetID ids.ID `json:"subnetID"`
}

ValidatesArgs are the arguments to Validates

type ValidatesResponse

type ValidatesResponse struct {
	BlockchainIDs []ids.ID `json:"blockchainIDs"`
}

ValidatesResponse is the response from calling Validates

type Validator

type Validator struct {
	// Node ID of the staker
	NodeID ids.ShortID `serialize:"true"`

	// Weight of this validator used when sampling
	Wght uint64 `serialize:"true"`
}

Validator ...

func (*Validator) ID

func (v *Validator) ID() ids.ShortID

ID returns the node ID of the staker

func (*Validator) Vdr

func (v *Validator) Vdr() validators.Validator

Vdr returns this validator

func (*Validator) Weight

func (v *Validator) Weight() uint64

Weight is this validator's weight when sampling

Jump to

Keyboard shortcuts

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