diff --git a/core/vm/evm.go b/core/vm/evm.go index cbb5a03ce789..a3f3a97cbc91 100644 --- a/core/vm/evm.go +++ b/core/vm/evm.go @@ -19,6 +19,7 @@ package vm import ( "math/big" "sync/atomic" + "time" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" @@ -165,13 +166,23 @@ func (evm *EVM) Call(caller ContractRef, addr common.Address, input []byte, gas } evm.Transfer(evm.StateDB, caller.Address(), to.Address(), value) - // initialise a new contract and set the code that is to be used by the - // E The contract is a scoped environment for this execution context - // only. + // Initialise a new contract and set the code that is to be used by the EVM. + // The contract is a scoped environment for this execution context only. contract := NewContract(caller, to, value, gas) contract.SetCallCode(&addr, evm.StateDB.GetCodeHash(addr), evm.StateDB.GetCode(addr)) + start := time.Now() + + // Capture the tracer start/end events in debug mode + if evm.vmConfig.Debug && evm.depth == 0 { + evm.vmConfig.Tracer.CaptureStart(caller.Address(), addr, false, input, gas, value) + + defer func() { // Lazy evaluation of the parameters + evm.vmConfig.Tracer.CaptureEnd(ret, gas-contract.Gas, time.Since(start), err) + }() + } ret, err = run(evm, contract, input) + // When an error was returned by the EVM or when setting the creation code // above we revert to the snapshot and consume any gas remaining. Additionally // when we're in homestead this also counts for code storage gas errors. @@ -338,7 +349,14 @@ func (evm *EVM) Create(caller ContractRef, code []byte, gas uint64, value *big.I if evm.vmConfig.NoRecursion && evm.depth > 0 { return nil, contractAddr, gas, nil } + + if evm.vmConfig.Debug && evm.depth == 0 { + evm.vmConfig.Tracer.CaptureStart(caller.Address(), contractAddr, true, code, gas, value) + } + start := time.Now() + ret, err = run(evm, contract, nil) + // check whether the max code size has been exceeded maxCodeSizeExceeded := evm.ChainConfig().IsEIP158(evm.BlockNumber) && len(ret) > params.MaxCodeSize // if the contract creation ran successfully and no errors were returned @@ -367,6 +385,9 @@ func (evm *EVM) Create(caller ContractRef, code []byte, gas uint64, value *big.I if maxCodeSizeExceeded && err == nil { err = errMaxCodeSizeExceeded } + if evm.vmConfig.Debug && evm.depth == 0 { + evm.vmConfig.Tracer.CaptureEnd(ret, gas-contract.Gas, time.Since(start), err) + } return ret, contractAddr, contract.Gas, err } diff --git a/core/vm/logger.go b/core/vm/logger.go old mode 100755 new mode 100644 index 1ed4c56a8665..1a6e43ee3042 --- a/core/vm/logger.go +++ b/core/vm/logger.go @@ -1,7 +1,7 @@ -// Copyright 2015 The go-nilu Authors -// This file is part of the go-nilu library. +// Copyright 2015 The go-ethereum Authors +// This file is part of the go-ethereum library. // -// The go-nilu library is free software: you can redistribute it and/or modify +// 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. @@ -23,10 +23,10 @@ import ( "math/big" "time" - "github.com/NiluPlatform/go-nilu/common" - "github.com/NiluPlatform/go-nilu/common/hexutil" - "github.com/NiluPlatform/go-nilu/common/math" - "github.com/NiluPlatform/go-nilu/core/types" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/common/hexutil" + "github.com/ethereum/go-ethereum/common/math" + "github.com/ethereum/go-ethereum/core/types" ) type Storage map[common.Hash]common.Hash @@ -62,30 +62,22 @@ type StructLog struct { Stack []*big.Int `json:"stack"` Storage map[common.Hash]common.Hash `json:"-"` Depth int `json:"depth"` - Err error `json:"-"` + Err error `json:"error"` } // overrides for gencodec type structLogMarshaling struct { - Stack []*math.HexOrDecimal256 - Gas math.HexOrDecimal64 - GasCost math.HexOrDecimal64 - Memory hexutil.Bytes - OpName string `json:"opName"` // adds call to OpName() in MarshalJSON - ErrorString string `json:"error"` // adds call to ErrorString() in MarshalJSON + Stack []*math.HexOrDecimal256 + Gas math.HexOrDecimal64 + GasCost math.HexOrDecimal64 + Memory hexutil.Bytes + OpName string `json:"opName"` } func (s *StructLog) OpName() string { return s.Op.String() } -func (s *StructLog) ErrorString() string { - if s.Err != nil { - return s.Err.Error() - } - return "" -} - // Tracer is used to collect execution traces from an EVM transaction // execution. CaptureState is called for each step of the VM with the // current VM state. @@ -108,8 +100,6 @@ type StructLogger struct { logs []StructLog changedValues map[common.Address]Storage - output []byte - err error } // NewStructLogger returns a new logger @@ -182,19 +172,17 @@ func (l *StructLogger) CaptureFault(env *EVM, pc uint64, op OpCode, gas, cost ui } func (l *StructLogger) CaptureEnd(output []byte, gasUsed uint64, t time.Duration, err error) error { - l.output = output - l.err = err + fmt.Printf("0x%x", output) + if err != nil { + fmt.Printf(" error: %v\n", err) + } return nil } -// StructLogs returns the captured log entries. -func (l *StructLogger) StructLogs() []StructLog { return l.logs } - -// Error returns the VM error captured by the trace. -func (l *StructLogger) Error() error { return l.err } - -// Output returns the VM return value captured by the trace. -func (l *StructLogger) Output() []byte { return l.output } +// StructLogs returns a list of captured log entries +func (l *StructLogger) StructLogs() []StructLog { + return l.logs +} // WriteTrace writes a formatted trace to the given writer func WriteTrace(writer io.Writer, logs []StructLog) { diff --git a/eth/api.go b/eth/api.go index c748f75de407..0db3eb5548c0 100644 --- a/eth/api.go +++ b/eth/api.go @@ -17,24 +17,19 @@ package eth import ( - "bytes" "compress/gzip" "context" "fmt" "io" - "io/ioutil" "math/big" "os" "strings" - "time" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/core/vm" - "github.com/ethereum/go-ethereum/internal/ethapi" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/miner" "github.com/ethereum/go-ethereum/params" @@ -43,8 +38,6 @@ import ( "github.com/ethereum/go-ethereum/trie" ) -const defaultTraceTimeout = 5 * time.Second - // PublicEthereumAPI provides an API to access Ethereum full node-related // information. type PublicEthereumAPI struct { @@ -348,248 +341,6 @@ func NewPrivateDebugAPI(config *params.ChainConfig, eth *Ethereum) *PrivateDebug return &PrivateDebugAPI{config: config, eth: eth} } -// BlockTraceResult is the returned value when replaying a block to check for -// consensus results and full VM trace logs for all included transactions. -type BlockTraceResult struct { - Validated bool `json:"validated"` - StructLogs []ethapi.StructLogRes `json:"structLogs"` - Error string `json:"error"` -} - -// TraceArgs holds extra parameters to trace functions -type TraceArgs struct { - *vm.LogConfig - Tracer *string - Timeout *string -} - -// TraceBlock processes the given block'api RLP but does not import the block in to -// the chain. -func (api *PrivateDebugAPI) TraceBlock(blockRlp []byte, config *vm.LogConfig) BlockTraceResult { - var block types.Block - err := rlp.Decode(bytes.NewReader(blockRlp), &block) - if err != nil { - return BlockTraceResult{Error: fmt.Sprintf("could not decode block: %v", err)} - } - - validated, logs, err := api.traceBlock(&block, config) - return BlockTraceResult{ - Validated: validated, - StructLogs: ethapi.FormatLogs(logs), - Error: formatError(err), - } -} - -// TraceBlockFromFile loads the block'api RLP from the given file name and attempts to -// process it but does not import the block in to the chain. -func (api *PrivateDebugAPI) TraceBlockFromFile(file string, config *vm.LogConfig) BlockTraceResult { - blockRlp, err := ioutil.ReadFile(file) - if err != nil { - return BlockTraceResult{Error: fmt.Sprintf("could not read file: %v", err)} - } - return api.TraceBlock(blockRlp, config) -} - -// TraceBlockByNumber processes the block by canonical block number. -func (api *PrivateDebugAPI) TraceBlockByNumber(blockNr rpc.BlockNumber, config *vm.LogConfig) BlockTraceResult { - // Fetch the block that we aim to reprocess - var block *types.Block - switch blockNr { - case rpc.PendingBlockNumber: - // Pending block is only known by the miner - block = api.eth.miner.PendingBlock() - case rpc.LatestBlockNumber: - block = api.eth.blockchain.CurrentBlock() - default: - block = api.eth.blockchain.GetBlockByNumber(uint64(blockNr)) - } - - if block == nil { - return BlockTraceResult{Error: fmt.Sprintf("block #%d not found", blockNr)} - } - - validated, logs, err := api.traceBlock(block, config) - return BlockTraceResult{ - Validated: validated, - StructLogs: ethapi.FormatLogs(logs), - Error: formatError(err), - } -} - -// TraceBlockByHash processes the block by hash. -func (api *PrivateDebugAPI) TraceBlockByHash(hash common.Hash, config *vm.LogConfig) BlockTraceResult { - // Fetch the block that we aim to reprocess - block := api.eth.BlockChain().GetBlockByHash(hash) - if block == nil { - return BlockTraceResult{Error: fmt.Sprintf("block #%x not found", hash)} - } - - validated, logs, err := api.traceBlock(block, config) - return BlockTraceResult{ - Validated: validated, - StructLogs: ethapi.FormatLogs(logs), - Error: formatError(err), - } -} - -// traceBlock processes the given block but does not save the state. -func (api *PrivateDebugAPI) traceBlock(block *types.Block, logConfig *vm.LogConfig) (bool, []vm.StructLog, error) { - // Validate and reprocess the block - var ( - blockchain = api.eth.BlockChain() - validator = blockchain.Validator() - processor = blockchain.Processor() - ) - - structLogger := vm.NewStructLogger(logConfig) - - config := vm.Config{ - Debug: true, - Tracer: structLogger, - } - if err := api.eth.engine.VerifyHeader(blockchain, block.Header(), true); err != nil { - return false, structLogger.StructLogs(), err - } - statedb, err := blockchain.StateAt(blockchain.GetBlock(block.ParentHash(), block.NumberU64()-1).Root()) - if err != nil { - switch err.(type) { - case *trie.MissingNodeError: - return false, structLogger.StructLogs(), fmt.Errorf("required historical state unavailable") - default: - return false, structLogger.StructLogs(), err - } - } - - receipts, _, usedGas, err := processor.Process(block, statedb, config) - if err != nil { - return false, structLogger.StructLogs(), err - } - if err := validator.ValidateState(block, blockchain.GetBlock(block.ParentHash(), block.NumberU64()-1), statedb, receipts, usedGas); err != nil { - return false, structLogger.StructLogs(), err - } - return true, structLogger.StructLogs(), nil -} - -// formatError formats a Go error into either an empty string or the data content -// of the error itself. -func formatError(err error) string { - if err == nil { - return "" - } - return err.Error() -} - -type timeoutError struct{} - -func (t *timeoutError) Error() string { - return "Execution time exceeded" -} - -// 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 vm.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 = ethapi.NewJavascriptTracer(*config.Tracer); err != nil { - return nil, err - } - - // Handle timeouts and RPC cancellations - deadlineCtx, cancel := context.WithTimeout(ctx, timeout) - go func() { - <-deadlineCtx.Done() - tracer.(*ethapi.JavascriptTracer).Stop(&timeoutError{}) - }() - defer cancel() - } else if config == nil { - tracer = vm.NewStructLogger(nil) - } else { - tracer = vm.NewStructLogger(config.LogConfig) - } - - // Retrieve the tx from the chain and the containing block - tx, blockHash, _, txIndex := core.GetTransaction(api.eth.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 { - switch err.(type) { - case *trie.MissingNodeError: - return nil, fmt.Errorf("required historical state unavailable") - default: - return nil, err - } - } - - // Run the transaction with tracing enabled. - vmenv := vm.NewEVM(context, statedb, api.config, vm.Config{Debug: true, Tracer: tracer}) - ret, gas, failed, err := core.ApplyMessage(vmenv, msg, new(core.GasPool).AddGas(tx.Gas())) - if err != nil { - return nil, fmt.Errorf("tracing failed: %v", err) - } - switch tracer := tracer.(type) { - case *vm.StructLogger: - return ðapi.ExecutionResult{ - Gas: gas, - Failed: failed, - ReturnValue: fmt.Sprintf("%x", ret), - StructLogs: ethapi.FormatLogs(tracer.StructLogs()), - }, nil - case *ethapi.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) (core.Message, vm.Context, *state.StateDB, error) { - // Create the parent state. - block := api.eth.BlockChain().GetBlockByHash(blockHash) - if block == nil { - return nil, vm.Context{}, nil, fmt.Errorf("block %x not found", blockHash) - } - parent := api.eth.BlockChain().GetBlock(block.ParentHash(), block.NumberU64()-1) - if parent == nil { - return nil, vm.Context{}, nil, fmt.Errorf("block parent %x not found", block.ParentHash()) - } - statedb, err := api.eth.BlockChain().StateAt(parent.Root()) - if err != nil { - return nil, vm.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 := core.NewEVMContext(msg, block.Header(), api.eth.BlockChain(), nil) - if idx == txIndex { - return msg, context, statedb, nil - } - - vmenv := vm.NewEVM(context, statedb, api.config, vm.Config{}) - gp := new(core.GasPool).AddGas(tx.Gas()) - _, _, _, err := core.ApplyMessage(vmenv, msg, gp) - if err != nil { - return nil, vm.Context{}, nil, fmt.Errorf("tx %x failed: %v", tx.Hash(), err) - } - statedb.DeleteSuicides() - } - return nil, vm.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 (api *PrivateDebugAPI) Preimage(ctx context.Context, hash common.Hash) (hexutil.Bytes, error) { db := core.PreimageTable(api.eth.ChainDb()) @@ -617,7 +368,7 @@ type storageEntry struct { // StorageRangeAt returns the storage at the given block height and transaction index. func (api *PrivateDebugAPI) StorageRangeAt(ctx context.Context, blockHash common.Hash, txIndex int, contractAddress common.Address, keyStart hexutil.Bytes, maxResult int) (StorageRangeResult, error) { - _, _, statedb, err := api.computeTxEnv(blockHash, txIndex) + _, _, statedb, err := api.computeTxEnv(blockHash, txIndex, 0) if err != nil { return StorageRangeResult{}, err } diff --git a/eth/api_tracer.go b/eth/api_tracer.go old mode 100755 new mode 100644 index 3e8d5a182710..0d0e2a73c33e --- a/eth/api_tracer.go +++ b/eth/api_tracer.go @@ -27,19 +27,19 @@ import ( "sync/atomic" "time" - "github.com/NiluPlatform/go-nilu/common" - "github.com/NiluPlatform/go-nilu/common/hexutil" - "github.com/NiluPlatform/go-nilu/core" - "github.com/NiluPlatform/go-nilu/core/state" - "github.com/NiluPlatform/go-nilu/core/types" - "github.com/NiluPlatform/go-nilu/core/vm" - "github.com/NiluPlatform/go-nilu/eth/tracers" - "github.com/NiluPlatform/go-nilu/ethdb" - "github.com/NiluPlatform/go-nilu/internal/ethapi" - "github.com/NiluPlatform/go-nilu/log" - "github.com/NiluPlatform/go-nilu/rlp" - "github.com/NiluPlatform/go-nilu/rpc" - "github.com/NiluPlatform/go-nilu/trie" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/common/hexutil" + "github.com/ethereum/go-ethereum/core" + "github.com/ethereum/go-ethereum/core/state" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/core/vm" + "github.com/ethereum/go-ethereum/eth/tracers" + "github.com/ethereum/go-ethereum/ethdb" + "github.com/ethereum/go-ethereum/internal/ethapi" + "github.com/ethereum/go-ethereum/log" + "github.com/ethereum/go-ethereum/rlp" + "github.com/ethereum/go-ethereum/rpc" + "github.com/ethereum/go-ethereum/trie" ) const ( @@ -204,7 +204,7 @@ func (api *PrivateDebugAPI) traceChain(ctx context.Context, start, end *types.Bl if err != nil { // If the starting state is missing, allow some number of blocks to be reexecuted reexec := defaultTraceReexec - if config != nil && config.Reexec != nil { + if config.Reexec != nil { reexec = *config.Reexec } // Find the most recent block that has the state available @@ -465,7 +465,7 @@ func (api *PrivateDebugAPI) traceBlock(ctx context.Context, block *types.Block, return nil, fmt.Errorf("parent %x not found", block.ParentHash()) } reexec := defaultTraceReexec - if config != nil && config.Reexec != nil { + if config.Reexec != nil { reexec = *config.Reexec } statedb, err := api.computeStateDB(parent, reexec) @@ -619,7 +619,7 @@ func (api *PrivateDebugAPI) TraceTransaction(ctx context.Context, hash common.Ha return nil, fmt.Errorf("transaction %x not found", hash) } reexec := defaultTraceReexec - if config != nil && config.Reexec != nil { + if config.Reexec != nil { reexec = *config.Reexec } msg, vmctx, statedb, err := api.computeTxEnv(blockHash, int(index), reexec) diff --git a/eth/handler.go b/eth/handler.go old mode 100755 new mode 100644 index 19146c32b3d0..cd66662d8fd1 --- a/eth/handler.go +++ b/eth/handler.go @@ -26,20 +26,20 @@ import ( "sync/atomic" "time" - "github.com/NiluPlatform/go-nilu/common" - "github.com/NiluPlatform/go-nilu/consensus" - "github.com/NiluPlatform/go-nilu/consensus/misc" - "github.com/NiluPlatform/go-nilu/core" - "github.com/NiluPlatform/go-nilu/core/types" - "github.com/NiluPlatform/go-nilu/eth/downloader" - "github.com/NiluPlatform/go-nilu/eth/fetcher" - "github.com/NiluPlatform/go-nilu/ethdb" - "github.com/NiluPlatform/go-nilu/event" - "github.com/NiluPlatform/go-nilu/log" - "github.com/NiluPlatform/go-nilu/p2p" - "github.com/NiluPlatform/go-nilu/p2p/discover" - "github.com/NiluPlatform/go-nilu/params" - "github.com/NiluPlatform/go-nilu/rlp" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/consensus" + "github.com/ethereum/go-ethereum/consensus/misc" + "github.com/ethereum/go-ethereum/core" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/eth/downloader" + "github.com/ethereum/go-ethereum/eth/fetcher" + "github.com/ethereum/go-ethereum/ethdb" + "github.com/ethereum/go-ethereum/event" + "github.com/ethereum/go-ethereum/log" + "github.com/ethereum/go-ethereum/p2p" + "github.com/ethereum/go-ethereum/p2p/discover" + "github.com/ethereum/go-ethereum/params" + "github.com/ethereum/go-ethereum/rlp" ) const ( @@ -394,14 +394,14 @@ func (pm *ProtocolManager) handleMsg(p *peer) error { case query.Reverse: // Number based traversal towards the genesis block if query.Origin.Number >= query.Skip+1 { - query.Origin.Number -= query.Skip + 1 + query.Origin.Number -= (query.Skip + 1) } else { unknown = true } case !query.Reverse: // Number based traversal towards the leaf block - query.Origin.Number += query.Skip + 1 + query.Origin.Number += (query.Skip + 1) } } return p.SendBlockHeaders(headers) @@ -744,10 +744,10 @@ func (self *ProtocolManager) txBroadcastLoop() { } } -// NodeInfo represents a short summary of the Ethereum sub-protocol metadata -// known about the host peer. -type NodeInfo struct { - Network uint64 `json:"network"` // Ethereum network ID (1=Frontier, 2=Morden, Ropsten=3, Rinkeby=4) +// EthNodeInfo represents a short summary of the Ethereum sub-protocol metadata known +// about the host peer. +type EthNodeInfo struct { + Network uint64 `json:"network"` // Ethereum network ID (1=Frontier, 2=Morden, Ropsten=3) Difficulty *big.Int `json:"difficulty"` // Total difficulty of the host's blockchain Genesis common.Hash `json:"genesis"` // SHA3 hash of the host's genesis block Config *params.ChainConfig `json:"config"` // Chain configuration for the fork rules @@ -755,9 +755,9 @@ type NodeInfo struct { } // NodeInfo retrieves some protocol metadata about the running host node. -func (self *ProtocolManager) NodeInfo() *NodeInfo { +func (self *ProtocolManager) NodeInfo() *EthNodeInfo { currentBlock := self.blockchain.CurrentBlock() - return &NodeInfo{ + return &EthNodeInfo{ Network: self.networkId, Difficulty: self.blockchain.GetTd(currentBlock.Hash(), currentBlock.NumberU64()), Genesis: self.blockchain.Genesis().Hash(), diff --git a/eth/tracers/internal/tracers/4byte_tracer.js b/eth/tracers/internal/tracers/4byte_tracer.js old mode 100755 new mode 100644 diff --git a/eth/tracers/internal/tracers/assets.go b/eth/tracers/internal/tracers/assets.go old mode 100755 new mode 100644 index 1912f74edd6b..cb0421008c13 --- a/eth/tracers/internal/tracers/assets.go +++ b/eth/tracers/internal/tracers/assets.go @@ -1,4 +1,4 @@ -// Code generated by go-bindata. DO NOT EDIT. +// Code generated by go-bindata. // sources: // 4byte_tracer.js // call_tracer.js @@ -6,6 +6,7 @@ // noop_tracer.js // opcount_tracer.js // prestate_tracer.js +// DO NOT EDIT! package tracers @@ -196,8 +197,8 @@ func prestate_tracerJs() (*asset, error) { // It returns an error if the asset could not be found or // could not be loaded. func Asset(name string) ([]byte, error) { - canonicalName := strings.Replace(name, "\\", "/", -1) - if f, ok := _bindata[canonicalName]; ok { + cannonicalName := strings.Replace(name, "\\", "/", -1) + if f, ok := _bindata[cannonicalName]; ok { a, err := f() if err != nil { return nil, fmt.Errorf("Asset %s can't read by error: %v", name, err) @@ -222,8 +223,8 @@ func MustAsset(name string) []byte { // It returns an error if the asset could not be found or // could not be loaded. func AssetInfo(name string) (os.FileInfo, error) { - canonicalName := strings.Replace(name, "\\", "/", -1) - if f, ok := _bindata[canonicalName]; ok { + cannonicalName := strings.Replace(name, "\\", "/", -1) + if f, ok := _bindata[cannonicalName]; ok { a, err := f() if err != nil { return nil, fmt.Errorf("AssetInfo %s can't read by error: %v", name, err) @@ -244,16 +245,11 @@ func AssetNames() []string { // _bindata is a table, holding each asset generator, mapped to its name. var _bindata = map[string]func() (*asset, error){ - "4byte_tracer.js": _4byte_tracerJs, - - "call_tracer.js": call_tracerJs, - - "evmdis_tracer.js": evmdis_tracerJs, - - "noop_tracer.js": noop_tracerJs, - - "opcount_tracer.js": opcount_tracerJs, - + "4byte_tracer.js": _4byte_tracerJs, + "call_tracer.js": call_tracerJs, + "evmdis_tracer.js": evmdis_tracerJs, + "noop_tracer.js": noop_tracerJs, + "opcount_tracer.js": opcount_tracerJs, "prestate_tracer.js": prestate_tracerJs, } @@ -273,8 +269,8 @@ var _bindata = map[string]func() (*asset, error){ func AssetDir(name string) ([]string, error) { node := _bintree if len(name) != 0 { - canonicalName := strings.Replace(name, "\\", "/", -1) - pathList := strings.Split(canonicalName, "/") + cannonicalName := strings.Replace(name, "\\", "/", -1) + pathList := strings.Split(cannonicalName, "/") for _, p := range pathList { node = node.Children[p] if node == nil { @@ -324,7 +320,11 @@ func RestoreAsset(dir, name string) error { if err != nil { return err } - return os.Chtimes(_filePath(dir, name), info.ModTime(), info.ModTime()) + err = os.Chtimes(_filePath(dir, name), info.ModTime(), info.ModTime()) + if err != nil { + return err + } + return nil } // RestoreAssets restores an asset under the given directory recursively @@ -345,6 +345,6 @@ func RestoreAssets(dir, name string) error { } func _filePath(dir, name string) string { - canonicalName := strings.Replace(name, "\\", "/", -1) - return filepath.Join(append([]string{dir}, strings.Split(canonicalName, "/")...)...) + cannonicalName := strings.Replace(name, "\\", "/", -1) + return filepath.Join(append([]string{dir}, strings.Split(cannonicalName, "/")...)...) } diff --git a/eth/tracers/internal/tracers/call_tracer.js b/eth/tracers/internal/tracers/call_tracer.js old mode 100755 new mode 100644 diff --git a/eth/tracers/internal/tracers/evmdis_tracer.js b/eth/tracers/internal/tracers/evmdis_tracer.js old mode 100755 new mode 100644 diff --git a/eth/tracers/internal/tracers/noop_tracer.js b/eth/tracers/internal/tracers/noop_tracer.js old mode 100755 new mode 100644 diff --git a/eth/tracers/internal/tracers/opcount_tracer.js b/eth/tracers/internal/tracers/opcount_tracer.js old mode 100755 new mode 100644 diff --git a/eth/tracers/internal/tracers/prestate_tracer.js b/eth/tracers/internal/tracers/prestate_tracer.js old mode 100755 new mode 100644 diff --git a/eth/tracers/internal/tracers/tracers.go b/eth/tracers/internal/tracers/tracers.go old mode 100755 new mode 100644 diff --git a/eth/tracers/testdata/call_tracer_create.json b/eth/tracers/testdata/call_tracer_create.json old mode 100755 new mode 100644 diff --git a/eth/tracers/testdata/call_tracer_deep_calls.json b/eth/tracers/testdata/call_tracer_deep_calls.json old mode 100755 new mode 100644 diff --git a/eth/tracers/testdata/call_tracer_delegatecall.json b/eth/tracers/testdata/call_tracer_delegatecall.json old mode 100755 new mode 100644 diff --git a/eth/tracers/testdata/call_tracer_inner_create_oog_outer_throw.json b/eth/tracers/testdata/call_tracer_inner_create_oog_outer_throw.json old mode 100755 new mode 100644 diff --git a/eth/tracers/testdata/call_tracer_inner_throw_outer_revert.json b/eth/tracers/testdata/call_tracer_inner_throw_outer_revert.json old mode 100755 new mode 100644 diff --git a/eth/tracers/testdata/call_tracer_oog.json b/eth/tracers/testdata/call_tracer_oog.json old mode 100755 new mode 100644 diff --git a/eth/tracers/testdata/call_tracer_revert.json b/eth/tracers/testdata/call_tracer_revert.json old mode 100755 new mode 100644 diff --git a/eth/tracers/testdata/call_tracer_simple.json b/eth/tracers/testdata/call_tracer_simple.json old mode 100755 new mode 100644 diff --git a/eth/tracers/testdata/call_tracer_throw.json b/eth/tracers/testdata/call_tracer_throw.json old mode 100755 new mode 100644 diff --git a/eth/tracers/tracer.go b/eth/tracers/tracer.go old mode 100755 new mode 100644 index 28becf2131d5..f3f848fc1b91 --- a/eth/tracers/tracer.go +++ b/eth/tracers/tracer.go @@ -25,11 +25,11 @@ import ( "time" "unsafe" - "github.com/NiluPlatform/go-nilu/common" - "github.com/NiluPlatform/go-nilu/common/hexutil" - "github.com/NiluPlatform/go-nilu/core/vm" - "github.com/NiluPlatform/go-nilu/crypto" - "github.com/NiluPlatform/go-nilu/log" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/common/hexutil" + "github.com/ethereum/go-ethereum/core/vm" + "github.com/ethereum/go-ethereum/crypto" + "github.com/ethereum/go-ethereum/log" duktape "gopkg.in/olebedev/go-duktape.v3" ) diff --git a/eth/tracers/tracers.go b/eth/tracers/tracers.go old mode 100755 new mode 100644 index 5524d64ee396..4e1ef23ad2f8 --- a/eth/tracers/tracers.go +++ b/eth/tracers/tracers.go @@ -21,7 +21,7 @@ import ( "strings" "unicode" - "github.com/NiluPlatform/go-nilu/eth/tracers/internal/tracers" + "github.com/ethereum/go-ethereum/eth/tracers/internal/tracers" ) // all contains all the built in JavaScript tracers by name. diff --git a/eth/tracers/tracers_test.go b/eth/tracers/tracers_test.go old mode 100755 new mode 100644 index 629fa27b7991..1392807978ef --- a/eth/tracers/tracers_test.go +++ b/eth/tracers/tracers_test.go @@ -25,15 +25,15 @@ import ( "strings" "testing" - "github.com/NiluPlatform/go-nilu/common" - "github.com/NiluPlatform/go-nilu/common/hexutil" - "github.com/NiluPlatform/go-nilu/common/math" - "github.com/NiluPlatform/go-nilu/core" - "github.com/NiluPlatform/go-nilu/core/types" - "github.com/NiluPlatform/go-nilu/core/vm" - "github.com/NiluPlatform/go-nilu/ethdb" - "github.com/NiluPlatform/go-nilu/rlp" - "github.com/NiluPlatform/go-nilu/tests" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/common/hexutil" + "github.com/ethereum/go-ethereum/common/math" + "github.com/ethereum/go-ethereum/core" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/core/vm" + "github.com/ethereum/go-ethereum/ethdb" + "github.com/ethereum/go-ethereum/rlp" + "github.com/ethereum/go-ethereum/tests" ) // To generate a new callTracer test, copy paste the makeTest method below into @@ -156,7 +156,7 @@ func TestCallTracer(t *testing.T) { BlockNumber: new(big.Int).SetUint64(uint64(test.Context.Number)), Time: new(big.Int).SetUint64(uint64(test.Context.Time)), Difficulty: (*big.Int)(test.Context.Difficulty), - GasLimit: uint64(test.Context.GasLimit), + GasLimit: new(big.Int).SetUint64(uint64(test.Context.GasLimit)), GasPrice: tx.GasPrice(), } db, _ := ethdb.NewMemDatabase() @@ -174,7 +174,7 @@ func TestCallTracer(t *testing.T) { t.Fatalf("failed to prepare transaction for tracing: %v", err) } st := core.NewStateTransition(evm, msg, new(core.GasPool).AddGas(tx.Gas())) - if _, _, _, err = st.TransitionDb(); err != nil { + if _, _, _, _, err = st.TransitionDb(); err != nil { t.Fatalf("failed to execute transaction: %v", err) } // Retrieve the trace result and compare against the etalon diff --git a/vendor/gopkg.in/olebedev/go-duktape.v3/Gopkg.lock b/vendor/gopkg.in/olebedev/go-duktape.v3/Gopkg.lock old mode 100755 new mode 100644 diff --git a/vendor/gopkg.in/olebedev/go-duktape.v3/Gopkg.toml b/vendor/gopkg.in/olebedev/go-duktape.v3/Gopkg.toml old mode 100755 new mode 100644 diff --git a/vendor/gopkg.in/olebedev/go-duktape.v3/LICENSE.md b/vendor/gopkg.in/olebedev/go-duktape.v3/LICENSE.md old mode 100755 new mode 100644 diff --git a/vendor/gopkg.in/olebedev/go-duktape.v3/README.md b/vendor/gopkg.in/olebedev/go-duktape.v3/README.md old mode 100755 new mode 100644 diff --git a/vendor/gopkg.in/olebedev/go-duktape.v3/api.go b/vendor/gopkg.in/olebedev/go-duktape.v3/api.go old mode 100755 new mode 100644 diff --git a/vendor/gopkg.in/olebedev/go-duktape.v3/appveyor.yml b/vendor/gopkg.in/olebedev/go-duktape.v3/appveyor.yml old mode 100755 new mode 100644 diff --git a/vendor/gopkg.in/olebedev/go-duktape.v3/conts.go b/vendor/gopkg.in/olebedev/go-duktape.v3/conts.go old mode 100755 new mode 100644 diff --git a/vendor/gopkg.in/olebedev/go-duktape.v3/duktape.go b/vendor/gopkg.in/olebedev/go-duktape.v3/duktape.go old mode 100755 new mode 100644 diff --git a/vendor/gopkg.in/olebedev/go-duktape.v3/timers.go b/vendor/gopkg.in/olebedev/go-duktape.v3/timers.go old mode 100755 new mode 100644 diff --git a/vendor/gopkg.in/olebedev/go-duktape.v3/utils.go b/vendor/gopkg.in/olebedev/go-duktape.v3/utils.go old mode 100755 new mode 100644 diff --git a/vendor/gopkg.in/olebedev/go-duktape.v3/wercker.yml b/vendor/gopkg.in/olebedev/go-duktape.v3/wercker.yml old mode 100755 new mode 100644