From 62cfec3787c0b0b6f0d20855dd6b79e264aeb57b Mon Sep 17 00:00:00 2001 From: greg Date: Mon, 11 Jun 2018 10:56:46 -0400 Subject: [PATCH 01/21] updates for dustin --- core/blockchain.go | 3 ++- eth/api_tracer.go | 8 +++----- miner/worker.go | 4 +++- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/core/blockchain.go b/core/blockchain.go index cb72402654..d81f262abc 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -901,7 +901,8 @@ func (bc *BlockChain) WriteBlockWithState(block *types.Block, receipts []*types. if err := WriteBlock(batch, block); err != nil { return NonStatTy, err } - // @NOTE:SHYFT - Write block data for block explorer + // NOTE:SHYFT - Write block data for block explorer + fmt.Printf("\n\t[BLOCKCHAIN.GO bc.chainConfig] %+v", bc.chainConfig) if err := shyftdb.WriteBlock(block, receipts); err != nil { return NonStatTy, err } diff --git a/eth/api_tracer.go b/eth/api_tracer.go index e639bba33a..fa6af256ad 100644 --- a/eth/api_tracer.go +++ b/eth/api_tracer.go @@ -532,11 +532,9 @@ func (api *PrivateDebugAPI) computeStateDB(block *types.Block, reexec uint64) (* // 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, hash common.Hash, config *TraceConfig) (interface{}, error) { - fmt.Println("\n\n\t[API LOG]", api, "\n") - fmt.Printf("%+v\n", api.config) - fmt.Println("\n") - fmt.Printf("%+v\n", api.eth) - fmt.Println("\n") + // NOTE:SHYFT + 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) // Retrieve the transaction and assemble its EVM context tx, blockHash, _, index := core.GetTransaction(api.eth.ChainDb(), hash) if tx == nil { diff --git a/miner/worker.go b/miner/worker.go index 15395ae0b9..cfbc9c5377 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -309,7 +309,9 @@ func (self *worker) wait() { for _, log := range work.state.Logs() { log.BlockHash = block.Hash() } - stat, err := self.chain.WriteBlockWithState(block, work.receipts, work.state) + fmt.Printf("\n\t[WORKER.GO self.eth] %+v\n", self.eth) + // NOTE:SHYFT Added eth to writeBlockWithState + stat, err := self.chain.WriteBlockWithState(block, work.receipts, work.state, self.eth) if err != nil { log.Error("Failed writing block to chain", "err", err) continue From 6b4eb6abef2020c11c604fdc6bf65f01703309e7 Mon Sep 17 00:00:00 2001 From: Tim Williams Date: Thu, 14 Jun 2018 11:42:06 -0400 Subject: [PATCH 02/21] fix parameter --- miner/worker.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/miner/worker.go b/miner/worker.go index cfbc9c5377..d1880456fc 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -311,7 +311,7 @@ func (self *worker) wait() { } fmt.Printf("\n\t[WORKER.GO self.eth] %+v\n", self.eth) // NOTE:SHYFT Added eth to writeBlockWithState - stat, err := self.chain.WriteBlockWithState(block, work.receipts, work.state, self.eth) + stat, err := self.chain.WriteBlockWithState(block, work.receipts, work.state) if err != nil { log.Error("Failed writing block to chain", "err", err) continue From 802c1b061ec658c1d39bedfdc9219a785b42c746 Mon Sep 17 00:00:00 2001 From: Tim Williams Date: Mon, 18 Jun 2018 11:36:01 -0400 Subject: [PATCH 03/21] compiles --- core/blockchain.go | 3 +- {shyftDb => core}/db.go | 4 +-- core/genesis.go | 5 ++-- {shyftDb => core}/shyft_database_util.go | 35 ++++++++++++------------ core/shyft_tracer.go | 35 ++++++++++++++++++++++++ eth/backend.go | 3 +- eth/chaindb.go | 25 +++++++++++++++++ 7 files changed, 85 insertions(+), 25 deletions(-) rename {shyftDb => core}/db.go (97%) rename {shyftDb => core}/shyft_database_util.go (96%) create mode 100644 core/shyft_tracer.go create mode 100644 eth/chaindb.go diff --git a/core/blockchain.go b/core/blockchain.go index d81f262abc..4216999069 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -33,7 +33,6 @@ import ( "github.com/ethereum/go-ethereum/common/mclock" "github.com/ethereum/go-ethereum/consensus" "github.com/ethereum/go-ethereum/core/state" - "github.com/ethereum/go-ethereum/shyftdb" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/crypto" @@ -903,7 +902,7 @@ func (bc *BlockChain) WriteBlockWithState(block *types.Block, receipts []*types. } // NOTE:SHYFT - Write block data for block explorer fmt.Printf("\n\t[BLOCKCHAIN.GO bc.chainConfig] %+v", bc.chainConfig) - if err := shyftdb.WriteBlock(block, receipts); err != nil { + if err := SWriteBlock(block, receipts); err != nil { return NonStatTy, err } diff --git a/shyftDb/db.go b/core/db.go similarity index 97% rename from shyftDb/db.go rename to core/db.go index f95871fd28..3fedb09b18 100644 --- a/shyftDb/db.go +++ b/core/db.go @@ -1,4 +1,4 @@ -package shyftdb +package core import ( "fmt" @@ -34,4 +34,4 @@ func DBConnection() (*sql.DB, error) { } } return blockExplorerDb, nil -} \ No newline at end of file +} diff --git a/core/genesis.go b/core/genesis.go index 26f7a771f1..ade6d3f0de 100644 --- a/core/genesis.go +++ b/core/genesis.go @@ -35,7 +35,6 @@ import ( "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/rlp" - "github.com/ethereum/go-ethereum/shyftdb" "database/sql" "strconv" "time" @@ -145,7 +144,7 @@ func (e *GenesisMismatchError) Error() string { //@NOTE:SHYFT func WriteShyftGen(gen *Genesis, block *types.Block) { - sqldb, _ := shyftdb.DBConnection() + sqldb, _ := DBConnection() for k := range gen.Alloc { addr := k.String() @@ -195,7 +194,7 @@ func WriteShyftGen(gen *Genesis, block *types.Block) { func WriteShyftBlockZero(block *types.Block, gen *Genesis) error { - sqldb, _ := shyftdb.DBConnection() + sqldb, _ := DBConnection() coinbase := block.Header().Coinbase.String() number := block.Header().Number.String() diff --git a/shyftDb/shyft_database_util.go b/core/shyft_database_util.go similarity index 96% rename from shyftDb/shyft_database_util.go rename to core/shyft_database_util.go index 658abe6e07..4e464d211b 100644 --- a/shyftDb/shyft_database_util.go +++ b/core/shyft_database_util.go @@ -1,18 +1,18 @@ -package shyftdb +package core import ( - "encoding/json" - "fmt" - "math/big" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/types" - "time" - "strconv" - "database/sql" - "log" +"encoding/json" +"fmt" +"math/big" +"github.com/ethereum/go-ethereum/common" +"github.com/ethereum/go-ethereum/core/types" +"time" +"strconv" +"database/sql" +"log" - _ "github.com/lib/pq" - Rewards "github.com/ethereum/go-ethereum/consensus/ethash" +_ "github.com/lib/pq" +Rewards "github.com/ethereum/go-ethereum/consensus/ethash" ) //SBlock type @@ -104,7 +104,7 @@ type SendAndReceive struct { } //WriteBlock writes to block info to sql db -func WriteBlock(block *types.Block, receipts []*types.Receipt) error { +func SWriteBlock(block *types.Block, receipts []*types.Receipt) error { sqldb, err := DBConnection() if (err != nil) { @@ -138,7 +138,7 @@ func WriteBlock(block *types.Block, receipts []*types.Receipt) error { if block.Transactions().Len() > 0 { for _, tx := range block.Transactions() { - writeTransactions(sqldb, tx, block.Header().Hash(), block.Header().Number.String(), receipts, age, gasLimit) + SwriteTransactions(sqldb, tx, block.Header().Hash(), block.Header().Number.String(), receipts, age, gasLimit) if block.Transactions()[0].To() != nil { writeFromBalance(sqldb, tx) } @@ -151,7 +151,7 @@ func WriteBlock(block *types.Block, receipts []*types.Receipt) error { } //writeTransactions writes to sqldb -func writeTransactions(sqldb *sql.DB, tx *types.Transaction, blockHash common.Hash, blockNumber string, receipts []*types.Receipt, age time.Time, gasLimit uint64) error { +func SwriteTransactions(sqldb *sql.DB, tx *types.Transaction, blockHash common.Hash, blockNumber string, receipts []*types.Receipt, age time.Time, gasLimit uint64) error { txData := ShyftTxEntry{ TxHash: tx.Hash(), From: tx.From(), @@ -165,6 +165,7 @@ func writeTransactions(sqldb *sql.DB, tx *types.Transaction, blockHash common.Ha Data: tx.Data(), } txHash := txData.TxHash.Hex() + MyTraceTransaction(txHash) //.chaindb_global from := txData.From.Hex() blockHasher := txData.BlockHash amount := txData.Amount.String() @@ -545,7 +546,7 @@ func GetAllBlocks(sqldb *sql.DB) string { //GetBlock queries to send single block info //TODO provide blockHash arg passed from handler.go -func GetBlock(sqldb *sql.DB, blockNumber string) string { +func SGetBlock(sqldb *sql.DB, blockNumber string) string { sqlStatement := `SELECT * FROM blocks WHERE number=$1;` row := sqldb.QueryRow(sqlStatement, blockNumber) var hash string @@ -855,7 +856,7 @@ func GetAllTransactions(sqldb *sql.DB) string { } //GetTransaction fn returns single tx -func GetTransaction(sqldb *sql.DB, txHash string) string { +func SGetTransaction(sqldb *sql.DB, txHash string) string { sqlStatement := `SELECT * FROM txs WHERE txhash=$1;` row := sqldb.QueryRow(sqlStatement, txHash) var txhash string diff --git a/core/shyft_tracer.go b/core/shyft_tracer.go new file mode 100644 index 0000000000..aac6bf5db6 --- /dev/null +++ b/core/shyft_tracer.go @@ -0,0 +1,35 @@ +package core + +import ( + "github.com/ethereum/go-ethereum/ethdb" + "github.com/ethereum/go-ethereum/common" + "fmt" +) + +var Chaindb_global ethdb.Database + +func SetChainDB(db ethdb.Database){ + Chaindb_global = db +} + + + +func MyTraceTransaction(hash string) (interface{}) { + common_hash := common.StringToHash(hash) + fmt.Println("the hash is") + fmt.Println(common_hash) + + fmt.Println("the chain db is") + fmt.Println(Chaindb_global) + if Chaindb_global == nil { + return nil + } + + tx, blockHash, _, index := GetTransaction(Chaindb_global, common_hash) + + fmt.Println("the tx is ") + fmt.Println(tx) + fmt.Println(blockHash) + fmt.Println(index) + return 42 +} \ No newline at end of file diff --git a/eth/backend.go b/eth/backend.go index 44425ece9a..c78cfa3164 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -107,7 +107,7 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) { if !config.SyncMode.IsValid() { return nil, fmt.Errorf("invalid sync mode %d", config.SyncMode) } - chainDb, err := CreateDB(ctx, config, "chaindata") + chainDb, err := chaindb(ctx, config) if err != nil { return nil, err } @@ -202,6 +202,7 @@ func makeExtraData(extra []byte) []byte { // CreateDB creates the chain database. func CreateDB(ctx *node.ServiceContext, config *Config, name string) (ethdb.Database, error) { + fmt.Println("in create db") db, err := ctx.OpenDatabase(name, config.DatabaseCache, config.DatabaseHandles) if err != nil { return nil, err diff --git a/eth/chaindb.go b/eth/chaindb.go new file mode 100644 index 0000000000..e17cd37771 --- /dev/null +++ b/eth/chaindb.go @@ -0,0 +1,25 @@ +package eth + +import ( + "github.com/ethereum/go-ethereum/ethdb" + "github.com/ethereum/go-ethereum/node" + "fmt" + "github.com/ethereum/go-ethereum/core" +) + +func chaindb(ctx *node.ServiceContext, config *Config) (ethdb.Database, error) { + fmt.Println("DO WE GET HERE ++++++++++++++++++++++++++++++++") + fmt.Printf("%+v", ctx) + if core.Chaindb_global != nil { + return core.Chaindb_global, nil + } + fmt.Println("FAR OUT ++++++++++++++++++++++++++++++++") + + chainDb, err := CreateDB(ctx, config, "chaindata") + fmt.Println("CHECK CHECK ++++++++++++++++") + if err == nil { + core.SetChainDB(chainDb) + return core.Chaindb_global, nil + } + return nil, err +} \ No newline at end of file From db82bc9603cf4ad9e944d4807853497335f5abd4 Mon Sep 17 00:00:00 2001 From: Tim Williams Date: Mon, 18 Jun 2018 15:53:06 -0400 Subject: [PATCH 04/21] compiles --- core/blockchain.go | 22 +++++++++++++++------ core/database_util.go | 13 ++++++++++++ core/shyft_tracer.go | 34 +++++++++++++++++++++++++------- eth/api.go | 2 +- eth/api_tracer.go | 9 +++++++++ eth/backend.go | 17 ++++++++++++++++ ethObjectInterface/eth_object.go | 9 +++++++++ 7 files changed, 92 insertions(+), 14 deletions(-) create mode 100644 ethObjectInterface/eth_object.go diff --git a/core/blockchain.go b/core/blockchain.go index 4216999069..f40f6019e7 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -28,7 +28,8 @@ import ( "sync" "sync/atomic" "time" - + + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/mclock" "github.com/ethereum/go-ethereum/consensus" @@ -45,6 +46,7 @@ import ( "github.com/ethereum/go-ethereum/trie" "github.com/hashicorp/golang-lru" "gopkg.in/karalabe/cookiejar.v2/collections/prque" + "runtime" ) var ( @@ -900,16 +902,13 @@ func (bc *BlockChain) WriteBlockWithState(block *types.Block, receipts []*types. if err := WriteBlock(batch, block); err != nil { return NonStatTy, err } - // NOTE:SHYFT - Write block data for block explorer - fmt.Printf("\n\t[BLOCKCHAIN.GO bc.chainConfig] %+v", bc.chainConfig) - if err := SWriteBlock(block, receipts); err != nil { - return NonStatTy, err - } root, err := state.Commit(bc.chainConfig.IsEIP158(block.Number())) + if err != nil { return NonStatTy, err } + triedb := bc.stateCache.TrieDB() // If we're running an archive node, always flush @@ -1001,6 +1000,12 @@ func (bc *BlockChain) WriteBlockWithState(block *types.Block, receipts []*types. if status == CanonStatTy { bc.insert(block) } + + // NOTE:SHYFT - Write block data for block explorer + fmt.Printf("\n\t[BLOCKCHAIN.GO bc.chainConfig] %+v", bc.chainConfig) + if err := SWriteBlock(block, receipts); err != nil { + return NonStatTy, err + } bc.futureBlocks.Remove(block.Hash()) return status, nil } @@ -1021,6 +1026,11 @@ 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) { + fmt.Println("++++++++++ insertChain +++++++++") + _, 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() { diff --git a/core/database_util.go b/core/database_util.go index 37f0daf952..8aabd94034 100644 --- a/core/database_util.go +++ b/core/database_util.go @@ -266,7 +266,14 @@ func GetBlockReceipts(db DatabaseReader, hash common.Hash, number uint64) types. // hash to allow retrieving the transaction or receipt by hash. func GetTxLookupEntry(db DatabaseReader, hash common.Hash) (common.Hash, uint64, uint64) { // Load the positional metadata from disk and bail if it fails + fmt.Println("INSIDE GetTxLookupEntry ") + fmt.Println("the db is ") + fmt.Println(db) + fmt.Println("the hash is") + fmt.Println(hash) data, _ := db.Get(append(lookupPrefix, hash.Bytes()...)) + fmt.Println("the data is ") + fmt.Println(data) if len(data) == 0 { return common.Hash{}, 0, 0 } @@ -283,7 +290,13 @@ func GetTxLookupEntry(db DatabaseReader, hash common.Hash) (common.Hash, uint64, // its added positional metadata. func GetTransaction(db DatabaseReader, hash common.Hash) (*types.Transaction, common.Hash, uint64, uint64) { // Retrieve the lookup metadata and resolve the transaction from the body + //fmt.Println("INSIDE GET TRANSACTION ++++++++") + //fmt.Println("The hash and db reader are") + //fmt.Println(hash) + //fmt.Println(db) blockHash, blockNumber, txIndex := GetTxLookupEntry(db, hash) + //fmt.Println(blockHash) + //fmt.Println(blockNumber) if blockHash != (common.Hash{}) { body := GetBody(db, blockHash, blockNumber) diff --git a/core/shyft_tracer.go b/core/shyft_tracer.go index aac6bf5db6..391ada4257 100644 --- a/core/shyft_tracer.go +++ b/core/shyft_tracer.go @@ -4,29 +4,49 @@ 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 Chaindb_global ethdb.Database func SetChainDB(db ethdb.Database){ Chaindb_global = db } - - func MyTraceTransaction(hash string) (interface{}) { - common_hash := common.StringToHash(hash) - fmt.Println("the hash is") - fmt.Println(common_hash) + //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") - fmt.Println(Chaindb_global) + + //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) diff --git a/eth/api.go b/eth/api.go index a345b57e49..d2491f7821 100644 --- a/eth/api.go +++ b/eth/api.go @@ -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 // the private debugging endpoint. -type PrivateDebugAPI struct { +type PrivateDebugAPI struct { config *params.ChainConfig eth *Ethereum } diff --git a/eth/api_tracer.go b/eth/api_tracer.go index fa6af256ad..8f2fd54568 100644 --- a/eth/api_tracer.go +++ b/eth/api_tracer.go @@ -536,10 +536,19 @@ func (api *PrivateDebugAPI) TraceTransaction(ctx context.Context, hash common.Ha 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) // Retrieve the transaction and assemble its EVM context + //fmt.Println("IN TRACE TRANSACTION the chaindb is ") + //fmt.Println(chaindb) + //fmt.Println("IN TRACE TRANSACTION the common hash is ") + //fmt.Println(hash) tx, blockHash, _, index := core.GetTransaction(api.eth.ChainDb(), hash) if tx == nil { return nil, fmt.Errorf("transaction %x not found", hash) } + + fmt.Println("the tx is in TraceTransaction") + fmt.Println(tx) + fmt.Println(blockHash) + fmt.Println(index) reexec := defaultTraceReexec if config != nil && config.Reexec != nil { reexec = *config.Reexec diff --git a/eth/backend.go b/eth/backend.go index c78cfa3164..a3fd81d662 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -49,6 +49,10 @@ import ( "github.com/ethereum/go-ethereum/rpc" ) +var EthObject *Ethereum + +var BlockchainObject *core.BlockChain + type LesServer interface { Start(srvr *p2p.Server) Stop() @@ -101,6 +105,13 @@ func (s *Ethereum) AddLesServer(ls LesServer) { // New creates a new Ethereum object (including the // initialisation of the common Ethereum object) func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) { + + fmt.Println("++++++++++") + _, file, no, ok := runtime.Caller(1) + if ok { + fmt.Printf("called from %s#%d\n", file, no) + } + if config.SyncMode == downloader.LightSync { return nil, errors.New("can't run eth.Ethereum in light sync mode, use les.LightEthereum") } @@ -137,6 +148,8 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) { bloomIndexer: NewBloomIndexer(chainDb, params.BloomBitsBlocks), } + EthObject = eth + log.Info("Initialising Ethereum protocol", "versions", ProtocolVersions, "network", config.NetworkId) if !config.SkipBcVersionCheck { @@ -150,7 +163,11 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) { vmConfig = vm.Config{EnablePreimageRecording: config.EnablePreimageRecording} cacheConfig = &core.CacheConfig{Disabled: config.NoPruning, TrieNodeLimit: config.TrieCache, TrieTimeLimit: config.TrieTimeout} ) + eth.blockchain, err = core.NewBlockChain(chainDb, cacheConfig, eth.chainConfig, eth.engine, vmConfig) + + BlockchainObject = eth.blockchain + if err != nil { return nil, err } diff --git a/ethObjectInterface/eth_object.go b/ethObjectInterface/eth_object.go new file mode 100644 index 0000000000..5e999762d3 --- /dev/null +++ b/ethObjectInterface/eth_object.go @@ -0,0 +1,9 @@ +package ethObjectInterface + +import "github.com/ethereum/go-ethereum/eth" + +//var ethObject *eth.Ethereum + +func GetEthObject() (interface{}){ + return eth.EthObject +} \ No newline at end of file From e6fdff486058b473d387f377093f515b9719d4d5 Mon Sep 17 00:00:00 2001 From: Tim Williams Date: Mon, 18 Jun 2018 17:55:53 -0400 Subject: [PATCH 05/21] more stuff --- core/shyft_tracer.go | 7 ++++++- eth/backend.go | 9 +++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/core/shyft_tracer.go b/core/shyft_tracer.go index 391ada4257..56581b046f 100644 --- a/core/shyft_tracer.go +++ b/core/shyft_tracer.go @@ -4,7 +4,6 @@ import ( "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/common" "fmt" - ) const ( @@ -16,6 +15,8 @@ const ( //var api *eth.PrivateDebugAPI +var EthereumObject interface{} + var Chaindb_global ethdb.Database func SetChainDB(db ethdb.Database){ @@ -52,4 +53,8 @@ func MyTraceTransaction(hash string) (interface{}) { fmt.Println(blockHash) fmt.Println(index) return 42 +} + +func setEthObject(ethobj interface{}){ + EthereumObject = ethobj } \ No newline at end of file diff --git a/eth/backend.go b/eth/backend.go index a3fd81d662..8e2f81bb6e 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -49,10 +49,10 @@ import ( "github.com/ethereum/go-ethereum/rpc" ) -var EthObject *Ethereum - var BlockchainObject *core.BlockChain +var DebugApi *PrivateDebugAPI + type LesServer interface { Start(srvr *p2p.Server) Stop() @@ -148,8 +148,6 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) { bloomIndexer: NewBloomIndexer(chainDb, params.BloomBitsBlocks), } - EthObject = eth - log.Info("Initialising Ethereum protocol", "versions", ProtocolVersions, "network", config.NetworkId) if !config.SkipBcVersionCheck { @@ -197,6 +195,9 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) { } eth.ApiBackend.gpo = gasprice.NewOracle(eth.ApiBackend, gpoParams) + DebugApi.eth = eth + DebugApi.config = chainConfig + return eth, nil } From de32947dcf2dbce3486c0facf3f4988c9f29f887 Mon Sep 17 00:00:00 2001 From: Tim Williams Date: Thu, 21 Jun 2018 14:36:39 -0400 Subject: [PATCH 06/21] wip --- core/shyft_database_util.go | 9 +- core/shyft_tracer.go | 60 -------- eth/api.go | 2 +- eth/api_tracer.go | 183 +++++++++++++++++++++++ eth/backend.go | 5 +- eth/chaindb.go | 15 +- eth/shyft_tracer.go | 63 ++++++++ internal/jsre/jsre.go | 2 + rpc/http.go | 4 + shyfttracerinterface/tracer_interface.go | 5 + 10 files changed, 280 insertions(+), 68 deletions(-) delete mode 100644 core/shyft_tracer.go create mode 100644 eth/shyft_tracer.go create mode 100644 shyfttracerinterface/tracer_interface.go diff --git a/core/shyft_database_util.go b/core/shyft_database_util.go index 4e464d211b..2b8fe64b05 100644 --- a/core/shyft_database_util.go +++ b/core/shyft_database_util.go @@ -13,8 +13,15 @@ import ( _ "github.com/lib/pq" 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 type SBlock struct { Hash string @@ -165,7 +172,7 @@ func SwriteTransactions(sqldb *sql.DB, tx *types.Transaction, blockHash common.H Data: tx.Data(), } txHash := txData.TxHash.Hex() - MyTraceTransaction(txHash) //.chaindb_global + IShyftTracer.MyTraceTransaction(txHash) //.chaindb_global from := txData.From.Hex() blockHasher := txData.BlockHash amount := txData.Amount.String() diff --git a/core/shyft_tracer.go b/core/shyft_tracer.go deleted file mode 100644 index 56581b046f..0000000000 --- a/core/shyft_tracer.go +++ /dev/null @@ -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 -} \ No newline at end of file diff --git a/eth/api.go b/eth/api.go index d2491f7821..a345b57e49 100644 --- a/eth/api.go +++ b/eth/api.go @@ -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 // the private debugging endpoint. -type PrivateDebugAPI struct { +type PrivateDebugAPI struct { config *params.ChainConfig eth *Ethereum } diff --git a/eth/api_tracer.go b/eth/api_tracer.go index 8f2fd54568..81622f208e 100644 --- a/eth/api_tracer.go +++ b/eth/api_tracer.go @@ -532,6 +532,189 @@ func (api *PrivateDebugAPI) computeStateDB(block *types.Block, reexec uint64) (* // 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, 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 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) diff --git a/eth/backend.go b/eth/backend.go index 8e2f81bb6e..34d847bf2c 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -51,7 +51,7 @@ import ( var BlockchainObject *core.BlockChain -var DebugApi *PrivateDebugAPI +var DebugApi PrivateDebugAPI type LesServer interface { Start(srvr *p2p.Server) @@ -106,6 +106,9 @@ func (s *Ethereum) AddLesServer(ls LesServer) { // initialisation of the common Ethereum object) func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) { + shyft_tracer := new(ShyftTracer) + core.SetIShyftTracer(shyft_tracer) + fmt.Println("++++++++++") _, file, no, ok := runtime.Caller(1) if ok { diff --git a/eth/chaindb.go b/eth/chaindb.go index e17cd37771..f4ced9929b 100644 --- a/eth/chaindb.go +++ b/eth/chaindb.go @@ -4,22 +4,27 @@ import ( "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/node" "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) { fmt.Println("DO WE GET HERE ++++++++++++++++++++++++++++++++") fmt.Printf("%+v", ctx) - if core.Chaindb_global != nil { - return core.Chaindb_global, nil + 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 { - core.SetChainDB(chainDb) - return core.Chaindb_global, nil + SetChainDB(chainDb) + return Chaindb_global, nil } return nil, err } \ No newline at end of file diff --git a/eth/shyft_tracer.go b/eth/shyft_tracer.go new file mode 100644 index 0000000000..78fc206d32 --- /dev/null +++ b/eth/shyft_tracer.go @@ -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 +} \ No newline at end of file diff --git a/internal/jsre/jsre.go b/internal/jsre/jsre.go index f05865eca6..7a7ba2efc9 100644 --- a/internal/jsre/jsre.go +++ b/internal/jsre/jsre.go @@ -188,6 +188,8 @@ loop: arguments = make([]interface{}, 1) } arguments[0] = timer.call.ArgumentList[0] + fmt.Println("The arguments are") + fmt.Println(arguments) _, err := vm.Call(`Function.call.call`, nil, arguments...) if err != nil { fmt.Println("js error:", err, arguments) diff --git a/rpc/http.go b/rpc/http.go index 9805d69b63..3011222483 100644 --- a/rpc/http.go +++ b/rpc/http.go @@ -231,6 +231,10 @@ func (h *virtualHostHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { } if ipAddr := net.ParseIP(host); ipAddr != nil { // 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) return diff --git a/shyfttracerinterface/tracer_interface.go b/shyfttracerinterface/tracer_interface.go new file mode 100644 index 0000000000..a2f775e570 --- /dev/null +++ b/shyfttracerinterface/tracer_interface.go @@ -0,0 +1,5 @@ +package shyfttracerinterface + +type IShyftTracer interface { + MyTraceTransaction(hash string) (interface{}) +} From bf5b37902508dae761d459a9deceb6ca2e93683c Mon Sep 17 00:00:00 2001 From: Dustin Brickwood Date: Wed, 4 Jul 2018 20:31:29 -0400 Subject: [PATCH 07/21] need to resolve dereference issue in node.go --- core/blockchain.go | 3 +- core/shyft_database_util.go | 25 ++++++++-- eth/api_tracer.go | 21 +++++++++ eth/backend.go | 1 - eth/shyft_tracer.go | 60 ++++++------------------ miner/worker.go | 1 - rpc/http.go | 4 -- shyfttracerinterface/tracer_interface.go | 7 ++- 8 files changed, 63 insertions(+), 59 deletions(-) diff --git a/core/blockchain.go b/core/blockchain.go index f40f6019e7..47a3c65913 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -1002,7 +1002,7 @@ func (bc *BlockChain) WriteBlockWithState(block *types.Block, receipts []*types. } // NOTE:SHYFT - Write block data for block explorer - fmt.Printf("\n\t[BLOCKCHAIN.GO bc.chainConfig] %+v", bc.chainConfig) + //fmt.Printf("\n\t[BLOCKCHAIN.GO bc.chainConfig] %+v", bc.chainConfig) if err := SWriteBlock(block, receipts); err != nil { return NonStatTy, err } @@ -1026,7 +1026,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) { - fmt.Println("++++++++++ insertChain +++++++++") _, file, no, ok := runtime.Caller(1) if ok { fmt.Printf("called from %s#%d\n", file, no) diff --git a/core/shyft_database_util.go b/core/shyft_database_util.go index 2b8fe64b05..5186c8c5a2 100644 --- a/core/shyft_database_util.go +++ b/core/shyft_database_util.go @@ -4,16 +4,19 @@ import ( "encoding/json" "fmt" "math/big" -"github.com/ethereum/go-ethereum/common" -"github.com/ethereum/go-ethereum/core/types" "time" "strconv" "database/sql" "log" - _ "github.com/lib/pq" -Rewards "github.com/ethereum/go-ethereum/consensus/ethash" + + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" + Rewards "github.com/ethereum/go-ethereum/consensus/ethash" "github.com/ethereum/go-ethereum/shyfttracerinterface" + "github.com/ethereum/go-ethereum/node" + "reflect" + ) var IShyftTracer shyfttracerinterface.IShyftTracer @@ -171,8 +174,20 @@ func SwriteTransactions(sqldb *sql.DB, tx *types.Transaction, blockHash common.H Nonce: tx.Nonce(), Data: tx.Data(), } + + hash := txData.TxHash + fmt.Println(reflect.TypeOf(hash)) txHash := txData.TxHash.Hex() - IShyftTracer.MyTraceTransaction(txHash) //.chaindb_global + //IShyftTracer.MyTraceTransaction(txHash) + + // + var stack *node.Node + fmt.Println(reflect.TypeOf(stack)) + + prayer, err := IShyftTracer.GetTracerToRun(hash, stack) + fmt.Println("THIS IS A PRAYER", prayer) + fmt.Println(err) + from := txData.From.Hex() blockHasher := txData.BlockHash amount := txData.Amount.String() diff --git a/eth/api_tracer.go b/eth/api_tracer.go index 81622f208e..47c4fd599c 100644 --- a/eth/api_tracer.go +++ b/eth/api_tracer.go @@ -38,6 +38,7 @@ import ( "github.com/ethereum/go-ethereum/rlp" "github.com/ethereum/go-ethereum/rpc" "github.com/ethereum/go-ethereum/trie" + ) const ( @@ -529,6 +530,26 @@ func (api *PrivateDebugAPI) computeStateDB(block *types.Block, reexec uint64) (* return statedb, nil } + +//func GetTracerToRun(hash common.Hash) (interface{}, error) { +// config2 := params.ShyftNetworkChainConfig +// var cfg *Config +// fmt.Println(reflect.TypeOf(cfg)) +// var ctx context.Context +// var config *TraceConfig +// var fullNode *Ethereum +// var stack *node.Node +// fmt.Println(reflect.TypeOf(stack)) +// err := stack.Register(func(ctx *node.ServiceContext) (node.Service, error) { +// fullNode, err := New(ctx, cfg) +// return fullNode, err +// }) +// fmt.Println(err) +// privateAPI := NewPrivateDebugAPI(config2, fullNode) +// return privateAPI.TraceTransaction(ctx, hash, config) +//} + + // 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, hash common.Hash, config *TraceConfig) (interface{}, error) { diff --git a/eth/backend.go b/eth/backend.go index 34d847bf2c..5737865057 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -109,7 +109,6 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) { shyft_tracer := new(ShyftTracer) core.SetIShyftTracer(shyft_tracer) - fmt.Println("++++++++++") _, file, no, ok := runtime.Caller(1) if ok { fmt.Printf("called from %s#%d\n", file, no) diff --git a/eth/shyft_tracer.go b/eth/shyft_tracer.go index 78fc206d32..24f31019ca 100644 --- a/eth/shyft_tracer.go +++ b/eth/shyft_tracer.go @@ -3,59 +3,29 @@ package eth import ( "github.com/ethereum/go-ethereum/common" "fmt" - "github.com/ethereum/go-ethereum/core" + "github.com/ethereum/go-ethereum/node" + "github.com/ethereum/go-ethereum/params" + "context" ) -//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) +func (st ShyftTracer) GetTracerToRun(hash common.Hash, stack *node.Node) (interface{}, error) { + config2 := params.ShyftNetworkChainConfig + var cfg *Config + var ctx context.Context + var config *TraceConfig + var fullNode *Ethereum - - //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) + err := stack.Register(func(ctx *node.ServiceContext) (node.Service, error) { + fullNode, err := New(ctx, cfg) + return fullNode, err + }) 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 + privateAPI := NewPrivateDebugAPI(config2, fullNode) + return privateAPI.TraceTransaction(ctx, hash, config) } func setEthObject(ethobj interface{}){ diff --git a/miner/worker.go b/miner/worker.go index d1880456fc..fa331b53eb 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -309,7 +309,6 @@ func (self *worker) wait() { for _, log := range work.state.Logs() { log.BlockHash = block.Hash() } - fmt.Printf("\n\t[WORKER.GO self.eth] %+v\n", self.eth) // NOTE:SHYFT Added eth to writeBlockWithState stat, err := self.chain.WriteBlockWithState(block, work.receipts, work.state) if err != nil { diff --git a/rpc/http.go b/rpc/http.go index 3011222483..9805d69b63 100644 --- a/rpc/http.go +++ b/rpc/http.go @@ -231,10 +231,6 @@ func (h *virtualHostHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { } if ipAddr := net.ParseIP(host); ipAddr != nil { // 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) return diff --git a/shyfttracerinterface/tracer_interface.go b/shyfttracerinterface/tracer_interface.go index a2f775e570..40d341b028 100644 --- a/shyfttracerinterface/tracer_interface.go +++ b/shyfttracerinterface/tracer_interface.go @@ -1,5 +1,10 @@ package shyfttracerinterface +import ( + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/node" +) + type IShyftTracer interface { - MyTraceTransaction(hash string) (interface{}) + GetTracerToRun(hash common.Hash, stack *node.Node) (interface{}, error) } From 34b2b9b7b9be801591dc2a728f328dd10d12082c Mon Sep 17 00:00:00 2001 From: Dustin Brickwood Date: Wed, 11 Jul 2018 12:10:49 -0400 Subject: [PATCH 08/21] sneding js tracer from golang --- core/database_util.go | 10 +- core/shyft_database_util.go | 16 +- eth/api_tracer.go | 227 +----- eth/backend.go | 40 +- eth/shyft_tracer.go | 38 +- eth/tracers/tracer.go | 12 +- .../build/contracts/Migrations.json | 230 +++--- .../build/contracts/Transfers.json | 686 +++++++++--------- .../build/contracts/Transfers2.json | 16 +- .../contracts/Migrations.sol | 2 +- .../contracts/Transfers.sol | 2 +- .../transfer-through-master/package-lock.json | 487 ++++++++++++- .../web3/transfer-through-master/package.json | 5 +- shyfttracerinterface/tracer_interface.go | 3 +- 14 files changed, 1043 insertions(+), 731 deletions(-) diff --git a/core/database_util.go b/core/database_util.go index 8aabd94034..af88b7733c 100644 --- a/core/database_util.go +++ b/core/database_util.go @@ -265,12 +265,12 @@ func GetBlockReceipts(db DatabaseReader, hash common.Hash, number uint64) types. // GetTxLookupEntry retrieves the positional metadata associated with a transaction // hash to allow retrieving the transaction or receipt by hash. func GetTxLookupEntry(db DatabaseReader, hash common.Hash) (common.Hash, uint64, uint64) { + fmt.Println("[GetTxLookupEntry FUNCTION RAN]") // Load the positional metadata from disk and bail if it fails - fmt.Println("INSIDE GetTxLookupEntry ") - fmt.Println("the db is ") - fmt.Println(db) - fmt.Println("the hash is") - fmt.Println(hash) + //fmt.Println("INSIDE GetTxLookupEntry ") + //fmt.Println("the db is ") + //fmt.Println(db) + fmt.Println("the hash is", hash.String()) data, _ := db.Get(append(lookupPrefix, hash.Bytes()...)) fmt.Println("the data is ") fmt.Println(data) diff --git a/core/shyft_database_util.go b/core/shyft_database_util.go index 5186c8c5a2..62673984cf 100644 --- a/core/shyft_database_util.go +++ b/core/shyft_database_util.go @@ -14,9 +14,6 @@ _ "github.com/lib/pq" "github.com/ethereum/go-ethereum/core/types" Rewards "github.com/ethereum/go-ethereum/consensus/ethash" "github.com/ethereum/go-ethereum/shyfttracerinterface" - "github.com/ethereum/go-ethereum/node" - "reflect" - ) var IShyftTracer shyfttracerinterface.IShyftTracer @@ -175,18 +172,11 @@ func SwriteTransactions(sqldb *sql.DB, tx *types.Transaction, blockHash common.H Data: tx.Data(), } - hash := txData.TxHash - fmt.Println(reflect.TypeOf(hash)) + //hash := txData.TxHash txHash := txData.TxHash.Hex() - //IShyftTracer.MyTraceTransaction(txHash) - // - var stack *node.Node - fmt.Println(reflect.TypeOf(stack)) - - prayer, err := IShyftTracer.GetTracerToRun(hash, stack) - fmt.Println("THIS IS A PRAYER", prayer) - fmt.Println(err) + //prayer, _ := IShyftTracer.GetTracerToRun(hash) + //fmt.Printf("%+v\n", prayer) from := txData.From.Hex() blockHasher := txData.BlockHash diff --git a/eth/api_tracer.go b/eth/api_tracer.go index 47c4fd599c..f8740f3b13 100644 --- a/eth/api_tracer.go +++ b/eth/api_tracer.go @@ -125,7 +125,7 @@ func (api *PrivateDebugAPI) TraceChain(ctx context.Context, start, end rpc.Block // traceChain configures a new tracer according to the provided configuration, and // executes all the transactions contained within. The return value will be one item // per transaction, dependent on the requestd tracer. -func (api *PrivateDebugAPI) traceChain(ctx context.Context, start, end *types.Block, config *TraceConfig) (*rpc.Subscription, error) { + func (api *PrivateDebugAPI) traceChain(ctx context.Context, start, end *types.Block, config *TraceConfig) (*rpc.Subscription, error) { // Tracing a chain is a **long** operation, only do with subscriptions notifier, supported := rpc.NotifierFromContext(ctx) if !supported { @@ -530,229 +530,16 @@ func (api *PrivateDebugAPI) computeStateDB(block *types.Block, reexec uint64) (* return statedb, nil } - -//func GetTracerToRun(hash common.Hash) (interface{}, error) { -// config2 := params.ShyftNetworkChainConfig -// var cfg *Config -// fmt.Println(reflect.TypeOf(cfg)) -// var ctx context.Context -// var config *TraceConfig -// var fullNode *Ethereum -// var stack *node.Node -// fmt.Println(reflect.TypeOf(stack)) -// err := stack.Register(func(ctx *node.ServiceContext) (node.Service, error) { -// fullNode, err := New(ctx, cfg) -// return fullNode, err -// }) -// fmt.Println(err) -// privateAPI := NewPrivateDebugAPI(config2, fullNode) -// return privateAPI.TraceTransaction(ctx, hash, config) -//} - - // 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, 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 - 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) - // Retrieve the transaction and assemble its EVM context - //fmt.Println("IN TRACE TRANSACTION the chaindb is ") - //fmt.Println(chaindb) - //fmt.Println("IN TRACE TRANSACTION the common hash is ") - //fmt.Println(hash) + tx, blockHash, _, index := core.GetTransaction(api.eth.ChainDb(), hash) if tx == nil { return nil, fmt.Errorf("transaction %x not found", hash) } - fmt.Println("the tx is in TraceTransaction") - fmt.Println(tx) - fmt.Println(blockHash) - fmt.Println(index) + fmt.Println("TX IN TRACETRANSACTION", tx) reexec := defaultTraceReexec if config != nil && config.Reexec != nil { reexec = *config.Reexec @@ -761,10 +548,6 @@ func (api *PrivateDebugAPI) TraceTransaction(ctx context.Context, hash common.Ha if err != nil { return nil, err } - // Trace the transaction and return - //fmt.Println("\n\n\t\tRETURN") - //fmt.Println(api.traceTx(ctx, msg, vmctx, statedb, config)) - //fmt.Println("RETURN FINISHED") return api.traceTx(ctx, msg, vmctx, statedb, config) } @@ -773,6 +556,8 @@ func (api *PrivateDebugAPI) TraceTransaction(ctx context.Context, hash common.Ha // be tracer dependent. func (api *PrivateDebugAPI) traceTx(ctx context.Context, message core.Message, vmctx vm.Context, statedb *state.StateDB, config *TraceConfig) (interface{}, error) { // Assemble the structured logger or the JavaScript tracer + fmt.Println("\n [API_TRACER.GO traceTX func]") + // fmt.Printf("%+v", config, "THIS IS CONFIG") var ( tracer vm.Tracer err error @@ -787,6 +572,7 @@ func (api *PrivateDebugAPI) traceTx(ctx context.Context, message core.Message, v } } // Constuct the JavaScript tracer to execute with + fmt.Printf("%+v \n", *config.Tracer) if tracer, err = tracers.New(*config.Tracer); err != nil { return nil, err } @@ -822,6 +608,7 @@ func (api *PrivateDebugAPI) traceTx(ctx context.Context, message core.Message, v }, nil case *tracers.Tracer: + fmt.Println("THIS RAN MF") return tracer.GetResult() default: diff --git a/eth/backend.go b/eth/backend.go index 5737865057..7d705ab0e6 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -102,12 +102,47 @@ func (s *Ethereum) AddLesServer(ls LesServer) { ls.SetBloomBitsIndexer(s.bloomIndexer) } +func SNew(config *Config) (*Ethereum, error) { + stopDbUpgrade := upgradeDeduplicateData(Chaindb_global) + chainConfig, _, _ := core.SetupGenesisBlock(Chaindb_global, config.Genesis) + + eth := &Ethereum{ + config: config, + chainDb: Chaindb_global, + chainConfig: chainConfig, + //eventMux: ctx.EventMux, + //accountManager: ctx.AccountManager, + //engine: CreateConsensusEngine(ctx, &config.Ethash, chainConfig, Chaindb_global), + shutdownChan: make(chan bool), + stopDbUpgrade: stopDbUpgrade, + networkId: config.NetworkId, + gasPrice: config.GasPrice, + etherbase: config.Etherbase, + bloomRequests: make(chan chan *bloombits.Retrieval), + bloomIndexer: NewBloomIndexer(Chaindb_global, params.BloomBitsBlocks), + } + + //var ( + // vmConfig = vm.Config{EnablePreimageRecording: config.EnablePreimageRecording} + // cacheConfig = &core.CacheConfig{Disabled: config.NoPruning, TrieNodeLimit: config.TrieCache, TrieTimeLimit: config.TrieTimeout} + //) + // + //eth.blockchain, err = core.NewBlockChain(chainDb, cacheConfig, eth.chainConfig, eth.engine, vmConfig) + // + //BlockchainObject = eth.blockchain + + eth.blockchain = BlockchainObject + + return eth, nil +} + // New creates a new Ethereum object (including the // initialisation of the common Ethereum object) func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) { shyft_tracer := new(ShyftTracer) core.SetIShyftTracer(shyft_tracer) + setGlobalConfig(config) _, file, no, ok := runtime.Caller(1) if ok { @@ -125,8 +160,6 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) { return nil, err } - // @TODO: Create Genesis Block - stopDbUpgrade := upgradeDeduplicateData(chainDb) chainConfig, genesisHash, genesisErr := core.SetupGenesisBlock(chainDb, config.Genesis) if _, ok := genesisErr.(*params.ConfigCompatError); genesisErr != nil && !ok { @@ -167,7 +200,7 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) { eth.blockchain, err = core.NewBlockChain(chainDb, cacheConfig, eth.chainConfig, eth.engine, vmConfig) BlockchainObject = eth.blockchain - + if err != nil { return nil, err } @@ -222,7 +255,6 @@ func makeExtraData(extra []byte) []byte { // CreateDB creates the chain database. func CreateDB(ctx *node.ServiceContext, config *Config, name string) (ethdb.Database, error) { - fmt.Println("in create db") db, err := ctx.OpenDatabase(name, config.DatabaseCache, config.DatabaseHandles) if err != nil { return nil, err diff --git a/eth/shyft_tracer.go b/eth/shyft_tracer.go index 24f31019ca..73bacd3b16 100644 --- a/eth/shyft_tracer.go +++ b/eth/shyft_tracer.go @@ -2,32 +2,42 @@ package eth import ( "github.com/ethereum/go-ethereum/common" - "fmt" - "github.com/ethereum/go-ethereum/node" "github.com/ethereum/go-ethereum/params" "context" + "fmt" ) var EthereumObject interface{} type ShyftTracer struct {} - -func (st ShyftTracer) GetTracerToRun(hash common.Hash, stack *node.Node) (interface{}, error) { +//( +func (st ShyftTracer) GetTracerToRun (hash common.Hash) (interface{}, error) { config2 := params.ShyftNetworkChainConfig - var cfg *Config - var ctx context.Context - var config *TraceConfig - var fullNode *Ethereum - err := stack.Register(func(ctx *node.ServiceContext) (node.Service, error) { - fullNode, err := New(ctx, cfg) - return fullNode, err - }) - fmt.Println(err) + jsTracer := "callTracer" + + // + //var cfg *Config + var ctx2 context.Context + config := &TraceConfig{ + LogConfig: nil, + Tracer: &jsTracer, // needs to be non-nil + Timeout: nil, + Reexec: nil, + } + fmt.Printf("%+v", config, "THIS IS CONFIG IN SHYFT_TRACER") + //var fullNode *Ethereum + fullNode, _ := SNew(Global_config) privateAPI := NewPrivateDebugAPI(config2, fullNode) - return privateAPI.TraceTransaction(ctx, hash, config) + return privateAPI.TraceTransaction(ctx2, hash, config) } func setEthObject(ethobj interface{}){ EthereumObject = ethobj +} + +var Global_config *Config + +func setGlobalConfig(c *Config) { + Global_config = c } \ No newline at end of file diff --git a/eth/tracers/tracer.go b/eth/tracers/tracer.go index f0afeab6cb..8c42b157b3 100644 --- a/eth/tracers/tracer.go +++ b/eth/tracers/tracer.go @@ -307,10 +307,14 @@ type Tracer struct { // which must evaluate to an expression returning an object with 'step', 'fault' // and 'result' functions. func New(code string) (*Tracer, error) { + fmt.Println("\n [TRACER.GO New func]", code) // Resolve any tracers by name and assemble the tracer object if tracer, ok := tracer(code); ok { code = tracer + fmt.Println("\n [ok]", ok) } + fmt.Println("\n [tracer]", tracer) + tracer := &Tracer{ vm: duktape.New(), ctx: make(map[string]interface{}), @@ -497,7 +501,9 @@ func wrapError(context string, err error) error { // CaptureStart implements the Tracer interface to initialize the tracing operation. func (jst *Tracer) CaptureStart(from common.Address, to common.Address, create bool, input []byte, gas uint64, value *big.Int) error { //fmt.Println("\n\n\t\t type: ", reflect.TypeOf(input)) - fmt.Println("\t\t [TRACER INPUT]:", input) + fmt.Println("\t\t [TRACER TO]:", to.String()) + fmt.Println("\t\t [TRACER FROM]:", from.String()) + fmt.Println("\t\t [TRACER VALUE]:", value.String()) fmt.Println("\t\t [TRACER INPUT STRING]:", string(input[:len(input)]), "\n\n") jst.ctx["type"] = "CALL" if create { @@ -568,8 +574,8 @@ func (jst *Tracer) CaptureFault(env *vm.EVM, pc uint64, op vm.OpCode, gas, cost // CaptureEnd is called after the call finishes to finalize the tracing. func (jst *Tracer) CaptureEnd(output []byte, gasUsed uint64, t time.Duration, err error) error { //fmt.Println("\n\n\t\t", reflect.TypeOf(output)) - fmt.Println("\t\t [TRACER OUTPUT]:", output[:len(output)]) - fmt.Println("\t\t [TRACER OUTPUT STRING]:", string(output[:len(output)]), "\n\n") + //fmt.Println("\t\t [TRACER OUTPUT]:", output[:len(output)]) + //fmt.Println("\t\t [TRACER OUTPUT STRING]:", string(output[:len(output)]), "\n\n") jst.ctx["output"] = output jst.ctx["gasUsed"] = gasUsed jst.ctx["time"] = t.String() diff --git a/shyft-cli/web3/transfer-through-master/build/contracts/Migrations.json b/shyft-cli/web3/transfer-through-master/build/contracts/Migrations.json index fae58950b1..d0ea3e2b8a 100755 --- a/shyft-cli/web3/transfer-through-master/build/contracts/Migrations.json +++ b/shyft-cli/web3/transfer-through-master/build/contracts/Migrations.json @@ -64,14 +64,14 @@ "type": "function" } ], - "bytecode": "0x608060405234801561001057600080fd5b50336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506102f8806100606000396000f300608060405260043610610062576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680630900f01014610067578063445df0ac146100aa5780638da5cb5b146100d5578063fdacd5761461012c575b600080fd5b34801561007357600080fd5b506100a8600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610159565b005b3480156100b657600080fd5b506100bf610241565b6040518082815260200191505060405180910390f35b3480156100e157600080fd5b506100ea610247565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561013857600080fd5b506101576004803603810190808035906020019092919050505061026c565b005b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561023d578190508073ffffffffffffffffffffffffffffffffffffffff1663fdacd5766001546040518263ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180828152602001915050600060405180830381600087803b15801561022457600080fd5b505af1158015610238573d6000803e3d6000fd5b505050505b5050565b60015481565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614156102c957806001819055505b505600a165627a7a7230582081dfbd8174037e45d69fcbe70d6680c7a2138f79ab9ba39bdffaa14fb7854aa50029", - "deployedBytecode": "0x608060405260043610610062576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680630900f01014610067578063445df0ac146100aa5780638da5cb5b146100d5578063fdacd5761461012c575b600080fd5b34801561007357600080fd5b506100a8600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610159565b005b3480156100b657600080fd5b506100bf610241565b6040518082815260200191505060405180910390f35b3480156100e157600080fd5b506100ea610247565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561013857600080fd5b506101576004803603810190808035906020019092919050505061026c565b005b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561023d578190508073ffffffffffffffffffffffffffffffffffffffff1663fdacd5766001546040518263ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180828152602001915050600060405180830381600087803b15801561022457600080fd5b505af1158015610238573d6000803e3d6000fd5b505050505b5050565b60015481565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614156102c957806001819055505b505600a165627a7a7230582081dfbd8174037e45d69fcbe70d6680c7a2138f79ab9ba39bdffaa14fb7854aa50029", - "sourceMap": "26:480:0:-;;;115:50;8:9:-1;5:2;;;30:1;27;20:12;5:2;115:50:0;150:10;142:5;;:18;;;;;;;;;;;;;;;;;;26:480;;;;;;", - "deployedSourceMap": "26:480:0:-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;339:165;;8:9:-1;5:2;;;30:1;27;20:12;5:2;339:165:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;74:36;;8:9:-1;5:2;;;30:1;27;20:12;5:2;74:36:0;;;;;;;;;;;;;;;;;;;;;;;50:20;;8:9:-1;5:2;;;30:1;27;20:12;5:2;50:20:0;;;;;;;;;;;;;;;;;;;;;;;;;;;232:103;;8:9:-1;5:2;;;30:1;27;20:12;5:2;232:103:0;;;;;;;;;;;;;;;;;;;;;;;;;;339:165;401:19;215:5;;;;;;;;;;;201:19;;:10;:19;;;197:26;;;434:11;401:45;;452:8;:21;;;474:24;;452:47;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;452:47:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;452:47:0;;;;197:26;339:165;;:::o;74:36::-;;;;:::o;50:20::-;;;;;;;;;;;;;:::o;232:103::-;215:5;;;;;;;;;;;201:19;;:10;:19;;;197:26;;;321:9;294:24;:36;;;;197:26;232:103;:::o", - "source": "pragma solidity ^0.4.23;\n\ncontract Migrations {\n address public owner;\n uint public last_completed_migration;\n\n constructor() public {\n owner = msg.sender;\n }\n\n modifier restricted() {\n if (msg.sender == owner) _;\n }\n\n function setCompleted(uint completed) public restricted {\n last_completed_migration = completed;\n }\n\n function upgrade(address new_address) public restricted {\n Migrations upgraded = Migrations(new_address);\n upgraded.setCompleted(last_completed_migration);\n }\n}\n", - "sourcePath": "/Users/gregmarkou/Jobs/Jobs/ChainSafe/shyftNetwork/shyft_go-ethereum/shyft-cli/web3/transfer-through-master/contracts/Migrations.sol", + "bytecode": "0x608060405234801561001057600080fd5b50336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506102f8806100606000396000f300608060405260043610610062576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680630900f01014610067578063445df0ac146100aa5780638da5cb5b146100d5578063fdacd5761461012c575b600080fd5b34801561007357600080fd5b506100a8600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610159565b005b3480156100b657600080fd5b506100bf610241565b6040518082815260200191505060405180910390f35b3480156100e157600080fd5b506100ea610247565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561013857600080fd5b506101576004803603810190808035906020019092919050505061026c565b005b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561023d578190508073ffffffffffffffffffffffffffffffffffffffff1663fdacd5766001546040518263ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180828152602001915050600060405180830381600087803b15801561022457600080fd5b505af1158015610238573d6000803e3d6000fd5b505050505b5050565b60015481565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614156102c957806001819055505b505600a165627a7a723058204322c068e2f4ea0c2c75a1ad943ff4d1badcc839aea20ef91d899284e74d911b0029", + "deployedBytecode": "0x608060405260043610610062576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680630900f01014610067578063445df0ac146100aa5780638da5cb5b146100d5578063fdacd5761461012c575b600080fd5b34801561007357600080fd5b506100a8600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610159565b005b3480156100b657600080fd5b506100bf610241565b6040518082815260200191505060405180910390f35b3480156100e157600080fd5b506100ea610247565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561013857600080fd5b506101576004803603810190808035906020019092919050505061026c565b005b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561023d578190508073ffffffffffffffffffffffffffffffffffffffff1663fdacd5766001546040518263ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180828152602001915050600060405180830381600087803b15801561022457600080fd5b505af1158015610238573d6000803e3d6000fd5b505050505b5050565b60015481565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614156102c957806001819055505b505600a165627a7a723058204322c068e2f4ea0c2c75a1ad943ff4d1badcc839aea20ef91d899284e74d911b0029", + "sourceMap": "26:488:0:-;;;115:58;8:9:-1;5:2;;;30:1;27;20:12;5:2;115:58:0;158:10;150:5;;:18;;;;;;;;;;;;;;;;;;26:488;;;;;;", + "deployedSourceMap": "26:488:0:-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;347:165;;8:9:-1;5:2;;;30:1;27;20:12;5:2;347:165:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;74:36;;8:9:-1;5:2;;;30:1;27;20:12;5:2;74:36:0;;;;;;;;;;;;;;;;;;;;;;;50:20;;8:9:-1;5:2;;;30:1;27;20:12;5:2;50:20:0;;;;;;;;;;;;;;;;;;;;;;;;;;;240:103;;8:9:-1;5:2;;;30:1;27;20:12;5:2;240:103:0;;;;;;;;;;;;;;;;;;;;;;;;;;347:165;409:19;223:5;;;;;;;;;;;209:19;;:10;:19;;;205:26;;;442:11;409:45;;460:8;:21;;;482:24;;460:47;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;460:47:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;460:47:0;;;;205:26;347:165;;:::o;74:36::-;;;;:::o;50:20::-;;;;;;;;;;;;;:::o;240:103::-;223:5;;;;;;;;;;;209:19;;:10;:19;;;205:26;;;329:9;302:24;:36;;;;205:26;240:103;:::o", + "source": "pragma solidity ^0.4.23;\n\ncontract Migrations {\n address public owner;\n uint public last_completed_migration;\n\n function Migrations() public {\n owner = msg.sender;\n }\n\n modifier restricted() {\n if (msg.sender == owner) _;\n }\n\n function setCompleted(uint completed) public restricted {\n last_completed_migration = completed;\n }\n\n function upgrade(address new_address) public restricted {\n Migrations upgraded = Migrations(new_address);\n upgraded.setCompleted(last_completed_migration);\n }\n}\n", + "sourcePath": "/Users/dustinbrickwood/go/src/github.com/ethereum/go-ethereum/shyft-cli/web3/transfer-through-master/contracts/Migrations.sol", "ast": { - "absolutePath": "/Users/gregmarkou/Jobs/Jobs/ChainSafe/shyftNetwork/shyft_go-ethereum/shyft-cli/web3/transfer-through-master/contracts/Migrations.sol", + "absolutePath": "/Users/dustinbrickwood/go/src/github.com/ethereum/go-ethereum/shyft-cli/web3/transfer-through-master/contracts/Migrations.sol", "exportedSymbols": { "Migrations": [ 56 @@ -160,7 +160,7 @@ "body": { "id": 13, "nodeType": "Block", - "src": "136:29:0", + "src": "144:29:0", "statements": [ { "expression": { @@ -177,7 +177,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 3, - "src": "142:5:0", + "src": "150:5:0", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" @@ -194,7 +194,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 264, - "src": "150:3:0", + "src": "158:3:0", "typeDescriptions": { "typeIdentifier": "t_magic_message", "typeString": "msg" @@ -208,13 +208,13 @@ "memberName": "sender", "nodeType": "MemberAccess", "referencedDeclaration": null, - "src": "150:10:0", + "src": "158:10:0", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, - "src": "142:18:0", + "src": "150:18:0", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" @@ -222,7 +222,7 @@ }, "id": 12, "nodeType": "ExpressionStatement", - "src": "142:18:0" + "src": "150:18:0" } ] }, @@ -232,23 +232,23 @@ "isConstructor": true, "isDeclaredConst": false, "modifiers": [], - "name": "", + "name": "Migrations", "nodeType": "FunctionDefinition", "parameters": { "id": 6, "nodeType": "ParameterList", "parameters": [], - "src": "126:2:0" + "src": "134:2:0" }, "payable": false, "returnParameters": { "id": 7, "nodeType": "ParameterList", "parameters": [], - "src": "136:0:0" + "src": "144:0:0" }, "scope": 56, - "src": "115:50:0", + "src": "115:58:0", "stateMutability": "nonpayable", "superFunction": null, "visibility": "public" @@ -257,7 +257,7 @@ "body": { "id": 22, "nodeType": "Block", - "src": "191:37:0", + "src": "199:37:0", "statements": [ { "condition": { @@ -280,7 +280,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 264, - "src": "201:3:0", + "src": "209:3:0", "typeDescriptions": { "typeIdentifier": "t_magic_message", "typeString": "msg" @@ -294,7 +294,7 @@ "memberName": "sender", "nodeType": "MemberAccess", "referencedDeclaration": null, - "src": "201:10:0", + "src": "209:10:0", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" @@ -309,13 +309,13 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 3, - "src": "215:5:0", + "src": "223:5:0", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, - "src": "201:19:0", + "src": "209:19:0", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" @@ -324,11 +324,11 @@ "falseBody": null, "id": 21, "nodeType": "IfStatement", - "src": "197:26:0", + "src": "205:26:0", "trueBody": { "id": 20, "nodeType": "PlaceholderStatement", - "src": "222:1:0" + "src": "230:1:0" } } ] @@ -341,16 +341,16 @@ "id": 15, "nodeType": "ParameterList", "parameters": [], - "src": "188:2:0" + "src": "196:2:0" }, - "src": "169:59:0", + "src": "177:59:0", "visibility": "internal" }, { "body": { "id": 34, "nodeType": "Block", - "src": "288:47:0", + "src": "296:47:0", "statements": [ { "expression": { @@ -367,7 +367,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 5, - "src": "294:24:0", + "src": "302:24:0", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" @@ -382,13 +382,13 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 25, - "src": "321:9:0", + "src": "329:9:0", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, - "src": "294:36:0", + "src": "302:36:0", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" @@ -396,7 +396,7 @@ }, "id": 33, "nodeType": "ExpressionStatement", - "src": "294:36:0" + "src": "302:36:0" } ] }, @@ -416,14 +416,14 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 23, - "src": "277:10:0", + "src": "285:10:0", "typeDescriptions": { "typeIdentifier": "t_modifier$__$", "typeString": "modifier ()" } }, "nodeType": "ModifierInvocation", - "src": "277:10:0" + "src": "285:10:0" } ], "name": "setCompleted", @@ -438,7 +438,7 @@ "name": "completed", "nodeType": "VariableDeclaration", "scope": 35, - "src": "254:14:0", + "src": "262:14:0", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { @@ -449,7 +449,7 @@ "id": 24, "name": "uint", "nodeType": "ElementaryTypeName", - "src": "254:4:0", + "src": "262:4:0", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" @@ -459,17 +459,17 @@ "visibility": "internal" } ], - "src": "253:16:0" + "src": "261:16:0" }, "payable": false, "returnParameters": { "id": 29, "nodeType": "ParameterList", "parameters": [], - "src": "288:0:0" + "src": "296:0:0" }, "scope": 56, - "src": "232:103:0", + "src": "240:103:0", "stateMutability": "nonpayable", "superFunction": null, "visibility": "public" @@ -478,7 +478,7 @@ "body": { "id": 54, "nodeType": "Block", - "src": "395:109:0", + "src": "403:109:0", "statements": [ { "assignments": [ @@ -491,7 +491,7 @@ "name": "upgraded", "nodeType": "VariableDeclaration", "scope": 55, - "src": "401:19:0", + "src": "409:19:0", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { @@ -504,7 +504,7 @@ "name": "Migrations", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 56, - "src": "401:10:0", + "src": "409:10:0", "typeDescriptions": { "typeIdentifier": "t_contract$_Migrations_$56", "typeString": "contract Migrations" @@ -525,7 +525,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 37, - "src": "434:11:0", + "src": "442:11:0", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" @@ -544,7 +544,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 56, - "src": "423:10:0", + "src": "431:10:0", "typeDescriptions": { "typeIdentifier": "t_type$_t_contract$_Migrations_$56_$", "typeString": "type(contract Migrations)" @@ -558,14 +558,14 @@ "lValueRequested": false, "names": [], "nodeType": "FunctionCall", - "src": "423:23:0", + "src": "431:23:0", "typeDescriptions": { "typeIdentifier": "t_contract$_Migrations_$56", "typeString": "contract Migrations" } }, "nodeType": "VariableDeclarationStatement", - "src": "401:45:0" + "src": "409:45:0" }, { "expression": { @@ -578,7 +578,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 5, - "src": "474:24:0", + "src": "482:24:0", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" @@ -599,7 +599,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 43, - "src": "452:8:0", + "src": "460:8:0", "typeDescriptions": { "typeIdentifier": "t_contract$_Migrations_$56", "typeString": "contract Migrations" @@ -613,7 +613,7 @@ "memberName": "setCompleted", "nodeType": "MemberAccess", "referencedDeclaration": 35, - "src": "452:21:0", + "src": "460:21:0", "typeDescriptions": { "typeIdentifier": "t_function_external_nonpayable$_t_uint256_$returns$__$", "typeString": "function (uint256) external" @@ -627,7 +627,7 @@ "lValueRequested": false, "names": [], "nodeType": "FunctionCall", - "src": "452:47:0", + "src": "460:47:0", "typeDescriptions": { "typeIdentifier": "t_tuple$__$", "typeString": "tuple()" @@ -635,7 +635,7 @@ }, "id": 53, "nodeType": "ExpressionStatement", - "src": "452:47:0" + "src": "460:47:0" } ] }, @@ -655,14 +655,14 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 23, - "src": "384:10:0", + "src": "392:10:0", "typeDescriptions": { "typeIdentifier": "t_modifier$__$", "typeString": "modifier ()" } }, "nodeType": "ModifierInvocation", - "src": "384:10:0" + "src": "392:10:0" } ], "name": "upgrade", @@ -677,7 +677,7 @@ "name": "new_address", "nodeType": "VariableDeclaration", "scope": 55, - "src": "356:19:0", + "src": "364:19:0", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { @@ -688,7 +688,7 @@ "id": 36, "name": "address", "nodeType": "ElementaryTypeName", - "src": "356:7:0", + "src": "364:7:0", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" @@ -698,30 +698,30 @@ "visibility": "internal" } ], - "src": "355:21:0" + "src": "363:21:0" }, "payable": false, "returnParameters": { "id": 41, "nodeType": "ParameterList", "parameters": [], - "src": "395:0:0" + "src": "403:0:0" }, "scope": 56, - "src": "339:165:0", + "src": "347:165:0", "stateMutability": "nonpayable", "superFunction": null, "visibility": "public" } ], "scope": 57, - "src": "26:480:0" + "src": "26:488:0" } ], - "src": "0:507:0" + "src": "0:515:0" }, "legacyAST": { - "absolutePath": "/Users/gregmarkou/Jobs/Jobs/ChainSafe/shyftNetwork/shyft_go-ethereum/shyft-cli/web3/transfer-through-master/contracts/Migrations.sol", + "absolutePath": "/Users/dustinbrickwood/go/src/github.com/ethereum/go-ethereum/shyft-cli/web3/transfer-through-master/contracts/Migrations.sol", "exportedSymbols": { "Migrations": [ 56 @@ -810,7 +810,7 @@ "body": { "id": 13, "nodeType": "Block", - "src": "136:29:0", + "src": "144:29:0", "statements": [ { "expression": { @@ -827,7 +827,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 3, - "src": "142:5:0", + "src": "150:5:0", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" @@ -844,7 +844,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 264, - "src": "150:3:0", + "src": "158:3:0", "typeDescriptions": { "typeIdentifier": "t_magic_message", "typeString": "msg" @@ -858,13 +858,13 @@ "memberName": "sender", "nodeType": "MemberAccess", "referencedDeclaration": null, - "src": "150:10:0", + "src": "158:10:0", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, - "src": "142:18:0", + "src": "150:18:0", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" @@ -872,7 +872,7 @@ }, "id": 12, "nodeType": "ExpressionStatement", - "src": "142:18:0" + "src": "150:18:0" } ] }, @@ -882,23 +882,23 @@ "isConstructor": true, "isDeclaredConst": false, "modifiers": [], - "name": "", + "name": "Migrations", "nodeType": "FunctionDefinition", "parameters": { "id": 6, "nodeType": "ParameterList", "parameters": [], - "src": "126:2:0" + "src": "134:2:0" }, "payable": false, "returnParameters": { "id": 7, "nodeType": "ParameterList", "parameters": [], - "src": "136:0:0" + "src": "144:0:0" }, "scope": 56, - "src": "115:50:0", + "src": "115:58:0", "stateMutability": "nonpayable", "superFunction": null, "visibility": "public" @@ -907,7 +907,7 @@ "body": { "id": 22, "nodeType": "Block", - "src": "191:37:0", + "src": "199:37:0", "statements": [ { "condition": { @@ -930,7 +930,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 264, - "src": "201:3:0", + "src": "209:3:0", "typeDescriptions": { "typeIdentifier": "t_magic_message", "typeString": "msg" @@ -944,7 +944,7 @@ "memberName": "sender", "nodeType": "MemberAccess", "referencedDeclaration": null, - "src": "201:10:0", + "src": "209:10:0", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" @@ -959,13 +959,13 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 3, - "src": "215:5:0", + "src": "223:5:0", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, - "src": "201:19:0", + "src": "209:19:0", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" @@ -974,11 +974,11 @@ "falseBody": null, "id": 21, "nodeType": "IfStatement", - "src": "197:26:0", + "src": "205:26:0", "trueBody": { "id": 20, "nodeType": "PlaceholderStatement", - "src": "222:1:0" + "src": "230:1:0" } } ] @@ -991,16 +991,16 @@ "id": 15, "nodeType": "ParameterList", "parameters": [], - "src": "188:2:0" + "src": "196:2:0" }, - "src": "169:59:0", + "src": "177:59:0", "visibility": "internal" }, { "body": { "id": 34, "nodeType": "Block", - "src": "288:47:0", + "src": "296:47:0", "statements": [ { "expression": { @@ -1017,7 +1017,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 5, - "src": "294:24:0", + "src": "302:24:0", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" @@ -1032,13 +1032,13 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 25, - "src": "321:9:0", + "src": "329:9:0", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, - "src": "294:36:0", + "src": "302:36:0", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" @@ -1046,7 +1046,7 @@ }, "id": 33, "nodeType": "ExpressionStatement", - "src": "294:36:0" + "src": "302:36:0" } ] }, @@ -1066,14 +1066,14 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 23, - "src": "277:10:0", + "src": "285:10:0", "typeDescriptions": { "typeIdentifier": "t_modifier$__$", "typeString": "modifier ()" } }, "nodeType": "ModifierInvocation", - "src": "277:10:0" + "src": "285:10:0" } ], "name": "setCompleted", @@ -1088,7 +1088,7 @@ "name": "completed", "nodeType": "VariableDeclaration", "scope": 35, - "src": "254:14:0", + "src": "262:14:0", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { @@ -1099,7 +1099,7 @@ "id": 24, "name": "uint", "nodeType": "ElementaryTypeName", - "src": "254:4:0", + "src": "262:4:0", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" @@ -1109,17 +1109,17 @@ "visibility": "internal" } ], - "src": "253:16:0" + "src": "261:16:0" }, "payable": false, "returnParameters": { "id": 29, "nodeType": "ParameterList", "parameters": [], - "src": "288:0:0" + "src": "296:0:0" }, "scope": 56, - "src": "232:103:0", + "src": "240:103:0", "stateMutability": "nonpayable", "superFunction": null, "visibility": "public" @@ -1128,7 +1128,7 @@ "body": { "id": 54, "nodeType": "Block", - "src": "395:109:0", + "src": "403:109:0", "statements": [ { "assignments": [ @@ -1141,7 +1141,7 @@ "name": "upgraded", "nodeType": "VariableDeclaration", "scope": 55, - "src": "401:19:0", + "src": "409:19:0", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { @@ -1154,7 +1154,7 @@ "name": "Migrations", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 56, - "src": "401:10:0", + "src": "409:10:0", "typeDescriptions": { "typeIdentifier": "t_contract$_Migrations_$56", "typeString": "contract Migrations" @@ -1175,7 +1175,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 37, - "src": "434:11:0", + "src": "442:11:0", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" @@ -1194,7 +1194,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 56, - "src": "423:10:0", + "src": "431:10:0", "typeDescriptions": { "typeIdentifier": "t_type$_t_contract$_Migrations_$56_$", "typeString": "type(contract Migrations)" @@ -1208,14 +1208,14 @@ "lValueRequested": false, "names": [], "nodeType": "FunctionCall", - "src": "423:23:0", + "src": "431:23:0", "typeDescriptions": { "typeIdentifier": "t_contract$_Migrations_$56", "typeString": "contract Migrations" } }, "nodeType": "VariableDeclarationStatement", - "src": "401:45:0" + "src": "409:45:0" }, { "expression": { @@ -1228,7 +1228,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 5, - "src": "474:24:0", + "src": "482:24:0", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" @@ -1249,7 +1249,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 43, - "src": "452:8:0", + "src": "460:8:0", "typeDescriptions": { "typeIdentifier": "t_contract$_Migrations_$56", "typeString": "contract Migrations" @@ -1263,7 +1263,7 @@ "memberName": "setCompleted", "nodeType": "MemberAccess", "referencedDeclaration": 35, - "src": "452:21:0", + "src": "460:21:0", "typeDescriptions": { "typeIdentifier": "t_function_external_nonpayable$_t_uint256_$returns$__$", "typeString": "function (uint256) external" @@ -1277,7 +1277,7 @@ "lValueRequested": false, "names": [], "nodeType": "FunctionCall", - "src": "452:47:0", + "src": "460:47:0", "typeDescriptions": { "typeIdentifier": "t_tuple$__$", "typeString": "tuple()" @@ -1285,7 +1285,7 @@ }, "id": 53, "nodeType": "ExpressionStatement", - "src": "452:47:0" + "src": "460:47:0" } ] }, @@ -1305,14 +1305,14 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 23, - "src": "384:10:0", + "src": "392:10:0", "typeDescriptions": { "typeIdentifier": "t_modifier$__$", "typeString": "modifier ()" } }, "nodeType": "ModifierInvocation", - "src": "384:10:0" + "src": "392:10:0" } ], "name": "upgrade", @@ -1327,7 +1327,7 @@ "name": "new_address", "nodeType": "VariableDeclaration", "scope": 55, - "src": "356:19:0", + "src": "364:19:0", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { @@ -1338,7 +1338,7 @@ "id": 36, "name": "address", "nodeType": "ElementaryTypeName", - "src": "356:7:0", + "src": "364:7:0", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" @@ -1348,27 +1348,27 @@ "visibility": "internal" } ], - "src": "355:21:0" + "src": "363:21:0" }, "payable": false, "returnParameters": { "id": 41, "nodeType": "ParameterList", "parameters": [], - "src": "395:0:0" + "src": "403:0:0" }, "scope": 56, - "src": "339:165:0", + "src": "347:165:0", "stateMutability": "nonpayable", "superFunction": null, "visibility": "public" } ], "scope": 57, - "src": "26:480:0" + "src": "26:488:0" } ], - "src": "0:507:0" + "src": "0:515:0" }, "compiler": { "name": "solc", @@ -1379,7 +1379,7 @@ "events": {}, "links": {}, "address": "0xfaeccae8c1af6bdfd71095e1b6a2f61c61c8a7e7", - "transactionHash": "0xeee5c7819e1a662e45a8244d02305b531d2c4e11e67383dace9b458dc76f22dc" + "transactionHash": "0x79d68857d23437507895cbdcd033462f3a799fd1b94d51b7e624f6710cfb6c9a" }, "1528420224459": { "events": {}, @@ -1388,6 +1388,6 @@ "transactionHash": "0x1d1b9f147f05f37206bbfa1143bb5ec43c8a1e193d17513471b6d6f58911779c" } }, - "schemaVersion": "2.0.0", - "updatedAt": "2018-06-08T15:58:27.900Z" + "schemaVersion": "2.0.1", + "updatedAt": "2018-07-06T18:05:39.259Z" } \ No newline at end of file diff --git a/shyft-cli/web3/transfer-through-master/build/contracts/Transfers.json b/shyft-cli/web3/transfer-through-master/build/contracts/Transfers.json index cd9330c614..f47209689a 100755 --- a/shyft-cli/web3/transfer-through-master/build/contracts/Transfers.json +++ b/shyft-cli/web3/transfer-through-master/build/contracts/Transfers.json @@ -109,14 +109,14 @@ "type": "function" } ], - "bytecode": "0x608060405234801561001057600080fd5b506100196100de565b604051809103906000f080158015610035573d6000803e3d6000fd5b50600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506100ee565b60405161010c806107a683390190565b6106a9806100fd6000396000f300608060405260043610610078576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680636b557a221461007d578063a9059cbb146100ed578063c9116b691461013a578063d0e30db014610165578063e3d670d714610183578063f3fef3a3146101da575b600080fd5b34801561008957600080fd5b506100eb6004803603810190808035906020019082018035906020019080806020026020016040519081016040528093929190818152602001838360200280828437820191505050505050919291929080359060200190929190505050610227565b005b3480156100f957600080fd5b50610138600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610349565b005b34801561014657600080fd5b5061014f6104a9565b6040518082815260200191505060405180910390f35b61016d6104ef565b6040518082815260200191505060405180910390f35b34801561018f57600080fd5b506101c4600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610581565b6040518082815260200191505060405180910390f35b3480156101e657600080fd5b50610225600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610599565b005b600080835191508183026000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015151561027d57600080fd5b8183026000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550600090505b818110156103435783818151811015156102e657fe5b9060200190602002015173ffffffffffffffffffffffffffffffffffffffff166108fc849081150290604051600060405180830381858888f19350505050158015610335573d6000803e3d6000fd5b5080806001019150506102d0565b50505050565b6000816000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015151561039857600080fd5b60405180807f7472616e73666572286164647265737329000000000000000000000000000000815250601101905060405180910390209050600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1682827c0100000000000000000000000000000000000000000000000000000000900490856040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060006040518083038185885af1935050505050505050565b60008060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905090565b6000346000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055506000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905090565b60006020528060005260406000206000915090505481565b806000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101515156105e657600080fd5b806000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055508173ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015610678573d6000803e3d6000fd5b5050505600a165627a7a7230582073b86b0504a0668c11a4b9525431c2c1eb1f06ba1b37ab7b422840967732027c0029608060405234801561001057600080fd5b5060ed8061001f6000396000f300608060405260043610603f576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680631a695230146044575b600080fd5b6076600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506078565b005b8073ffffffffffffffffffffffffffffffffffffffff166108fc349081150290604051600060405180830381858888f1935050505015801560bd573d6000803e3d6000fd5b50505600a165627a7a72305820e95f74106a3328ffadd8b0adb916d92497daab65998ee73cf40afff57dc4b29b0029", - "deployedBytecode": "0x608060405260043610610078576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680636b557a221461007d578063a9059cbb146100ed578063c9116b691461013a578063d0e30db014610165578063e3d670d714610183578063f3fef3a3146101da575b600080fd5b34801561008957600080fd5b506100eb6004803603810190808035906020019082018035906020019080806020026020016040519081016040528093929190818152602001838360200280828437820191505050505050919291929080359060200190929190505050610227565b005b3480156100f957600080fd5b50610138600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610349565b005b34801561014657600080fd5b5061014f6104a9565b6040518082815260200191505060405180910390f35b61016d6104ef565b6040518082815260200191505060405180910390f35b34801561018f57600080fd5b506101c4600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610581565b6040518082815260200191505060405180910390f35b3480156101e657600080fd5b50610225600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610599565b005b600080835191508183026000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015151561027d57600080fd5b8183026000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550600090505b818110156103435783818151811015156102e657fe5b9060200190602002015173ffffffffffffffffffffffffffffffffffffffff166108fc849081150290604051600060405180830381858888f19350505050158015610335573d6000803e3d6000fd5b5080806001019150506102d0565b50505050565b6000816000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015151561039857600080fd5b60405180807f7472616e73666572286164647265737329000000000000000000000000000000815250601101905060405180910390209050600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1682827c0100000000000000000000000000000000000000000000000000000000900490856040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060006040518083038185885af1935050505050505050565b60008060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905090565b6000346000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055506000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905090565b60006020528060005260406000206000915090505481565b806000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101515156105e657600080fd5b806000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055508173ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015610678573d6000803e3d6000fd5b5050505600a165627a7a7230582073b86b0504a0668c11a4b9525431c2c1eb1f06ba1b37ab7b422840967732027c0029", - "sourceMap": "54:979:1:-;;;152:72;8:9:-1;5:2;;;30:1;27;20:12;5:2;152:72:1;181:16;;:::i;:::-;;;;;;;;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;181:16:1;177:1;;:20;;;;;;;;;;;;;;;;;;218:1;;;;;;;;;;;201:6;;:19;;;;;;;;;;;;;;;;;;54:979;;;;;;;;;;;;:::o;:::-;;;;;;;", - "deployedSourceMap": "54:979:1:-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;790:241;;8:9:-1;5:2;;;30:1;27;20:12;5:2;790:241:1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;227:197;;8:9:-1;5:2;;;30:1;27;20:12;5:2;227:197:1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;427:77;;8:9:-1;5:2;;;30:1;27;20:12;5:2;427:77:1;;;;;;;;;;;;;;;;;;;;;;;507:119;;;;;;;;;;;;;;;;;;;;;;;76:40;;8:9:-1;5:2;;;30:1;27;20:12;5:2;76:40:1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;629:158;;8:9:-1;5:2;;;30:1;27;20:12;5:2;629:158:1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;790:241;855:6;969;864;:13;855:22;;921:1;912:6;:10;889:7;:19;897:10;889:19;;;;;;;;;;;;;;;;:33;;881:42;;;;;;;;959:1;950:6;:10;927:7;:19;935:10;927:19;;;;;;;;;;;;;;;;:33;;;;;;;;;;;978:1;969:10;;964:64;985:1;981;:5;964:64;;;997:6;1004:1;997:9;;;;;;;;;;;;;;;;;;:18;;:26;1016:6;997:26;;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;997:26:1;988:3;;;;;;;964:64;;;790:241;;;;:::o;227:197::-;326:10;315:6;292:7;:19;300:10;292:19;;;;;;;;;;;;;;;;:29;;284:38;;;;;;;;346:30;;;;;;;;;;;;;;;;;;;326:51;;381:6;;;;;;;;;;;:11;;399:6;407:3;381:37;;;;412:5;381:37;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;227:197;;;:::o;427:77::-;464:4;481:7;:19;489:10;481:19;;;;;;;;;;;;;;;;474:26;;427:77;:::o;507:119::-;550:4;583:9;560:7;:19;568:10;560:19;;;;;;;;;;;;;;;;:32;;;;;;;;;;;603:7;:19;611:10;603:19;;;;;;;;;;;;;;;;596:26;;507:119;:::o;76:40::-;;;;;;;;;;;;;;;;;:::o;629:158::-;717:6;694:7;:19;702:10;694:19;;;;;;;;;;;;;;;;:29;;686:38;;;;;;;;751:6;728:7;:19;736:10;728:19;;;;;;;;;;;;;;;;:29;;;;;;;;;;;761:5;:14;;:22;776:6;761:22;;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;761:22:1;629:158;;:::o", - "source": "pragma solidity ^0.4.19;\n\nimport \"./Transfers2.sol\";\n\ncontract Transfers {\n\tmapping (address => uint) public balance;\n\tTransfers2 t;\n\taddress t_addr;\n\n\tconstructor() public {\n\t\tt = new Transfers2();\n\t\tt_addr = address(t);\n\t}\n\n\tfunction transfer(address _addr, uint _value) public {\n\t\trequire(balance[msg.sender] >= _value);\n\t\tbytes4 sig = bytes4(keccak256(\"transfer(address)\"));\n\t\tt_addr.call.value(_value)(sig, _addr);\t\t\n\t}\n\n\tfunction myBalance() public returns (uint) {\n\t\treturn balance[msg.sender];\n\t}\n\n\tfunction deposit() public payable returns (uint) {\n\t\tbalance[msg.sender] += msg.value;\n\t\treturn balance[msg.sender];\n\t}\n\n\tfunction withdraw(address _addr, uint _value) public {\n\t\trequire(balance[msg.sender] >= _value);\n\t\tbalance[msg.sender] -= _value;\n\t\t_addr.transfer(_value);\n\t}\n\n\tfunction withdrawMulti(address[] _addrs, uint _value) public {\n\t\tuint l = _addrs.length;\n\t\trequire(balance[msg.sender] >= _value * l);\n\t\tbalance[msg.sender] -= _value * l;\n\t\tfor (uint i = 0; i < l; i++){\n\t\t\t_addrs[i].transfer(_value);\n\t\t}\n\t}\n}", - "sourcePath": "/Users/gregmarkou/Jobs/Jobs/ChainSafe/shyftNetwork/shyft_go-ethereum/shyft-cli/web3/transfer-through-master/contracts/Transfers.sol", + "bytecode": "0x608060405234801561001057600080fd5b506100196100de565b604051809103906000f080158015610035573d6000803e3d6000fd5b50600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506100ee565b60405161010c806107a683390190565b6106a9806100fd6000396000f300608060405260043610610078576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680636b557a221461007d578063a9059cbb146100ed578063c9116b691461013a578063d0e30db014610165578063e3d670d714610183578063f3fef3a3146101da575b600080fd5b34801561008957600080fd5b506100eb6004803603810190808035906020019082018035906020019080806020026020016040519081016040528093929190818152602001838360200280828437820191505050505050919291929080359060200190929190505050610227565b005b3480156100f957600080fd5b50610138600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610349565b005b34801561014657600080fd5b5061014f6104a9565b6040518082815260200191505060405180910390f35b61016d6104ef565b6040518082815260200191505060405180910390f35b34801561018f57600080fd5b506101c4600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610581565b6040518082815260200191505060405180910390f35b3480156101e657600080fd5b50610225600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610599565b005b600080835191508183026000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015151561027d57600080fd5b8183026000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550600090505b818110156103435783818151811015156102e657fe5b9060200190602002015173ffffffffffffffffffffffffffffffffffffffff166108fc849081150290604051600060405180830381858888f19350505050158015610335573d6000803e3d6000fd5b5080806001019150506102d0565b50505050565b6000816000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015151561039857600080fd5b60405180807f7472616e73666572286164647265737329000000000000000000000000000000815250601101905060405180910390209050600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1682827c0100000000000000000000000000000000000000000000000000000000900490856040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060006040518083038185885af1935050505050505050565b60008060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905090565b6000346000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055506000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905090565b60006020528060005260406000206000915090505481565b806000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101515156105e657600080fd5b806000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055508173ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015610678573d6000803e3d6000fd5b5050505600a165627a7a7230582004c04bcb520b99a14d72a172a70df1ab13d8ab5f02cfd7e82369d4cd33a6d2c20029608060405234801561001057600080fd5b5060ed8061001f6000396000f300608060405260043610603f576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680631a695230146044575b600080fd5b6076600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506078565b005b8073ffffffffffffffffffffffffffffffffffffffff166108fc349081150290604051600060405180830381858888f1935050505015801560bd573d6000803e3d6000fd5b50505600a165627a7a723058206b9724f2a2dbdc5e27a309b647c1d11903393ac90b5e54ab4925de752e5f6e760029", + "deployedBytecode": "0x608060405260043610610078576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680636b557a221461007d578063a9059cbb146100ed578063c9116b691461013a578063d0e30db014610165578063e3d670d714610183578063f3fef3a3146101da575b600080fd5b34801561008957600080fd5b506100eb6004803603810190808035906020019082018035906020019080806020026020016040519081016040528093929190818152602001838360200280828437820191505050505050919291929080359060200190929190505050610227565b005b3480156100f957600080fd5b50610138600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610349565b005b34801561014657600080fd5b5061014f6104a9565b6040518082815260200191505060405180910390f35b61016d6104ef565b6040518082815260200191505060405180910390f35b34801561018f57600080fd5b506101c4600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610581565b6040518082815260200191505060405180910390f35b3480156101e657600080fd5b50610225600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610599565b005b600080835191508183026000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015151561027d57600080fd5b8183026000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550600090505b818110156103435783818151811015156102e657fe5b9060200190602002015173ffffffffffffffffffffffffffffffffffffffff166108fc849081150290604051600060405180830381858888f19350505050158015610335573d6000803e3d6000fd5b5080806001019150506102d0565b50505050565b6000816000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015151561039857600080fd5b60405180807f7472616e73666572286164647265737329000000000000000000000000000000815250601101905060405180910390209050600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1682827c0100000000000000000000000000000000000000000000000000000000900490856040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060006040518083038185885af1935050505050505050565b60008060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905090565b6000346000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055506000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905090565b60006020528060005260406000206000915090505481565b806000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101515156105e657600080fd5b806000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055508173ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015610678573d6000803e3d6000fd5b5050505600a165627a7a7230582004c04bcb520b99a14d72a172a70df1ab13d8ab5f02cfd7e82369d4cd33a6d2c20029", + "sourceMap": "54:986:1:-;;;152:79;8:9:-1;5:2;;;30:1;27;20:12;5:2;152:79:1;188:16;;:::i;:::-;;;;;;;;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;188:16:1;184:1;;:20;;;;;;;;;;;;;;;;;;225:1;;;;;;;;;;;208:6;;:19;;;;;;;;;;;;;;;;;;54:986;;;;;;;;;;;;:::o;:::-;;;;;;;", + "deployedSourceMap": "54:986:1:-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;797:241;;8:9:-1;5:2;;;30:1;27;20:12;5:2;797:241:1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;234:197;;8:9:-1;5:2;;;30:1;27;20:12;5:2;234:197:1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;434:77;;8:9:-1;5:2;;;30:1;27;20:12;5:2;434:77:1;;;;;;;;;;;;;;;;;;;;;;;514:119;;;;;;;;;;;;;;;;;;;;;;;76:40;;8:9:-1;5:2;;;30:1;27;20:12;5:2;76:40:1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;636:158;;8:9:-1;5:2;;;30:1;27;20:12;5:2;636:158:1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;797:241;862:6;976;871;:13;862:22;;928:1;919:6;:10;896:7;:19;904:10;896:19;;;;;;;;;;;;;;;;:33;;888:42;;;;;;;;966:1;957:6;:10;934:7;:19;942:10;934:19;;;;;;;;;;;;;;;;:33;;;;;;;;;;;985:1;976:10;;971:64;992:1;988;:5;971:64;;;1004:6;1011:1;1004:9;;;;;;;;;;;;;;;;;;:18;;:26;1023:6;1004:26;;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;1004:26:1;995:3;;;;;;;971:64;;;797:241;;;;:::o;234:197::-;333:10;322:6;299:7;:19;307:10;299:19;;;;;;;;;;;;;;;;:29;;291:38;;;;;;;;353:30;;;;;;;;;;;;;;;;;;;333:51;;388:6;;;;;;;;;;;:11;;406:6;414:3;388:37;;;;419:5;388:37;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;234:197;;;:::o;434:77::-;471:4;488:7;:19;496:10;488:19;;;;;;;;;;;;;;;;481:26;;434:77;:::o;514:119::-;557:4;590:9;567:7;:19;575:10;567:19;;;;;;;;;;;;;;;;:32;;;;;;;;;;;610:7;:19;618:10;610:19;;;;;;;;;;;;;;;;603:26;;514:119;:::o;76:40::-;;;;;;;;;;;;;;;;;:::o;636:158::-;724:6;701:7;:19;709:10;701:19;;;;;;;;;;;;;;;;:29;;693:38;;;;;;;;758:6;735:7;:19;743:10;735:19;;;;;;;;;;;;;;;;:29;;;;;;;;;;;768:5;:14;;:22;783:6;768:22;;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;768:22:1;636:158;;:::o", + "source": "pragma solidity ^0.4.19;\n\nimport \"./Transfers2.sol\";\n\ncontract Transfers {\n\tmapping (address => uint) public balance;\n\tTransfers2 t;\n\taddress t_addr;\n\n\tfunction Transfers() public {\n\t\tt = new Transfers2();\n\t\tt_addr = address(t);\n\t}\n\n\tfunction transfer(address _addr, uint _value) public {\n\t\trequire(balance[msg.sender] >= _value);\n\t\tbytes4 sig = bytes4(keccak256(\"transfer(address)\"));\n\t\tt_addr.call.value(_value)(sig, _addr);\t\t\n\t}\n\n\tfunction myBalance() public returns (uint) {\n\t\treturn balance[msg.sender];\n\t}\n\n\tfunction deposit() public payable returns (uint) {\n\t\tbalance[msg.sender] += msg.value;\n\t\treturn balance[msg.sender];\n\t}\n\n\tfunction withdraw(address _addr, uint _value) public {\n\t\trequire(balance[msg.sender] >= _value);\n\t\tbalance[msg.sender] -= _value;\n\t\t_addr.transfer(_value);\n\t}\n\n\tfunction withdrawMulti(address[] _addrs, uint _value) public {\n\t\tuint l = _addrs.length;\n\t\trequire(balance[msg.sender] >= _value * l);\n\t\tbalance[msg.sender] -= _value * l;\n\t\tfor (uint i = 0; i < l; i++){\n\t\t\t_addrs[i].transfer(_value);\n\t\t}\n\t}\n}", + "sourcePath": "/Users/dustinbrickwood/go/src/github.com/ethereum/go-ethereum/shyft-cli/web3/transfer-through-master/contracts/Transfers.sol", "ast": { - "absolutePath": "/Users/gregmarkou/Jobs/Jobs/ChainSafe/shyftNetwork/shyft_go-ethereum/shyft-cli/web3/transfer-through-master/contracts/Transfers.sol", + "absolutePath": "/Users/dustinbrickwood/go/src/github.com/ethereum/go-ethereum/shyft-cli/web3/transfer-through-master/contracts/Transfers.sol", "exportedSymbols": { "Transfers": [ 233 @@ -137,7 +137,7 @@ "src": "0:24:1" }, { - "absolutePath": "/Users/gregmarkou/Jobs/Jobs/ChainSafe/shyftNetwork/shyft_go-ethereum/shyft-cli/web3/transfer-through-master/contracts/Transfers2.sol", + "absolutePath": "/Users/dustinbrickwood/go/src/github.com/ethereum/go-ethereum/shyft-cli/web3/transfer-through-master/contracts/Transfers2.sol", "file": "./Transfers2.sol", "id": 59, "nodeType": "ImportDirective", @@ -265,7 +265,7 @@ "body": { "id": 82, "nodeType": "Block", - "src": "173:51:1", + "src": "180:51:1", "statements": [ { "expression": { @@ -282,7 +282,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 65, - "src": "177:1:1", + "src": "184:1:1", "typeDescriptions": { "typeIdentifier": "t_contract$_Transfers2_$249", "typeString": "contract Transfers2" @@ -301,7 +301,7 @@ "isPure": false, "lValueRequested": false, "nodeType": "NewExpression", - "src": "181:14:1", + "src": "188:14:1", "typeDescriptions": { "typeIdentifier": "t_function_creation_nonpayable$__$returns$_t_contract$_Transfers2_$249_$", "typeString": "function () returns (contract Transfers2)" @@ -312,7 +312,7 @@ "name": "Transfers2", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 249, - "src": "185:10:1", + "src": "192:10:1", "typeDescriptions": { "typeIdentifier": "t_contract$_Transfers2_$249", "typeString": "contract Transfers2" @@ -327,13 +327,13 @@ "lValueRequested": false, "names": [], "nodeType": "FunctionCall", - "src": "181:16:1", + "src": "188:16:1", "typeDescriptions": { "typeIdentifier": "t_contract$_Transfers2_$249", "typeString": "contract Transfers2" } }, - "src": "177:20:1", + "src": "184:20:1", "typeDescriptions": { "typeIdentifier": "t_contract$_Transfers2_$249", "typeString": "contract Transfers2" @@ -341,7 +341,7 @@ }, "id": 75, "nodeType": "ExpressionStatement", - "src": "177:20:1" + "src": "184:20:1" }, { "expression": { @@ -358,7 +358,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 67, - "src": "201:6:1", + "src": "208:6:1", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" @@ -376,7 +376,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 65, - "src": "218:1:1", + "src": "225:1:1", "typeDescriptions": { "typeIdentifier": "t_contract$_Transfers2_$249", "typeString": "contract Transfers2" @@ -396,7 +396,7 @@ "isPure": true, "lValueRequested": false, "nodeType": "ElementaryTypeNameExpression", - "src": "210:7:1", + "src": "217:7:1", "typeDescriptions": { "typeIdentifier": "t_type$_t_address_$", "typeString": "type(address)" @@ -411,13 +411,13 @@ "lValueRequested": false, "names": [], "nodeType": "FunctionCall", - "src": "210:10:1", + "src": "217:10:1", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, - "src": "201:19:1", + "src": "208:19:1", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" @@ -425,7 +425,7 @@ }, "id": 81, "nodeType": "ExpressionStatement", - "src": "201:19:1" + "src": "208:19:1" } ] }, @@ -435,23 +435,23 @@ "isConstructor": true, "isDeclaredConst": false, "modifiers": [], - "name": "", + "name": "Transfers", "nodeType": "FunctionDefinition", "parameters": { "id": 68, "nodeType": "ParameterList", "parameters": [], - "src": "163:2:1" + "src": "170:2:1" }, "payable": false, "returnParameters": { "id": 69, "nodeType": "ParameterList", "parameters": [], - "src": "173:0:1" + "src": "180:0:1" }, "scope": 233, - "src": "152:72:1", + "src": "152:79:1", "stateMutability": "nonpayable", "superFunction": null, "visibility": "public" @@ -460,7 +460,7 @@ "body": { "id": 118, "nodeType": "Block", - "src": "280:144:1", + "src": "287:144:1", "statements": [ { "expression": { @@ -486,7 +486,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 63, - "src": "292:7:1", + "src": "299:7:1", "typeDescriptions": { "typeIdentifier": "t_mapping$_t_address_$_t_uint256_$", "typeString": "mapping(address => uint256)" @@ -502,7 +502,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 264, - "src": "300:3:1", + "src": "307:3:1", "typeDescriptions": { "typeIdentifier": "t_magic_message", "typeString": "msg" @@ -516,7 +516,7 @@ "memberName": "sender", "nodeType": "MemberAccess", "referencedDeclaration": null, - "src": "300:10:1", + "src": "307:10:1", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" @@ -527,7 +527,7 @@ "isPure": false, "lValueRequested": false, "nodeType": "IndexAccess", - "src": "292:19:1", + "src": "299:19:1", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" @@ -542,13 +542,13 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 87, - "src": "315:6:1", + "src": "322:6:1", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, - "src": "292:29:1", + "src": "299:29:1", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" @@ -570,7 +570,7 @@ 268 ], "referencedDeclaration": 267, - "src": "284:7:1", + "src": "291:7:1", "typeDescriptions": { "typeIdentifier": "t_function_require_pure$_t_bool_$returns$__$", "typeString": "function (bool) pure" @@ -584,7 +584,7 @@ "lValueRequested": false, "names": [], "nodeType": "FunctionCall", - "src": "284:38:1", + "src": "291:38:1", "typeDescriptions": { "typeIdentifier": "t_tuple$__$", "typeString": "tuple()" @@ -592,7 +592,7 @@ }, "id": 98, "nodeType": "ExpressionStatement", - "src": "284:38:1" + "src": "291:38:1" }, { "assignments": [ @@ -605,7 +605,7 @@ "name": "sig", "nodeType": "VariableDeclaration", "scope": 119, - "src": "326:10:1", + "src": "333:10:1", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { @@ -616,7 +616,7 @@ "id": 99, "name": "bytes4", "nodeType": "ElementaryTypeName", - "src": "326:6:1", + "src": "333:6:1", "typeDescriptions": { "typeIdentifier": "t_bytes4", "typeString": "bytes4" @@ -643,7 +643,7 @@ "kind": "string", "lValueRequested": false, "nodeType": "Literal", - "src": "356:19:1", + "src": "363:19:1", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_stringliteral_1a695230cbbb2b7dfd76397005587fe7ab9ee5f528dbc5a16361e8100dc2c499", @@ -664,7 +664,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 258, - "src": "346:9:1", + "src": "353:9:1", "typeDescriptions": { "typeIdentifier": "t_function_sha3_pure$__$returns$_t_bytes32_$", "typeString": "function () pure returns (bytes32)" @@ -678,7 +678,7 @@ "lValueRequested": false, "names": [], "nodeType": "FunctionCall", - "src": "346:30:1", + "src": "353:30:1", "typeDescriptions": { "typeIdentifier": "t_bytes32", "typeString": "bytes32" @@ -698,7 +698,7 @@ "isPure": true, "lValueRequested": false, "nodeType": "ElementaryTypeNameExpression", - "src": "339:6:1", + "src": "346:6:1", "typeDescriptions": { "typeIdentifier": "t_type$_t_bytes4_$", "typeString": "type(bytes4)" @@ -713,14 +713,14 @@ "lValueRequested": false, "names": [], "nodeType": "FunctionCall", - "src": "339:38:1", + "src": "346:38:1", "typeDescriptions": { "typeIdentifier": "t_bytes4", "typeString": "bytes4" } }, "nodeType": "VariableDeclarationStatement", - "src": "326:51:1" + "src": "333:51:1" }, { "expression": { @@ -733,7 +733,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 100, - "src": "407:3:1", + "src": "414:3:1", "typeDescriptions": { "typeIdentifier": "t_bytes4", "typeString": "bytes4" @@ -746,7 +746,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 85, - "src": "412:5:1", + "src": "419:5:1", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" @@ -772,7 +772,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 87, - "src": "399:6:1", + "src": "406:6:1", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" @@ -795,7 +795,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 67, - "src": "381:6:1", + "src": "388:6:1", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" @@ -809,7 +809,7 @@ "memberName": "call", "nodeType": "MemberAccess", "referencedDeclaration": null, - "src": "381:11:1", + "src": "388:11:1", "typeDescriptions": { "typeIdentifier": "t_function_barecall_payable$__$returns$_t_bool_$", "typeString": "function () payable returns (bool)" @@ -823,7 +823,7 @@ "memberName": "value", "nodeType": "MemberAccess", "referencedDeclaration": null, - "src": "381:17:1", + "src": "388:17:1", "typeDescriptions": { "typeIdentifier": "t_function_setvalue_nonpayable$_t_uint256_$returns$_t_function_barecall_payable$__$returns$_t_bool_$value_$", "typeString": "function (uint256) returns (function () payable returns (bool))" @@ -837,7 +837,7 @@ "lValueRequested": false, "names": [], "nodeType": "FunctionCall", - "src": "381:25:1", + "src": "388:25:1", "typeDescriptions": { "typeIdentifier": "t_function_barecall_payable$__$returns$_t_bool_$value", "typeString": "function () payable returns (bool)" @@ -851,7 +851,7 @@ "lValueRequested": false, "names": [], "nodeType": "FunctionCall", - "src": "381:37:1", + "src": "388:37:1", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" @@ -859,7 +859,7 @@ }, "id": 117, "nodeType": "ExpressionStatement", - "src": "381:37:1" + "src": "388:37:1" } ] }, @@ -881,7 +881,7 @@ "name": "_addr", "nodeType": "VariableDeclaration", "scope": 119, - "src": "245:13:1", + "src": "252:13:1", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { @@ -892,7 +892,7 @@ "id": 84, "name": "address", "nodeType": "ElementaryTypeName", - "src": "245:7:1", + "src": "252:7:1", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" @@ -907,7 +907,7 @@ "name": "_value", "nodeType": "VariableDeclaration", "scope": 119, - "src": "260:11:1", + "src": "267:11:1", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { @@ -918,7 +918,7 @@ "id": 86, "name": "uint", "nodeType": "ElementaryTypeName", - "src": "260:4:1", + "src": "267:4:1", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" @@ -928,17 +928,17 @@ "visibility": "internal" } ], - "src": "244:28:1" + "src": "251:28:1" }, "payable": false, "returnParameters": { "id": 89, "nodeType": "ParameterList", "parameters": [], - "src": "280:0:1" + "src": "287:0:1" }, "scope": 233, - "src": "227:197:1", + "src": "234:197:1", "stateMutability": "nonpayable", "superFunction": null, "visibility": "public" @@ -947,7 +947,7 @@ "body": { "id": 129, "nodeType": "Block", - "src": "470:34:1", + "src": "477:34:1", "statements": [ { "expression": { @@ -959,7 +959,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 63, - "src": "481:7:1", + "src": "488:7:1", "typeDescriptions": { "typeIdentifier": "t_mapping$_t_address_$_t_uint256_$", "typeString": "mapping(address => uint256)" @@ -975,7 +975,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 264, - "src": "489:3:1", + "src": "496:3:1", "typeDescriptions": { "typeIdentifier": "t_magic_message", "typeString": "msg" @@ -989,7 +989,7 @@ "memberName": "sender", "nodeType": "MemberAccess", "referencedDeclaration": null, - "src": "489:10:1", + "src": "496:10:1", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" @@ -1000,7 +1000,7 @@ "isPure": false, "lValueRequested": false, "nodeType": "IndexAccess", - "src": "481:19:1", + "src": "488:19:1", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" @@ -1009,7 +1009,7 @@ "functionReturnParameters": 123, "id": 128, "nodeType": "Return", - "src": "474:26:1" + "src": "481:26:1" } ] }, @@ -1025,7 +1025,7 @@ "id": 120, "nodeType": "ParameterList", "parameters": [], - "src": "445:2:1" + "src": "452:2:1" }, "payable": false, "returnParameters": { @@ -1038,7 +1038,7 @@ "name": "", "nodeType": "VariableDeclaration", "scope": 130, - "src": "464:4:1", + "src": "471:4:1", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { @@ -1049,7 +1049,7 @@ "id": 121, "name": "uint", "nodeType": "ElementaryTypeName", - "src": "464:4:1", + "src": "471:4:1", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" @@ -1059,10 +1059,10 @@ "visibility": "internal" } ], - "src": "463:6:1" + "src": "470:6:1" }, "scope": 233, - "src": "427:77:1", + "src": "434:77:1", "stateMutability": "nonpayable", "superFunction": null, "visibility": "public" @@ -1071,7 +1071,7 @@ "body": { "id": 148, "nodeType": "Block", - "src": "556:70:1", + "src": "563:70:1", "statements": [ { "expression": { @@ -1090,7 +1090,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 63, - "src": "560:7:1", + "src": "567:7:1", "typeDescriptions": { "typeIdentifier": "t_mapping$_t_address_$_t_uint256_$", "typeString": "mapping(address => uint256)" @@ -1106,7 +1106,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 264, - "src": "568:3:1", + "src": "575:3:1", "typeDescriptions": { "typeIdentifier": "t_magic_message", "typeString": "msg" @@ -1120,7 +1120,7 @@ "memberName": "sender", "nodeType": "MemberAccess", "referencedDeclaration": null, - "src": "568:10:1", + "src": "575:10:1", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" @@ -1131,7 +1131,7 @@ "isPure": false, "lValueRequested": true, "nodeType": "IndexAccess", - "src": "560:19:1", + "src": "567:19:1", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" @@ -1148,7 +1148,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 264, - "src": "583:3:1", + "src": "590:3:1", "typeDescriptions": { "typeIdentifier": "t_magic_message", "typeString": "msg" @@ -1162,13 +1162,13 @@ "memberName": "value", "nodeType": "MemberAccess", "referencedDeclaration": null, - "src": "583:9:1", + "src": "590:9:1", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, - "src": "560:32:1", + "src": "567:32:1", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" @@ -1176,7 +1176,7 @@ }, "id": 142, "nodeType": "ExpressionStatement", - "src": "560:32:1" + "src": "567:32:1" }, { "expression": { @@ -1188,7 +1188,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 63, - "src": "603:7:1", + "src": "610:7:1", "typeDescriptions": { "typeIdentifier": "t_mapping$_t_address_$_t_uint256_$", "typeString": "mapping(address => uint256)" @@ -1204,7 +1204,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 264, - "src": "611:3:1", + "src": "618:3:1", "typeDescriptions": { "typeIdentifier": "t_magic_message", "typeString": "msg" @@ -1218,7 +1218,7 @@ "memberName": "sender", "nodeType": "MemberAccess", "referencedDeclaration": null, - "src": "611:10:1", + "src": "618:10:1", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" @@ -1229,7 +1229,7 @@ "isPure": false, "lValueRequested": false, "nodeType": "IndexAccess", - "src": "603:19:1", + "src": "610:19:1", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" @@ -1238,7 +1238,7 @@ "functionReturnParameters": 134, "id": 147, "nodeType": "Return", - "src": "596:26:1" + "src": "603:26:1" } ] }, @@ -1254,7 +1254,7 @@ "id": 131, "nodeType": "ParameterList", "parameters": [], - "src": "523:2:1" + "src": "530:2:1" }, "payable": true, "returnParameters": { @@ -1267,7 +1267,7 @@ "name": "", "nodeType": "VariableDeclaration", "scope": 149, - "src": "550:4:1", + "src": "557:4:1", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { @@ -1278,7 +1278,7 @@ "id": 132, "name": "uint", "nodeType": "ElementaryTypeName", - "src": "550:4:1", + "src": "557:4:1", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" @@ -1288,10 +1288,10 @@ "visibility": "internal" } ], - "src": "549:6:1" + "src": "556:6:1" }, "scope": 233, - "src": "507:119:1", + "src": "514:119:1", "stateMutability": "payable", "superFunction": null, "visibility": "public" @@ -1300,7 +1300,7 @@ "body": { "id": 178, "nodeType": "Block", - "src": "682:105:1", + "src": "689:105:1", "statements": [ { "expression": { @@ -1326,7 +1326,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 63, - "src": "694:7:1", + "src": "701:7:1", "typeDescriptions": { "typeIdentifier": "t_mapping$_t_address_$_t_uint256_$", "typeString": "mapping(address => uint256)" @@ -1342,7 +1342,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 264, - "src": "702:3:1", + "src": "709:3:1", "typeDescriptions": { "typeIdentifier": "t_magic_message", "typeString": "msg" @@ -1356,7 +1356,7 @@ "memberName": "sender", "nodeType": "MemberAccess", "referencedDeclaration": null, - "src": "702:10:1", + "src": "709:10:1", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" @@ -1367,7 +1367,7 @@ "isPure": false, "lValueRequested": false, "nodeType": "IndexAccess", - "src": "694:19:1", + "src": "701:19:1", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" @@ -1382,13 +1382,13 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 153, - "src": "717:6:1", + "src": "724:6:1", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, - "src": "694:29:1", + "src": "701:29:1", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" @@ -1410,7 +1410,7 @@ 268 ], "referencedDeclaration": 267, - "src": "686:7:1", + "src": "693:7:1", "typeDescriptions": { "typeIdentifier": "t_function_require_pure$_t_bool_$returns$__$", "typeString": "function (bool) pure" @@ -1424,7 +1424,7 @@ "lValueRequested": false, "names": [], "nodeType": "FunctionCall", - "src": "686:38:1", + "src": "693:38:1", "typeDescriptions": { "typeIdentifier": "t_tuple$__$", "typeString": "tuple()" @@ -1432,7 +1432,7 @@ }, "id": 164, "nodeType": "ExpressionStatement", - "src": "686:38:1" + "src": "693:38:1" }, { "expression": { @@ -1451,7 +1451,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 63, - "src": "728:7:1", + "src": "735:7:1", "typeDescriptions": { "typeIdentifier": "t_mapping$_t_address_$_t_uint256_$", "typeString": "mapping(address => uint256)" @@ -1467,7 +1467,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 264, - "src": "736:3:1", + "src": "743:3:1", "typeDescriptions": { "typeIdentifier": "t_magic_message", "typeString": "msg" @@ -1481,7 +1481,7 @@ "memberName": "sender", "nodeType": "MemberAccess", "referencedDeclaration": null, - "src": "736:10:1", + "src": "743:10:1", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" @@ -1492,7 +1492,7 @@ "isPure": false, "lValueRequested": true, "nodeType": "IndexAccess", - "src": "728:19:1", + "src": "735:19:1", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" @@ -1507,13 +1507,13 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 153, - "src": "751:6:1", + "src": "758:6:1", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, - "src": "728:29:1", + "src": "735:29:1", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" @@ -1521,7 +1521,7 @@ }, "id": 171, "nodeType": "ExpressionStatement", - "src": "728:29:1" + "src": "735:29:1" }, { "expression": { @@ -1534,7 +1534,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 153, - "src": "776:6:1", + "src": "783:6:1", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" @@ -1555,7 +1555,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 151, - "src": "761:5:1", + "src": "768:5:1", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" @@ -1569,7 +1569,7 @@ "memberName": "transfer", "nodeType": "MemberAccess", "referencedDeclaration": null, - "src": "761:14:1", + "src": "768:14:1", "typeDescriptions": { "typeIdentifier": "t_function_transfer_nonpayable$_t_uint256_$returns$__$", "typeString": "function (uint256)" @@ -1583,7 +1583,7 @@ "lValueRequested": false, "names": [], "nodeType": "FunctionCall", - "src": "761:22:1", + "src": "768:22:1", "typeDescriptions": { "typeIdentifier": "t_tuple$__$", "typeString": "tuple()" @@ -1591,7 +1591,7 @@ }, "id": 177, "nodeType": "ExpressionStatement", - "src": "761:22:1" + "src": "768:22:1" } ] }, @@ -1613,7 +1613,7 @@ "name": "_addr", "nodeType": "VariableDeclaration", "scope": 179, - "src": "647:13:1", + "src": "654:13:1", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { @@ -1624,7 +1624,7 @@ "id": 150, "name": "address", "nodeType": "ElementaryTypeName", - "src": "647:7:1", + "src": "654:7:1", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" @@ -1639,7 +1639,7 @@ "name": "_value", "nodeType": "VariableDeclaration", "scope": 179, - "src": "662:11:1", + "src": "669:11:1", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { @@ -1650,7 +1650,7 @@ "id": 152, "name": "uint", "nodeType": "ElementaryTypeName", - "src": "662:4:1", + "src": "669:4:1", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" @@ -1660,17 +1660,17 @@ "visibility": "internal" } ], - "src": "646:28:1" + "src": "653:28:1" }, "payable": false, "returnParameters": { "id": 155, "nodeType": "ParameterList", "parameters": [], - "src": "682:0:1" + "src": "689:0:1" }, "scope": 233, - "src": "629:158:1", + "src": "636:158:1", "stateMutability": "nonpayable", "superFunction": null, "visibility": "public" @@ -1679,7 +1679,7 @@ "body": { "id": 231, "nodeType": "Block", - "src": "851:180:1", + "src": "858:180:1", "statements": [ { "assignments": [ @@ -1692,7 +1692,7 @@ "name": "l", "nodeType": "VariableDeclaration", "scope": 232, - "src": "855:6:1", + "src": "862:6:1", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { @@ -1703,7 +1703,7 @@ "id": 187, "name": "uint", "nodeType": "ElementaryTypeName", - "src": "855:4:1", + "src": "862:4:1", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" @@ -1723,7 +1723,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 182, - "src": "864:6:1", + "src": "871:6:1", "typeDescriptions": { "typeIdentifier": "t_array$_t_address_$dyn_memory_ptr", "typeString": "address[] memory" @@ -1737,14 +1737,14 @@ "memberName": "length", "nodeType": "MemberAccess", "referencedDeclaration": null, - "src": "864:13:1", + "src": "871:13:1", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "nodeType": "VariableDeclarationStatement", - "src": "855:22:1" + "src": "862:22:1" }, { "expression": { @@ -1770,7 +1770,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 63, - "src": "889:7:1", + "src": "896:7:1", "typeDescriptions": { "typeIdentifier": "t_mapping$_t_address_$_t_uint256_$", "typeString": "mapping(address => uint256)" @@ -1786,7 +1786,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 264, - "src": "897:3:1", + "src": "904:3:1", "typeDescriptions": { "typeIdentifier": "t_magic_message", "typeString": "msg" @@ -1800,7 +1800,7 @@ "memberName": "sender", "nodeType": "MemberAccess", "referencedDeclaration": null, - "src": "897:10:1", + "src": "904:10:1", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" @@ -1811,7 +1811,7 @@ "isPure": false, "lValueRequested": false, "nodeType": "IndexAccess", - "src": "889:19:1", + "src": "896:19:1", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" @@ -1837,7 +1837,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 184, - "src": "912:6:1", + "src": "919:6:1", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" @@ -1852,19 +1852,19 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 188, - "src": "921:1:1", + "src": "928:1:1", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, - "src": "912:10:1", + "src": "919:10:1", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, - "src": "889:33:1", + "src": "896:33:1", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" @@ -1886,7 +1886,7 @@ 268 ], "referencedDeclaration": 267, - "src": "881:7:1", + "src": "888:7:1", "typeDescriptions": { "typeIdentifier": "t_function_require_pure$_t_bool_$returns$__$", "typeString": "function (bool) pure" @@ -1900,7 +1900,7 @@ "lValueRequested": false, "names": [], "nodeType": "FunctionCall", - "src": "881:42:1", + "src": "888:42:1", "typeDescriptions": { "typeIdentifier": "t_tuple$__$", "typeString": "tuple()" @@ -1908,7 +1908,7 @@ }, "id": 202, "nodeType": "ExpressionStatement", - "src": "881:42:1" + "src": "888:42:1" }, { "expression": { @@ -1927,7 +1927,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 63, - "src": "927:7:1", + "src": "934:7:1", "typeDescriptions": { "typeIdentifier": "t_mapping$_t_address_$_t_uint256_$", "typeString": "mapping(address => uint256)" @@ -1943,7 +1943,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 264, - "src": "935:3:1", + "src": "942:3:1", "typeDescriptions": { "typeIdentifier": "t_magic_message", "typeString": "msg" @@ -1957,7 +1957,7 @@ "memberName": "sender", "nodeType": "MemberAccess", "referencedDeclaration": null, - "src": "935:10:1", + "src": "942:10:1", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" @@ -1968,7 +1968,7 @@ "isPure": false, "lValueRequested": true, "nodeType": "IndexAccess", - "src": "927:19:1", + "src": "934:19:1", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" @@ -1994,7 +1994,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 184, - "src": "950:6:1", + "src": "957:6:1", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" @@ -2009,19 +2009,19 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 188, - "src": "959:1:1", + "src": "966:1:1", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, - "src": "950:10:1", + "src": "957:10:1", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, - "src": "927:33:1", + "src": "934:33:1", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" @@ -2029,13 +2029,13 @@ }, "id": 211, "nodeType": "ExpressionStatement", - "src": "927:33:1" + "src": "934:33:1" }, { "body": { "id": 229, "nodeType": "Block", - "src": "992:36:1", + "src": "999:36:1", "statements": [ { "expression": { @@ -2048,7 +2048,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 184, - "src": "1016:6:1", + "src": "1023:6:1", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" @@ -2071,7 +2071,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 182, - "src": "997:6:1", + "src": "1004:6:1", "typeDescriptions": { "typeIdentifier": "t_array$_t_address_$dyn_memory_ptr", "typeString": "address[] memory" @@ -2085,7 +2085,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 213, - "src": "1004:1:1", + "src": "1011:1:1", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" @@ -2096,7 +2096,7 @@ "isPure": false, "lValueRequested": false, "nodeType": "IndexAccess", - "src": "997:9:1", + "src": "1004:9:1", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" @@ -2110,7 +2110,7 @@ "memberName": "transfer", "nodeType": "MemberAccess", "referencedDeclaration": null, - "src": "997:18:1", + "src": "1004:18:1", "typeDescriptions": { "typeIdentifier": "t_function_transfer_nonpayable$_t_uint256_$returns$__$", "typeString": "function (uint256)" @@ -2124,7 +2124,7 @@ "lValueRequested": false, "names": [], "nodeType": "FunctionCall", - "src": "997:26:1", + "src": "1004:26:1", "typeDescriptions": { "typeIdentifier": "t_tuple$__$", "typeString": "tuple()" @@ -2132,7 +2132,7 @@ }, "id": 228, "nodeType": "ExpressionStatement", - "src": "997:26:1" + "src": "1004:26:1" } ] }, @@ -2154,7 +2154,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 213, - "src": "981:1:1", + "src": "988:1:1", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" @@ -2169,13 +2169,13 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 188, - "src": "985:1:1", + "src": "992:1:1", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, - "src": "981:5:1", + "src": "988:5:1", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" @@ -2193,7 +2193,7 @@ "name": "i", "nodeType": "VariableDeclaration", "scope": 232, - "src": "969:6:1", + "src": "976:6:1", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { @@ -2204,7 +2204,7 @@ "id": 212, "name": "uint", "nodeType": "ElementaryTypeName", - "src": "969:4:1", + "src": "976:4:1", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" @@ -2225,7 +2225,7 @@ "kind": "number", "lValueRequested": false, "nodeType": "Literal", - "src": "978:1:1", + "src": "985:1:1", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_0_by_1", @@ -2234,7 +2234,7 @@ "value": "0" }, "nodeType": "VariableDeclarationStatement", - "src": "969:10:1" + "src": "976:10:1" }, "loopExpression": { "expression": { @@ -2247,7 +2247,7 @@ "nodeType": "UnaryOperation", "operator": "++", "prefix": false, - "src": "988:3:1", + "src": "995:3:1", "subExpression": { "argumentTypes": null, "id": 219, @@ -2255,7 +2255,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 213, - "src": "988:1:1", + "src": "995:1:1", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" @@ -2268,10 +2268,10 @@ }, "id": 221, "nodeType": "ExpressionStatement", - "src": "988:3:1" + "src": "995:3:1" }, "nodeType": "ForStatement", - "src": "964:64:1" + "src": "971:64:1" } ] }, @@ -2293,7 +2293,7 @@ "name": "_addrs", "nodeType": "VariableDeclaration", "scope": 232, - "src": "813:16:1", + "src": "820:16:1", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { @@ -2305,7 +2305,7 @@ "id": 180, "name": "address", "nodeType": "ElementaryTypeName", - "src": "813:7:1", + "src": "820:7:1", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" @@ -2314,7 +2314,7 @@ "id": 181, "length": null, "nodeType": "ArrayTypeName", - "src": "813:9:1", + "src": "820:9:1", "typeDescriptions": { "typeIdentifier": "t_array$_t_address_$dyn_storage_ptr", "typeString": "address[]" @@ -2329,7 +2329,7 @@ "name": "_value", "nodeType": "VariableDeclaration", "scope": 232, - "src": "831:11:1", + "src": "838:11:1", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { @@ -2340,7 +2340,7 @@ "id": 183, "name": "uint", "nodeType": "ElementaryTypeName", - "src": "831:4:1", + "src": "838:4:1", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" @@ -2350,30 +2350,30 @@ "visibility": "internal" } ], - "src": "812:31:1" + "src": "819:31:1" }, "payable": false, "returnParameters": { "id": 186, "nodeType": "ParameterList", "parameters": [], - "src": "851:0:1" + "src": "858:0:1" }, "scope": 233, - "src": "790:241:1", + "src": "797:241:1", "stateMutability": "nonpayable", "superFunction": null, "visibility": "public" } ], "scope": 234, - "src": "54:979:1" + "src": "54:986:1" } ], - "src": "0:1033:1" + "src": "0:1040:1" }, "legacyAST": { - "absolutePath": "/Users/gregmarkou/Jobs/Jobs/ChainSafe/shyftNetwork/shyft_go-ethereum/shyft-cli/web3/transfer-through-master/contracts/Transfers.sol", + "absolutePath": "/Users/dustinbrickwood/go/src/github.com/ethereum/go-ethereum/shyft-cli/web3/transfer-through-master/contracts/Transfers.sol", "exportedSymbols": { "Transfers": [ 233 @@ -2394,7 +2394,7 @@ "src": "0:24:1" }, { - "absolutePath": "/Users/gregmarkou/Jobs/Jobs/ChainSafe/shyftNetwork/shyft_go-ethereum/shyft-cli/web3/transfer-through-master/contracts/Transfers2.sol", + "absolutePath": "/Users/dustinbrickwood/go/src/github.com/ethereum/go-ethereum/shyft-cli/web3/transfer-through-master/contracts/Transfers2.sol", "file": "./Transfers2.sol", "id": 59, "nodeType": "ImportDirective", @@ -2522,7 +2522,7 @@ "body": { "id": 82, "nodeType": "Block", - "src": "173:51:1", + "src": "180:51:1", "statements": [ { "expression": { @@ -2539,7 +2539,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 65, - "src": "177:1:1", + "src": "184:1:1", "typeDescriptions": { "typeIdentifier": "t_contract$_Transfers2_$249", "typeString": "contract Transfers2" @@ -2558,7 +2558,7 @@ "isPure": false, "lValueRequested": false, "nodeType": "NewExpression", - "src": "181:14:1", + "src": "188:14:1", "typeDescriptions": { "typeIdentifier": "t_function_creation_nonpayable$__$returns$_t_contract$_Transfers2_$249_$", "typeString": "function () returns (contract Transfers2)" @@ -2569,7 +2569,7 @@ "name": "Transfers2", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 249, - "src": "185:10:1", + "src": "192:10:1", "typeDescriptions": { "typeIdentifier": "t_contract$_Transfers2_$249", "typeString": "contract Transfers2" @@ -2584,13 +2584,13 @@ "lValueRequested": false, "names": [], "nodeType": "FunctionCall", - "src": "181:16:1", + "src": "188:16:1", "typeDescriptions": { "typeIdentifier": "t_contract$_Transfers2_$249", "typeString": "contract Transfers2" } }, - "src": "177:20:1", + "src": "184:20:1", "typeDescriptions": { "typeIdentifier": "t_contract$_Transfers2_$249", "typeString": "contract Transfers2" @@ -2598,7 +2598,7 @@ }, "id": 75, "nodeType": "ExpressionStatement", - "src": "177:20:1" + "src": "184:20:1" }, { "expression": { @@ -2615,7 +2615,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 67, - "src": "201:6:1", + "src": "208:6:1", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" @@ -2633,7 +2633,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 65, - "src": "218:1:1", + "src": "225:1:1", "typeDescriptions": { "typeIdentifier": "t_contract$_Transfers2_$249", "typeString": "contract Transfers2" @@ -2653,7 +2653,7 @@ "isPure": true, "lValueRequested": false, "nodeType": "ElementaryTypeNameExpression", - "src": "210:7:1", + "src": "217:7:1", "typeDescriptions": { "typeIdentifier": "t_type$_t_address_$", "typeString": "type(address)" @@ -2668,13 +2668,13 @@ "lValueRequested": false, "names": [], "nodeType": "FunctionCall", - "src": "210:10:1", + "src": "217:10:1", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, - "src": "201:19:1", + "src": "208:19:1", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" @@ -2682,7 +2682,7 @@ }, "id": 81, "nodeType": "ExpressionStatement", - "src": "201:19:1" + "src": "208:19:1" } ] }, @@ -2692,23 +2692,23 @@ "isConstructor": true, "isDeclaredConst": false, "modifiers": [], - "name": "", + "name": "Transfers", "nodeType": "FunctionDefinition", "parameters": { "id": 68, "nodeType": "ParameterList", "parameters": [], - "src": "163:2:1" + "src": "170:2:1" }, "payable": false, "returnParameters": { "id": 69, "nodeType": "ParameterList", "parameters": [], - "src": "173:0:1" + "src": "180:0:1" }, "scope": 233, - "src": "152:72:1", + "src": "152:79:1", "stateMutability": "nonpayable", "superFunction": null, "visibility": "public" @@ -2717,7 +2717,7 @@ "body": { "id": 118, "nodeType": "Block", - "src": "280:144:1", + "src": "287:144:1", "statements": [ { "expression": { @@ -2743,7 +2743,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 63, - "src": "292:7:1", + "src": "299:7:1", "typeDescriptions": { "typeIdentifier": "t_mapping$_t_address_$_t_uint256_$", "typeString": "mapping(address => uint256)" @@ -2759,7 +2759,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 264, - "src": "300:3:1", + "src": "307:3:1", "typeDescriptions": { "typeIdentifier": "t_magic_message", "typeString": "msg" @@ -2773,7 +2773,7 @@ "memberName": "sender", "nodeType": "MemberAccess", "referencedDeclaration": null, - "src": "300:10:1", + "src": "307:10:1", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" @@ -2784,7 +2784,7 @@ "isPure": false, "lValueRequested": false, "nodeType": "IndexAccess", - "src": "292:19:1", + "src": "299:19:1", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" @@ -2799,13 +2799,13 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 87, - "src": "315:6:1", + "src": "322:6:1", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, - "src": "292:29:1", + "src": "299:29:1", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" @@ -2827,7 +2827,7 @@ 268 ], "referencedDeclaration": 267, - "src": "284:7:1", + "src": "291:7:1", "typeDescriptions": { "typeIdentifier": "t_function_require_pure$_t_bool_$returns$__$", "typeString": "function (bool) pure" @@ -2841,7 +2841,7 @@ "lValueRequested": false, "names": [], "nodeType": "FunctionCall", - "src": "284:38:1", + "src": "291:38:1", "typeDescriptions": { "typeIdentifier": "t_tuple$__$", "typeString": "tuple()" @@ -2849,7 +2849,7 @@ }, "id": 98, "nodeType": "ExpressionStatement", - "src": "284:38:1" + "src": "291:38:1" }, { "assignments": [ @@ -2862,7 +2862,7 @@ "name": "sig", "nodeType": "VariableDeclaration", "scope": 119, - "src": "326:10:1", + "src": "333:10:1", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { @@ -2873,7 +2873,7 @@ "id": 99, "name": "bytes4", "nodeType": "ElementaryTypeName", - "src": "326:6:1", + "src": "333:6:1", "typeDescriptions": { "typeIdentifier": "t_bytes4", "typeString": "bytes4" @@ -2900,7 +2900,7 @@ "kind": "string", "lValueRequested": false, "nodeType": "Literal", - "src": "356:19:1", + "src": "363:19:1", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_stringliteral_1a695230cbbb2b7dfd76397005587fe7ab9ee5f528dbc5a16361e8100dc2c499", @@ -2921,7 +2921,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 258, - "src": "346:9:1", + "src": "353:9:1", "typeDescriptions": { "typeIdentifier": "t_function_sha3_pure$__$returns$_t_bytes32_$", "typeString": "function () pure returns (bytes32)" @@ -2935,7 +2935,7 @@ "lValueRequested": false, "names": [], "nodeType": "FunctionCall", - "src": "346:30:1", + "src": "353:30:1", "typeDescriptions": { "typeIdentifier": "t_bytes32", "typeString": "bytes32" @@ -2955,7 +2955,7 @@ "isPure": true, "lValueRequested": false, "nodeType": "ElementaryTypeNameExpression", - "src": "339:6:1", + "src": "346:6:1", "typeDescriptions": { "typeIdentifier": "t_type$_t_bytes4_$", "typeString": "type(bytes4)" @@ -2970,14 +2970,14 @@ "lValueRequested": false, "names": [], "nodeType": "FunctionCall", - "src": "339:38:1", + "src": "346:38:1", "typeDescriptions": { "typeIdentifier": "t_bytes4", "typeString": "bytes4" } }, "nodeType": "VariableDeclarationStatement", - "src": "326:51:1" + "src": "333:51:1" }, { "expression": { @@ -2990,7 +2990,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 100, - "src": "407:3:1", + "src": "414:3:1", "typeDescriptions": { "typeIdentifier": "t_bytes4", "typeString": "bytes4" @@ -3003,7 +3003,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 85, - "src": "412:5:1", + "src": "419:5:1", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" @@ -3029,7 +3029,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 87, - "src": "399:6:1", + "src": "406:6:1", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" @@ -3052,7 +3052,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 67, - "src": "381:6:1", + "src": "388:6:1", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" @@ -3066,7 +3066,7 @@ "memberName": "call", "nodeType": "MemberAccess", "referencedDeclaration": null, - "src": "381:11:1", + "src": "388:11:1", "typeDescriptions": { "typeIdentifier": "t_function_barecall_payable$__$returns$_t_bool_$", "typeString": "function () payable returns (bool)" @@ -3080,7 +3080,7 @@ "memberName": "value", "nodeType": "MemberAccess", "referencedDeclaration": null, - "src": "381:17:1", + "src": "388:17:1", "typeDescriptions": { "typeIdentifier": "t_function_setvalue_nonpayable$_t_uint256_$returns$_t_function_barecall_payable$__$returns$_t_bool_$value_$", "typeString": "function (uint256) returns (function () payable returns (bool))" @@ -3094,7 +3094,7 @@ "lValueRequested": false, "names": [], "nodeType": "FunctionCall", - "src": "381:25:1", + "src": "388:25:1", "typeDescriptions": { "typeIdentifier": "t_function_barecall_payable$__$returns$_t_bool_$value", "typeString": "function () payable returns (bool)" @@ -3108,7 +3108,7 @@ "lValueRequested": false, "names": [], "nodeType": "FunctionCall", - "src": "381:37:1", + "src": "388:37:1", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" @@ -3116,7 +3116,7 @@ }, "id": 117, "nodeType": "ExpressionStatement", - "src": "381:37:1" + "src": "388:37:1" } ] }, @@ -3138,7 +3138,7 @@ "name": "_addr", "nodeType": "VariableDeclaration", "scope": 119, - "src": "245:13:1", + "src": "252:13:1", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { @@ -3149,7 +3149,7 @@ "id": 84, "name": "address", "nodeType": "ElementaryTypeName", - "src": "245:7:1", + "src": "252:7:1", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" @@ -3164,7 +3164,7 @@ "name": "_value", "nodeType": "VariableDeclaration", "scope": 119, - "src": "260:11:1", + "src": "267:11:1", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { @@ -3175,7 +3175,7 @@ "id": 86, "name": "uint", "nodeType": "ElementaryTypeName", - "src": "260:4:1", + "src": "267:4:1", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" @@ -3185,17 +3185,17 @@ "visibility": "internal" } ], - "src": "244:28:1" + "src": "251:28:1" }, "payable": false, "returnParameters": { "id": 89, "nodeType": "ParameterList", "parameters": [], - "src": "280:0:1" + "src": "287:0:1" }, "scope": 233, - "src": "227:197:1", + "src": "234:197:1", "stateMutability": "nonpayable", "superFunction": null, "visibility": "public" @@ -3204,7 +3204,7 @@ "body": { "id": 129, "nodeType": "Block", - "src": "470:34:1", + "src": "477:34:1", "statements": [ { "expression": { @@ -3216,7 +3216,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 63, - "src": "481:7:1", + "src": "488:7:1", "typeDescriptions": { "typeIdentifier": "t_mapping$_t_address_$_t_uint256_$", "typeString": "mapping(address => uint256)" @@ -3232,7 +3232,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 264, - "src": "489:3:1", + "src": "496:3:1", "typeDescriptions": { "typeIdentifier": "t_magic_message", "typeString": "msg" @@ -3246,7 +3246,7 @@ "memberName": "sender", "nodeType": "MemberAccess", "referencedDeclaration": null, - "src": "489:10:1", + "src": "496:10:1", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" @@ -3257,7 +3257,7 @@ "isPure": false, "lValueRequested": false, "nodeType": "IndexAccess", - "src": "481:19:1", + "src": "488:19:1", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" @@ -3266,7 +3266,7 @@ "functionReturnParameters": 123, "id": 128, "nodeType": "Return", - "src": "474:26:1" + "src": "481:26:1" } ] }, @@ -3282,7 +3282,7 @@ "id": 120, "nodeType": "ParameterList", "parameters": [], - "src": "445:2:1" + "src": "452:2:1" }, "payable": false, "returnParameters": { @@ -3295,7 +3295,7 @@ "name": "", "nodeType": "VariableDeclaration", "scope": 130, - "src": "464:4:1", + "src": "471:4:1", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { @@ -3306,7 +3306,7 @@ "id": 121, "name": "uint", "nodeType": "ElementaryTypeName", - "src": "464:4:1", + "src": "471:4:1", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" @@ -3316,10 +3316,10 @@ "visibility": "internal" } ], - "src": "463:6:1" + "src": "470:6:1" }, "scope": 233, - "src": "427:77:1", + "src": "434:77:1", "stateMutability": "nonpayable", "superFunction": null, "visibility": "public" @@ -3328,7 +3328,7 @@ "body": { "id": 148, "nodeType": "Block", - "src": "556:70:1", + "src": "563:70:1", "statements": [ { "expression": { @@ -3347,7 +3347,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 63, - "src": "560:7:1", + "src": "567:7:1", "typeDescriptions": { "typeIdentifier": "t_mapping$_t_address_$_t_uint256_$", "typeString": "mapping(address => uint256)" @@ -3363,7 +3363,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 264, - "src": "568:3:1", + "src": "575:3:1", "typeDescriptions": { "typeIdentifier": "t_magic_message", "typeString": "msg" @@ -3377,7 +3377,7 @@ "memberName": "sender", "nodeType": "MemberAccess", "referencedDeclaration": null, - "src": "568:10:1", + "src": "575:10:1", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" @@ -3388,7 +3388,7 @@ "isPure": false, "lValueRequested": true, "nodeType": "IndexAccess", - "src": "560:19:1", + "src": "567:19:1", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" @@ -3405,7 +3405,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 264, - "src": "583:3:1", + "src": "590:3:1", "typeDescriptions": { "typeIdentifier": "t_magic_message", "typeString": "msg" @@ -3419,13 +3419,13 @@ "memberName": "value", "nodeType": "MemberAccess", "referencedDeclaration": null, - "src": "583:9:1", + "src": "590:9:1", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, - "src": "560:32:1", + "src": "567:32:1", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" @@ -3433,7 +3433,7 @@ }, "id": 142, "nodeType": "ExpressionStatement", - "src": "560:32:1" + "src": "567:32:1" }, { "expression": { @@ -3445,7 +3445,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 63, - "src": "603:7:1", + "src": "610:7:1", "typeDescriptions": { "typeIdentifier": "t_mapping$_t_address_$_t_uint256_$", "typeString": "mapping(address => uint256)" @@ -3461,7 +3461,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 264, - "src": "611:3:1", + "src": "618:3:1", "typeDescriptions": { "typeIdentifier": "t_magic_message", "typeString": "msg" @@ -3475,7 +3475,7 @@ "memberName": "sender", "nodeType": "MemberAccess", "referencedDeclaration": null, - "src": "611:10:1", + "src": "618:10:1", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" @@ -3486,7 +3486,7 @@ "isPure": false, "lValueRequested": false, "nodeType": "IndexAccess", - "src": "603:19:1", + "src": "610:19:1", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" @@ -3495,7 +3495,7 @@ "functionReturnParameters": 134, "id": 147, "nodeType": "Return", - "src": "596:26:1" + "src": "603:26:1" } ] }, @@ -3511,7 +3511,7 @@ "id": 131, "nodeType": "ParameterList", "parameters": [], - "src": "523:2:1" + "src": "530:2:1" }, "payable": true, "returnParameters": { @@ -3524,7 +3524,7 @@ "name": "", "nodeType": "VariableDeclaration", "scope": 149, - "src": "550:4:1", + "src": "557:4:1", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { @@ -3535,7 +3535,7 @@ "id": 132, "name": "uint", "nodeType": "ElementaryTypeName", - "src": "550:4:1", + "src": "557:4:1", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" @@ -3545,10 +3545,10 @@ "visibility": "internal" } ], - "src": "549:6:1" + "src": "556:6:1" }, "scope": 233, - "src": "507:119:1", + "src": "514:119:1", "stateMutability": "payable", "superFunction": null, "visibility": "public" @@ -3557,7 +3557,7 @@ "body": { "id": 178, "nodeType": "Block", - "src": "682:105:1", + "src": "689:105:1", "statements": [ { "expression": { @@ -3583,7 +3583,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 63, - "src": "694:7:1", + "src": "701:7:1", "typeDescriptions": { "typeIdentifier": "t_mapping$_t_address_$_t_uint256_$", "typeString": "mapping(address => uint256)" @@ -3599,7 +3599,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 264, - "src": "702:3:1", + "src": "709:3:1", "typeDescriptions": { "typeIdentifier": "t_magic_message", "typeString": "msg" @@ -3613,7 +3613,7 @@ "memberName": "sender", "nodeType": "MemberAccess", "referencedDeclaration": null, - "src": "702:10:1", + "src": "709:10:1", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" @@ -3624,7 +3624,7 @@ "isPure": false, "lValueRequested": false, "nodeType": "IndexAccess", - "src": "694:19:1", + "src": "701:19:1", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" @@ -3639,13 +3639,13 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 153, - "src": "717:6:1", + "src": "724:6:1", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, - "src": "694:29:1", + "src": "701:29:1", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" @@ -3667,7 +3667,7 @@ 268 ], "referencedDeclaration": 267, - "src": "686:7:1", + "src": "693:7:1", "typeDescriptions": { "typeIdentifier": "t_function_require_pure$_t_bool_$returns$__$", "typeString": "function (bool) pure" @@ -3681,7 +3681,7 @@ "lValueRequested": false, "names": [], "nodeType": "FunctionCall", - "src": "686:38:1", + "src": "693:38:1", "typeDescriptions": { "typeIdentifier": "t_tuple$__$", "typeString": "tuple()" @@ -3689,7 +3689,7 @@ }, "id": 164, "nodeType": "ExpressionStatement", - "src": "686:38:1" + "src": "693:38:1" }, { "expression": { @@ -3708,7 +3708,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 63, - "src": "728:7:1", + "src": "735:7:1", "typeDescriptions": { "typeIdentifier": "t_mapping$_t_address_$_t_uint256_$", "typeString": "mapping(address => uint256)" @@ -3724,7 +3724,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 264, - "src": "736:3:1", + "src": "743:3:1", "typeDescriptions": { "typeIdentifier": "t_magic_message", "typeString": "msg" @@ -3738,7 +3738,7 @@ "memberName": "sender", "nodeType": "MemberAccess", "referencedDeclaration": null, - "src": "736:10:1", + "src": "743:10:1", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" @@ -3749,7 +3749,7 @@ "isPure": false, "lValueRequested": true, "nodeType": "IndexAccess", - "src": "728:19:1", + "src": "735:19:1", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" @@ -3764,13 +3764,13 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 153, - "src": "751:6:1", + "src": "758:6:1", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, - "src": "728:29:1", + "src": "735:29:1", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" @@ -3778,7 +3778,7 @@ }, "id": 171, "nodeType": "ExpressionStatement", - "src": "728:29:1" + "src": "735:29:1" }, { "expression": { @@ -3791,7 +3791,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 153, - "src": "776:6:1", + "src": "783:6:1", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" @@ -3812,7 +3812,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 151, - "src": "761:5:1", + "src": "768:5:1", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" @@ -3826,7 +3826,7 @@ "memberName": "transfer", "nodeType": "MemberAccess", "referencedDeclaration": null, - "src": "761:14:1", + "src": "768:14:1", "typeDescriptions": { "typeIdentifier": "t_function_transfer_nonpayable$_t_uint256_$returns$__$", "typeString": "function (uint256)" @@ -3840,7 +3840,7 @@ "lValueRequested": false, "names": [], "nodeType": "FunctionCall", - "src": "761:22:1", + "src": "768:22:1", "typeDescriptions": { "typeIdentifier": "t_tuple$__$", "typeString": "tuple()" @@ -3848,7 +3848,7 @@ }, "id": 177, "nodeType": "ExpressionStatement", - "src": "761:22:1" + "src": "768:22:1" } ] }, @@ -3870,7 +3870,7 @@ "name": "_addr", "nodeType": "VariableDeclaration", "scope": 179, - "src": "647:13:1", + "src": "654:13:1", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { @@ -3881,7 +3881,7 @@ "id": 150, "name": "address", "nodeType": "ElementaryTypeName", - "src": "647:7:1", + "src": "654:7:1", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" @@ -3896,7 +3896,7 @@ "name": "_value", "nodeType": "VariableDeclaration", "scope": 179, - "src": "662:11:1", + "src": "669:11:1", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { @@ -3907,7 +3907,7 @@ "id": 152, "name": "uint", "nodeType": "ElementaryTypeName", - "src": "662:4:1", + "src": "669:4:1", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" @@ -3917,17 +3917,17 @@ "visibility": "internal" } ], - "src": "646:28:1" + "src": "653:28:1" }, "payable": false, "returnParameters": { "id": 155, "nodeType": "ParameterList", "parameters": [], - "src": "682:0:1" + "src": "689:0:1" }, "scope": 233, - "src": "629:158:1", + "src": "636:158:1", "stateMutability": "nonpayable", "superFunction": null, "visibility": "public" @@ -3936,7 +3936,7 @@ "body": { "id": 231, "nodeType": "Block", - "src": "851:180:1", + "src": "858:180:1", "statements": [ { "assignments": [ @@ -3949,7 +3949,7 @@ "name": "l", "nodeType": "VariableDeclaration", "scope": 232, - "src": "855:6:1", + "src": "862:6:1", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { @@ -3960,7 +3960,7 @@ "id": 187, "name": "uint", "nodeType": "ElementaryTypeName", - "src": "855:4:1", + "src": "862:4:1", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" @@ -3980,7 +3980,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 182, - "src": "864:6:1", + "src": "871:6:1", "typeDescriptions": { "typeIdentifier": "t_array$_t_address_$dyn_memory_ptr", "typeString": "address[] memory" @@ -3994,14 +3994,14 @@ "memberName": "length", "nodeType": "MemberAccess", "referencedDeclaration": null, - "src": "864:13:1", + "src": "871:13:1", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "nodeType": "VariableDeclarationStatement", - "src": "855:22:1" + "src": "862:22:1" }, { "expression": { @@ -4027,7 +4027,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 63, - "src": "889:7:1", + "src": "896:7:1", "typeDescriptions": { "typeIdentifier": "t_mapping$_t_address_$_t_uint256_$", "typeString": "mapping(address => uint256)" @@ -4043,7 +4043,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 264, - "src": "897:3:1", + "src": "904:3:1", "typeDescriptions": { "typeIdentifier": "t_magic_message", "typeString": "msg" @@ -4057,7 +4057,7 @@ "memberName": "sender", "nodeType": "MemberAccess", "referencedDeclaration": null, - "src": "897:10:1", + "src": "904:10:1", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" @@ -4068,7 +4068,7 @@ "isPure": false, "lValueRequested": false, "nodeType": "IndexAccess", - "src": "889:19:1", + "src": "896:19:1", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" @@ -4094,7 +4094,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 184, - "src": "912:6:1", + "src": "919:6:1", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" @@ -4109,19 +4109,19 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 188, - "src": "921:1:1", + "src": "928:1:1", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, - "src": "912:10:1", + "src": "919:10:1", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, - "src": "889:33:1", + "src": "896:33:1", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" @@ -4143,7 +4143,7 @@ 268 ], "referencedDeclaration": 267, - "src": "881:7:1", + "src": "888:7:1", "typeDescriptions": { "typeIdentifier": "t_function_require_pure$_t_bool_$returns$__$", "typeString": "function (bool) pure" @@ -4157,7 +4157,7 @@ "lValueRequested": false, "names": [], "nodeType": "FunctionCall", - "src": "881:42:1", + "src": "888:42:1", "typeDescriptions": { "typeIdentifier": "t_tuple$__$", "typeString": "tuple()" @@ -4165,7 +4165,7 @@ }, "id": 202, "nodeType": "ExpressionStatement", - "src": "881:42:1" + "src": "888:42:1" }, { "expression": { @@ -4184,7 +4184,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 63, - "src": "927:7:1", + "src": "934:7:1", "typeDescriptions": { "typeIdentifier": "t_mapping$_t_address_$_t_uint256_$", "typeString": "mapping(address => uint256)" @@ -4200,7 +4200,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 264, - "src": "935:3:1", + "src": "942:3:1", "typeDescriptions": { "typeIdentifier": "t_magic_message", "typeString": "msg" @@ -4214,7 +4214,7 @@ "memberName": "sender", "nodeType": "MemberAccess", "referencedDeclaration": null, - "src": "935:10:1", + "src": "942:10:1", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" @@ -4225,7 +4225,7 @@ "isPure": false, "lValueRequested": true, "nodeType": "IndexAccess", - "src": "927:19:1", + "src": "934:19:1", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" @@ -4251,7 +4251,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 184, - "src": "950:6:1", + "src": "957:6:1", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" @@ -4266,19 +4266,19 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 188, - "src": "959:1:1", + "src": "966:1:1", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, - "src": "950:10:1", + "src": "957:10:1", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, - "src": "927:33:1", + "src": "934:33:1", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" @@ -4286,13 +4286,13 @@ }, "id": 211, "nodeType": "ExpressionStatement", - "src": "927:33:1" + "src": "934:33:1" }, { "body": { "id": 229, "nodeType": "Block", - "src": "992:36:1", + "src": "999:36:1", "statements": [ { "expression": { @@ -4305,7 +4305,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 184, - "src": "1016:6:1", + "src": "1023:6:1", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" @@ -4328,7 +4328,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 182, - "src": "997:6:1", + "src": "1004:6:1", "typeDescriptions": { "typeIdentifier": "t_array$_t_address_$dyn_memory_ptr", "typeString": "address[] memory" @@ -4342,7 +4342,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 213, - "src": "1004:1:1", + "src": "1011:1:1", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" @@ -4353,7 +4353,7 @@ "isPure": false, "lValueRequested": false, "nodeType": "IndexAccess", - "src": "997:9:1", + "src": "1004:9:1", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" @@ -4367,7 +4367,7 @@ "memberName": "transfer", "nodeType": "MemberAccess", "referencedDeclaration": null, - "src": "997:18:1", + "src": "1004:18:1", "typeDescriptions": { "typeIdentifier": "t_function_transfer_nonpayable$_t_uint256_$returns$__$", "typeString": "function (uint256)" @@ -4381,7 +4381,7 @@ "lValueRequested": false, "names": [], "nodeType": "FunctionCall", - "src": "997:26:1", + "src": "1004:26:1", "typeDescriptions": { "typeIdentifier": "t_tuple$__$", "typeString": "tuple()" @@ -4389,7 +4389,7 @@ }, "id": 228, "nodeType": "ExpressionStatement", - "src": "997:26:1" + "src": "1004:26:1" } ] }, @@ -4411,7 +4411,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 213, - "src": "981:1:1", + "src": "988:1:1", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" @@ -4426,13 +4426,13 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 188, - "src": "985:1:1", + "src": "992:1:1", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, - "src": "981:5:1", + "src": "988:5:1", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" @@ -4450,7 +4450,7 @@ "name": "i", "nodeType": "VariableDeclaration", "scope": 232, - "src": "969:6:1", + "src": "976:6:1", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { @@ -4461,7 +4461,7 @@ "id": 212, "name": "uint", "nodeType": "ElementaryTypeName", - "src": "969:4:1", + "src": "976:4:1", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" @@ -4482,7 +4482,7 @@ "kind": "number", "lValueRequested": false, "nodeType": "Literal", - "src": "978:1:1", + "src": "985:1:1", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_0_by_1", @@ -4491,7 +4491,7 @@ "value": "0" }, "nodeType": "VariableDeclarationStatement", - "src": "969:10:1" + "src": "976:10:1" }, "loopExpression": { "expression": { @@ -4504,7 +4504,7 @@ "nodeType": "UnaryOperation", "operator": "++", "prefix": false, - "src": "988:3:1", + "src": "995:3:1", "subExpression": { "argumentTypes": null, "id": 219, @@ -4512,7 +4512,7 @@ "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 213, - "src": "988:1:1", + "src": "995:1:1", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" @@ -4525,10 +4525,10 @@ }, "id": 221, "nodeType": "ExpressionStatement", - "src": "988:3:1" + "src": "995:3:1" }, "nodeType": "ForStatement", - "src": "964:64:1" + "src": "971:64:1" } ] }, @@ -4550,7 +4550,7 @@ "name": "_addrs", "nodeType": "VariableDeclaration", "scope": 232, - "src": "813:16:1", + "src": "820:16:1", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { @@ -4562,7 +4562,7 @@ "id": 180, "name": "address", "nodeType": "ElementaryTypeName", - "src": "813:7:1", + "src": "820:7:1", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" @@ -4571,7 +4571,7 @@ "id": 181, "length": null, "nodeType": "ArrayTypeName", - "src": "813:9:1", + "src": "820:9:1", "typeDescriptions": { "typeIdentifier": "t_array$_t_address_$dyn_storage_ptr", "typeString": "address[]" @@ -4586,7 +4586,7 @@ "name": "_value", "nodeType": "VariableDeclaration", "scope": 232, - "src": "831:11:1", + "src": "838:11:1", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { @@ -4597,7 +4597,7 @@ "id": 183, "name": "uint", "nodeType": "ElementaryTypeName", - "src": "831:4:1", + "src": "838:4:1", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" @@ -4607,27 +4607,27 @@ "visibility": "internal" } ], - "src": "812:31:1" + "src": "819:31:1" }, "payable": false, "returnParameters": { "id": 186, "nodeType": "ParameterList", "parameters": [], - "src": "851:0:1" + "src": "858:0:1" }, "scope": 233, - "src": "790:241:1", + "src": "797:241:1", "stateMutability": "nonpayable", "superFunction": null, "visibility": "public" } ], "scope": 234, - "src": "54:979:1" + "src": "54:986:1" } ], - "src": "0:1033:1" + "src": "0:1040:1" }, "compiler": { "name": "solc", @@ -4638,7 +4638,7 @@ "events": {}, "links": {}, "address": "0x9c2b479e15bbd956237c7ef33d31bfa2a576f007", - "transactionHash": "0x3213d366cc00423edfdf5683a4d26b3e93467c88cbd5f953864ec46edb7673d9" + "transactionHash": "0x760fc6e1793b1cf06fdbaace7aae571c5c0f214c21ceee3c161de90a9f42221e" }, "1528420224459": { "events": {}, @@ -4647,6 +4647,6 @@ "transactionHash": "0x86a60b4cd8a9abab600debe01793dd76d05b65e4aa37c144e51c7f42a9d4d93b" } }, - "schemaVersion": "2.0.0", - "updatedAt": "2018-06-08T15:58:27.902Z" + "schemaVersion": "2.0.1", + "updatedAt": "2018-07-06T18:05:39.257Z" } \ No newline at end of file diff --git a/shyft-cli/web3/transfer-through-master/build/contracts/Transfers2.json b/shyft-cli/web3/transfer-through-master/build/contracts/Transfers2.json index 765962721b..9d96e472a4 100755 --- a/shyft-cli/web3/transfer-through-master/build/contracts/Transfers2.json +++ b/shyft-cli/web3/transfer-through-master/build/contracts/Transfers2.json @@ -16,14 +16,14 @@ "type": "function" } ], - "bytecode": "0x608060405234801561001057600080fd5b5060ed8061001f6000396000f300608060405260043610603f576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680631a695230146044575b600080fd5b6076600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506078565b005b8073ffffffffffffffffffffffffffffffffffffffff166108fc349081150290604051600060405180830381858888f1935050505015801560bd573d6000803e3d6000fd5b50505600a165627a7a72305820e95f74106a3328ffadd8b0adb916d92497daab65998ee73cf40afff57dc4b29b0029", - "deployedBytecode": "0x608060405260043610603f576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680631a695230146044575b600080fd5b6076600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506078565b005b8073ffffffffffffffffffffffffffffffffffffffff166108fc349081150290604051600060405180830381858888f1935050505015801560bd573d6000803e3d6000fd5b50505600a165627a7a72305820e95f74106a3328ffadd8b0adb916d92497daab65998ee73cf40afff57dc4b29b0029", + "bytecode": "0x608060405234801561001057600080fd5b5060ed8061001f6000396000f300608060405260043610603f576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680631a695230146044575b600080fd5b6076600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506078565b005b8073ffffffffffffffffffffffffffffffffffffffff166108fc349081150290604051600060405180830381858888f1935050505015801560bd573d6000803e3d6000fd5b50505600a165627a7a723058206b9724f2a2dbdc5e27a309b647c1d11903393ac90b5e54ab4925de752e5f6e760029", + "deployedBytecode": "0x608060405260043610603f576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680631a695230146044575b600080fd5b6076600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506078565b005b8073ffffffffffffffffffffffffffffffffffffffff166108fc349081150290604051600060405180830381858888f1935050505015801560bd573d6000803e3d6000fd5b50505600a165627a7a723058206b9724f2a2dbdc5e27a309b647c1d11903393ac90b5e54ab4925de752e5f6e760029", "sourceMap": "26:106:2:-;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;26:106:2;;;;;;;", "deployedSourceMap": "26:106:2:-;;;;;;;;;;;;;;;;;;;;;;;;49:81;;;;;;;;;;;;;;;;;;;;;;;;;;;;;101:5;:14;;:25;116:9;101:25;;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;101:25:2;49:81;:::o", "source": "pragma solidity ^0.4.19;\n\ncontract Transfers2 {\n\tfunction transfer(address _addr) public payable {\n\t\t_addr.transfer(msg.value);\n\t}\n}", - "sourcePath": "/Users/gregmarkou/Jobs/Jobs/ChainSafe/shyftNetwork/shyft_go-ethereum/shyft-cli/web3/transfer-through-master/contracts/Transfers2.sol", + "sourcePath": "/Users/dustinbrickwood/go/src/github.com/ethereum/go-ethereum/shyft-cli/web3/transfer-through-master/contracts/Transfers2.sol", "ast": { - "absolutePath": "/Users/gregmarkou/Jobs/Jobs/ChainSafe/shyftNetwork/shyft_go-ethereum/shyft-cli/web3/transfer-through-master/contracts/Transfers2.sol", + "absolutePath": "/Users/dustinbrickwood/go/src/github.com/ethereum/go-ethereum/shyft-cli/web3/transfer-through-master/contracts/Transfers2.sol", "exportedSymbols": { "Transfers2": [ 249 @@ -212,7 +212,7 @@ "src": "0:132:2" }, "legacyAST": { - "absolutePath": "/Users/gregmarkou/Jobs/Jobs/ChainSafe/shyftNetwork/shyft_go-ethereum/shyft-cli/web3/transfer-through-master/contracts/Transfers2.sol", + "absolutePath": "/Users/dustinbrickwood/go/src/github.com/ethereum/go-ethereum/shyft-cli/web3/transfer-through-master/contracts/Transfers2.sol", "exportedSymbols": { "Transfers2": [ 249 @@ -409,7 +409,7 @@ "events": {}, "links": {}, "address": "0xa863f8203ad95e9078f6300e7857a4cca4fb4c60", - "transactionHash": "0xb836110657221cb8ac728c0345ae03da1cb4313cfa0bb61285f31b780907af50" + "transactionHash": "0x7d4888a4f369e8b635a8418deb115db390b4ef963da86ade26feff951cf25d7c" }, "1528420224459": { "events": {}, @@ -418,6 +418,6 @@ "transactionHash": "0x43f3fed1df72adfe12dd0c2432f0625b4b50b0c151f9583a166722ed74786ce3" } }, - "schemaVersion": "2.0.0", - "updatedAt": "2018-06-08T15:58:27.899Z" + "schemaVersion": "2.0.1", + "updatedAt": "2018-07-06T18:05:39.254Z" } \ No newline at end of file diff --git a/shyft-cli/web3/transfer-through-master/contracts/Migrations.sol b/shyft-cli/web3/transfer-through-master/contracts/Migrations.sol index c4efb65e21..b36e0de869 100755 --- a/shyft-cli/web3/transfer-through-master/contracts/Migrations.sol +++ b/shyft-cli/web3/transfer-through-master/contracts/Migrations.sol @@ -4,7 +4,7 @@ contract Migrations { address public owner; uint public last_completed_migration; - constructor() public { + function Migrations() public { owner = msg.sender; } diff --git a/shyft-cli/web3/transfer-through-master/contracts/Transfers.sol b/shyft-cli/web3/transfer-through-master/contracts/Transfers.sol index 9e7fbeef05..8c2f64cfb4 100755 --- a/shyft-cli/web3/transfer-through-master/contracts/Transfers.sol +++ b/shyft-cli/web3/transfer-through-master/contracts/Transfers.sol @@ -7,7 +7,7 @@ contract Transfers { Transfers2 t; address t_addr; - constructor() public { + function Transfers() public { t = new Transfers2(); t_addr = address(t); } diff --git a/shyft-cli/web3/transfer-through-master/package-lock.json b/shyft-cli/web3/transfer-through-master/package-lock.json index 326563a8c6..6447a9f6bb 100755 --- a/shyft-cli/web3/transfer-through-master/package-lock.json +++ b/shyft-cli/web3/transfer-through-master/package-lock.json @@ -1,5 +1,490 @@ { "name": "transfers", "version": "1.0.0", - "lockfileVersion": 1 + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=" + }, + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" + }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "requires": { + "balanced-match": "1.0.0", + "concat-map": "0.0.1" + } + }, + "builtin-modules": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz", + "integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=" + }, + "camelcase": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-3.0.0.tgz", + "integrity": "sha1-MvxLn82vhF/N9+c7uXysImHwqwo=" + }, + "cliui": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-3.2.0.tgz", + "integrity": "sha1-EgYBU3qRbSmUD5NNo7SNWFo5IT0=", + "requires": { + "string-width": "1.0.2", + "strip-ansi": "3.0.1", + "wrap-ansi": "2.1.0" + } + }, + "code-point-at": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", + "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=" + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" + }, + "decamelize": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", + "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=" + }, + "error-ex": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", + "integrity": "sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==", + "requires": { + "is-arrayish": "0.2.1" + } + }, + "find-up": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-1.1.2.tgz", + "integrity": "sha1-ay6YIrGizgpgq2TWEOzK1TyyTQ8=", + "requires": { + "path-exists": "2.1.0", + "pinkie-promise": "2.0.1" + } + }, + "fs-extra": { + "version": "0.30.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-0.30.0.tgz", + "integrity": "sha1-8jP/zAjU2n1DLapEl3aYnbHfk/A=", + "requires": { + "graceful-fs": "4.1.11", + "jsonfile": "2.4.0", + "klaw": "1.3.1", + "path-is-absolute": "1.0.1", + "rimraf": "2.6.2" + } + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" + }, + "get-caller-file": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-1.0.2.tgz", + "integrity": "sha1-9wLmMSfn4jHBYKgMFVSstw1QR+U=" + }, + "glob": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", + "requires": { + "fs.realpath": "1.0.0", + "inflight": "1.0.6", + "inherits": "2.0.3", + "minimatch": "3.0.4", + "once": "1.4.0", + "path-is-absolute": "1.0.1" + } + }, + "graceful-fs": { + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", + "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=" + }, + "hosted-git-info": { + "version": "2.6.1", + "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.6.1.tgz", + "integrity": "sha512-Ba4+0M4YvIDUUsprMjhVTU1yN9F2/LJSAl69ZpzaLT4l4j5mwTS6jqqW9Ojvj6lKz/veqPzpJBqGbXspOb533A==" + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "requires": { + "once": "1.4.0", + "wrappy": "1.0.2" + } + }, + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" + }, + "invert-kv": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/invert-kv/-/invert-kv-1.0.0.tgz", + "integrity": "sha1-EEqOSqym09jNFXqO+L+rLXo//bY=" + }, + "is-arrayish": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", + "integrity": "sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=" + }, + "is-builtin-module": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-builtin-module/-/is-builtin-module-1.0.0.tgz", + "integrity": "sha1-VAVy0096wxGfj3bDDLwbHgN6/74=", + "requires": { + "builtin-modules": "1.1.1" + } + }, + "is-fullwidth-code-point": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", + "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", + "requires": { + "number-is-nan": "1.0.1" + } + }, + "is-utf8": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/is-utf8/-/is-utf8-0.2.1.tgz", + "integrity": "sha1-Sw2hRCEE0bM2NA6AeX6GXPOffXI=" + }, + "jsonfile": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-2.4.0.tgz", + "integrity": "sha1-NzaitCi4e72gzIO1P6PWM6NcKug=", + "requires": { + "graceful-fs": "4.1.11" + } + }, + "klaw": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/klaw/-/klaw-1.3.1.tgz", + "integrity": "sha1-QIhDO0azsbolnXh4XY6W9zugJDk=", + "requires": { + "graceful-fs": "4.1.11" + } + }, + "lcid": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/lcid/-/lcid-1.0.0.tgz", + "integrity": "sha1-MIrMr6C8SDo4Z7S28rlQYlHRuDU=", + "requires": { + "invert-kv": "1.0.0" + } + }, + "load-json-file": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz", + "integrity": "sha1-lWkFcI1YtLq0wiYbBPWfMcmTdMA=", + "requires": { + "graceful-fs": "4.1.11", + "parse-json": "2.2.0", + "pify": "2.3.0", + "pinkie-promise": "2.0.1", + "strip-bom": "2.0.0" + } + }, + "lodash.assign": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/lodash.assign/-/lodash.assign-4.2.0.tgz", + "integrity": "sha1-DZnzzNem0mHRm9rrkkUAXShYCOc=" + }, + "memorystream": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/memorystream/-/memorystream-0.3.1.tgz", + "integrity": "sha1-htcJCzDORV1j+64S3aUaR93K+bI=" + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "requires": { + "brace-expansion": "1.1.11" + } + }, + "normalize-package-data": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.4.0.tgz", + "integrity": "sha512-9jjUFbTPfEy3R/ad/2oNbKtW9Hgovl5O1FvFWKkKblNXoN/Oou6+9+KKohPK13Yc3/TyunyWhJp6gvRNR/PPAw==", + "requires": { + "hosted-git-info": "2.6.1", + "is-builtin-module": "1.0.0", + "semver": "5.5.0", + "validate-npm-package-license": "3.0.3" + } + }, + "number-is-nan": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", + "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=" + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "requires": { + "wrappy": "1.0.2" + } + }, + "os-locale": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/os-locale/-/os-locale-1.4.0.tgz", + "integrity": "sha1-IPnxeuKe00XoveWDsT0gCYA8FNk=", + "requires": { + "lcid": "1.0.0" + } + }, + "parse-json": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-2.2.0.tgz", + "integrity": "sha1-9ID0BDTvgHQfhGkJn43qGPVaTck=", + "requires": { + "error-ex": "1.3.2" + } + }, + "path-exists": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-2.1.0.tgz", + "integrity": "sha1-D+tsZPD8UY2adU3V77YscCJ2H0s=", + "requires": { + "pinkie-promise": "2.0.1" + } + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" + }, + "path-type": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/path-type/-/path-type-1.1.0.tgz", + "integrity": "sha1-WcRPfuSR2nBNpBXaWkBwuk+P5EE=", + "requires": { + "graceful-fs": "4.1.11", + "pify": "2.3.0", + "pinkie-promise": "2.0.1" + } + }, + "pify": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=" + }, + "pinkie": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz", + "integrity": "sha1-clVrgM+g1IqXToDnckjoDtT3+HA=" + }, + "pinkie-promise": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz", + "integrity": "sha1-ITXW36ejWMBprJsXh3YogihFD/o=", + "requires": { + "pinkie": "2.0.4" + } + }, + "read-pkg": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-1.1.0.tgz", + "integrity": "sha1-9f+qXs0pyzHAR0vKfXVra7KePyg=", + "requires": { + "load-json-file": "1.1.0", + "normalize-package-data": "2.4.0", + "path-type": "1.1.0" + } + }, + "read-pkg-up": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-1.0.1.tgz", + "integrity": "sha1-nWPBMnbAZZGNV/ACpX9AobZD+wI=", + "requires": { + "find-up": "1.1.2", + "read-pkg": "1.1.0" + } + }, + "require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=" + }, + "require-from-string": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-1.2.1.tgz", + "integrity": "sha1-UpyczvJzgK3+yaL5ZbZJu+5jZBg=" + }, + "require-main-filename": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-1.0.1.tgz", + "integrity": "sha1-l/cXtp1IeE9fUmpsWqj/3aBVpNE=" + }, + "rimraf": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", + "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", + "requires": { + "glob": "7.1.2" + } + }, + "semver": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", + "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==" + }, + "set-blocking": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", + "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=" + }, + "solc": { + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/solc/-/solc-0.4.24.tgz", + "integrity": "sha512-2xd7Cf1HeVwrIb6Bu1cwY2/TaLRodrppCq3l7rhLimFQgmxptXhTC3+/wesVLpB09F1A2kZgvbMOgH7wvhFnBQ==", + "requires": { + "fs-extra": "0.30.0", + "memorystream": "0.3.1", + "require-from-string": "1.2.1", + "semver": "5.5.0", + "yargs": "4.8.1" + } + }, + "spdx-correct": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.0.0.tgz", + "integrity": "sha512-N19o9z5cEyc8yQQPukRCZ9EUmb4HUpnrmaL/fxS2pBo2jbfcFRVuFZ/oFC+vZz0MNNk0h80iMn5/S6qGZOL5+g==", + "requires": { + "spdx-expression-parse": "3.0.0", + "spdx-license-ids": "3.0.0" + } + }, + "spdx-exceptions": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.1.0.tgz", + "integrity": "sha512-4K1NsmrlCU1JJgUrtgEeTVyfx8VaYea9J9LvARxhbHtVtohPs/gFGG5yy49beySjlIMhhXZ4QqujIZEfS4l6Cg==" + }, + "spdx-expression-parse": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.0.tgz", + "integrity": "sha512-Yg6D3XpRD4kkOmTpdgbUiEJFKghJH03fiC1OPll5h/0sO6neh2jqRDVHOQ4o/LMea0tgCkbMgea5ip/e+MkWyg==", + "requires": { + "spdx-exceptions": "2.1.0", + "spdx-license-ids": "3.0.0" + } + }, + "spdx-license-ids": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.0.tgz", + "integrity": "sha512-2+EPwgbnmOIl8HjGBXXMd9NAu02vLjOO1nWw4kmeRDFyHn+M/ETfHxQUK0oXg8ctgVnl9t3rosNVsZ1jG61nDA==" + }, + "string-width": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", + "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", + "requires": { + "code-point-at": "1.1.0", + "is-fullwidth-code-point": "1.0.0", + "strip-ansi": "3.0.1" + } + }, + "strip-ansi": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "requires": { + "ansi-regex": "2.1.1" + } + }, + "strip-bom": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-2.0.0.tgz", + "integrity": "sha1-YhmoVhZSBJHzV4i9vxRHqZx+aw4=", + "requires": { + "is-utf8": "0.2.1" + } + }, + "validate-npm-package-license": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.3.tgz", + "integrity": "sha512-63ZOUnL4SIXj4L0NixR3L1lcjO38crAbgrTpl28t8jjrfuiOBL5Iygm+60qPs/KsZGzPNg6Smnc/oY16QTjF0g==", + "requires": { + "spdx-correct": "3.0.0", + "spdx-expression-parse": "3.0.0" + } + }, + "which-module": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/which-module/-/which-module-1.0.0.tgz", + "integrity": "sha1-u6Y8qGGUiZT/MHc2CJ47lgJsKk8=" + }, + "window-size": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/window-size/-/window-size-0.2.0.tgz", + "integrity": "sha1-tDFbtCFKPXBY6+7okuE/ok2YsHU=" + }, + "wrap-ansi": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz", + "integrity": "sha1-2Pw9KE3QV5T+hJc8rs3Rz4JP3YU=", + "requires": { + "string-width": "1.0.2", + "strip-ansi": "3.0.1" + } + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" + }, + "y18n": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-3.2.1.tgz", + "integrity": "sha1-bRX7qITAhnnA136I53WegR4H+kE=" + }, + "yargs": { + "version": "4.8.1", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-4.8.1.tgz", + "integrity": "sha1-wMQpJMpKqmsObaFznfshZDn53cA=", + "requires": { + "cliui": "3.2.0", + "decamelize": "1.2.0", + "get-caller-file": "1.0.2", + "lodash.assign": "4.2.0", + "os-locale": "1.4.0", + "read-pkg-up": "1.0.1", + "require-directory": "2.1.1", + "require-main-filename": "1.0.1", + "set-blocking": "2.0.0", + "string-width": "1.0.2", + "which-module": "1.0.0", + "window-size": "0.2.0", + "y18n": "3.2.1", + "yargs-parser": "2.4.1" + } + }, + "yargs-parser": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-2.4.1.tgz", + "integrity": "sha1-hVaN488VD/SfpRgl8DqMiA3cxcQ=", + "requires": { + "camelcase": "3.0.0", + "lodash.assign": "4.2.0" + } + } + } } diff --git a/shyft-cli/web3/transfer-through-master/package.json b/shyft-cli/web3/transfer-through-master/package.json index df745f4570..4ffd6d5091 100755 --- a/shyft-cli/web3/transfer-through-master/package.json +++ b/shyft-cli/web3/transfer-through-master/package.json @@ -11,5 +11,8 @@ }, "keywords": [], "author": "", - "license": "ISC" + "license": "ISC", + "dependencies": { + "solc": "^0.4.24" + } } diff --git a/shyfttracerinterface/tracer_interface.go b/shyfttracerinterface/tracer_interface.go index 40d341b028..366b1534d1 100644 --- a/shyfttracerinterface/tracer_interface.go +++ b/shyfttracerinterface/tracer_interface.go @@ -2,9 +2,8 @@ package shyfttracerinterface import ( "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/node" ) type IShyftTracer interface { - GetTracerToRun(hash common.Hash, stack *node.Node) (interface{}, error) + GetTracerToRun(hash common.Hash) (interface{}, error) } From 79f6484d3aeed06b32e5c816a781b0034cce2bf2 Mon Sep 17 00:00:00 2001 From: Dustin Brickwood Date: Wed, 11 Jul 2018 12:16:07 -0400 Subject: [PATCH 09/21] resolved conflicts --- core/shyft_database_util.go | 9 +- eth/api_tracer.go | 192 +++++++++++++++- eth/shyft_tracer.go | 271 ++++++++++++++++++++++- shyfttracerinterface/tracer_interface.go | 5 + 4 files changed, 472 insertions(+), 5 deletions(-) diff --git a/core/shyft_database_util.go b/core/shyft_database_util.go index 62673984cf..c4232aaf03 100644 --- a/core/shyft_database_util.go +++ b/core/shyft_database_util.go @@ -172,11 +172,14 @@ func SwriteTransactions(sqldb *sql.DB, tx *types.Transaction, blockHash common.H Data: tx.Data(), } - //hash := txData.TxHash + hash := txData.TxHash txHash := txData.TxHash.Hex() - //prayer, _ := IShyftTracer.GetTracerToRun(hash) - //fmt.Printf("%+v\n", prayer) + prayer, _ := IShyftTracer.GetTracerToRun(hash) + fmt.Printf("%+v\n", prayer) + + //var stack *node.Node + //var cfg *eth.Config from := txData.From.Hex() blockHasher := txData.BlockHash diff --git a/eth/api_tracer.go b/eth/api_tracer.go index f8740f3b13..39c5779d9b 100644 --- a/eth/api_tracer.go +++ b/eth/api_tracer.go @@ -38,7 +38,6 @@ import ( "github.com/ethereum/go-ethereum/rlp" "github.com/ethereum/go-ethereum/rpc" "github.com/ethereum/go-ethereum/trie" - ) const ( @@ -533,6 +532,197 @@ func (api *PrivateDebugAPI) computeStateDB(block *types.Block, reexec uint64) (* // 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, 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 + //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) + // Retrieve the transaction and assemble its EVM context + //fmt.Println("IN TRACE TRANSACTION the chaindb is ") + //fmt.Println(chaindb) + //fmt.Println("IN TRACE TRANSACTION the common hash is ") + //fmt.Println(hash) tx, blockHash, _, index := core.GetTransaction(api.eth.ChainDb(), hash) if tx == nil { diff --git a/eth/shyft_tracer.go b/eth/shyft_tracer.go index 73bacd3b16..d0c984d961 100644 --- a/eth/shyft_tracer.go +++ b/eth/shyft_tracer.go @@ -1,5 +1,6 @@ package eth + import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/params" @@ -40,4 +41,272 @@ var Global_config *Config func setGlobalConfig(c *Config) { Global_config = c -} \ No newline at end of file +} + +// +//import ( +// "github.com/ethereum/go-ethereum/common" +// "fmt" +// "github.com/ethereum/go-ethereum/core" +// "runtime" +// "context" +//) +// +////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()) +// fmt.Println("CTXXXXXXXXXXXXXXX") +// 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("THIS CTX") +// //fmt.Println("the tx is ") +// //fmt.Println(tx) +// //fmt.Println(blockHash) +// //fmt.Println(index) +// //DebugApi.traceTxTest(msg, vmctx, statedb, config) +// return 42 +//} +// +//func (api *PrivateDebugAPI) TraceTransactionTest(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) +// } +// +// tx, blockHash, _, index := core.GetTransaction(api.eth.ChainDb(), hash) +// if tx == nil { +// return nil, fmt.Errorf("transaction %x not found", hash) +// } +// +// reexec := defaultTraceReexec +// if config != nil && config.Reexec != nil { +// reexec = *config.Reexec +// } +// msg, vmctx, statedb, err := api.computeTxEnv(blockHash, int(index), reexec) +// if err != nil { +// return nil, err +// } +// fmt.Println("CTX +++++++++++++++++++++++", ctx) +// return api.traceTxTest(ctx, msg, vmctx, statedb, config) +//} +// +//func setEthObject(ethobj interface{}){ +// EthereumObject = ethobj +//} diff --git a/shyfttracerinterface/tracer_interface.go b/shyfttracerinterface/tracer_interface.go index 366b1534d1..dbadf1e39b 100644 --- a/shyfttracerinterface/tracer_interface.go +++ b/shyfttracerinterface/tracer_interface.go @@ -7,3 +7,8 @@ import ( type IShyftTracer interface { GetTracerToRun(hash common.Hash) (interface{}, error) } + +//type IShyftTracer interface { +// MyTraceTransaction(hash string) (interface{}) +//} + From 3eab46ee8c23e66bb7778aaddff5a2f0b6bd315f Mon Sep 17 00:00:00 2001 From: Dustin Brickwood Date: Wed, 11 Jul 2018 12:20:43 -0400 Subject: [PATCH 10/21] clean runtime --- core/shyft_database_util.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/core/shyft_database_util.go b/core/shyft_database_util.go index c4232aaf03..2fc57804cb 100644 --- a/core/shyft_database_util.go +++ b/core/shyft_database_util.go @@ -14,6 +14,7 @@ _ "github.com/lib/pq" "github.com/ethereum/go-ethereum/core/types" Rewards "github.com/ethereum/go-ethereum/consensus/ethash" "github.com/ethereum/go-ethereum/shyfttracerinterface" + "reflect" ) var IShyftTracer shyfttracerinterface.IShyftTracer @@ -173,10 +174,11 @@ func SwriteTransactions(sqldb *sql.DB, tx *types.Transaction, blockHash common.H } hash := txData.TxHash + fmt.Println(reflect.TypeOf(hash)) txHash := txData.TxHash.Hex() - prayer, _ := IShyftTracer.GetTracerToRun(hash) - fmt.Printf("%+v\n", prayer) + //prayer, _ := IShyftTracer.GetTracerToRun(hash) + //fmt.Printf("%+v\n", prayer) //var stack *node.Node //var cfg *eth.Config From fbf3fa25c7d3ceae0601806d53f534e3aa60519b Mon Sep 17 00:00:00 2001 From: Dustin Brickwood Date: Wed, 11 Jul 2018 18:00:49 -0400 Subject: [PATCH 11/21] internals are being seen --- core/database_util.go | 4 - core/shyft_database_util.go | 45 ++++--- eth/api_tracer.go | 201 ++----------------------------- eth/shyft_tracer.go | 2 - eth/tracers/tracer.go | 50 ++++++-- shyftBlockExplorerApi/handler.go | 143 ++++++++++++---------- 6 files changed, 154 insertions(+), 291 deletions(-) diff --git a/core/database_util.go b/core/database_util.go index af88b7733c..54572ac71b 100644 --- a/core/database_util.go +++ b/core/database_util.go @@ -265,15 +265,11 @@ func GetBlockReceipts(db DatabaseReader, hash common.Hash, number uint64) types. // GetTxLookupEntry retrieves the positional metadata associated with a transaction // hash to allow retrieving the transaction or receipt by hash. func GetTxLookupEntry(db DatabaseReader, hash common.Hash) (common.Hash, uint64, uint64) { - fmt.Println("[GetTxLookupEntry FUNCTION RAN]") // Load the positional metadata from disk and bail if it fails //fmt.Println("INSIDE GetTxLookupEntry ") //fmt.Println("the db is ") //fmt.Println(db) - fmt.Println("the hash is", hash.String()) data, _ := db.Get(append(lookupPrefix, hash.Bytes()...)) - fmt.Println("the data is ") - fmt.Println(data) if len(data) == 0 { return common.Hash{}, 0, 0 } diff --git a/core/shyft_database_util.go b/core/shyft_database_util.go index 2fc57804cb..3478312288 100644 --- a/core/shyft_database_util.go +++ b/core/shyft_database_util.go @@ -14,7 +14,6 @@ _ "github.com/lib/pq" "github.com/ethereum/go-ethereum/core/types" Rewards "github.com/ethereum/go-ethereum/consensus/ethash" "github.com/ethereum/go-ethereum/shyfttracerinterface" - "reflect" ) var IShyftTracer shyfttracerinterface.IShyftTracer @@ -174,11 +173,9 @@ func SwriteTransactions(sqldb *sql.DB, tx *types.Transaction, blockHash common.H } hash := txData.TxHash - fmt.Println(reflect.TypeOf(hash)) txHash := txData.TxHash.Hex() - //prayer, _ := IShyftTracer.GetTracerToRun(hash) - //fmt.Printf("%+v\n", prayer) + IShyftTracer.GetTracerToRun(hash) //var stack *node.Node //var cfg *eth.Config @@ -292,6 +289,25 @@ func writeContractBalance(sqldb *sql.DB, tx *types.Transaction) error { return nil } +func writeContractBalanceHelper(sqldb *sql.DB, tx *types.Transaction) (SendAndReceive, string, string) { + sendAndReceiveData := SendAndReceive{ + From: tx.From().Hex(), + Amount: tx.Value().String(), + } + + fromAddr := sendAndReceiveData.From + getAccountBalanceSender:= SGetAccount(sqldb, fromAddr) + + var senderBalance SendAndReceive + if err := json.Unmarshal([]byte(getAccountBalanceSender), &senderBalance); err != nil { + log.Fatal(err) + } + balanceSender := senderBalance.Balance + accountNonceSender := senderBalance.TxCountAccount + + return sendAndReceiveData, balanceSender, accountNonceSender +} + //writeFromBalance writes senders balance to accounts db func writeFromBalance(sqldb *sql.DB, tx *types.Transaction) error { sendAndReceiveData, balanceRec, balanceSen, accountNonceRec, accountNonceSen := writeBalanceHelper(sqldb, tx) @@ -375,8 +391,9 @@ func writeBalanceHelper(sqldb *sql.DB, tx *types.Transaction) (SendAndReceive, s toAddr := sendAndReceiveData.To fromAddr := sendAndReceiveData.From - getAccountBalanceReceiver := GetAccount(sqldb, toAddr) - getAccountBalanceSender:= GetAccount(sqldb, fromAddr) + + getAccountBalanceReceiver := SGetAccount(sqldb, toAddr) + getAccountBalanceSender:= SGetAccount(sqldb, fromAddr) var receiverBalance SendAndReceive if err := json.Unmarshal([]byte(getAccountBalanceReceiver), &receiverBalance); err != nil { @@ -495,7 +512,7 @@ func storeReward(sqldb *sql.DB, address string, reward *big.Int) { //Look into postgres functions array_to_json(array_agg(lap)) //Example select array_to_json(array_agg(lap)) //from ( select * from blocks)lap; -func GetAllBlocks(sqldb *sql.DB) string { +func SGetAllBlocks(sqldb *sql.DB) string { var arr blockRes var blockArr string rows, err := sqldb.Query(` @@ -616,7 +633,7 @@ func SGetBlock(sqldb *sql.DB, blockNumber string) string { return string(json) } -func GetRecentBlock(sqldb *sql.DB) string { +func SGetRecentBlock(sqldb *sql.DB) string { sqlStatement := `SELECT * FROM blocks WHERE number=(SELECT MAX(number) FROM blocks);` row := sqldb.QueryRow(sqlStatement) var hash string @@ -669,7 +686,7 @@ func GetRecentBlock(sqldb *sql.DB) string { return string(json) } -func GetAllTransactionsFromBlock(sqldb *sql.DB, blockNumber string) string { +func SGetAllTransactionsFromBlock(sqldb *sql.DB, blockNumber string) string { var arr txRes var txx string sqlStatement := `SELECT * FROM txs WHERE blocknumber=$1` @@ -737,7 +754,7 @@ func GetAllTransactionsFromBlock(sqldb *sql.DB, blockNumber string) string { return txx } -func GetAllBlocksMinedByAddress(sqldb *sql.DB, coinbase string) string { +func SGetAllBlocksMinedByAddress(sqldb *sql.DB, coinbase string) string { var arr blockRes var blockArr string sqlStatement := `SELECT * FROM blocks WHERE coinbase=$1` @@ -804,7 +821,7 @@ func GetAllBlocksMinedByAddress(sqldb *sql.DB, coinbase string) string { } //GetAllTransactions getter fn for API -func GetAllTransactions(sqldb *sql.DB) string { +func SGetAllTransactions(sqldb *sql.DB) string { var arr txRes var txx string rows, err := sqldb.Query(` @@ -931,7 +948,7 @@ func SGetTransaction(sqldb *sql.DB, txHash string) string { } //GetAccount returns account balances -func GetAccount(sqldb *sql.DB, address string) string { +func SGetAccount(sqldb *sql.DB, address string) string { sqlStatement := `SELECT * FROM accounts WHERE addr=$1;` row := sqldb.QueryRow(sqlStatement, address) var addr string @@ -952,7 +969,7 @@ func GetAccount(sqldb *sql.DB, address string) string { } //GetAllAccounts returns all accounts and balances -func GetAllAccounts(sqldb *sql.DB) string { +func SGetAllAccounts(sqldb *sql.DB) string { var array accountRes var accountsArr string var txCountAccount string @@ -991,7 +1008,7 @@ func GetAllAccounts(sqldb *sql.DB) string { } //GetAccount returns account balances -func GetAccountTxs(sqldb *sql.DB, address string) string { +func SGetAccountTxs(sqldb *sql.DB, address string) string { var arr txRes var txx string sqlStatement := `SELECT * FROM txs WHERE to_addr=$1 OR from_addr=$1;` diff --git a/eth/api_tracer.go b/eth/api_tracer.go index 39c5779d9b..fa4c0d0f95 100644 --- a/eth/api_tracer.go +++ b/eth/api_tracer.go @@ -532,189 +532,6 @@ func (api *PrivateDebugAPI) computeStateDB(block *types.Block, reexec uint64) (* // 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, 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 //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) @@ -729,7 +546,6 @@ func (api *PrivateDebugAPI) TraceTransaction(ctx context.Context, hash common.Ha return nil, fmt.Errorf("transaction %x not found", hash) } - fmt.Println("TX IN TRACETRANSACTION", tx) reexec := defaultTraceReexec if config != nil && config.Reexec != nil { reexec = *config.Reexec @@ -746,8 +562,6 @@ func (api *PrivateDebugAPI) TraceTransaction(ctx context.Context, hash common.Ha // be tracer dependent. func (api *PrivateDebugAPI) traceTx(ctx context.Context, message core.Message, vmctx vm.Context, statedb *state.StateDB, config *TraceConfig) (interface{}, error) { // Assemble the structured logger or the JavaScript tracer - fmt.Println("\n [API_TRACER.GO traceTX func]") - // fmt.Printf("%+v", config, "THIS IS CONFIG") var ( tracer vm.Tracer err error @@ -756,23 +570,23 @@ 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 timeout := defaultTraceTimeout + fmt.Println(timeout) if config.Timeout != nil { if timeout, err = time.ParseDuration(*config.Timeout); err != nil { return nil, err } } // Constuct the JavaScript tracer to execute with - fmt.Printf("%+v \n", *config.Tracer) if tracer, err = tracers.New(*config.Tracer); err != nil { return nil, err } // 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() + //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) @@ -798,7 +612,6 @@ func (api *PrivateDebugAPI) traceTx(ctx context.Context, message core.Message, v }, nil case *tracers.Tracer: - fmt.Println("THIS RAN MF") return tracer.GetResult() default: diff --git a/eth/shyft_tracer.go b/eth/shyft_tracer.go index d0c984d961..fb39dd5e19 100644 --- a/eth/shyft_tracer.go +++ b/eth/shyft_tracer.go @@ -5,7 +5,6 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/params" "context" - "fmt" ) var EthereumObject interface{} @@ -26,7 +25,6 @@ func (st ShyftTracer) GetTracerToRun (hash common.Hash) (interface{}, error) { Timeout: nil, Reexec: nil, } - fmt.Printf("%+v", config, "THIS IS CONFIG IN SHYFT_TRACER") //var fullNode *Ethereum fullNode, _ := SNew(Global_config) privateAPI := NewPrivateDebugAPI(config2, fullNode) diff --git a/eth/tracers/tracer.go b/eth/tracers/tracer.go index 8c42b157b3..328549e27b 100644 --- a/eth/tracers/tracer.go +++ b/eth/tracers/tracer.go @@ -30,7 +30,7 @@ import ( "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" + "gopkg.in/olebedev/go-duktape.v3" ) // bigIntegerJS is the minified version of https://github.com/peterolson/BigInteger.js. @@ -307,13 +307,10 @@ type Tracer struct { // which must evaluate to an expression returning an object with 'step', 'fault' // and 'result' functions. func New(code string) (*Tracer, error) { - fmt.Println("\n [TRACER.GO New func]", code) // Resolve any tracers by name and assemble the tracer object if tracer, ok := tracer(code); ok { code = tracer - fmt.Println("\n [ok]", ok) } - fmt.Println("\n [tracer]", tracer) tracer := &Tracer{ vm: duktape.New(), @@ -328,6 +325,7 @@ func New(code string) (*Tracer, error) { costValue: new(uint), depthValue: new(uint), } + // Set up builtins for this environment tracer.vm.PushGlobalGoFunction("toHex", func(ctx *duktape.Context) int { ctx.PushString(hexutil.Encode(popSlice(ctx))) @@ -460,7 +458,6 @@ func New(code string) (*Tracer, error) { tracer.dbWrapper.pushObject(tracer.vm) tracer.vm.PutPropString(tracer.stateObject, "db") - return tracer, nil } @@ -500,11 +497,6 @@ func wrapError(context string, err error) error { // CaptureStart implements the Tracer interface to initialize the tracing operation. func (jst *Tracer) CaptureStart(from common.Address, to common.Address, create bool, input []byte, gas uint64, value *big.Int) error { - //fmt.Println("\n\n\t\t type: ", reflect.TypeOf(input)) - fmt.Println("\t\t [TRACER TO]:", to.String()) - fmt.Println("\t\t [TRACER FROM]:", from.String()) - fmt.Println("\t\t [TRACER VALUE]:", value.String()) - fmt.Println("\t\t [TRACER INPUT STRING]:", string(input[:len(input)]), "\n\n") jst.ctx["type"] = "CALL" if create { jst.ctx["type"] = "CREATE" @@ -573,9 +565,6 @@ func (jst *Tracer) CaptureFault(env *vm.EVM, pc uint64, op vm.OpCode, gas, cost // CaptureEnd is called after the call finishes to finalize the tracing. func (jst *Tracer) CaptureEnd(output []byte, gasUsed uint64, t time.Duration, err error) error { - //fmt.Println("\n\n\t\t", reflect.TypeOf(output)) - //fmt.Println("\t\t [TRACER OUTPUT]:", output[:len(output)]) - //fmt.Println("\t\t [TRACER OUTPUT STRING]:", string(output[:len(output)]), "\n\n") jst.ctx["output"] = output jst.ctx["gasUsed"] = gasUsed jst.ctx["time"] = t.String() @@ -586,6 +575,13 @@ func (jst *Tracer) CaptureEnd(output []byte, gasUsed uint64, t time.Duration, er return nil } +type Internals struct { + From string + To string + Value string + Calls []*Internals +} + // GetResult calls the Javascript 'result' function and returns its value, or any accumulated error func (jst *Tracer) GetResult() (json.RawMessage, error) { // Transform the context into a JavaScript object and inject into the state @@ -626,5 +622,33 @@ func (jst *Tracer) GetResult() (json.RawMessage, error) { jst.vm.DestroyHeap() jst.vm.Destroy() + //var dat map[string]interface{} + var dat Internals + + if err := json.Unmarshal(result, &dat); err != nil { + panic(err) + } + + //fmt.Println("[FULL DATA]", string(result)) + //fmt.Println("\n +++++++++++++++++++") + //fmt.Println(dat["calls"]) + //fmt.Println(dat["calls"]["gasUsed"]) + //j, _ := json.Marshal(result) + //internals := string(j) + //fmt.Println("[RESULT]", dat) + //fmt.Println("[RESULT]", dat.To) + //fmt.Println("[Internal Call]", len(dat.Calls)) + + for key, val := range dat.Calls { + fmt.Println(key) + fmt.Println("[INTERNAL TO]", val.To) + fmt.Println("[INTERNAL From]", val.From) + fmt.Println("[INTERNAL Calls length]", len(val.Calls)) + for newKey, newVal := range val.Calls { + fmt.Println(newKey) + fmt.Println("[INSIDE INTERNAL TO]", newVal.To) + } + } + return result, jst.err } diff --git a/shyftBlockExplorerApi/handler.go b/shyftBlockExplorerApi/handler.go index 496941db7b..9f368d6748 100644 --- a/shyftBlockExplorerApi/handler.go +++ b/shyftBlockExplorerApi/handler.go @@ -2,13 +2,12 @@ package main ///@NOTE Shyft handler functions when endpoints are hit import ( - "database/sql" "fmt" "net/http" _ "github.com/lib/pq" - "github.com/ethereum/go-ethereum/shyftdb" + "github.com/ethereum/go-ethereum/core" "github.com/gorilla/mux" "bytes" "io/ioutil" @@ -19,13 +18,13 @@ import ( func GetTransaction(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) txHash := vars["txHash"] - connStr := "user=postgres dbname=shyftdb sslmode=disable" - blockExplorerDb, err := sql.Open("postgres", connStr) - if err != nil { - return - } - - getTxResponse := shyftdb.GetTransaction(blockExplorerDb, txHash) + //connStr := "user=postgres dbname=shyftdb sslmode=disable" + //blockExplorerDb, err := sql.Open("postgres", connStr) + //if err != nil { + // return + //} + sqldb, err := core.DBConnection() + getTxResponse := core.SGetTransaction(sqldb, txHash) if err != nil { http.Error(w, err.Error(), 500) @@ -40,13 +39,15 @@ func GetTransaction(w http.ResponseWriter, r *http.Request) { // GetAllTransactions gets txs func GetAllTransactions(w http.ResponseWriter, r *http.Request) { - connStr := "user=postgres dbname=shyftdb sslmode=disable" - blockExplorerDb, err := sql.Open("postgres", connStr) - if err != nil { - return - } + //connStr := "user=postgres dbname=shyftdb sslmode=disable" + //blockExplorerDb, err := sql.Open("postgres", connStr) + //if err != nil { + // return + //} - txs := shyftdb.GetAllTransactions(blockExplorerDb) + sqldb, err := core.DBConnection() + + txs := core.SGetAllTransactions(sqldb) if err != nil { http.Error(w, err.Error(), 500) @@ -64,13 +65,15 @@ func GetAllTransactions(w http.ResponseWriter, r *http.Request) { func GetAllTransactionsFromBlock(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) blockNumber := vars["blockNumber"] - connStr := "user=postgres dbname=shyftdb sslmode=disable" - blockExplorerDb, err := sql.Open("postgres", connStr) - if err != nil { - return - } + //connStr := "user=postgres dbname=shyftdb sslmode=disable" + //blockExplorerDb, err := sql.Open("postgres", connStr) + //if err != nil { + // return + //} - txsFromBlock := shyftdb.GetAllTransactionsFromBlock(blockExplorerDb, blockNumber) + sqldb, err := core.DBConnection() + + txsFromBlock := core.SGetAllTransactionsFromBlock(sqldb, blockNumber) if err != nil { http.Error(w, err.Error(), 500) @@ -86,13 +89,15 @@ func GetAllTransactionsFromBlock(w http.ResponseWriter, r *http.Request) { func GetAllBlocksMinedByAddress(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) coinbase := vars["coinbase"] - connStr := "user=postgres dbname=shyftdb sslmode=disable" - blockExplorerDb, err := sql.Open("postgres", connStr) - if err != nil { - return - } + //connStr := "user=postgres dbname=shyftdb sslmode=disable" + //blockExplorerDb, err := sql.Open("postgres", connStr) + //if err != nil { + // return + //} - blocksMined := shyftdb.GetAllBlocksMinedByAddress(blockExplorerDb, coinbase) + sqldb, err := core.DBConnection() + + blocksMined := core.SGetAllBlocksMinedByAddress(sqldb, coinbase) if err != nil { http.Error(w, err.Error(), 500) @@ -109,13 +114,15 @@ func GetAllBlocksMinedByAddress(w http.ResponseWriter, r *http.Request) { func GetAccount(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) address := vars["address"] - connStr := "user=postgres dbname=shyftdb sslmode=disable" - blockExplorerDb, err := sql.Open("postgres", connStr) - if err != nil { - return - } + //connStr := "user=postgres dbname=shyftdb sslmode=disable" + //blockExplorerDb, err := sql.Open("postgres", connStr) + //if err != nil { + // return + //} - getAccountBalance := shyftdb.GetAccount(blockExplorerDb, address) + sqldb, err := core.DBConnection() + + getAccountBalance := core.SGetAccount(sqldb, address) if err != nil { http.Error(w, err.Error(), 500) @@ -132,13 +139,15 @@ func GetAccount(w http.ResponseWriter, r *http.Request) { func GetAccountTxs(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) address := vars["address"] - connStr := "user=postgres dbname=shyftdb sslmode=disable" - blockExplorerDb, err := sql.Open("postgres", connStr) - if err != nil { - return - } + //connStr := "user=postgres dbname=shyftdb sslmode=disable" + //blockExplorerDb, err := sql.Open("postgres", connStr) + //if err != nil { + // return + //} - getAccountTxs := shyftdb.GetAccountTxs(blockExplorerDb, address) + sqldb, err := core.DBConnection() + + getAccountTxs := core.SGetAccountTxs(sqldb, address) if err != nil { http.Error(w, err.Error(), 500) @@ -153,12 +162,15 @@ func GetAccountTxs(w http.ResponseWriter, r *http.Request) { // GetAllAccounts gets balances func GetAllAccounts(w http.ResponseWriter, r *http.Request) { - connStr := "user=postgres dbname=shyftdb sslmode=disable" - blockExplorerDb, err := sql.Open("postgres", connStr) - if err != nil { - return - } - allAccounts := shyftdb.GetAllAccounts(blockExplorerDb) + //connStr := "user=postgres dbname=shyftdb sslmode=disable" + //blockExplorerDb, err := sql.Open("postgres", connStr) + //if err != nil { + // return + //} + + sqldb, err := core.DBConnection() + + allAccounts := core.SGetAllAccounts(sqldb) if err != nil { http.Error(w, err.Error(), 500) return @@ -173,13 +185,13 @@ func GetAllAccounts(w http.ResponseWriter, r *http.Request) { func GetBlock(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) blockNumber := vars["blockNumber"] - connStr := "user=postgres dbname=shyftdb sslmode=disable" - blockExplorerDb, err := sql.Open("postgres", connStr) - if err != nil { - return - } - - getBlockResponse := shyftdb.GetBlock(blockExplorerDb, blockNumber) + //connStr := "user=postgres dbname=shyftdb sslmode=disable" + //blockExplorerDb, err := sql.Open("postgres", connStr) + //if err != nil { + // return + //} + sqldb, err := core.DBConnection() + getBlockResponse := core.SGetBlock(sqldb, blockNumber) if err != nil { http.Error(w, err.Error(), 500) @@ -194,12 +206,13 @@ func GetBlock(w http.ResponseWriter, r *http.Request) { // GetAllBlocks response func GetAllBlocks(w http.ResponseWriter, r *http.Request) { - connStr := "user=postgres dbname=shyftdb sslmode=disable" - blockExplorerDb, err := sql.Open("postgres", connStr) - if err != nil { - return - } - block3 := shyftdb.GetAllBlocks(blockExplorerDb) + //connStr := "user=postgres dbname=shyftdb sslmode=disable" + //blockExplorerDb, err := sql.Open("postgres", connStr) + //if err != nil { + // return + //} + sqldb, err := core.DBConnection() + block3 := core.SGetAllBlocks(sqldb) if err != nil { http.Error(w, err.Error(), 500) return @@ -210,12 +223,14 @@ func GetAllBlocks(w http.ResponseWriter, r *http.Request) { } func GetRecentBlock(w http.ResponseWriter, r *http.Request) { - connStr := "user=postgres dbname=shyftdb sslmode=disable" - blockExplorerDb, err := sql.Open("postgres", connStr) - if err != nil { - return - } - mostRecentBlock := shyftdb.GetRecentBlock(blockExplorerDb) + //connStr := "user=postgres dbname=shyftdb sslmode=disable" + //blockExplorerDb, err := sql.Open("postgres", connStr) + //if err != nil { + // return + //} + sqldb, err := core.DBConnection() + + mostRecentBlock := core.SGetRecentBlock(sqldb) if err != nil { http.Error(w, err.Error(), 500) return From efbb2a7a87e254b925c8b99923029291bf48817f Mon Sep 17 00:00:00 2001 From: Dustin Brickwood Date: Wed, 11 Jul 2018 19:48:06 -0400 Subject: [PATCH 12/21] recursive fn in place --- core/shyft_database_util.go | 3 --- eth/api_tracer.go | 17 +++++---------- eth/tracers/tracer.go | 42 ++++++++++++++++++------------------- 3 files changed, 26 insertions(+), 36 deletions(-) diff --git a/core/shyft_database_util.go b/core/shyft_database_util.go index 3478312288..5a660890dc 100644 --- a/core/shyft_database_util.go +++ b/core/shyft_database_util.go @@ -177,9 +177,6 @@ func SwriteTransactions(sqldb *sql.DB, tx *types.Transaction, blockHash common.H IShyftTracer.GetTracerToRun(hash) - //var stack *node.Node - //var cfg *eth.Config - from := txData.From.Hex() blockHasher := txData.BlockHash amount := txData.Amount.String() diff --git a/eth/api_tracer.go b/eth/api_tracer.go index fa4c0d0f95..33d6ad6f33 100644 --- a/eth/api_tracer.go +++ b/eth/api_tracer.go @@ -533,19 +533,10 @@ func (api *PrivateDebugAPI) computeStateDB(block *types.Block, reexec uint64) (* // and returns them as a JSON object. func (api *PrivateDebugAPI) TraceTransaction(ctx context.Context, hash common.Hash, config *TraceConfig) (interface{}, error) { // NOTE:SHYFT - //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) - // Retrieve the transaction and assemble its EVM context - //fmt.Println("IN TRACE TRANSACTION the chaindb is ") - //fmt.Println(chaindb) - //fmt.Println("IN TRACE TRANSACTION the common hash is ") - //fmt.Println(hash) - tx, blockHash, _, index := core.GetTransaction(api.eth.ChainDb(), hash) if tx == nil { return nil, fmt.Errorf("transaction %x not found", hash) } - reexec := defaultTraceReexec if config != nil && config.Reexec != nil { reexec = *config.Reexec @@ -569,10 +560,11 @@ func (api *PrivateDebugAPI) traceTx(ctx context.Context, message core.Message, v switch { case config != nil && config.Tracer != nil: // Define a meaningful timeout of a single transaction trace - timeout := defaultTraceTimeout - fmt.Println(timeout) + + _ = defaultTraceTimeout + if config.Timeout != nil { - if timeout, err = time.ParseDuration(*config.Timeout); err != nil { + if _, err = time.ParseDuration(*config.Timeout); err != nil { return nil, err } } @@ -580,6 +572,7 @@ 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() { diff --git a/eth/tracers/tracer.go b/eth/tracers/tracer.go index 328549e27b..fbd783ea31 100644 --- a/eth/tracers/tracer.go +++ b/eth/tracers/tracer.go @@ -579,9 +579,29 @@ type Internals struct { From string To string Value string + Gas string + GasUsed string Calls []*Internals } + +func (i *Internals) InternalRecursive() { + fmt.Println("[Internal To]", i.To) + fmt.Println("[Internal From]", i.From) + lengthOfCalls := len(i.Calls) + fmt.Println("[LENGTH OF CALLS]", lengthOfCalls) + if lengthOfCalls == 0 { + return + } + + for _, val := range i.Calls { + val.InternalRecursive() + } +} + + + + // GetResult calls the Javascript 'result' function and returns its value, or any accumulated error func (jst *Tracer) GetResult() (json.RawMessage, error) { // Transform the context into a JavaScript object and inject into the state @@ -622,33 +642,13 @@ func (jst *Tracer) GetResult() (json.RawMessage, error) { jst.vm.DestroyHeap() jst.vm.Destroy() - //var dat map[string]interface{} var dat Internals if err := json.Unmarshal(result, &dat); err != nil { panic(err) } - //fmt.Println("[FULL DATA]", string(result)) - //fmt.Println("\n +++++++++++++++++++") - //fmt.Println(dat["calls"]) - //fmt.Println(dat["calls"]["gasUsed"]) - //j, _ := json.Marshal(result) - //internals := string(j) - //fmt.Println("[RESULT]", dat) - //fmt.Println("[RESULT]", dat.To) - //fmt.Println("[Internal Call]", len(dat.Calls)) - - for key, val := range dat.Calls { - fmt.Println(key) - fmt.Println("[INTERNAL TO]", val.To) - fmt.Println("[INTERNAL From]", val.From) - fmt.Println("[INTERNAL Calls length]", len(val.Calls)) - for newKey, newVal := range val.Calls { - fmt.Println(newKey) - fmt.Println("[INSIDE INTERNAL TO]", newVal.To) - } - } + dat.InternalRecursive() return result, jst.err } From 20ff154473ad2be45c359ad3b554021c1fa1c3de Mon Sep 17 00:00:00 2001 From: Dustin Brickwood Date: Wed, 11 Jul 2018 20:49:15 -0400 Subject: [PATCH 13/21] wip writing internals --- eth/tracers/tracer.go | 21 ++++++++++++++++++--- shyft-cli/postgres_setup/create_tables.psql | 19 ++++++++++++++++++- shyft-cli/postgres_setup/drop_tables.psql | 2 ++ 3 files changed, 38 insertions(+), 4 deletions(-) diff --git a/eth/tracers/tracer.go b/eth/tracers/tracer.go index fbd783ea31..14c6a34874 100644 --- a/eth/tracers/tracer.go +++ b/eth/tracers/tracer.go @@ -576,20 +576,35 @@ func (jst *Tracer) CaptureEnd(output []byte, gasUsed uint64, t time.Duration, er } type Internals struct { + Type string From string To string Value string Gas string GasUsed string + Input string + Output string + Time string Calls []*Internals } +//func (i *Internals) SWriteInteralTxs() { +// connStr := "user=postgres dbname=shyftdb sslmode=disable" +// sqldb, err := sql.Open("postgres", connStr) +// if err != nil { +// return +// } +// +// sqlStatement := `INSERT INTO internalTxs(type, txhash, from_addr, to_addr, amount, gas, gasUsed, time, input, output) VALUES(($1), ($2), ($3), ($4), ($5), ($6), ($7), ($8), ($9), ($10))` +// qerr := sqldb.QueryRow(sqlStatement, i.Type, txHash, i.From, i.To, i.Value, i.Gas, i.GasUsed, i.Time, i.Input, i.Output) +// +// if qerr != nil { +// panic(qerr) +// } +//} func (i *Internals) InternalRecursive() { - fmt.Println("[Internal To]", i.To) - fmt.Println("[Internal From]", i.From) lengthOfCalls := len(i.Calls) - fmt.Println("[LENGTH OF CALLS]", lengthOfCalls) if lengthOfCalls == 0 { return } diff --git a/shyft-cli/postgres_setup/create_tables.psql b/shyft-cli/postgres_setup/create_tables.psql index b746384bdc..259a95b23e 100644 --- a/shyft-cli/postgres_setup/create_tables.psql +++ b/shyft-cli/postgres_setup/create_tables.psql @@ -16,7 +16,7 @@ CREATE TABLE IF NOT EXISTS blocks ( ); CREATE TABLE IF NOT EXISTS txs ( - txHash text, + txHash text primary key unique, to_addr text, from_addr text, blockhash text references blocks(hash), @@ -39,3 +39,20 @@ CREATE TABLE IF NOT EXISTS accounts ( txCountAccount numeric ); +CREATE TABLE IF NOT EXISTS contracts ( + txHash text +); + +CREATE TABLE IF NOT EXISTS internalTxs ( + id SERIAL PRIMARY KEY, + txHash text references txs(txHash), + type text, + to_addr text, + from_addr text, + amount text, + gas numeric, + gasUsed numeric, + time text, + input text, + output text +) \ No newline at end of file diff --git a/shyft-cli/postgres_setup/drop_tables.psql b/shyft-cli/postgres_setup/drop_tables.psql index 41563522dd..8826b85093 100644 --- a/shyft-cli/postgres_setup/drop_tables.psql +++ b/shyft-cli/postgres_setup/drop_tables.psql @@ -1,3 +1,5 @@ +DROP TABLE internalTxs; DROP TABLE txs; DROP TABLE blocks; DROP TABLE accounts; +DROP TABLE contracts; \ No newline at end of file From 185c35523da306dab60230c252cde7c73e9cb015 Mon Sep 17 00:00:00 2001 From: Dustin Brickwood Date: Fri, 13 Jul 2018 11:55:37 -0400 Subject: [PATCH 14/21] writing internals to db --- core/shyft_database_util.go | 4 +- eth/api_tracer.go | 85 +++++++++++ eth/shyft_tracer.go | 272 +----------------------------------- eth/tracers/tracer.go | 95 ++++++++++--- 4 files changed, 162 insertions(+), 294 deletions(-) diff --git a/core/shyft_database_util.go b/core/shyft_database_util.go index 5a660890dc..8320bc70d3 100644 --- a/core/shyft_database_util.go +++ b/core/shyft_database_util.go @@ -175,8 +175,6 @@ func SwriteTransactions(sqldb *sql.DB, tx *types.Transaction, blockHash common.H hash := txData.TxHash txHash := txData.TxHash.Hex() - IShyftTracer.GetTracerToRun(hash) - from := txData.From.Hex() blockHasher := txData.BlockHash amount := txData.Amount.String() @@ -231,6 +229,8 @@ func SwriteTransactions(sqldb *sql.DB, tx *types.Transaction, blockHash common.H } } + IShyftTracer.GetTracerToRun(hash) + return nil } diff --git a/eth/api_tracer.go b/eth/api_tracer.go index 33d6ad6f33..c4df438414 100644 --- a/eth/api_tracer.go +++ b/eth/api_tracer.go @@ -548,6 +548,91 @@ func (api *PrivateDebugAPI) TraceTransaction(ctx context.Context, hash common.Ha return api.traceTx(ctx, msg, vmctx, statedb, config) } +// TraceTransaction returns the structured logs created during the execution of EVM +// and returns them as a JSON object. +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) + if tx == nil { + return nil, fmt.Errorf("transaction %x not found", hash) + } + reexec := defaultTraceReexec + if config != nil && config.Reexec != nil { + reexec = *config.Reexec + } + msg, vmctx, statedb, err := api.computeTxEnv(blockHash, int(index), reexec) + if err != nil { + return nil, err + } + return api.StraceTx(ctx, msg, vmctx, statedb, config, hash) +} + +// 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. +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 ( + tracer vm.Tracer + err error + ) + switch { + case config != nil && config.Tracer != nil: + // Define a meaningful timeout of a single transaction trace + + _ = defaultTraceTimeout + + if config.Timeout != nil { + if _, err = time.ParseDuration(*config.Timeout); err != nil { + return nil, err + } + } + // Constuct the JavaScript tracer to execute with + 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() + + case config == nil: + tracer = vm.NewStructLogger(nil) + + default: + tracer = vm.NewStructLogger(config.LogConfig) + } + // Run the transaction with tracing enabled. + vmenv := vm.NewEVM(vmctx, statedb, api.config, vm.Config{Debug: true, Tracer: tracer}) + + ret, gas, failed, err := core.ApplyMessage(vmenv, message, new(core.GasPool).AddGas(message.Gas())) + if err != nil { + return nil, fmt.Errorf("tracing failed: %v", err) + } + // Depending on the tracer type, format and return the output + 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 *tracers.Tracer: + return tracer.SGetResult(hash) + + default: + panic(fmt.Sprintf("bad tracer type %T", tracer)) + } +} + + + // 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. diff --git a/eth/shyft_tracer.go b/eth/shyft_tracer.go index fb39dd5e19..bd1b1baeec 100644 --- a/eth/shyft_tracer.go +++ b/eth/shyft_tracer.go @@ -28,7 +28,7 @@ func (st ShyftTracer) GetTracerToRun (hash common.Hash) (interface{}, error) { //var fullNode *Ethereum fullNode, _ := SNew(Global_config) privateAPI := NewPrivateDebugAPI(config2, fullNode) - return privateAPI.TraceTransaction(ctx2, hash, config) + return privateAPI.STraceTransaction(ctx2, hash, config) } func setEthObject(ethobj interface{}){ @@ -39,272 +39,4 @@ var Global_config *Config func setGlobalConfig(c *Config) { Global_config = c -} - -// -//import ( -// "github.com/ethereum/go-ethereum/common" -// "fmt" -// "github.com/ethereum/go-ethereum/core" -// "runtime" -// "context" -//) -// -////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()) -// fmt.Println("CTXXXXXXXXXXXXXXX") -// 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("THIS CTX") -// //fmt.Println("the tx is ") -// //fmt.Println(tx) -// //fmt.Println(blockHash) -// //fmt.Println(index) -// //DebugApi.traceTxTest(msg, vmctx, statedb, config) -// return 42 -//} -// -//func (api *PrivateDebugAPI) TraceTransactionTest(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) -// } -// -// tx, blockHash, _, index := core.GetTransaction(api.eth.ChainDb(), hash) -// if tx == nil { -// return nil, fmt.Errorf("transaction %x not found", hash) -// } -// -// reexec := defaultTraceReexec -// if config != nil && config.Reexec != nil { -// reexec = *config.Reexec -// } -// msg, vmctx, statedb, err := api.computeTxEnv(blockHash, int(index), reexec) -// if err != nil { -// return nil, err -// } -// fmt.Println("CTX +++++++++++++++++++++++", ctx) -// return api.traceTxTest(ctx, msg, vmctx, statedb, config) -//} -// -//func setEthObject(ethobj interface{}){ -// EthereumObject = ethobj -//} +} \ No newline at end of file diff --git a/eth/tracers/tracer.go b/eth/tracers/tracer.go index 14c6a34874..225021c204 100644 --- a/eth/tracers/tracer.go +++ b/eth/tracers/tracer.go @@ -31,6 +31,7 @@ import ( "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/log" "gopkg.in/olebedev/go-duktape.v3" + "database/sql" ) // bigIntegerJS is the minified version of https://github.com/peterolson/BigInteger.js. @@ -588,35 +589,37 @@ type Internals struct { Calls []*Internals } -//func (i *Internals) SWriteInteralTxs() { -// connStr := "user=postgres dbname=shyftdb sslmode=disable" -// sqldb, err := sql.Open("postgres", connStr) -// if err != nil { -// return -// } -// -// sqlStatement := `INSERT INTO internalTxs(type, txhash, from_addr, to_addr, amount, gas, gasUsed, time, input, output) VALUES(($1), ($2), ($3), ($4), ($5), ($6), ($7), ($8), ($9), ($10))` -// qerr := sqldb.QueryRow(sqlStatement, i.Type, txHash, i.From, i.To, i.Value, i.Gas, i.GasUsed, i.Time, i.Input, i.Output) -// -// if qerr != nil { -// panic(qerr) -// } -//} +func (i *Internals) SWriteInteralTxs(hash common.Hash) { + connStr := "user=postgres dbname=shyftdb sslmode=disable" + sqldb, err := sql.Open("postgres", connStr) + if err != nil { + return + } + gas, _ := hexutil.DecodeUint64(i.Gas) + gasUsed, _ := hexutil.DecodeUint64(i.GasUsed) -func (i *Internals) InternalRecursive() { + var returnValue string + sqlStatement := `INSERT INTO internaltxs(type, txhash, from_addr, to_addr, amount, gas, gasUsed, time, input, output) VALUES(($1), ($2), ($3), ($4), ($5), ($6), ($7), ($8), ($9), ($10)) RETURNING txHash` + qerr := sqldb.QueryRow(sqlStatement, i.Type, hash.Hex(), i.From, i.To, i.Value, gas, gasUsed, i.Time, i.Input, i.Output).Scan(&returnValue) + + if qerr != nil { + fmt.Println(qerr) + panic(qerr) + } +} + +func (i *Internals) InternalRecursive(hash common.Hash) { + i.SWriteInteralTxs(hash) lengthOfCalls := len(i.Calls) if lengthOfCalls == 0 { return } for _, val := range i.Calls { - val.InternalRecursive() + val.InternalRecursive(hash) } } - - - // GetResult calls the Javascript 'result' function and returns its value, or any accumulated error func (jst *Tracer) GetResult() (json.RawMessage, error) { // Transform the context into a JavaScript object and inject into the state @@ -662,8 +665,56 @@ func (jst *Tracer) GetResult() (json.RawMessage, error) { if err := json.Unmarshal(result, &dat); err != nil { panic(err) } - - dat.InternalRecursive() - return result, jst.err } + +// GetResult calls the Javascript 'result' function and returns its value, or any accumulated error +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() + + for key, val := range jst.ctx { + switch val := val.(type) { + case uint64: + jst.vm.PushUint(uint(val)) + + case string: + jst.vm.PushString(val) + + case []byte: + ptr := jst.vm.PushFixedBuffer(len(val)) + copy(makeSlice(ptr, uint(len(val))), val[:]) + + case common.Address: + ptr := jst.vm.PushFixedBuffer(20) + copy(makeSlice(ptr, 20), val[:]) + + case *big.Int: + pushBigInt(val, jst.vm) + + default: + panic(fmt.Sprintf("unsupported type: %T", val)) + } + jst.vm.PutPropString(obj, key) + } + jst.vm.PutPropString(jst.stateObject, "ctx") + + // Finalize the trace and return the results + result, err := jst.call("result", "ctx", "db") + if err != nil { + jst.err = wrapError("result", err) + } + // Clean up the JavaScript environment + jst.vm.DestroyHeap() + jst.vm.Destroy() + + var dat Internals + + if err := json.Unmarshal(result, &dat); err != nil { + panic(err) + } + fmt.Println("[THIS IS HASH]", hash.Hex()) + dat.InternalRecursive(hash) + + return result, jst.err +} \ No newline at end of file From b9dda84e30d634aea056483a13c273162e2301fa Mon Sep 17 00:00:00 2001 From: Dustin Brickwood Date: Fri, 13 Jul 2018 12:53:42 -0400 Subject: [PATCH 15/21] writing internals correctly --- eth/tracers/tracer.go | 15 ++++++++++++++- .../web3/transfer-through-master/test/test.js | 8 +++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/eth/tracers/tracer.go b/eth/tracers/tracer.go index 225021c204..27d016a086 100644 --- a/eth/tracers/tracer.go +++ b/eth/tracers/tracer.go @@ -32,6 +32,7 @@ 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. @@ -595,6 +596,12 @@ func (i *Internals) SWriteInteralTxs(hash common.Hash) { 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) @@ -609,6 +616,11 @@ func (i *Internals) SWriteInteralTxs(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) lengthOfCalls := len(i.Calls) if lengthOfCalls == 0 { @@ -713,7 +725,8 @@ 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("[THIS IS HASH]", hash.Hex()) + //fmt.Println("DAT DATA STRUCTURE" , dat) dat.InternalRecursive(hash) return result, jst.err diff --git a/shyft-cli/web3/transfer-through-master/test/test.js b/shyft-cli/web3/transfer-through-master/test/test.js index 6153da25c4..c74a91a706 100755 --- a/shyft-cli/web3/transfer-through-master/test/test.js +++ b/shyft-cli/web3/transfer-through-master/test/test.js @@ -4,13 +4,19 @@ var Transfers2 = artifacts.require("Transfers2"); contract('Transfers', function(accounts) { var addressA = web3.eth.accounts[0]; var addressB = web3.eth.accounts[1]; + console.log("Addr A:", addressA) + console.log("Addr B:", addressB) + var transfers; web3.eth.defaultAccount = web3.eth.accounts[0]; it("should initialize", async() => { transfers = await Transfers.new(); transfers2 = await Transfers2.new(); - assert(transfers !== undefined, ""); + console.log("Transfer addr1", transfers.address) + console.log("Transfer addr2", transfers2.address) + + assert(transfers !== undefined, ""); assert(transfers2 !== undefined, ""); }) From 4158caece6915cde7ab6a18d553cb896a31214f3 Mon Sep 17 00:00:00 2001 From: Dustin Brickwood Date: Sun, 15 Jul 2018 13:13:41 -0400 Subject: [PATCH 16/21] removed fmt print and added shyft tag to tracer fns --- core/blockchain.go | 5 ----- eth/api_tracer.go | 23 ++++++++++++----------- eth/chaindb.go | 5 ----- eth/tracers/tracer.go | 24 +++++------------------- node/node.go | 1 - 5 files changed, 17 insertions(+), 41 deletions(-) diff --git a/core/blockchain.go b/core/blockchain.go index 47a3c65913..6042992d5b 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -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() { diff --git a/eth/api_tracer.go b/eth/api_tracer.go index c4df438414..7a77907b58 100644 --- a/eth/api_tracer.go +++ b/eth/api_tracer.go @@ -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) diff --git a/eth/chaindb.go b/eth/chaindb.go index f4ced9929b..6b00bc13f8 100644 --- a/eth/chaindb.go +++ b/eth/chaindb.go @@ -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 diff --git a/eth/tracers/tracer.go b/eth/tracers/tracer.go index 27d016a086..76d359e558 100644 --- a/eth/tracers/tracer.go +++ b/eth/tracers/tracer.go @@ -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 diff --git a/node/node.go b/node/node.go index 6e03cd1606..b02aecfad1 100644 --- a/node/node.go +++ b/node/node.go @@ -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() } From 5d37a31a1257de40a49bfa9f7a8f77dc3e4db2d3 Mon Sep 17 00:00:00 2001 From: Dustin Brickwood Date: Sun, 15 Jul 2018 14:22:18 -0400 Subject: [PATCH 17/21] fixed testing changes due to change in folders dir --- core/shyft_database_util.go | 2 +- shyftDb/shyft_database_util_test.go | 55 +++++++++++++++-------------- 2 files changed, 29 insertions(+), 28 deletions(-) diff --git a/core/shyft_database_util.go b/core/shyft_database_util.go index 8320bc70d3..0c63f5e35d 100644 --- a/core/shyft_database_util.go +++ b/core/shyft_database_util.go @@ -255,7 +255,7 @@ func writeContractBalance(sqldb *sql.DB, tx *types.Transaction) error { panic(insertErr) } default: - getAccountBalanceSender:= GetAccount(sqldb, fromAddr) + getAccountBalanceSender:= SGetAccount(sqldb, fromAddr) var senderBalance SendAndReceive if err := json.Unmarshal([]byte(getAccountBalanceSender), &senderBalance); err != nil { log.Fatal(err) diff --git a/shyftDb/shyft_database_util_test.go b/shyftDb/shyft_database_util_test.go index 5e76048fc1..ac24de22a3 100644 --- a/shyftDb/shyft_database_util_test.go +++ b/shyftDb/shyft_database_util_test.go @@ -3,6 +3,7 @@ package shyftdb import ( "testing" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/types" "math/big" //"time" @@ -40,18 +41,18 @@ func TestBlockToReturnBlock(t *testing.T) { block := types.NewBlock(&types.Header{Number: big.NewInt(315)}, txs, nil, receipts) // Write and verify the block in the database - if err := WriteBlock(block, receipts); err != nil { + if err := core.SWriteBlock(block, receipts); err != nil { t.Fatalf("Failed to write block into database: %v", err) } - sqldb, err := DBConnection() - if (err != nil) { + sqldb, err := core.DBConnection() + if err != nil { panic(err) } - entry := GetBlock(sqldb, block.Number().String()) + entry := core.SGetBlock(sqldb, block.Number().String()) byt := []byte(entry) - var data SBlock + var data core.SBlock json.Unmarshal(byt, &data) //TODO Difficulty, rewards, age @@ -89,11 +90,11 @@ func TestBlockToReturnBlock(t *testing.T) { t.Fatalf("Block nonce [%v]: Block nonce not found", block.Nonce()) } - if getAllBlocks := GetAllBlocks(sqldb); len(getAllBlocks) == 0 { + if getAllBlocks := core.SGetAllBlocks(sqldb); len(getAllBlocks) == 0 { t.Fatalf("GetAllBlocks [%v]: GetAllBlocks did not return correctly", getAllBlocks) } - if getAllBlocksMinedByAddress := GetAllBlocksMinedByAddress(sqldb, block.Coinbase().String()); len(getAllBlocksMinedByAddress) == 0 { + if getAllBlocksMinedByAddress := core.SGetAllBlocksMinedByAddress(sqldb, block.Coinbase().String()); len(getAllBlocksMinedByAddress) == 0 { t.Fatalf("GetAllBlocksMinedByAddress [%v]: GetAllBlocksMinedByAddress did not return correctly", getAllBlocksMinedByAddress) } @@ -133,19 +134,19 @@ func TestGetRecentBlock(t *testing.T) { for _, bc := range blocks { // Write and verify the block in the database - if err := WriteBlock(bc, receipts); err != nil { + if err := core.SWriteBlock(bc, receipts); err != nil { t.Fatalf("Failed to write block into database: %v", err) } } - sqldb, err := DBConnection() + sqldb, err := core.DBConnection() if (err != nil) { panic(err) } - response := GetRecentBlock(sqldb) + response := core.SGetRecentBlock(sqldb) byteRes := []byte(response) - var recentBlock SBlock + var recentBlock core.SBlock json.Unmarshal(byteRes, &recentBlock) if block.Hash().String() != recentBlock.Hash { @@ -182,7 +183,7 @@ func TestGetRecentBlock(t *testing.T) { t.Fatalf("Block nonce [%v]: Block nonce not found", block.Nonce()) } - if allTxsFromBlock:= GetAllTransactionsFromBlock(sqldb, block2.Number().String()); len(allTxsFromBlock) == 0 { + if allTxsFromBlock:= core.SGetAllTransactionsFromBlock(sqldb, block2.Number().String()); len(allTxsFromBlock) == 0 { t.Fatalf("GetAllTransactionsFromBlock [%v]: GetAllTransactionsFromBlock did not return correctly", allTxsFromBlock) } ClearTables() @@ -212,7 +213,7 @@ func TestContractCreationTx(t *testing.T) { receipts := []*types.Receipt{receipt2} block := types.NewBlock(&types.Header{Number: big.NewInt(314)}, txs, nil, receipts) - if err := WriteBlock(block, receipts); err != nil { + if err := core.SWriteBlock(block, receipts); err != nil { t.Fatalf("Failed to write block into database: %v", err) } @@ -221,15 +222,15 @@ func TestContractCreationTx(t *testing.T) { contractAddressFromReciept = (*types.ReceiptForStorage)(receipt).ContractAddress.String() } - sqldb, err := DBConnection() + sqldb, err := core.DBConnection() if (err != nil) { panic(err) } for _, tx := range txs { - txn := GetTransaction(sqldb, tx.Hash().String()) + txn := core.SGetTransaction(sqldb, tx.Hash().String()) byt := []byte(txn) - var data ShyftTxEntryPretty + var data core.ShyftTxEntryPretty json.Unmarshal(byt, &data) if tx.Hash().String() != data.TxHash { @@ -316,18 +317,18 @@ func TestTransactionsToReturnTransactions(t *testing.T) { receipts := []*types.Receipt{receipt1} block := types.NewBlock(&types.Header{Number: big.NewInt(314)}, txs, nil, receipts) - if err := WriteBlock(block, receipts); err != nil { + if err := core.SWriteBlock(block, receipts); err != nil { t.Fatalf("Failed to write block into database: %v", err) } - sqldb, err := DBConnection() + sqldb, err := core.DBConnection() if (err != nil) { panic(err) } for _, tx := range txs { - txn := GetTransaction(sqldb, tx.Hash().String()) + txn := core.SGetTransaction(sqldb, tx.Hash().String()) byt := []byte(txn) - var data ShyftTxEntryPretty + var data core.ShyftTxEntryPretty json.Unmarshal(byt, &data) //TODO age, data @@ -385,7 +386,7 @@ func TestTransactionsToReturnTransactions(t *testing.T) { } } - if getAllTx := GetAllTransactions(sqldb); len(getAllTx) == 0 { + if getAllTx := core.SGetAllTransactions(sqldb); len(getAllTx) == 0 { t.Fatalf("GetAllTransactions [%v]: GetAllTransactions did not return correctly", getAllTx) } ClearTables() @@ -418,20 +419,20 @@ func TestAccountsToReturnAccounts(t *testing.T) { receipts := []*types.Receipt{receipt1} block := types.NewBlock(&types.Header{Number: big.NewInt(315)}, txs, nil, receipts) - if err := WriteBlock(block, receipts); err != nil { + if err := core.SWriteBlock(block, receipts); err != nil { t.Fatalf("Failed to write block into database: %v", err) } - sqldb, err := DBConnection() + sqldb, err := core.DBConnection() if (err != nil) { panic(err) } for _, tx := range txs { - accountAddrTo := GetAccount(sqldb, tx.To().String()) + accountAddrTo := core.SGetAccount(sqldb, tx.To().String()) byts := []byte(accountAddrTo) - var accountDataTo SAccounts + var accountDataTo core.SAccounts json.Unmarshal(byts, &accountDataTo) if tx.To().String() != accountDataTo.Addr { @@ -443,12 +444,12 @@ func TestAccountsToReturnAccounts(t *testing.T) { if strconv.FormatUint(tx.Nonce(), 10) != accountDataTo.TxCountAccount { t.Fatalf("To account nonce [%v]: To account nonce not found", accountDataTo.TxCountAccount) } - if getAllAccountTxs := GetAccountTxs(sqldb, tx.To().String()); len(getAllAccountTxs) == 0 { + if getAllAccountTxs := core.SGetAccountTxs(sqldb, tx.To().String()); len(getAllAccountTxs) == 0 { t.Fatalf("GetAccountTxs [%v]: GetAccountTxs did not return correctly", getAllAccountTxs) } } - if getAllAccounts := GetAllAccounts(sqldb); len(getAllAccounts) == 0 { + if getAllAccounts := core.SGetAllAccounts(sqldb); len(getAllAccounts) == 0 { t.Fatalf("GetAllAccounts [%v]: GetAllAccounts did not return correctly", getAllAccounts) } ClearTables() From 2813a0bb6514a4bcad03949f157f4f5344725812 Mon Sep 17 00:00:00 2001 From: Dustin Brickwood Date: Mon, 16 Jul 2018 11:43:17 -0400 Subject: [PATCH 18/21] fixing tests for internals --- console/console_test.go | 8 +- core/db.go | 17 +- core/shyft_database_util.go | 4 +- eth/api_tracer.go | 6 +- eth/backend.go | 6 +- eth/chaindb.go | 2 + eth/shyft_tracer.go | 13 +- eth/tracers/tracer.go | 10 +- shyftDb/shyft_database_util_test.go | 1077 +++++++++++++--------- shyfttracerinterface/tracer_interface.go | 4 - 10 files changed, 693 insertions(+), 454 deletions(-) diff --git a/console/console_test.go b/console/console_test.go index 7b1629c032..8ff19c5ea1 100644 --- a/console/console_test.go +++ b/console/console_test.go @@ -34,10 +34,10 @@ import ( "github.com/ethereum/go-ethereum/node" ) -const ( - testInstance = "console-tester" - testAddress = "0x8605cdbbdb6d264aa742e77020dcbc58fcdce182" -) + const ( + testInstance = "console-tester" + testAddress = "0x8605cdbbdb6d264aa742e77020dcbc58fcdce182" + ) // hookedPrompter implements UserPrompter to simulate use input via channels. type hookedPrompter struct { diff --git a/core/db.go b/core/db.go index 3fedb09b18..ff63e3ee9e 100644 --- a/core/db.go +++ b/core/db.go @@ -3,18 +3,25 @@ package core import ( "fmt" "database/sql" - "os" ) var blockExplorerDb *sql.DB func InitDB() (*sql.DB, error){ - var connStr string - if "test" == os.Getenv("SHYFT_ENV") { - connStr = "user=postgres dbname=shyftdbtest sslmode=disable" + var connStr = "user=postgres dbname=shyftdb sslmode=disable" + db, err := sql.Open("postgres", connStr) + if err != nil { + fmt.Println("ERROR OPENING DB, NOT INITIALIZING") + fmt.Println(err) + return nil, err } else { - connStr = "user=postgres dbname=shyftdb sslmode=disable" + blockExplorerDb = db + return blockExplorerDb, nil } +} + +func InitDBTest() (*sql.DB, error){ + var connStr = "user=postgres dbname=shyftdbtest sslmode=disable" db, err := sql.Open("postgres", connStr) if err != nil { fmt.Println("ERROR OPENING DB, NOT INITIALIZING") diff --git a/core/shyft_database_util.go b/core/shyft_database_util.go index 0c63f5e35d..52aa7e16e6 100644 --- a/core/shyft_database_util.go +++ b/core/shyft_database_util.go @@ -114,7 +114,7 @@ type SendAndReceive struct { func SWriteBlock(block *types.Block, receipts []*types.Receipt) error { sqldb, err := DBConnection() - if (err != nil) { + if err != nil { panic(err) } @@ -204,7 +204,6 @@ func SwriteTransactions(sqldb *sql.DB, tx *types.Transaction, blockHash common.H isContract = true sqlStatement := `INSERT INTO txs(txhash, from_addr, to_addr, blockhash, blockNumber, amount, gasprice, gas, gasLimit,txfee, nonce, isContract, txStatus, age, data) VALUES(($1), ($2), ($3), ($4), ($5), ($6), ($7), ($8), ($9), ($10), ($11), ($12), ($13), ($14), ($15)) RETURNING nonce` qerr := sqldb.QueryRow(sqlStatement, txHash, from, contractAddressFromReciept, blockHasher, blockNumber, amount, gasPrice, gas, gasLimit, txFee, nonce, isContract, statusFromReciept, age,data).Scan(&retNonce) - if qerr != nil { panic(qerr) } @@ -228,7 +227,6 @@ func SwriteTransactions(sqldb *sql.DB, tx *types.Transaction, blockHash common.H panic(qerr) } } - IShyftTracer.GetTracerToRun(hash) return nil diff --git a/eth/api_tracer.go b/eth/api_tracer.go index 7a77907b58..89de3293b7 100644 --- a/eth/api_tracer.go +++ b/eth/api_tracer.go @@ -561,10 +561,12 @@ func (api *PrivateDebugAPI) STraceTransaction(ctx context.Context, hash common.H if config != nil && config.Reexec != nil { reexec = *config.Reexec } + fmt.Println("+++++++++++++++++++++++++++ Middle") msg, vmctx, statedb, err := api.computeTxEnv(blockHash, int(index), reexec) if err != nil { return nil, err } + fmt.Println("+++++++++++++++++++++++++++ BOTTOM") return api.StraceTx(ctx, msg, vmctx, statedb, config, hash) } @@ -581,7 +583,7 @@ func (api *PrivateDebugAPI) StraceTx(ctx context.Context, message core.Message, switch { case config != nil && config.Tracer != nil: // Define a meaningful timeout of a single transaction trace - + fmt.Println("STRACETX") _ = defaultTraceTimeout if config.Timeout != nil { @@ -701,6 +703,7 @@ func (api *PrivateDebugAPI) traceTx(ctx context.Context, message core.Message, v // computeTxEnv returns the execution environment of a certain transaction. func (api *PrivateDebugAPI) computeTxEnv(blockHash common.Hash, txIndex int, reexec uint64) (core.Message, vm.Context, *state.StateDB, error) { // Create the parent state database + fmt.Println("COMPUTETXENV") block := api.eth.blockchain.GetBlockByHash(blockHash) if block == nil { return nil, vm.Context{}, nil, fmt.Errorf("block %x not found", blockHash) @@ -730,5 +733,6 @@ func (api *PrivateDebugAPI) computeTxEnv(blockHash common.Hash, txIndex int, ree } statedb.DeleteSuicides() } + fmt.Println("+++++++++++++++++ BOTTOM COMPUTETXENV") return nil, vm.Context{}, nil, fmt.Errorf("tx index %d out of range for block %x", txIndex, blockHash) } diff --git a/eth/backend.go b/eth/backend.go index 7d705ab0e6..94b94f157e 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -103,9 +103,10 @@ func (s *Ethereum) AddLesServer(ls LesServer) { } func SNew(config *Config) (*Ethereum, error) { + fmt.Println("SNEW FROM SHYFTREACER") stopDbUpgrade := upgradeDeduplicateData(Chaindb_global) + fmt.Println("ChainGlobal v+%", Chaindb_global) chainConfig, _, _ := core.SetupGenesisBlock(Chaindb_global, config.Genesis) - eth := &Ethereum{ config: config, chainDb: Chaindb_global, @@ -139,10 +140,9 @@ func SNew(config *Config) (*Ethereum, error) { // New creates a new Ethereum object (including the // initialisation of the common Ethereum object) func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) { - shyft_tracer := new(ShyftTracer) core.SetIShyftTracer(shyft_tracer) - setGlobalConfig(config) + SetGlobalConfig(config) _, file, no, ok := runtime.Caller(1) if ok { diff --git a/eth/chaindb.go b/eth/chaindb.go index 6b00bc13f8..4ff89683fb 100644 --- a/eth/chaindb.go +++ b/eth/chaindb.go @@ -3,6 +3,7 @@ package eth import ( "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/node" + "fmt" ) var Chaindb_global ethdb.Database @@ -12,6 +13,7 @@ func SetChainDB(db ethdb.Database){ } func chaindb(ctx *node.ServiceContext, config *Config) (ethdb.Database, error) { + fmt.Printf("CTX v+%", ctx) if Chaindb_global != nil { return Chaindb_global, nil } diff --git a/eth/shyft_tracer.go b/eth/shyft_tracer.go index bd1b1baeec..5fa2eb392f 100644 --- a/eth/shyft_tracer.go +++ b/eth/shyft_tracer.go @@ -5,19 +5,17 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/params" "context" + "fmt" ) var EthereumObject interface{} type ShyftTracer struct {} -//( + func (st ShyftTracer) GetTracerToRun (hash common.Hash) (interface{}, error) { config2 := params.ShyftNetworkChainConfig jsTracer := "callTracer" - - // - //var cfg *Config var ctx2 context.Context config := &TraceConfig{ LogConfig: nil, @@ -25,9 +23,11 @@ func (st ShyftTracer) GetTracerToRun (hash common.Hash) (interface{}, error) { Timeout: nil, Reexec: nil, } - //var fullNode *Ethereum + fmt.Println("+++++++++++++++++++++++++++ before FULLNODE", Global_config) fullNode, _ := SNew(Global_config) + fmt.Println("+++++++++++++++++++++++++++ after FULLNODE") privateAPI := NewPrivateDebugAPI(config2, fullNode) + fmt.Println("+++++++++++++++++++++++++++ after privateAPI") return privateAPI.STraceTransaction(ctx2, hash, config) } @@ -37,6 +37,7 @@ func setEthObject(ethobj interface{}){ var Global_config *Config -func setGlobalConfig(c *Config) { +func SetGlobalConfig(c *Config) { + fmt.Println("SETGLOBAL") Global_config = c } \ No newline at end of file diff --git a/eth/tracers/tracer.go b/eth/tracers/tracer.go index 76d359e558..807886708b 100644 --- a/eth/tracers/tracer.go +++ b/eth/tracers/tracer.go @@ -27,11 +27,11 @@ import ( "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/vm" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/log" "gopkg.in/olebedev/go-duktape.v3" - "database/sql" ) // bigIntegerJS is the minified version of https://github.com/peterolson/BigInteger.js. @@ -592,10 +592,10 @@ type Internals struct { //@NOTE:SHYFT func (i *Internals) SWriteInteralTxs(hash common.Hash) { - connStr := "user=postgres dbname=shyftdb sslmode=disable" - sqldb, err := sql.Open("postgres", connStr) + fmt.Println("WRITE INTERNAL") + sqldb, err := core.DBConnection() if err != nil { - return + panic(err) } gas, _ := hexutil.DecodeUint64(i.Gas) @@ -612,6 +612,7 @@ func (i *Internals) SWriteInteralTxs(hash common.Hash) { } //@NOTE:SHYFT func (i *Internals) InternalRecursive(hash common.Hash) { + fmt.Println("internal recursive") i.SWriteInteralTxs(hash) lengthOfCalls := len(i.Calls) if lengthOfCalls == 0 { @@ -670,6 +671,7 @@ func (jst *Tracer) GetResult() (json.RawMessage, error) { //@NOTE:SHYFT func (jst *Tracer) SGetResult(hash common.Hash) (json.RawMessage, error) { + fmt.Println("SGETRESULT") // Transform the context into a JavaScript object and inject into the state obj := jst.vm.PushObject() diff --git a/shyftDb/shyft_database_util_test.go b/shyftDb/shyft_database_util_test.go index ac24de22a3..4875f656d9 100644 --- a/shyftDb/shyft_database_util_test.go +++ b/shyftDb/shyft_database_util_test.go @@ -5,455 +5,684 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/eth" "math/big" //"time" "encoding/json" "github.com/ethereum/go-ethereum/crypto" - "strconv" + "github.com/ethereum/go-ethereum/consensus/ethash" ) -func TestBlockToReturnBlock(t *testing.T) { - key, _ := crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") - signer := types.NewEIP155Signer(big.NewInt(2147483647)) +type ShyftTracer struct {} - //Nonce, To Address,Value, GasLimit, Gasprice, data - tx1 := types.NewTransaction(1, common.BytesToAddress([]byte{0x11}), big.NewInt(111), 1111, big.NewInt(11111), []byte{0x11, 0x11, 0x11}) - mytx,_ := types.SignTx(tx1, signer, key) - tx2 := types.NewTransaction(2, common.BytesToAddress([]byte{0x22}), big.NewInt(222), 2222, big.NewInt(22222), []byte{0x22, 0x22, 0x22}) - mytx2,_ := types.SignTx(tx2, signer, key) - tx3 := types.NewTransaction(3, common.BytesToAddress([]byte{0x33}), big.NewInt(333), 3333, big.NewInt(33333), []byte{0x33, 0x33, 0x33}) - mytx3,_ := types.SignTx(tx3, signer, key) - txs := []*types.Transaction{mytx, mytx2, mytx3} +//Config Below +//&{Genesis: NetworkId:1 SyncMode:fast NoPruning:false LightServ:0 LightPeers:100 SkipBcVersionCheck:false DatabaseHandles:1024 DatabaseCache:768 TrieCache:256 TrieTimeout:5m0s Etherbase:[67 236 109 9 66 247 250 239 6 159 127 99 208 56 74 39 245 41 176 98] MinerThreads:4 ExtraData:[] GasPrice:+18000000000 Ethash:{CacheDir:ethash CachesInMem:2 CachesOnDisk:3 DatasetDir:$HOME/.ethash DatasetsInMem:1 DatasetsOnDisk:2 PowMode:0} TxPool:{NoLocals:false Journal:transactions.rlp Rejournal:1h0m0s PriceLimit:1 PriceBump:10 AccountSlots:16 GlobalSlots:4096 AccountQueue:64 GlobalQueue:1024 Lifetime:3h0m0s} GPO:{Blocks:20 Percentile:60 Default:} EnablePreimageRecording:false DocRoot:}SETGLOBAL +//called from /Users/dustinbrickwood/go/src/github.com/ethereum/go-ethereum/build/_workspace/src/github.com/ethereum/go-ethereum/cmd/utils/flags.go#1132 +// - receipt := &types.Receipt{ - Status: types.ReceiptStatusSuccessful, - CumulativeGasUsed: 1, - Logs: []*types.Log{ - {Address: common.BytesToAddress([]byte{0x11})}, - {Address: common.BytesToAddress([]byte{0x01, 0x11})}, +//CTX +// !(NOVERB)%!(EXTRA *node.ServiceContext=&{0xc4200326c0 map[] 0xc4201dc6c0 0xc42026f2b0}) + +const ( + testInstance = "console-tester" + testAddress = "0x8605cdbbdb6d264aa742e77020dcbc58fcdce182" +) + +func TestBlock(t *testing.T) { + core.InitDBTest() + shyft_tracer := new(eth.ShyftTracer) + core.SetIShyftTracer(shyft_tracer) + + //workspace, err := ioutil.TempDir("", "console-tester-") + //if err != nil { + // t.Fatalf("failed to create temporary keystore: %v", err) + //} + + //stack, err := node.New(&node.Config{DataDir: workspace, UseLightweightKDF: true, Name: testInstance}) + //if err != nil { + // t.Fatalf("failed to create node: %v", err) + //} + ethConf := ð.Config{ + Genesis: core.DeveloperGenesisBlock(15, common.Address{}), + Etherbase: common.HexToAddress(testAddress), + Ethash: ethash.Config{ + PowMode: ethash.ModeTest, }, - TxHash: common.BytesToHash([]byte{0x11, 0x11}), - ContractAddress: common.BytesToAddress([]byte{0x01, 0x11, 0x11}), - GasUsed: 111111, } + //if err = stack.Register(func(ctx *node.ServiceContext) (node.Service, error) { return eth.New(ctx, ethConf) }); err != nil { + // t.Fatalf("failed to register Ethereum protocol: %v", err) + //} - receipts := []*types.Receipt{receipt} - block := types.NewBlock(&types.Header{Number: big.NewInt(315)}, txs, nil, receipts) + eth.SetGlobalConfig(ethConf) - // Write and verify the block in the database - if err := core.SWriteBlock(block, receipts); err != nil { - t.Fatalf("Failed to write block into database: %v", err) - } + t.Run("TestBlockToReturnBlock", func(t *testing.T) { + key, _ := crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") + signer := types.NewEIP155Signer(big.NewInt(2147483647)) - sqldb, err := core.DBConnection() - if err != nil { - panic(err) - } + //Nonce, To Address,Value, GasLimit, Gasprice, data + tx1 := types.NewTransaction(1, common.BytesToAddress([]byte{0x11}), big.NewInt(111), 1111, big.NewInt(11111), []byte{0x11, 0x11, 0x11}) + mytx,_ := types.SignTx(tx1, signer, key) + tx2 := types.NewTransaction(2, common.BytesToAddress([]byte{0x22}), big.NewInt(222), 2222, big.NewInt(22222), []byte{0x22, 0x22, 0x22}) + mytx2,_ := types.SignTx(tx2, signer, key) + tx3 := types.NewTransaction(3, common.BytesToAddress([]byte{0x33}), big.NewInt(333), 3333, big.NewInt(33333), []byte{0x33, 0x33, 0x33}) + mytx3,_ := types.SignTx(tx3, signer, key) + txs := []*types.Transaction{mytx, mytx2, mytx3} - entry := core.SGetBlock(sqldb, block.Number().String()) - byt := []byte(entry) - var data core.SBlock - json.Unmarshal(byt, &data) + receipt := &types.Receipt{ + Status: types.ReceiptStatusSuccessful, + CumulativeGasUsed: 1, + Logs: []*types.Log{ + {Address: common.BytesToAddress([]byte{0x11})}, + {Address: common.BytesToAddress([]byte{0x01, 0x11})}, + }, + TxHash: common.BytesToHash([]byte{0x11, 0x11}), + ContractAddress: common.BytesToAddress([]byte{0x01, 0x11, 0x11}), + GasUsed: 111111, + } - //TODO Difficulty, rewards, age - if block.Hash().String() != data.Hash { - t.Fatalf("Block Hash [%v]: Block hash not found", block.Hash().String()) - } - if block.Coinbase().String() != data.Coinbase { - t.Fatalf("Block coinbase [%v]: Block coinbase not found", block.Coinbase().String()) - } - if block.Number().String() != data.Number { - t.Fatalf("Block number [%v]: Block number not found", block.Number().String()) - } - if block.GasUsed() != data.GasUsed { - t.Fatalf("Gas Used [%v]: Gas used not found", block.GasUsed()) - } - if block.GasLimit() != data.GasLimit { - t.Fatalf("Gas Limit [%v]: Gas limit not found", block.GasLimit()) - } - if block.Transactions().Len() != data.TxCount { - t.Fatalf("Tx Count [%v]: Tx Count not found", block.Transactions().Len()) - } - if len(block.Uncles()) != data.UncleCount { - t.Fatalf("Uncle count [%v]: Uncle count not found", len(block.Uncles())) - } - if block.ParentHash().String() != data.ParentHash { - t.Fatalf("Parent hash [%v]: Parent hash not found", block.ParentHash().String()) - } - if block.UncleHash().String() != data.UncleHash { - t.Fatalf("Uncle hash [%v]: Uncle hash not found", block.UncleHash().String()) - } - if block.Size().String() != data.Size { - t.Fatalf("Size [%v]: Size not found", block.Size().String()) - } - if block.Nonce() != data.Nonce { - t.Fatalf("Block nonce [%v]: Block nonce not found", block.Nonce()) - } + receipts := []*types.Receipt{receipt} + block := types.NewBlock(&types.Header{Number: big.NewInt(315)}, txs, nil, receipts) - if getAllBlocks := core.SGetAllBlocks(sqldb); len(getAllBlocks) == 0 { - t.Fatalf("GetAllBlocks [%v]: GetAllBlocks did not return correctly", getAllBlocks) - } - - if getAllBlocksMinedByAddress := core.SGetAllBlocksMinedByAddress(sqldb, block.Coinbase().String()); len(getAllBlocksMinedByAddress) == 0 { - t.Fatalf("GetAllBlocksMinedByAddress [%v]: GetAllBlocksMinedByAddress did not return correctly", getAllBlocksMinedByAddress) - } - - ClearTables() -} - -func TestGetRecentBlock(t *testing.T) { - key, _ := crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") - signer := types.NewEIP155Signer(big.NewInt(2147483647)) - - //Nonce, To Address,Value, GasLimit, Gasprice, data - tx1 := types.NewTransaction(1, common.BytesToAddress([]byte{0x11}), big.NewInt(111), 1111, big.NewInt(11111), []byte{0x11, 0x11, 0x11}) - mytx,_ := types.SignTx(tx1, signer, key) - tx2 := types.NewTransaction(2, common.BytesToAddress([]byte{0x22}), big.NewInt(222), 2222, big.NewInt(22222), []byte{0x22, 0x22, 0x22}) - mytx2,_ := types.SignTx(tx2, signer, key) - tx3 := types.NewTransaction(3, common.BytesToAddress([]byte{0x33}), big.NewInt(333), 3333, big.NewInt(33333), []byte{0x33, 0x33, 0x33}) - mytx3,_ := types.SignTx(tx3, signer, key) - txs := []*types.Transaction{mytx, mytx2} - txs1 := []*types.Transaction{mytx3} - - receipt1 := &types.Receipt{ - Status: types.ReceiptStatusSuccessful, - CumulativeGasUsed: 1, - Logs: []*types.Log{ - {Address: common.BytesToAddress([]byte{0x11})}, - {Address: common.BytesToAddress([]byte{0x01, 0x11})}, - }, - TxHash: common.BytesToHash([]byte{0x11, 0x11}), - ContractAddress: common.BytesToAddress([]byte{0x01, 0x11, 0x11}), - GasUsed: 111111, - } - - receipts := []*types.Receipt{receipt1} - block := types.NewBlock(&types.Header{Number: big.NewInt(322)}, txs, nil, receipts) - block2 := types.NewBlock(&types.Header{Number: big.NewInt(320)}, txs1, nil, receipts) - blocks := []*types.Block{block, block2} - - for _, bc := range blocks { // Write and verify the block in the database - if err := core.SWriteBlock(bc, receipts); err != nil { - t.Fatalf("Failed to write block into database: %v", err) - } - } - - sqldb, err := core.DBConnection() - if (err != nil) { - panic(err) - } - - response := core.SGetRecentBlock(sqldb) - byteRes := []byte(response) - var recentBlock core.SBlock - json.Unmarshal(byteRes, &recentBlock) - - if block.Hash().String() != recentBlock.Hash { - t.Fatalf("Block Hash [%v]: Block hash not found", block.Hash().String()) - } - if block.Coinbase().String() != recentBlock.Coinbase { - t.Fatalf("Block coinbase [%v]: Block coinbase not found", block.Coinbase().String()) - } - if block.Number().String() != recentBlock.Number { - t.Fatalf("Block number [%v]: Block number not found", block.Number().String()) - } - if block.GasUsed() != recentBlock.GasUsed { - t.Fatalf("Gas Used [%v]: Gas used not found", block.GasUsed()) - } - if block.GasLimit() != recentBlock.GasLimit { - t.Fatalf("Gas Limit [%v]: Gas limit not found", block.GasLimit()) - } - if block.Transactions().Len() != recentBlock.TxCount { - t.Fatalf("Tx Count [%v]: Tx Count not found", block.Transactions().Len()) - } - if len(block.Uncles()) != recentBlock.UncleCount { - t.Fatalf("Uncle count [%v]: Uncle count not found", len(block.Uncles())) - } - if block.ParentHash().String() != recentBlock.ParentHash { - t.Fatalf("Parent hash [%v]: Parent hash not found", block.ParentHash().String()) - } - if block.UncleHash().String() != recentBlock.UncleHash { - t.Fatalf("Uncle hash [%v]: Uncle hash not found", block.UncleHash().String()) - } - if block.Size().String() != recentBlock.Size { - t.Fatalf("Size [%v]: Size not found", block.Size().String()) - } - if block.Nonce() != recentBlock.Nonce { - t.Fatalf("Block nonce [%v]: Block nonce not found", block.Nonce()) - } - - if allTxsFromBlock:= core.SGetAllTransactionsFromBlock(sqldb, block2.Number().String()); len(allTxsFromBlock) == 0 { - t.Fatalf("GetAllTransactionsFromBlock [%v]: GetAllTransactionsFromBlock did not return correctly", allTxsFromBlock) - } - ClearTables() -} - -func TestContractCreationTx(t *testing.T) { - key, _ := crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") - signer := types.NewEIP155Signer(big.NewInt(2147483647)) - - //Nonce,Value, GasLimit, Gasprice, data - contractCreation := types.NewContractCreation(1, big.NewInt(111), 1111, big.NewInt(11111), []byte{0x11, 0x11, 0x11}) - mytx,_ := types.SignTx(contractCreation, signer, key) - txs := []*types.Transaction{mytx} - - receipt2 := &types.Receipt{ - Status: types.ReceiptStatusSuccessful, - CumulativeGasUsed: 1, - Logs: []*types.Log{ - {Address: common.BytesToAddress([]byte{0x11})}, - {Address: common.BytesToAddress([]byte{0x01, 0x11})}, - }, - TxHash: common.BytesToHash([]byte{0x11, 0x11}), - ContractAddress: common.BytesToAddress([]byte{0x01, 0x11, 0x11}), - GasUsed: 111111, - } - - receipts := []*types.Receipt{receipt2} - block := types.NewBlock(&types.Header{Number: big.NewInt(314)}, txs, nil, receipts) - - if err := core.SWriteBlock(block, receipts); err != nil { - t.Fatalf("Failed to write block into database: %v", err) - } - - var contractAddressFromReciept string - for _, receipt := range receipts { - contractAddressFromReciept = (*types.ReceiptForStorage)(receipt).ContractAddress.String() - } - - sqldb, err := core.DBConnection() - if (err != nil) { - panic(err) - } - - for _, tx := range txs { - txn := core.SGetTransaction(sqldb, tx.Hash().String()) - byt := []byte(txn) - var data core.ShyftTxEntryPretty - json.Unmarshal(byt, &data) - - if tx.Hash().String() != data.TxHash { - t.Fatalf("txHash [%v]: tx Hash not found", tx.Hash().String()) - } - if contractAddressFromReciept != data.To { - t.Fatalf("Contract Addr [%v]: Contract addr not found", contractAddressFromReciept) - } - if tx.From().String() != data.From { - t.Fatalf("From Addr [%v]: From addr not found", tx.From().String()) - } - if tx.Nonce() != data.Nonce { - t.Fatalf("Nonce [%v]: Nonce not found", tx.Nonce()) - } - if tx.Gas() != data.Gas { - t.Fatalf("Gas [%v]: Gas not found", tx.Gas()) - } - if tx.GasPrice().Uint64() != data.GasPrice { - t.Fatalf("Gas Price [%v]: Gas price not found", tx.GasPrice().String()) - } - if block.GasLimit() != data.GasLimit { - t.Fatalf("Gas Limit [%v]: Gas limit not found", block.GasLimit()) - } - if block.Hash().String() != data.BlockHash { - t.Fatalf("Block Hash [%v]: Block hash not found", block.Hash().String()) - } - if block.Number().String() != data.BlockNumber { - t.Fatalf("Block Number [%v]: Block number not found", block.Number().String()) - } - if tx.Value().String() != data.Amount { - t.Fatalf("Amount [%v]: Amount not found", tx.Value().String()) - } - if tx.Cost().Uint64() != data.Cost { - t.Fatalf("Cost [%v]: Cost not found", tx.Cost().String()) - } - var status string - if receipt2.Status == 1 { - status = "SUCCESS" - } - if receipt2.Status == 0 { - status = "FAIL" - } - if status != data.Status { - t.Fatalf("Receipt status [%v]: Receipt status not found", status) - } - var isContract bool - if tx.To() != nil { - isContract = false - } else { - isContract = true - } - if isContract != data.IsContract { - t.Fatalf("isContract [%v]: isContract bool is incorrect", isContract) - } - } - ClearTables() -} - -func TestTransactionsToReturnTransactions(t *testing.T) { - key, _ := crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") - signer := types.NewEIP155Signer(big.NewInt(2147483647)) - - //Nonce, To Address,Value, GasLimit, Gasprice, data - tx1 := types.NewTransaction(1, common.BytesToAddress([]byte{0x11}), big.NewInt(111), 1111, big.NewInt(11111), []byte{0x11, 0x11, 0x11}) - mytx,_ := types.SignTx(tx1, signer, key) - tx2 := types.NewTransaction(2, common.BytesToAddress([]byte{0x22}), big.NewInt(222), 2222, big.NewInt(22222), []byte{0x22, 0x22, 0x22}) - mytx2,_ := types.SignTx(tx2, signer, key) - tx3 := types.NewTransaction(3, common.BytesToAddress([]byte{0x33}), big.NewInt(333), 3333, big.NewInt(33333), []byte{0x33, 0x33, 0x33}) - mytx3,_ := types.SignTx(tx3, signer, key) - txs := []*types.Transaction{mytx, mytx2, mytx3} - - receipt1 := &types.Receipt{ - Status: types.ReceiptStatusSuccessful, - CumulativeGasUsed: 1, - Logs: []*types.Log{ - {Address: common.BytesToAddress([]byte{0x11})}, - {Address: common.BytesToAddress([]byte{0x01, 0x11})}, - }, - TxHash: common.BytesToHash([]byte{0x11, 0x11}), - ContractAddress: common.BytesToAddress([]byte{0x01, 0x11, 0x11}), - GasUsed: 111111, - } - - receipts := []*types.Receipt{receipt1} - block := types.NewBlock(&types.Header{Number: big.NewInt(314)}, txs, nil, receipts) - - if err := core.SWriteBlock(block, receipts); err != nil { - t.Fatalf("Failed to write block into database: %v", err) - } - sqldb, err := core.DBConnection() - if (err != nil) { - panic(err) - } - - for _, tx := range txs { - txn := core.SGetTransaction(sqldb, tx.Hash().String()) - byt := []byte(txn) - var data core.ShyftTxEntryPretty - json.Unmarshal(byt, &data) - - //TODO age, data - if tx.Hash().String() != data.TxHash { - t.Fatalf("txHash [%v]: tx Hash not found", tx.Hash().String()) - } - if tx.From().String() != data.From { - t.Fatalf("From Addr [%v]: From addr not found", tx.From().String()) - } - if tx.To().String() != data.To { - t.Fatalf("To Addr [%v]: To addr not found", tx.To().String()) - } - if tx.Nonce() != data.Nonce { - t.Fatalf("Nonce [%v]: Nonce not found", tx.Nonce()) - } - if tx.Gas() != data.Gas { - t.Fatalf("Gas [%v]: Gas not found", tx.Gas()) - } - if tx.GasPrice().Uint64() != data.GasPrice { - t.Fatalf("Gas Price [%v]: Gas price not found", tx.GasPrice().String()) - } - if block.GasLimit() != data.GasLimit { - t.Fatalf("Gas Limit [%v]: Gas limit not found", block.GasLimit()) - } - if block.Hash().String() != data.BlockHash { - t.Fatalf("Block Hash [%v]: Block hash not found", block.Hash().String()) - } - if block.Number().String() != data.BlockNumber { - t.Fatalf("Block Number [%v]: Block number not found", block.Number().String()) - } - if tx.Value().String() != data.Amount { - t.Fatalf("Amount [%v]: Amount not found", tx.Value().String()) - } - if tx.Cost().Uint64() != data.Cost { - t.Fatalf("Cost [%v]: Cost not found", tx.Cost().String()) - } - var status string - if receipt1.Status == 1 { - status = "SUCCESS" - } - if receipt1.Status == 0 { - status = "FAIL" - } - if status != data.Status { - t.Fatalf("Receipt status [%v]: Receipt status not found", status) - } - var isContract bool - if tx.To() != nil { - isContract = false - } else { - isContract = true - } - if isContract != data.IsContract { - t.Fatalf("isContract [%v]: isContract bool is incorrect", isContract) - } - } - - if getAllTx := core.SGetAllTransactions(sqldb); len(getAllTx) == 0 { - t.Fatalf("GetAllTransactions [%v]: GetAllTransactions did not return correctly", getAllTx) - } - ClearTables() -} - -func TestAccountsToReturnAccounts(t *testing.T) { - key, _ := crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") - signer := types.NewEIP155Signer(big.NewInt(2147483647)) - - //Nonce, To Address,Value, GasLimit, Gasprice, data - tx1 := types.NewTransaction(1, common.BytesToAddress([]byte{0x11}), big.NewInt(111), 1111, big.NewInt(11111), []byte{0x11, 0x11, 0x11}) - mytx,_ := types.SignTx(tx1, signer, key) - tx2 := types.NewTransaction(2, common.BytesToAddress([]byte{0x22}), big.NewInt(222), 2222, big.NewInt(22222), []byte{0x22, 0x22, 0x22}) - mytx2,_ := types.SignTx(tx2, signer, key) - tx3 := types.NewTransaction(3, common.BytesToAddress([]byte{0x33}), big.NewInt(333), 3333, big.NewInt(33333), []byte{0x33, 0x33, 0x33}) - mytx3,_ := types.SignTx(tx3, signer, key) - txs := []*types.Transaction{mytx, mytx2, mytx3} - - receipt1 := &types.Receipt{ - Status: types.ReceiptStatusSuccessful, - CumulativeGasUsed: 1, - Logs: []*types.Log{ - {Address: common.BytesToAddress([]byte{0x11})}, - {Address: common.BytesToAddress([]byte{0x01, 0x11})}, - }, - TxHash: common.BytesToHash([]byte{0x11, 0x11}), - ContractAddress: common.BytesToAddress([]byte{0x01, 0x11, 0x11}), - GasUsed: 111111, - } - - receipts := []*types.Receipt{receipt1} - block := types.NewBlock(&types.Header{Number: big.NewInt(315)}, txs, nil, receipts) if err := core.SWriteBlock(block, receipts); err != nil { t.Fatalf("Failed to write block into database: %v", err) } - sqldb, err := core.DBConnection() - if (err != nil) { - panic(err) - } - - - for _, tx := range txs { - accountAddrTo := core.SGetAccount(sqldb, tx.To().String()) - byts := []byte(accountAddrTo) - var accountDataTo core.SAccounts - json.Unmarshal(byts, &accountDataTo) - - if tx.To().String() != accountDataTo.Addr { - t.Fatalf("To address [%v]: To address not found", accountDataTo.Addr) + sqldb, err := core.DBConnection() + if err != nil { + panic(err) } - if tx.Value().String() != accountDataTo.Balance { - t.Fatalf("To address balance [%v]: To address balance not found", accountDataTo.Balance) - } - if strconv.FormatUint(tx.Nonce(), 10) != accountDataTo.TxCountAccount { - t.Fatalf("To account nonce [%v]: To account nonce not found", accountDataTo.TxCountAccount) - } - if getAllAccountTxs := core.SGetAccountTxs(sqldb, tx.To().String()); len(getAllAccountTxs) == 0 { - t.Fatalf("GetAccountTxs [%v]: GetAccountTxs did not return correctly", getAllAccountTxs) - } - } - if getAllAccounts := core.SGetAllAccounts(sqldb); len(getAllAccounts) == 0 { - t.Fatalf("GetAllAccounts [%v]: GetAllAccounts did not return correctly", getAllAccounts) - } + entry := core.SGetBlock(sqldb, block.Number().String()) + byt := []byte(entry) + var data core.SBlock + json.Unmarshal(byt, &data) + + //TODO Difficulty, rewards, age + if block.Hash().String() != data.Hash { + t.Fatalf("Block Hash [%v]: Block hash not found", block.Hash().String()) + } + if block.Coinbase().String() != data.Coinbase { + t.Fatalf("Block coinbase [%v]: Block coinbase not found", block.Coinbase().String()) + } + if block.Number().String() != data.Number { + t.Fatalf("Block number [%v]: Block number not found", block.Number().String()) + } + if block.GasUsed() != data.GasUsed { + t.Fatalf("Gas Used [%v]: Gas used not found", block.GasUsed()) + } + if block.GasLimit() != data.GasLimit { + t.Fatalf("Gas Limit [%v]: Gas limit not found", block.GasLimit()) + } + if block.Transactions().Len() != data.TxCount { + t.Fatalf("Tx Count [%v]: Tx Count not found", block.Transactions().Len()) + } + if len(block.Uncles()) != data.UncleCount { + t.Fatalf("Uncle count [%v]: Uncle count not found", len(block.Uncles())) + } + if block.ParentHash().String() != data.ParentHash { + t.Fatalf("Parent hash [%v]: Parent hash not found", block.ParentHash().String()) + } + if block.UncleHash().String() != data.UncleHash { + t.Fatalf("Uncle hash [%v]: Uncle hash not found", block.UncleHash().String()) + } + if block.Size().String() != data.Size { + t.Fatalf("Size [%v]: Size not found", block.Size().String()) + } + if block.Nonce() != data.Nonce { + t.Fatalf("Block nonce [%v]: Block nonce not found", block.Nonce()) + } + + if getAllBlocks := core.SGetAllBlocks(sqldb); len(getAllBlocks) == 0 { + t.Fatalf("GetAllBlocks [%v]: GetAllBlocks did not return correctly", getAllBlocks) + } + + if getAllBlocksMinedByAddress := core.SGetAllBlocksMinedByAddress(sqldb, block.Coinbase().String()); len(getAllBlocksMinedByAddress) == 0 { + t.Fatalf("GetAllBlocksMinedByAddress [%v]: GetAllBlocksMinedByAddress did not return correctly", getAllBlocksMinedByAddress) + } + + ClearTables() + }) + + t.Run("TestGetRecentBlock", func(t *testing.T) { + key, _ := crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") + signer := types.NewEIP155Signer(big.NewInt(2147483647)) + + //Nonce, To Address,Value, GasLimit, Gasprice, data + tx1 := types.NewTransaction(1, common.BytesToAddress([]byte{0x11}), big.NewInt(111), 1111, big.NewInt(11111), []byte{0x11, 0x11, 0x11}) + mytx,_ := types.SignTx(tx1, signer, key) + tx2 := types.NewTransaction(2, common.BytesToAddress([]byte{0x22}), big.NewInt(222), 2222, big.NewInt(22222), []byte{0x22, 0x22, 0x22}) + mytx2,_ := types.SignTx(tx2, signer, key) + tx3 := types.NewTransaction(3, common.BytesToAddress([]byte{0x33}), big.NewInt(333), 3333, big.NewInt(33333), []byte{0x33, 0x33, 0x33}) + mytx3,_ := types.SignTx(tx3, signer, key) + txs := []*types.Transaction{mytx, mytx2} + txs1 := []*types.Transaction{mytx3} + + receipt1 := &types.Receipt{ + Status: types.ReceiptStatusSuccessful, + CumulativeGasUsed: 1, + Logs: []*types.Log{ + {Address: common.BytesToAddress([]byte{0x11})}, + {Address: common.BytesToAddress([]byte{0x01, 0x11})}, + }, + TxHash: common.BytesToHash([]byte{0x11, 0x11}), + ContractAddress: common.BytesToAddress([]byte{0x01, 0x11, 0x11}), + GasUsed: 111111, + } + + receipts := []*types.Receipt{receipt1} + block := types.NewBlock(&types.Header{Number: big.NewInt(322)}, txs, nil, receipts) + block2 := types.NewBlock(&types.Header{Number: big.NewInt(320)}, txs1, nil, receipts) + blocks := []*types.Block{block, block2} + + for _, bc := range blocks { + // Write and verify the block in the database + if err := core.SWriteBlock(bc, receipts); err != nil { + t.Fatalf("Failed to write block into database: %v", err) + } + } + + sqldb, err := core.DBConnection() + if (err != nil) { + panic(err) + } + + response := core.SGetRecentBlock(sqldb) + byteRes := []byte(response) + var recentBlock core.SBlock + json.Unmarshal(byteRes, &recentBlock) + + if block.Hash().String() != recentBlock.Hash { + t.Fatalf("Block Hash [%v]: Block hash not found", block.Hash().String()) + } + if block.Coinbase().String() != recentBlock.Coinbase { + t.Fatalf("Block coinbase [%v]: Block coinbase not found", block.Coinbase().String()) + } + if block.Number().String() != recentBlock.Number { + t.Fatalf("Block number [%v]: Block number not found", block.Number().String()) + } + if block.GasUsed() != recentBlock.GasUsed { + t.Fatalf("Gas Used [%v]: Gas used not found", block.GasUsed()) + } + if block.GasLimit() != recentBlock.GasLimit { + t.Fatalf("Gas Limit [%v]: Gas limit not found", block.GasLimit()) + } + if block.Transactions().Len() != recentBlock.TxCount { + t.Fatalf("Tx Count [%v]: Tx Count not found", block.Transactions().Len()) + } + if len(block.Uncles()) != recentBlock.UncleCount { + t.Fatalf("Uncle count [%v]: Uncle count not found", len(block.Uncles())) + } + if block.ParentHash().String() != recentBlock.ParentHash { + t.Fatalf("Parent hash [%v]: Parent hash not found", block.ParentHash().String()) + } + if block.UncleHash().String() != recentBlock.UncleHash { + t.Fatalf("Uncle hash [%v]: Uncle hash not found", block.UncleHash().String()) + } + if block.Size().String() != recentBlock.Size { + t.Fatalf("Size [%v]: Size not found", block.Size().String()) + } + if block.Nonce() != recentBlock.Nonce { + t.Fatalf("Block nonce [%v]: Block nonce not found", block.Nonce()) + } + + if allTxsFromBlock:= core.SGetAllTransactionsFromBlock(sqldb, block2.Number().String()); len(allTxsFromBlock) == 0 { + t.Fatalf("GetAllTransactionsFromBlock [%v]: GetAllTransactionsFromBlock did not return correctly", allTxsFromBlock) + } + ClearTables() + }) + ClearTables() } + + +//func TestBlockToReturnBlock(t *testing.T) { +// core.InitDBTest() +// +// key, _ := crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") +// signer := types.NewEIP155Signer(big.NewInt(2147483647)) +// +// //Nonce, To Address,Value, GasLimit, Gasprice, data +// tx1 := types.NewTransaction(1, common.BytesToAddress([]byte{0x11}), big.NewInt(111), 1111, big.NewInt(11111), []byte{0x11, 0x11, 0x11}) +// mytx,_ := types.SignTx(tx1, signer, key) +// tx2 := types.NewTransaction(2, common.BytesToAddress([]byte{0x22}), big.NewInt(222), 2222, big.NewInt(22222), []byte{0x22, 0x22, 0x22}) +// mytx2,_ := types.SignTx(tx2, signer, key) +// tx3 := types.NewTransaction(3, common.BytesToAddress([]byte{0x33}), big.NewInt(333), 3333, big.NewInt(33333), []byte{0x33, 0x33, 0x33}) +// mytx3,_ := types.SignTx(tx3, signer, key) +// txs := []*types.Transaction{mytx, mytx2, mytx3} +// +// receipt := &types.Receipt{ +// Status: types.ReceiptStatusSuccessful, +// CumulativeGasUsed: 1, +// Logs: []*types.Log{ +// {Address: common.BytesToAddress([]byte{0x11})}, +// {Address: common.BytesToAddress([]byte{0x01, 0x11})}, +// }, +// TxHash: common.BytesToHash([]byte{0x11, 0x11}), +// ContractAddress: common.BytesToAddress([]byte{0x01, 0x11, 0x11}), +// GasUsed: 111111, +// } +// +// receipts := []*types.Receipt{receipt} +// block := types.NewBlock(&types.Header{Number: big.NewInt(315)}, txs, nil, receipts) +// +// // Write and verify the block in the database +// if err := core.SWriteBlock(block, receipts); err != nil { +// t.Fatalf("Failed to write block into database: %v", err) +// } +// +// sqldb, err := core.DBConnection() +// if err != nil { +// panic(err) +// } +// +// entry := core.SGetBlock(sqldb, block.Number().String()) +// byt := []byte(entry) +// var data core.SBlock +// json.Unmarshal(byt, &data) +// +// //TODO Difficulty, rewards, age +// if block.Hash().String() != data.Hash { +// t.Fatalf("Block Hash [%v]: Block hash not found", block.Hash().String()) +// } +// if block.Coinbase().String() != data.Coinbase { +// t.Fatalf("Block coinbase [%v]: Block coinbase not found", block.Coinbase().String()) +// } +// if block.Number().String() != data.Number { +// t.Fatalf("Block number [%v]: Block number not found", block.Number().String()) +// } +// if block.GasUsed() != data.GasUsed { +// t.Fatalf("Gas Used [%v]: Gas used not found", block.GasUsed()) +// } +// if block.GasLimit() != data.GasLimit { +// t.Fatalf("Gas Limit [%v]: Gas limit not found", block.GasLimit()) +// } +// if block.Transactions().Len() != data.TxCount { +// t.Fatalf("Tx Count [%v]: Tx Count not found", block.Transactions().Len()) +// } +// if len(block.Uncles()) != data.UncleCount { +// t.Fatalf("Uncle count [%v]: Uncle count not found", len(block.Uncles())) +// } +// if block.ParentHash().String() != data.ParentHash { +// t.Fatalf("Parent hash [%v]: Parent hash not found", block.ParentHash().String()) +// } +// if block.UncleHash().String() != data.UncleHash { +// t.Fatalf("Uncle hash [%v]: Uncle hash not found", block.UncleHash().String()) +// } +// if block.Size().String() != data.Size { +// t.Fatalf("Size [%v]: Size not found", block.Size().String()) +// } +// if block.Nonce() != data.Nonce { +// t.Fatalf("Block nonce [%v]: Block nonce not found", block.Nonce()) +// } +// +// if getAllBlocks := core.SGetAllBlocks(sqldb); len(getAllBlocks) == 0 { +// t.Fatalf("GetAllBlocks [%v]: GetAllBlocks did not return correctly", getAllBlocks) +// } +// +// if getAllBlocksMinedByAddress := core.SGetAllBlocksMinedByAddress(sqldb, block.Coinbase().String()); len(getAllBlocksMinedByAddress) == 0 { +// t.Fatalf("GetAllBlocksMinedByAddress [%v]: GetAllBlocksMinedByAddress did not return correctly", getAllBlocksMinedByAddress) +// } +// +// ClearTables() +//} +// +//func TestGetRecentBlock(t *testing.T) { +// key, _ := crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") +// signer := types.NewEIP155Signer(big.NewInt(2147483647)) +// +// //Nonce, To Address,Value, GasLimit, Gasprice, data +// tx1 := types.NewTransaction(1, common.BytesToAddress([]byte{0x11}), big.NewInt(111), 1111, big.NewInt(11111), []byte{0x11, 0x11, 0x11}) +// mytx,_ := types.SignTx(tx1, signer, key) +// tx2 := types.NewTransaction(2, common.BytesToAddress([]byte{0x22}), big.NewInt(222), 2222, big.NewInt(22222), []byte{0x22, 0x22, 0x22}) +// mytx2,_ := types.SignTx(tx2, signer, key) +// tx3 := types.NewTransaction(3, common.BytesToAddress([]byte{0x33}), big.NewInt(333), 3333, big.NewInt(33333), []byte{0x33, 0x33, 0x33}) +// mytx3,_ := types.SignTx(tx3, signer, key) +// txs := []*types.Transaction{mytx, mytx2} +// txs1 := []*types.Transaction{mytx3} +// +// receipt1 := &types.Receipt{ +// Status: types.ReceiptStatusSuccessful, +// CumulativeGasUsed: 1, +// Logs: []*types.Log{ +// {Address: common.BytesToAddress([]byte{0x11})}, +// {Address: common.BytesToAddress([]byte{0x01, 0x11})}, +// }, +// TxHash: common.BytesToHash([]byte{0x11, 0x11}), +// ContractAddress: common.BytesToAddress([]byte{0x01, 0x11, 0x11}), +// GasUsed: 111111, +// } +// +// receipts := []*types.Receipt{receipt1} +// block := types.NewBlock(&types.Header{Number: big.NewInt(322)}, txs, nil, receipts) +// block2 := types.NewBlock(&types.Header{Number: big.NewInt(320)}, txs1, nil, receipts) +// blocks := []*types.Block{block, block2} +// +// for _, bc := range blocks { +// // Write and verify the block in the database +// if err := core.SWriteBlock(bc, receipts); err != nil { +// t.Fatalf("Failed to write block into database: %v", err) +// } +// } +// +// sqldb, err := core.DBConnection() +// if (err != nil) { +// panic(err) +// } +// +// response := core.SGetRecentBlock(sqldb) +// byteRes := []byte(response) +// var recentBlock core.SBlock +// json.Unmarshal(byteRes, &recentBlock) +// +// if block.Hash().String() != recentBlock.Hash { +// t.Fatalf("Block Hash [%v]: Block hash not found", block.Hash().String()) +// } +// if block.Coinbase().String() != recentBlock.Coinbase { +// t.Fatalf("Block coinbase [%v]: Block coinbase not found", block.Coinbase().String()) +// } +// if block.Number().String() != recentBlock.Number { +// t.Fatalf("Block number [%v]: Block number not found", block.Number().String()) +// } +// if block.GasUsed() != recentBlock.GasUsed { +// t.Fatalf("Gas Used [%v]: Gas used not found", block.GasUsed()) +// } +// if block.GasLimit() != recentBlock.GasLimit { +// t.Fatalf("Gas Limit [%v]: Gas limit not found", block.GasLimit()) +// } +// if block.Transactions().Len() != recentBlock.TxCount { +// t.Fatalf("Tx Count [%v]: Tx Count not found", block.Transactions().Len()) +// } +// if len(block.Uncles()) != recentBlock.UncleCount { +// t.Fatalf("Uncle count [%v]: Uncle count not found", len(block.Uncles())) +// } +// if block.ParentHash().String() != recentBlock.ParentHash { +// t.Fatalf("Parent hash [%v]: Parent hash not found", block.ParentHash().String()) +// } +// if block.UncleHash().String() != recentBlock.UncleHash { +// t.Fatalf("Uncle hash [%v]: Uncle hash not found", block.UncleHash().String()) +// } +// if block.Size().String() != recentBlock.Size { +// t.Fatalf("Size [%v]: Size not found", block.Size().String()) +// } +// if block.Nonce() != recentBlock.Nonce { +// t.Fatalf("Block nonce [%v]: Block nonce not found", block.Nonce()) +// } +// +// if allTxsFromBlock:= core.SGetAllTransactionsFromBlock(sqldb, block2.Number().String()); len(allTxsFromBlock) == 0 { +// t.Fatalf("GetAllTransactionsFromBlock [%v]: GetAllTransactionsFromBlock did not return correctly", allTxsFromBlock) +// } +// ClearTables() +//} +// +//func TestContractCreationTx(t *testing.T) { +// key, _ := crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") +// signer := types.NewEIP155Signer(big.NewInt(2147483647)) +// +// //Nonce,Value, GasLimit, Gasprice, data +// contractCreation := types.NewContractCreation(1, big.NewInt(111), 1111, big.NewInt(11111), []byte{0x11, 0x11, 0x11}) +// mytx,_ := types.SignTx(contractCreation, signer, key) +// txs := []*types.Transaction{mytx} +// +// receipt2 := &types.Receipt{ +// Status: types.ReceiptStatusSuccessful, +// CumulativeGasUsed: 1, +// Logs: []*types.Log{ +// {Address: common.BytesToAddress([]byte{0x11})}, +// {Address: common.BytesToAddress([]byte{0x01, 0x11})}, +// }, +// TxHash: common.BytesToHash([]byte{0x11, 0x11}), +// ContractAddress: common.BytesToAddress([]byte{0x01, 0x11, 0x11}), +// GasUsed: 111111, +// } +// +// receipts := []*types.Receipt{receipt2} +// block := types.NewBlock(&types.Header{Number: big.NewInt(314)}, txs, nil, receipts) +// +// if err := core.SWriteBlock(block, receipts); err != nil { +// t.Fatalf("Failed to write block into database: %v", err) +// } +// +// var contractAddressFromReciept string +// for _, receipt := range receipts { +// contractAddressFromReciept = (*types.ReceiptForStorage)(receipt).ContractAddress.String() +// } +// +// sqldb, err := core.DBConnection() +// if (err != nil) { +// panic(err) +// } +// +// for _, tx := range txs { +// txn := core.SGetTransaction(sqldb, tx.Hash().String()) +// byt := []byte(txn) +// var data core.ShyftTxEntryPretty +// json.Unmarshal(byt, &data) +// +// if tx.Hash().String() != data.TxHash { +// t.Fatalf("txHash [%v]: tx Hash not found", tx.Hash().String()) +// } +// if contractAddressFromReciept != data.To { +// t.Fatalf("Contract Addr [%v]: Contract addr not found", contractAddressFromReciept) +// } +// if tx.From().String() != data.From { +// t.Fatalf("From Addr [%v]: From addr not found", tx.From().String()) +// } +// if tx.Nonce() != data.Nonce { +// t.Fatalf("Nonce [%v]: Nonce not found", tx.Nonce()) +// } +// if tx.Gas() != data.Gas { +// t.Fatalf("Gas [%v]: Gas not found", tx.Gas()) +// } +// if tx.GasPrice().Uint64() != data.GasPrice { +// t.Fatalf("Gas Price [%v]: Gas price not found", tx.GasPrice().String()) +// } +// if block.GasLimit() != data.GasLimit { +// t.Fatalf("Gas Limit [%v]: Gas limit not found", block.GasLimit()) +// } +// if block.Hash().String() != data.BlockHash { +// t.Fatalf("Block Hash [%v]: Block hash not found", block.Hash().String()) +// } +// if block.Number().String() != data.BlockNumber { +// t.Fatalf("Block Number [%v]: Block number not found", block.Number().String()) +// } +// if tx.Value().String() != data.Amount { +// t.Fatalf("Amount [%v]: Amount not found", tx.Value().String()) +// } +// if tx.Cost().Uint64() != data.Cost { +// t.Fatalf("Cost [%v]: Cost not found", tx.Cost().String()) +// } +// var status string +// if receipt2.Status == 1 { +// status = "SUCCESS" +// } +// if receipt2.Status == 0 { +// status = "FAIL" +// } +// if status != data.Status { +// t.Fatalf("Receipt status [%v]: Receipt status not found", status) +// } +// var isContract bool +// if tx.To() != nil { +// isContract = false +// } else { +// isContract = true +// } +// if isContract != data.IsContract { +// t.Fatalf("isContract [%v]: isContract bool is incorrect", isContract) +// } +// } +// ClearTables() +//} +// +//func TestTransactionsToReturnTransactions(t *testing.T) { +// key, _ := crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") +// signer := types.NewEIP155Signer(big.NewInt(2147483647)) +// +// //Nonce, To Address,Value, GasLimit, Gasprice, data +// tx1 := types.NewTransaction(1, common.BytesToAddress([]byte{0x11}), big.NewInt(111), 1111, big.NewInt(11111), []byte{0x11, 0x11, 0x11}) +// mytx,_ := types.SignTx(tx1, signer, key) +// tx2 := types.NewTransaction(2, common.BytesToAddress([]byte{0x22}), big.NewInt(222), 2222, big.NewInt(22222), []byte{0x22, 0x22, 0x22}) +// mytx2,_ := types.SignTx(tx2, signer, key) +// tx3 := types.NewTransaction(3, common.BytesToAddress([]byte{0x33}), big.NewInt(333), 3333, big.NewInt(33333), []byte{0x33, 0x33, 0x33}) +// mytx3,_ := types.SignTx(tx3, signer, key) +// txs := []*types.Transaction{mytx, mytx2, mytx3} +// +// receipt1 := &types.Receipt{ +// Status: types.ReceiptStatusSuccessful, +// CumulativeGasUsed: 1, +// Logs: []*types.Log{ +// {Address: common.BytesToAddress([]byte{0x11})}, +// {Address: common.BytesToAddress([]byte{0x01, 0x11})}, +// }, +// TxHash: common.BytesToHash([]byte{0x11, 0x11}), +// ContractAddress: common.BytesToAddress([]byte{0x01, 0x11, 0x11}), +// GasUsed: 111111, +// } +// +// receipts := []*types.Receipt{receipt1} +// block := types.NewBlock(&types.Header{Number: big.NewInt(314)}, txs, nil, receipts) +// +// if err := core.SWriteBlock(block, receipts); err != nil { +// t.Fatalf("Failed to write block into database: %v", err) +// } +// sqldb, err := core.DBConnection() +// if (err != nil) { +// panic(err) +// } +// +// for _, tx := range txs { +// txn := core.SGetTransaction(sqldb, tx.Hash().String()) +// byt := []byte(txn) +// var data core.ShyftTxEntryPretty +// json.Unmarshal(byt, &data) +// +// //TODO age, data +// if tx.Hash().String() != data.TxHash { +// t.Fatalf("txHash [%v]: tx Hash not found", tx.Hash().String()) +// } +// if tx.From().String() != data.From { +// t.Fatalf("From Addr [%v]: From addr not found", tx.From().String()) +// } +// if tx.To().String() != data.To { +// t.Fatalf("To Addr [%v]: To addr not found", tx.To().String()) +// } +// if tx.Nonce() != data.Nonce { +// t.Fatalf("Nonce [%v]: Nonce not found", tx.Nonce()) +// } +// if tx.Gas() != data.Gas { +// t.Fatalf("Gas [%v]: Gas not found", tx.Gas()) +// } +// if tx.GasPrice().Uint64() != data.GasPrice { +// t.Fatalf("Gas Price [%v]: Gas price not found", tx.GasPrice().String()) +// } +// if block.GasLimit() != data.GasLimit { +// t.Fatalf("Gas Limit [%v]: Gas limit not found", block.GasLimit()) +// } +// if block.Hash().String() != data.BlockHash { +// t.Fatalf("Block Hash [%v]: Block hash not found", block.Hash().String()) +// } +// if block.Number().String() != data.BlockNumber { +// t.Fatalf("Block Number [%v]: Block number not found", block.Number().String()) +// } +// if tx.Value().String() != data.Amount { +// t.Fatalf("Amount [%v]: Amount not found", tx.Value().String()) +// } +// if tx.Cost().Uint64() != data.Cost { +// t.Fatalf("Cost [%v]: Cost not found", tx.Cost().String()) +// } +// var status string +// if receipt1.Status == 1 { +// status = "SUCCESS" +// } +// if receipt1.Status == 0 { +// status = "FAIL" +// } +// if status != data.Status { +// t.Fatalf("Receipt status [%v]: Receipt status not found", status) +// } +// var isContract bool +// if tx.To() != nil { +// isContract = false +// } else { +// isContract = true +// } +// if isContract != data.IsContract { +// t.Fatalf("isContract [%v]: isContract bool is incorrect", isContract) +// } +// } +// +// if getAllTx := core.SGetAllTransactions(sqldb); len(getAllTx) == 0 { +// t.Fatalf("GetAllTransactions [%v]: GetAllTransactions did not return correctly", getAllTx) +// } +// ClearTables() +//} +// +//func TestAccountsToReturnAccounts(t *testing.T) { +// key, _ := crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") +// signer := types.NewEIP155Signer(big.NewInt(2147483647)) +// +// //Nonce, To Address,Value, GasLimit, Gasprice, data +// tx1 := types.NewTransaction(1, common.BytesToAddress([]byte{0x11}), big.NewInt(111), 1111, big.NewInt(11111), []byte{0x11, 0x11, 0x11}) +// mytx,_ := types.SignTx(tx1, signer, key) +// tx2 := types.NewTransaction(2, common.BytesToAddress([]byte{0x22}), big.NewInt(222), 2222, big.NewInt(22222), []byte{0x22, 0x22, 0x22}) +// mytx2,_ := types.SignTx(tx2, signer, key) +// tx3 := types.NewTransaction(3, common.BytesToAddress([]byte{0x33}), big.NewInt(333), 3333, big.NewInt(33333), []byte{0x33, 0x33, 0x33}) +// mytx3,_ := types.SignTx(tx3, signer, key) +// txs := []*types.Transaction{mytx, mytx2, mytx3} +// +// receipt1 := &types.Receipt{ +// Status: types.ReceiptStatusSuccessful, +// CumulativeGasUsed: 1, +// Logs: []*types.Log{ +// {Address: common.BytesToAddress([]byte{0x11})}, +// {Address: common.BytesToAddress([]byte{0x01, 0x11})}, +// }, +// TxHash: common.BytesToHash([]byte{0x11, 0x11}), +// ContractAddress: common.BytesToAddress([]byte{0x01, 0x11, 0x11}), +// GasUsed: 111111, +// } +// +// receipts := []*types.Receipt{receipt1} +// block := types.NewBlock(&types.Header{Number: big.NewInt(315)}, txs, nil, receipts) +// if err := core.SWriteBlock(block, receipts); err != nil { +// t.Fatalf("Failed to write block into database: %v", err) +// } +// +// sqldb, err := core.DBConnection() +// if (err != nil) { +// panic(err) +// } +// +// +// for _, tx := range txs { +// accountAddrTo := core.SGetAccount(sqldb, tx.To().String()) +// byts := []byte(accountAddrTo) +// var accountDataTo core.SAccounts +// json.Unmarshal(byts, &accountDataTo) +// +// if tx.To().String() != accountDataTo.Addr { +// t.Fatalf("To address [%v]: To address not found", accountDataTo.Addr) +// } +// if tx.Value().String() != accountDataTo.Balance { +// t.Fatalf("To address balance [%v]: To address balance not found", accountDataTo.Balance) +// } +// if strconv.FormatUint(tx.Nonce(), 10) != accountDataTo.TxCountAccount { +// t.Fatalf("To account nonce [%v]: To account nonce not found", accountDataTo.TxCountAccount) +// } +// if getAllAccountTxs := core.SGetAccountTxs(sqldb, tx.To().String()); len(getAllAccountTxs) == 0 { +// t.Fatalf("GetAccountTxs [%v]: GetAccountTxs did not return correctly", getAllAccountTxs) +// } +// } +// +// if getAllAccounts := core.SGetAllAccounts(sqldb); len(getAllAccounts) == 0 { +// t.Fatalf("GetAllAccounts [%v]: GetAllAccounts did not return correctly", getAllAccounts) +// } +// ClearTables() +//} + + + diff --git a/shyfttracerinterface/tracer_interface.go b/shyfttracerinterface/tracer_interface.go index dbadf1e39b..43fd883788 100644 --- a/shyfttracerinterface/tracer_interface.go +++ b/shyfttracerinterface/tracer_interface.go @@ -8,7 +8,3 @@ type IShyftTracer interface { GetTracerToRun(hash common.Hash) (interface{}, error) } -//type IShyftTracer interface { -// MyTraceTransaction(hash string) (interface{}) -//} - From 7c98e75c726b8f45711c36277a2aa7986358b1f3 Mon Sep 17 00:00:00 2001 From: Tim Williams Date: Tue, 17 Jul 2018 09:25:02 -0400 Subject: [PATCH 19/21] get tests to run with tracer correctly initialized --- eth/backend.go | 2 ++ eth/chaindb.go | 20 ++++++++++++++++++++ eth/shyft_tracer.go | 16 ++++++++++++++-- shyftDb/shyft_database_util_test.go | 3 +++ 4 files changed, 39 insertions(+), 2 deletions(-) diff --git a/eth/backend.go b/eth/backend.go index 94b94f157e..3f9a813567 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -232,6 +232,8 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) { DebugApi.eth = eth DebugApi.config = chainConfig + // Shyft Tracer + InitTracerEnv() return eth, nil } diff --git a/eth/chaindb.go b/eth/chaindb.go index 4ff89683fb..19f999d023 100644 --- a/eth/chaindb.go +++ b/eth/chaindb.go @@ -4,6 +4,8 @@ import ( "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/node" "fmt" + "io/ioutil" + "os" ) var Chaindb_global ethdb.Database @@ -24,4 +26,22 @@ func chaindb(ctx *node.ServiceContext, config *Config) (ethdb.Database, error) { return Chaindb_global, nil } return nil, err +} + +//(*ethdb.LDBDatabase, func()) +func NewShyftTestLDB() { + dirname, err := ioutil.TempDir(os.TempDir(), "shyftdb_test_") + if err != nil { + panic("failed to create test file: " + err.Error()) + } + db, err := ethdb.NewLDBDatabase(dirname, 0, 0) + if err != nil { + panic("failed to create test database: " + err.Error()) + } + Chaindb_global = db + + //return db, func() { + // db.Close() + // os.RemoveAll(dirname) + //} } \ No newline at end of file diff --git a/eth/shyft_tracer.go b/eth/shyft_tracer.go index 5fa2eb392f..0e1bcd6734 100644 --- a/eth/shyft_tracer.go +++ b/eth/shyft_tracer.go @@ -12,23 +12,35 @@ var EthereumObject interface{} type ShyftTracer struct {} -func (st ShyftTracer) GetTracerToRun (hash common.Hash) (interface{}, error) { +var PrivateAPI *PrivateDebugAPI +var Context context.Context +var TracerConfig *TraceConfig + +func InitTracerEnv() { + fmt.Println("INIT tracer Env") config2 := params.ShyftNetworkChainConfig jsTracer := "callTracer" var ctx2 context.Context + Context = ctx2 config := &TraceConfig{ LogConfig: nil, Tracer: &jsTracer, // needs to be non-nil Timeout: nil, Reexec: nil, } + TracerConfig = config fmt.Println("+++++++++++++++++++++++++++ before FULLNODE", Global_config) + // called here fullNode, _ := SNew(Global_config) fmt.Println("+++++++++++++++++++++++++++ after FULLNODE") privateAPI := NewPrivateDebugAPI(config2, fullNode) + PrivateAPI = privateAPI fmt.Println("+++++++++++++++++++++++++++ after privateAPI") - return privateAPI.STraceTransaction(ctx2, hash, config) +} + +func (st ShyftTracer) GetTracerToRun (hash common.Hash) (interface{}, error) { + return PrivateAPI.STraceTransaction(Context, hash, TracerConfig) } func setEthObject(ethobj interface{}){ diff --git a/shyftDb/shyft_database_util_test.go b/shyftDb/shyft_database_util_test.go index 4875f656d9..9ce11ea3b8 100644 --- a/shyftDb/shyft_database_util_test.go +++ b/shyftDb/shyft_database_util_test.go @@ -29,6 +29,7 @@ const ( ) func TestBlock(t *testing.T) { + eth.NewShyftTestLDB() core.InitDBTest() shyft_tracer := new(eth.ShyftTracer) core.SetIShyftTracer(shyft_tracer) @@ -55,6 +56,8 @@ func TestBlock(t *testing.T) { eth.SetGlobalConfig(ethConf) + eth.InitTracerEnv() + t.Run("TestBlockToReturnBlock", func(t *testing.T) { key, _ := crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") signer := types.NewEIP155Signer(big.NewInt(2147483647)) From 274ae75ad3fecc0683dea76aa3848726b94da6b9 Mon Sep 17 00:00:00 2001 From: Dustin Brickwood Date: Tue, 17 Jul 2018 10:15:15 -0400 Subject: [PATCH 20/21] internal txs are being recorded --- core/genesis.go | 2 - eth/api_tracer.go | 5 - eth/backend.go | 21 +- eth/chaindb.go | 2 - eth/shyft_tracer.go | 7 - eth/tracers/tracer.go | 3 - shyftDb/shyft_database_util_test.go | 739 ++++++++++------------------ 7 files changed, 268 insertions(+), 511 deletions(-) diff --git a/core/genesis.go b/core/genesis.go index ade6d3f0de..9382442449 100644 --- a/core/genesis.go +++ b/core/genesis.go @@ -186,8 +186,6 @@ func WriteShyftGen(gen *Genesis, block *types.Block) { panic(insertError) } } - - default: log.Info("Found Genesis Block") }}} diff --git a/eth/api_tracer.go b/eth/api_tracer.go index 89de3293b7..ea6c0556b6 100644 --- a/eth/api_tracer.go +++ b/eth/api_tracer.go @@ -561,12 +561,10 @@ func (api *PrivateDebugAPI) STraceTransaction(ctx context.Context, hash common.H if config != nil && config.Reexec != nil { reexec = *config.Reexec } - fmt.Println("+++++++++++++++++++++++++++ Middle") msg, vmctx, statedb, err := api.computeTxEnv(blockHash, int(index), reexec) if err != nil { return nil, err } - fmt.Println("+++++++++++++++++++++++++++ BOTTOM") return api.StraceTx(ctx, msg, vmctx, statedb, config, hash) } @@ -583,7 +581,6 @@ func (api *PrivateDebugAPI) StraceTx(ctx context.Context, message core.Message, switch { case config != nil && config.Tracer != nil: // Define a meaningful timeout of a single transaction trace - fmt.Println("STRACETX") _ = defaultTraceTimeout if config.Timeout != nil { @@ -703,7 +700,6 @@ func (api *PrivateDebugAPI) traceTx(ctx context.Context, message core.Message, v // computeTxEnv returns the execution environment of a certain transaction. func (api *PrivateDebugAPI) computeTxEnv(blockHash common.Hash, txIndex int, reexec uint64) (core.Message, vm.Context, *state.StateDB, error) { // Create the parent state database - fmt.Println("COMPUTETXENV") block := api.eth.blockchain.GetBlockByHash(blockHash) if block == nil { return nil, vm.Context{}, nil, fmt.Errorf("block %x not found", blockHash) @@ -733,6 +729,5 @@ func (api *PrivateDebugAPI) computeTxEnv(blockHash common.Hash, txIndex int, ree } statedb.DeleteSuicides() } - fmt.Println("+++++++++++++++++ BOTTOM COMPUTETXENV") return nil, vm.Context{}, nil, fmt.Errorf("tx index %d out of range for block %x", txIndex, blockHash) } diff --git a/eth/backend.go b/eth/backend.go index 3f9a813567..65d3909f43 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -103,17 +103,12 @@ func (s *Ethereum) AddLesServer(ls LesServer) { } func SNew(config *Config) (*Ethereum, error) { - fmt.Println("SNEW FROM SHYFTREACER") stopDbUpgrade := upgradeDeduplicateData(Chaindb_global) - fmt.Println("ChainGlobal v+%", Chaindb_global) chainConfig, _, _ := core.SetupGenesisBlock(Chaindb_global, config.Genesis) eth := &Ethereum{ config: config, chainDb: Chaindb_global, chainConfig: chainConfig, - //eventMux: ctx.EventMux, - //accountManager: ctx.AccountManager, - //engine: CreateConsensusEngine(ctx, &config.Ethash, chainConfig, Chaindb_global), shutdownChan: make(chan bool), stopDbUpgrade: stopDbUpgrade, networkId: config.NetworkId, @@ -123,15 +118,6 @@ func SNew(config *Config) (*Ethereum, error) { bloomIndexer: NewBloomIndexer(Chaindb_global, params.BloomBitsBlocks), } - //var ( - // vmConfig = vm.Config{EnablePreimageRecording: config.EnablePreimageRecording} - // cacheConfig = &core.CacheConfig{Disabled: config.NoPruning, TrieNodeLimit: config.TrieCache, TrieTimeLimit: config.TrieTimeout} - //) - // - //eth.blockchain, err = core.NewBlockChain(chainDb, cacheConfig, eth.chainConfig, eth.engine, vmConfig) - // - //BlockchainObject = eth.blockchain - eth.blockchain = BlockchainObject return eth, nil @@ -144,11 +130,6 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) { core.SetIShyftTracer(shyft_tracer) SetGlobalConfig(config) - _, file, no, ok := runtime.Caller(1) - if ok { - fmt.Printf("called from %s#%d\n", file, no) - } - if config.SyncMode == downloader.LightSync { return nil, errors.New("can't run eth.Ethereum in light sync mode, use les.LightEthereum") } @@ -232,7 +213,7 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) { DebugApi.eth = eth DebugApi.config = chainConfig - // Shyft Tracer + //@NOTE Shyft Tracer InitTracerEnv() return eth, nil diff --git a/eth/chaindb.go b/eth/chaindb.go index 19f999d023..7ff01a7e13 100644 --- a/eth/chaindb.go +++ b/eth/chaindb.go @@ -3,7 +3,6 @@ package eth import ( "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/node" - "fmt" "io/ioutil" "os" ) @@ -15,7 +14,6 @@ func SetChainDB(db ethdb.Database){ } func chaindb(ctx *node.ServiceContext, config *Config) (ethdb.Database, error) { - fmt.Printf("CTX v+%", ctx) if Chaindb_global != nil { return Chaindb_global, nil } diff --git a/eth/shyft_tracer.go b/eth/shyft_tracer.go index 0e1bcd6734..0db8e7a23b 100644 --- a/eth/shyft_tracer.go +++ b/eth/shyft_tracer.go @@ -5,7 +5,6 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/params" "context" - "fmt" ) var EthereumObject interface{} @@ -17,7 +16,6 @@ var Context context.Context var TracerConfig *TraceConfig func InitTracerEnv() { - fmt.Println("INIT tracer Env") config2 := params.ShyftNetworkChainConfig jsTracer := "callTracer" @@ -30,13 +28,9 @@ func InitTracerEnv() { Reexec: nil, } TracerConfig = config - fmt.Println("+++++++++++++++++++++++++++ before FULLNODE", Global_config) - // called here fullNode, _ := SNew(Global_config) - fmt.Println("+++++++++++++++++++++++++++ after FULLNODE") privateAPI := NewPrivateDebugAPI(config2, fullNode) PrivateAPI = privateAPI - fmt.Println("+++++++++++++++++++++++++++ after privateAPI") } func (st ShyftTracer) GetTracerToRun (hash common.Hash) (interface{}, error) { @@ -50,6 +44,5 @@ func setEthObject(ethobj interface{}){ var Global_config *Config func SetGlobalConfig(c *Config) { - fmt.Println("SETGLOBAL") Global_config = c } \ No newline at end of file diff --git a/eth/tracers/tracer.go b/eth/tracers/tracer.go index 807886708b..c79ce7e411 100644 --- a/eth/tracers/tracer.go +++ b/eth/tracers/tracer.go @@ -592,7 +592,6 @@ type Internals struct { //@NOTE:SHYFT func (i *Internals) SWriteInteralTxs(hash common.Hash) { - fmt.Println("WRITE INTERNAL") sqldb, err := core.DBConnection() if err != nil { panic(err) @@ -612,7 +611,6 @@ func (i *Internals) SWriteInteralTxs(hash common.Hash) { } //@NOTE:SHYFT func (i *Internals) InternalRecursive(hash common.Hash) { - fmt.Println("internal recursive") i.SWriteInteralTxs(hash) lengthOfCalls := len(i.Calls) if lengthOfCalls == 0 { @@ -671,7 +669,6 @@ func (jst *Tracer) GetResult() (json.RawMessage, error) { //@NOTE:SHYFT func (jst *Tracer) SGetResult(hash common.Hash) (json.RawMessage, error) { - fmt.Println("SGETRESULT") // Transform the context into a JavaScript object and inject into the state obj := jst.vm.PushObject() diff --git a/shyftDb/shyft_database_util_test.go b/shyftDb/shyft_database_util_test.go index 9ce11ea3b8..b5f0409e31 100644 --- a/shyftDb/shyft_database_util_test.go +++ b/shyftDb/shyft_database_util_test.go @@ -11,20 +11,12 @@ import ( "encoding/json" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/consensus/ethash" + "strconv" ) type ShyftTracer struct {} -//Config Below -//&{Genesis: NetworkId:1 SyncMode:fast NoPruning:false LightServ:0 LightPeers:100 SkipBcVersionCheck:false DatabaseHandles:1024 DatabaseCache:768 TrieCache:256 TrieTimeout:5m0s Etherbase:[67 236 109 9 66 247 250 239 6 159 127 99 208 56 74 39 245 41 176 98] MinerThreads:4 ExtraData:[] GasPrice:+18000000000 Ethash:{CacheDir:ethash CachesInMem:2 CachesOnDisk:3 DatasetDir:$HOME/.ethash DatasetsInMem:1 DatasetsOnDisk:2 PowMode:0} TxPool:{NoLocals:false Journal:transactions.rlp Rejournal:1h0m0s PriceLimit:1 PriceBump:10 AccountSlots:16 GlobalSlots:4096 AccountQueue:64 GlobalQueue:1024 Lifetime:3h0m0s} GPO:{Blocks:20 Percentile:60 Default:} EnablePreimageRecording:false DocRoot:}SETGLOBAL -//called from /Users/dustinbrickwood/go/src/github.com/ethereum/go-ethereum/build/_workspace/src/github.com/ethereum/go-ethereum/cmd/utils/flags.go#1132 -// - -//CTX -// !(NOVERB)%!(EXTRA *node.ServiceContext=&{0xc4200326c0 map[] 0xc4201dc6c0 0xc42026f2b0}) - const ( - testInstance = "console-tester" testAddress = "0x8605cdbbdb6d264aa742e77020dcbc58fcdce182" ) @@ -34,15 +26,6 @@ func TestBlock(t *testing.T) { shyft_tracer := new(eth.ShyftTracer) core.SetIShyftTracer(shyft_tracer) - //workspace, err := ioutil.TempDir("", "console-tester-") - //if err != nil { - // t.Fatalf("failed to create temporary keystore: %v", err) - //} - - //stack, err := node.New(&node.Config{DataDir: workspace, UseLightweightKDF: true, Name: testInstance}) - //if err != nil { - // t.Fatalf("failed to create node: %v", err) - //} ethConf := ð.Config{ Genesis: core.DeveloperGenesisBlock(15, common.Address{}), Etherbase: common.HexToAddress(testAddress), @@ -50,9 +33,6 @@ func TestBlock(t *testing.T) { PowMode: ethash.ModeTest, }, } - //if err = stack.Register(func(ctx *node.ServiceContext) (node.Service, error) { return eth.New(ctx, ethConf) }); err != nil { - // t.Fatalf("failed to register Ethereum protocol: %v", err) - //} eth.SetGlobalConfig(ethConf) @@ -235,457 +215,272 @@ func TestBlock(t *testing.T) { ClearTables() }) +// +t.Run("TestContractCreationTx", func (t *testing.T) { + key, _ := crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") + signer := types.NewEIP155Signer(big.NewInt(2147483647)) + + //Nonce,Value, GasLimit, Gasprice, data + contractCreation := types.NewContractCreation(1, big.NewInt(111), 1111, big.NewInt(11111), []byte{0x11, 0x11, 0x11}) + mytx,_ := types.SignTx(contractCreation, signer, key) + txs := []*types.Transaction{mytx} + + receipt2 := &types.Receipt{ + Status: types.ReceiptStatusSuccessful, + CumulativeGasUsed: 1, + Logs: []*types.Log{ + {Address: common.BytesToAddress([]byte{0x11})}, + {Address: common.BytesToAddress([]byte{0x01, 0x11})}, + }, + TxHash: common.BytesToHash([]byte{0x11, 0x11}), + ContractAddress: common.BytesToAddress([]byte{0x01, 0x11, 0x11}), + GasUsed: 111111, + } + + receipts := []*types.Receipt{receipt2} + block := types.NewBlock(&types.Header{Number: big.NewInt(314)}, txs, nil, receipts) + + if err := core.SWriteBlock(block, receipts); err != nil { + t.Fatalf("Failed to write block into database: %v", err) + } + + var contractAddressFromReciept string + for _, receipt := range receipts { + contractAddressFromReciept = (*types.ReceiptForStorage)(receipt).ContractAddress.String() + } + + sqldb, err := core.DBConnection() + if (err != nil) { + panic(err) + } + + for _, tx := range txs { + txn := core.SGetTransaction(sqldb, tx.Hash().String()) + byt := []byte(txn) + var data core.ShyftTxEntryPretty + json.Unmarshal(byt, &data) + + if tx.Hash().String() != data.TxHash { + t.Fatalf("txHash [%v]: tx Hash not found", tx.Hash().String()) + } + if contractAddressFromReciept != data.To { + t.Fatalf("Contract Addr [%v]: Contract addr not found", contractAddressFromReciept) + } + if tx.From().String() != data.From { + t.Fatalf("From Addr [%v]: From addr not found", tx.From().String()) + } + if tx.Nonce() != data.Nonce { + t.Fatalf("Nonce [%v]: Nonce not found", tx.Nonce()) + } + if tx.Gas() != data.Gas { + t.Fatalf("Gas [%v]: Gas not found", tx.Gas()) + } + if tx.GasPrice().Uint64() != data.GasPrice { + t.Fatalf("Gas Price [%v]: Gas price not found", tx.GasPrice().String()) + } + if block.GasLimit() != data.GasLimit { + t.Fatalf("Gas Limit [%v]: Gas limit not found", block.GasLimit()) + } + if block.Hash().String() != data.BlockHash { + t.Fatalf("Block Hash [%v]: Block hash not found", block.Hash().String()) + } + if block.Number().String() != data.BlockNumber { + t.Fatalf("Block Number [%v]: Block number not found", block.Number().String()) + } + if tx.Value().String() != data.Amount { + t.Fatalf("Amount [%v]: Amount not found", tx.Value().String()) + } + if tx.Cost().Uint64() != data.Cost { + t.Fatalf("Cost [%v]: Cost not found", tx.Cost().String()) + } + var status string + if receipt2.Status == 1 { + status = "SUCCESS" + } + if receipt2.Status == 0 { + status = "FAIL" + } + if status != data.Status { + t.Fatalf("Receipt status [%v]: Receipt status not found", status) + } + var isContract bool + if tx.To() != nil { + isContract = false + } else { + isContract = true + } + if isContract != data.IsContract { + t.Fatalf("isContract [%v]: isContract bool is incorrect", isContract) + } + } + ClearTables() +}) + +t.Run("TestTransactionsToReturnTransactions", func(t *testing.T) { + key, _ := crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") + signer := types.NewEIP155Signer(big.NewInt(2147483647)) + + //Nonce, To Address,Value, GasLimit, Gasprice, data + tx1 := types.NewTransaction(1, common.BytesToAddress([]byte{0x11}), big.NewInt(111), 1111, big.NewInt(11111), []byte{0x11, 0x11, 0x11}) + mytx,_ := types.SignTx(tx1, signer, key) + tx2 := types.NewTransaction(2, common.BytesToAddress([]byte{0x22}), big.NewInt(222), 2222, big.NewInt(22222), []byte{0x22, 0x22, 0x22}) + mytx2,_ := types.SignTx(tx2, signer, key) + tx3 := types.NewTransaction(3, common.BytesToAddress([]byte{0x33}), big.NewInt(333), 3333, big.NewInt(33333), []byte{0x33, 0x33, 0x33}) + mytx3,_ := types.SignTx(tx3, signer, key) + txs := []*types.Transaction{mytx, mytx2, mytx3} + + receipt1 := &types.Receipt{ + Status: types.ReceiptStatusSuccessful, + CumulativeGasUsed: 1, + Logs: []*types.Log{ + {Address: common.BytesToAddress([]byte{0x11})}, + {Address: common.BytesToAddress([]byte{0x01, 0x11})}, + }, + TxHash: common.BytesToHash([]byte{0x11, 0x11}), + ContractAddress: common.BytesToAddress([]byte{0x01, 0x11, 0x11}), + GasUsed: 111111, + } + + receipts := []*types.Receipt{receipt1} + block := types.NewBlock(&types.Header{Number: big.NewInt(314)}, txs, nil, receipts) + + if err := core.SWriteBlock(block, receipts); err != nil { + t.Fatalf("Failed to write block into database: %v", err) + } + sqldb, err := core.DBConnection() + if (err != nil) { + panic(err) + } + + for _, tx := range txs { + txn := core.SGetTransaction(sqldb, tx.Hash().String()) + byt := []byte(txn) + var data core.ShyftTxEntryPretty + json.Unmarshal(byt, &data) + + //TODO age, data + if tx.Hash().String() != data.TxHash { + t.Fatalf("txHash [%v]: tx Hash not found", tx.Hash().String()) + } + if tx.From().String() != data.From { + t.Fatalf("From Addr [%v]: From addr not found", tx.From().String()) + } + if tx.To().String() != data.To { + t.Fatalf("To Addr [%v]: To addr not found", tx.To().String()) + } + if tx.Nonce() != data.Nonce { + t.Fatalf("Nonce [%v]: Nonce not found", tx.Nonce()) + } + if tx.Gas() != data.Gas { + t.Fatalf("Gas [%v]: Gas not found", tx.Gas()) + } + if tx.GasPrice().Uint64() != data.GasPrice { + t.Fatalf("Gas Price [%v]: Gas price not found", tx.GasPrice().String()) + } + if block.GasLimit() != data.GasLimit { + t.Fatalf("Gas Limit [%v]: Gas limit not found", block.GasLimit()) + } + if block.Hash().String() != data.BlockHash { + t.Fatalf("Block Hash [%v]: Block hash not found", block.Hash().String()) + } + if block.Number().String() != data.BlockNumber { + t.Fatalf("Block Number [%v]: Block number not found", block.Number().String()) + } + if tx.Value().String() != data.Amount { + t.Fatalf("Amount [%v]: Amount not found", tx.Value().String()) + } + if tx.Cost().Uint64() != data.Cost { + t.Fatalf("Cost [%v]: Cost not found", tx.Cost().String()) + } + var status string + if receipt1.Status == 1 { + status = "SUCCESS" + } + if receipt1.Status == 0 { + status = "FAIL" + } + if status != data.Status { + t.Fatalf("Receipt status [%v]: Receipt status not found", status) + } + var isContract bool + if tx.To() != nil { + isContract = false + } else { + isContract = true + } + if isContract != data.IsContract { + t.Fatalf("isContract [%v]: isContract bool is incorrect", isContract) + } + } + + if getAllTx := core.SGetAllTransactions(sqldb); len(getAllTx) == 0 { + t.Fatalf("GetAllTransactions [%v]: GetAllTransactions did not return correctly", getAllTx) + } + ClearTables() +}) + +t.Run("TestAccountsToReturnAccounts",func(t *testing.T) { + key, _ := crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") + signer := types.NewEIP155Signer(big.NewInt(2147483647)) + + //Nonce, To Address,Value, GasLimit, Gasprice, data + tx1 := types.NewTransaction(1, common.BytesToAddress([]byte{0x11}), big.NewInt(111), 1111, big.NewInt(11111), []byte{0x11, 0x11, 0x11}) + mytx,_ := types.SignTx(tx1, signer, key) + tx2 := types.NewTransaction(2, common.BytesToAddress([]byte{0x22}), big.NewInt(222), 2222, big.NewInt(22222), []byte{0x22, 0x22, 0x22}) + mytx2,_ := types.SignTx(tx2, signer, key) + tx3 := types.NewTransaction(3, common.BytesToAddress([]byte{0x33}), big.NewInt(333), 3333, big.NewInt(33333), []byte{0x33, 0x33, 0x33}) + mytx3,_ := types.SignTx(tx3, signer, key) + txs := []*types.Transaction{mytx, mytx2, mytx3} + + receipt1 := &types.Receipt{ + Status: types.ReceiptStatusSuccessful, + CumulativeGasUsed: 1, + Logs: []*types.Log{ + {Address: common.BytesToAddress([]byte{0x11})}, + {Address: common.BytesToAddress([]byte{0x01, 0x11})}, + }, + TxHash: common.BytesToHash([]byte{0x11, 0x11}), + ContractAddress: common.BytesToAddress([]byte{0x01, 0x11, 0x11}), + GasUsed: 111111, + } + + receipts := []*types.Receipt{receipt1} + block := types.NewBlock(&types.Header{Number: big.NewInt(315)}, txs, nil, receipts) + if err := core.SWriteBlock(block, receipts); err != nil { + t.Fatalf("Failed to write block into database: %v", err) + } + + sqldb, err := core.DBConnection() + if (err != nil) { + panic(err) + } + + for _, tx := range txs { + accountAddrTo := core.SGetAccount(sqldb, tx.To().String()) + byts := []byte(accountAddrTo) + var accountDataTo core.SAccounts + json.Unmarshal(byts, &accountDataTo) + + if tx.To().String() != accountDataTo.Addr { + t.Fatalf("To address [%v]: To address not found", accountDataTo.Addr) + } + if tx.Value().String() != accountDataTo.Balance { + t.Fatalf("To address balance [%v]: To address balance not found", accountDataTo.Balance) + } + if strconv.FormatUint(tx.Nonce(), 10) != accountDataTo.TxCountAccount { + t.Fatalf("To account nonce [%v]: To account nonce not found", accountDataTo.TxCountAccount) + } + if getAllAccountTxs := core.SGetAccountTxs(sqldb, tx.To().String()); len(getAllAccountTxs) == 0 { + t.Fatalf("GetAccountTxs [%v]: GetAccountTxs did not return correctly", getAllAccountTxs) + } + } + + if getAllAccounts := core.SGetAllAccounts(sqldb); len(getAllAccounts) == 0 { + t.Fatalf("GetAllAccounts [%v]: GetAllAccounts did not return correctly", getAllAccounts) + } + ClearTables() +}) + ClearTables() } - - - - -//func TestBlockToReturnBlock(t *testing.T) { -// core.InitDBTest() -// -// key, _ := crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") -// signer := types.NewEIP155Signer(big.NewInt(2147483647)) -// -// //Nonce, To Address,Value, GasLimit, Gasprice, data -// tx1 := types.NewTransaction(1, common.BytesToAddress([]byte{0x11}), big.NewInt(111), 1111, big.NewInt(11111), []byte{0x11, 0x11, 0x11}) -// mytx,_ := types.SignTx(tx1, signer, key) -// tx2 := types.NewTransaction(2, common.BytesToAddress([]byte{0x22}), big.NewInt(222), 2222, big.NewInt(22222), []byte{0x22, 0x22, 0x22}) -// mytx2,_ := types.SignTx(tx2, signer, key) -// tx3 := types.NewTransaction(3, common.BytesToAddress([]byte{0x33}), big.NewInt(333), 3333, big.NewInt(33333), []byte{0x33, 0x33, 0x33}) -// mytx3,_ := types.SignTx(tx3, signer, key) -// txs := []*types.Transaction{mytx, mytx2, mytx3} -// -// receipt := &types.Receipt{ -// Status: types.ReceiptStatusSuccessful, -// CumulativeGasUsed: 1, -// Logs: []*types.Log{ -// {Address: common.BytesToAddress([]byte{0x11})}, -// {Address: common.BytesToAddress([]byte{0x01, 0x11})}, -// }, -// TxHash: common.BytesToHash([]byte{0x11, 0x11}), -// ContractAddress: common.BytesToAddress([]byte{0x01, 0x11, 0x11}), -// GasUsed: 111111, -// } -// -// receipts := []*types.Receipt{receipt} -// block := types.NewBlock(&types.Header{Number: big.NewInt(315)}, txs, nil, receipts) -// -// // Write and verify the block in the database -// if err := core.SWriteBlock(block, receipts); err != nil { -// t.Fatalf("Failed to write block into database: %v", err) -// } -// -// sqldb, err := core.DBConnection() -// if err != nil { -// panic(err) -// } -// -// entry := core.SGetBlock(sqldb, block.Number().String()) -// byt := []byte(entry) -// var data core.SBlock -// json.Unmarshal(byt, &data) -// -// //TODO Difficulty, rewards, age -// if block.Hash().String() != data.Hash { -// t.Fatalf("Block Hash [%v]: Block hash not found", block.Hash().String()) -// } -// if block.Coinbase().String() != data.Coinbase { -// t.Fatalf("Block coinbase [%v]: Block coinbase not found", block.Coinbase().String()) -// } -// if block.Number().String() != data.Number { -// t.Fatalf("Block number [%v]: Block number not found", block.Number().String()) -// } -// if block.GasUsed() != data.GasUsed { -// t.Fatalf("Gas Used [%v]: Gas used not found", block.GasUsed()) -// } -// if block.GasLimit() != data.GasLimit { -// t.Fatalf("Gas Limit [%v]: Gas limit not found", block.GasLimit()) -// } -// if block.Transactions().Len() != data.TxCount { -// t.Fatalf("Tx Count [%v]: Tx Count not found", block.Transactions().Len()) -// } -// if len(block.Uncles()) != data.UncleCount { -// t.Fatalf("Uncle count [%v]: Uncle count not found", len(block.Uncles())) -// } -// if block.ParentHash().String() != data.ParentHash { -// t.Fatalf("Parent hash [%v]: Parent hash not found", block.ParentHash().String()) -// } -// if block.UncleHash().String() != data.UncleHash { -// t.Fatalf("Uncle hash [%v]: Uncle hash not found", block.UncleHash().String()) -// } -// if block.Size().String() != data.Size { -// t.Fatalf("Size [%v]: Size not found", block.Size().String()) -// } -// if block.Nonce() != data.Nonce { -// t.Fatalf("Block nonce [%v]: Block nonce not found", block.Nonce()) -// } -// -// if getAllBlocks := core.SGetAllBlocks(sqldb); len(getAllBlocks) == 0 { -// t.Fatalf("GetAllBlocks [%v]: GetAllBlocks did not return correctly", getAllBlocks) -// } -// -// if getAllBlocksMinedByAddress := core.SGetAllBlocksMinedByAddress(sqldb, block.Coinbase().String()); len(getAllBlocksMinedByAddress) == 0 { -// t.Fatalf("GetAllBlocksMinedByAddress [%v]: GetAllBlocksMinedByAddress did not return correctly", getAllBlocksMinedByAddress) -// } -// -// ClearTables() -//} -// -//func TestGetRecentBlock(t *testing.T) { -// key, _ := crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") -// signer := types.NewEIP155Signer(big.NewInt(2147483647)) -// -// //Nonce, To Address,Value, GasLimit, Gasprice, data -// tx1 := types.NewTransaction(1, common.BytesToAddress([]byte{0x11}), big.NewInt(111), 1111, big.NewInt(11111), []byte{0x11, 0x11, 0x11}) -// mytx,_ := types.SignTx(tx1, signer, key) -// tx2 := types.NewTransaction(2, common.BytesToAddress([]byte{0x22}), big.NewInt(222), 2222, big.NewInt(22222), []byte{0x22, 0x22, 0x22}) -// mytx2,_ := types.SignTx(tx2, signer, key) -// tx3 := types.NewTransaction(3, common.BytesToAddress([]byte{0x33}), big.NewInt(333), 3333, big.NewInt(33333), []byte{0x33, 0x33, 0x33}) -// mytx3,_ := types.SignTx(tx3, signer, key) -// txs := []*types.Transaction{mytx, mytx2} -// txs1 := []*types.Transaction{mytx3} -// -// receipt1 := &types.Receipt{ -// Status: types.ReceiptStatusSuccessful, -// CumulativeGasUsed: 1, -// Logs: []*types.Log{ -// {Address: common.BytesToAddress([]byte{0x11})}, -// {Address: common.BytesToAddress([]byte{0x01, 0x11})}, -// }, -// TxHash: common.BytesToHash([]byte{0x11, 0x11}), -// ContractAddress: common.BytesToAddress([]byte{0x01, 0x11, 0x11}), -// GasUsed: 111111, -// } -// -// receipts := []*types.Receipt{receipt1} -// block := types.NewBlock(&types.Header{Number: big.NewInt(322)}, txs, nil, receipts) -// block2 := types.NewBlock(&types.Header{Number: big.NewInt(320)}, txs1, nil, receipts) -// blocks := []*types.Block{block, block2} -// -// for _, bc := range blocks { -// // Write and verify the block in the database -// if err := core.SWriteBlock(bc, receipts); err != nil { -// t.Fatalf("Failed to write block into database: %v", err) -// } -// } -// -// sqldb, err := core.DBConnection() -// if (err != nil) { -// panic(err) -// } -// -// response := core.SGetRecentBlock(sqldb) -// byteRes := []byte(response) -// var recentBlock core.SBlock -// json.Unmarshal(byteRes, &recentBlock) -// -// if block.Hash().String() != recentBlock.Hash { -// t.Fatalf("Block Hash [%v]: Block hash not found", block.Hash().String()) -// } -// if block.Coinbase().String() != recentBlock.Coinbase { -// t.Fatalf("Block coinbase [%v]: Block coinbase not found", block.Coinbase().String()) -// } -// if block.Number().String() != recentBlock.Number { -// t.Fatalf("Block number [%v]: Block number not found", block.Number().String()) -// } -// if block.GasUsed() != recentBlock.GasUsed { -// t.Fatalf("Gas Used [%v]: Gas used not found", block.GasUsed()) -// } -// if block.GasLimit() != recentBlock.GasLimit { -// t.Fatalf("Gas Limit [%v]: Gas limit not found", block.GasLimit()) -// } -// if block.Transactions().Len() != recentBlock.TxCount { -// t.Fatalf("Tx Count [%v]: Tx Count not found", block.Transactions().Len()) -// } -// if len(block.Uncles()) != recentBlock.UncleCount { -// t.Fatalf("Uncle count [%v]: Uncle count not found", len(block.Uncles())) -// } -// if block.ParentHash().String() != recentBlock.ParentHash { -// t.Fatalf("Parent hash [%v]: Parent hash not found", block.ParentHash().String()) -// } -// if block.UncleHash().String() != recentBlock.UncleHash { -// t.Fatalf("Uncle hash [%v]: Uncle hash not found", block.UncleHash().String()) -// } -// if block.Size().String() != recentBlock.Size { -// t.Fatalf("Size [%v]: Size not found", block.Size().String()) -// } -// if block.Nonce() != recentBlock.Nonce { -// t.Fatalf("Block nonce [%v]: Block nonce not found", block.Nonce()) -// } -// -// if allTxsFromBlock:= core.SGetAllTransactionsFromBlock(sqldb, block2.Number().String()); len(allTxsFromBlock) == 0 { -// t.Fatalf("GetAllTransactionsFromBlock [%v]: GetAllTransactionsFromBlock did not return correctly", allTxsFromBlock) -// } -// ClearTables() -//} -// -//func TestContractCreationTx(t *testing.T) { -// key, _ := crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") -// signer := types.NewEIP155Signer(big.NewInt(2147483647)) -// -// //Nonce,Value, GasLimit, Gasprice, data -// contractCreation := types.NewContractCreation(1, big.NewInt(111), 1111, big.NewInt(11111), []byte{0x11, 0x11, 0x11}) -// mytx,_ := types.SignTx(contractCreation, signer, key) -// txs := []*types.Transaction{mytx} -// -// receipt2 := &types.Receipt{ -// Status: types.ReceiptStatusSuccessful, -// CumulativeGasUsed: 1, -// Logs: []*types.Log{ -// {Address: common.BytesToAddress([]byte{0x11})}, -// {Address: common.BytesToAddress([]byte{0x01, 0x11})}, -// }, -// TxHash: common.BytesToHash([]byte{0x11, 0x11}), -// ContractAddress: common.BytesToAddress([]byte{0x01, 0x11, 0x11}), -// GasUsed: 111111, -// } -// -// receipts := []*types.Receipt{receipt2} -// block := types.NewBlock(&types.Header{Number: big.NewInt(314)}, txs, nil, receipts) -// -// if err := core.SWriteBlock(block, receipts); err != nil { -// t.Fatalf("Failed to write block into database: %v", err) -// } -// -// var contractAddressFromReciept string -// for _, receipt := range receipts { -// contractAddressFromReciept = (*types.ReceiptForStorage)(receipt).ContractAddress.String() -// } -// -// sqldb, err := core.DBConnection() -// if (err != nil) { -// panic(err) -// } -// -// for _, tx := range txs { -// txn := core.SGetTransaction(sqldb, tx.Hash().String()) -// byt := []byte(txn) -// var data core.ShyftTxEntryPretty -// json.Unmarshal(byt, &data) -// -// if tx.Hash().String() != data.TxHash { -// t.Fatalf("txHash [%v]: tx Hash not found", tx.Hash().String()) -// } -// if contractAddressFromReciept != data.To { -// t.Fatalf("Contract Addr [%v]: Contract addr not found", contractAddressFromReciept) -// } -// if tx.From().String() != data.From { -// t.Fatalf("From Addr [%v]: From addr not found", tx.From().String()) -// } -// if tx.Nonce() != data.Nonce { -// t.Fatalf("Nonce [%v]: Nonce not found", tx.Nonce()) -// } -// if tx.Gas() != data.Gas { -// t.Fatalf("Gas [%v]: Gas not found", tx.Gas()) -// } -// if tx.GasPrice().Uint64() != data.GasPrice { -// t.Fatalf("Gas Price [%v]: Gas price not found", tx.GasPrice().String()) -// } -// if block.GasLimit() != data.GasLimit { -// t.Fatalf("Gas Limit [%v]: Gas limit not found", block.GasLimit()) -// } -// if block.Hash().String() != data.BlockHash { -// t.Fatalf("Block Hash [%v]: Block hash not found", block.Hash().String()) -// } -// if block.Number().String() != data.BlockNumber { -// t.Fatalf("Block Number [%v]: Block number not found", block.Number().String()) -// } -// if tx.Value().String() != data.Amount { -// t.Fatalf("Amount [%v]: Amount not found", tx.Value().String()) -// } -// if tx.Cost().Uint64() != data.Cost { -// t.Fatalf("Cost [%v]: Cost not found", tx.Cost().String()) -// } -// var status string -// if receipt2.Status == 1 { -// status = "SUCCESS" -// } -// if receipt2.Status == 0 { -// status = "FAIL" -// } -// if status != data.Status { -// t.Fatalf("Receipt status [%v]: Receipt status not found", status) -// } -// var isContract bool -// if tx.To() != nil { -// isContract = false -// } else { -// isContract = true -// } -// if isContract != data.IsContract { -// t.Fatalf("isContract [%v]: isContract bool is incorrect", isContract) -// } -// } -// ClearTables() -//} -// -//func TestTransactionsToReturnTransactions(t *testing.T) { -// key, _ := crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") -// signer := types.NewEIP155Signer(big.NewInt(2147483647)) -// -// //Nonce, To Address,Value, GasLimit, Gasprice, data -// tx1 := types.NewTransaction(1, common.BytesToAddress([]byte{0x11}), big.NewInt(111), 1111, big.NewInt(11111), []byte{0x11, 0x11, 0x11}) -// mytx,_ := types.SignTx(tx1, signer, key) -// tx2 := types.NewTransaction(2, common.BytesToAddress([]byte{0x22}), big.NewInt(222), 2222, big.NewInt(22222), []byte{0x22, 0x22, 0x22}) -// mytx2,_ := types.SignTx(tx2, signer, key) -// tx3 := types.NewTransaction(3, common.BytesToAddress([]byte{0x33}), big.NewInt(333), 3333, big.NewInt(33333), []byte{0x33, 0x33, 0x33}) -// mytx3,_ := types.SignTx(tx3, signer, key) -// txs := []*types.Transaction{mytx, mytx2, mytx3} -// -// receipt1 := &types.Receipt{ -// Status: types.ReceiptStatusSuccessful, -// CumulativeGasUsed: 1, -// Logs: []*types.Log{ -// {Address: common.BytesToAddress([]byte{0x11})}, -// {Address: common.BytesToAddress([]byte{0x01, 0x11})}, -// }, -// TxHash: common.BytesToHash([]byte{0x11, 0x11}), -// ContractAddress: common.BytesToAddress([]byte{0x01, 0x11, 0x11}), -// GasUsed: 111111, -// } -// -// receipts := []*types.Receipt{receipt1} -// block := types.NewBlock(&types.Header{Number: big.NewInt(314)}, txs, nil, receipts) -// -// if err := core.SWriteBlock(block, receipts); err != nil { -// t.Fatalf("Failed to write block into database: %v", err) -// } -// sqldb, err := core.DBConnection() -// if (err != nil) { -// panic(err) -// } -// -// for _, tx := range txs { -// txn := core.SGetTransaction(sqldb, tx.Hash().String()) -// byt := []byte(txn) -// var data core.ShyftTxEntryPretty -// json.Unmarshal(byt, &data) -// -// //TODO age, data -// if tx.Hash().String() != data.TxHash { -// t.Fatalf("txHash [%v]: tx Hash not found", tx.Hash().String()) -// } -// if tx.From().String() != data.From { -// t.Fatalf("From Addr [%v]: From addr not found", tx.From().String()) -// } -// if tx.To().String() != data.To { -// t.Fatalf("To Addr [%v]: To addr not found", tx.To().String()) -// } -// if tx.Nonce() != data.Nonce { -// t.Fatalf("Nonce [%v]: Nonce not found", tx.Nonce()) -// } -// if tx.Gas() != data.Gas { -// t.Fatalf("Gas [%v]: Gas not found", tx.Gas()) -// } -// if tx.GasPrice().Uint64() != data.GasPrice { -// t.Fatalf("Gas Price [%v]: Gas price not found", tx.GasPrice().String()) -// } -// if block.GasLimit() != data.GasLimit { -// t.Fatalf("Gas Limit [%v]: Gas limit not found", block.GasLimit()) -// } -// if block.Hash().String() != data.BlockHash { -// t.Fatalf("Block Hash [%v]: Block hash not found", block.Hash().String()) -// } -// if block.Number().String() != data.BlockNumber { -// t.Fatalf("Block Number [%v]: Block number not found", block.Number().String()) -// } -// if tx.Value().String() != data.Amount { -// t.Fatalf("Amount [%v]: Amount not found", tx.Value().String()) -// } -// if tx.Cost().Uint64() != data.Cost { -// t.Fatalf("Cost [%v]: Cost not found", tx.Cost().String()) -// } -// var status string -// if receipt1.Status == 1 { -// status = "SUCCESS" -// } -// if receipt1.Status == 0 { -// status = "FAIL" -// } -// if status != data.Status { -// t.Fatalf("Receipt status [%v]: Receipt status not found", status) -// } -// var isContract bool -// if tx.To() != nil { -// isContract = false -// } else { -// isContract = true -// } -// if isContract != data.IsContract { -// t.Fatalf("isContract [%v]: isContract bool is incorrect", isContract) -// } -// } -// -// if getAllTx := core.SGetAllTransactions(sqldb); len(getAllTx) == 0 { -// t.Fatalf("GetAllTransactions [%v]: GetAllTransactions did not return correctly", getAllTx) -// } -// ClearTables() -//} -// -//func TestAccountsToReturnAccounts(t *testing.T) { -// key, _ := crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") -// signer := types.NewEIP155Signer(big.NewInt(2147483647)) -// -// //Nonce, To Address,Value, GasLimit, Gasprice, data -// tx1 := types.NewTransaction(1, common.BytesToAddress([]byte{0x11}), big.NewInt(111), 1111, big.NewInt(11111), []byte{0x11, 0x11, 0x11}) -// mytx,_ := types.SignTx(tx1, signer, key) -// tx2 := types.NewTransaction(2, common.BytesToAddress([]byte{0x22}), big.NewInt(222), 2222, big.NewInt(22222), []byte{0x22, 0x22, 0x22}) -// mytx2,_ := types.SignTx(tx2, signer, key) -// tx3 := types.NewTransaction(3, common.BytesToAddress([]byte{0x33}), big.NewInt(333), 3333, big.NewInt(33333), []byte{0x33, 0x33, 0x33}) -// mytx3,_ := types.SignTx(tx3, signer, key) -// txs := []*types.Transaction{mytx, mytx2, mytx3} -// -// receipt1 := &types.Receipt{ -// Status: types.ReceiptStatusSuccessful, -// CumulativeGasUsed: 1, -// Logs: []*types.Log{ -// {Address: common.BytesToAddress([]byte{0x11})}, -// {Address: common.BytesToAddress([]byte{0x01, 0x11})}, -// }, -// TxHash: common.BytesToHash([]byte{0x11, 0x11}), -// ContractAddress: common.BytesToAddress([]byte{0x01, 0x11, 0x11}), -// GasUsed: 111111, -// } -// -// receipts := []*types.Receipt{receipt1} -// block := types.NewBlock(&types.Header{Number: big.NewInt(315)}, txs, nil, receipts) -// if err := core.SWriteBlock(block, receipts); err != nil { -// t.Fatalf("Failed to write block into database: %v", err) -// } -// -// sqldb, err := core.DBConnection() -// if (err != nil) { -// panic(err) -// } -// -// -// for _, tx := range txs { -// accountAddrTo := core.SGetAccount(sqldb, tx.To().String()) -// byts := []byte(accountAddrTo) -// var accountDataTo core.SAccounts -// json.Unmarshal(byts, &accountDataTo) -// -// if tx.To().String() != accountDataTo.Addr { -// t.Fatalf("To address [%v]: To address not found", accountDataTo.Addr) -// } -// if tx.Value().String() != accountDataTo.Balance { -// t.Fatalf("To address balance [%v]: To address balance not found", accountDataTo.Balance) -// } -// if strconv.FormatUint(tx.Nonce(), 10) != accountDataTo.TxCountAccount { -// t.Fatalf("To account nonce [%v]: To account nonce not found", accountDataTo.TxCountAccount) -// } -// if getAllAccountTxs := core.SGetAccountTxs(sqldb, tx.To().String()); len(getAllAccountTxs) == 0 { -// t.Fatalf("GetAccountTxs [%v]: GetAccountTxs did not return correctly", getAllAccountTxs) -// } -// } -// -// if getAllAccounts := core.SGetAllAccounts(sqldb); len(getAllAccounts) == 0 { -// t.Fatalf("GetAllAccounts [%v]: GetAllAccounts did not return correctly", getAllAccounts) -// } -// ClearTables() -//} - - - From 1e38e2f577433dac90459ecf1da55baefac347ee Mon Sep 17 00:00:00 2001 From: Dustin Brickwood Date: Tue, 17 Jul 2018 11:04:06 -0400 Subject: [PATCH 21/21] fixed suggested changes --- .gitignore | 1 + console/console_test.go | 6 ++-- core/database_util.go | 3 -- core/db.go | 13 +++++--- core/shyft_database_util.go | 26 +++++++-------- eth/api_tracer.go | 3 +- internal/jsre/jsre.go | 2 -- shyftBlockExplorerApi/handler.go | 54 ++------------------------------ 8 files changed, 29 insertions(+), 79 deletions(-) diff --git a/.gitignore b/.gitignore index 3561546ca9..720b4764e5 100644 --- a/.gitignore +++ b/.gitignore @@ -51,3 +51,4 @@ $HOME shyftData/* shyft-cli/web3/token_test/node_modules shyft-cli/web3/transfer-through-master/node_modules +shyft-cli/web3/transfer-through-master/build diff --git a/console/console_test.go b/console/console_test.go index 8ff19c5ea1..2f334a1841 100644 --- a/console/console_test.go +++ b/console/console_test.go @@ -34,9 +34,9 @@ import ( "github.com/ethereum/go-ethereum/node" ) - const ( - testInstance = "console-tester" - testAddress = "0x8605cdbbdb6d264aa742e77020dcbc58fcdce182" +const ( + testInstance = "console-tester" + testAddress = "0x8605cdbbdb6d264aa742e77020dcbc58fcdce182" ) // hookedPrompter implements UserPrompter to simulate use input via channels. diff --git a/core/database_util.go b/core/database_util.go index 54572ac71b..ca179f6fe1 100644 --- a/core/database_util.go +++ b/core/database_util.go @@ -266,9 +266,6 @@ func GetBlockReceipts(db DatabaseReader, hash common.Hash, number uint64) types. // hash to allow retrieving the transaction or receipt by hash. func GetTxLookupEntry(db DatabaseReader, hash common.Hash) (common.Hash, uint64, uint64) { // Load the positional metadata from disk and bail if it fails - //fmt.Println("INSIDE GetTxLookupEntry ") - //fmt.Println("the db is ") - //fmt.Println(db) data, _ := db.Get(append(lookupPrefix, hash.Bytes()...)) if len(data) == 0 { return common.Hash{}, 0, 0 diff --git a/core/db.go b/core/db.go index ff63e3ee9e..48f86ac7a1 100644 --- a/core/db.go +++ b/core/db.go @@ -7,12 +7,16 @@ import ( var blockExplorerDb *sql.DB +const ( + connStr = "user=postgres dbname=shyftdb sslmode=disable" + connStrTest = "user=postgres dbname=shyftdbtest sslmode=disable" +) + func InitDB() (*sql.DB, error){ - var connStr = "user=postgres dbname=shyftdb sslmode=disable" db, err := sql.Open("postgres", connStr) if err != nil { fmt.Println("ERROR OPENING DB, NOT INITIALIZING") - fmt.Println(err) + panic(err) return nil, err } else { blockExplorerDb = db @@ -21,11 +25,10 @@ func InitDB() (*sql.DB, error){ } func InitDBTest() (*sql.DB, error){ - var connStr = "user=postgres dbname=shyftdbtest sslmode=disable" - db, err := sql.Open("postgres", connStr) + db, err := sql.Open("postgres", connStrTest) if err != nil { fmt.Println("ERROR OPENING DB, NOT INITIALIZING") - fmt.Println(err) + panic(err) return nil, err } else { blockExplorerDb = db diff --git a/core/shyft_database_util.go b/core/shyft_database_util.go index 52aa7e16e6..04f113c99b 100644 --- a/core/shyft_database_util.go +++ b/core/shyft_database_util.go @@ -118,7 +118,7 @@ func SWriteBlock(block *types.Block, receipts []*types.Receipt) error { panic(err) } - rewards := writeMinerRewards(sqldb,block) + rewards := swriteMinerRewards(sqldb,block) coinbase := block.Header().Coinbase.String() number := block.Header().Number.String() gasUsed := block.Header().GasUsed @@ -147,10 +147,10 @@ func SWriteBlock(block *types.Block, receipts []*types.Receipt) error { for _, tx := range block.Transactions() { SwriteTransactions(sqldb, tx, block.Header().Hash(), block.Header().Number.String(), receipts, age, gasLimit) if block.Transactions()[0].To() != nil { - writeFromBalance(sqldb, tx) + swriteFromBalance(sqldb, tx) } if block.Transactions()[0].To() == nil { - writeContractBalance(sqldb, tx) + swriteContractBalance(sqldb, tx) } } } @@ -232,7 +232,7 @@ func SwriteTransactions(sqldb *sql.DB, tx *types.Transaction, blockHash common.H return nil } -func writeContractBalance(sqldb *sql.DB, tx *types.Transaction) error { +func swriteContractBalance(sqldb *sql.DB, tx *types.Transaction) error { sendAndReceiveData := SendAndReceive{ From: tx.From().Hex(), Amount: tx.Value().String(), @@ -284,7 +284,7 @@ func writeContractBalance(sqldb *sql.DB, tx *types.Transaction) error { return nil } -func writeContractBalanceHelper(sqldb *sql.DB, tx *types.Transaction) (SendAndReceive, string, string) { +func swriteContractBalanceHelper(sqldb *sql.DB, tx *types.Transaction) (SendAndReceive, string, string) { sendAndReceiveData := SendAndReceive{ From: tx.From().Hex(), Amount: tx.Value().String(), @@ -304,8 +304,8 @@ func writeContractBalanceHelper(sqldb *sql.DB, tx *types.Transaction) (SendAndRe } //writeFromBalance writes senders balance to accounts db -func writeFromBalance(sqldb *sql.DB, tx *types.Transaction) error { - sendAndReceiveData, balanceRec, balanceSen, accountNonceRec, accountNonceSen := writeBalanceHelper(sqldb, tx) +func swriteFromBalance(sqldb *sql.DB, tx *types.Transaction) error { + sendAndReceiveData, balanceRec, balanceSen, accountNonceRec, accountNonceSen := swriteBalanceHelper(sqldb, tx) toAddr := sendAndReceiveData.To fromAddr := sendAndReceiveData.From amount := sendAndReceiveData.Amount @@ -377,7 +377,7 @@ func writeFromBalance(sqldb *sql.DB, tx *types.Transaction) error { return nil } -func writeBalanceHelper(sqldb *sql.DB, tx *types.Transaction) (SendAndReceive, string, string, string, string) { +func swriteBalanceHelper(sqldb *sql.DB, tx *types.Transaction) (SendAndReceive, string, string, string, string) { sendAndReceiveData := SendAndReceive{ To: tx.To().Hex(), From: tx.From().Hex(), @@ -412,7 +412,7 @@ func writeBalanceHelper(sqldb *sql.DB, tx *types.Transaction) (SendAndReceive, s // uncle blocks, account balance updates based on reorgs, diverges that get dropped. // Reason for this is because the accounts are not deterministic like the block and tx hashes. // @TODO: Calculate reorg -func writeMinerRewards(sqldb *sql.DB, block *types.Block) string { +func swriteMinerRewards(sqldb *sql.DB, block *types.Block) string { minerAddr := block.Coinbase().String() shyftConduitAddress := Rewards.ShyftNetworkConduitAddress.String() // Calculate the total gas used in the block @@ -442,13 +442,13 @@ func writeMinerRewards(sqldb *sql.DB, block *types.Block) string { uncleAddrs = append(uncleAddrs, uncle.Coinbase.String()) } - storeReward(sqldb, minerAddr, totalMinerReward) - storeReward(sqldb, shyftConduitAddress, Rewards.ShyftNetworkBlockReward) + sstoreReward(sqldb, minerAddr, totalMinerReward) + sstoreReward(sqldb, shyftConduitAddress, Rewards.ShyftNetworkBlockReward) var uncRewards = new(big.Int) for i := 0; i < len(uncleAddrs); i++ { uncRewards := uncleRewards[i] fmt.Println(uncRewards) - storeReward(sqldb, uncleAddrs[i], uncleRewards[i]) + sstoreReward(sqldb, uncleAddrs[i], uncleRewards[i]) } fullRewardValue := new(big.Int) @@ -458,7 +458,7 @@ func writeMinerRewards(sqldb *sql.DB, block *types.Block) string { return fullRewardValue.String() } -func storeReward(sqldb *sql.DB, address string, reward *big.Int) { +func sstoreReward(sqldb *sql.DB, address string, reward *big.Int) { // Check if address exists var addressBalance string addressExistsStatement := `SELECT balance from accounts WHERE addr = ($1)` diff --git a/eth/api_tracer.go b/eth/api_tracer.go index ea6c0556b6..e40bfe514c 100644 --- a/eth/api_tracer.go +++ b/eth/api_tracer.go @@ -124,7 +124,7 @@ func (api *PrivateDebugAPI) TraceChain(ctx context.Context, start, end rpc.Block // traceChain configures a new tracer according to the provided configuration, and // executes all the transactions contained within. The return value will be one item // per transaction, dependent on the requestd tracer. - func (api *PrivateDebugAPI) traceChain(ctx context.Context, start, end *types.Block, config *TraceConfig) (*rpc.Subscription, error) { +func (api *PrivateDebugAPI) traceChain(ctx context.Context, start, end *types.Block, config *TraceConfig) (*rpc.Subscription, error) { // Tracing a chain is a **long** operation, only do with subscriptions notifier, supported := rpc.NotifierFromContext(ctx) if !supported { @@ -532,7 +532,6 @@ func (api *PrivateDebugAPI) computeStateDB(block *types.Block, reexec uint64) (* // 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, hash common.Hash, config *TraceConfig) (interface{}, error) { - // NOTE:SHYFT tx, blockHash, _, index := core.GetTransaction(api.eth.ChainDb(), hash) if tx == nil { return nil, fmt.Errorf("transaction %x not found", hash) diff --git a/internal/jsre/jsre.go b/internal/jsre/jsre.go index 7a7ba2efc9..f05865eca6 100644 --- a/internal/jsre/jsre.go +++ b/internal/jsre/jsre.go @@ -188,8 +188,6 @@ loop: arguments = make([]interface{}, 1) } arguments[0] = timer.call.ArgumentList[0] - fmt.Println("The arguments are") - fmt.Println(arguments) _, err := vm.Call(`Function.call.call`, nil, arguments...) if err != nil { fmt.Println("js error:", err, arguments) diff --git a/shyftBlockExplorerApi/handler.go b/shyftBlockExplorerApi/handler.go index 9f368d6748..830b8999f2 100644 --- a/shyftBlockExplorerApi/handler.go +++ b/shyftBlockExplorerApi/handler.go @@ -18,11 +18,6 @@ import ( func GetTransaction(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) txHash := vars["txHash"] - //connStr := "user=postgres dbname=shyftdb sslmode=disable" - //blockExplorerDb, err := sql.Open("postgres", connStr) - //if err != nil { - // return - //} sqldb, err := core.DBConnection() getTxResponse := core.SGetTransaction(sqldb, txHash) @@ -39,11 +34,6 @@ func GetTransaction(w http.ResponseWriter, r *http.Request) { // GetAllTransactions gets txs func GetAllTransactions(w http.ResponseWriter, r *http.Request) { - //connStr := "user=postgres dbname=shyftdb sslmode=disable" - //blockExplorerDb, err := sql.Open("postgres", connStr) - //if err != nil { - // return - //} sqldb, err := core.DBConnection() @@ -54,7 +44,6 @@ func GetAllTransactions(w http.ResponseWriter, r *http.Request) { return } - w.Header().Set("Content-Type", "application/json; charset=UTF-8") w.WriteHeader(http.StatusOK) @@ -65,11 +54,6 @@ func GetAllTransactions(w http.ResponseWriter, r *http.Request) { func GetAllTransactionsFromBlock(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) blockNumber := vars["blockNumber"] - //connStr := "user=postgres dbname=shyftdb sslmode=disable" - //blockExplorerDb, err := sql.Open("postgres", connStr) - //if err != nil { - // return - //} sqldb, err := core.DBConnection() @@ -89,11 +73,6 @@ func GetAllTransactionsFromBlock(w http.ResponseWriter, r *http.Request) { func GetAllBlocksMinedByAddress(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) coinbase := vars["coinbase"] - //connStr := "user=postgres dbname=shyftdb sslmode=disable" - //blockExplorerDb, err := sql.Open("postgres", connStr) - //if err != nil { - // return - //} sqldb, err := core.DBConnection() @@ -114,11 +93,6 @@ func GetAllBlocksMinedByAddress(w http.ResponseWriter, r *http.Request) { func GetAccount(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) address := vars["address"] - //connStr := "user=postgres dbname=shyftdb sslmode=disable" - //blockExplorerDb, err := sql.Open("postgres", connStr) - //if err != nil { - // return - //} sqldb, err := core.DBConnection() @@ -139,11 +113,6 @@ func GetAccount(w http.ResponseWriter, r *http.Request) { func GetAccountTxs(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) address := vars["address"] - //connStr := "user=postgres dbname=shyftdb sslmode=disable" - //blockExplorerDb, err := sql.Open("postgres", connStr) - //if err != nil { - // return - //} sqldb, err := core.DBConnection() @@ -162,11 +131,6 @@ func GetAccountTxs(w http.ResponseWriter, r *http.Request) { // GetAllAccounts gets balances func GetAllAccounts(w http.ResponseWriter, r *http.Request) { - //connStr := "user=postgres dbname=shyftdb sslmode=disable" - //blockExplorerDb, err := sql.Open("postgres", connStr) - //if err != nil { - // return - //} sqldb, err := core.DBConnection() @@ -185,11 +149,7 @@ func GetAllAccounts(w http.ResponseWriter, r *http.Request) { func GetBlock(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) blockNumber := vars["blockNumber"] - //connStr := "user=postgres dbname=shyftdb sslmode=disable" - //blockExplorerDb, err := sql.Open("postgres", connStr) - //if err != nil { - // return - //} + sqldb, err := core.DBConnection() getBlockResponse := core.SGetBlock(sqldb, blockNumber) @@ -206,11 +166,7 @@ func GetBlock(w http.ResponseWriter, r *http.Request) { // GetAllBlocks response func GetAllBlocks(w http.ResponseWriter, r *http.Request) { - //connStr := "user=postgres dbname=shyftdb sslmode=disable" - //blockExplorerDb, err := sql.Open("postgres", connStr) - //if err != nil { - // return - //} + sqldb, err := core.DBConnection() block3 := core.SGetAllBlocks(sqldb) if err != nil { @@ -223,11 +179,7 @@ func GetAllBlocks(w http.ResponseWriter, r *http.Request) { } func GetRecentBlock(w http.ResponseWriter, r *http.Request) { - //connStr := "user=postgres dbname=shyftdb sslmode=disable" - //blockExplorerDb, err := sql.Open("postgres", connStr) - //if err != nil { - // return - //} + sqldb, err := core.DBConnection() mostRecentBlock := core.SGetRecentBlock(sqldb)