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
035150e4
Commit
035150e4
authored
Jan 03, 2017
by
yann300
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
calculate cost of SSTORE & store empty storage if creation
parent
d3f25cf5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
6 deletions
+36
-6
web3VmProvider.js
src/web3Provider/web3VmProvider.js
+36
-6
No files found.
src/web3Provider/web3VmProvider.js
View file @
035150e4
var
util
=
require
(
'../helpers/util'
)
var
util
=
require
(
'../helpers/util'
)
var
uiutil
=
require
(
'../helpers/ui'
)
var
traceHelper
=
require
(
'../helpers/traceHelper'
)
var
traceHelper
=
require
(
'../helpers/traceHelper'
)
var
Web3
=
require
(
'web3'
)
var
Web3
=
require
(
'web3'
)
var
fees
=
require
(
'ethereum-common'
)
var
ethutil
=
require
(
'ethereumjs-util'
)
function
web3VmProvider
()
{
function
web3VmProvider
()
{
var
self
=
this
var
self
=
this
...
@@ -9,6 +12,8 @@ function web3VmProvider () {
...
@@ -9,6 +12,8 @@ function web3VmProvider () {
this
.
vmTraces
=
{}
this
.
vmTraces
=
{}
this
.
txs
=
{}
this
.
txs
=
{}
this
.
processingHash
this
.
processingHash
this
.
processingAddress
this
.
processingIndex
this
.
incr
=
0
this
.
incr
=
0
this
.
eth
=
{}
this
.
eth
=
{}
this
.
debug
=
{}
this
.
debug
=
{}
...
@@ -43,7 +48,7 @@ web3VmProvider.prototype.releaseCurrentHash = function () {
...
@@ -43,7 +48,7 @@ web3VmProvider.prototype.releaseCurrentHash = function () {
return
ret
return
ret
}
}
web3VmProvider
.
prototype
.
txWillProcess
=
function
(
self
,
data
)
{
web3VmProvider
.
prototype
.
txWillProcess
=
function
(
self
,
data
)
{
self
.
incr
++
self
.
incr
++
self
.
processingHash
=
util
.
hexConvert
(
data
.
hash
())
self
.
processingHash
=
util
.
hexConvert
(
data
.
hash
())
self
.
vmTraces
[
self
.
processingHash
]
=
{
self
.
vmTraces
[
self
.
processingHash
]
=
{
...
@@ -57,6 +62,7 @@ web3VmProvider.prototype.txWillProcess = function (self, data) {
...
@@ -57,6 +62,7 @@ web3VmProvider.prototype.txWillProcess = function (self, data) {
if
(
data
.
to
&&
data
.
to
.
length
)
{
if
(
data
.
to
&&
data
.
to
.
length
)
{
tx
.
to
=
util
.
hexConvert
(
data
.
to
)
tx
.
to
=
util
.
hexConvert
(
data
.
to
)
}
}
this
.
processingAddress
=
tx
.
to
tx
.
data
=
util
.
hexConvert
(
data
.
data
)
tx
.
data
=
util
.
hexConvert
(
data
.
data
)
tx
.
input
=
util
.
hexConvert
(
data
.
input
)
tx
.
input
=
util
.
hexConvert
(
data
.
input
)
tx
.
gas
=
util
.
hexConvert
(
data
.
gas
)
tx
.
gas
=
util
.
hexConvert
(
data
.
gas
)
...
@@ -70,6 +76,7 @@ web3VmProvider.prototype.txWillProcess = function (self, data) {
...
@@ -70,6 +76,7 @@ web3VmProvider.prototype.txWillProcess = function (self, data) {
self
.
storageCache
[
self
.
processingHash
][
tx
.
to
]
=
storage
self
.
storageCache
[
self
.
processingHash
][
tx
.
to
]
=
storage
})
})
}
}
this
.
processingIndex
=
0
}
}
web3VmProvider
.
prototype
.
txProcessed
=
function
(
self
,
data
)
{
web3VmProvider
.
prototype
.
txProcessed
=
function
(
self
,
data
)
{
...
@@ -79,6 +86,8 @@ web3VmProvider.prototype.txProcessed = function (self, data) {
...
@@ -79,6 +86,8 @@ web3VmProvider.prototype.txProcessed = function (self, data) {
}
else
{
}
else
{
self
.
vmTraces
[
self
.
processingHash
].
return
=
util
.
hexConvert
(
data
.
vm
.
return
)
self
.
vmTraces
[
self
.
processingHash
].
return
=
util
.
hexConvert
(
data
.
vm
.
return
)
}
}
this
.
processingIndex
=
null
this
.
processingAddress
=
null
}
}
web3VmProvider
.
prototype
.
pushTrace
=
function
(
self
,
data
)
{
web3VmProvider
.
prototype
.
pushTrace
=
function
(
self
,
data
)
{
...
@@ -95,15 +104,36 @@ web3VmProvider.prototype.pushTrace = function (self, data) {
...
@@ -95,15 +104,36 @@ web3VmProvider.prototype.pushTrace = function (self, data) {
gasCost
:
data
.
opcode
.
fee
.
toString
(),
gasCost
:
data
.
opcode
.
fee
.
toString
(),
gas
:
data
.
gasLeft
.
toString
()
gas
:
data
.
gasLeft
.
toString
()
}
}
if
(
data
.
opcode
.
name
===
'SSTORE'
)
{
var
currentStorage
=
this
.
storageCache
[
this
.
processingHash
][
this
.
processingAddress
]
var
key
=
step
.
stack
[
step
.
stack
.
length
-
1
]
var
value
=
step
.
stack
[
step
.
stack
.
length
-
2
]
value
=
util
.
hexToIntArray
(
value
)
value
=
ethutil
.
unpad
(
value
)
if
(
value
.
length
===
0
)
{
data
.
opcode
.
fee
=
fees
.
sstoreResetGas
.
v
}
else
if
(
currentStorage
[
key
]
===
undefined
)
{
data
.
opcode
.
fee
=
fees
.
sstoreSetGas
.
v
}
else
{
data
.
opcode
.
fee
=
fees
.
sstoreResetGas
.
v
}
step
.
gasCost
=
data
.
opcode
.
fee
}
self
.
vmTraces
[
self
.
processingHash
].
structLogs
.
push
(
step
)
self
.
vmTraces
[
self
.
processingHash
].
structLogs
.
push
(
step
)
if
(
traceHelper
.
newContextStorage
(
step
))
{
if
(
traceHelper
.
newContextStorage
(
step
))
{
if
(
!
self
.
storageCache
[
self
.
processingHash
][
address
])
{
if
(
step
.
op
===
'CREATE'
)
{
var
address
=
step
.
stack
[
step
.
stack
.
length
-
2
]
this
.
processingAddress
=
traceHelper
.
contractCreationToken
(
this
.
processingIndex
)
self
.
vm
.
stateManager
.
dumpStorage
(
address
,
function
(
storage
)
{
this
.
storageCache
[
this
.
processingHash
][
this
.
processingAddress
]
=
{}
self
.
storageCache
[
self
.
processingHash
][
address
]
=
storage
}
else
{
})
this
.
processingAddress
=
uiutil
.
normalizeHex
(
step
.
stack
[
step
.
stack
.
length
-
2
])
if
(
!
self
.
storageCache
[
self
.
processingHash
][
this
.
processingAddress
])
{
self
.
vm
.
stateManager
.
dumpStorage
(
this
.
processingAddress
,
function
(
storage
)
{
self
.
storageCache
[
self
.
processingHash
][
this
.
processingAddress
]
=
storage
})
}
}
}
}
}
this
.
processingIndex
++
}
}
web3VmProvider
.
prototype
.
getCode
=
function
(
address
,
cb
)
{
web3VmProvider
.
prototype
.
getCode
=
function
(
address
,
cb
)
{
...
...
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