mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 02:12:23 +00:00
removed fmt print and added shyft tag to tracer fns
This commit is contained in:
parent
b9dda84e30
commit
4158caece6
5 changed files with 17 additions and 41 deletions
|
|
@ -46,7 +46,6 @@ import (
|
||||||
"github.com/ethereum/go-ethereum/trie"
|
"github.com/ethereum/go-ethereum/trie"
|
||||||
"github.com/hashicorp/golang-lru"
|
"github.com/hashicorp/golang-lru"
|
||||||
"gopkg.in/karalabe/cookiejar.v2/collections/prque"
|
"gopkg.in/karalabe/cookiejar.v2/collections/prque"
|
||||||
"runtime"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
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
|
// only reason this method exists as a separate one is to make locking cleaner
|
||||||
// with deferred statements.
|
// with deferred statements.
|
||||||
func (bc *BlockChain) insertChain(chain types.Blocks) (int, []interface{}, []*types.Log, error) {
|
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
|
// Do a sanity check that the provided chain is actually ordered and linked
|
||||||
for i := 1; i < len(chain); i++ {
|
for i := 1; i < len(chain); i++ {
|
||||||
if chain[i].NumberU64() != chain[i-1].NumberU64()+1 || chain[i].ParentHash() != chain[i-1].Hash() {
|
if chain[i].NumberU64() != chain[i-1].NumberU64()+1 || chain[i].ParentHash() != chain[i-1].Hash() {
|
||||||
|
|
|
||||||
|
|
@ -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
|
// TraceTransaction returns the structured logs created during the execution of EVM
|
||||||
// and returns them as a JSON object.
|
// and returns them as a JSON object.
|
||||||
|
//@NOTE:SHYFT
|
||||||
func (api *PrivateDebugAPI) STraceTransaction(ctx context.Context, hash common.Hash, config *TraceConfig) (interface{}, error) {
|
func (api *PrivateDebugAPI) STraceTransaction(ctx context.Context, hash common.Hash, config *TraceConfig) (interface{}, error) {
|
||||||
// NOTE:SHYFT
|
// NOTE:SHYFT
|
||||||
tx, blockHash, _, index := core.GetTransaction(api.eth.ChainDb(), hash)
|
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
|
// traceTx configures a new tracer according to the provided configuration, and
|
||||||
// executes the given message in the provided environment. The return value will
|
// executes the given message in the provided environment. The return value will
|
||||||
// be tracer dependent.
|
// 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) {
|
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
|
// Assemble the structured logger or the JavaScript tracer
|
||||||
var (
|
var (
|
||||||
|
|
@ -591,7 +593,7 @@ func (api *PrivateDebugAPI) StraceTx(ctx context.Context, message core.Message,
|
||||||
if tracer, err = tracers.New(*config.Tracer); err != nil {
|
if tracer, err = tracers.New(*config.Tracer); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
// NOTE:SHYFT REMOVED CTX DEADLINE
|
// @NOTE:SHYFT REMOVED CTX DEADLINE
|
||||||
// Handle timeouts and RPC cancellations
|
// Handle timeouts and RPC cancellations
|
||||||
//deadlineCtx, cancel := context.WithTimeout(ctx, timeout)
|
//deadlineCtx, cancel := context.WithTimeout(ctx, timeout)
|
||||||
//go func() {
|
//go func() {
|
||||||
|
|
@ -646,10 +648,10 @@ func (api *PrivateDebugAPI) traceTx(ctx context.Context, message core.Message, v
|
||||||
case config != nil && config.Tracer != nil:
|
case config != nil && config.Tracer != nil:
|
||||||
// Define a meaningful timeout of a single transaction trace
|
// Define a meaningful timeout of a single transaction trace
|
||||||
|
|
||||||
_ = defaultTraceTimeout
|
timeout := defaultTraceTimeout
|
||||||
|
|
||||||
if config.Timeout != nil {
|
if config.Timeout != nil {
|
||||||
if _, err = time.ParseDuration(*config.Timeout); err != nil {
|
if timeout, err = time.ParseDuration(*config.Timeout); err != nil {
|
||||||
return nil, err
|
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 {
|
if tracer, err = tracers.New(*config.Tracer); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
// NOTE:SHYFT REMOVED CTX DEADLINE
|
//Handle timeouts and RPC cancellations
|
||||||
// Handle timeouts and RPC cancellations
|
deadlineCtx, cancel := context.WithTimeout(ctx, timeout)
|
||||||
//deadlineCtx, cancel := context.WithTimeout(ctx, timeout)
|
go func() {
|
||||||
//go func() {
|
<-deadlineCtx.Done()
|
||||||
// <-deadlineCtx.Done()
|
tracer.(*tracers.Tracer).Stop(errors.New("execution timeout"))
|
||||||
// tracer.(*tracers.Tracer).Stop(errors.New("execution timeout"))
|
}()
|
||||||
//}()
|
defer cancel()
|
||||||
//defer cancel()
|
|
||||||
|
|
||||||
case config == nil:
|
case config == nil:
|
||||||
tracer = vm.NewStructLogger(nil)
|
tracer = vm.NewStructLogger(nil)
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@ package eth
|
||||||
import (
|
import (
|
||||||
"github.com/ethereum/go-ethereum/ethdb"
|
"github.com/ethereum/go-ethereum/ethdb"
|
||||||
"github.com/ethereum/go-ethereum/node"
|
"github.com/ethereum/go-ethereum/node"
|
||||||
"fmt"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var Chaindb_global ethdb.Database
|
var Chaindb_global ethdb.Database
|
||||||
|
|
@ -13,15 +12,11 @@ func SetChainDB(db ethdb.Database){
|
||||||
}
|
}
|
||||||
|
|
||||||
func chaindb(ctx *node.ServiceContext, config *Config) (ethdb.Database, error) {
|
func chaindb(ctx *node.ServiceContext, config *Config) (ethdb.Database, error) {
|
||||||
fmt.Println("DO WE GET HERE ++++++++++++++++++++++++++++++++")
|
|
||||||
fmt.Printf("%+v", ctx)
|
|
||||||
if Chaindb_global != nil {
|
if Chaindb_global != nil {
|
||||||
return Chaindb_global, nil
|
return Chaindb_global, nil
|
||||||
}
|
}
|
||||||
fmt.Println("FAR OUT ++++++++++++++++++++++++++++++++")
|
|
||||||
|
|
||||||
chainDb, err := CreateDB(ctx, config, "chaindata")
|
chainDb, err := CreateDB(ctx, config, "chaindata")
|
||||||
fmt.Println("CHECK CHECK ++++++++++++++++")
|
|
||||||
if err == nil {
|
if err == nil {
|
||||||
SetChainDB(chainDb)
|
SetChainDB(chainDb)
|
||||||
return Chaindb_global, nil
|
return Chaindb_global, nil
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,6 @@ import (
|
||||||
"github.com/ethereum/go-ethereum/log"
|
"github.com/ethereum/go-ethereum/log"
|
||||||
"gopkg.in/olebedev/go-duktape.v3"
|
"gopkg.in/olebedev/go-duktape.v3"
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"reflect"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// bigIntegerJS is the minified version of https://github.com/peterolson/BigInteger.js.
|
// 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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//@NOTE:SHYFT
|
||||||
type Internals struct {
|
type Internals struct {
|
||||||
Type string
|
Type string
|
||||||
From string
|
From string
|
||||||
|
|
@ -590,17 +590,13 @@ type Internals struct {
|
||||||
Calls []*Internals
|
Calls []*Internals
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//@NOTE:SHYFT
|
||||||
func (i *Internals) SWriteInteralTxs(hash common.Hash) {
|
func (i *Internals) SWriteInteralTxs(hash common.Hash) {
|
||||||
connStr := "user=postgres dbname=shyftdb sslmode=disable"
|
connStr := "user=postgres dbname=shyftdb sslmode=disable"
|
||||||
sqldb, err := sql.Open("postgres", connStr)
|
sqldb, err := sql.Open("postgres", connStr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
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)
|
gas, _ := hexutil.DecodeUint64(i.Gas)
|
||||||
gasUsed, _ := hexutil.DecodeUint64(i.GasUsed)
|
gasUsed, _ := hexutil.DecodeUint64(i.GasUsed)
|
||||||
|
|
@ -614,13 +610,8 @@ func (i *Internals) SWriteInteralTxs(hash common.Hash) {
|
||||||
panic(qerr)
|
panic(qerr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//@NOTE:SHYFT
|
||||||
func (i *Internals) InternalRecursive(hash common.Hash) {
|
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)
|
i.SWriteInteralTxs(hash)
|
||||||
lengthOfCalls := len(i.Calls)
|
lengthOfCalls := len(i.Calls)
|
||||||
if lengthOfCalls == 0 {
|
if lengthOfCalls == 0 {
|
||||||
|
|
@ -672,15 +663,12 @@ func (jst *Tracer) GetResult() (json.RawMessage, error) {
|
||||||
jst.vm.DestroyHeap()
|
jst.vm.DestroyHeap()
|
||||||
jst.vm.Destroy()
|
jst.vm.Destroy()
|
||||||
|
|
||||||
var dat Internals
|
|
||||||
|
|
||||||
if err := json.Unmarshal(result, &dat); err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return result, jst.err
|
return result, jst.err
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetResult calls the Javascript 'result' function and returns its value, or any accumulated error
|
// 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) {
|
func (jst *Tracer) SGetResult(hash common.Hash) (json.RawMessage, error) {
|
||||||
// Transform the context into a JavaScript object and inject into the state
|
// Transform the context into a JavaScript object and inject into the state
|
||||||
obj := jst.vm.PushObject()
|
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 {
|
if err := json.Unmarshal(result, &dat); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
//fmt.Println("[THIS IS HASH]", hash.Hex())
|
|
||||||
//fmt.Println("DAT DATA STRUCTURE" , dat)
|
|
||||||
dat.InternalRecursive(hash)
|
dat.InternalRecursive(hash)
|
||||||
|
|
||||||
return result, jst.err
|
return result, jst.err
|
||||||
|
|
|
||||||
|
|
@ -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
|
// previous can be found) from within the node's instance directory. If the node is
|
||||||
// ephemeral, a memory database is returned.
|
// ephemeral, a memory database is returned.
|
||||||
func (n *Node) OpenDatabase(name string, cache, handles int) (ethdb.Database, error) {
|
func (n *Node) OpenDatabase(name string, cache, handles int) (ethdb.Database, error) {
|
||||||
fmt.Println("DSAhhysagdhkajsndjgasuygdvkhasbdjhs")
|
|
||||||
if n.config.DataDir == "" {
|
if n.config.DataDir == "" {
|
||||||
return ethdb.NewMemDatabase()
|
return ethdb.NewMemDatabase()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue