Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
baas-ide
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guxukai
baas-ide
Commits
ea29683c
Commit
ea29683c
authored
Jun 27, 2016
by
yann300
Committed by
GitHub
Jun 27, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #42 from yann300/ui
display storage changes instead of full storage
parents
60037e97
efdb3378
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
35 additions
and
24 deletions
+35
-24
Ethdebugger.js
src/Ethdebugger.js
+3
-5
StoragePanel.js
src/StoragePanel.js
+1
-1
TxBrowser.js
src/TxBrowser.js
+2
-3
traceManager.js
src/trace/traceManager.js
+14
-4
traceRetriever.js
src/trace/traceRetriever.js
+7
-3
codeManager.js
test/codeManager.js
+3
-3
traceManager.js
test/traceManager.js
+5
-5
No files found.
src/Ethdebugger.js
View file @
ea29683c
...
...
@@ -69,12 +69,10 @@ Ethdebugger.prototype.startDebugging = function (blockNumber, txIndex, tx) {
console
.
log
(
'loading trace...'
)
this
.
tx
=
tx
var
self
=
this
this
.
traceManager
.
resolveTrace
(
tx
,
function
(
success
)
{
console
.
log
(
'trace loaded '
+
success
)
if
(
success
)
{
this
.
traceManager
.
resolveTrace
(
tx
,
function
(
error
,
result
)
{
console
.
log
(
'trace loaded '
+
result
+
' '
+
error
)
if
(
result
)
{
self
.
trigger
(
'newTraceLoaded'
)
}
else
{
console
.
log
(
'trace not loaded'
)
}
})
}
...
...
src/StoragePanel.js
View file @
ea29683c
...
...
@@ -5,7 +5,7 @@ var yo = require('yo-yo')
function
StoragePanel
(
_parent
,
_traceManager
)
{
this
.
parent
=
_parent
this
.
traceManager
=
_traceManager
this
.
basicPanel
=
new
BasicPanel
(
'Storage'
)
this
.
basicPanel
=
new
BasicPanel
(
'Storage
Changes
'
)
this
.
init
()
}
...
...
src/TxBrowser.js
View file @
ea29683c
...
...
@@ -19,9 +19,8 @@ function TxBrowser (_web3) {
this
.
setDefaultValues
()
}
// 0xcda2b2835add61af54cf83bd076664d98d7908c6cd98d86423b3b48d8b8e51ff
// creation 0xa9619e1d0a35b2c1d686f5b661b3abd87f998d2844e8e9cc905edb57fc9ce349
// invokation 0x71a6d583d16d142c5c3e8903060e8a4ee5a5016348a9448df6c3e63b68076ec4
// invokation 0x71a6d583d16d142c5c3e8903060e8a4ee5a5016348a9448df6c3e63b68076ec4
0xcda2b2835add61af54cf83bd076664d98d7908c6cd98d86423b3b48d8b8e51ff
// test:
// creation: 0x72908de76f99fca476f9e3a3b5d352f350a98cd77d09cebfc59ffe32a6ecaa0b
// invokation: 0x20ef65b8b186ca942fcccd634f37074dde49b541c27994fc7596740ef44cfd51
...
...
@@ -31,7 +30,7 @@ TxBrowser.prototype.setDefaultValues = function () {
this
.
to
=
' - '
this
.
hash
=
' - '
this
.
blockNumber
=
null
this
.
txNumber
=
'0x
71a6d583d16d142c5c3e8903060e8a4ee5a5016348a9448df6c3e63b68076ec4
'
this
.
txNumber
=
'0x
cda2b2835add61af54cf83bd076664d98d7908c6cd98d86423b3b48d8b8e51ff
'
}
TxBrowser
.
prototype
.
submit
=
function
()
{
...
...
src/trace/traceManager.js
View file @
ea29683c
...
...
@@ -20,13 +20,14 @@ function TraceManager (_web3) {
TraceManager
.
prototype
.
resolveTrace
=
function
(
tx
,
callback
)
{
this
.
tx
=
tx
this
.
init
()
if
(
!
this
.
web3
)
callback
(
false
)
if
(
!
this
.
web3
)
callback
(
'web3 not loaded'
,
false
)
this
.
isLoading
=
true
var
self
=
this
this
.
traceRetriever
.
getTrace
(
tx
.
hash
,
function
(
error
,
result
)
{
if
(
error
)
{
console
.
log
(
error
)
self
.
isLoading
=
false
callback
(
error
,
false
)
}
else
{
if
(
result
.
structLogs
.
length
>
0
)
{
self
.
trace
=
result
.
structLogs
...
...
@@ -34,15 +35,17 @@ TraceManager.prototype.resolveTrace = function (tx, callback) {
if
(
error
)
{
self
.
isLoading
=
false
console
.
log
(
error
)
callback
(
false
)
callback
(
error
,
false
)
}
else
{
self
.
isLoading
=
false
callback
(
true
)
callback
(
null
,
true
)
}
})
}
else
{
console
.
log
(
tx
.
hash
+
' is not a contract invokation or contract creation.'
)
var
mes
=
tx
.
hash
+
' is not a contract invokation or contract creation.'
console
.
log
(
mes
)
self
.
isLoading
=
false
callback
(
mes
,
false
)
}
}
})
...
...
@@ -77,6 +80,12 @@ TraceManager.prototype.getStorageAt = function (stepIndex, tx, callback) {
}
var
stoChange
=
traceHelper
.
findLowerBound
(
stepIndex
,
this
.
traceCache
.
storageChanges
)
if
(
stoChange
===
undefined
)
return
callback
(
'no storage found'
,
null
)
var
address
=
this
.
traceCache
.
sstore
[
stoChange
].
address
var
storage
=
{}
storage
=
this
.
traceCache
.
rebuildStorage
(
address
,
storage
,
stepIndex
)
callback
(
null
,
storage
)
/*
// TODO: use it if we need the full storage to be loaded
var self = this
if (this.traceRetriever.debugStorageAtAvailable()) {
var address = this.traceCache.sstore[stoChange].address
...
...
@@ -92,6 +101,7 @@ TraceManager.prototype.getStorageAt = function (stepIndex, tx, callback) {
} else {
callback(null, this.trace[stoChange].storage)
}
*/
}
TraceManager
.
prototype
.
getCallDataAt
=
function
(
stepIndex
,
callback
)
{
...
...
src/trace/traceRetriever.js
View file @
ea29683c
...
...
@@ -8,10 +8,10 @@ function TraceRetriever (_web3) {
TraceRetriever
.
prototype
.
getTrace
=
function
(
txHash
,
callback
)
{
var
options
=
{
disableStorage
:
t
his
.
debugStorageAtAvailable
()
,
disableStorage
:
t
rue
,
disableMemory
:
false
,
disableStack
:
false
,
fullStorage
:
false
// !this.debugStorageAtAvailable()
fullStorage
:
false
}
this
.
web3
.
debug
.
traceTransaction
(
txHash
,
options
,
function
(
error
,
result
)
{
callback
(
error
,
result
)
...
...
@@ -24,16 +24,20 @@ TraceRetriever.prototype.getStorage = function (tx, address, callback) {
}
else
if
(
this
.
storages
[
address
])
{
callback
(
null
,
this
.
storages
[
address
])
}
else
{
// we always return an empty storage ... storage changes will be displayed instead of the full contract storage
callback
(
null
,
{})
/*
var self = this
this.web3.debug.storageAt(tx.blockNumber.toString(), tx.transactionIndex, address, function (error, result) {
self.storages[address] = result
callback(error, result)
})
*/
}
}
TraceRetriever
.
prototype
.
debugStorageAtAvailable
=
function
()
{
return
this
.
web3
.
version
.
node
.
toLowerCase
().
indexOf
(
'geth'
)
===
-
1
// storageAt not available if using geth
return
false
//
this.web3.version.node.toLowerCase().indexOf('geth') === -1 // storageAt not available if using geth
}
module
.
exports
=
TraceRetriever
test/codeManager.js
View file @
ea29683c
...
...
@@ -14,9 +14,9 @@ tape('CodeManager', function (t) {
traceManager
.
traceRetriever
=
new
TestTraceRetriever
()
codeManager
=
new
CodeManager
(
web3
,
traceManager
)
codeManager
.
codeResolver
.
cacheExecutingCode
(
'0x0d3a18d64dfe4f927832ab58d6451cecc4e517c5'
,
contractCode
)
// so a call to web3 is not necessary
traceManager
.
resolveTrace
(
txInvokation
,
function
(
success
)
{
if
(
!
success
)
{
t
.
fail
(
' - traceManager.resolveTrace - failed
'
)
traceManager
.
resolveTrace
(
txInvokation
,
function
(
error
,
result
)
{
if
(
error
)
{
t
.
fail
(
' - traceManager.resolveTrace - failed
'
+
result
)
}
else
{
continueTesting
(
t
,
codeManager
)
}
...
...
test/traceManager.js
View file @
ea29683c
...
...
@@ -16,9 +16,9 @@ tape('TraceManager', function (t) {
})
t
.
test
(
'TraceManager.resolveTrace'
,
function
(
st
)
{
traceManager
.
resolveTrace
(
txInvokation
,
function
(
success
)
{
if
(
!
success
)
{
st
.
fail
(
' - traceManager.resolveTrace - failed
'
)
traceManager
.
resolveTrace
(
txInvokation
,
function
(
error
,
result
)
{
if
(
error
)
{
st
.
fail
(
' - traceManager.resolveTrace - failed
'
+
result
)
}
else
{
st
.
end
()
}
...
...
@@ -44,11 +44,11 @@ tape('TraceManager', function (t) {
})
t
.
test
(
'TraceManager.getStorageAt'
,
function
(
st
)
{
traceManager
.
getStorageAt
(
0
,
txInvokation
,
function
(
error
,
result
)
{
traceManager
.
getStorageAt
(
11
0
,
txInvokation
,
function
(
error
,
result
)
{
if
(
error
)
{
st
.
fail
(
error
)
}
else
{
st
.
ok
(
result
[
'0x00'
]
===
'0x
2d
'
)
st
.
ok
(
result
[
'0x00'
]
===
'0x
38
'
)
st
.
end
()
}
})
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment