This repository has been archived by the owner on Mar 3, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 565
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move sha3 mapping from traceChache to web3VMProvider
- add we3.debug.preimage - move mapping resolver from soliditystate to storageViewer
- Loading branch information
Showing
10 changed files
with
131 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
var global = require('../helpers/global') | ||
|
||
module.exports = { | ||
extractMappingPreimages: extractMappingPreimages | ||
} | ||
|
||
async function extractMappingPreimages (storageViewer) { | ||
return new Promise((resolve, reject) => { | ||
storageViewer.storageRange(function (error, storage) { | ||
if (!error) { | ||
decodeMappingsKeys(storage, (error, mappings) => { | ||
if (error) { | ||
reject(error) | ||
} else { | ||
resolve(mappings) | ||
} | ||
}) | ||
} else { | ||
reject(error) | ||
} | ||
}) | ||
}) | ||
} | ||
|
||
async function decodeMappingsKeys (storage, callback) { | ||
var ret = {} | ||
for (var hashedLoc in storage) { | ||
var preimage | ||
try { | ||
preimage = await getPreimage(storage[hashedLoc].key) | ||
} catch (e) { | ||
} | ||
if (preimage) { | ||
// got preimage! | ||
// get mapping position (i.e. storage slot), its the last 32 bytes | ||
var slotByteOffset = preimage.length - 64 | ||
var mappingSlot = preimage.substr(slotByteOffset) | ||
var mappingKey = preimage.substr(0, slotByteOffset) | ||
if (!ret[mappingSlot]) { | ||
ret[mappingSlot] = {} | ||
} | ||
ret[mappingSlot][mappingKey] = preimage | ||
} | ||
} | ||
callback(null, ret) | ||
} | ||
|
||
function getPreimage (key) { | ||
return new Promise((resolve, reject) => { | ||
global.web3.debug.preimage(key, function (error, preimage) { | ||
if (error) { | ||
reject(error) | ||
} else { | ||
resolve(preimage) | ||
} | ||
}) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters