aoa

package
v0.0.0-...-d85cb20 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: GPL-3.0 Imports: 59 Imported by: 3

Documentation

Overview

Package em implements the eminer-pro protocol.

Package em implements the eminer-pro protocol.

Index

Constants

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

	NewBlockMsg        = 0x07
	SignaturesBlockMsg = 0x08
	// broadcast to delegate p2p network
	PreBlockMsg = 0x09
	// Protocol messages belonging to em/63
	GetNodeDataMsg = 0x0d
	NodeDataMsg    = 0x0e
	GetReceiptsMsg = 0x0f
	ReceiptsMsg    = 0x10
)

em 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:    20,
	DatabaseCache: 128,
	GasPrice:      big.NewInt(4 * params.Shannon),

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

DefaultConfig contains default settings for use on the eminer-pro main net.

View Source
var ProtocolLengths = []uint64{17, 17}

Number of implemented message corresponding to different protocol versions.

View Source
var ProtocolName = "aoa"

Official short name of the protocol used during capability negotiation.

View Source
var ProtocolVersions = []uint{aoa01, aoa02}

Supported versions of the em protocol (first is primary).

Functions

func CreateDB

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

CreateDB creates the chain database.

func CreateDacchainConsensusEngine

func CreateDacchainConsensusEngine() consensus.Engine

func NewBloomIndexer

func NewBloomIndexer(db aoadb.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 BloomIndexer

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

BloomIndexer implements a core.ChainIndexer, building up a rotated bloom bits index for the eminer-pro 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 eminer-pro 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

	// 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

	// Mining-related options
	Dacchainbase common.Address `toml:",omitempty"`
	MinerThreads int            `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:"-"`

	// Enables Watching internal transactions in a contract call.
	EnableInterTxWatching bool
}

func (Config) MarshalTOML

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

MarshalTOML marshals as TOML.

func (*Config) UnmarshalTOML

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

UnmarshalTOML unmarshals from TOML.

type DacApiBackend

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

implements emapi.Backend for full nodes

func (*DacApiBackend) AccountManager

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

func (*DacApiBackend) BlockByNumber

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

func (*DacApiBackend) BloomStatus

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

func (*DacApiBackend) ChainConfig

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

func (*DacApiBackend) ChainDb

func (b *DacApiBackend) ChainDb() aoadb.Database

func (*DacApiBackend) CurrentBlock

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

func (*DacApiBackend) Downloader

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

func (*DacApiBackend) GetBlock

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

func (*DacApiBackend) GetDelegatePoll

func (b *DacApiBackend) GetDelegatePoll(block *types.Block) (*map[common.Address]types.Candidate, error)

func (*DacApiBackend) GetDelegateWalletInfoCallback

func (b *DacApiBackend) GetDelegateWalletInfoCallback() func(data *aa.DelegateWalletInfo)

func (*DacApiBackend) GetEVM

func (b *DacApiBackend) GetEVM(ctx context.Context, msg core.Message, state *state.StateDB, header *types.Header, vmCfg vm.Config) (*vm.EVM, func() error, error)

func (*DacApiBackend) GetInnerTxDb

func (b *DacApiBackend) GetInnerTxDb() watch.InnerTxDb

func (*DacApiBackend) GetPoolNonce

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

func (*DacApiBackend) GetPoolTransaction

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

func (*DacApiBackend) GetPoolTransactions

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

func (*DacApiBackend) GetReceipts

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

func (*DacApiBackend) GetTd

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

func (*DacApiBackend) HeaderByNumber

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

func (*DacApiBackend) IsWatchInnerTxEnable

func (b *DacApiBackend) IsWatchInnerTxEnable() bool

func (*DacApiBackend) ProtocolVersion

func (b *DacApiBackend) ProtocolVersion() int

func (*DacApiBackend) SendTx

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

func (*DacApiBackend) ServiceFilter

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

func (*DacApiBackend) SetHead

func (b *DacApiBackend) SetHead(number uint64)

func (*DacApiBackend) StateAndHeaderByNumber

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

func (*DacApiBackend) Stats

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

func (*DacApiBackend) SubscribeChainEvent

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

func (*DacApiBackend) SubscribeChainHeadEvent

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

func (*DacApiBackend) SubscribeChainSideEvent

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

func (*DacApiBackend) SubscribeLogsEvent

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

func (*DacApiBackend) SubscribeRemovedLogsEvent

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

func (*DacApiBackend) SubscribeTxPreEvent

func (b *DacApiBackend) SubscribeTxPreEvent(ch chan<- core.TxPreEvent) event.Subscription

func (*DacApiBackend) SuggestPrice

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

func (*DacApiBackend) TxPoolContent

type Dacchain

type Dacchain struct {
	ApiBackend *DacApiBackend
	// contains filtered or unexported fields
}

eminer-pro implements the eminer-pro full node service.

func New

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

New creates a new eminer-pro object (including the initialisation of the common eminer-pro object)

func (*Dacchain) APIs

func (dacchain *Dacchain) APIs() []rpc.API

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

func (*Dacchain) AccountManager

func (dacchain *Dacchain) AccountManager() *accounts.Manager

func (*Dacchain) AddLesServer

func (dacchain *Dacchain) AddLesServer(ls LesServer)

func (*Dacchain) BlockChain

func (dacchain *Dacchain) BlockChain() *core.BlockChain

func (*Dacchain) ChainDb

func (dacchain *Dacchain) ChainDb() aoadb.Database

func (*Dacchain) Downloader

func (dacchain *Dacchain) Downloader() *downloader.Downloader

func (*Dacchain) Engine

func (dacchain *Dacchain) Engine() consensus.Engine

func (*Dacchain) EthVersion

func (dacchain *Dacchain) EthVersion() int

func (*Dacchain) IsListening

func (dacchain *Dacchain) IsListening() bool

func (*Dacchain) NetVersion

func (dacchain *Dacchain) NetVersion() uint64

func (*Dacchain) Protocols

func (dacchain *Dacchain) Protocols() []p2p.Protocol

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

func (*Dacchain) ResetWithGenesisBlock

func (dacchain *Dacchain) ResetWithGenesisBlock(gb *types.Block)

func (*Dacchain) Start

func (dacchain *Dacchain) Start(srvr *p2p.Server) error

Start implements node.Service, starting all internal goroutines needed by the eminer-pro protocol implementation.

func (*Dacchain) Stop

func (dacchain *Dacchain) Stop() error

Stop implements node.Service, terminating all internal goroutines used by the eminer-pro protocol.

func (*Dacchain) TxPool

func (dacchain *Dacchain) TxPool() *core.TxPool

func (*Dacchain) WatcherDb

func (dacchain *Dacchain) WatcherDb() aoadb.Database

type DposTaskManager

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

func NewDposTaskManager

func NewDposTaskManager(ctx *node.ServiceContext, blockchain *core.BlockChain, accountManager *accounts.Manager, produceBlockCallback func(ctx context.Context), shuffleHashChan chan *types.ShuffleData) *DposTaskManager

func (*DposTaskManager) GetCurrentDelegateByAddress

func (taskManager *DposTaskManager) GetCurrentDelegateByAddress(coinbase string) *types.ShuffleDel

get coinbase shuffle info by address, only use by delegate node

func (*DposTaskManager) GetCurrentShuffleRound

func (taskManager *DposTaskManager) GetCurrentShuffleRound() *types.ShuffleList

func (*DposTaskManager) GetLocalCurrentRound

func (taskManager *DposTaskManager) GetLocalCurrentRound() []string

get all top delegatePeers in current node

func (*DposTaskManager) ShuffleWhenVerifyFail

func (taskManager *DposTaskManager) ShuffleWhenVerifyFail(receiveBlockNumber int64, receiveBlockTime int64, shuffleBlockNumber *big.Int) error

shuffle to create new shuffleList when verify fail,only try one times.

type LesServer

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

type NodeInfo

type NodeInfo struct {
	Network uint64              `json:"network"` // eminer-pro network ID (1=Frontier)
	Genesis common.Hash         `json:"genesis"` // SHA3 hash of the host's genesis block
	Config  *params.ChainConfig `json:"config"`
	Head    common.Hash         `json:"head"` // SHA3 hash of the host's best owned block
}

type PeerInfo

type PeerInfo struct {
	Version int `json:"version"` // eminer-pro protocol version negotiated

	Head string `json:"head"` // SHA3 hash of the peer's best owned block
	// contains filtered or unexported fields
}

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

type PrivateAdminAPI

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

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

func NewPrivateAdminAPI

func NewPrivateAdminAPI(dac *Dacchain) *PrivateAdminAPI

NewPrivateAdminAPI creates a new API definition for the full node private admin methods of the eminer-pro 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 eminer-pro full node APIs exposed over the private debugging endpoint.

func NewPrivateDebugAPI

func NewPrivateDebugAPI(config *params.ChainConfig, dac *Dacchain) *PrivateDebugAPI

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

func (*PrivateDebugAPI) GetBadBlocks

func (api *PrivateDebugAPI) GetBadBlocks(ctx context.Context) ([]core.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) GetTranTypeNum

func (api *PrivateDebugAPI) GetTranTypeNum() interface{}

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 EVM 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 EVM 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 EVM 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 EVM 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 EVM 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 EVM and returns them as a JSON object.

type ProtocolManager

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

func NewProtocolManager

func NewProtocolManager(config *params.ChainConfig, mode downloader.SyncMode, networkId uint64, txpool txPool, engine consensus.Engine, blockchain *core.BlockChain, chaindb aoadb.Database, taskManager *DposTaskManager, blockChan chan *types.Block, addDelegateWalletCallback func(data *aa.DelegateWalletInfo), delegateWallets map[string]*ecdsa.PrivateKey) (*ProtocolManager, error)

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

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) BroadcastBlockSignatures

func (pm *ProtocolManager) BroadcastBlockSignatures(blockHash []byte, signs []types.VoteSign)

func (*ProtocolManager) BroadcastCommitBlock

func (pm *ProtocolManager) BroadcastCommitBlock(block types.CommitBlock)

Broadcast commit block

func (*ProtocolManager) BroadcastTx

func (pm *ProtocolManager) BroadcastTx(hash common.Hash, tx *types.Transaction)

BroadcastTx will propagate a transaction to all peers which are not known to already have the given transaction.

func (*ProtocolManager) GetAddDelegateWalletCallback

func (pm *ProtocolManager) GetAddDelegateWalletCallback() func(data *aa.DelegateWalletInfo)

func (*ProtocolManager) NodeInfo

func (pm *ProtocolManager) NodeInfo() *NodeInfo

NodeInfo retrieves some protocol metadata about the running host node.

func (*ProtocolManager) PreBroadcastBlock

func (pm *ProtocolManager) PreBroadcastBlock(block *types.Block)

broadcast to agent p2p network

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 eminer-pro full node APIs exposed over the public debugging endpoint.

func NewPublicDebugAPI

func NewPublicDebugAPI(dac *Dacchain) *PublicDebugAPI

NewPublicDebugAPI creates a new API definition for the full node- related public debug methods of the eminer-pro 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 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.

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 an dacchain filtering system for block, transactions and log events.
Package filters implements an dacchain filtering system for block, transactions and log events.
Package tracers is a collection of JavaScript transaction tracers.
Package tracers is a collection of JavaScript transaction tracers.
internal/tracers
Package tracers contains the actual JavaScript tracer assets.
Package tracers contains the actual JavaScript tracer assets.

Jump to

Keyboard shortcuts

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