removed fmt print and added shyft tag to tracer fns

This commit is contained in:
Dustin Brickwood 2018-07-15 13:13:41 -04:00
parent b9dda84e30
commit 4158caece6
5 changed files with 17 additions and 41 deletions

View file

@ -46,7 +46,6 @@ import (
"github.com/ethereum/go-ethereum/trie"
"github.com/hashicorp/golang-lru"
"gopkg.in/karalabe/cookiejar.v2/collections/prque"
"runtime"
)
var (
@ -1026,10 +1025,6 @@ func (bc *BlockChain) InsertChain(chain types.Blocks) (int, error) {
// only reason this method exists as a separate one is to make locking cleaner
// with deferred statements.
func (bc *BlockChain) insertChain(chain types.Blocks) (int, []interface{}, []*types.Log, error) {
_, file, no, ok := runtime.Caller(1)
if ok {
fmt.Printf("called from %s#%d\n", file, no)
}
// Do a sanity check that the provided chain is actually ordered and linked
for i := 1; i < len(chain); i++ {
if chain[i].NumberU64() != chain[i-1].NumberU64()+1 || chain[i].ParentHash() != chain[i-1].Hash() {

View file

@ -550,6 +550,7 @@ func (api *PrivateDebugAPI) TraceTransaction(ctx context.Context, hash common.Ha
// TraceTransaction returns the structured logs created during the execution of EVM
// and returns them as a JSON object.
//@NOTE:SHYFT
func (api *PrivateDebugAPI) STraceTransaction(ctx context.Context, hash common.Hash, config *TraceConfig) (interface{}, error) {
// NOTE:SHYFT
tx, blockHash, _, index := core.GetTransaction(api.eth.ChainDb(), hash)
@ -570,6 +571,7 @@ func (api *PrivateDebugAPI) STraceTransaction(ctx context.Context, hash common.H
// traceTx configures a new tracer according to the provided configuration, and
// executes the given message in the provided environment. The return value will
// be tracer dependent.
//@NOTE:SHYFT
func (api *PrivateDebugAPI) StraceTx(ctx context.Context, message core.Message, vmctx vm.Context, statedb *state.StateDB, config *TraceConfig, hash common.Hash) (interface{}, error) {
// Assemble the structured logger or the JavaScript tracer
var (
@ -591,7 +593,7 @@ func (api *PrivateDebugAPI) StraceTx(ctx context.Context, message core.Message,
if tracer, err = tracers.New(*config.Tracer); err != nil {
return nil, err
}
// NOTE:SHYFT REMOVED CTX DEADLINE
// @NOTE:SHYFT REMOVED CTX DEADLINE
// Handle timeouts and RPC cancellations
//deadlineCtx, cancel := context.WithTimeout(ctx, timeout)
//go func() {
@ -646,10 +648,10 @@ func (api *PrivateDebugAPI) traceTx(ctx context.Context, message core.Message, v
case config != nil && config.Tracer != nil:
// Define a meaningful timeout of a single transaction trace
_ = defaultTraceTimeout
timeout := defaultTraceTimeout
if config.Timeout != nil {
if _, err = time.ParseDuration(*config.Timeout); err != nil {
if timeout, err = time.ParseDuration(*config.Timeout); err != nil {
return nil, err
}
}
@ -657,14 +659,13 @@ func (api *PrivateDebugAPI) traceTx(ctx context.Context, message core.Message, v
if tracer, err = tracers.New(*config.Tracer); err != nil {
return nil, err
}
// NOTE:SHYFT REMOVED CTX DEADLINE
// Handle timeouts and RPC cancellations
//deadlineCtx, cancel := context.WithTimeout(ctx, timeout)
//go func() {
// <-deadlineCtx.Done()
// tracer.(*tracers.Tracer).Stop(errors.New("execution timeout"))
//}()
//defer cancel()
//Handle timeouts and RPC cancellations
deadlineCtx, cancel := context.WithTimeout(ctx, timeout)
go func() {
<-deadlineCtx.Done()
tracer.(*tracers.Tracer).Stop(errors.New("execution timeout"))
}()
defer cancel()
case config == nil:
tracer = vm.NewStructLogger(nil)

View file

@ -3,7 +3,6 @@ package eth
import (
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/node"
"fmt"
)
var Chaindb_global ethdb.Database
@ -13,15 +12,11 @@ func SetChainDB(db ethdb.Database){
}
func chaindb(ctx *node.ServiceContext, config *Config) (ethdb.Database, error) {
fmt.Println("DO WE GET HERE ++++++++++++++++++++++++++++++++")
fmt.Printf("%+v", ctx)
if Chaindb_global != nil {
return Chaindb_global, nil
}
fmt.Println("FAR OUT ++++++++++++++++++++++++++++++++")
chainDb, err := CreateDB(ctx, config, "chaindata")
fmt.Println("CHECK CHECK ++++++++++++++++")
if err == nil {
SetChainDB(chainDb)
return Chaindb_global, nil

View file

@ -32,7 +32,6 @@ import (
"github.com/ethereum/go-ethereum/log"
"gopkg.in/olebedev/go-duktape.v3"
"database/sql"
"reflect"
)
// bigIntegerJS is the minified version of https://github.com/peterolson/BigInteger.js.
@ -577,6 +576,7 @@ func (jst *Tracer) CaptureEnd(output []byte, gasUsed uint64, t time.Duration, er
return nil
}
//@NOTE:SHYFT
type Internals struct {
Type string
From string
@ -590,17 +590,13 @@ type Internals struct {
Calls []*Internals
}
//@NOTE:SHYFT
func (i *Internals) SWriteInteralTxs(hash common.Hash) {
connStr := "user=postgres dbname=shyftdb sslmode=disable"
sqldb, err := sql.Open("postgres", connStr)
if err != nil {
return
}
fmt.Println("[VALUE]", reflect.TypeOf(i.Value))
test := "0x3782dace9d900000"
if test == i.Value {
fmt.Println("[EQUAL]: ", test, i.Value)
}
gas, _ := hexutil.DecodeUint64(i.Gas)
gasUsed, _ := hexutil.DecodeUint64(i.GasUsed)
@ -614,13 +610,8 @@ func (i *Internals) SWriteInteralTxs(hash common.Hash) {
panic(qerr)
}
}
//@NOTE:SHYFT
func (i *Internals) InternalRecursive(hash common.Hash) {
amount, _ := hexutil.DecodeUint64(i.Value)
if i.Type != "CREATE" {
fmt.Println("[INSIDE RECURSIVE VALUE]", amount)
fmt.Printf("%+v", i)
}
i.SWriteInteralTxs(hash)
lengthOfCalls := len(i.Calls)
if lengthOfCalls == 0 {
@ -672,15 +663,12 @@ func (jst *Tracer) GetResult() (json.RawMessage, error) {
jst.vm.DestroyHeap()
jst.vm.Destroy()
var dat Internals
if err := json.Unmarshal(result, &dat); err != nil {
panic(err)
}
return result, jst.err
}
// GetResult calls the Javascript 'result' function and returns its value, or any accumulated error
//@NOTE:SHYFT
func (jst *Tracer) SGetResult(hash common.Hash) (json.RawMessage, error) {
// Transform the context into a JavaScript object and inject into the state
obj := jst.vm.PushObject()
@ -725,8 +713,6 @@ func (jst *Tracer) SGetResult(hash common.Hash) (json.RawMessage, error) {
if err := json.Unmarshal(result, &dat); err != nil {
panic(err)
}
//fmt.Println("[THIS IS HASH]", hash.Hex())
//fmt.Println("DAT DATA STRUCTURE" , dat)
dat.InternalRecursive(hash)
return result, jst.err

View file

@ -642,7 +642,6 @@ func (n *Node) EventMux() *event.TypeMux {
// previous can be found) from within the node's instance directory. If the node is
// ephemeral, a memory database is returned.
func (n *Node) OpenDatabase(name string, cache, handles int) (ethdb.Database, error) {
fmt.Println("DSAhhysagdhkajsndjgasuygdvkhasbdjhs")
if n.config.DataDir == "" {
return ethdb.NewMemDatabase()
}