aboutsummaryrefslogtreecommitdiffstats
path: root/internal/ethapi
diff options
context:
space:
mode:
Diffstat (limited to 'internal/ethapi')
-rw-r--r--internal/ethapi/api.go389
-rw-r--r--internal/ethapi/backend.go15
-rw-r--r--internal/ethapi/solc.go82
-rw-r--r--internal/ethapi/tracer.go317
-rw-r--r--internal/ethapi/tracer_test.go201
5 files changed, 685 insertions, 319 deletions
diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go
index f604a0ef2..0b1384f58 100644
--- a/internal/ethapi/api.go
+++ b/internal/ethapi/api.go
@@ -20,17 +20,14 @@ import (
"bytes"
"encoding/hex"
"encoding/json"
- "errors"
"fmt"
"math/big"
"strings"
- "sync"
"time"
"github.com/ethereum/ethash"
"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/common/compiler"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm"
@@ -50,14 +47,12 @@ const defaultGas = uint64(90000)
// PublicEthereumAPI provides an API to access Ethereum related information.
// It offers only methods that operate on public data that is freely available to anyone.
type PublicEthereumAPI struct {
- b Backend
- solcPath *string
- solc **compiler.Solidity
+ b Backend
}
// NewPublicEthereumAPI creates a new Etheruem protocol API.
-func NewPublicEthereumAPI(b Backend, solcPath *string, solc **compiler.Solidity) *PublicEthereumAPI {
- return &PublicEthereumAPI{b, solcPath, solc}
+func NewPublicEthereumAPI(b Backend) *PublicEthereumAPI {
+ return &PublicEthereumAPI{b}
}
// GasPrice returns a suggestion for a gas price.
@@ -65,39 +60,6 @@ func (s *PublicEthereumAPI) GasPrice(ctx context.Context) (*big.Int, error) {
return s.b.SuggestPrice(ctx)
}
-func (s *PublicEthereumAPI) getSolc() (*compiler.Solidity, error) {
- var err error
- solc := *s.solc
- if solc == nil {
- solc, err = compiler.New(*s.solcPath)
- }
- return solc, err
-}
-
-// GetCompilers returns the collection of available smart contract compilers
-func (s *PublicEthereumAPI) GetCompilers() ([]string, error) {
- solc, err := s.getSolc()
- if err == nil && solc != nil {
- return []string{"Solidity"}, nil
- }
-
- return []string{}, nil
-}
-
-// CompileSolidity compiles the given solidity source
-func (s *PublicEthereumAPI) CompileSolidity(source string) (map[string]*compiler.Contract, error) {
- solc, err := s.getSolc()
- if err != nil {
- return nil, err
- }
-
- if solc == nil {
- return nil, errors.New("solc (solidity compiler) not found")
- }
-
- return solc.Compile(source)
-}
-
// ProtocolVersion returns the current Ethereum protocol version this node supports
func (s *PublicEthereumAPI) ProtocolVersion() *rpc.HexNumber {
return rpc.NewHexNumber(s.b.ProtocolVersion())
@@ -111,19 +73,19 @@ func (s *PublicEthereumAPI) ProtocolVersion() *rpc.HexNumber {
// - pulledStates: number of state entries processed until now
// - knownStates: number of known state entries that still need to be pulled
func (s *PublicEthereumAPI) Syncing() (interface{}, error) {
- origin, current, height, pulled, known := s.b.Downloader().Progress()
+ progress := s.b.Downloader().Progress()
// Return not syncing if the synchronisation already completed
- if current >= height {
+ if progress.CurrentBlock >= progress.HighestBlock {
return false, nil
}
// Otherwise gather the block sync stats
return map[string]interface{}{
- "startingBlock": rpc.NewHexNumber(origin),
- "currentBlock": rpc.NewHexNumber(current),
- "highestBlock": rpc.NewHexNumber(height),
- "pulledStates": rpc.NewHexNumber(pulled),
- "knownStates": rpc.NewHexNumber(known),
+ "startingBlock": rpc.NewHexNumber(progress.StartingBlock),
+ "currentBlock": rpc.NewHexNumber(progress.CurrentBlock),
+ "highestBlock": rpc.NewHexNumber(progress.HighestBlock),
+ "pulledStates": rpc.NewHexNumber(progress.PulledStates),
+ "knownStates": rpc.NewHexNumber(progress.KnownStates),
}, nil
}
@@ -138,32 +100,26 @@ func NewPublicTxPoolAPI(b Backend) *PublicTxPoolAPI {
}
// Content returns the transactions contained within the transaction pool.
-func (s *PublicTxPoolAPI) Content() map[string]map[string]map[string][]*RPCTransaction {
- content := map[string]map[string]map[string][]*RPCTransaction{
- "pending": make(map[string]map[string][]*RPCTransaction),
- "queued": make(map[string]map[string][]*RPCTransaction),
+func (s *PublicTxPoolAPI) Content() map[string]map[string]map[string]*RPCTransaction {
+ content := map[string]map[string]map[string]*RPCTransaction{
+ "pending": make(map[string]map[string]*RPCTransaction),
+ "queued": make(map[string]map[string]*RPCTransaction),
}
pending, queue := s.b.TxPoolContent()
// Flatten the pending transactions
- for account, batches := range pending {
- dump := make(map[string][]*RPCTransaction)
- for nonce, txs := range batches {
- nonce := fmt.Sprintf("%d", nonce)
- for _, tx := range txs {
- dump[nonce] = append(dump[nonce], newRPCPendingTransaction(tx))
- }
+ for account, txs := range pending {
+ dump := make(map[string]*RPCTransaction)
+ for nonce, tx := range txs {
+ dump[fmt.Sprintf("%d", nonce)] = newRPCPendingTransaction(tx)
}
content["pending"][account.Hex()] = dump
}
// Flatten the queued transactions
- for account, batches := range queue {
- dump := make(map[string][]*RPCTransaction)
- for nonce, txs := range batches {
- nonce := fmt.Sprintf("%d", nonce)
- for _, tx := range txs {
- dump[nonce] = append(dump[nonce], newRPCPendingTransaction(tx))
- }
+ for account, txs := range queue {
+ dump := make(map[string]*RPCTransaction)
+ for nonce, tx := range txs {
+ dump[fmt.Sprintf("%d", nonce)] = newRPCPendingTransaction(tx)
}
content["queued"][account.Hex()] = dump
}
@@ -181,10 +137,10 @@ func (s *PublicTxPoolAPI) Status() map[string]*rpc.HexNumber {
// Inspect retrieves the content of the transaction pool and flattens it into an
// easily inspectable list.
-func (s *PublicTxPoolAPI) Inspect() map[string]map[string]map[string][]string {
- content := map[string]map[string]map[string][]string{
- "pending": make(map[string]map[string][]string),
- "queued": make(map[string]map[string][]string),
+func (s *PublicTxPoolAPI) Inspect() map[string]map[string]map[string]string {
+ content := map[string]map[string]map[string]string{
+ "pending": make(map[string]map[string]string),
+ "queued": make(map[string]map[string]string),
}
pending, queue := s.b.TxPoolContent()
@@ -196,24 +152,18 @@ func (s *PublicTxPoolAPI) Inspect() map[string]map[string]map[string][]string {
return fmt.Sprintf("contract creation: %v wei + %v × %v gas", tx.Value(), tx.Gas(), tx.GasPrice())
}
// Flatten the pending transactions
- for account, batches := range pending {
- dump := make(map[string][]string)
- for nonce, txs := range batches {
- nonce := fmt.Sprintf("%d", nonce)
- for _, tx := range txs {
- dump[nonce] = append(dump[nonce], format(tx))
- }
+ for account, txs := range pending {
+ dump := make(map[string]string)
+ for nonce, tx := range txs {
+ dump[fmt.Sprintf("%d", nonce)] = format(tx)
}
content["pending"][account.Hex()] = dump
}
// Flatten the queued transactions
- for account, batches := range queue {
- dump := make(map[string][]string)
- for nonce, txs := range batches {
- nonce := fmt.Sprintf("%d", nonce)
- for _, tx := range txs {
- dump[nonce] = append(dump[nonce], format(tx))
- }
+ for account, txs := range queue {
+ dump := make(map[string]string)
+ for nonce, tx := range txs {
+ dump[fmt.Sprintf("%d", nonce)] = format(tx)
}
content["queued"][account.Hex()] = dump
}
@@ -303,10 +253,10 @@ func (s *PrivateAccountAPI) LockAccount(addr common.Address) bool {
return s.am.Lock(addr) == nil
}
-// SignAndSendTransaction will create a transaction from the given arguments and
+// SendTransaction will create a transaction from the given arguments and
// tries to sign it with the key associated with args.To. If the given passwd isn't
// able to decrypt the key it fails.
-func (s *PrivateAccountAPI) SignAndSendTransaction(ctx context.Context, args SendTxArgs, passwd string) (common.Hash, error) {
+func (s *PrivateAccountAPI) SendTransaction(ctx context.Context, args SendTxArgs, passwd string) (common.Hash, error) {
var err error
args, err = prepareSendTxArgs(ctx, args, s.b)
if err != nil {
@@ -336,40 +286,21 @@ func (s *PrivateAccountAPI) SignAndSendTransaction(ctx context.Context, args Sen
return submitTransaction(ctx, s.b, tx, signature)
}
+// SignAndSendTransaction was renamed to SendTransaction. This method is deprecated
+// and will be removed in the future. It primary goal is to give clients time to update.
+func (s *PrivateAccountAPI) SignAndSendTransaction(ctx context.Context, args SendTxArgs, passwd string) (common.Hash, error) {
+ return s.SendTransaction(ctx, args, passwd)
+}
+
// PublicBlockChainAPI provides an API to access the Ethereum blockchain.
// It offers only methods that operate on public data that is freely available to anyone.
type PublicBlockChainAPI struct {
- b Backend
- muNewBlockSubscriptions sync.Mutex // protects newBlocksSubscriptions
- newBlockSubscriptions map[string]func(core.ChainEvent) error // callbacks for new block subscriptions
+ b Backend
}
// NewPublicBlockChainAPI creates a new Etheruem blockchain API.
func NewPublicBlockChainAPI(b Backend) *PublicBlockChainAPI {
- api := &PublicBlockChainAPI{
- b: b,
- newBlockSubscriptions: make(map[string]func(core.ChainEvent) error),
- }
-
- go api.subscriptionLoop()
-
- return api
-}
-
-// subscriptionLoop reads events from the global event mux and creates notifications for the matched subscriptions.
-func (s *PublicBlockChainAPI) subscriptionLoop() {
- sub := s.b.EventMux().Subscribe(core.ChainEvent{})
- for event := range sub.Chan() {
- if chainEvent, ok := event.Data.(core.ChainEvent); ok {
- s.muNewBlockSubscriptions.Lock()
- for id, notifyOf := range s.newBlockSubscriptions {
- if notifyOf(chainEvent) == rpc.ErrNotificationNotFound {
- delete(s.newBlockSubscriptions, id)
- }
- }
- s.muNewBlockSubscriptions.Unlock()
- }
- }
+ return &PublicBlockChainAPI{b}
}
// BlockNumber returns the block number of the chain head.
@@ -464,45 +395,6 @@ func (s *PublicBlockChainAPI) GetUncleCountByBlockHash(ctx context.Context, bloc
return nil
}
-// NewBlocksArgs allows the user to specify if the returned block should include transactions and in which format.
-type NewBlocksArgs struct {
- IncludeTransactions bool `json:"includeTransactions"`
- TransactionDetails bool `json:"transactionDetails"`
-}
-
-// NewBlocks triggers a new block event each time a block is appended to the chain. It accepts an argument which allows
-// the caller to specify whether the output should contain transactions and in what format.
-func (s *PublicBlockChainAPI) NewBlocks(ctx context.Context, args NewBlocksArgs) (rpc.Subscription, error) {
- notifier, supported := rpc.NotifierFromContext(ctx)
- if !supported {
- return nil, rpc.ErrNotificationsUnsupported
- }
-
- // create a subscription that will remove itself when unsubscribed/cancelled
- subscription, err := notifier.NewSubscription(func(subId string) {
- s.muNewBlockSubscriptions.Lock()
- delete(s.newBlockSubscriptions, subId)
- s.muNewBlockSubscriptions.Unlock()
- })
-
- if err != nil {
- return nil, err
- }
-
- // add a callback that is called on chain events which will format the block and notify the client
- s.muNewBlockSubscriptions.Lock()
- s.newBlockSubscriptions[subscription.ID()] = func(e core.ChainEvent) error {
- notification, err := s.rpcOutputBlock(e.Block, args.IncludeTransactions, args.TransactionDetails)
- if err == nil {
- return subscription.Notify(notification)
- }
- glog.V(logger.Warn).Info("unable to format block %v\n", err)
- return nil
- }
- s.muNewBlockSubscriptions.Unlock()
- return subscription, nil
-}
-
// GetCode returns the code stored at the given address in the state for the given block number.
func (s *PublicBlockChainAPI) GetCode(ctx context.Context, address common.Address, blockNr rpc.BlockNumber) (string, error) {
state, _, err := s.b.StateAndHeaderByNumber(blockNr)
@@ -680,82 +572,30 @@ func FormatLogs(structLogs []vm.StructLog) []StructLogRes {
return formattedStructLogs
}
-// TraceCall executes a call and returns the amount of gas, created logs and optionally returned values.
-func (s *PublicBlockChainAPI) TraceCall(ctx context.Context, args CallArgs, blockNr rpc.BlockNumber) (*ExecutionResult, error) {
- state, header, err := s.b.StateAndHeaderByNumber(blockNr)
- if state == nil || err != nil {
- return nil, err
- }
-
- var addr common.Address
- if args.From == (common.Address{}) {
- accounts := s.b.AccountManager().Accounts()
- if len(accounts) == 0 {
- addr = common.Address{}
- } else {
- addr = accounts[0].Address
- }
- } else {
- addr = args.From
- }
-
- // Assemble the CALL invocation
- msg := callmsg{
- addr: addr,
- to: args.To,
- gas: args.Gas.BigInt(),
- gasPrice: args.GasPrice.BigInt(),
- value: args.Value.BigInt(),
- data: common.FromHex(args.Data),
- }
-
- if msg.gas.Cmp(common.Big0) == 0 {
- msg.gas = big.NewInt(50000000)
- }
-
- if msg.gasPrice.Cmp(common.Big0) == 0 {
- msg.gasPrice = new(big.Int).Mul(big.NewInt(50), common.Shannon)
- }
-
- // Execute the call and return
- vmenv, vmError, err := s.b.GetVMEnv(ctx, msg, state, header)
- if err != nil {
- return nil, err
- }
- gp := new(core.GasPool).AddGas(common.MaxBig)
- ret, gas, err := core.ApplyMessage(vmenv, msg, gp)
- if err := vmError(); err != nil {
- return nil, err
- }
- return &ExecutionResult{
- Gas: gas,
- ReturnValue: fmt.Sprintf("%x", ret),
- StructLogs: FormatLogs(vmenv.StructLogs()),
- }, nil
-}
-
// rpcOutputBlock converts the given block to the RPC output which depends on fullTx. If inclTx is true transactions are
// returned. When fullTx is true the returned block contains full transaction details, otherwise it will only contain
// transaction hashes.
func (s *PublicBlockChainAPI) rpcOutputBlock(b *types.Block, inclTx bool, fullTx bool) (map[string]interface{}, error) {
+ head := b.Header() // copies the header once
fields := map[string]interface{}{
- "number": rpc.NewHexNumber(b.Number()),
+ "number": rpc.NewHexNumber(head.Number),
"hash": b.Hash(),
- "parentHash": b.ParentHash(),
- "nonce": b.Header().Nonce,
- "sha3Uncles": b.UncleHash(),
- "logsBloom": b.Bloom(),
- "stateRoot": b.Root(),
- "miner": b.Coinbase(),
- "difficulty": rpc.NewHexNumber(b.Difficulty()),
+ "parentHash": head.ParentHash,
+ "nonce": head.Nonce,
+ "mixHash": head.MixDigest,
+ "sha3Uncles": head.UncleHash,
+ "logsBloom": head.Bloom,
+ "stateRoot": head.Root,
+ "miner": head.Coinbase,
+ "difficulty": rpc.NewHexNumber(head.Difficulty),
"totalDifficulty": rpc.NewHexNumber(s.b.GetTd(b.Hash())),
- "extraData": fmt.Sprintf("0x%x", b.Extra()),
+ "extraData": rpc.HexBytes(head.Extra),
"size": rpc.NewHexNumber(b.Size().Int64()),
- "gasLimit": rpc.NewHexNumber(b.GasLimit()),
- "gasUsed": rpc.NewHexNumber(b.GasUsed()),
- "timestamp": rpc.NewHexNumber(b.Time()),
- "transactionsRoot": b.TxHash(),
- "receiptRoot": b.ReceiptHash(),
+ "gasLimit": rpc.NewHexNumber(head.GasLimit),
+ "gasUsed": rpc.NewHexNumber(head.GasUsed),
+ "timestamp": rpc.NewHexNumber(head.Time),
+ "transactionsRoot": head.TxHash,
+ "receiptRoot": head.ReceiptHash,
}
if inclTx {
@@ -798,26 +638,32 @@ type RPCTransaction struct {
Gas *rpc.HexNumber `json:"gas"`
GasPrice *rpc.HexNumber `json:"gasPrice"`
Hash common.Hash `json:"hash"`
- Input string `json:"input"`
+ Input rpc.HexBytes `json:"input"`
Nonce *rpc.HexNumber `json:"nonce"`
To *common.Address `json:"to"`
TransactionIndex *rpc.HexNumber `json:"transactionIndex"`
Value *rpc.HexNumber `json:"value"`
+ V *rpc.HexNumber `json:"v"`
+ R *rpc.HexNumber `json:"r"`
+ S *rpc.HexNumber `json:"s"`
}
// newRPCPendingTransaction returns a pending transaction that will serialize to the RPC representation
func newRPCPendingTransaction(tx *types.Transaction) *RPCTransaction {
from, _ := tx.FromFrontier()
-
+ v, r, s := tx.SignatureValues()
return &RPCTransaction{
From: from,
Gas: rpc.NewHexNumber(tx.Gas()),
GasPrice: rpc.NewHexNumber(tx.GasPrice()),
Hash: tx.Hash(),
- Input: fmt.Sprintf("0x%x", tx.Data()),
+ Input: rpc.HexBytes(tx.Data()),
Nonce: rpc.NewHexNumber(tx.Nonce()),
To: tx.To(),
Value: rpc.NewHexNumber(tx.Value()),
+ V: rpc.NewHexNumber(v),
+ R: rpc.NewHexNumber(r),
+ S: rpc.NewHexNumber(s),
}
}
@@ -829,7 +675,7 @@ func newRPCTransactionFromBlockIndex(b *types.Block, txIndex int) (*RPCTransacti
if err != nil {
return nil, err
}
-
+ v, r, s := tx.SignatureValues()
return &RPCTransaction{
BlockHash: b.Hash(),
BlockNumber: rpc.NewHexNumber(b.Number()),
@@ -837,11 +683,14 @@ func newRPCTransactionFromBlockIndex(b *types.Block, txIndex int) (*RPCTransacti
Gas: rpc.NewHexNumber(tx.Gas()),
GasPrice: rpc.NewHexNumber(tx.GasPrice()),
Hash: tx.Hash(),
- Input: fmt.Sprintf("0x%x", tx.Data()),
+ Input: rpc.HexBytes(tx.Data()),
Nonce: rpc.NewHexNumber(tx.Nonce()),
To: tx.To(),
TransactionIndex: rpc.NewHexNumber(txIndex),
Value: rpc.NewHexNumber(tx.Value()),
+ V: rpc.NewHexNumber(v),
+ R: rpc.NewHexNumber(r),
+ S: rpc.NewHexNumber(s),
}, nil
}
@@ -861,40 +710,12 @@ func newRPCTransaction(b *types.Block, txHash common.Hash) (*RPCTransaction, err
// PublicTransactionPoolAPI exposes methods for the RPC interface
type PublicTransactionPoolAPI struct {
- b Backend
- muPendingTxSubs sync.Mutex
- pendingTxSubs map[string]rpc.Subscription
+ b Backend
}
// NewPublicTransactionPoolAPI creates a new RPC service with methods specific for the transaction pool.
func NewPublicTransactionPoolAPI(b Backend) *PublicTransactionPoolAPI {
- api := &PublicTransactionPoolAPI{
- b: b,
- pendingTxSubs: make(map[string]rpc.Subscription),
- }
-
- go api.subscriptionLoop()
-
- return api
-}
-
-// subscriptionLoop listens for events on the global event mux and creates notifications for subscriptions.
-func (s *PublicTransactionPoolAPI) subscriptionLoop() {
- sub := s.b.EventMux().Subscribe(core.TxPreEvent{})
- for event := range sub.Chan() {
- tx := event.Data.(core.TxPreEvent)
- if from, err := tx.Tx.FromFrontier(); err == nil {
- if s.b.AccountManager().HasAddress(from) {
- s.muPendingTxSubs.Lock()
- for id, sub := range s.pendingTxSubs {
- if sub.Notify(tx.Tx.Hash()) == rpc.ErrNotificationNotFound {
- delete(s.pendingTxSubs, id)
- }
- }
- s.muPendingTxSubs.Unlock()
- }
- }
- }
+ return &PublicTransactionPoolAPI{b}
}
func getTransaction(chainDb ethdb.Database, b Backend, txHash common.Hash) (*types.Transaction, bool, error) {
@@ -1039,7 +860,7 @@ func (s *PublicTransactionPoolAPI) GetTransactionReceipt(txHash common.Hash) (ma
}
fields := map[string]interface{}{
- "root": common.Bytes2Hex(receipt.PostState),
+ "root": rpc.HexBytes(receipt.PostState),
"blockHash": txBlock,
"blockNumber": rpc.NewHexNumber(blockIndex),
"transactionHash": txHash,
@@ -1050,17 +871,15 @@ func (s *PublicTransactionPoolAPI) GetTransactionReceipt(txHash common.Hash) (ma
"cumulativeGasUsed": rpc.NewHexNumber(receipt.CumulativeGasUsed),
"contractAddress": nil,
"logs": receipt.Logs,
+ "logsBloom": receipt.Bloom,
}
-
if receipt.Logs == nil {
fields["logs"] = []vm.Logs{}
}
-
// If the ContractAddress is 20 0x0 bytes, assume it is not a contract creation
- if bytes.Compare(receipt.ContractAddress.Bytes(), bytes.Repeat([]byte{0}, 20)) != 0 {
+ if receipt.ContractAddress != (common.Address{}) {
fields["contractAddress"] = receipt.ContractAddress
}
-
return fields, nil
}
@@ -1347,31 +1166,6 @@ func (s *PublicTransactionPoolAPI) PendingTransactions() []*RPCTransaction {
return transactions
}
-// NewPendingTransactions creates a subscription that is triggered each time a transaction enters the transaction pool
-// and is send from one of the transactions this nodes manages.
-func (s *PublicTransactionPoolAPI) NewPendingTransactions(ctx context.Context) (rpc.Subscription, error) {
- notifier, supported := rpc.NotifierFromContext(ctx)
- if !supported {
- return nil, rpc.ErrNotificationsUnsupported
- }
-
- subscription, err := notifier.NewSubscription(func(id string) {
- s.muPendingTxSubs.Lock()
- delete(s.pendingTxSubs, id)
- s.muPendingTxSubs.Unlock()
- })
-
- if err != nil {
- return nil, err
- }
-
- s.muPendingTxSubs.Lock()
- s.pendingTxSubs[subscription.ID()] = subscription
- s.muPendingTxSubs.Unlock()
-
- return subscription, nil
-}
-
// Resend accepts an existing transaction and a new gas price and limit. It will remove the given transaction from the
// pool and reinsert it with the new gas price and limit.
func (s *PublicTransactionPoolAPI) Resend(ctx context.Context, tx *Tx, gasPrice, gasLimit *rpc.HexNumber) (common.Hash, error) {
@@ -1410,31 +1204,6 @@ func (s *PublicTransactionPoolAPI) Resend(ctx context.Context, tx *Tx, gasPrice,
return common.Hash{}, fmt.Errorf("Transaction %#x not found", tx.Hash)
}
-// PrivateAdminAPI is the collection of Etheruem APIs exposed over the private
-// admin endpoint.
-type PrivateAdminAPI struct {
- b Backend
- solcPath *string
- solc **compiler.Solidity
-}
-
-// NewPrivateAdminAPI creates a new API definition for the private admin methods
-// of the Ethereum service.
-func NewPrivateAdminAPI(b Backend, solcPath *string, solc **compiler.Solidity) *PrivateAdminAPI {
- return &PrivateAdminAPI{b, solcPath, solc}
-}
-
-// SetSolc sets the Solidity compiler path to be used by the node.
-func (api *PrivateAdminAPI) SetSolc(path string) (string, error) {
- var err error
- *api.solcPath = path
- *api.solc, err = compiler.New(path)
- if err != nil {
- return "", err
- }
- return (*api.solc).Info(), nil
-}
-
// PublicDebugAPI is the collection of Etheruem APIs exposed over the public
// debugging endpoint.
type PublicDebugAPI struct {
diff --git a/internal/ethapi/backend.go b/internal/ethapi/backend.go
index d112a6aef..0aa3da18d 100644
--- a/internal/ethapi/backend.go
+++ b/internal/ethapi/backend.go
@@ -22,7 +22,6 @@ import (
"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/common/compiler"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm"
@@ -59,7 +58,7 @@ type Backend interface {
GetPoolTransaction(txHash common.Hash) *types.Transaction
GetPoolNonce(ctx context.Context, addr common.Address) (uint64, error)
Stats() (pending int, queued int)
- TxPoolContent() (map[common.Address]map[uint64][]*types.Transaction, map[common.Address]map[uint64][]*types.Transaction)
+ TxPoolContent() (map[common.Address]types.Transactions, map[common.Address]types.Transactions)
}
type State interface {
@@ -69,12 +68,13 @@ type State interface {
GetNonce(ctx context.Context, addr common.Address) (uint64, error)
}
-func GetAPIs(apiBackend Backend, solcPath *string, solc **compiler.Solidity) []rpc.API {
- return []rpc.API{
+func GetAPIs(apiBackend Backend, solcPath string) []rpc.API {
+ compiler := makeCompilerAPIs(solcPath)
+ all := []rpc.API{
{
Namespace: "eth",
Version: "1.0",
- Service: NewPublicEthereumAPI(apiBackend, solcPath, solc),
+ Service: NewPublicEthereumAPI(apiBackend),
Public: true,
}, {
Namespace: "eth",
@@ -92,10 +92,6 @@ func GetAPIs(apiBackend Backend, solcPath *string, solc **compiler.Solidity) []r
Service: NewPublicTxPoolAPI(apiBackend),
Public: true,
}, {
- Namespace: "admin",
- Version: "1.0",
- Service: NewPrivateAdminAPI(apiBackend, solcPath, solc),
- }, {
Namespace: "debug",
Version: "1.0",
Service: NewPublicDebugAPI(apiBackend),
@@ -116,4 +112,5 @@ func GetAPIs(apiBackend Backend, solcPath *string, solc **compiler.Solidity) []r
Public: false,
},
}
+ return append(compiler, all...)
}
diff --git a/internal/ethapi/solc.go b/internal/ethapi/solc.go
new file mode 100644
index 000000000..b9acc518b
--- /dev/null
+++ b/internal/ethapi/solc.go
@@ -0,0 +1,82 @@
+// Copyright 2016 The go-ethereum Authors
+// This file is part of the go-ethereum library.
+//
+// The go-ethereum library is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// The go-ethereum library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
+
+package ethapi
+
+import (
+ "sync"
+
+ "github.com/ethereum/go-ethereum/common/compiler"
+ "github.com/ethereum/go-ethereum/rpc"
+)
+
+func makeCompilerAPIs(solcPath string) []rpc.API {
+ c := &compilerAPI{solc: solcPath}
+ return []rpc.API{
+ {
+ Namespace: "eth",
+ Version: "1.0",
+ Service: (*PublicCompilerAPI)(c),
+ Public: true,
+ },
+ {
+ Namespace: "admin",
+ Version: "1.0",
+ Service: (*CompilerAdminAPI)(c),
+ Public: true,
+ },
+ }
+}
+
+type compilerAPI struct {
+ // This lock guards the solc path set through the API.
+ // It also ensures that only one solc process is used at
+ // any time.
+ mu sync.Mutex
+ solc string
+}
+
+type CompilerAdminAPI compilerAPI
+
+// SetSolc sets the Solidity compiler path to be used by the node.
+func (api *CompilerAdminAPI) SetSolc(path string) (string, error) {
+ api.mu.Lock()
+ defer api.mu.Unlock()
+ info, err := compiler.SolidityVersion(path)
+ if err != nil {
+ return "", err
+ }
+ api.solc = path
+ return info.FullVersion, nil
+}
+
+type PublicCompilerAPI compilerAPI
+
+// CompileSolidity compiles the given solidity source.
+func (api *PublicCompilerAPI) CompileSolidity(source string) (map[string]*compiler.Contract, error) {
+ api.mu.Lock()
+ defer api.mu.Unlock()
+ return compiler.CompileSolidityString(api.solc, source)
+}
+
+func (api *PublicCompilerAPI) GetCompilers() ([]string, error) {
+ api.mu.Lock()
+ defer api.mu.Unlock()
+ if _, err := compiler.SolidityVersion(api.solc); err == nil {
+ return []string{"Solidity"}, nil
+ }
+ return []string{}, nil
+}
diff --git a/internal/ethapi/tracer.go b/internal/ethapi/tracer.go
new file mode 100644
index 000000000..16ec6ebf0
--- /dev/null
+++ b/internal/ethapi/tracer.go
@@ -0,0 +1,317 @@
+// Copyright 2016 The go-ethereum Authors
+// This file is part of the go-ethereum library.
+//
+// The go-ethereum library is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// The go-ethereum library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
+
+package ethapi
+
+import (
+ "encoding/json"
+ "errors"
+ "fmt"
+ "math/big"
+
+ "github.com/ethereum/go-ethereum/common"
+ "github.com/ethereum/go-ethereum/core/vm"
+ "github.com/robertkrimen/otto"
+)
+
+// fakeBig is used to provide an interface to Javascript for 'big.NewInt'
+type fakeBig struct{}
+
+// NewInt creates a new big.Int with the specified int64 value.
+func (fb *fakeBig) NewInt(x int64) *big.Int {
+ return big.NewInt(x)
+}
+
+// OpCodeWrapper provides a JavaScript-friendly wrapper around OpCode, to convince Otto to treat it
+// as an object, instead of a number.
+type opCodeWrapper struct {
+ op vm.OpCode
+}
+
+// toNumber returns the ID of this opcode as an integer
+func (ocw *opCodeWrapper) toNumber() int {
+ return int(ocw.op)
+}
+
+// toString returns the string representation of the opcode
+func (ocw *opCodeWrapper) toString() string {
+ return ocw.op.String()
+}
+
+// isPush returns true if the op is a Push
+func (ocw *opCodeWrapper) isPush() bool {
+ return ocw.op.IsPush()
+}
+
+// MarshalJSON serializes the opcode as JSON
+func (ocw *opCodeWrapper) MarshalJSON() ([]byte, error) {
+ return json.Marshal(ocw.op.String())
+}
+
+// toValue returns an otto.Value for the opCodeWrapper
+func (ocw *opCodeWrapper) toValue(vm *otto.Otto) otto.Value {
+ value, _ := vm.ToValue(ocw)
+ obj := value.Object()
+ obj.Set("toNumber", ocw.toNumber)
+ obj.Set("toString", ocw.toString)
+ obj.Set("isPush", ocw.isPush)
+ return value
+}
+
+// memoryWrapper provides a JS wrapper around vm.Memory
+type memoryWrapper struct {
+ memory *vm.Memory
+}
+
+// slice returns the requested range of memory as a byte slice
+func (mw *memoryWrapper) slice(begin, end int64) []byte {
+ return mw.memory.Get(begin, end-begin)
+}
+
+// getUint returns the 32 bytes at the specified address interpreted
+// as an unsigned integer
+func (mw *memoryWrapper) getUint(addr int64) *big.Int {
+ ret := big.NewInt(0)
+ ret.SetBytes(mw.memory.GetPtr(addr, 32))
+ return ret
+}
+
+// toValue returns an otto.Value for the memoryWrapper
+func (mw *memoryWrapper) toValue(vm *otto.Otto) otto.Value {
+ value, _ := vm.ToValue(mw)
+ obj := value.Object()
+ obj.Set("slice", mw.slice)
+ obj.Set("getUint", mw.getUint)
+ return value
+}
+
+// stackWrapper provides a JS wrapper around vm.Stack
+type stackWrapper struct {
+ stack *vm.Stack
+}
+
+// peek returns the nth-from-the-top element of the stack.
+func (sw *stackWrapper) peek(idx int) *big.Int {
+ return sw.stack.Data()[len(sw.stack.Data())-idx-1]
+}
+
+// length returns the length of the stack
+func (sw *stackWrapper) length() int {
+ return len(sw.stack.Data())
+}
+
+// toValue returns an otto.Value for the stackWrapper
+func (sw *stackWrapper) toValue(vm *otto.Otto) otto.Value {
+ value, _ := vm.ToValue(sw)
+ obj := value.Object()
+ obj.Set("peek", sw.peek)
+ obj.Set("length", sw.length)
+ return value
+}
+
+// dbWrapper provides a JS wrapper around vm.Database
+type dbWrapper struct {
+ db vm.Database
+}
+
+// getBalance retrieves an account's balance
+func (dw *dbWrapper) getBalance(addr common.Address) *big.Int {
+ return dw.db.GetBalance(addr)
+}
+
+// getNonce retrieves an account's nonce
+func (dw *dbWrapper) getNonce(addr common.Address) uint64 {
+ return dw.db.GetNonce(addr)
+}
+
+// getCode retrieves an account's code
+func (dw *dbWrapper) getCode(addr common.Address) []byte {
+ return dw.db.GetCode(addr)
+}
+
+// getState retrieves an account's state data for the given hash
+func (dw *dbWrapper) getState(addr common.Address, hash common.Hash) common.Hash {
+ return dw.db.GetState(addr, hash)
+}
+
+// exists returns true iff the account exists
+func (dw *dbWrapper) exists(addr common.Address) bool {
+ return dw.db.Exist(addr)
+}
+
+// toValue returns an otto.Value for the dbWrapper
+func (dw *dbWrapper) toValue(vm *otto.Otto) otto.Value {
+ value, _ := vm.ToValue(dw)
+ obj := value.Object()
+ obj.Set("getBalance", dw.getBalance)
+ obj.Set("getNonce", dw.getNonce)
+ obj.Set("getCode", dw.getCode)
+ obj.Set("getState", dw.getState)
+ obj.Set("exists", dw.exists)
+ return value
+}
+
+// JavascriptTracer provides an implementation of Tracer that evaluates a
+// Javascript function for each VM execution step.
+type JavascriptTracer struct {
+ vm *otto.Otto // Javascript VM instance
+ traceobj *otto.Object // User-supplied object to call
+ log map[string]interface{} // (Reusable) map for the `log` arg to `step`
+ logvalue otto.Value // JS view of `log`
+ memory *memoryWrapper // Wrapper around the VM memory
+ memvalue otto.Value // JS view of `memory`
+ stack *stackWrapper // Wrapper around the VM stack
+ stackvalue otto.Value // JS view of `stack`
+ db *dbWrapper // Wrapper around the VM environment
+ dbvalue otto.Value // JS view of `db`
+ err error // Error, if one has occurred
+}
+
+// NewJavascriptTracer instantiates a new JavascriptTracer instance.
+// code specifies a Javascript snippet, which must evaluate to an expression
+// returning an object with 'step' and 'result' functions.
+func NewJavascriptTracer(code string) (*JavascriptTracer, error) {
+ vm := otto.New()
+ vm.Interrupt = make(chan func(), 1)
+
+ // Set up builtins for this environment
+ vm.Set("big", &fakeBig{})
+
+ jstracer, err := vm.Object("(" + code + ")")
+ if err != nil {
+ return nil, err
+ }
+
+ // Check the required functions exist
+ step, err := jstracer.Get("step")
+ if err != nil {
+ return nil, err
+ }
+ if !step.IsFunction() {
+ return nil, fmt.Errorf("Trace object must expose a function step()")
+ }
+
+ result, err := jstracer.Get("result")
+ if err != nil {
+ return nil, err
+ }
+ if !result.IsFunction() {
+ return nil, fmt.Errorf("Trace object must expose a function result()")
+ }
+
+ // Create the persistent log object
+ log := make(map[string]interface{})
+ logvalue, _ := vm.ToValue(log)
+
+ // Create persistent wrappers for memory and stack
+ mem := &memoryWrapper{}
+ stack := &stackWrapper{}
+ db := &dbWrapper{}
+
+ return &JavascriptTracer{
+ vm: vm,
+ traceobj: jstracer,
+ log: log,
+ logvalue: logvalue,
+ memory: mem,
+ memvalue: mem.toValue(vm),
+ stack: stack,
+ stackvalue: stack.toValue(vm),
+ db: db,
+ dbvalue: db.toValue(vm),
+ err: nil,
+ }, nil
+}
+
+// Stop terminates execution of any JavaScript
+func (jst *JavascriptTracer) Stop(err error) {
+ jst.vm.Interrupt <- func() {
+ panic(err)
+ }
+}
+
+// callSafely executes a method on a JS object, catching any panics and
+// returning them as error objects.
+func (jst *JavascriptTracer) callSafely(method string, argumentList ...interface{}) (ret interface{}, err error) {
+ defer func() {
+ if caught := recover(); caught != nil {
+ switch caught := caught.(type) {
+ case error:
+ err = caught
+ case string:
+ err = errors.New(caught)
+ case fmt.Stringer:
+ err = errors.New(caught.String())
+ default:
+ panic(caught)
+ }
+ }
+ }()
+
+ value, err := jst.traceobj.Call(method, argumentList...)
+ ret, _ = value.Export()
+ return ret, err
+}
+
+func wrapError(context string, err error) error {
+ var message string
+ switch err := err.(type) {
+ case *otto.Error:
+ message = err.String()
+ default:
+ message = err.Error()
+ }
+ return fmt.Errorf("%v in server-side tracer function '%v'", message, context)
+}
+
+// CaptureState implements the Tracer interface to trace a single step of VM execution
+func (jst *JavascriptTracer) CaptureState(env vm.Environment, pc uint64, op vm.OpCode, gas, cost *big.Int, memory *vm.Memory, stack *vm.Stack, contract *vm.Contract, depth int, err error) {
+ if jst.err == nil {
+ jst.memory.memory = memory
+ jst.stack.stack = stack
+ jst.db.db = env.Db()
+
+ ocw := &opCodeWrapper{op}
+
+ jst.log["pc"] = pc
+ jst.log["op"] = ocw.toValue(jst.vm)
+ jst.log["gas"] = gas.Int64()
+ jst.log["gasPrice"] = cost.Int64()
+ jst.log["memory"] = jst.memvalue
+ jst.log["stack"] = jst.stackvalue
+ jst.log["depth"] = depth
+ jst.log["account"] = contract.Address()
+ jst.log["err"] = err
+
+ _, err := jst.callSafely("step", jst.logvalue, jst.dbvalue)
+ if err != nil {
+ jst.err = wrapError("step", err)
+ }
+ }
+}
+
+// GetResult calls the Javascript 'result' function and returns its value, or any accumulated error
+func (jst *JavascriptTracer) GetResult() (result interface{}, err error) {
+ if jst.err != nil {
+ return nil, jst.err
+ }
+
+ result, err = jst.callSafely("result")
+ if err != nil {
+ err = wrapError("result", err)
+ }
+ return
+}
diff --git a/internal/ethapi/tracer_test.go b/internal/ethapi/tracer_test.go
new file mode 100644
index 000000000..301ff4840
--- /dev/null
+++ b/internal/ethapi/tracer_test.go
@@ -0,0 +1,201 @@
+// Copyright 2016 The go-ethereum Authors
+// This file is part of the go-ethereum library.
+//
+// The go-ethereum library is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// The go-ethereum library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
+
+package ethapi
+
+import (
+ "errors"
+ "math/big"
+ "reflect"
+ "testing"
+ "time"
+
+ "github.com/ethereum/go-ethereum/common"
+ "github.com/ethereum/go-ethereum/core/vm"
+ "github.com/ethereum/go-ethereum/crypto"
+)
+
+type ruleSet struct{}
+
+func (self *ruleSet) IsHomestead(*big.Int) bool { return true }
+
+type Env struct {
+ gasLimit *big.Int
+ depth int
+ evm *vm.EVM
+}
+
+func NewEnv(config *vm.Config) *Env {
+ env := &Env{gasLimit: big.NewInt(10000), depth: 0}
+ env.evm = vm.New(env, *config)
+ return env
+}
+
+func (self *Env) RuleSet() vm.RuleSet { return &ruleSet{} }
+func (self *Env) Vm() vm.Vm { return self.evm }
+func (self *Env) Origin() common.Address { return common.Address{} }
+func (self *Env) BlockNumber() *big.Int { return big.NewInt(0) }
+
+//func (self *Env) PrevHash() []byte { return self.parent }
+func (self *Env) Coinbase() common.Address { return common.Address{} }
+func (self *Env) MakeSnapshot() vm.Database { return nil }
+func (self *Env) SetSnapshot(vm.Database) {}
+func (self *Env) Time() *big.Int { return big.NewInt(time.Now().Unix()) }
+func (self *Env) Difficulty() *big.Int { return big.NewInt(0) }
+func (self *Env) Db() vm.Database { return nil }
+func (self *Env) GasLimit() *big.Int { return self.gasLimit }
+func (self *Env) VmType() vm.Type { return vm.StdVmTy }
+func (self *Env) GetHash(n uint64) common.Hash {
+ return common.BytesToHash(crypto.Keccak256([]byte(big.NewInt(int64(n)).String())))
+}
+func (self *Env) AddLog(log *vm.Log) {
+}
+func (self *Env) Depth() int { return self.depth }
+func (self *Env) SetDepth(i int) { self.depth = i }
+func (self *Env) CanTransfer(from common.Address, balance *big.Int) bool {
+ return true
+}
+func (self *Env) Transfer(from, to vm.Account, amount *big.Int) {}
+func (self *Env) Call(caller vm.ContractRef, addr common.Address, data []byte, gas, price, value *big.Int) ([]byte, error) {
+ return nil, nil
+}
+func (self *Env) CallCode(caller vm.ContractRef, addr common.Address, data []byte, gas, price, value *big.Int) ([]byte, error) {
+ return nil, nil
+}
+func (self *Env) Create(caller vm.ContractRef, data []byte, gas, price, value *big.Int) ([]byte, common.Address, error) {
+ return nil, common.Address{}, nil
+}
+func (self *Env) DelegateCall(me vm.ContractRef, addr common.Address, data []byte, gas, price *big.Int) ([]byte, error) {
+ return nil, nil
+}
+
+type account struct{}
+
+func (account) SubBalance(amount *big.Int) {}
+func (account) AddBalance(amount *big.Int) {}
+func (account) SetAddress(common.Address) {}
+func (account) Value() *big.Int { return nil }
+func (account) SetBalance(*big.Int) {}
+func (account) SetNonce(uint64) {}
+func (account) Balance() *big.Int { return nil }
+func (account) Address() common.Address { return common.Address{} }
+func (account) ReturnGas(*big.Int, *big.Int) {}
+func (account) SetCode([]byte) {}
+func (account) ForEachStorage(cb func(key, value common.Hash) bool) {}
+
+func runTrace(tracer *JavascriptTracer) (interface{}, error) {
+ env := NewEnv(&vm.Config{Debug: true, Tracer: tracer})
+
+ contract := vm.NewContract(account{}, account{}, big.NewInt(0), env.GasLimit(), big.NewInt(1))
+ contract.Code = []byte{byte(vm.PUSH1), 0x1, byte(vm.PUSH1), 0x1, 0x0}
+
+ _, err := env.Vm().Run(contract, []byte{})
+ if err != nil {
+ return nil, err
+ }
+
+ return tracer.GetResult()
+}
+
+func TestTracing(t *testing.T) {
+ tracer, err := NewJavascriptTracer("{count: 0, step: function() { this.count += 1; }, result: function() { return this.count; }}")
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ ret, err := runTrace(tracer)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ value, ok := ret.(float64)
+ if !ok {
+ t.Errorf("Expected return value to be float64, was %T", ret)
+ }
+ if value != 3 {
+ t.Errorf("Expected return value to be 3, got %v", value)
+ }
+}
+
+func TestStack(t *testing.T) {
+ tracer, err := NewJavascriptTracer("{depths: [], step: function(log) { this.depths.push(log.stack.length()); }, result: function() { return this.depths; }}")
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ ret, err := runTrace(tracer)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ expected := []int{0, 1, 2}
+ if !reflect.DeepEqual(ret, expected) {
+ t.Errorf("Expected return value to be %#v, got %#v", expected, ret)
+ }
+}
+
+func TestOpcodes(t *testing.T) {
+ tracer, err := NewJavascriptTracer("{opcodes: [], step: function(log) { this.opcodes.push(log.op.toString()); }, result: function() { return this.opcodes; }}")
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ ret, err := runTrace(tracer)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ expected := []string{"PUSH1", "PUSH1", "STOP"}
+ if !reflect.DeepEqual(ret, expected) {
+ t.Errorf("Expected return value to be %#v, got %#v", expected, ret)
+ }
+}
+
+func TestHalt(t *testing.T) {
+ timeout := errors.New("stahp")
+ tracer, err := NewJavascriptTracer("{step: function() { while(1); }, result: function() { return null; }}")
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ go func() {
+ time.Sleep(1 * time.Second)
+ tracer.Stop(timeout)
+ }()
+
+ if _, err = runTrace(tracer); err.Error() != "stahp in server-side tracer function 'step'" {
+ t.Errorf("Expected timeout error, got %v", err)
+ }
+}
+
+func TestHaltBetweenSteps(t *testing.T) {
+ tracer, err := NewJavascriptTracer("{step: function() {}, result: function() { return null; }}")
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ env := NewEnv(&vm.Config{Debug: true, Tracer: tracer})
+ contract := vm.NewContract(&account{}, &account{}, big.NewInt(0), big.NewInt(0), big.NewInt(0))
+
+ tracer.CaptureState(env, 0, 0, big.NewInt(0), big.NewInt(0), nil, nil, contract, 0, nil)
+ timeout := errors.New("stahp")
+ tracer.Stop(timeout)
+ tracer.CaptureState(env, 0, 0, big.NewInt(0), big.NewInt(0), nil, nil, contract, 0, nil)
+
+ if _, err := tracer.GetResult(); err.Error() != "stahp in server-side tracer function 'step'" {
+ t.Errorf("Expected timeout error, got %v", err)
+ }
+}