Commit b2760e67 authored by chriseth's avatar chriseth Committed by GitHub

Merge pull request #158 from ethereum/storageRangeat

add storageRangeAt
parents 703c8579 3c0742c6
...@@ -21,9 +21,17 @@ TraceRetriever.prototype.getStorage = function (tx, address, callback) { ...@@ -21,9 +21,17 @@ TraceRetriever.prototype.getStorage = function (tx, address, callback) {
if (traceHelper.isContractCreation(address)) { if (traceHelper.isContractCreation(address)) {
callback(null, {}) callback(null, {})
} else { } else {
util.web3.debug.storageAt(null, tx.hash, address, function (error, result) { if (util.web3.debug.storageRangeAt) {
callback(error, result) var end = 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'
var maxSize = 10000
// The VM gives only a tx hash
// TODO: get rid of that and use the range parameters
util.web3.debug.storageRangeAt(tx.blockHash, tx.transactionIndex === undefined ? tx.hash : tx.transactionIndex, address, '0x0', '0x' + end, maxSize, function (error, result) {
callback(error, result.storage)
}) })
} else {
callback('no storageRangeAt endpoint found')
}
} }
} }
......
...@@ -45,7 +45,7 @@ FullStoragesChanges.prototype.init = function () { ...@@ -45,7 +45,7 @@ FullStoragesChanges.prototype.init = function () {
if (index === self.traceLength - 1) { if (index === self.traceLength - 1) {
var storageJSON = {} var storageJSON = {}
for (var k in self.addresses) { for (var k in self.addresses) {
self.traceManager.getStorageAt(index, null, function (error, result) { self.traceManager.getStorageAt(index, this.parent.tx, function (error, result) {
if (!error) { if (!error) {
storageJSON[self.addresses[k]] = result storageJSON[self.addresses[k]] = result
self.basicPanel.update(storageJSON) self.basicPanel.update(storageJSON)
......
'use strict' 'use strict'
module.exports = { module.exports = {
extend: function (web3) { extend: function (web3) {
if (!web3._extend) {
return
}
// DEBUG // DEBUG
var methods = [] var methods = []
if (!(web3.debug && web3.debug.traceTransaction)) { if (!(web3.debug && web3.debug.traceTransaction)) {
...@@ -12,12 +15,12 @@ module.exports = { ...@@ -12,12 +15,12 @@ module.exports = {
})) }))
} }
if (!(web3.debug && web3.debug.storageAt)) { if (!(web3.debug && web3.debug.storageRangeAt)) {
methods.push(new web3._extend.Method({ methods.push(new web3._extend.Method({
name: 'storageAt', name: 'storageRangeAt',
call: 'debug_storageAt', call: 'debug_storageRangeAt',
inputFormatter: [null, null, null], inputFormatter: [null, null, null, null, null, null],
params: 3 params: 6
})) }))
} }
if (methods.length > 0) { if (methods.length > 0) {
......
...@@ -7,7 +7,7 @@ function dummyProvider () { ...@@ -7,7 +7,7 @@ function dummyProvider () {
this.eth.getTransactionFromBlock = function (blockNumber, txIndex, cb) { return self.getTransactionFromBlock(blockNumber, txIndex, cb) } this.eth.getTransactionFromBlock = function (blockNumber, txIndex, cb) { return self.getTransactionFromBlock(blockNumber, txIndex, cb) }
this.eth.getBlockNumber = function (cb) { return self.getBlockNumber(cb) } this.eth.getBlockNumber = function (cb) { return self.getBlockNumber(cb) }
this.debug.traceTransaction = function (hash, options, cb) { return self.traceTransaction(hash, options, cb) } this.debug.traceTransaction = function (hash, options, cb) { return self.traceTransaction(hash, options, cb) }
this.debug.storageAt = function (blockNumber, txIndex, address, cb) { return self.storageAt(blockNumber, txIndex, address, cb) } this.debug.storageRangeAt = function (blockNumber, txIndex, address, start, end, maxLength, cb) { return self.storageRangeAt(blockNumber, txIndex, address, start, end, maxLength, cb) }
this.providers = { 'HttpProvider': function (url) {} } this.providers = { 'HttpProvider': function (url) {} }
this.currentProvider = {'host': ''} this.currentProvider = {'host': ''}
} }
...@@ -25,7 +25,7 @@ dummyProvider.prototype.traceTransaction = function (txHash, options, cb) { ...@@ -25,7 +25,7 @@ dummyProvider.prototype.traceTransaction = function (txHash, options, cb) {
return {} return {}
} }
dummyProvider.prototype.storageAt = function (blockNumber, txIndex, address, cb) { cb(null, {}) } dummyProvider.prototype.storageRangeAt = function (blockNumber, txIndex, address, start, end, maxLength, cb) { cb(null, {}) }
dummyProvider.prototype.getBlockNumber = function (cb) { cb(null, '') } dummyProvider.prototype.getBlockNumber = function (cb) { cb(null, '') }
......
...@@ -17,7 +17,7 @@ function web3VmProvider () { ...@@ -17,7 +17,7 @@ function web3VmProvider () {
this.eth.getTransactionFromBlock = function (blockNumber, txIndex, cb) { return self.getTransactionFromBlock(blockNumber, txIndex, cb) } this.eth.getTransactionFromBlock = function (blockNumber, txIndex, cb) { return self.getTransactionFromBlock(blockNumber, txIndex, cb) }
this.eth.getBlockNumber = function (cb) { return self.getBlockNumber(cb) } this.eth.getBlockNumber = function (cb) { return self.getBlockNumber(cb) }
this.debug.traceTransaction = function (hash, options, cb) { return self.traceTransaction(hash, options, cb) } this.debug.traceTransaction = function (hash, options, cb) { return self.traceTransaction(hash, options, cb) }
this.debug.storageAt = function (blockNumber, txIndex, address, cb) { return self.storageAt(blockNumber, txIndex, address, cb) } this.debug.storageRangeAt = function (blockNumber, txIndex, address, start, end, maxLength, cb) { return self.storageRangeAt(blockNumber, txIndex, address, start, end, maxLength, cb) }
this.providers = { 'HttpProvider': function (url) {} } this.providers = { 'HttpProvider': function (url) {} }
this.currentProvider = {'host': 'vm provider'} this.currentProvider = {'host': 'vm provider'}
this.storageCache = {} this.storageCache = {}
...@@ -127,10 +127,14 @@ web3VmProvider.prototype.traceTransaction = function (txHash, options, cb) { ...@@ -127,10 +127,14 @@ web3VmProvider.prototype.traceTransaction = function (txHash, options, cb) {
} }
} }
web3VmProvider.prototype.storageAt = function (blockNumber, txIndex, address, cb) { // txIndex is the hash in the case of the VM web3VmProvider.prototype.storageRangeAt = function (blockNumber, txIndex, address, start, end, maxLength, cb) { // txIndex is the hash in the case of the VM
// we don't use the range params here
if (this.storageCache[txIndex] && this.storageCache[txIndex][address]) { if (this.storageCache[txIndex] && this.storageCache[txIndex][address]) {
var storage = this.storageCache[txIndex][address] var storage = this.storageCache[txIndex][address]
return cb(null, JSON.parse(JSON.stringify(storage))) // copy creation... return cb(null, {
storage: JSON.parse(JSON.stringify(storage)), // copy
complete: true
})
} else { } else {
cb('unable to retrieve storage ' + txIndex + ' ' + address) cb('unable to retrieve storage ' + txIndex + ' ' + address)
} }
......
...@@ -64,6 +64,7 @@ function panels (browser) { ...@@ -64,6 +64,7 @@ function panels (browser) {
.click('#load') .click('#load')
.click('#nextcall') .click('#nextcall')
.assertStack(['0x', '0x60', '0x65', '0x38', '0x55', '0x60fe47b1']) .assertStack(['0x', '0x60', '0x65', '0x38', '0x55', '0x60fe47b1'])
.pause(5000)
.assertStorageChanges(['0x000x38']) .assertStorageChanges(['0x000x38'])
.assertCallData(['0x60fe47b10000000000000000000000000000000000000000000000000000000000000038']) .assertCallData(['0x60fe47b10000000000000000000000000000000000000000000000000000000000000038'])
.assertCallStack(['0x0d3a18d64dfe4f927832ab58d6451cecc4e517c5']) .assertCallStack(['0x0d3a18d64dfe4f927832ab58d6451cecc4e517c5'])
......
...@@ -2,7 +2,7 @@ var init = { ...@@ -2,7 +2,7 @@ var init = {
overrideWeb3: function (web3, web3Override) { overrideWeb3: function (web3, web3Override) {
web3.eth.getCode = web3Override.getCode web3.eth.getCode = web3Override.getCode
web3.debug.traceTransaction = web3Override.traceTransaction web3.debug.traceTransaction = web3Override.traceTransaction
web3.debug.storageAt = web3Override.storageAt web3.debug.storageRangeAt = web3Override.storageRangeAt
web3.eth.getTransaction = web3Override.getTransaction web3.eth.getTransaction = web3Override.getTransaction
web3.eth.getTransactionFromBlock = web3Override.getTransactionFromBlock web3.eth.getTransactionFromBlock = web3Override.getTransactionFromBlock
web3.eth.getBlockNumber = web3Override.getBlockNumber web3.eth.getBlockNumber = web3Override.getBlockNumber
......
...@@ -28,8 +28,8 @@ function loadTestWeb3 (data) { ...@@ -28,8 +28,8 @@ function loadTestWeb3 (data) {
callback(null, data.testTraces[txHash]) callback(null, data.testTraces[txHash])
} }
uiTestweb3.debug.storageAt = function (blockNumber, txIndex, address, callback) { uiTestweb3.debug.storageRangeAt = function (blockNumber, txIndex, address, start, end, size, callback) {
callback(null, {}) callback(null, { storage: {}, complete: true })
} }
uiTestweb3.eth.getTransaction = function (txHash, callback) { uiTestweb3.eth.getTransaction = function (txHash, callback) {
......
...@@ -18,8 +18,8 @@ web3Override.debug.traceTransaction = function (txHash, options, callback) { ...@@ -18,8 +18,8 @@ web3Override.debug.traceTransaction = function (txHash, options, callback) {
callback(null, data.testTraces[txHash]) callback(null, data.testTraces[txHash])
} }
web3Override.debug.storageAt = function (blockNumber, txIndex, address, callback) { web3Override.debug.storageRangeAt = function (blockNumber, txIndex, address, start, end, maxSize, callback) {
callback(null, {}) callback(null, { storage: {}, complete: true })
} }
web3Override.eth.getTransaction = function (txHash, callback) { web3Override.eth.getTransaction = function (txHash, callback) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment