Documentation ¶
Overview ¶
Package eth implements the Hpb protocol.
Package node sets up multi-protocol Hpb nodes.
In the model exposed by this package, a node is a collection of services which use shared resources to provide RPC APIs. Services can also offer devp2p protocols, which are wired up to the devp2p network when the node instance is started.
Resources Managed By Node ¶
All file-system resources used by a node instance are located in a directory called the data directory. The location of each resource can be overridden through additional node configuration. The data directory is optional. If it is not set and the location of a resource is otherwise unspecified, package node will create the resource in memory.
To access to the devp2p network, Node configures and starts p2p.Server. Each host on the devp2p network has a unique identifier, the node key. The Node instance persists this key across restarts. Node also loads static and trusted node lists and ensures that knowledge about other hosts is persisted.
JSON-RPC servers which run HTTP, WebSocket or IPC can be started on a Node. RPC modules offered by registered services will be offered on those endpoints. Users can restrict any endpoint to a subset of RPC modules. Node itself offers the "debug", "admin" and "web3" modules.
Service implementations can open LevelDB databases through the service context. Package node chooses the file system location of each database. If the node is configured to run without a data directory, databases are opened in memory instead.
Node also creates the shared store of encrypted Hpb account keys. Services can access the account manager through the service context.
Sharing Data Directory Among Instances ¶
Multiple node instances can share a single data directory if they have distinct instance names (set through the Name config option). Sharing behaviour depends on the type of resource.
devp2p-related resources (node key, static/trusted node lists, known hosts database) are stored in a directory with the same name as the instance. Thus, multiple node instances using the same data directory will store this information in different subdirectories of the data directory.
LevelDB databases are also stored within the instance subdirectory. If multiple node instances use the same data directory, openening the databases with identical names will create one database for each instance.
The account key store is shared among all node instances using the same data directory unless its location is changed through the KeyStoreDir configuration option.
Data Directory Sharing Example ¶
In this example, two node instances named A and B are started with the same data directory. Mode instance A opens the database "db", node instance B opens the databases "db" and "db-2". The following files will be created in the data directory:
data-directory/ A/ nodekey -- devp2p node key of instance A nodes/ -- devp2p discovery knowledge database of instance A db/ -- LevelDB content for "db" A.ipc -- JSON-RPC UNIX domain socket endpoint of instance A B/ nodekey -- devp2p node key of node B nodes/ -- devp2p discovery knowledge database of instance B static-nodes.json -- devp2p static node list of instance B db/ -- LevelDB content for "db" db-2/ -- LevelDB content for "db-2" B.ipc -- JSON-RPC UNIX domain socket endpoint of instance A keystore/ -- account key store, used by both instances
Index ¶
- Variables
- func NewBloomIndexer(db hpbdb.Database, size uint64) *bc.ChainIndexer
- func StartGraphqlHTTPEndpoint(endpoint string, backend *HpbApiBackend, cors []string, vhosts []string, ...) (net.Listener, http.Handler, error)
- type AccountDiff
- type BadBlockArgs
- type BloomIndexer
- type ConsensuscfgF
- type DuplicateServiceError
- type HpbApiBackend
- func (b *HpbApiBackend) AccountManager() *accounts.Manager
- func (b *HpbApiBackend) BlockByHash(ctx context.Context, hash common.Hash) (*types.Block, error)
- func (b *HpbApiBackend) BlockByNumber(ctx context.Context, blockNr rpc.BlockNumber) (*types.Block, error)
- func (b *HpbApiBackend) BlockByNumberOrHash(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (*types.Block, error)
- func (b *HpbApiBackend) BloomStatus() (uint64, uint64)
- func (b *HpbApiBackend) ChainConfig() *config.ChainConfig
- func (b *HpbApiBackend) ChainDb() hpbdb.Database
- func (b *HpbApiBackend) CurrentBlock() *types.Block
- func (b *HpbApiBackend) CurrentHeader() *types.Header
- func (b *HpbApiBackend) Downloader() *synctrl.Syncer
- func (b *HpbApiBackend) EventMux() *sub.TypeMux
- func (b *HpbApiBackend) GetBlock(ctx context.Context, blockHash common.Hash) (*types.Block, error)
- func (b *HpbApiBackend) GetEVM(ctx context.Context, msg types.Message, state *state.StateDB, ...) (vmcore.EVM, func() error, error)
- func (b *HpbApiBackend) GetPoolNonce(ctx context.Context, addr common.Address) (uint64, error)
- func (b *HpbApiBackend) GetPoolTransaction(hash common.Hash) *types.Transaction
- func (b *HpbApiBackend) GetPoolTransactions() (types.Transactions, error)
- func (b *HpbApiBackend) GetReceipts(ctx context.Context, blockHash common.Hash) (types.Receipts, error)
- func (b *HpbApiBackend) GetTd(blockHash common.Hash) *big.Int
- func (b *HpbApiBackend) GetTransaction(ctx context.Context, hash common.Hash) (*types.Transaction, common.Hash, uint64, uint64)
- func (b *HpbApiBackend) HeaderByHash(ctx context.Context, hash common.Hash) (*types.Header, error)
- func (b *HpbApiBackend) HeaderByNumber(ctx context.Context, blockNr rpc.BlockNumber) (*types.Header, error)
- func (b *HpbApiBackend) HeaderByNumberOrHash(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (*types.Header, error)
- func (b *HpbApiBackend) ProtocolVersion() int
- func (b *HpbApiBackend) RPCGasCap() uint64
- func (b *HpbApiBackend) SendTx(ctx context.Context, signedTx *types.Transaction) error
- func (b *HpbApiBackend) ServiceFilter(ctx context.Context, session *bloombits.MatcherSession)
- func (b *HpbApiBackend) SetHead(number uint64)
- func (b *HpbApiBackend) StateAndHeaderByNumber(ctx context.Context, blockNr rpc.BlockNumber) (*state.StateDB, *types.Header, error)
- func (b *HpbApiBackend) StateAndHeaderByNumberOrHash(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (*state.StateDB, *types.Header, error)
- func (b *HpbApiBackend) Stats() (pending int, queued int)
- func (b *HpbApiBackend) SubscribeChainEvent(ch chan<- bc.ChainEvent) sub.Subscription
- func (b *HpbApiBackend) SubscribeChainHeadEvent(ch chan<- bc.ChainHeadEvent) sub.Subscription
- func (b *HpbApiBackend) SubscribeChainSideEvent(ch chan<- bc.ChainSideEvent) sub.Subscription
- func (b *HpbApiBackend) SubscribeLogsEvent(ch chan<- []*types.Log) sub.Subscription
- func (b *HpbApiBackend) SubscribeRemovedLogsEvent(ch chan<- bc.RemovedLogsEvent) sub.Subscription
- func (b *HpbApiBackend) SubscribeTxPreEvent(ch chan<- bc.TxPreEvent) sub.Subscription
- func (b *HpbApiBackend) SuggestPrice(ctx context.Context) (*big.Int, error)
- func (b *HpbApiBackend) TxPoolContent() (map[common.Address]types.Transactions, map[common.Address]types.Transactions)
- func (b *HpbApiBackend) TxPoolContentFrom(addr common.Address) (types.Transactions, types.Transactions)
- type LesServer
- type Node
- func (s *Node) APIAccountManager() *accounts.Manager
- func (s *Node) APIs() []rpc.API
- func (n *Node) AccountManager() *accounts.Manager
- func (n *Node) Attach(ipc *rpc.Server) (*rpc.Client, error)
- func (s *Node) BlockChain() *bc.BlockChain
- func (s *Node) ChainDb() hpbdb.Database
- func (n *Node) DataDir() string
- func (s *Node) Engine() consensus.Engine
- func (s *Node) EthVersion() int
- func (n *Node) GetAPI() error
- func (s *Node) Hpberbase() (eb common.Address, err error)
- func (n *Node) InstanceDir() string
- func (s *Node) IsListening() bool
- func (s *Node) IsMining() bool
- func (s *Node) Miner() *worker.Miner
- func (s *Node) NetVersion() uint64
- func (n *Node) NewBlockMux() *sub.TypeMux
- func (n *Node) Nodeapis() []rpc.API
- func (n *Node) RPCHandler() (*rpc.Server, error)
- func (s *Node) ResetWithGenesisBlock(gb *types.Block)
- func (n *Node) ResolvePath(x string) string
- func (n *Node) Restart() error
- func (self *Node) SetHpberbase(hpberbase common.Address)
- func (n *Node) SetNodeAPI() error
- func (hpbnode *Node) Start(conf *config.HpbConfig) error
- func (s *Node) StartMining(local bool) error
- func (n *Node) Stop() error
- func (s *Node) StopMining()
- func (s *Node) TxPool() *txpool.TxPool
- func (n *Node) Wait()
- func (hpbnode *Node) WorkerInit(conf *config.HpbConfig) error
- type PrivateAdminAPI
- type PrivateDebugAPI
- func (api *PrivateDebugAPI) GetBadBlocks(ctx context.Context) ([]BadBlockArgs, error)
- func (api *PrivateDebugAPI) Preimage(ctx context.Context, hash common.Hash) (hexutil.Bytes, error)
- func (api *PrivateDebugAPI) StandardTraceBadBlockToFile(ctx context.Context, hash common.Hash, config *StdTraceConfig) ([]string, error)
- func (api *PrivateDebugAPI) StandardTraceBlockToFile(ctx context.Context, hash common.Hash, config *StdTraceConfig) ([]string, error)
- func (api *PrivateDebugAPI) TraceBadBlock(ctx context.Context, hash common.Hash, config *TraceConfig) ([]*txTraceResult, error)
- func (api *PrivateDebugAPI) TraceBlock(ctx context.Context, blob hexutil.Bytes, config *TraceConfig) ([]*txTraceResult, error)
- func (api *PrivateDebugAPI) TraceBlockByHash(ctx context.Context, hash common.Hash, config *TraceConfig) ([]*txTraceResult, error)
- func (api *PrivateDebugAPI) TraceBlockByNumber(ctx context.Context, number rpc.BlockNumber, config *TraceConfig) ([]*txTraceResult, error)
- func (api *PrivateDebugAPI) TraceBlockFromFile(ctx context.Context, file string, config *TraceConfig) ([]*txTraceResult, error)
- func (api *PrivateDebugAPI) TraceCall(ctx context.Context, args hpbapi.CallArgs, blockNrOrHash rpc.BlockNumberOrHash, ...) (interface{}, error)
- func (api *PrivateDebugAPI) TraceChain(ctx context.Context, start, end rpc.BlockNumber, config *TraceConfig) (*rpc.Subscription, error)
- func (api *PrivateDebugAPI) TraceTransaction(ctx context.Context, hash common.Hash, config *TraceConfig) (interface{}, error)
- type PrivateMinerAPI
- type PublicAdminAPI
- type PublicDebugAPI
- type PublicHpbAPI
- func (api *PublicHpbAPI) Coinbase() (common.Address, error)
- func (api *PublicHpbAPI) GetRandom(blocknum *rpc.BlockNumber) string
- func (api *PublicHpbAPI) GetRandomAndBlock(blocknum *rpc.BlockNumber) (result RandomAndBlock)
- func (api *PublicHpbAPI) GetStatediffbyblock(data string) string
- func (api *PublicHpbAPI) GetStatediffbyblockandTx(data string, hash string) string
- func (api *PublicHpbAPI) Hpberbase() (common.Address, error)
- func (api *PublicHpbAPI) Mining() bool
- type PublicWeb3API
- type RandomAndBlock
- type StateDiff
- type StdTraceConfig
- type StopError
- type StorageRangeResult
- type TraceConfig
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func NewBloomIndexer ¶
func NewBloomIndexer(db hpbdb.Database, size uint64) *bc.ChainIndexer
NewBloomIndexer returns a chain indexer that generates bloom bits data for the canonical chain for fast logs filtering.
func StartGraphqlHTTPEndpoint ¶
func StartGraphqlHTTPEndpoint(endpoint string, backend *HpbApiBackend, cors []string, vhosts []string, timeouts config.HTTPTimeouts) (net.Listener, http.Handler, error)
StartGraphqlHTTPEndpoint starts the HTTP RPC endpoint, configured with cors/vhosts/modules
Types ¶
type AccountDiff ¶
type AccountDiff struct {
// contains filtered or unexported fields
}
func (AccountDiff) MarshalJSON ¶
func (accountdiff AccountDiff) MarshalJSON() ([]byte, error)
type BadBlockArgs ¶
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 Ethereum 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 ¶
Process implements core.ChainIndexerBackend, adding a new header's bloom into the index.
func (*BloomIndexer) Prune ¶
func (b *BloomIndexer) Prune(threshold uint64) error
Prune returns an empty error since we don't support pruning here.
type ConsensuscfgF ¶
type ConsensuscfgF struct { HpNodesNum int //`json:"HpNodesNum"` //hp nodes number HpVotingRndScope int //`json:"HpVotingRndScope"` //hp voting rand selection scope FinalizeRetErrIg bool //`json:"FinalizeRetErrIg"` //finalize return err ignore Time int //`json:"Time"` //gen block interval Nodeids []string //`json:"Nodeids"` //bootnode`s nodeid only add one }
type DuplicateServiceError ¶
DuplicateServiceError is returned during Node startup if a registered service constructor returns a service of the same type that was already started.
func (*DuplicateServiceError) Error ¶
func (e *DuplicateServiceError) Error() string
Error generates a textual representation of the duplicate service error.
type HpbApiBackend ¶
type HpbApiBackend struct {
// contains filtered or unexported fields
}
HpbApiBackend implements ethapi.Backend for full nodes
func (*HpbApiBackend) AccountManager ¶
func (b *HpbApiBackend) AccountManager() *accounts.Manager
func (*HpbApiBackend) BlockByHash ¶
func (*HpbApiBackend) BlockByNumber ¶
func (b *HpbApiBackend) BlockByNumber(ctx context.Context, blockNr rpc.BlockNumber) (*types.Block, error)
func (*HpbApiBackend) BlockByNumberOrHash ¶
func (b *HpbApiBackend) BlockByNumberOrHash(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (*types.Block, error)
func (*HpbApiBackend) BloomStatus ¶
func (b *HpbApiBackend) BloomStatus() (uint64, uint64)
func (*HpbApiBackend) ChainConfig ¶
func (b *HpbApiBackend) ChainConfig() *config.ChainConfig
func (*HpbApiBackend) ChainDb ¶
func (b *HpbApiBackend) ChainDb() hpbdb.Database
func (*HpbApiBackend) CurrentBlock ¶
func (b *HpbApiBackend) CurrentBlock() *types.Block
func (*HpbApiBackend) CurrentHeader ¶
func (b *HpbApiBackend) CurrentHeader() *types.Header
func (*HpbApiBackend) Downloader ¶
func (b *HpbApiBackend) Downloader() *synctrl.Syncer
func (*HpbApiBackend) EventMux ¶
func (b *HpbApiBackend) EventMux() *sub.TypeMux
func (*HpbApiBackend) GetPoolNonce ¶
func (*HpbApiBackend) GetPoolTransaction ¶
func (b *HpbApiBackend) GetPoolTransaction(hash common.Hash) *types.Transaction
func (*HpbApiBackend) GetPoolTransactions ¶
func (b *HpbApiBackend) GetPoolTransactions() (types.Transactions, error)
func (*HpbApiBackend) GetReceipts ¶
func (*HpbApiBackend) GetTransaction ¶
func (*HpbApiBackend) HeaderByHash ¶
func (*HpbApiBackend) HeaderByNumber ¶
func (b *HpbApiBackend) HeaderByNumber(ctx context.Context, blockNr rpc.BlockNumber) (*types.Header, error)
func (*HpbApiBackend) HeaderByNumberOrHash ¶
func (b *HpbApiBackend) HeaderByNumberOrHash(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (*types.Header, error)
func (*HpbApiBackend) ProtocolVersion ¶
func (b *HpbApiBackend) ProtocolVersion() int
func (*HpbApiBackend) RPCGasCap ¶
func (b *HpbApiBackend) RPCGasCap() uint64
func (*HpbApiBackend) SendTx ¶
func (b *HpbApiBackend) SendTx(ctx context.Context, signedTx *types.Transaction) error
func (*HpbApiBackend) ServiceFilter ¶
func (b *HpbApiBackend) ServiceFilter(ctx context.Context, session *bloombits.MatcherSession)
func (*HpbApiBackend) SetHead ¶
func (b *HpbApiBackend) SetHead(number uint64)
func (*HpbApiBackend) StateAndHeaderByNumber ¶
func (b *HpbApiBackend) StateAndHeaderByNumber(ctx context.Context, blockNr rpc.BlockNumber) (*state.StateDB, *types.Header, error)
func (*HpbApiBackend) StateAndHeaderByNumberOrHash ¶
func (b *HpbApiBackend) StateAndHeaderByNumberOrHash(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (*state.StateDB, *types.Header, error)
func (*HpbApiBackend) Stats ¶
func (b *HpbApiBackend) Stats() (pending int, queued int)
func (*HpbApiBackend) SubscribeChainEvent ¶
func (b *HpbApiBackend) SubscribeChainEvent(ch chan<- bc.ChainEvent) sub.Subscription
func (*HpbApiBackend) SubscribeChainHeadEvent ¶
func (b *HpbApiBackend) SubscribeChainHeadEvent(ch chan<- bc.ChainHeadEvent) sub.Subscription
func (*HpbApiBackend) SubscribeChainSideEvent ¶
func (b *HpbApiBackend) SubscribeChainSideEvent(ch chan<- bc.ChainSideEvent) sub.Subscription
func (*HpbApiBackend) SubscribeLogsEvent ¶
func (b *HpbApiBackend) SubscribeLogsEvent(ch chan<- []*types.Log) sub.Subscription
func (*HpbApiBackend) SubscribeRemovedLogsEvent ¶
func (b *HpbApiBackend) SubscribeRemovedLogsEvent(ch chan<- bc.RemovedLogsEvent) sub.Subscription
func (*HpbApiBackend) SubscribeTxPreEvent ¶
func (b *HpbApiBackend) SubscribeTxPreEvent(ch chan<- bc.TxPreEvent) sub.Subscription
func (*HpbApiBackend) SuggestPrice ¶
func (*HpbApiBackend) TxPoolContent ¶
func (b *HpbApiBackend) TxPoolContent() (map[common.Address]types.Transactions, map[common.Address]types.Transactions)
func (*HpbApiBackend) TxPoolContentFrom ¶
func (b *HpbApiBackend) TxPoolContentFrom(addr common.Address) (types.Transactions, types.Transactions)
type Node ¶
type Node struct { Hpbconfig *config.HpbConfig Hpbpeermanager *p2p.PeerManager Hpbrpcmanager *rpc.RpcManager Hpbsyncctr *synctrl.SynCtrl Hpbtxpool *txpool.TxPool Hpbbc *bc.BlockChain Hpbboe *boe.BoeHandle //HpbDb HpbDb hpbdb.Database Hpbengine consensus.Engine ApiBackend *HpbApiBackend RpcAPIs []rpc.API // List of APIs currently provided by the node //1:boe init ok 0: boe init fail Boeflag uint8 // contains filtered or unexported fields }
Node is a container on which services can be registered.
func (*Node) APIAccountManager ¶
func (*Node) APIs ¶
APIs returns the collection of RPC services the hpb package offers. NOTE, some of these services probably need to be moved to somewhere else.
func (*Node) AccountManager ¶
AccountManager retrieves the account manager used by the protocol stack.
func (*Node) BlockChain ¶
func (s *Node) BlockChain() *bc.BlockChain
func (*Node) DataDir ¶
DataDir retrieves the current datadir used by the protocol stack. Deprecated: No files should be stored in this directory, use InstanceDir instead.
func (*Node) EthVersion ¶
func (*Node) InstanceDir ¶
InstanceDir retrieves the instance directory used by the protocol stack.
func (*Node) IsListening ¶
func (*Node) NetVersion ¶
func (*Node) NewBlockMux ¶
EventMux retrieves the event multiplexer used by all the network services in the current protocol stack.
func (*Node) RPCHandler ¶
RPCHandler returns the in-process RPC request handler.
func (*Node) ResetWithGenesisBlock ¶
func (*Node) ResolvePath ¶
ResolvePath returns the absolute path of a resource in the instance directory.
func (*Node) Restart ¶
Restart terminates a running node and boots up a new one in its place. If the node isn't running, an error is returned.
func (*Node) SetHpberbase ¶
set in js console via admin interface or wrapper from cli flags
func (*Node) SetNodeAPI ¶
func (*Node) StartMining ¶
func (*Node) Stop ¶
Stop terminates a running node along with all it's services. In the node was not started, an error is returned.
func (*Node) StopMining ¶
func (s *Node) StopMining()
type PrivateAdminAPI ¶
type PrivateAdminAPI struct {
// contains filtered or unexported fields
}
PrivateAdminAPI is the collection of Hpb full node-related APIs exposed over the private admin endpoint.
func NewPrivateAdminAPI ¶
func NewPrivateAdminAPI(hpb *Node) *PrivateAdminAPI
NewPrivateAdminAPI creates a new API definition for the full node private admin methods of the Hpb service.
func (*PrivateAdminAPI) AddPeer ¶
func (api *PrivateAdminAPI) AddPeer(url string) error
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.
func (*PrivateAdminAPI) RemovePeer ¶
func (api *PrivateAdminAPI) RemovePeer(url string) error
type PrivateDebugAPI ¶
type PrivateDebugAPI struct {
// contains filtered or unexported fields
}
PrivateDebugAPI is the collection of Hpb full node APIs exposed over the private debugging endpoint.
func NewPrivateDebugAPI ¶
func NewPrivateDebugAPI(config *config.ChainConfig, hpb *Node) *PrivateDebugAPI
NewPrivateDebugAPI creates a new API definition for the full node-related private debug methods of the Hpb service.
func (*PrivateDebugAPI) GetBadBlocks ¶
func (api *PrivateDebugAPI) GetBadBlocks(ctx context.Context) ([]BadBlockArgs, error)
BadBlocks returns a list of the last 'bad blocks' that the client has seen on the network
func (*PrivateDebugAPI) Preimage ¶
// TraceTransaction returns the structured logs created during the execution of EVM // and returns them as a JSON object.
func (api *PrivateDebugAPI) TraceTransaction(ctx context.Context, txHash common.Hash, config *TraceArgs) (interface{}, error) { var tracer evm.Tracer if config != nil && config.Tracer != nil { timeout := defaultTraceTimeout if config.Timeout != nil { var err error if timeout, err = time.ParseDuration(*config.Timeout); err != nil { return nil, err } } var err error if tracer, err = hpbapi.NewJavascriptTracer(*config.Tracer); err != nil { return nil, err } // Handle timeouts and RPC cancellations deadlineCtx, cancel := context.WithTimeout(ctx, timeout) go func() { <-deadlineCtx.Done() tracer.(*hpbapi.JavascriptTracer).Stop(&timeoutError{}) }() defer cancel() } else if config == nil { tracer = evm.NewStructLogger(nil) } else { tracer = evm.NewStructLogger(config.LogConfig) } // Retrieve the tx from the chain and the containing block tx, blockHash, _, txIndex := bc.GetTransaction(api.hpb.ChainDb(), txHash) if tx == nil { return nil, fmt.Errorf("transaction %x not found", txHash) } msg, context, statedb, err := api.computeTxEnv(blockHash, int(txIndex)) if err != nil { return nil, err } // Run the transaction with tracing enabled. vmenv := evm.NewEVM(context, statedb, api.config, evm.Config{Debug: true, Tracer: tracer}) block := bc.InstanceBlockChain() ret, gas, failed, err := bc.ApplyMessage(block, nil, nil, nil, msg , nil) if err != nil { return nil, fmt.Errorf("tracing failed: %v", err) } switch tracer := tracer.(type) { case *evm.StructLogger: return &hpbapi.ExecutionResult{ Gas: gas, Failed: failed, ReturnValue: fmt.Sprintf("%x", ret), StructLogs: hpbapi.FormatLogs(tracer.StructLogs()), }, nil case *hpbapi.JavascriptTracer: return tracer.GetResult() default: panic(fmt.Sprintf("bad tracer type %T", tracer)) } }
// computeTxEnv returns the execution environment of a certain transaction.
func (api *PrivateDebugAPI) computeTxEnv(blockHash common.Hash, txIndex int) (bc.Message, evm.Context, *state.StateDB, error) { // Create the parent state. block := api.hpb.BlockChain().GetBlockByHash(blockHash) if block == nil { return nil, evm.Context{}, nil, fmt.Errorf("block %x not found", blockHash) } parent := api.hpb.BlockChain().GetBlock(block.ParentHash(), block.NumberU64()-1) if parent == nil { return nil, evm.Context{}, nil, fmt.Errorf("block parent %x not found", block.ParentHash()) } statedb, err := api.hpb.BlockChain().StateAt(parent.Root()) if err != nil { return nil, evm.Context{}, nil, err } txs := block.Transactions() // Recompute transactions up to the target index. signer := types.MakeSigner(api.config, block.Number()) for idx, tx := range txs { // Assemble the transaction call message msg, _ := tx.AsMessage(signer) context := hvm.NewEVMContext(msg, block.Header(), api.hpb.BlockChain(), nil) if idx == txIndex { return msg, context, statedb, nil } vmenv := evm.NewEVM(context, statedb, api.config, evm.Config{}) gp := new(bc.GasPool).AddGas(tx.Gas()) _, _, _, err := bc.ApplyMessage(vmenv, msg, gp) if err != nil { return nil, evm.Context{}, nil, fmt.Errorf("tx %x failed: %v", tx.Hash(), err) } statedb.DeleteSuicides() } return nil, evm.Context{}, nil, fmt.Errorf("tx index %d out of range for block %x", txIndex, blockHash) }
Preimage is a debug API function that returns the preimage for a sha3 hash, if known.
func (*PrivateDebugAPI) StandardTraceBadBlockToFile ¶
func (api *PrivateDebugAPI) StandardTraceBadBlockToFile(ctx context.Context, hash common.Hash, config *StdTraceConfig) ([]string, error)
StandardTraceBadBlockToFile dumps the structured logs created during the execution of EVM against a block pulled from the pool of bad ones to the local file system and returns a list of files to the caller.
func (*PrivateDebugAPI) StandardTraceBlockToFile ¶
func (api *PrivateDebugAPI) StandardTraceBlockToFile(ctx context.Context, hash common.Hash, config *StdTraceConfig) ([]string, error)
StandardTraceBlockToFile dumps the structured logs created during the execution of EVM to the local file system and returns a list of files to the caller.
func (*PrivateDebugAPI) TraceBadBlock ¶
func (api *PrivateDebugAPI) TraceBadBlock(ctx context.Context, hash common.Hash, config *TraceConfig) ([]*txTraceResult, error)
TraceBadBlock returns the structured logs created during the execution of EVM against a block pulled from the pool of bad ones and returns them as a JSON object.
func (*PrivateDebugAPI) TraceBlock ¶
func (api *PrivateDebugAPI) TraceBlock(ctx context.Context, blob hexutil.Bytes, 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) TraceCall ¶
func (api *PrivateDebugAPI) TraceCall(ctx context.Context, args hpbapi.CallArgs, blockNrOrHash rpc.BlockNumberOrHash, config *TraceConfig) (interface{}, error)
TraceCall lets you trace a given eth_call. It collects the structured logs created during the execution of EVM if the given transaction was added on top of the provided block and returns them as a JSON object. You can provide -2 as a block number to trace on top of the pending block.
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 PrivateMinerAPI ¶
type PrivateMinerAPI struct {
// contains filtered or unexported fields
}
PrivateMinerAPI provides private RPC methods tso control the miner. These methods can be abused by external users and must be considered insecure for use by untrusted users.
func NewPrivateMinerAPI ¶
func NewPrivateMinerAPI(e *Node) *PrivateMinerAPI
NewPrivateMinerAPI create a new RPC service which controls the miner of this node.
func (*PrivateMinerAPI) SetExtra ¶
func (api *PrivateMinerAPI) SetExtra(extra string) (bool, error)
SetExtra sets the extra data string that is included when this miner mines a block.
func (*PrivateMinerAPI) SetGasPrice ¶
func (api *PrivateMinerAPI) SetGasPrice(gasPrice hexutil.Big) bool
SetGasPrice sets the minimum accepted gas price for the miner.
func (*PrivateMinerAPI) SetHpberbase ¶
func (api *PrivateMinerAPI) SetHpberbase(hpberbase common.Address) bool
SetHpberbase sets the hpberbase of the miner
func (*PrivateMinerAPI) Start ¶
func (api *PrivateMinerAPI) Start(threads *int) error
Start the miner 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 mining is already running, this method adjust the number of threads allowed to use.
type PublicAdminAPI ¶
type PublicAdminAPI struct {
// contains filtered or unexported fields
}
PublicAdminAPI is the collection of administrative API methods exposed over both secure and unsecure RPC channels.
func NewPublicAdminAPI ¶
func NewPublicAdminAPI(node *Node) *PublicAdminAPI
NewPublicAdminAPI creates a new API definition for the public admin methods of the node itself.
func (*PublicAdminAPI) Datadir ¶
func (api *PublicAdminAPI) Datadir() string
Datadir retrieves the current data directory the node is using.
type PublicDebugAPI ¶
type PublicDebugAPI struct {
// contains filtered or unexported fields
}
PublicDebugAPI is the collection of Hpb full node APIs exposed over the public debugging endpoint.
func NewPublicDebugAPI ¶
func NewPublicDebugAPI(hpb *Node) *PublicDebugAPI
NewPublicDebugAPI creates a new API definition for the full node- related public debug methods of the Hpb 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 PublicHpbAPI ¶
type PublicHpbAPI struct {
// contains filtered or unexported fields
}
PublicHpbAPI provides an API to access Hpb full node-related information.
func NewPublicHpbAPI ¶
func NewPublicHpbAPI(e *Node) *PublicHpbAPI
NewPublicHpbAPI creates a new Hpb protocol API for full nodes.
func (*PublicHpbAPI) Coinbase ¶
func (api *PublicHpbAPI) Coinbase() (common.Address, error)
Coinbase is the address that mining rewards will be send to (alias for Hpberbase)
func (*PublicHpbAPI) GetRandom ¶
func (api *PublicHpbAPI) GetRandom(blocknum *rpc.BlockNumber) string
func (*PublicHpbAPI) GetRandomAndBlock ¶
func (api *PublicHpbAPI) GetRandomAndBlock(blocknum *rpc.BlockNumber) (result RandomAndBlock)
func (*PublicHpbAPI) GetStatediffbyblock ¶
func (api *PublicHpbAPI) GetStatediffbyblock(data string) string
func (*PublicHpbAPI) GetStatediffbyblockandTx ¶
func (api *PublicHpbAPI) GetStatediffbyblockandTx(data string, hash string) string
func (*PublicHpbAPI) Hpberbase ¶
func (api *PublicHpbAPI) Hpberbase() (common.Address, error)
Hpberbase is the address that mining rewards will be send to
func (*PublicHpbAPI) Mining ¶
func (api *PublicHpbAPI) Mining() bool
Mining returns the miner is mining
type PublicWeb3API ¶
type PublicWeb3API struct {
// contains filtered or unexported fields
}
PublicWeb3API offers helper utils
func NewPublicWeb3API ¶
func NewPublicWeb3API(stack *Node) *PublicWeb3API
NewPublicWeb3API creates a new Web3Service instance
func (*PublicWeb3API) ClientVersion ¶
func (s *PublicWeb3API) ClientVersion() string
ClientVersion returns the node name
type RandomAndBlock ¶
type StateDiff ¶
type StateDiff struct {
// contains filtered or unexported fields
}
func (StateDiff) MarshalJSON ¶
type StdTraceConfig ¶
StdTraceConfig holds extra parameters to standard-json trace functions.
type StopError ¶
StopError is returned if a Node fails to stop either any of its registered services or itself.
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.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package filters implements an hpb filtering system for block, transactions and log events.
|
Package filters implements an hpb 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. |