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
39c5e31e
Commit
39c5e31e
authored
Jun 04, 2019
by
Iuri Matias
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cleanup
parent
85c0c518
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
11 additions
and
105 deletions
+11
-105
execution-context.js
remix-lib/src/execution/execution-context.js
+0
-5
txRunner.js
remix-lib/src/execution/txRunner.js
+8
-64
web3VmProvider.js
remix-lib/src/web3Provider/web3VmProvider.js
+0
-2
blocks.js
remix-simulator/src/methods/blocks.js
+0
-6
transactions.js
remix-simulator/src/methods/transactions.js
+3
-28
No files found.
remix-lib/src/execution/execution-context.js
View file @
39c5e31e
...
...
@@ -118,8 +118,6 @@ function ExecutionContext () {
}
this
.
web3
=
function
()
{
console
.
dir
(
"isVM"
)
console
.
dir
(
this
.
isVM
())
return
this
.
isVM
()
?
vms
.
constantinople
.
web3vm
:
web3
}
...
...
@@ -188,9 +186,6 @@ function ExecutionContext () {
if
(
context
===
'vm'
)
{
executionContext
=
context
// vms.constantinople.stateManager.revert(() => {
// vms.constantinople.stateManager.checkpoint(() => {})
// })
self
.
event
.
trigger
(
'contextChanged'
,
[
'vm'
])
return
cb
()
}
...
...
remix-lib/src/execution/txRunner.js
View file @
39c5e31e
...
...
@@ -94,7 +94,7 @@ class TxRunner {
}
}
runInVm
(
from
,
to
,
data
,
value
,
gasLimit
,
useCall
,
timestamp
,
callback
)
{
runInVm
(
from
,
to
,
data
,
value
,
gasLimit
,
useCall
,
timestamp
,
callback
)
{
const
self
=
this
var
account
=
self
.
vmaccounts
[
from
]
if
(
!
account
)
{
...
...
@@ -111,106 +111,50 @@ class TxRunner {
})
tx
.
sign
(
account
.
privateKey
)
const
coinbases
=
[
'0x0e9281e9c6a0808672eaba6bd1220e144c9bb07a'
,
'0x8945a1288dc78a6d8952a92c77aee6730b414778'
,
'0x94d76e24f818426ae84aa404140e8d5f60e10e7e'
]
const
difficulties
=
[
new
BN
(
'69762765929000'
,
10
),
new
BN
(
'70762765929000'
,
10
),
new
BN
(
'71762765929000'
,
10
)
]
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],
// coinbase: coinbases[0],
//difficulty: difficulties[0],
coinbase
:
coinbases
[
self
.
blockNumber
%
coinbases
.
length
],
difficulty
:
difficulties
[
self
.
blockNumber
%
difficulties
.
length
],
coinbase
:
coinbases
[
0
],
// gasLimit: new BN(gasLimit, 10).imuln(200),
gasLimit
:
new
BN
(
"5000000"
).
imuln
(
1
)
},
transactions
:
[
tx
],
//transactions: [],
uncleHeaders
:
[]
})
if
(
!
useCall
)
{
++
self
.
blockNumber
}
else
{
executionContext
.
vm
().
stateManager
.
checkpoint
(()
=>
{})
executionContext
.
vm
().
stateManager
.
checkpoint
(()
=>
{
})
}
//block.transactions.push(tx);
this
.
checkpointAndCommit
(()
=>
{
//executionContext.vm().blockchain.getLatestBlock((a, b) => {
// console.dir("b.hash()")
// console.dir(b.hash())
// console.dir(b.hash().length)
// console.dir(b.hash().toString('hex'))
// console.dir(b.hash().toString('hex').length)
// block.header.parentHash = b.hash()
// block.header.parentHash = b.hash().toString('hex')
//block.header.parentHash = Buffer.from(b.hash(), 'hex')
//block.header.parentHash = "4599f6765f1d5a50Bf1E3DBFa14A72dF"
// block.header.parentHash = b.hash()
// block.header.difficulty = block.header.canonicalDifficulty(b)
//executionContext.vm().runTx({block: block, tx: tx, skipBalance: true, skipNonce: true}, function (err, result) {
executionContext
.
vm
().
runBlock
({
block
:
block
,
generate
:
true
,
skipBlockValidation
:
true
,
skipBalance
:
false
},
function
(
err
,
results
)
{
console
.
dir
(
"-- runBlock result"
)
console
.
dir
(
err
)
//console.dir(results)
executionContext
.
vm
().
runBlock
({
block
:
block
,
generate
:
true
,
skipBlockValidation
:
true
,
skipBalance
:
false
},
function
(
err
,
results
)
{
let
result
=
results
.
results
[
0
]
console
.
dir
(
result
)
if
(
useCall
)
{
executionContext
.
vm
().
stateManager
.
revert
(
function
()
{
})
executionContext
.
vm
().
stateManager
.
revert
(
function
()
{
})
}
err
=
err
?
err
.
message
:
err
if
(
result
)
{
result
.
status
=
'0x'
+
result
.
vm
.
exception
.
toString
(
16
)
}
//executionContext.vm().blockchain.putBlock(block, (err, savedBlock) => {
executionContext
.
addBlock
(
block
)
executionContext
.
trackTx
(
"0x"
+
tx
.
hash
().
toString
(
'hex'
),
block
)
// result.blockHash = "0x" + block.hash().toString('hex')
// result.blockNumber = "0x" + block.header.number.toString('hex')
callback
(
err
,
{
result
:
result
,
transactionHash
:
ethJSUtil
.
bufferToHex
(
Buffer
.
from
(
tx
.
hash
()))
})
//})
})
//})
})
//})
}
checkpointAndCommit
(
cb
)
{
console
.
dir
(
"------------------------"
)
console
.
dir
(
"------------------------"
)
console
.
dir
(
"------------------------"
)
console
.
dir
(
"------------------------"
)
console
.
dir
(
"------------------------"
)
console
.
dir
(
"------------------------"
)
console
.
dir
(
executionContext
.
vm
().
stateManager
.
_checkpointCount
)
console
.
dir
(
"------------------------"
)
console
.
dir
(
"------------------------"
)
console
.
dir
(
"------------------------"
)
console
.
dir
(
"------------------------"
)
console
.
dir
(
"------------------------"
)
console
.
dir
(
"------------------------"
)
if
(
executionContext
.
vm
().
stateManager
.
_checkpointCount
>
0
)
{
return
executionContext
.
vm
().
stateManager
.
commit
(()
=>
{
cb
()
...
...
remix-lib/src/web3Provider/web3VmProvider.js
View file @
39c5e31e
...
...
@@ -194,8 +194,6 @@ web3VmProvider.prototype.pushTrace = function (self, data) {
}
web3VmProvider
.
prototype
.
getCode
=
function
(
address
,
cb
)
{
console
.
dir
(
"===> web3VmProvider: "
)
const
account
=
ethutil
.
toBuffer
(
address
)
this
.
vm
.
stateManager
.
getContractCode
(
account
,
function
(
error
,
result
)
{
cb
(
error
,
util
.
hexConvert
(
result
))
...
...
remix-simulator/src/methods/blocks.js
View file @
39c5e31e
...
...
@@ -56,12 +56,6 @@ function toHex(value) {
}
Blocks
.
prototype
.
eth_getBlockByHash
=
function
(
payload
,
cb
)
{
console
.
dir
(
"eth_getBlockByHash"
)
console
.
dir
(
payload
)
console
.
dir
(
Object
.
keys
(
executionContext
.
blocks
))
console
.
dir
(
"== toJSON"
)
console
.
dir
(
executionContext
.
blocks
[
payload
.
params
[
0
]].
toJSON
())
var
block
=
executionContext
.
blocks
[
payload
.
params
[
0
]]
let
b
=
{
...
...
remix-simulator/src/methods/transactions.js
View file @
39c5e31e
...
...
@@ -40,8 +40,6 @@ Transactions.prototype.eth_sendTransaction = function (payload, cb) {
}
Transactions
.
prototype
.
eth_getTransactionReceipt
=
function
(
payload
,
cb
)
{
console
.
dir
(
"== eth_getTransactionReceipt"
)
console
.
dir
(
payload
.
params
)
executionContext
.
web3
().
eth
.
getTransactionReceipt
(
payload
.
params
[
0
],
(
error
,
receipt
)
=>
{
if
(
error
)
{
return
cb
(
error
)
...
...
@@ -70,22 +68,13 @@ Transactions.prototype.eth_estimateGas = function (payload, cb) {
}
Transactions
.
prototype
.
eth_getCode
=
function
(
payload
,
cb
)
{
console
.
dir
(
"== eth_getCode"
)
console
.
dir
(
payload
.
params
)
let
address
=
payload
.
params
[
0
]
console
.
dir
(
address
);
// const account = ethJSUtil.toBuffer(address)
// console.dir(account)
//executionContext.vm().stateManager.getContractCode(account, (error, result) => {
//executionContext.web3().eth.getContractCode(address, (error, result) => {
executionContext
.
web3
().
eth
.
getCode
(
address
,
(
error
,
result
)
=>
{
if
(
error
)
{
console
.
dir
(
"error getting code"
);
console
.
dir
(
error
);
}
//cb(error, hexConvert(result))
cb
(
error
,
result
)
})
}
...
...
@@ -107,8 +96,6 @@ Transactions.prototype.eth_getTransactionCount = function (payload, cb) {
}
Transactions
.
prototype
.
eth_getTransactionByHash
=
function
(
payload
,
cb
)
{
console
.
dir
(
"== eth_getTransactionByHash"
)
console
.
dir
(
payload
.
params
)
const
address
=
payload
.
params
[
0
]
executionContext
.
web3
().
eth
.
getTransactionReceipt
(
address
,
(
error
,
receipt
)
=>
{
...
...
@@ -116,14 +103,11 @@ Transactions.prototype.eth_getTransactionByHash = function (payload, cb) {
return
cb
(
error
)
}
console
.
dir
(
"== receipt"
)
console
.
dir
(
receipt
)
var
test
=
executionContext
.
web3
();
var
txBlock
=
executionContext
.
txs
[
receipt
.
transactionHash
];
//
executionContext.web3().eth.getBlock(receipt.hash).then((block) => {
//
TODO: params to add later
let
r
=
{
'blockHash'
:
"0x"
+
txBlock
.
hash
().
toString
(
'hex'
),
'blockNumber'
:
"0x"
+
txBlock
.
header
.
number
.
toString
(
'hex'
),
...
...
@@ -151,14 +135,10 @@ Transactions.prototype.eth_getTransactionByHash = function (payload, cb) {
}
cb
(
null
,
r
)
// })
})
}
Transactions
.
prototype
.
eth_getTransactionByBlockHashAndIndex
=
function
(
payload
,
cb
)
{
console
.
dir
(
"== eth_getTransactionByHash"
)
console
.
dir
(
payload
.
params
)
// const address = payload.params[0]
const
txIndex
=
payload
.
params
[
1
]
var
txBlock
=
executionContext
.
blocks
[
payload
.
params
[
0
]]
...
...
@@ -169,7 +149,7 @@ Transactions.prototype.eth_getTransactionByBlockHashAndIndex = function (payload
return
cb
(
error
)
}
//
executionContext.web3().eth.getBlock(receipt.hash).then((block) => {
//
TODO: params to add later
let
r
=
{
'blockHash'
:
"0x"
+
txBlock
.
hash
().
toString
(
'hex'
),
'blockNumber'
:
"0x"
+
txBlock
.
header
.
number
.
toString
(
'hex'
),
...
...
@@ -197,14 +177,10 @@ Transactions.prototype.eth_getTransactionByBlockHashAndIndex = function (payload
}
cb
(
null
,
r
)
// })
})
}
Transactions
.
prototype
.
eth_getTransactionByBlockNumberAndIndex
=
function
(
payload
,
cb
)
{
console
.
dir
(
"== eth_getTransactionByHash"
)
console
.
dir
(
payload
.
params
)
// const address = payload.params[0]
const
txIndex
=
payload
.
params
[
1
]
var
txBlock
=
executionContext
.
blocks
[
payload
.
params
[
0
]]
...
...
@@ -215,7 +191,7 @@ Transactions.prototype.eth_getTransactionByBlockNumberAndIndex = function (paylo
return
cb
(
error
)
}
//
executionContext.web3().eth.getBlock(receipt.hash).then((block) => {
//
TODO: params to add later
let
r
=
{
'blockHash'
:
"0x"
+
txBlock
.
hash
().
toString
(
'hex'
),
'blockNumber'
:
"0x"
+
txBlock
.
header
.
number
.
toString
(
'hex'
),
...
...
@@ -243,7 +219,6 @@ Transactions.prototype.eth_getTransactionByBlockNumberAndIndex = function (paylo
}
cb
(
null
,
r
)
// })
})
}
...
...
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