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
9703013b
Commit
9703013b
authored
Sep 25, 2019
by
Iuri Matias
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix eth_getBlockByNumber when param is latest
parent
782d79e5
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
5 additions
and
26 deletions
+5
-26
execution-context.js
remix-lib/src/execution/execution-context.js
+2
-0
txRunner.js
remix-lib/src/execution/txRunner.js
+0
-3
accounts.js
remix-simulator/src/methods/accounts.js
+0
-12
blocks.js
remix-simulator/src/methods/blocks.js
+2
-6
provider.js
remix-simulator/src/provider.js
+0
-4
blocks.js
remix-simulator/test/blocks.js
+1
-1
No files found.
remix-lib/src/execution/execution-context.js
View file @
9703013b
...
@@ -115,6 +115,7 @@ function ExecutionContext () {
...
@@ -115,6 +115,7 @@ function ExecutionContext () {
this
.
blockGasLimit
=
this
.
blockGasLimitDefault
this
.
blockGasLimit
=
this
.
blockGasLimitDefault
this
.
customNetWorks
=
{}
this
.
customNetWorks
=
{}
this
.
blocks
=
{}
this
.
blocks
=
{}
this
.
latestBlockNumber
=
0
;
this
.
txs
=
{}
this
.
txs
=
{}
this
.
init
=
function
(
config
)
{
this
.
init
=
function
(
config
)
{
...
@@ -309,6 +310,7 @@ function ExecutionContext () {
...
@@ -309,6 +310,7 @@ function ExecutionContext () {
self
.
blocks
[
'0x'
+
block
.
hash
().
toString
(
'hex'
)]
=
block
self
.
blocks
[
'0x'
+
block
.
hash
().
toString
(
'hex'
)]
=
block
self
.
blocks
[
blockNumber
]
=
block
self
.
blocks
[
blockNumber
]
=
block
self
.
latestBlockNumber
=
blockNumber
this
.
logsManager
.
checkBlock
(
blockNumber
,
block
,
this
.
web3
())
this
.
logsManager
.
checkBlock
(
blockNumber
,
block
,
this
.
web3
())
}
}
...
...
remix-lib/src/execution/txRunner.js
View file @
9703013b
...
@@ -133,9 +133,6 @@ class TxRunner {
...
@@ -133,9 +133,6 @@ class TxRunner {
++
self
.
blockNumber
++
self
.
blockNumber
this
.
runBlockInVm
(
tx
,
block
,
callback
)
this
.
runBlockInVm
(
tx
,
block
,
callback
)
}
else
{
}
else
{
console
.
dir
(
"============"
)
console
.
dir
(
"========= useCall"
)
console
.
dir
(
"============"
)
executionContext
.
vm
().
stateManager
.
checkpoint
(()
=>
{
executionContext
.
vm
().
stateManager
.
checkpoint
(()
=>
{
this
.
runBlockInVm
(
tx
,
block
,
(
err
,
result
)
=>
{
this
.
runBlockInVm
(
tx
,
block
,
(
err
,
result
)
=>
{
executionContext
.
vm
().
stateManager
.
revert
(()
=>
{
executionContext
.
vm
().
stateManager
.
revert
(()
=>
{
...
...
remix-simulator/src/methods/accounts.js
View file @
9703013b
...
@@ -17,18 +17,6 @@ var Accounts = function () {
...
@@ -17,18 +17,6 @@ var Accounts = function () {
Accounts
.
prototype
.
init
=
async
function
()
{
Accounts
.
prototype
.
init
=
async
function
()
{
let
setBalance
=
(
account
)
=>
{
let
setBalance
=
(
account
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
// this.accountsKeys[ethJSUtil.toChecksumAddress(account.address).toLowerCase()] = account.privateKey
// this.accounts[ethJSUtil.toChecksumAddress(account.address).toLowerCase()] = { privateKey: Buffer.from(account.privateKey.replace('0x', ''), 'hex'), nonce: 0 }
// executionContext.vm().stateManager.getAccount(Buffer.from(account.address.toLowerCase().replace('0x', ''), 'hex'), (err, account) => {
// if (err) {
// throw new Error(err)
// }
// var balance = '0x56BC75E2D63100000'
// account.balance = balance || '0xf00000000000000001'
// resolve()
// })
this
.
accountsKeys
[
ethJSUtil
.
toChecksumAddress
(
account
.
address
)]
=
account
.
privateKey
this
.
accountsKeys
[
ethJSUtil
.
toChecksumAddress
(
account
.
address
)]
=
account
.
privateKey
this
.
accounts
[
ethJSUtil
.
toChecksumAddress
(
account
.
address
)]
=
{
privateKey
:
Buffer
.
from
(
account
.
privateKey
.
replace
(
'0x'
,
''
),
'hex'
),
nonce
:
0
}
this
.
accounts
[
ethJSUtil
.
toChecksumAddress
(
account
.
address
)]
=
{
privateKey
:
Buffer
.
from
(
account
.
privateKey
.
replace
(
'0x'
,
''
),
'hex'
),
nonce
:
0
}
...
...
remix-simulator/src/methods/blocks.js
View file @
9703013b
...
@@ -25,14 +25,10 @@ Blocks.prototype.methods = function () {
...
@@ -25,14 +25,10 @@ Blocks.prototype.methods = function () {
Blocks
.
prototype
.
eth_getBlockByNumber
=
function
(
payload
,
cb
)
{
Blocks
.
prototype
.
eth_getBlockByNumber
=
function
(
payload
,
cb
)
{
let
blockIndex
=
payload
.
params
[
0
]
let
blockIndex
=
payload
.
params
[
0
]
if
(
blockIndex
===
'latest'
)
{
if
(
blockIndex
===
'latest'
)
{
blockIndex
=
(
Object
.
keys
(
executionContext
.
blocks
).
length
/
2
)
-
1
blockIndex
=
executionContext
.
latestBlockNumber
}
}
// =======
var
block
=
executionContext
.
blocks
[
blockIndex
]
// TODO: FIX ME
// var block = executionContext.blocks[blockIndex]
var
block
=
Object
.
values
(
executionContext
.
blocks
)[
0
]
// =======
if
(
!
block
)
{
if
(
!
block
)
{
return
cb
(
new
Error
(
'block not found'
))
return
cb
(
new
Error
(
'block not found'
))
...
...
remix-simulator/src/provider.js
View file @
9703013b
...
@@ -23,7 +23,6 @@ var Provider = function (options) {
...
@@ -23,7 +23,6 @@ var Provider = function (options) {
this
.
methods
=
merge
(
this
.
methods
,
(
new
Misc
()).
methods
())
this
.
methods
=
merge
(
this
.
methods
,
(
new
Misc
()).
methods
())
this
.
methods
=
merge
(
this
.
methods
,
(
new
Filters
()).
methods
())
this
.
methods
=
merge
(
this
.
methods
,
(
new
Filters
()).
methods
())
this
.
methods
=
merge
(
this
.
methods
,
(
new
Net
()).
methods
())
this
.
methods
=
merge
(
this
.
methods
,
(
new
Net
()).
methods
())
// this.methods = merge(this.methods, (new Transactions(this.Accounts.accounts)).methods())
this
.
methods
=
merge
(
this
.
methods
,
this
.
Transactions
.
methods
())
this
.
methods
=
merge
(
this
.
methods
,
this
.
Transactions
.
methods
())
generateBlock
()
generateBlock
()
...
@@ -39,11 +38,8 @@ Provider.prototype.sendAsync = function (payload, callback) {
...
@@ -39,11 +38,8 @@ Provider.prototype.sendAsync = function (payload, callback) {
log
.
info
(
'payload method is '
,
payload
.
method
)
log
.
info
(
'payload method is '
,
payload
.
method
)
let
method
=
this
.
methods
[
payload
.
method
]
let
method
=
this
.
methods
[
payload
.
method
]
console
.
dir
(
payload
)
if
(
method
)
{
if
(
method
)
{
return
method
.
call
(
method
,
payload
,
(
err
,
result
)
=>
{
return
method
.
call
(
method
,
payload
,
(
err
,
result
)
=>
{
console
.
dir
(
err
)
console
.
dir
(
result
)
if
(
err
)
{
if
(
err
)
{
return
callback
(
err
)
return
callback
(
err
)
}
}
...
...
remix-simulator/test/blocks.js
View file @
9703013b
...
@@ -29,7 +29,7 @@ describe('blocks', function () {
...
@@ -29,7 +29,7 @@ describe('blocks', function () {
parentHash
:
'0x0000000000000000000000000000000000000000000000000000000000000000'
,
parentHash
:
'0x0000000000000000000000000000000000000000000000000000000000000000'
,
sha3Uncles
:
'0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347'
,
sha3Uncles
:
'0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347'
,
size
:
163591
,
size
:
163591
,
stateRoot
:
'0x
a633ca0e8f0ae4e86d4d572b048ea93d84eb4b11e2c988b48cb3a5f6f10b3c68
'
,
stateRoot
:
'0x
63e1738ea12d4e7d12b71f0f4604706417921eb6a62c407ca5f1d66b9e67f579
'
,
timestamp
:
block
.
timestamp
,
timestamp
:
block
.
timestamp
,
totalDifficulty
:
'0'
,
totalDifficulty
:
'0'
,
transactions
:
[],
transactions
:
[],
...
...
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