aboutsummaryrefslogtreecommitdiffstats
path: root/internal
diff options
context:
space:
mode:
authorNick Johnson <arachnid@notdot.net>2016-08-19 22:19:51 +0800
committerNick Johnson <arachnid@notdot.net>2016-08-22 16:26:15 +0800
commit781915f183c6e09474c6192d1aaba8e99c4990de (patch)
tree572ae2ca95d46c8a37e12a3d03cf3058caf06740 /internal
parent475521dd747070372f84c2b0ac202e14216dc0e0 (diff)
downloadgo-tangerine-781915f183c6e09474c6192d1aaba8e99c4990de.tar.gz
go-tangerine-781915f183c6e09474c6192d1aaba8e99c4990de.tar.zst
go-tangerine-781915f183c6e09474c6192d1aaba8e99c4990de.zip
core/vm: Refactor tracing to make Tracer the main interface
This CL makes several refactors: - Define a Tracer interface, implementing the `CaptureState` method - Add the VM environment as the first argument of `Tracer.CaptureState` - Rename existing functionality `StructLogger` an make it an implementation of `Tracer` - Delete `StructLogCollector` and make `StructLogger` collect the logs directly - Change all callers to use the new `StructLogger` where necessary and extract logs from that. - Deletes the apparently obsolete and likely nonfunctional 'TraceCall' from the eth API. Callers that only wish accumulated logs can use the `StructLogger` implementation straightforwardly. Callers that wish to efficiently capture VM traces and operate on them without excessive copying can now implement the `Tracer` interface to receive VM state at each step and do with it as they wish. This CL also removes the accumulation of logs from the vm.Environment; this was necessary as part of the refactor, but also simplifies it by removing a responsibility that doesn't directly belong to the Environment.
Diffstat (limited to 'internal')
-rw-r--r--internal/ethapi/api.go54
1 files changed, 0 insertions, 54 deletions
diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go
index ca825ad89..135f9f8e8 100644
--- a/internal/ethapi/api.go
+++ b/internal/ethapi/api.go
@@ -584,60 +584,6 @@ 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.