mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 02:12:23 +00:00
wip
This commit is contained in:
parent
e6fdff4860
commit
de32947dcf
10 changed files with 280 additions and 68 deletions
|
|
@ -13,8 +13,15 @@ import (
|
||||||
|
|
||||||
_ "github.com/lib/pq"
|
_ "github.com/lib/pq"
|
||||||
Rewards "github.com/ethereum/go-ethereum/consensus/ethash"
|
Rewards "github.com/ethereum/go-ethereum/consensus/ethash"
|
||||||
|
"github.com/ethereum/go-ethereum/shyfttracerinterface"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var IShyftTracer shyfttracerinterface.IShyftTracer
|
||||||
|
|
||||||
|
func SetIShyftTracer(st shyfttracerinterface.IShyftTracer) {
|
||||||
|
IShyftTracer = st
|
||||||
|
}
|
||||||
|
|
||||||
//SBlock type
|
//SBlock type
|
||||||
type SBlock struct {
|
type SBlock struct {
|
||||||
Hash string
|
Hash string
|
||||||
|
|
@ -165,7 +172,7 @@ func SwriteTransactions(sqldb *sql.DB, tx *types.Transaction, blockHash common.H
|
||||||
Data: tx.Data(),
|
Data: tx.Data(),
|
||||||
}
|
}
|
||||||
txHash := txData.TxHash.Hex()
|
txHash := txData.TxHash.Hex()
|
||||||
MyTraceTransaction(txHash) //.chaindb_global
|
IShyftTracer.MyTraceTransaction(txHash) //.chaindb_global
|
||||||
from := txData.From.Hex()
|
from := txData.From.Hex()
|
||||||
blockHasher := txData.BlockHash
|
blockHasher := txData.BlockHash
|
||||||
amount := txData.Amount.String()
|
amount := txData.Amount.String()
|
||||||
|
|
|
||||||
|
|
@ -1,60 +0,0 @@
|
||||||
package core
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/ethereum/go-ethereum/ethdb"
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
|
||||||
"fmt"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
// defaultTraceReexec is the number of blocks the tracer is willing to go back
|
|
||||||
// and reexecute to produce missing historical state necessary to run a specific
|
|
||||||
// trace.
|
|
||||||
defaultTraceReexec = uint64(128)
|
|
||||||
)
|
|
||||||
|
|
||||||
//var api *eth.PrivateDebugAPI
|
|
||||||
|
|
||||||
var EthereumObject interface{}
|
|
||||||
|
|
||||||
var Chaindb_global ethdb.Database
|
|
||||||
|
|
||||||
func SetChainDB(db ethdb.Database){
|
|
||||||
Chaindb_global = db
|
|
||||||
}
|
|
||||||
|
|
||||||
func MyTraceTransaction(hash string) (interface{}) {
|
|
||||||
//fmt.Println("THE stringed hash is in MYTRACETRANSACTION")
|
|
||||||
//fmt.Println(hash)
|
|
||||||
//fmt.Println(ethObjectInterface.GetEthObject())
|
|
||||||
common_hash := common.HexToHash(hash)
|
|
||||||
|
|
||||||
|
|
||||||
//fmt.Println("the chain db is in MyTraceTransaction")
|
|
||||||
//fmt.Println(Chaindb_global)
|
|
||||||
if Chaindb_global == nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
tx, blockHash, _, index := GetTransaction(Chaindb_global, common_hash)
|
|
||||||
|
|
||||||
//reexec := defaultTraceReexec
|
|
||||||
//if config != nil && config.Reexec != nil {
|
|
||||||
// reexec = *config.Reexec
|
|
||||||
//}
|
|
||||||
//msg, vmctx, statedb, err := eth.api.computeTxEnv(blockHash, int(index), reexec)
|
|
||||||
|
|
||||||
if tx == nil {
|
|
||||||
fmt.Println("TRANSACTION NOT FOUND IN MyTraceTransaction +++++++++")
|
|
||||||
}
|
|
||||||
|
|
||||||
fmt.Println("the tx is ")
|
|
||||||
fmt.Println(tx)
|
|
||||||
fmt.Println(blockHash)
|
|
||||||
fmt.Println(index)
|
|
||||||
return 42
|
|
||||||
}
|
|
||||||
|
|
||||||
func setEthObject(ethobj interface{}){
|
|
||||||
EthereumObject = ethobj
|
|
||||||
}
|
|
||||||
|
|
@ -330,7 +330,7 @@ func (api *PublicDebugAPI) DumpBlock(blockNr rpc.BlockNumber) (state.Dump, error
|
||||||
|
|
||||||
// PrivateDebugAPI is the collection of Ethereum full node APIs exposed over
|
// PrivateDebugAPI is the collection of Ethereum full node APIs exposed over
|
||||||
// the private debugging endpoint.
|
// the private debugging endpoint.
|
||||||
type PrivateDebugAPI struct {
|
type PrivateDebugAPI struct {
|
||||||
config *params.ChainConfig
|
config *params.ChainConfig
|
||||||
eth *Ethereum
|
eth *Ethereum
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -532,6 +532,189 @@ func (api *PrivateDebugAPI) computeStateDB(block *types.Block, reexec uint64) (*
|
||||||
// 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.
|
||||||
func (api *PrivateDebugAPI) TraceTransaction(ctx context.Context, hash common.Hash, config *TraceConfig) (interface{}, error) {
|
func (api *PrivateDebugAPI) TraceTransaction(ctx context.Context, hash common.Hash, config *TraceConfig) (interface{}, error) {
|
||||||
|
fmt.Println("TRACE TRANSACTION ++++++!+!+!+!+!+!+!+!+!+!+!+!++!")
|
||||||
|
_, file, no, ok := runtime.Caller(1)
|
||||||
|
if ok {
|
||||||
|
fmt.Printf("called from %s#%d\n", file, no)
|
||||||
|
}
|
||||||
|
_, file, no, ok = runtime.Caller(2)
|
||||||
|
if ok {
|
||||||
|
fmt.Printf("called from %s#%d\n", file, no)
|
||||||
|
}
|
||||||
|
_, file, no, ok = runtime.Caller(3)
|
||||||
|
if ok {
|
||||||
|
fmt.Printf("called from %s#%d\n", file, no)
|
||||||
|
}
|
||||||
|
_, file, no, ok = runtime.Caller(4)
|
||||||
|
if ok {
|
||||||
|
fmt.Printf("called from %s#%d\n", file, no)
|
||||||
|
}
|
||||||
|
_, file, no, ok = runtime.Caller(5)
|
||||||
|
if ok {
|
||||||
|
fmt.Printf("called from %s#%d\n", file, no)
|
||||||
|
}
|
||||||
|
_, file, no, ok = runtime.Caller(6)
|
||||||
|
if ok {
|
||||||
|
fmt.Printf("called from %s#%d\n", file, no)
|
||||||
|
}
|
||||||
|
_, file, no, ok = runtime.Caller(7)
|
||||||
|
if ok {
|
||||||
|
fmt.Printf("called from %s#%d\n", file, no)
|
||||||
|
}
|
||||||
|
_, file, no, ok = runtime.Caller(8)
|
||||||
|
if ok {
|
||||||
|
fmt.Printf("called from %s#%d\n", file, no)
|
||||||
|
}
|
||||||
|
_, file, no, ok = runtime.Caller(9)
|
||||||
|
if ok {
|
||||||
|
fmt.Printf("called from %s#%d\n", file, no)
|
||||||
|
}
|
||||||
|
_, file, no, ok = runtime.Caller(10)
|
||||||
|
if ok {
|
||||||
|
fmt.Printf("called from %s#%d\n", file, no)
|
||||||
|
}
|
||||||
|
_, file, no, ok = runtime.Caller(11)
|
||||||
|
if ok {
|
||||||
|
fmt.Printf("called from %s#%d\n", file, no)
|
||||||
|
}
|
||||||
|
_, file, no, ok = runtime.Caller(12)
|
||||||
|
if ok {
|
||||||
|
fmt.Printf("called from %s#%d\n", file, no)
|
||||||
|
}
|
||||||
|
_, file, no, ok = runtime.Caller(13)
|
||||||
|
if ok {
|
||||||
|
fmt.Printf("called from %s#%d\n", file, no)
|
||||||
|
}
|
||||||
|
_, file, no, ok = runtime.Caller(14)
|
||||||
|
if ok {
|
||||||
|
fmt.Printf("called from %s#%d\n", file, no)
|
||||||
|
}
|
||||||
|
_, file, no, ok = runtime.Caller(15)
|
||||||
|
if ok {
|
||||||
|
fmt.Printf("called from %s#%d\n", file, no)
|
||||||
|
}
|
||||||
|
_, file, no, ok = runtime.Caller(16)
|
||||||
|
if ok {
|
||||||
|
fmt.Printf("called from %s#%d\n", file, no)
|
||||||
|
}
|
||||||
|
_, file, no, ok = runtime.Caller(17)
|
||||||
|
if ok {
|
||||||
|
fmt.Printf("called from %s#%d\n", file, no)
|
||||||
|
}
|
||||||
|
_, file, no, ok = runtime.Caller(18)
|
||||||
|
if ok {
|
||||||
|
fmt.Printf("called from %s#%d\n", file, no)
|
||||||
|
}
|
||||||
|
_, file, no, ok = runtime.Caller(19)
|
||||||
|
if ok {
|
||||||
|
fmt.Printf("called from %s#%d\n", file, no)
|
||||||
|
}
|
||||||
|
_, file, no, ok = runtime.Caller(20)
|
||||||
|
if ok {
|
||||||
|
fmt.Printf("called from %s#%d\n", file, no)
|
||||||
|
}
|
||||||
|
_, file, no, ok = runtime.Caller(21)
|
||||||
|
if ok {
|
||||||
|
fmt.Printf("called from %s#%d\n", file, no)
|
||||||
|
}
|
||||||
|
_, file, no, ok = runtime.Caller(22)
|
||||||
|
if ok {
|
||||||
|
fmt.Printf("called from %s#%d\n", file, no)
|
||||||
|
}
|
||||||
|
_, file, no, ok = runtime.Caller(23)
|
||||||
|
if ok {
|
||||||
|
fmt.Printf("called from %s#%d\n", file, no)
|
||||||
|
}
|
||||||
|
_, file, no, ok = runtime.Caller(24)
|
||||||
|
if ok {
|
||||||
|
fmt.Printf("called from %s#%d\n", file, no)
|
||||||
|
}
|
||||||
|
_, file, no, ok = runtime.Caller(25)
|
||||||
|
if ok {
|
||||||
|
fmt.Printf("called from %s#%d\n", file, no)
|
||||||
|
}
|
||||||
|
_, file, no, ok = runtime.Caller(26)
|
||||||
|
if ok {
|
||||||
|
fmt.Printf("called from %s#%d\n", file, no)
|
||||||
|
}
|
||||||
|
_, file, no, ok = runtime.Caller(27)
|
||||||
|
if ok {
|
||||||
|
fmt.Printf("called from %s#%d\n", file, no)
|
||||||
|
}
|
||||||
|
_, file, no, ok = runtime.Caller(28)
|
||||||
|
if ok {
|
||||||
|
fmt.Printf("called from %s#%d\n", file, no)
|
||||||
|
}
|
||||||
|
_, file, no, ok = runtime.Caller(29)
|
||||||
|
if ok {
|
||||||
|
fmt.Printf("called from %s#%d\n", file, no)
|
||||||
|
}
|
||||||
|
_, file, no, ok = runtime.Caller(30)
|
||||||
|
if ok {
|
||||||
|
fmt.Printf("called from %s#%d\n", file, no)
|
||||||
|
}
|
||||||
|
_, file, no, ok = runtime.Caller(31)
|
||||||
|
if ok {
|
||||||
|
fmt.Printf("called from %s#%d\n", file, no)
|
||||||
|
}
|
||||||
|
_, file, no, ok = runtime.Caller(32)
|
||||||
|
if ok {
|
||||||
|
fmt.Printf("called from %s#%d\n", file, no)
|
||||||
|
}
|
||||||
|
_, file, no, ok = runtime.Caller(33)
|
||||||
|
if ok {
|
||||||
|
fmt.Printf("called from %s#%d\n", file, no)
|
||||||
|
}
|
||||||
|
_, file, no, ok = runtime.Caller(34)
|
||||||
|
if ok {
|
||||||
|
fmt.Printf("called from %s#%d\n", file, no)
|
||||||
|
}
|
||||||
|
_, file, no, ok = runtime.Caller(35)
|
||||||
|
if ok {
|
||||||
|
fmt.Printf("called from %s#%d\n", file, no)
|
||||||
|
}
|
||||||
|
_, file, no, ok = runtime.Caller(36)
|
||||||
|
if ok {
|
||||||
|
fmt.Printf("called from %s#%d\n", file, no)
|
||||||
|
}
|
||||||
|
_, file, no, ok = runtime.Caller(37)
|
||||||
|
if ok {
|
||||||
|
fmt.Printf("called from %s#%d\n", file, no)
|
||||||
|
}
|
||||||
|
_, file, no, ok = runtime.Caller(38)
|
||||||
|
if ok {
|
||||||
|
fmt.Printf("called from %s#%d\n", file, no)
|
||||||
|
}
|
||||||
|
_, file, no, ok = runtime.Caller(39)
|
||||||
|
if ok {
|
||||||
|
fmt.Printf("called from %s#%d\n", file, no)
|
||||||
|
}
|
||||||
|
_, file, no, ok = runtime.Caller(40)
|
||||||
|
if ok {
|
||||||
|
fmt.Printf("called from %s#%d\n", file, no)
|
||||||
|
}
|
||||||
|
fmt.Println("////////////// ++++++++++++++++ /////////////////// Phantom *(!*!*!*!*!*!**!*!*")
|
||||||
|
_, file, no, ok = runtime.Caller(41)
|
||||||
|
if ok {
|
||||||
|
fmt.Printf("called from %s#%d\n", file, no)
|
||||||
|
}
|
||||||
|
_, file, no, ok = runtime.Caller(42)
|
||||||
|
if ok {
|
||||||
|
fmt.Printf("called from %s#%d\n", file, no)
|
||||||
|
}
|
||||||
|
_, file, no, ok = runtime.Caller(43)
|
||||||
|
if ok {
|
||||||
|
fmt.Printf("called from %s#%d\n", file, no)
|
||||||
|
}
|
||||||
|
_, file, no, ok = runtime.Caller(44)
|
||||||
|
if ok {
|
||||||
|
fmt.Printf("called from %s#%d\n", file, no)
|
||||||
|
}
|
||||||
|
fmt.Println("////////////// ++++++++++++++++ /////////////////// TraceTransaction *(!*!*!*!*!*!**!*!*")
|
||||||
|
_, file, no, ok = runtime.Caller(45)
|
||||||
|
if ok {
|
||||||
|
fmt.Printf("called from %s#%d\n", file, no)
|
||||||
|
}
|
||||||
// NOTE:SHYFT
|
// NOTE:SHYFT
|
||||||
fmt.Printf("\n\t[API_TRACER.GO api.config] %+v", api.config)
|
fmt.Printf("\n\t[API_TRACER.GO api.config] %+v", api.config)
|
||||||
fmt.Printf("\n\t[API_TRACER.GO api.eth] %+v\n", api.eth)
|
fmt.Printf("\n\t[API_TRACER.GO api.eth] %+v\n", api.eth)
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ import (
|
||||||
|
|
||||||
var BlockchainObject *core.BlockChain
|
var BlockchainObject *core.BlockChain
|
||||||
|
|
||||||
var DebugApi *PrivateDebugAPI
|
var DebugApi PrivateDebugAPI
|
||||||
|
|
||||||
type LesServer interface {
|
type LesServer interface {
|
||||||
Start(srvr *p2p.Server)
|
Start(srvr *p2p.Server)
|
||||||
|
|
@ -106,6 +106,9 @@ func (s *Ethereum) AddLesServer(ls LesServer) {
|
||||||
// initialisation of the common Ethereum object)
|
// initialisation of the common Ethereum object)
|
||||||
func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) {
|
func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) {
|
||||||
|
|
||||||
|
shyft_tracer := new(ShyftTracer)
|
||||||
|
core.SetIShyftTracer(shyft_tracer)
|
||||||
|
|
||||||
fmt.Println("++++++++++")
|
fmt.Println("++++++++++")
|
||||||
_, file, no, ok := runtime.Caller(1)
|
_, file, no, ok := runtime.Caller(1)
|
||||||
if ok {
|
if ok {
|
||||||
|
|
|
||||||
|
|
@ -4,22 +4,27 @@ 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"
|
"fmt"
|
||||||
"github.com/ethereum/go-ethereum/core"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var Chaindb_global ethdb.Database
|
||||||
|
|
||||||
|
func SetChainDB(db ethdb.Database){
|
||||||
|
Chaindb_global = db
|
||||||
|
}
|
||||||
|
|
||||||
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.Println("DO WE GET HERE ++++++++++++++++++++++++++++++++")
|
||||||
fmt.Printf("%+v", ctx)
|
fmt.Printf("%+v", ctx)
|
||||||
if core.Chaindb_global != nil {
|
if Chaindb_global != nil {
|
||||||
return core.Chaindb_global, nil
|
return Chaindb_global, nil
|
||||||
}
|
}
|
||||||
fmt.Println("FAR OUT ++++++++++++++++++++++++++++++++")
|
fmt.Println("FAR OUT ++++++++++++++++++++++++++++++++")
|
||||||
|
|
||||||
chainDb, err := CreateDB(ctx, config, "chaindata")
|
chainDb, err := CreateDB(ctx, config, "chaindata")
|
||||||
fmt.Println("CHECK CHECK ++++++++++++++++")
|
fmt.Println("CHECK CHECK ++++++++++++++++")
|
||||||
if err == nil {
|
if err == nil {
|
||||||
core.SetChainDB(chainDb)
|
SetChainDB(chainDb)
|
||||||
return core.Chaindb_global, nil
|
return Chaindb_global, nil
|
||||||
}
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
63
eth/shyft_tracer.go
Normal file
63
eth/shyft_tracer.go
Normal file
|
|
@ -0,0 +1,63 @@
|
||||||
|
package eth
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/ethereum/go-ethereum/common"
|
||||||
|
"fmt"
|
||||||
|
"github.com/ethereum/go-ethereum/core"
|
||||||
|
)
|
||||||
|
|
||||||
|
//const (
|
||||||
|
// // defaultTraceReexec is the number of blocks the tracer is willing to go back
|
||||||
|
// // and reexecute to produce missing historical state necessary to run a specific
|
||||||
|
// // trace.
|
||||||
|
// defaultTraceReexec = uint64(128)
|
||||||
|
//)
|
||||||
|
|
||||||
|
//var api *eth.PrivateDebugAPI
|
||||||
|
|
||||||
|
var EthereumObject interface{}
|
||||||
|
|
||||||
|
type ShyftTracer struct {}
|
||||||
|
|
||||||
|
func (st ShyftTracer) MyTraceTransaction(hash string) (interface{}) {
|
||||||
|
//fmt.Println("THE stringed hash is in MYTRACETRANSACTION")
|
||||||
|
//fmt.Println(hash)
|
||||||
|
//fmt.Println(ethObjectInterface.GetEthObject())
|
||||||
|
common_hash := common.HexToHash(hash)
|
||||||
|
|
||||||
|
|
||||||
|
//fmt.Println("the chain db is in MyTraceTransaction")
|
||||||
|
//fmt.Println(Chaindb_global)
|
||||||
|
if Chaindb_global == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
tx, blockHash, _, index := core.GetTransaction(Chaindb_global, common_hash)
|
||||||
|
|
||||||
|
if tx == nil {
|
||||||
|
fmt.Println("TRANSACTION NOT FOUND IN MyTraceTransaction +++++++++")
|
||||||
|
}
|
||||||
|
|
||||||
|
reexec := defaultTraceReexec
|
||||||
|
//if config != nil && config.Reexec != nil {
|
||||||
|
// reexec = *config.Reexec
|
||||||
|
//}
|
||||||
|
msg, vmctx, statedb, err := DebugApi.computeTxEnv(blockHash, int(index), reexec)
|
||||||
|
|
||||||
|
fmt.Println("stuff and nonsense")
|
||||||
|
fmt.Println(msg)
|
||||||
|
fmt.Println(vmctx)
|
||||||
|
fmt.Println(statedb)
|
||||||
|
fmt.Println(err)
|
||||||
|
|
||||||
|
//fmt.Println("the tx is ")
|
||||||
|
//fmt.Println(tx)
|
||||||
|
//fmt.Println(blockHash)
|
||||||
|
//fmt.Println(index)
|
||||||
|
//DebugApi.traceTx(ctx, msg, vmctx, statedb, config)
|
||||||
|
return 42
|
||||||
|
}
|
||||||
|
|
||||||
|
func setEthObject(ethobj interface{}){
|
||||||
|
EthereumObject = ethobj
|
||||||
|
}
|
||||||
|
|
@ -188,6 +188,8 @@ loop:
|
||||||
arguments = make([]interface{}, 1)
|
arguments = make([]interface{}, 1)
|
||||||
}
|
}
|
||||||
arguments[0] = timer.call.ArgumentList[0]
|
arguments[0] = timer.call.ArgumentList[0]
|
||||||
|
fmt.Println("The arguments are")
|
||||||
|
fmt.Println(arguments)
|
||||||
_, err := vm.Call(`Function.call.call`, nil, arguments...)
|
_, err := vm.Call(`Function.call.call`, nil, arguments...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("js error:", err, arguments)
|
fmt.Println("js error:", err, arguments)
|
||||||
|
|
|
||||||
|
|
@ -231,6 +231,10 @@ func (h *virtualHostHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
if ipAddr := net.ParseIP(host); ipAddr != nil {
|
if ipAddr := net.ParseIP(host); ipAddr != nil {
|
||||||
// It's an IP address, we can serve that
|
// It's an IP address, we can serve that
|
||||||
|
fmt.Println("THE write is ")
|
||||||
|
fmt.Println(w)
|
||||||
|
fmt.Println("The read is ")
|
||||||
|
fmt.Println(r)
|
||||||
h.next.ServeHTTP(w, r)
|
h.next.ServeHTTP(w, r)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
|
||||||
5
shyfttracerinterface/tracer_interface.go
Normal file
5
shyfttracerinterface/tracer_interface.go
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
package shyfttracerinterface
|
||||||
|
|
||||||
|
type IShyftTracer interface {
|
||||||
|
MyTraceTransaction(hash string) (interface{})
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue