Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Impliments debug_traceTransaction #1573

Open
wants to merge 42 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
a443c17
debug_traceTransaction
Sriep Nov 7, 2019
d2f2656
external branch changes
Sriep Nov 7, 2019
ba6c0c5
remove comment, noevem
Sriep Nov 7, 2019
b24ae1f
noevem
Sriep Nov 7, 2019
9a17eba
noevem
Sriep Nov 7, 2019
31b9eaf
touch
Sriep Nov 7, 2019
25931d9
tg branch
Sriep Nov 7, 2019
5dad4a2
tg branch
Sriep Nov 7, 2019
621b9ef
unit tests, truffle test
Sriep Nov 7, 2019
7eef46a
unit tests
Sriep Nov 7, 2019
117a17c
try increase sleep
Sriep Nov 7, 2019
df96846
review issues
Sriep Nov 8, 2019
8deefbd
reeview issues,
Sriep Nov 11, 2019
9d4600e
config tracer
Sriep Nov 11, 2019
f49d7c6
truffle test
Sriep Nov 11, 2019
769672f
debug trace
Sriep Nov 11, 2019
895c456
truffle test
Sriep Nov 11, 2019
c556b04
fix vmmanager
Sriep Nov 12, 2019
d9d554c
fix
Sriep Nov 12, 2019
fcc157b
touch
Sriep Nov 12, 2019
cf52a2c
Merge remote-tracking branch 'remotes/origin/master' into ethdebug
Sriep Nov 13, 2019
a970270
touch
Sriep Nov 13, 2019
b1be5c7
test
Sriep Nov 13, 2019
8eee6c4
test
Sriep Nov 13, 2019
548f1d7
test
Sriep Nov 13, 2019
4826258
fix lint errors
Sriep Nov 13, 2019
7bcc26e
untest
Sriep Nov 13, 2019
571c9de
test
Sriep Nov 13, 2019
1a5f57f
noevm
Sriep Nov 13, 2019
8d60e39
debug_storagerangeat
Sriep Nov 14, 2019
66cf306
handle 0x
Sriep Nov 15, 2019
ffb7d75
fix
Sriep Nov 15, 2019
c5874bd
reciew issues
Sriep Nov 18, 2019
cb46125
debug_storageRangeAt
Sriep Nov 18, 2019
971d5cf
Merge remote-tracking branch 'remotes/origin/master' into ethdebug
Sriep Nov 18, 2019
05ddc25
review issues
Sriep Nov 19, 2019
51a8d62
range
Sriep Nov 19, 2019
a9777d0
review issues
Sriep Nov 21, 2019
4a27262
restore
Sriep Nov 21, 2019
bf28c5d
Merge remote-tracking branch 'remotes/origin/master' into ethdebug
Sriep Nov 27, 2019
d73f8e6
sort range
Sriep Nov 27, 2019
d98b4a5
touch
Sriep Nov 27, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix lint errors
  • Loading branch information
Sriep committed Nov 13, 2019
commit 482625800b5f51ec5637c5a866eeeafb8acd2c1c
7 changes: 3 additions & 4 deletions cmd/loom/gateway_reactors.go
Original file line number Diff line number Diff line change
@@ -15,10 +15,9 @@ import (
)

const (
GatewayName = "gateway"
LoomGatewayName = "loomcoin-gateway"
BinanceGatewayName = "binance-gateway"
TronGatewayName = "tron-gateway"
GatewayName = "gateway"
LoomGatewayName = "loomcoin-gateway"
TronGatewayName = "tron-gateway"
)

func startGatewayReactors(
20 changes: 0 additions & 20 deletions cmd/loom/loom.go
Original file line number Diff line number Diff line change
@@ -493,14 +493,6 @@ func contractInfoCommand() *cobra.Command {
return cmd
}

//nolint:deadcode
func recovery() {
if r := recover(); r != nil {
log.Error("caught RPC proxy exception, exiting", r)
os.Exit(1)
}
}

func startFeatureAutoEnabler(
chainID string, cfg *config.ChainConfigConfig, nodeSigner glAuth.Signer, node backend.Backend,
logger *loom.Logger,
@@ -1069,8 +1061,6 @@ func deployContract(

type contextFactory func(state loomchain.State) (contractpb.Context, error)

type staticContextFactory func(state loomchain.State) (contractpb.StaticContext, error)

func getContractCtx(pluginName string, vmManager *vm.Manager) contextFactory {
return func(state loomchain.State) (contractpb.Context, error) {
pvm, err := vmManager.InitVM(vm.VMType_PLUGIN, state)
@@ -1081,16 +1071,6 @@ func getContractCtx(pluginName string, vmManager *vm.Manager) contextFactory {
}
}

func getContractStaticCtx(pluginName string, vmManager *vm.Manager) staticContextFactory {
return func(state loomchain.State) (contractpb.StaticContext, error) {
pvm, err := vmManager.InitVM(vm.VMType_PLUGIN, state)
if err != nil {
return nil, err
}
return plugin.NewInternalContractContext(pluginName, pvm.(*plugin.PluginVM), true)
}
}

func initBackend(cfg *config.Config, abciServerAddr string, fnRegistry fnConsensus.FnRegistry) backend.Backend {
ovCfg := &backend.OverrideConfig{
LogLevel: cfg.BlockchainLogLevel,
10 changes: 5 additions & 5 deletions eth/polls/polls_test.go
Original file line number Diff line number Diff line change
@@ -29,9 +29,8 @@ var (
)

const (
deployId = uint32(1)
callId = uint32(2)
migrationTx = uint32(3)
deployId = uint32(1)
callId = uint32(2)
)

func TestLogPoll(t *testing.T) {
@@ -248,7 +247,7 @@ func testTimeout(t *testing.T, version handler.ReceiptHandlerVersion) {
state40 := common.MockStateAt(state, uint64(40))
_ = sub.AddTxPoll(uint64(40))

result, err = sub.LegacyPoll(state40, id, receiptHandler)
_, err = sub.LegacyPoll(state40, id, receiptHandler)
require.Error(t, err, "poll did not timed out")
require.NoError(t, receiptHandler.Close())
}
@@ -360,6 +359,7 @@ func TestAddRemove(t *testing.T) {
Topics: nil,
}
myFilter, err := eth.DecLogFilter(jsonFilter)
require.NoError(t, err)
id, err := s.AddLogPoll(myFilter, 1)
require.NoError(t, err)
_, ok := s.polls[id]
@@ -407,6 +407,6 @@ func mockSignedTx(t *testing.T, id uint32, to loom.Address, from loom.Address, d
signedTx, err := proto.Marshal(&auth.SignedTx{
Inner: nonceTx,
})

require.NoError(t, err)
return signedTx
}
3 changes: 3 additions & 0 deletions eth/query/tx.go
Original file line number Diff line number Diff line change
@@ -38,6 +38,9 @@ func GetTxByBlockAndIndex(
iHeight := int64(height)

blockResult, err := blockStore.GetBlockByHeight(&iHeight)
if err != nil {
return eth.GetEmptyTxObject(), errors.Errorf("error getting block for height %v", height)
}
if blockResult == nil || blockResult.Block == nil {
return eth.GetEmptyTxObject(), errors.Errorf("no block results found at height %v", height)
}
26 changes: 0 additions & 26 deletions evm/evm.go
Original file line number Diff line number Diff line change
@@ -302,32 +302,6 @@ func defaultChainConfig(enableConstantinople bool) params.ChainConfig {
}
}

func defaultVmConfig() vm.Config {
logCfg := vm.LogConfig{
DisableMemory: true, // disable memory capture
DisableStack: true, // disable stack capture
DisableStorage: true, // disable storage capture
Limit: 0, // maximum length of output, but zero means unlimited
}

logger := vm.NewStructLogger(&logCfg)
return vm.Config{
// Debug enabled debugging Interpreter options
Debug: false,
// Tracer is the op code logger
Tracer: logger,
// NoRecursion disabled Interpreter call, callcode,
// delegate call and create.
NoRecursion: false,
// Enable recording of SHA3/keccak preimages
EnablePreimageRecording: true, //TODO: make this optional, [MGC] I don't think we need to keep this
// JumpTable contains the EVM instruction table. This
// may be left uninitialised and will be set to the default
// table.
//JumpTable: [256]operation,
}
}

func createVmConfig(tracer vm.Tracer) (vm.Config, error) {
if tracer == nil {
logCfg := vm.LogConfig{
2 changes: 1 addition & 1 deletion plugin/external.go
Original file line number Diff line number Diff line change
@@ -30,7 +30,7 @@ func (f *FileNameInfo) String() string {
return f.Base + f.Ext + f.Version
}

var fileInfoRE = regexp.MustCompile("(.+?)(\\.[a-zA-Z]+?)?\\.([0-9\\.]+)")
var fileInfoRE = regexp.MustCompile(`(.+?)(\.[a-zA-Z]+?)?\.([0-9\.]+)`)

func parseFileName(name string) (*FileNameInfo, error) {
groups := fileInfoRE.FindSubmatch([]byte(name))
2 changes: 1 addition & 1 deletion plugin/loader.go
Original file line number Diff line number Diff line change
@@ -121,7 +121,7 @@ func (m *StaticLoader) LoadContract(name string, blockHeight int64) (plugin.Cont
}

func (m *StaticLoader) findOverride(name string, blockHeight int64) plugin.Contract {
if overrides, _ := m.overrides[name]; overrides != nil {
if overrides := m.overrides[name]; overrides != nil {
for i := len(overrides) - 1; i >= 0; i-- {
if blockHeight >= overrides[i].BlockHeight {
return overrides[i].Contract
17 changes: 2 additions & 15 deletions receipts/leveldb/leveldb_test.go
Original file line number Diff line number Diff line change
@@ -2,15 +2,15 @@ package leveldb

import (
"bytes"
"fmt"
"os"
"testing"

"github.com/gogo/protobuf/proto"
"github.com/loomnetwork/go-loom/plugin/types"
"github.com/stretchr/testify/require"

"github.com/loomnetwork/loomchain/receipts/common"
evmaux "github.com/loomnetwork/loomchain/store/evm_aux"
"github.com/stretchr/testify/require"
)

const (
@@ -173,19 +173,6 @@ func TestConfirmTransactionReceipts(t *testing.T) {
require.Error(t, err)
}

//nolint:deadcode
func dumpDbEntries(evmAuxStore *evmaux.EvmAuxStore) error {
fmt.Println("\nDumping leveldb")
db := evmAuxStore.DB()
iter := db.NewIterator(nil, nil)
defer iter.Release()
for iter.Next() {
fmt.Printf("key %s\t\tvalue %s", iter.Key(), iter.Value())
}
fmt.Println()
return iter.Error()
}

func countDbEntries(evmAuxStore *evmaux.EvmAuxStore) (uint64, error) {
count := uint64(0)
db := evmAuxStore.DB()
2 changes: 1 addition & 1 deletion registry/v1/registry.go
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@ const (
)

var (
validNameRE = regexp.MustCompile("^[a-zA-Z0-9\\.\\-]+$")
validNameRE = regexp.MustCompile(`^[a-zA-Z0-9\.\-]+$`)
)

func recordKey(name string) []byte {
2 changes: 1 addition & 1 deletion registry/v2/registry.go
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@ const (
)

var (
validNameRE = regexp.MustCompile("^[a-zA-Z0-9\\.\\-]+$")
validNameRE = regexp.MustCompile(`^[a-zA-Z0-9\.\-]+$`)

// Store Keys
contractAddrKeyPrefix = []byte("reg_caddr")
23 changes: 20 additions & 3 deletions store/block_store_cache_test.go
Original file line number Diff line number Diff line change
@@ -220,7 +220,13 @@ func TestBlockFetchAtHeight2Q(t *testing.T) {
//request for a block for nil height, maximum height data is returned and cached
blockstoreData, err = cachedblockStore.GetBlockByHeight(nil)
require.NoError(t, err, "Gives maximum height block")
require.Equal(t, int64(50), blockstoreData.Block.Height, "Expecting blockstore height 50 as maximum height block is fetched,this is default functionality of corresponding tendermint blockstore API also")
require.Equal(
t,
int64(50),
blockstoreData.Block.Height,
"Expecting blockstore height 50 as maximum height block is fetched,this is default"+
"functionality of corresponding tendermint blockstore API also",
)

//block at maximum height present in cache
_, ok = cachedblockStore.TwoQueueCache.Get(height)
@@ -249,7 +255,12 @@ func TestGetBlockRangeByHeight2Q(t *testing.T) {

//Blocks returned by MockBlockStore are verified for data accuracy
for i := minheight; i <= maxheight; i++ {
require.Equal(t, int64(i), int64(blockrangeData.BlockMetas[i-1].Header.Height), "Expecting height field in blockMetas equal height supplied to API for accuracy check,Expecting Data from API")
require.Equal(
t,
int64(i),
int64(blockrangeData.BlockMetas[i-1].Header.Height),
"Expecting height field in blockMetas equal height supplied to API for accuracy check,Expecting Data from API",
)
}

//Block infos in above provided height range gets cached resulting in cache hit for each height in height range
@@ -264,7 +275,13 @@ func TestGetBlockRangeByHeight2Q(t *testing.T) {

//Blocks returned by Cached are verified for data accuracy
for i := minheight; i <= maxheight; i++ {
require.Equal(t, int64(i), int64(blockrangeData.BlockMetas[i-1].Header.Height), "Expecting Data from Cache,Expecting height field in blockMetas equal height supplied to API for Cache accuracy check")
require.Equal(
t,
int64(i),
int64(blockrangeData.BlockMetas[i-1].Header.Height),
"Expecting Data from Cache,Expecting height field in blockMetas equal height"+
" supplied to API for Cache accuracy check",
)
}

//request for blockinfo for height range where max height is greater than maximum height of blockchain, error is returned by Cache, caching occurs till max height of blockchain
22 changes: 2 additions & 20 deletions store/pruning_iavlstore.go
Original file line number Diff line number Diff line change
@@ -2,18 +2,18 @@ package store

import (
"fmt"
"runtime"
"sync"
"time"

"github.com/go-kit/kit/metrics"
kitprometheus "github.com/go-kit/kit/metrics/prometheus"
"github.com/loomnetwork/go-loom"
"github.com/loomnetwork/go-loom/plugin"
"github.com/loomnetwork/loomchain/log"
"github.com/pkg/errors"
stdprometheus "github.com/prometheus/client_golang/prometheus"
dbm "github.com/tendermint/tendermint/libs/db"

"github.com/loomnetwork/loomchain/log"
)

var (
@@ -234,24 +234,6 @@ func (s *PruningIAVLStore) deleteVersion(ver int64) error {
return err
}

// runWithRecovery should run in a goroutine, it will ensure the given function keeps on running in
// a goroutine as long as it doesn't panic due to a runtime error.
//[MGC] I believe this function shouldn't be used as we should just fail fast if this breaks
func (s *PruningIAVLStore) runWithRecovery(run func()) {
defer func() {
if r := recover(); r != nil {
s.logger.Error("Recovered from panic in PruningIAVLStore goroutine", "r", r)
// Unless it's a runtime error restart the goroutine
if _, ok := r.(runtime.Error); !ok {
time.Sleep(30 * time.Second)
s.logger.Info("Restarting PruningIAVLStore goroutine...\n")
go s.runWithRecovery(run)
}
}
}()
run()
}

// loopWithInterval will execute the step function in an endless loop, sleeping for the specified
// interval at the end of each loop iteration.
func (s *PruningIAVLStore) loopWithInterval(step func() error, interval time.Duration) {