-
Notifications
You must be signed in to change notification settings - Fork 565
Conversation
cool!! |
@yann300 btw feel free to review and intervene early. Particularly in src/ui/SolidityState.js and the call to storageViewer.storageRange, that will probably get refactored to support getting preimages using debug_preimage (see ethereum/go-ethereum#3543 and ethereum/go-ethereum#3407). |
5a26444
to
ca9a5d2
Compare
src/solidity/decodeInfo.js
Outdated
@@ -233,7 +233,7 @@ function getEnum (type, stateDefinitions, contractName) { | |||
* @param {String} location - location of the data (storage ref| storage pointer| memory| calldata) | |||
* @return {Array} containing all members of the current struct type | |||
*/ | |||
function getStructMembers (type, stateDefinitions, contractName) { | |||
function getStructMembers (type, stateDefinitions, contractName, location) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the location
argument is never used in the getStructMembers function because to get the members only the struct definition is used (not the stateVar declaration, which does have a storage slot location).
src/solidity/types/StringType.js
Outdated
@@ -40,7 +40,7 @@ function format (decoded) { | |||
var value = decoded.value | |||
value = value.replace('0x', '').replace(/(..)/g, '%$1') | |||
var ret = { | |||
// length: decoded.length, // unneeded, only dynamicBytes uses length | |||
length: decoded.length, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't remember why i was convinced that the length here is never used, but it doesn't matter.
yeah the length here is not really relevant. but removing this breaks tests |
* @return {Array} containing all members of the current struct type | ||
*/ | ||
function getStructMembers (type, stateDefinitions, contractName, location) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a test for the following type: struct X { uint a; mapping(uint=>uint) b; uint c; }
If such a struct is used in memory, it should be identical to struct X { uint a; uint c; }
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/solidity/types/Mapping.js
Outdated
type: this.type | ||
} | ||
} | ||
var mapSlot = util.toBN(location.slot).toString(16) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use helper here
@@ -0,0 +1,58 @@ | |||
var global = require('../helpers/global') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please document all functions here.
src/storage/storageViewer.js
Outdated
|
||
class StorageViewer { | ||
constructor (_context, _storageResolver, _traceManager) { | ||
this.context = _context | ||
this.storageResolver = _storageResolver | ||
// contains [mappingSlot][mappingkey] = preimage | ||
// this map is renewed for each execution step |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should only do it once at the beginning of the debugging session and use the trace otherwise.
src/web3Provider/web3VmProvider.js
Outdated
function pushSha3Preimage (self, sha3Input) { | ||
var preimage = sha3Input | ||
var imageHash = ethutil.sha3('0x' + sha3Input).toString('hex') | ||
self.sha3Preimages[imageHash] = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using self in that way here looks a bit weird. What about moving the code to the point where this function is called?
src/web3Provider/web3VmProvider.js
Outdated
memoryStart = parseInt(memStartDec) * 2 | ||
var memLengthDec = (new ethutil.BN(memoryLength.replace('0x', ''), 16).toString(10)) | ||
memoryLength = parseInt(memLengthDec) * 2 | ||
var memoryHex = memory.join('') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please avoid this (high complexity).
- add we3.debug.preimage - move mapping resolver from soliditystate to storageViewer
src/web3Provider/web3VmProvider.js
Outdated
var subMemoryIndex = Math.floor(memoryStart / 32) | ||
var sha3Input = '' | ||
while (sha3Input.length < memoryLength) { | ||
sha3Input += memory[subMemoryIndex] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I think I misunderstood your question earlier. Unfortunately this won't work. Types in memory most of the time have a length of 32 bytes but
- they might be offset by some amount
- this does not apply to sha3
* | ||
* @param {Function} callback | ||
*/ | ||
async mappingsLocation () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return a promise
Work in progress, don't merge.