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
7a8b0463
Commit
7a8b0463
authored
Dec 14, 2020
by
aniket-engg
Committed by
Aniket
Dec 21, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
src updated
parent
80b87ef2
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
203 additions
and
190 deletions
+203
-190
Ethdebugger.ts
libs/remix-debug/src/Ethdebugger.ts
+126
-115
eventManager.ts
libs/remix-debug/src/eventManager.ts
+63
-60
index.ts
libs/remix-debug/src/index.ts
+6
-6
init.ts
libs/remix-debug/src/init.ts
+8
-9
No files found.
libs/remix-debug/src/Ethdebugger.ts
View file @
7a8b0463
...
@@ -23,141 +23,152 @@ const {SolidityProxy, stateDecoder, localDecoder, InternalCallTree} = require('.
...
@@ -23,141 +23,152 @@ const {SolidityProxy, stateDecoder, localDecoder, InternalCallTree} = require('.
*
*
* @param {Map} opts - { function compilationResult } //
* @param {Map} opts - { function compilationResult } //
*/
*/
function
Ethdebugger
(
opts
)
{
export
class
Ethdebugger
{
this
.
compilationResult
=
opts
.
compilationResult
||
function
(
contractAddress
)
{
return
null
}
this
.
web3
=
opts
.
web3
compilationResult
this
.
opts
=
opts
web3
opts
this
.
event
=
new
EventManager
()
event
tx
this
.
tx
traceManager
codeManager
this
.
traceManager
=
new
TraceManager
({
web3
:
this
.
web3
})
solidityProxy
this
.
codeManager
=
new
CodeManager
(
this
.
traceManager
)
storageResolver
this
.
solidityProxy
=
new
SolidityProxy
({
getCurrentCalledAddressAt
:
this
.
traceManager
.
getCurrentCalledAddressAt
.
bind
(
this
.
traceManager
),
getCode
:
this
.
codeManager
.
getCode
.
bind
(
this
.
codeManager
)})
callTree
this
.
storageResolver
=
null
breakpointManager
statusMessage
const
includeLocalVariables
=
true
this
.
callTree
=
new
InternalCallTree
(
this
.
event
,
constructor
(
opts
)
{
this
.
traceManager
,
this
.
compilationResult
=
opts
.
compilationResult
||
function
(
contractAddress
)
{
return
null
}
this
.
solidityProxy
,
this
.
web3
=
opts
.
web3
this
.
codeManager
,
this
.
opts
=
opts
{
...
opts
,
includeLocalVariables
})
}
this
.
event
=
new
EventManager
()
this
.
traceManager
=
new
TraceManager
({
web3
:
this
.
web3
})
this
.
codeManager
=
new
CodeManager
(
this
.
traceManager
)
this
.
solidityProxy
=
new
SolidityProxy
({
getCurrentCalledAddressAt
:
this
.
traceManager
.
getCurrentCalledAddressAt
.
bind
(
this
.
traceManager
),
getCode
:
this
.
codeManager
.
getCode
.
bind
(
this
.
codeManager
)})
this
.
storageResolver
=
null
const
includeLocalVariables
=
true
this
.
callTree
=
new
InternalCallTree
(
this
.
event
,
this
.
traceManager
,
this
.
solidityProxy
,
this
.
codeManager
,
{
...
opts
,
includeLocalVariables
})
}
Ethdebugger
.
prototype
.
setManagers
=
function
()
{
setManagers
()
{
this
.
traceManager
=
new
TraceManager
({
web3
:
this
.
web3
})
this
.
traceManager
=
new
TraceManager
({
web3
:
this
.
web3
})
this
.
codeManager
=
new
CodeManager
(
this
.
traceManager
)
this
.
codeManager
=
new
CodeManager
(
this
.
traceManager
)
this
.
solidityProxy
=
new
SolidityProxy
({
getCurrentCalledAddressAt
:
this
.
traceManager
.
getCurrentCalledAddressAt
.
bind
(
this
.
traceManager
),
getCode
:
this
.
codeManager
.
getCode
.
bind
(
this
.
codeManager
)})
this
.
solidityProxy
=
new
SolidityProxy
({
getCurrentCalledAddressAt
:
this
.
traceManager
.
getCurrentCalledAddressAt
.
bind
(
this
.
traceManager
),
getCode
:
this
.
codeManager
.
getCode
.
bind
(
this
.
codeManager
)})
this
.
storageResolver
=
null
this
.
storageResolver
=
null
const
includeLocalVariables
=
true
const
includeLocalVariables
=
true
this
.
callTree
=
new
InternalCallTree
(
this
.
event
,
this
.
callTree
=
new
InternalCallTree
(
this
.
event
,
this
.
traceManager
,
this
.
traceManager
,
this
.
solidityProxy
,
this
.
solidityProxy
,
this
.
codeManager
,
this
.
codeManager
,
{
...
this
.
opts
,
includeLocalVariables
})
{
...
this
.
opts
,
includeLocalVariables
})
this
.
event
.
trigger
(
'managersChanged'
)
this
.
event
.
trigger
(
'managersChanged'
)
}
}
Ethdebugger
.
prototype
.
resolveStep
=
function
(
index
)
{
resolveStep
(
index
)
{
this
.
codeManager
.
resolveStep
(
index
,
this
.
tx
)
this
.
codeManager
.
resolveStep
(
index
,
this
.
tx
)
}
}
Ethdebugger
.
prototype
.
setCompilationResult
=
function
(
compilationResult
)
{
setCompilationResult
(
compilationResult
)
{
this
.
solidityProxy
.
reset
((
compilationResult
&&
compilationResult
.
data
)
||
{})
this
.
solidityProxy
.
reset
((
compilationResult
&&
compilationResult
.
data
)
||
{})
}
}
Ethdebugger
.
prototype
.
sourceLocationFromVMTraceIndex
=
async
function
(
address
,
stepIndex
)
{
async
sourceLocationFromVMTraceIndex
(
address
,
stepIndex
)
{
return
this
.
callTree
.
sourceLocationTracker
.
getSourceLocationFromVMTraceIndex
(
address
,
stepIndex
,
this
.
solidityProxy
.
contracts
)
return
this
.
callTree
.
sourceLocationTracker
.
getSourceLocationFromVMTraceIndex
(
address
,
stepIndex
,
this
.
solidityProxy
.
contracts
)
}
}
Ethdebugger
.
prototype
.
getValidSourceLocationFromVMTraceIndex
=
async
function
(
address
,
stepIndex
)
{
async
getValidSourceLocationFromVMTraceIndex
(
address
,
stepIndex
)
{
return
this
.
callTree
.
sourceLocationTracker
.
getValidSourceLocationFromVMTraceIndex
(
address
,
stepIndex
,
this
.
solidityProxy
.
contracts
)
return
this
.
callTree
.
sourceLocationTracker
.
getValidSourceLocationFromVMTraceIndex
(
address
,
stepIndex
,
this
.
solidityProxy
.
contracts
)
}
}
Ethdebugger
.
prototype
.
sourceLocationFromInstructionIndex
=
async
function
(
address
,
instIndex
,
callback
)
{
async
sourceLocationFromInstructionIndex
(
address
,
instIndex
,
callback
)
{
return
this
.
callTree
.
sourceLocationTracker
.
getSourceLocationFromInstructionIndex
(
address
,
instIndex
,
this
.
solidityProxy
.
contracts
)
return
this
.
callTree
.
sourceLocationTracker
.
getSourceLocationFromInstructionIndex
(
address
,
instIndex
,
this
.
solidityProxy
.
contracts
)
}
}
/* breakpoint */
/* breakpoint */
Ethdebugger
.
prototype
.
setBreakpointManager
=
function
(
breakpointManager
)
{
setBreakpointManager
(
breakpointManager
)
{
this
.
breakpointManager
=
breakpointManager
this
.
breakpointManager
=
breakpointManager
}
}
/* decode locals */
/* decode locals */
Ethdebugger
.
prototype
.
extractLocalsAt
=
function
(
step
)
{
extractLocalsAt
(
step
)
{
return
this
.
callTree
.
findScope
(
step
)
return
this
.
callTree
.
findScope
(
step
)
}
}
Ethdebugger
.
prototype
.
decodeLocalsAt
=
async
function
(
step
,
sourceLocation
,
callback
)
{
async
decodeLocalsAt
(
step
,
sourceLocation
,
callback
)
{
try
{
const
stack
=
this
.
traceManager
.
getStackAt
(
step
)
const
memory
=
this
.
traceManager
.
getMemoryAt
(
step
)
const
address
=
this
.
traceManager
.
getCurrentCalledAddressAt
(
step
)
try
{
try
{
const
storageViewer
=
new
StorageViewer
({
stepIndex
:
step
,
tx
:
this
.
tx
,
address
:
address
},
this
.
storageResolver
,
this
.
traceManager
)
const
stack
=
this
.
traceManager
.
getStackAt
(
step
)
const
locals
=
await
localDecoder
.
solidityLocals
(
step
,
this
.
callTree
,
stack
,
memory
,
storageViewer
,
sourceLocation
)
const
memory
=
this
.
traceManager
.
getMemoryAt
(
step
)
if
(
locals
.
error
)
{
const
address
=
this
.
traceManager
.
getCurrentCalledAddressAt
(
step
)
return
callback
(
locals
.
error
)
try
{
const
storageViewer
=
new
StorageViewer
({
stepIndex
:
step
,
tx
:
this
.
tx
,
address
:
address
},
this
.
storageResolver
,
this
.
traceManager
)
const
locals
=
await
localDecoder
.
solidityLocals
(
step
,
this
.
callTree
,
stack
,
memory
,
storageViewer
,
sourceLocation
)
if
(
locals
.
error
)
{
return
callback
(
locals
.
error
)
}
return
callback
(
null
,
locals
)
}
catch
(
e
)
{
callback
(
e
.
message
)
}
}
return
callback
(
null
,
locals
)
}
catch
(
error
)
{
}
catch
(
e
)
{
callback
(
error
)
callback
(
e
.
message
)
}
}
}
catch
(
error
)
{
callback
(
error
)
}
}
}
/* decode state */
Ethdebugger
.
prototype
.
extractStateAt
=
async
function
(
step
)
{
return
this
.
solidityProxy
.
extractStateVariablesAt
(
step
)
}
Ethdebugger
.
prototype
.
decodeStateAt
=
async
function
(
step
,
stateVars
,
callback
)
{
/* decode state */
try
{
async
extractStateAt
(
step
)
{
const
address
=
this
.
traceManager
.
getCurrentCalledAddressAt
(
step
)
return
this
.
solidityProxy
.
extractStateVariablesAt
(
step
)
const
storageViewer
=
new
StorageViewer
({
stepIndex
:
step
,
tx
:
this
.
tx
,
address
:
address
},
this
.
storageResolver
,
this
.
traceManager
)
const
result
=
await
stateDecoder
.
decodeState
(
stateVars
,
storageViewer
)
return
result
}
catch
(
error
)
{
callback
(
error
)
}
}
}
Ethdebugger
.
prototype
.
storageViewAt
=
function
(
step
,
address
)
{
async
decodeStateAt
(
step
,
stateVars
,
callback
)
{
return
new
StorageViewer
({
stepIndex
:
step
,
tx
:
this
.
tx
,
address
:
address
},
this
.
storageResolver
,
this
.
traceManager
)
try
{
}
const
address
=
this
.
traceManager
.
getCurrentCalledAddressAt
(
step
)
const
storageViewer
=
new
StorageViewer
({
stepIndex
:
step
,
tx
:
this
.
tx
,
address
:
address
},
this
.
storageResolver
,
this
.
traceManager
)
const
result
=
await
stateDecoder
.
decodeState
(
stateVars
,
storageViewer
)
return
result
}
catch
(
error
)
{
callback
(
error
)
}
}
Ethdebugger
.
prototype
.
updateWeb3
=
function
(
web3
)
{
storageViewAt
(
step
,
address
)
{
this
.
web3
=
web3
return
new
StorageViewer
({
stepIndex
:
step
,
tx
:
this
.
tx
,
address
:
address
},
this
.
storageResolver
,
this
.
traceManager
)
this
.
setManagers
()
}
}
Ethdebugger
.
prototype
.
unLoad
=
function
()
{
updateWeb3
(
web3
)
{
this
.
traceManager
.
init
()
this
.
web3
=
web3
this
.
codeManager
.
clear
()
this
.
setManagers
()
this
.
event
.
trigger
(
'traceUnloaded'
)
}
}
Ethdebugger
.
prototype
.
debug
=
function
(
tx
)
{
unLoad
()
{
if
(
this
.
traceManager
.
isLoading
)
{
this
.
traceManager
.
init
()
return
this
.
codeManager
.
clear
()
this
.
event
.
trigger
(
'traceUnloaded'
)
}
}
tx
.
to
=
tx
.
to
||
traceHelper
.
contractCreationToken
(
'0'
)
this
.
tx
=
tx
this
.
traceManager
.
resolveTrace
(
tx
).
then
(
async
(
result
)
=>
{
debug
(
tx
)
{
this
.
setCompilationResult
(
await
this
.
compilationResult
(
tx
.
to
))
if
(
this
.
traceManager
.
isLoading
)
{
this
.
event
.
trigger
(
'newTraceLoaded'
,
[
this
.
traceManager
.
trace
])
return
if
(
this
.
breakpointManager
&&
this
.
breakpointManager
.
hasBreakpoint
())
{
this
.
breakpointManager
.
jumpNextBreakpoint
(
false
)
}
}
this
.
storageResolver
=
new
StorageResolver
({
web3
:
this
.
traceManager
.
web3
})
tx
.
to
=
tx
.
to
||
traceHelper
.
contractCreationToken
(
'0'
)
}).
catch
((
error
)
=>
{
this
.
tx
=
tx
this
.
statusMessage
=
error
?
error
.
message
:
'Trace not loaded'
})
this
.
traceManager
.
resolveTrace
(
tx
).
then
(
async
(
result
)
=>
{
this
.
setCompilationResult
(
await
this
.
compilationResult
(
tx
.
to
))
this
.
event
.
trigger
(
'newTraceLoaded'
,
[
this
.
traceManager
.
trace
])
if
(
this
.
breakpointManager
&&
this
.
breakpointManager
.
hasBreakpoint
())
{
this
.
breakpointManager
.
jumpNextBreakpoint
(
false
)
}
this
.
storageResolver
=
new
StorageResolver
({
web3
:
this
.
traceManager
.
web3
})
}).
catch
((
error
)
=>
{
this
.
statusMessage
=
error
?
error
.
message
:
'Trace not loaded'
})
}
}
}
module
.
exports
=
Ethdebugger
libs/remix-debug/src/eventManager.ts
View file @
7a8b0463
'use strict'
'use strict'
function
eventManager
()
{
export
class
eventManager
{
this
.
registered
=
{}
this
.
anonymous
=
{}
}
/*
registered
* Unregister a listener.
anonymous
* Note that if obj is a function. the unregistration will be applied to the dummy obj {}.
*
constructor
()
{
* @param {String} eventName - the event name
this
.
registered
=
{}
* @param {Object or Func} obj - object that will listen on this event
this
.
anonymous
=
{}
* @param {Func} func - function of the listeners that will be executed
*/
eventManager
.
prototype
.
unregister
=
function
(
eventName
,
obj
,
func
)
{
if
(
!
this
.
registered
[
eventName
])
{
return
}
if
(
obj
instanceof
Function
)
{
func
=
obj
obj
=
this
.
anonymous
}
}
for
(
let
reg
in
this
.
registered
[
eventName
])
{
if
(
this
.
registered
[
eventName
][
reg
].
obj
===
obj
&&
this
.
registered
[
eventName
][
reg
].
func
===
func
)
{
/*
this
.
registered
[
eventName
].
splice
(
reg
,
1
)
* Unregister a listener.
* Note that if obj is a function. the unregistration will be applied to the dummy obj {}.
*
* @param {String} eventName - the event name
* @param {Object or Func} obj - object that will listen on this event
* @param {Func} func - function of the listeners that will be executed
*/
unregister
(
eventName
,
obj
,
func
)
{
if
(
!
this
.
registered
[
eventName
])
{
return
}
if
(
obj
instanceof
Function
)
{
func
=
obj
obj
=
this
.
anonymous
}
for
(
let
reg
in
this
.
registered
[
eventName
])
{
if
(
this
.
registered
[
eventName
][
reg
].
obj
===
obj
&&
this
.
registered
[
eventName
][
reg
].
func
===
func
)
{
this
.
registered
[
eventName
].
splice
(
reg
,
1
)
}
}
}
}
}
}
/*
/*
* Register a new listener.
* Register a new listener.
* Note that if obj is a function, the function registration will be associated with the dummy object {}
* Note that if obj is a function, the function registration will be associated with the dummy object {}
*
*
* @param {String} eventName - the event name
* @param {String} eventName - the event name
* @param {Object or Func} obj - object that will listen on this event
* @param {Object or Func} obj - object that will listen on this event
* @param {Func} func - function of the listeners that will be executed
* @param {Func} func - function of the listeners that will be executed
*/
*/
eventManager
.
prototype
.
register
=
function
(
eventName
,
obj
,
func
)
{
register
(
eventName
,
obj
,
func
)
{
if
(
!
this
.
registered
[
eventName
])
{
if
(
!
this
.
registered
[
eventName
])
{
this
.
registered
[
eventName
]
=
[]
this
.
registered
[
eventName
]
=
[]
}
}
if
(
obj
instanceof
Function
)
{
if
(
obj
instanceof
Function
)
{
func
=
obj
func
=
obj
obj
=
this
.
anonymous
obj
=
this
.
anonymous
}
this
.
registered
[
eventName
].
push
({
obj
:
obj
,
func
:
func
})
}
}
this
.
registered
[
eventName
].
push
({
obj
:
obj
,
func
:
func
})
}
/*
/*
* trigger event.
* trigger event.
* Every listener have their associated function executed
* Every listener have their associated function executed
*
*
* @param {String} eventName - the event name
* @param {String} eventName - the event name
* @param {Array}j - argument that will be passed to the executed function.
* @param {Array}j - argument that will be passed to the executed function.
*/
*/
eventManager
.
prototype
.
trigger
=
function
(
eventName
,
args
)
{
trigger
(
eventName
,
args
)
{
if
(
!
this
.
registered
[
eventName
])
{
if
(
!
this
.
registered
[
eventName
])
{
return
return
}
}
for
(
let
listener
in
this
.
registered
[
eventName
])
{
for
(
let
listener
in
this
.
registered
[
eventName
])
{
const
l
=
this
.
registered
[
eventName
][
listener
]
const
l
=
this
.
registered
[
eventName
][
listener
]
l
.
func
.
apply
(
l
.
obj
===
this
.
anonymous
?
{}
:
l
.
obj
,
args
)
l
.
func
.
apply
(
l
.
obj
===
this
.
anonymous
?
{}
:
l
.
obj
,
args
)
}
}
}
}
}
module
.
exports
=
eventManager
\ No newline at end of file
libs/remix-debug/src/index.ts
View file @
7a8b0463
...
@@ -23,23 +23,23 @@ const traceHelper = require('./src/trace/traceHelper')
...
@@ -23,23 +23,23 @@ const traceHelper = require('./src/trace/traceHelper')
})
})
this.debugger.setBreakpointManager(breakPointManager)
this.debugger.setBreakpointManager(breakPointManager)
*/
*/
module
.
exports
=
{
export
=
{
init
,
init
,
traceHelper
,
traceHelper
,
SourceMappingDecoder
,
SourceMappingDecoder
,
EthDebugger
:
EthDebugger
,
EthDebugger
,
TransactionDebugger
:
TransactionDebugger
,
TransactionDebugger
,
/**
/**
* constructor
* constructor
*
*
* @param {Object} _debugger - type of EthDebugger
* @param {Object} _debugger - type of EthDebugger
* @return {Function} _locationToRowConverter - function implemented by editor which return a column/line position for a char source location
* @return {Function} _locationToRowConverter - function implemented by editor which return a column/line position for a char source location
*/
*/
BreakpointManager
:
BreakpointManager
,
BreakpointManager
,
SolidityDecoder
:
SolidityDecoder
,
SolidityDecoder
,
storage
:
{
storage
:
{
StorageViewer
:
StorageViewer
,
StorageViewer
:
StorageViewer
,
StorageResolver
:
StorageResolver
StorageResolver
:
StorageResolver
},
},
CmdLine
:
CmdLine
CmdLine
}
}
libs/remix-debug/src/init.ts
View file @
7a8b0463
'use strict'
'use strict'
const
Web3
=
require
(
'web3'
)
const
Web3
=
require
(
'web3'
)
module
.
exports
=
{
export
=
{
loadWeb3
:
function
(
url
)
{
loadWeb3
:
function
(
url
)
{
if
(
!
url
)
url
=
'http://localhost:8545'
if
(
!
url
)
url
=
'http://localhost:8545'
const
web3
=
new
Web3
()
const
web3
=
new
Web3
()
...
@@ -19,6 +19,13 @@ module.exports = {
...
@@ -19,6 +19,13 @@ module.exports = {
},
},
web3DebugNode
:
function
(
network
)
{
web3DebugNode
:
function
(
network
)
{
const
web3DebugNodes
=
{
'Main'
:
'https://rpc.archivenode.io/e50zmkroshle2e2e50zm0044i7ao04ym'
,
'Rinkeby'
:
'https://remix-rinkeby.ethdevops.io'
,
'Ropsten'
:
'https://remix-ropsten.ethdevops.io'
,
'Goerli'
:
'https://remix-goerli.ethdevops.io'
,
'Kovan'
:
'https://remix-kovan.ethdevops.io'
}
if
(
web3DebugNodes
[
network
])
{
if
(
web3DebugNodes
[
network
])
{
return
this
.
loadWeb3
(
web3DebugNodes
[
network
])
return
this
.
loadWeb3
(
web3DebugNodes
[
network
])
}
}
...
@@ -66,11 +73,3 @@ module.exports = {
...
@@ -66,11 +73,3 @@ module.exports = {
}
}
}
}
}
}
const
web3DebugNodes
=
{
'Main'
:
'https://rpc.archivenode.io/e50zmkroshle2e2e50zm0044i7ao04ym'
,
'Rinkeby'
:
'https://remix-rinkeby.ethdevops.io'
,
'Ropsten'
:
'https://remix-ropsten.ethdevops.io'
,
'Goerli'
:
'https://remix-goerli.ethdevops.io'
,
'Kovan'
:
'https://remix-kovan.ethdevops.io'
}
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