vnt

package
v0.6.4-alpha.2 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2019 License: GPL-3.0 Imports: 49 Imported by: 0

Documentation

Overview

Package vnt implements the VNT protocol.

Index

Constants

View Source
const (
	// Protocol messages belonging to vnt/62
	StatusMsg          = 0x00
	NewBlockHashesMsg  = 0x01
	TxMsg              = 0x02
	GetBlockHeadersMsg = 0x03
	BlockHeadersMsg    = 0x04
	GetBlockBodiesMsg  = 0x05
	BlockBodiesMsg     = 0x06
	NewBlockMsg        = 0x07

	// Protocol messages belonging to vnt/63
	GetNodeDataMsg   = 0x0d
	NodeDataMsg      = 0x0e
	GetReceiptsMsg   = 0x0f
	ReceiptsMsg      = 0x10
	BftPreprepareMsg = 0x11
	BftPrepareMsg    = 0x12
	BftCommitMsg     = 0x13
)

vnt protocol message codes

View Source
const (
	ErrMsgTooLarge = iota
	ErrDecode
	ErrInvalidMsgCode
	ErrProtocolVersionMismatch
	ErrNetworkIdMismatch
	ErrGenesisBlockMismatch
	ErrNoStatusMsg
	ErrExtraStatusMsg
	ErrSuspendedPeer
)
View Source
const ProtocolMaxMsgSize = 10 * 1024 * 1024 // Maximum cap on the size of a protocol message

Variables

View Source
var DefaultConfig = Config{
	SyncMode:      downloader.FullSync,
	NetworkId:     1,
	LightPeers:    100,
	DatabaseCache: 768,
	TrieCache:     256,
	TrieTimeout:   300 * time.Millisecond,
	GasPrice:      big.NewInt(18 * params.Gwei),

	TxPool: core.DefaultTxPoolConfig,
	GPO: gasprice.Config{
		Blocks:     20,
		Percentile: 60,
	},
}

DefaultConfig contains default settings for use on the VNT main net.

View Source
var ProtocolLengths = []uint64{20, 8}

ProtocolLengths are the number of implemented message corresponding to different protocol versions.

View Source
var ProtocolName = "vnt"

ProtocolName is the official short name of the protocol used during capability negotiation.

View Source
var ProtocolVersions = []uint{vnt63, vnt62}

ProtocolVersions are the upported versions of the vnt protocol (first is primary).

Functions

func CreateConsensusEngine

func CreateConsensusEngine(ctx *node.ServiceContext, chainConfig *params.ChainConfig, db vntdb.Database) consensus.Engine

CreateConsensusEngine creates the required type of consensus engine instance for an vnt service

func CreateDB

func CreateDB(ctx *node.ServiceContext, config *Config, name string) (vntdb.Database, error)

CreateDB creates the chain database.

func NewBloomIndexer

func NewBloomIndexer(db vntdb.Database, size uint64) *core.ChainIndexer

NewBloomIndexer returns a chain indexer that generates bloom bits data for the canonical chain for fast logs filtering.

Types

type BadBlockArgs

type BadBlockArgs struct {
	Hash  common.Hash            `json:"hash"`
	Block map[string]interface{} `json:"block"`
	RLP   string                 `json:"rlp"`
}

BadBlockArgs represents the entries in the list returned when bad blocks are queried.

type BloomIndexer

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

BloomIndexer implements a core.ChainIndexer, building up a rotated bloom bits index for the VNT header bloom filters, permitting blazing fast filtering.

func (*BloomIndexer) Commit

func (b *BloomIndexer) Commit() error

Commit implements core.ChainIndexerBackend, finalizing the bloom section and writing it out into the database.

func (*BloomIndexer) Process

func (b *BloomIndexer) Process(header *types.Header)

Process implements core.ChainIndexerBackend, adding a new header's bloom into the index.

func (*BloomIndexer) Reset

func (b *BloomIndexer) Reset(section uint64, lastSectionHead common.Hash) error

Reset implements core.ChainIndexerBackend, starting a new bloombits index section.

type Config

type Config struct {
	// The genesis block, which is inserted if the database is empty.
	// If nil, the VNT main net block is used.
	Genesis *core.Genesis `toml:",omitempty"`

	// Protocol options
	NetworkId uint64 // Network ID to use for selecting peers to connect to
	SyncMode  downloader.SyncMode
	NoPruning bool

	// Light client options
	LightServ  int `toml:",omitempty"` // Maximum percentage of time allowed for serving LES requests
	LightPeers int `toml:",omitempty"` // Maximum number of LES client peers

	// Database options
	SkipBcVersionCheck bool `toml:"-"`
	DatabaseHandles    int  `toml:"-"`
	DatabaseCache      int
	TrieCache          int
	TrieTimeout        time.Duration

	// Producing-related options
	Coinbase  common.Address `toml:",omitempty"`
	ExtraData []byte         `toml:",omitempty"`
	GasPrice  *big.Int

	// Transaction pool options
	TxPool core.TxPoolConfig

	// Gas Price Oracle options
	GPO gasprice.Config

	// Enables tracking of SHA3 preimages in the VM
	EnablePreimageRecording bool

	// Miscellaneous options
	DocRoot string `toml:"-"`
}

func (Config) MarshalTOML

func (c Config) MarshalTOML() (interface{}, error)

func (*Config) UnmarshalTOML

func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error

type LesServer

type LesServer interface {
	Start(srvr *vntp2p.Server)
	Stop()
	Protocols() []vntp2p.Protocol
	SetBloomBitsIndexer(bbIndexer *core.ChainIndexer)
}

type NodeInfo

type NodeInfo struct {
	Network    uint64              `json:"network"`    // VNT network ID (1=Frontier)
	Difficulty *big.Int            `json:"difficulty"` // Total difficulty of the host's blockchain
	Genesis    common.Hash         `json:"genesis"`    // SHA3 hash of the host's genesis block
	Config     *params.ChainConfig `json:"config"`     // Chain configuration for the fork rules
	Head       common.Hash         `json:"head"`       // SHA3 hash of the host's best owned block
}

NodeInfo represents a short summary of the VNT sub-protocol metadata known about the host peer.

type PeerInfo

type PeerInfo struct {
	Version    int      `json:"version"`    // VNT protocol version negotiated
	Difficulty *big.Int `json:"difficulty"` // Total difficulty of the peer's blockchain
	Head       string   `json:"head"`       // SHA3 hash of the peer's best owned block
}

PeerInfo represents a short summary of the VNT sub-protocol metadata known about a connected peer.

type PrivateAdminAPI

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

PrivateAdminAPI is the collection of VNT full node-related APIs exposed over the private admin endpoint.

func NewPrivateAdminAPI

func NewPrivateAdminAPI(vnt *VNT) *PrivateAdminAPI

NewPrivateAdminAPI creates a new API definition for the full node private admin methods of the VNT service.

func (*PrivateAdminAPI) ExportChain

func (api *PrivateAdminAPI) ExportChain(file string) (bool, error)

ExportChain exports the current blockchain into a local file.

func (*PrivateAdminAPI) ImportChain

func (api *PrivateAdminAPI) ImportChain(file string) (bool, error)

ImportChain imports a blockchain from a local file.

type PrivateDebugAPI

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

PrivateDebugAPI is the collection of VNT full node APIs exposed over the private debugging endpoint.

func NewPrivateDebugAPI

func NewPrivateDebugAPI(config *params.ChainConfig, vnt *VNT) *PrivateDebugAPI

NewPrivateDebugAPI creates a new API definition for the full node-related private debug methods of the VNT service.

func (*PrivateDebugAPI) GetBadBlocks

func (api *PrivateDebugAPI) GetBadBlocks(ctx context.Context) ([]*BadBlockArgs, error)

GetBadBLocks returns a list of the last 'bad blocks' that the client has seen on the network and returns them as a JSON list of block-hashes

func (*PrivateDebugAPI) GetModifiedAccountsByHash

func (api *PrivateDebugAPI) GetModifiedAccountsByHash(startHash common.Hash, endHash *common.Hash) ([]common.Address, error)

GetModifiedAccountsByHash returns all accounts that have changed between the two blocks specified. A change is defined as a difference in nonce, balance, code hash, or storage hash.

With one parameter, returns the list of accounts modified in the specified block.

func (*PrivateDebugAPI) GetModifiedAccountsByNumber

func (api *PrivateDebugAPI) GetModifiedAccountsByNumber(startNum uint64, endNum *uint64) ([]common.Address, error)

GetModifiedAccountsByumber returns all accounts that have changed between the two blocks specified. A change is defined as a difference in nonce, balance, code hash, or storage hash.

With one parameter, returns the list of accounts modified in the specified block.

func (*PrivateDebugAPI) Preimage

func (api *PrivateDebugAPI) Preimage(ctx context.Context, hash common.Hash) (hexutil.Bytes, error)

Preimage is a debug API function that returns the preimage for a sha3 hash, if known.

func (*PrivateDebugAPI) StorageRangeAt

func (api *PrivateDebugAPI) StorageRangeAt(ctx context.Context, blockHash common.Hash, txIndex int, contractAddress common.Address, keyStart hexutil.Bytes, maxResult int) (StorageRangeResult, error)

StorageRangeAt returns the storage at the given block height and transaction index.

func (*PrivateDebugAPI) TraceBlock

func (api *PrivateDebugAPI) TraceBlock(ctx context.Context, blob []byte, config *TraceConfig) ([]*txTraceResult, error)

TraceBlock returns the structured logs created during the execution of WAVM and returns them as a JSON object.

func (*PrivateDebugAPI) TraceBlockByHash

func (api *PrivateDebugAPI) TraceBlockByHash(ctx context.Context, hash common.Hash, config *TraceConfig) ([]*txTraceResult, error)

TraceBlockByHash returns the structured logs created during the execution of WAVM and returns them as a JSON object.

func (*PrivateDebugAPI) TraceBlockByNumber

func (api *PrivateDebugAPI) TraceBlockByNumber(ctx context.Context, number rpc.BlockNumber, config *TraceConfig) ([]*txTraceResult, error)

TraceBlockByNumber returns the structured logs created during the execution of WAVM and returns them as a JSON object.

func (*PrivateDebugAPI) TraceBlockFromFile

func (api *PrivateDebugAPI) TraceBlockFromFile(ctx context.Context, file string, config *TraceConfig) ([]*txTraceResult, error)

TraceBlockFromFile returns the structured logs created during the execution of WAVM and returns them as a JSON object.

func (*PrivateDebugAPI) TraceChain

func (api *PrivateDebugAPI) TraceChain(ctx context.Context, start, end rpc.BlockNumber, config *TraceConfig) (*rpc.Subscription, error)

TraceChain returns the structured logs created during the execution of WAVM between two blocks (excluding start) and returns them as a JSON object.

func (*PrivateDebugAPI) TraceTransaction

func (api *PrivateDebugAPI) TraceTransaction(ctx context.Context, hash common.Hash, config *TraceConfig) (interface{}, error)

TraceTransaction returns the structured logs created during the execution of WAVM and returns them as a JSON object.

type PrivateProducerAPI added in v0.6.2

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

PrivateProducerAPI provides private RPC methods to control the producer. These methods can be abused by external users and must be considered insecure for use by untrusted users.

func NewPrivateProducerAPI added in v0.6.2

func NewPrivateProducerAPI(e *VNT) *PrivateProducerAPI

NewPrivateProducerAPI create a new RPC service which controls the producer of this node.

func (*PrivateProducerAPI) SetCoinbase added in v0.6.2

func (api *PrivateProducerAPI) SetCoinbase(coinbase common.Address) bool

SetCoinbase sets the coinbase of the producer

func (*PrivateProducerAPI) SetExtra added in v0.6.2

func (api *PrivateProducerAPI) SetExtra(extra string) (bool, error)

SetExtra sets the extra data string that is included when this producer mines a block.

func (*PrivateProducerAPI) SetGasPrice added in v0.6.2

func (api *PrivateProducerAPI) SetGasPrice(gasPrice hexutil.Big) bool

SetGasPrice sets the minimum accepted gas price for the producer.

func (*PrivateProducerAPI) Start added in v0.6.2

func (api *PrivateProducerAPI) Start(threads *int) error

Start the producer with the given number of threads. If threads is nil the number of workers started is equal to the number of logical CPUs that are usable by this process. If block producing is already running, this method adjust the number of threads allowed to use.

func (*PrivateProducerAPI) Stop added in v0.6.2

func (api *PrivateProducerAPI) Stop() bool

Stop the producer

type ProtocolManager

type ProtocolManager struct {
	SubProtocols []vntp2p.Protocol
	// contains filtered or unexported fields
}

func NewProtocolManager

func NewProtocolManager(config *params.ChainConfig, mode downloader.SyncMode, networkId uint64, mux *event.TypeMux, txpool txPool, engine consensus.Engine, blockchain *core.BlockChain, chaindb vntdb.Database, node *node.Node) (*ProtocolManager, error)

NewProtocolManager returns a new VNT sub protocol manager. The VNT sub protocol manages peers capable with the VNT network.

func (*ProtocolManager) BroadcastBftMsg

func (pm *ProtocolManager) BroadcastBftMsg(bftMsg types.BftMsg)

func (*ProtocolManager) BroadcastBlock

func (pm *ProtocolManager) BroadcastBlock(block *types.Block, propagate bool)

BroadcastBlock will either propagate a block to a subset of it's peers, or will only announce it's availability (depending what's requested).

func (*ProtocolManager) BroadcastTxs

func (pm *ProtocolManager) BroadcastTxs(txs types.Transactions)

BroadcastTxs will propagate a batch of transactions to all peers which are not known to already have the given transaction.

func (*ProtocolManager) NodeInfo

func (pm *ProtocolManager) NodeInfo() *NodeInfo

NodeInfo retrieves some protocol metadata about the running host node.

func (*ProtocolManager) Start

func (pm *ProtocolManager) Start(maxPeers int)

func (*ProtocolManager) Stop

func (pm *ProtocolManager) Stop()

type PublicDebugAPI

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

PublicDebugAPI is the collection of VNT full node APIs exposed over the public debugging endpoint.

func NewPublicDebugAPI

func NewPublicDebugAPI(vnt *VNT) *PublicDebugAPI

NewPublicDebugAPI creates a new API definition for the full node- related public debug methods of the VNT service.

func (*PublicDebugAPI) DumpBlock

func (api *PublicDebugAPI) DumpBlock(blockNr rpc.BlockNumber) (state.Dump, error)

DumpBlock retrieves the entire state of the database at a given block.

type PublicProducerAPI added in v0.6.2

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

PublicProducerAPI provides an API to control the producer. It offers only methods that operate on data that pose no security risk when it is publicly accessible.

func NewPublicProducerAPI added in v0.6.2

func NewPublicProducerAPI(e *VNT) *PublicProducerAPI

NewPublicProducerAPI create a new PublicProducerAPI instance.

func (*PublicProducerAPI) Producing added in v0.6.2

func (api *PublicProducerAPI) Producing() bool

Producing returns an indication if this node is currently block producing.

type PublicVntAPI

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

PublicVntAPI provides an API to access VNT full node-related information.

func NewPublicVntAPI

func NewPublicVntAPI(e *VNT) *PublicVntAPI

NewPublicVntAPI creates a new VNT protocol API for full nodes.

func (*PublicVntAPI) Coinbase

func (api *PublicVntAPI) Coinbase() (common.Address, error)

Coinbase is the address that block producing rewards will be send to

type StorageRangeResult

type StorageRangeResult struct {
	Storage storageMap   `json:"storage"`
	NextKey *common.Hash `json:"nextKey"` // nil if Storage includes the last key in the trie.
}

StorageRangeResult is the result of a debug_storageRangeAt API call.

type TraceConfig

type TraceConfig struct {
	*vm.LogConfig
	Tracer  *string
	Timeout *string
	Reexec  *uint64
}

TraceConfig holds extra parameters to trace functions.

type VNT

type VNT struct {
	APIBackend *VntAPIBackend
	// contains filtered or unexported fields
}

VNT implements the VNT full node service.

func New

func New(ctx *node.ServiceContext, config *Config, node *node.Node) (*VNT, error)

New creates a new VNT object (including the initialisation of the common VNT object)

func (*VNT) APIs

func (s *VNT) APIs() []rpc.API

APIs return the collection of RPC services the hubble package offers. NOTE, some of these services probably need to be moved to somewhere else.

func (*VNT) AccountManager

func (s *VNT) AccountManager() *accounts.Manager

func (*VNT) AddLesServer

func (s *VNT) AddLesServer(ls LesServer)

func (*VNT) BlockChain

func (s *VNT) BlockChain() *core.BlockChain

func (*VNT) ChainDb

func (s *VNT) ChainDb() vntdb.Database

func (*VNT) Coinbase

func (s *VNT) Coinbase() (eb common.Address, err error)

func (*VNT) Downloader

func (s *VNT) Downloader() *downloader.Downloader

func (*VNT) Engine

func (s *VNT) Engine() consensus.Engine

func (*VNT) EventMux

func (s *VNT) EventMux() *event.TypeMux

func (*VNT) IsListening

func (s *VNT) IsListening() bool

func (*VNT) IsProducing

func (s *VNT) IsProducing() bool

func (*VNT) NetVersion

func (s *VNT) NetVersion() uint64

func (*VNT) Producer added in v0.6.2

func (s *VNT) Producer() *producer.Producer

func (*VNT) Protocols

func (s *VNT) Protocols() []vntp2p.Protocol

Protocols implements node.Service, returning all the currently configured network protocols to start.

func (*VNT) ResetWithGenesisBlock

func (s *VNT) ResetWithGenesisBlock(gb *types.Block)

func (*VNT) SetCoinbase

func (s *VNT) SetCoinbase(coinbase common.Address)

SetCoinbase sets the block producing reward address.

func (*VNT) Start

func (s *VNT) Start(srvr *vntp2p.Server) error

Start implements node.Service, starting all internal goroutines needed by the VNT protocol implementation.

func (*VNT) StartProducing

func (s *VNT) StartProducing(local bool) error

func (*VNT) Stop

func (s *VNT) Stop() error

Stop implements node.Service, terminating all internal goroutines used by the VNT protocol.

func (*VNT) StopProducing

func (s *VNT) StopProducing()

func (*VNT) TxPool

func (s *VNT) TxPool() *core.TxPool

func (*VNT) VntVersion added in v0.6.2

func (s *VNT) VntVersion() int

type VntAPIBackend

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

VntAPIBackend implements vntapi.Backend for full nodes

func (*VntAPIBackend) AccountManager

func (b *VntAPIBackend) AccountManager() *accounts.Manager

func (*VntAPIBackend) BlockByNumber

func (b *VntAPIBackend) BlockByNumber(ctx context.Context, blockNr rpc.BlockNumber) (*types.Block, error)

func (*VntAPIBackend) BloomStatus

func (b *VntAPIBackend) BloomStatus() (uint64, uint64)

func (*VntAPIBackend) ChainConfig

func (b *VntAPIBackend) ChainConfig() *params.ChainConfig

func (*VntAPIBackend) ChainDb

func (b *VntAPIBackend) ChainDb() vntdb.Database

func (*VntAPIBackend) CurrentBlock

func (b *VntAPIBackend) CurrentBlock() *types.Block

func (*VntAPIBackend) Downloader

func (b *VntAPIBackend) Downloader() *downloader.Downloader

func (*VntAPIBackend) EventMux

func (b *VntAPIBackend) EventMux() *event.TypeMux

func (*VntAPIBackend) GetBlock

func (b *VntAPIBackend) GetBlock(ctx context.Context, hash common.Hash) (*types.Block, error)

func (*VntAPIBackend) GetLogs

func (b *VntAPIBackend) GetLogs(ctx context.Context, hash common.Hash) ([][]*types.Log, error)

func (*VntAPIBackend) GetPoolNonce

func (b *VntAPIBackend) GetPoolNonce(ctx context.Context, addr common.Address) (uint64, error)

func (*VntAPIBackend) GetPoolTransaction

func (b *VntAPIBackend) GetPoolTransaction(hash common.Hash) *types.Transaction

func (*VntAPIBackend) GetPoolTransactions

func (b *VntAPIBackend) GetPoolTransactions() (types.Transactions, error)

func (*VntAPIBackend) GetReceipts

func (b *VntAPIBackend) GetReceipts(ctx context.Context, hash common.Hash) (types.Receipts, error)

func (*VntAPIBackend) GetTd

func (b *VntAPIBackend) GetTd(blockHash common.Hash) *big.Int

func (*VntAPIBackend) GetVM

func (b *VntAPIBackend) GetVM(ctx context.Context, msg core.Message, state *state.StateDB, header *types.Header, vmCfg vm.Config) (vm.VM, func() error, error)

func (*VntAPIBackend) HeaderByNumber

func (b *VntAPIBackend) HeaderByNumber(ctx context.Context, blockNr rpc.BlockNumber) (*types.Header, error)

func (*VntAPIBackend) ProtocolVersion

func (b *VntAPIBackend) ProtocolVersion() int

func (*VntAPIBackend) SendTx

func (b *VntAPIBackend) SendTx(ctx context.Context, signedTx *types.Transaction) error

func (*VntAPIBackend) ServiceFilter

func (b *VntAPIBackend) ServiceFilter(ctx context.Context, session *bloombits.MatcherSession)

func (*VntAPIBackend) SetHead

func (b *VntAPIBackend) SetHead(number uint64)

func (*VntAPIBackend) StateAndHeaderByNumber

func (b *VntAPIBackend) StateAndHeaderByNumber(ctx context.Context, blockNr rpc.BlockNumber) (*state.StateDB, *types.Header, error)

func (*VntAPIBackend) Stats

func (b *VntAPIBackend) Stats() (pending int, queued int)

func (*VntAPIBackend) SubscribeChainEvent

func (b *VntAPIBackend) SubscribeChainEvent(ch chan<- core.ChainEvent) event.Subscription

func (*VntAPIBackend) SubscribeChainHeadEvent

func (b *VntAPIBackend) SubscribeChainHeadEvent(ch chan<- core.ChainHeadEvent) event.Subscription

func (*VntAPIBackend) SubscribeChainSideEvent

func (b *VntAPIBackend) SubscribeChainSideEvent(ch chan<- core.ChainSideEvent) event.Subscription

func (*VntAPIBackend) SubscribeLogsEvent

func (b *VntAPIBackend) SubscribeLogsEvent(ch chan<- []*types.Log) event.Subscription

func (*VntAPIBackend) SubscribeNewTxsEvent

func (b *VntAPIBackend) SubscribeNewTxsEvent(ch chan<- core.NewTxsEvent) event.Subscription

func (*VntAPIBackend) SubscribeRemovedLogsEvent

func (b *VntAPIBackend) SubscribeRemovedLogsEvent(ch chan<- core.RemovedLogsEvent) event.Subscription

func (*VntAPIBackend) SuggestPrice

func (b *VntAPIBackend) SuggestPrice(ctx context.Context) (*big.Int, error)

func (*VntAPIBackend) TxPoolContent

Directories

Path Synopsis
Package downloader contains the manual full chain synchronisation.
Package downloader contains the manual full chain synchronisation.
Package fetcher contains the block announcement based synchronisation.
Package fetcher contains the block announcement based synchronisation.
Package filters implements the hubble filtering system for block, transactions and log events.
Package filters implements the hubble filtering system for block, transactions and log events.

Jump to

Keyboard shortcuts

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