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
Show file tree
Hide file tree
Changes from 2 commits
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
3 changes: 1 addition & 2 deletions app.go
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,6 @@ func (a *Application) DeliverTx(txBytes []byte) abci.ResponseDeliverTx {
if a.EVMTracer != nil {
log.Debug("evm trace", "trace", a.EVMTracer)
}
Sriep marked this conversation as resolved.
Show resolved Hide resolved

txFailed = r.Code != abci.CodeTypeOK
// TODO: this isn't 100% reliable when txFailed == true
isEvmTx = r.Info == utils.CallEVM || r.Info == utils.DeployEvm
Expand Down Expand Up @@ -954,7 +953,7 @@ func (a *Application) ReplayApplication(blockNumber uint64, blockstore store.Blo
return nil, 0, errors.Errorf("no saved version for height %d", blockNumber)
}

splitStore := store.NewSplitStore(snapshot, store.NewMemStore(), startVersion-1)
splitStore := store.NewSplitStore(snapshot, startVersion-1)
factory := a.TxHandlerFactory.Copy(splitStore)
txHandle, err := factory.TxHandlerWithTracerAndDefaultVmManager(nil, false)
if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ type Config struct {
AllowNamedEvmContracts bool

// Dragons
EVMTracer *EVMTracer
EVMTracer *EVMTracerConfig
// Set to true to disable minimum required build number check on node startup
SkipMinBuildCheck bool

Expand All @@ -172,7 +172,7 @@ func DefaultFnConsensusConfig() *FnConsensusConfig {
}
}

type EVMTracer struct {
type EVMTracerConfig struct {
Enabled bool // enable tracer
Tracer string // enable JavaScript-based transaction tracing
DisableMemory bool // disable memory capture
Expand All @@ -181,8 +181,8 @@ type EVMTracer struct {
Limit int // maximum length of output, but zero means unlimited
}

func DefaultEvmTraceConfig() *EVMTracer {
return &EVMTracer{
func DefaultEvmTraceConfig() *EVMTracerConfig {
return &EVMTracerConfig{
Enabled: false,
}
}
Expand Down
3 changes: 3 additions & 0 deletions rpc/debug/trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@ func runTxsTo(app *loomchain.Application, blockstore store.BlockStore, startHeig
}

_ = app.EndBlock(requestEndBlock(h))

// todo we should really be matching the app hash returned here with the one that was
// stored in the next block, otherwise we can't really know if the replay was successful or not.
_ = app.Commit()
Sriep marked this conversation as resolved.
Show resolved Hide resolved
}
return nil, errors.Errorf("cannot find transaction at height %d index %d", height, index)
Expand Down
15 changes: 12 additions & 3 deletions store/splitstore.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package store

import (
"bytes"
"sort"

"github.com/loomnetwork/go-loom/plugin"
)

Expand All @@ -11,10 +14,10 @@ type splitStore struct {
version int64
}

func NewSplitStore(full KVReader, empty VersionedKVStore, version int64) VersionedKVStore {
func NewSplitStore(history KVReader, version int64) VersionedKVStore {
return &splitStore{
KVReader: full,
VersionedKVStore: empty,
KVReader: history,
VersionedKVStore: NewMemStore(),
deleted: make(map[string]bool),
version: version,
}
Expand All @@ -33,6 +36,12 @@ func (ss *splitStore) Get(key []byte) []byte {
func (ss *splitStore) Range(prefix []byte) plugin.RangeData {
readerRange := ss.KVReader.Range(prefix)
updateRange := ss.VersionedKVStore.Range(prefix)
Sriep marked this conversation as resolved.
Show resolved Hide resolved

// VersionedKVStore comes from a MemStore, hence updateRange is not deterministic
sort.Slice(updateRange, func(i, j int) bool {
return bytes.Compare(updateRange[i].Key, updateRange[j].Key) < 0
})

for _, re := range readerRange {
if !ss.VersionedKVStore.Has(re.Key) && !ss.deleted[string(re.Key)] {
updateRange = append(updateRange, re)
Sriep marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
2 changes: 1 addition & 1 deletion store/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ type SplitStoreTestSuite struct {

// runs before each test in this suite
func (ts *SplitStoreTestSuite) SetupTest() {
ts.store = NewSplitStore(NewMemStore(), NewMemStore(), 1)
ts.store = NewSplitStore(NewMemStore(), 1)
}

func (ts *SplitStoreTestSuite) SetupSuite() {
Expand Down