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
52fc1540
Commit
52fc1540
authored
Jun 27, 2016
by
yann300
Committed by
GitHub
Jun 27, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into yann300-patch-3
parents
6e64e2d7
69feb2dd
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
64 additions
and
26 deletions
+64
-26
Ethdebugger.js
src/Ethdebugger.js
+3
-5
StoragePanel.js
src/StoragePanel.js
+1
-1
TxBrowser.js
src/TxBrowser.js
+27
-5
init.js
src/helpers/init.js
+4
-0
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 @
52fc1540
...
@@ -69,12 +69,10 @@ Ethdebugger.prototype.startDebugging = function (blockNumber, txIndex, tx) {
...
@@ -69,12 +69,10 @@ Ethdebugger.prototype.startDebugging = function (blockNumber, txIndex, tx) {
console
.
log
(
'loading trace...'
)
console
.
log
(
'loading trace...'
)
this
.
tx
=
tx
this
.
tx
=
tx
var
self
=
this
var
self
=
this
this
.
traceManager
.
resolveTrace
(
tx
,
function
(
success
)
{
this
.
traceManager
.
resolveTrace
(
tx
,
function
(
error
,
result
)
{
console
.
log
(
'trace loaded '
+
success
)
console
.
log
(
'trace loaded '
+
result
+
' '
+
error
)
if
(
success
)
{
if
(
result
)
{
self
.
trigger
(
'newTraceLoaded'
)
self
.
trigger
(
'newTraceLoaded'
)
}
else
{
console
.
log
(
'trace not loaded'
)
}
}
})
})
}
}
...
...
src/StoragePanel.js
View file @
52fc1540
...
@@ -5,7 +5,7 @@ var yo = require('yo-yo')
...
@@ -5,7 +5,7 @@ var yo = require('yo-yo')
function
StoragePanel
(
_parent
,
_traceManager
)
{
function
StoragePanel
(
_parent
,
_traceManager
)
{
this
.
parent
=
_parent
this
.
parent
=
_parent
this
.
traceManager
=
_traceManager
this
.
traceManager
=
_traceManager
this
.
basicPanel
=
new
BasicPanel
(
'Storage'
)
this
.
basicPanel
=
new
BasicPanel
(
'Storage
Changes
'
)
this
.
init
()
this
.
init
()
}
}
...
...
src/TxBrowser.js
View file @
52fc1540
...
@@ -4,6 +4,7 @@ var EventManager = require('./lib/eventManager')
...
@@ -4,6 +4,7 @@ var EventManager = require('./lib/eventManager')
var
traceHelper
=
require
(
'./helpers/traceHelper'
)
var
traceHelper
=
require
(
'./helpers/traceHelper'
)
var
yo
=
require
(
'yo-yo'
)
var
yo
=
require
(
'yo-yo'
)
var
ui
=
require
(
'./helpers/ui'
)
var
ui
=
require
(
'./helpers/ui'
)
var
init
=
require
(
'./helpers/init'
)
function
TxBrowser
(
_web3
)
{
function
TxBrowser
(
_web3
)
{
util
.
extend
(
this
,
new
EventManager
())
util
.
extend
(
this
,
new
EventManager
())
...
@@ -19,9 +20,8 @@ function TxBrowser (_web3) {
...
@@ -19,9 +20,8 @@ function TxBrowser (_web3) {
this
.
setDefaultValues
()
this
.
setDefaultValues
()
}
}
// 0xcda2b2835add61af54cf83bd076664d98d7908c6cd98d86423b3b48d8b8e51ff
// creation 0xa9619e1d0a35b2c1d686f5b661b3abd87f998d2844e8e9cc905edb57fc9ce349
// creation 0xa9619e1d0a35b2c1d686f5b661b3abd87f998d2844e8e9cc905edb57fc9ce349
// invokation 0x71a6d583d16d142c5c3e8903060e8a4ee5a5016348a9448df6c3e63b68076ec4
// invokation 0x71a6d583d16d142c5c3e8903060e8a4ee5a5016348a9448df6c3e63b68076ec4
0xcda2b2835add61af54cf83bd076664d98d7908c6cd98d86423b3b48d8b8e51ff
// test:
// test:
// creation: 0x72908de76f99fca476f9e3a3b5d352f350a98cd77d09cebfc59ffe32a6ecaa0b
// creation: 0x72908de76f99fca476f9e3a3b5d352f350a98cd77d09cebfc59ffe32a6ecaa0b
// invokation: 0x20ef65b8b186ca942fcccd634f37074dde49b541c27994fc7596740ef44cfd51
// invokation: 0x20ef65b8b186ca942fcccd634f37074dde49b541c27994fc7596740ef44cfd51
...
@@ -31,7 +31,9 @@ TxBrowser.prototype.setDefaultValues = function () {
...
@@ -31,7 +31,9 @@ TxBrowser.prototype.setDefaultValues = function () {
this
.
to
=
' - '
this
.
to
=
' - '
this
.
hash
=
' - '
this
.
hash
=
' - '
this
.
blockNumber
=
null
this
.
blockNumber
=
null
this
.
txNumber
=
'0x71a6d583d16d142c5c3e8903060e8a4ee5a5016348a9448df6c3e63b68076ec4'
this
.
txNumber
=
'0xcda2b2835add61af54cf83bd076664d98d7908c6cd98d86423b3b48d8b8e51ff'
this
.
connectInfo
=
''
this
.
checkWeb3
()
}
}
TxBrowser
.
prototype
.
submit
=
function
()
{
TxBrowser
.
prototype
.
submit
=
function
()
{
...
@@ -67,6 +69,22 @@ TxBrowser.prototype.submit = function () {
...
@@ -67,6 +69,22 @@ TxBrowser.prototype.submit = function () {
yo
.
update
(
this
.
view
,
this
.
render
())
yo
.
update
(
this
.
view
,
this
.
render
())
}
}
TxBrowser
.
prototype
.
updateWeb3Url
=
function
(
ev
)
{
init
.
setProvider
(
this
.
web3
,
ev
.
target
.
value
)
this
.
checkWeb3
()
yo
.
update
(
this
.
view
,
this
.
render
())
}
TxBrowser
.
prototype
.
checkWeb3
=
function
()
{
try
{
console
.
log
(
'block '
+
this
.
web3
.
eth
.
blockNumber
)
this
.
connectInfo
=
'Connected to '
+
this
.
web3
.
currentProvider
.
host
}
catch
(
e
)
{
console
.
log
(
e
)
this
.
connectInfo
=
e
.
message
}
}
TxBrowser
.
prototype
.
updateBlockN
=
function
(
ev
)
{
TxBrowser
.
prototype
.
updateBlockN
=
function
(
ev
)
{
this
.
blockNumber
=
ev
.
target
.
value
this
.
blockNumber
=
ev
.
target
.
value
}
}
...
@@ -83,8 +101,12 @@ TxBrowser.prototype.init = function (ev) {
...
@@ -83,8 +101,12 @@ TxBrowser.prototype.init = function (ev) {
TxBrowser
.
prototype
.
render
=
function
()
{
TxBrowser
.
prototype
.
render
=
function
()
{
var
self
=
this
var
self
=
this
var
view
=
yo
`<div style=
${
ui
.
formatCss
(
style
.
container
)}
>
var
view
=
yo
`<div style=
${
ui
.
formatCss
(
style
.
container
)}
>
<input onchange=
${
function
()
{
self
.
updateBlockN
(
arguments
[
0
])
}
} type='text' placeholder=
${
'Block number (default 1000110)'
+
this
.
blockNumber
}
></input>
<span>Node URL: </span><input onkeyup=
${
function
()
{
self
.
updateWeb3Url
(
arguments
[
0
])
}
} value=
${
this
.
web3
.
currentProvider
?
this
.
web3
.
currentProvider
.
host
:
' - none - '
}
type='text' />
<input onchange=
${
function
()
{
self
.
updateTxN
(
arguments
[
0
])
}
} type='text' value=
${
this
.
txNumber
}
placeholder=
${
'Transaction Number or hash (default 2) '
+
this
.
txNumber
}
></input>
<span>
${
this
.
connectInfo
}
</span>
<br />
<br />
<input onkeyup=
${
function
()
{
self
.
updateBlockN
(
arguments
[
0
])
}
} type='text' placeholder=
${
'Block number (default 1000110)'
+
this
.
blockNumber
}
/>
<input onkeyup=
${
function
()
{
self
.
updateTxN
(
arguments
[
0
])
}
} type='text' value=
${
this
.
txNumber
}
placeholder=
${
'Transaction Number or hash (default 2) '
+
this
.
txNumber
}
/>
<button onclick=
${
function
()
{
self
.
submit
()
}
}>
<button onclick=
${
function
()
{
self
.
submit
()
}
}>
Get
Get
</button>
</button>
...
...
src/helpers/init.js
View file @
52fc1540
...
@@ -8,5 +8,9 @@ module.exports = {
...
@@ -8,5 +8,9 @@ module.exports = {
web3
.
setProvider
(
new
web3
.
providers
.
HttpProvider
(
'http://localhost:8545'
))
web3
.
setProvider
(
new
web3
.
providers
.
HttpProvider
(
'http://localhost:8545'
))
Web3Admin
.
extend
(
web3
)
Web3Admin
.
extend
(
web3
)
return
web3
return
web3
},
setProvider
:
function
(
web3
,
url
)
{
web3
.
setProvider
(
new
web3
.
providers
.
HttpProvider
(
url
))
}
}
}
}
src/trace/traceManager.js
View file @
52fc1540
...
@@ -20,13 +20,14 @@ function TraceManager (_web3) {
...
@@ -20,13 +20,14 @@ function TraceManager (_web3) {
TraceManager
.
prototype
.
resolveTrace
=
function
(
tx
,
callback
)
{
TraceManager
.
prototype
.
resolveTrace
=
function
(
tx
,
callback
)
{
this
.
tx
=
tx
this
.
tx
=
tx
this
.
init
()
this
.
init
()
if
(
!
this
.
web3
)
callback
(
false
)
if
(
!
this
.
web3
)
callback
(
'web3 not loaded'
,
false
)
this
.
isLoading
=
true
this
.
isLoading
=
true
var
self
=
this
var
self
=
this
this
.
traceRetriever
.
getTrace
(
tx
.
hash
,
function
(
error
,
result
)
{
this
.
traceRetriever
.
getTrace
(
tx
.
hash
,
function
(
error
,
result
)
{
if
(
error
)
{
if
(
error
)
{
console
.
log
(
error
)
console
.
log
(
error
)
self
.
isLoading
=
false
self
.
isLoading
=
false
callback
(
error
,
false
)
}
else
{
}
else
{
if
(
result
.
structLogs
.
length
>
0
)
{
if
(
result
.
structLogs
.
length
>
0
)
{
self
.
trace
=
result
.
structLogs
self
.
trace
=
result
.
structLogs
...
@@ -34,15 +35,17 @@ TraceManager.prototype.resolveTrace = function (tx, callback) {
...
@@ -34,15 +35,17 @@ TraceManager.prototype.resolveTrace = function (tx, callback) {
if
(
error
)
{
if
(
error
)
{
self
.
isLoading
=
false
self
.
isLoading
=
false
console
.
log
(
error
)
console
.
log
(
error
)
callback
(
false
)
callback
(
error
,
false
)
}
else
{
}
else
{
self
.
isLoading
=
false
self
.
isLoading
=
false
callback
(
true
)
callback
(
null
,
true
)
}
}
})
})
}
else
{
}
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
self
.
isLoading
=
false
callback
(
mes
,
false
)
}
}
}
}
})
})
...
@@ -77,6 +80,12 @@ TraceManager.prototype.getStorageAt = function (stepIndex, tx, callback) {
...
@@ -77,6 +80,12 @@ TraceManager.prototype.getStorageAt = function (stepIndex, tx, callback) {
}
}
var
stoChange
=
traceHelper
.
findLowerBound
(
stepIndex
,
this
.
traceCache
.
storageChanges
)
var
stoChange
=
traceHelper
.
findLowerBound
(
stepIndex
,
this
.
traceCache
.
storageChanges
)
if
(
stoChange
===
undefined
)
return
callback
(
'no storage found'
,
null
)
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
var self = this
if (this.traceRetriever.debugStorageAtAvailable()) {
if (this.traceRetriever.debugStorageAtAvailable()) {
var address = this.traceCache.sstore[stoChange].address
var address = this.traceCache.sstore[stoChange].address
...
@@ -92,6 +101,7 @@ TraceManager.prototype.getStorageAt = function (stepIndex, tx, callback) {
...
@@ -92,6 +101,7 @@ TraceManager.prototype.getStorageAt = function (stepIndex, tx, callback) {
} else {
} else {
callback(null, this.trace[stoChange].storage)
callback(null, this.trace[stoChange].storage)
}
}
*/
}
}
TraceManager
.
prototype
.
getCallDataAt
=
function
(
stepIndex
,
callback
)
{
TraceManager
.
prototype
.
getCallDataAt
=
function
(
stepIndex
,
callback
)
{
...
...
src/trace/traceRetriever.js
View file @
52fc1540
...
@@ -8,10 +8,10 @@ function TraceRetriever (_web3) {
...
@@ -8,10 +8,10 @@ function TraceRetriever (_web3) {
TraceRetriever
.
prototype
.
getTrace
=
function
(
txHash
,
callback
)
{
TraceRetriever
.
prototype
.
getTrace
=
function
(
txHash
,
callback
)
{
var
options
=
{
var
options
=
{
disableStorage
:
t
his
.
debugStorageAtAvailable
()
,
disableStorage
:
t
rue
,
disableMemory
:
false
,
disableMemory
:
false
,
disableStack
:
false
,
disableStack
:
false
,
fullStorage
:
false
// !this.debugStorageAtAvailable()
fullStorage
:
false
}
}
this
.
web3
.
debug
.
traceTransaction
(
txHash
,
options
,
function
(
error
,
result
)
{
this
.
web3
.
debug
.
traceTransaction
(
txHash
,
options
,
function
(
error
,
result
)
{
callback
(
error
,
result
)
callback
(
error
,
result
)
...
@@ -24,16 +24,20 @@ TraceRetriever.prototype.getStorage = function (tx, address, callback) {
...
@@ -24,16 +24,20 @@ TraceRetriever.prototype.getStorage = function (tx, address, callback) {
}
else
if
(
this
.
storages
[
address
])
{
}
else
if
(
this
.
storages
[
address
])
{
callback
(
null
,
this
.
storages
[
address
])
callback
(
null
,
this
.
storages
[
address
])
}
else
{
}
else
{
// we always return an empty storage ... storage changes will be displayed instead of the full contract storage
callback
(
null
,
{})
/*
var self = this
var self = this
this.web3.debug.storageAt(tx.blockNumber.toString(), tx.transactionIndex, address, function (error, result) {
this.web3.debug.storageAt(tx.blockNumber.toString(), tx.transactionIndex, address, function (error, result) {
self.storages[address] = result
self.storages[address] = result
callback(error, result)
callback(error, result)
})
})
*/
}
}
}
}
TraceRetriever
.
prototype
.
debugStorageAtAvailable
=
function
()
{
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
module
.
exports
=
TraceRetriever
test/codeManager.js
View file @
52fc1540
...
@@ -14,9 +14,9 @@ tape('CodeManager', function (t) {
...
@@ -14,9 +14,9 @@ tape('CodeManager', function (t) {
traceManager
.
traceRetriever
=
new
TestTraceRetriever
()
traceManager
.
traceRetriever
=
new
TestTraceRetriever
()
codeManager
=
new
CodeManager
(
web3
,
traceManager
)
codeManager
=
new
CodeManager
(
web3
,
traceManager
)
codeManager
.
codeResolver
.
cacheExecutingCode
(
'0x0d3a18d64dfe4f927832ab58d6451cecc4e517c5'
,
contractCode
)
// so a call to web3 is not necessary
codeManager
.
codeResolver
.
cacheExecutingCode
(
'0x0d3a18d64dfe4f927832ab58d6451cecc4e517c5'
,
contractCode
)
// so a call to web3 is not necessary
traceManager
.
resolveTrace
(
txInvokation
,
function
(
success
)
{
traceManager
.
resolveTrace
(
txInvokation
,
function
(
error
,
result
)
{
if
(
!
success
)
{
if
(
error
)
{
t
.
fail
(
' - traceManager.resolveTrace - failed
'
)
t
.
fail
(
' - traceManager.resolveTrace - failed
'
+
result
)
}
else
{
}
else
{
continueTesting
(
t
,
codeManager
)
continueTesting
(
t
,
codeManager
)
}
}
...
...
test/traceManager.js
View file @
52fc1540
...
@@ -16,9 +16,9 @@ tape('TraceManager', function (t) {
...
@@ -16,9 +16,9 @@ tape('TraceManager', function (t) {
})
})
t
.
test
(
'TraceManager.resolveTrace'
,
function
(
st
)
{
t
.
test
(
'TraceManager.resolveTrace'
,
function
(
st
)
{
traceManager
.
resolveTrace
(
txInvokation
,
function
(
success
)
{
traceManager
.
resolveTrace
(
txInvokation
,
function
(
error
,
result
)
{
if
(
!
success
)
{
if
(
error
)
{
st
.
fail
(
' - traceManager.resolveTrace - failed
'
)
st
.
fail
(
' - traceManager.resolveTrace - failed
'
+
result
)
}
else
{
}
else
{
st
.
end
()
st
.
end
()
}
}
...
@@ -44,11 +44,11 @@ tape('TraceManager', function (t) {
...
@@ -44,11 +44,11 @@ tape('TraceManager', function (t) {
})
})
t
.
test
(
'TraceManager.getStorageAt'
,
function
(
st
)
{
t
.
test
(
'TraceManager.getStorageAt'
,
function
(
st
)
{
traceManager
.
getStorageAt
(
0
,
txInvokation
,
function
(
error
,
result
)
{
traceManager
.
getStorageAt
(
11
0
,
txInvokation
,
function
(
error
,
result
)
{
if
(
error
)
{
if
(
error
)
{
st
.
fail
(
error
)
st
.
fail
(
error
)
}
else
{
}
else
{
st
.
ok
(
result
[
'0x00'
]
===
'0x
2d
'
)
st
.
ok
(
result
[
'0x00'
]
===
'0x
38
'
)
st
.
end
()
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