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
62dd310f
Unverified
Commit
62dd310f
authored
Sep 03, 2019
by
yann300
Committed by
GitHub
Sep 03, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1278 from ethereum/fixNonStateChangingCalls
Fix sending non state changing call
parents
516fd3f0
b2f7cd14
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
76 additions
and
47 deletions
+76
-47
execution-context.js
remix-lib/src/execution/execution-context.js
+18
-0
txRunner.js
remix-lib/src/execution/txRunner.js
+58
-47
No files found.
remix-lib/src/execution/execution-context.js
View file @
62dd310f
...
...
@@ -56,6 +56,24 @@ class StateManagerCommonStorageDump extends StateManager {
})
})
}
getStateRoot
(
cb
)
{
let
checkpoint
=
this
.
_checkpointCount
this
.
_checkpointCount
=
0
super
.
getStateRoot
((
err
,
stateRoot
)
=>
{
this
.
_checkpointCount
=
checkpoint
cb
(
err
,
stateRoot
)
})
}
setStateRoot
(
stateRoot
,
cb
)
{
let
checkpoint
=
this
.
_checkpointCount
this
.
_checkpointCount
=
0
super
.
setStateRoot
(
stateRoot
,
(
err
)
=>
{
this
.
_checkpointCount
=
checkpoint
cb
(
err
)
})
}
}
function
createVm
(
hardfork
)
{
...
...
remix-lib/src/execution/txRunner.js
View file @
62dd310f
...
...
@@ -101,59 +101,70 @@ class TxRunner {
return
callback
(
'Invalid account selected'
)
}
var
tx
=
new
EthJSTX
({
timestamp
:
timestamp
,
nonce
:
new
BN
(
account
.
nonce
++
),
gasPrice
:
new
BN
(
1
),
gasLimit
:
gasLimit
,
to
:
to
,
value
:
new
BN
(
value
,
10
),
data
:
Buffer
.
from
(
data
.
slice
(
2
),
'hex'
)
})
tx
.
sign
(
account
.
privateKey
)
executionContext
.
vm
().
stateManager
.
getAccount
(
Buffer
.
from
(
from
.
replace
(
'0x'
,
''
),
'hex'
),
(
err
,
res
)
=>
{
if
(
err
)
{
callback
(
'Account not found'
)
}
else
{
var
tx
=
new
EthJSTX
({
timestamp
:
timestamp
,
nonce
:
new
BN
(
res
.
nonce
),
gasPrice
:
new
BN
(
1
),
gasLimit
:
gasLimit
,
to
:
to
,
value
:
new
BN
(
value
,
10
),
data
:
Buffer
.
from
(
data
.
slice
(
2
),
'hex'
)
})
tx
.
sign
(
account
.
privateKey
)
const
coinbases
=
[
'0x0e9281e9c6a0808672eaba6bd1220e144c9bb07a'
,
'0x8945a1288dc78a6d8952a92c77aee6730b414778'
,
'0x94d76e24f818426ae84aa404140e8d5f60e10e7e'
]
const
difficulties
=
[
new
BN
(
'69762765929000'
,
10
),
new
BN
(
'70762765929000'
,
10
),
new
BN
(
'71762765929000'
,
10
)]
var
block
=
new
EthJSBlock
({
header
:
{
timestamp
:
timestamp
||
(
new
Date
().
getTime
()
/
1000
|
0
),
number
:
self
.
blockNumber
,
coinbase
:
coinbases
[
self
.
blockNumber
%
coinbases
.
length
],
difficulty
:
difficulties
[
self
.
blockNumber
%
difficulties
.
length
],
gasLimit
:
new
BN
(
gasLimit
,
10
).
imuln
(
2
)
},
transactions
:
[
tx
],
uncleHeaders
:
[]
const
coinbases
=
[
'0x0e9281e9c6a0808672eaba6bd1220e144c9bb07a'
,
'0x8945a1288dc78a6d8952a92c77aee6730b414778'
,
'0x94d76e24f818426ae84aa404140e8d5f60e10e7e'
]
const
difficulties
=
[
new
BN
(
'69762765929000'
,
10
),
new
BN
(
'70762765929000'
,
10
),
new
BN
(
'71762765929000'
,
10
)]
var
block
=
new
EthJSBlock
({
header
:
{
timestamp
:
timestamp
||
(
new
Date
().
getTime
()
/
1000
|
0
),
number
:
self
.
blockNumber
,
coinbase
:
coinbases
[
self
.
blockNumber
%
coinbases
.
length
],
difficulty
:
difficulties
[
self
.
blockNumber
%
difficulties
.
length
],
gasLimit
:
new
BN
(
gasLimit
,
10
).
imuln
(
2
)
},
transactions
:
[
tx
],
uncleHeaders
:
[]
})
if
(
!
useCall
)
{
++
self
.
blockNumber
this
.
runBlockInVm
(
tx
,
block
,
callback
)
}
else
{
executionContext
.
vm
().
stateManager
.
checkpoint
(()
=>
{
this
.
runBlockInVm
(
tx
,
block
,
(
err
,
result
)
=>
{
executionContext
.
vm
().
stateManager
.
revert
(()
=>
{
callback
(
err
,
result
)
})
})
})
}
}
})
if
(
!
useCall
)
{
++
self
.
blockNumber
}
else
{
executionContext
.
vm
().
stateManager
.
checkpoint
(()
=>
{
})
}
}
executionContext
.
checkpointAndCommit
(()
=>
{
executionContext
.
vm
().
runBlock
({
block
:
block
,
generate
:
true
,
skipBlockValidation
:
true
,
skipBalance
:
false
},
function
(
err
,
results
)
{
err
=
err
?
err
.
message
:
err
if
(
err
)
{
return
callback
(
err
)
}
let
result
=
results
.
results
[
0
]
if
(
useCall
)
{
executionContext
.
vm
().
stateManager
.
revert
(
function
()
{
})
}
if
(
result
)
{
result
.
status
=
'0x'
+
result
.
vm
.
exception
.
toString
(
16
)
}
runBlockInVm
(
tx
,
block
,
callback
)
{
executionContext
.
vm
().
runBlock
({
block
:
block
,
generate
:
true
,
skipBlockValidation
:
true
,
skipBalance
:
false
},
function
(
err
,
results
)
{
err
=
err
?
err
.
message
:
err
if
(
err
)
{
return
callback
(
err
)
}
let
result
=
results
.
results
[
0
]
executionContext
.
addBlock
(
block
)
executionContext
.
trackTx
(
'0x'
+
tx
.
hash
().
toString
(
'hex'
),
block
)
if
(
result
)
{
result
.
status
=
'0x'
+
result
.
vm
.
exception
.
toString
(
16
)
}
callback
(
err
,
{
result
:
result
,
transactionHash
:
ethJSUtil
.
bufferToHex
(
Buffer
.
from
(
tx
.
hash
()))
})
executionContext
.
addBlock
(
block
)
executionContext
.
trackTx
(
'0x'
+
tx
.
hash
().
toString
(
'hex'
),
block
)
callback
(
err
,
{
result
:
result
,
transactionHash
:
ethJSUtil
.
bufferToHex
(
Buffer
.
from
(
tx
.
hash
()))
})
}
,
1
)
})
}
runInNode
(
from
,
to
,
data
,
value
,
gasLimit
,
useCall
,
confirmCb
,
gasEstimationForceSend
,
promptCb
,
callback
)
{
...
...
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