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
36fa9cb5
Commit
36fa9cb5
authored
Apr 13, 2017
by
yann300
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move accumulateStorageChanges && address to StorageViewer
parent
c5b4fc96
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
70 additions
and
79 deletions
+70
-79
storageResolver.js
src/storage/storageResolver.js
+28
-45
storageViewer.js
src/storage/storageViewer.js
+15
-14
FullStoragesChanges.js
src/ui/FullStoragesChanges.js
+3
-2
SolidityLocals.js
src/ui/SolidityLocals.js
+7
-3
SolidityState.js
src/ui/SolidityState.js
+4
-3
StoragePanel.js
src/ui/StoragePanel.js
+12
-11
VmDebugger.js
src/ui/VmDebugger.js
+1
-1
No files found.
src/storage/storageResolver.js
View file @
36fa9cb5
...
@@ -3,8 +3,7 @@ var traceHelper = require('../helpers/traceHelper')
...
@@ -3,8 +3,7 @@ var traceHelper = require('../helpers/traceHelper')
var
util
=
require
(
'../helpers/global'
)
var
util
=
require
(
'../helpers/global'
)
class
StorageResolver
{
class
StorageResolver
{
constructor
(
_traceManager
)
{
constructor
()
{
this
.
traceManager
=
_traceManager
this
.
storageByAddress
=
{}
this
.
storageByAddress
=
{}
this
.
maxSize
=
100
this
.
maxSize
=
100
}
}
...
@@ -15,10 +14,12 @@ class StorageResolver {
...
@@ -15,10 +14,12 @@ class StorageResolver {
*
*
* @param {Object} - tx - transaction
* @param {Object} - tx - transaction
* @param {Int} - stepIndex - Index of the stop in the vm trace
* @param {Int} - stepIndex - Index of the stop in the vm trace
* @param {Object} - storageChanges - contains storage changes by hashde key
* @param {String} - address - lookup address
* @param {Function} - callback - contains a map: [hashedKey] = {key, hashedKey, value}
* @param {Function} - callback - contains a map: [hashedKey] = {key, hashedKey, value}
*/
*/
storageRange
(
tx
,
stepIndex
,
callback
)
{
storageRange
(
tx
,
stepIndex
,
storageChanges
,
address
,
callback
)
{
storageRangeInternal
(
this
,
zeroSlot
,
tx
,
stepIndex
,
true
,
callback
)
storageRangeInternal
(
this
,
zeroSlot
,
tx
,
stepIndex
,
true
,
storageChanges
,
address
,
callback
)
}
}
/**
/**
...
@@ -27,10 +28,12 @@ class StorageResolver {
...
@@ -27,10 +28,12 @@ class StorageResolver {
* @param {String} - slot - slot key
* @param {String} - slot - slot key
* @param {Object} - tx - transaction
* @param {Object} - tx - transaction
* @param {Int} - stepIndex - Index of the stop in the vm trace
* @param {Int} - stepIndex - Index of the stop in the vm trace
* @param {Object} - storageChanges - contains storage changes by hashde key
* @param {String} - address - lookup address
* @param {Function} - callback - {key, hashedKey, value} -
* @param {Function} - callback - {key, hashedKey, value} -
*/
*/
storageSlot
(
slot
,
tx
,
stepIndex
,
callback
)
{
storageSlot
(
slot
,
tx
,
stepIndex
,
storageChanges
,
address
,
callback
)
{
storageRangeInternal
(
this
,
slot
,
tx
,
stepIndex
,
false
,
function
(
error
,
storage
)
{
storageRangeInternal
(
this
,
slot
,
tx
,
stepIndex
,
false
,
storageChanges
,
address
,
function
(
error
,
storage
)
{
if
(
error
)
{
if
(
error
)
{
callback
(
error
)
callback
(
error
)
}
else
{
}
else
{
...
@@ -56,39 +59,29 @@ class StorageResolver {
...
@@ -56,39 +59,29 @@ class StorageResolver {
* even if the next 1000 items are not in the cache.
* even if the next 1000 items are not in the cache.
* - If @arg slot is not cached, the corresponding value will be resolved and the next 1000 slots.
* - If @arg slot is not cached, the corresponding value will be resolved and the next 1000 slots.
*/
*/
function
storageRangeInternal
(
self
,
slotKey
,
tx
,
stepIndex
,
fullStorage
,
callback
)
{
function
storageRangeInternal
(
self
,
slotKey
,
tx
,
stepIndex
,
fullStorage
,
storageChanges
,
address
,
callback
)
{
resolveAddress
(
self
,
stepIndex
,
(
error
,
address
)
=>
{
if
(
!
fullStorage
&&
storageChanges
[
slotKey
])
{
// don't need the full storage just returning the value from the storageChanges
return
callback
(
null
,
storageChanges
)
}
var
cached
=
fromCache
(
self
,
address
)
if
(
cached
&&
cached
.
storage
[
slotKey
])
{
// we have the current slot in the cache and maybe the next 1000...
return
callback
(
null
,
Object
.
assign
({},
cached
.
storage
,
storageChanges
))
}
storageRangeWeb3Call
(
tx
,
address
,
slotKey
,
self
.
maxSize
,
(
error
,
storage
,
complete
)
=>
{
if
(
error
)
{
if
(
error
)
{
return
callback
(
error
)
return
callback
(
error
)
}
}
self
.
traceManager
.
accumulateStorageChanges
(
stepIndex
,
address
,
{},
(
error
,
storageChanges
)
=>
{
if
(
!
storage
[
slotKey
])
{
if
(
error
)
{
storage
[
slotKey
]
=
{
return
callback
(
error
)
key
:
slotKey
,
}
value
:
zeroSlot
if
(
!
fullStorage
&&
storageChanges
[
slotKey
])
{
// don't need the full storage just returning the value from the storageChanges
return
callback
(
null
,
storageChanges
)
}
var
cached
=
fromCache
(
self
,
address
)
if
(
cached
&&
cached
.
storage
[
slotKey
])
{
// we have the current slot in the cache and maybe the next 1000...
return
callback
(
null
,
Object
.
assign
(
cached
.
storage
,
storageChanges
))
}
}
storageRangeWeb3Call
(
tx
,
address
,
slotKey
,
self
.
maxSize
,
(
error
,
storage
,
complete
)
=>
{
}
if
(
error
)
{
toCache
(
self
,
address
,
storage
)
return
callback
(
error
)
if
(
slotKey
===
zeroSlot
&&
Object
.
keys
(
storage
).
length
<
self
.
maxSize
)
{
}
self
.
storageByAddress
[
address
].
complete
=
true
if
(
!
storage
[
slotKey
])
{
}
storage
[
slotKey
]
=
{
callback
(
null
,
Object
.
assign
(
storage
,
storageChanges
))
key
:
slotKey
,
value
:
zeroSlot
}
}
toCache
(
self
,
address
,
storage
)
if
(
slotKey
===
zeroSlot
&&
Object
.
keys
(
storage
).
length
<
self
.
maxSize
)
{
self
.
storageByAddress
[
address
].
complete
=
true
}
callback
(
null
,
Object
.
assign
(
storage
,
storageChanges
))
})
})
})
})
}
}
...
@@ -141,14 +134,4 @@ function storageRangeWeb3Call (tx, address, start, maxSize, callback) {
...
@@ -141,14 +134,4 @@ function storageRangeWeb3Call (tx, address, start, maxSize, callback) {
}
}
}
}
function
resolveAddress
(
self
,
stepIndex
,
callback
)
{
self
.
traceManager
.
getCurrentCalledAddressAt
(
stepIndex
,
(
error
,
result
)
=>
{
if
(
error
)
{
callback
(
error
)
}
else
{
callback
(
null
,
result
)
}
})
}
module
.
exports
=
StorageResolver
module
.
exports
=
StorageResolver
src/storage/storageViewer.js
View file @
36fa9cb5
...
@@ -2,9 +2,16 @@
...
@@ -2,9 +2,16 @@
var
helper
=
require
(
'../helpers/util'
)
var
helper
=
require
(
'../helpers/util'
)
class
StorageViewer
{
class
StorageViewer
{
constructor
(
_context
,
_storageResolver
)
{
constructor
(
_context
,
_storageResolver
,
_traceManager
)
{
this
.
context
=
_context
this
.
context
=
_context
this
.
storageResolver
=
_storageResolver
this
.
storageResolver
=
_storageResolver
_traceManager
.
accumulateStorageChanges
(
this
.
context
.
stepIndex
,
this
.
context
.
address
,
{},
(
error
,
storageChanges
)
=>
{
if
(
!
error
)
{
this
.
storageChanges
=
storageChanges
}
else
{
console
.
log
(
error
)
}
})
}
}
/**
/**
...
@@ -14,27 +21,21 @@ class StorageViewer {
...
@@ -14,27 +21,21 @@ class StorageViewer {
* @param {Function} - callback - contains a map: [hashedKey] = {key, hashedKey, value}
* @param {Function} - callback - contains a map: [hashedKey] = {key, hashedKey, value}
*/
*/
storageRange
(
callback
)
{
storageRange
(
callback
)
{
this
.
storageResolver
.
storageRange
(
this
.
context
.
tx
,
this
.
context
.
stepIndex
,
callback
)
this
.
storageResolver
.
storageRange
(
this
.
context
.
tx
,
this
.
context
.
stepIndex
,
this
.
storageChanges
,
this
.
context
.
address
,
callback
)
}
}
/**
/**
* return a slot value for the current context (address and vm trace index)
* return a slot value for the current context (address and vm trace index)
*
*
@param {String} - slot - slot key (not hashed key!)
* @param {Function} - callback - {key, hashedKey, value} -
* @param {Function} - callback - {key, hashedKey, value} -
*/
*/
storageSlot
(
slot
,
callback
)
{
storageSlot
(
slot
,
callback
)
{
this
.
storageResolver
.
storageSlot
(
slot
,
this
.
context
.
tx
,
this
.
context
.
stepIndex
,
(
error
,
result
)
=>
{
var
hashed
=
helper
.
sha3_32
(
slot
)
if
(
error
||
!
result
||
!
result
[
slot
])
{
this
.
storageResolver
.
storageSlot
(
hashed
,
this
.
context
.
tx
,
this
.
context
.
stepIndex
,
this
.
storageChanges
,
this
.
context
.
address
,
(
error
,
result
)
=>
{
var
hashed
=
helper
.
sha3_32
(
slot
)
if
(
error
)
{
this
.
storageResolver
.
storageSlot
(
hashed
,
this
.
context
.
tx
,
this
.
context
.
stepIndex
,
(
error
,
result
)
=>
{
callback
(
error
)
if
(
error
)
{
callback
(
error
)
}
else
{
callback
(
null
,
result
)
}
})
}
else
{
}
else
{
return
callback
(
null
,
result
)
callback
(
null
,
result
)
}
}
})
})
}
}
...
...
src/ui/FullStoragesChanges.js
View file @
36fa9cb5
...
@@ -51,8 +51,9 @@ FullStoragesChanges.prototype.init = function () {
...
@@ -51,8 +51,9 @@ FullStoragesChanges.prototype.init = function () {
var
address
=
self
.
addresses
[
k
]
var
address
=
self
.
addresses
[
k
]
var
storageViewer
=
new
StorageViewer
({
var
storageViewer
=
new
StorageViewer
({
stepIndex
:
self
.
parent
.
currentStepIndex
,
stepIndex
:
self
.
parent
.
currentStepIndex
,
tx
:
self
.
parent
.
tx
tx
:
self
.
parent
.
tx
,
},
self
.
storageResolver
)
address
:
address
},
self
.
storageResolver
,
self
.
traceManager
)
storageViewer
.
storageRange
(
function
(
error
,
result
)
{
storageViewer
.
storageRange
(
function
(
error
,
result
)
{
if
(
!
error
)
{
if
(
!
error
)
{
storageJSON
[
address
]
=
result
storageJSON
[
address
]
=
result
...
...
src/ui/SolidityLocals.js
View file @
36fa9cb5
...
@@ -39,7 +39,8 @@ class SolidityLocals {
...
@@ -39,7 +39,8 @@ class SolidityLocals {
}
}
this
.
traceManager
.
waterfall
([
this
.
traceManager
.
waterfall
([
this
.
traceManager
.
getStackAt
,
this
.
traceManager
.
getStackAt
,
this
.
traceManager
.
getMemoryAt
],
this
.
traceManager
.
getMemoryAt
,
this
.
traceManager
.
getCurrentCalledAddressAt
],
this
.
parent
.
currentStepIndex
,
this
.
parent
.
currentStepIndex
,
(
error
,
result
)
=>
{
(
error
,
result
)
=>
{
if
(
!
error
)
{
if
(
!
error
)
{
...
@@ -48,8 +49,9 @@ class SolidityLocals {
...
@@ -48,8 +49,9 @@ class SolidityLocals {
try
{
try
{
var
storageViewer
=
new
StorageViewer
({
var
storageViewer
=
new
StorageViewer
({
stepIndex
:
this
.
parent
.
currentStepIndex
,
stepIndex
:
this
.
parent
.
currentStepIndex
,
tx
:
this
.
parent
.
tx
tx
:
this
.
parent
.
tx
,
},
this
.
storageResolver
)
address
:
result
[
2
].
value
},
this
.
storageResolver
,
this
.
traceManager
)
localDecoder
.
solidityLocals
(
this
.
parent
.
currentStepIndex
,
this
.
internalTreeCall
,
stack
,
memory
,
storageViewer
,
sourceLocation
).
then
((
locals
)
=>
{
localDecoder
.
solidityLocals
(
this
.
parent
.
currentStepIndex
,
this
.
internalTreeCall
,
stack
,
memory
,
storageViewer
,
sourceLocation
).
then
((
locals
)
=>
{
if
(
!
result
.
error
)
{
if
(
!
result
.
error
)
{
this
.
basicPanel
.
update
(
locals
)
this
.
basicPanel
.
update
(
locals
)
...
@@ -58,6 +60,8 @@ class SolidityLocals {
...
@@ -58,6 +60,8 @@ class SolidityLocals {
}
catch
(
e
)
{
}
catch
(
e
)
{
warningDiv
.
innerHTML
=
e
.
message
warningDiv
.
innerHTML
=
e
.
message
}
}
}
else
{
console
.
log
(
error
)
}
}
})
})
})
})
...
...
src/ui/SolidityState.js
View file @
36fa9cb5
...
@@ -49,7 +49,7 @@ SolidityState.prototype.init = function () {
...
@@ -49,7 +49,7 @@ SolidityState.prototype.init = function () {
return
return
}
}
self
.
traceManager
.
getCurrentCalledAddressAt
(
self
.
parent
.
currentStepIndex
,
(
error
,
result
)
=>
{
self
.
traceManager
.
getCurrentCalledAddressAt
(
self
.
parent
.
currentStepIndex
,
(
error
,
address
)
=>
{
if
(
error
)
{
if
(
error
)
{
self
.
basicPanel
.
update
({})
self
.
basicPanel
.
update
({})
console
.
log
(
error
)
console
.
log
(
error
)
...
@@ -61,8 +61,9 @@ SolidityState.prototype.init = function () {
...
@@ -61,8 +61,9 @@ SolidityState.prototype.init = function () {
}
else
{
}
else
{
var
storageViewer
=
new
StorageViewer
({
var
storageViewer
=
new
StorageViewer
({
stepIndex
:
self
.
parent
.
currentStepIndex
,
stepIndex
:
self
.
parent
.
currentStepIndex
,
tx
:
self
.
parent
.
tx
tx
:
self
.
parent
.
tx
,
},
self
.
storageResolver
)
address
:
address
},
self
.
storageResolver
,
self
.
traceManager
)
stateDecoder
.
decodeState
(
stateVars
,
storageViewer
).
then
((
result
)
=>
{
stateDecoder
.
decodeState
(
stateVars
,
storageViewer
).
then
((
result
)
=>
{
if
(
!
result
.
error
)
{
if
(
!
result
.
error
)
{
self
.
basicPanel
.
update
(
result
)
self
.
basicPanel
.
update
(
result
)
...
...
src/ui/StoragePanel.js
View file @
36fa9cb5
...
@@ -24,18 +24,19 @@ StoragePanel.prototype.init = function () {
...
@@ -24,18 +24,19 @@ StoragePanel.prototype.init = function () {
if
(
self
.
parent
.
currentStepIndex
!==
index
)
return
if
(
self
.
parent
.
currentStepIndex
!==
index
)
return
if
(
!
self
.
storageResolver
)
return
if
(
!
self
.
storageResolver
)
return
var
storageViewer
=
new
StorageViewer
({
this
.
traceManager
.
getCurrentCalledAddressAt
(
index
,
(
error
,
address
)
=>
{
stepIndex
:
self
.
parent
.
currentStepIndex
,
if
(
!
error
)
{
tx
:
self
.
parent
.
tx
var
storageViewer
=
new
StorageViewer
({
},
self
.
storageResolver
)
stepIndex
:
self
.
parent
.
currentStepIndex
,
tx
:
self
.
parent
.
tx
,
address
:
address
},
self
.
storageResolver
,
self
.
traceManager
)
storageViewer
.
storageRange
((
error
,
storage
)
=>
{
storageViewer
.
storageRange
((
error
,
storage
)
=>
{
if
(
error
)
{
if
(
error
)
{
console
.
log
(
error
)
console
.
log
(
error
)
self
.
basicPanel
.
update
({})
self
.
basicPanel
.
update
({})
}
else
if
(
self
.
parent
.
currentStepIndex
===
index
)
{
}
else
if
(
self
.
parent
.
currentStepIndex
===
index
)
{
this
.
traceManager
.
getCurrentCalledAddressAt
(
index
,
(
error
,
address
)
=>
{
if
(
!
error
)
{
var
header
=
storageViewer
.
isComplete
(
address
)
?
'completely loaded'
:
'partially loaded...'
var
header
=
storageViewer
.
isComplete
(
address
)
?
'completely loaded'
:
'partially loaded...'
self
.
basicPanel
.
update
(
storage
,
header
)
self
.
basicPanel
.
update
(
storage
,
header
)
}
}
...
...
src/ui/VmDebugger.js
View file @
36fa9cb5
...
@@ -44,7 +44,7 @@ function VmDebugger (_parent, _traceManager, _codeManager, _solidityProxy, _call
...
@@ -44,7 +44,7 @@ function VmDebugger (_parent, _traceManager, _codeManager, _solidityProxy, _call
this
.
view
this
.
view
var
self
=
this
var
self
=
this
_parent
.
event
.
register
(
'newTraceLoaded'
,
this
,
function
()
{
_parent
.
event
.
register
(
'newTraceLoaded'
,
this
,
function
()
{
var
storageResolver
=
new
StorageResolver
(
_traceManager
)
var
storageResolver
=
new
StorageResolver
()
self
.
storagePanel
.
storageResolver
=
storageResolver
self
.
storagePanel
.
storageResolver
=
storageResolver
self
.
solidityState
.
storageResolver
=
storageResolver
self
.
solidityState
.
storageResolver
=
storageResolver
self
.
solidityLocals
.
storageResolver
=
storageResolver
self
.
solidityLocals
.
storageResolver
=
storageResolver
...
...
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