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
d74ad36b
Commit
d74ad36b
authored
Jun 22, 2017
by
yann300
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
last block gas limit
parent
d3537b31
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
36 additions
and
25 deletions
+36
-25
app.js
src/app.js
+2
-1
execution-context.js
src/app/execution-context.js
+17
-0
renderer.js
src/app/renderer.js
+2
-2
txRunner.js
src/app/txRunner.js
+15
-22
No files found.
src/app.js
View file @
d74ad36b
...
...
@@ -475,7 +475,8 @@ var run = function () {
callback
(
null
,
executionContext
.
web3
().
fromWei
(
balance
,
'ether'
))
}
})
}
},
currentblockGasLimit
:
()
=>
{
return
executionContext
.
currentblockGasLimit
()
}
}
var
renderer
=
new
Renderer
(
rendererAPI
,
compiler
.
event
)
...
...
src/app/execution-context.js
View file @
d74ad36b
...
...
@@ -123,6 +123,23 @@ function ExecutionContext () {
}
}
this
.
currentblockGasLimit
=
function
()
{
return
this
.
blockGasLimit
}
this
.
blockGasLimitDefault
=
4300000
this
.
blockGasLimit
=
this
.
blockGasLimitDefault
setInterval
(()
=>
{
web3
.
eth
.
getBlock
(
'latest'
,
(
err
,
block
)
=>
{
if
(
!
err
)
{
// we can't use the blockGasLimit cause the next blocks could have a lower limit : https://github.com/ethereum/remix/issues/506
this
.
blockGasLimit
=
(
block
&&
block
.
gasLimit
)
?
Math
.
floor
(
block
.
gasLimit
-
(
5
*
block
.
gasLimit
)
/
1024
)
:
this
.
blockGasLimitDefault
}
else
{
this
.
blockGasLimit
=
this
.
blockGasLimitDefault
}
})
},
15000
)
function
setProviderFromEndpoint
(
endpoint
)
{
if
(
endpoint
===
'ipc'
)
{
web3
.
setProvider
(
new
web3
.
providers
.
IpcProvider
())
...
...
src/app/renderer.js
View file @
d74ad36b
...
...
@@ -111,6 +111,7 @@ Renderer.prototype.error = function (message, container, options) {
}
Renderer
.
prototype
.
contracts
=
function
(
data
,
source
)
{
var
self
=
this
var
retrieveMetadataHash
=
function
(
bytecode
)
{
var
match
=
/a165627a7a72305820
([
0-9a-f
]{64})
0029$/
.
exec
(
bytecode
)
if
(
match
)
{
...
...
@@ -210,7 +211,7 @@ Renderer.prototype.contracts = function (data, source) {
code
+=
'
\
n {'
+
'
\
n from: web3.eth.accounts[0], '
+
"
\
n data: '0x"
+
bytecode
+
"', "
+
"
\
n gas: '
4700000
'"
+
"
\
n gas: '
"
+
self
.
appAPI
.
currentblockGasLimit
()
+
"
'"
+
'
\
n }, function (e, contract){'
+
'
\
n console.log(e, contract);'
+
"
\
n if (typeof contract.address !== 'undefined') {"
+
...
...
@@ -313,7 +314,6 @@ Renderer.prototype.contracts = function (data, source) {
return
$
(
'<div class="contractDetails"/>'
).
append
(
button
).
append
(
details
)
}
var
self
=
this
var
renderOutputModifier
=
function
(
contractName
,
$contractOutput
)
{
var
contract
=
data
.
contracts
[
contractName
]
var
ctrSource
=
self
.
appAPI
.
currentCompiledSourceCode
()
...
...
src/app/txRunner.js
View file @
d74ad36b
...
...
@@ -69,30 +69,23 @@ TxRunner.prototype.execute = function () {
if
(
err
)
{
return
callback
(
err
,
gasEstimation
)
}
self
.
web3
.
eth
.
getBlock
(
'latest'
,
function
(
err
,
block
)
{
var
blockGasLimit
=
self
.
executionContext
.
currentblockGasLimit
()
// NOTE: estimateGas very likely will return a large limit if execution of the code failed
// we want to be able to run the code in order to debug and find the cause for the failure
if
(
gasEstimation
>
gasLimit
)
{
return
callback
(
'Gas required exceeds limit: '
+
gasLimit
)
}
if
(
gasEstimation
>
blockGasLimit
)
{
return
callback
(
'Gas required exceeds block gas limit: '
+
gasLimit
)
}
tx
.
gas
=
gasEstimation
var
sendTransaction
=
self
.
personalMode
?
self
.
web3
.
personal
.
sendTransaction
:
self
.
web3
.
eth
.
sendTransaction
sendTransaction
(
tx
,
function
(
err
,
resp
)
{
if
(
err
)
{
return
callback
(
err
)
}
else
{
// NOTE: estimateGas very likely will return a large limit if execution of the code failed
// we want to be able to run the code in order to debug and find the cause for the failure
// we can't use the blockGasLimit cause the next blocks could have a lower limit : https://github.com/ethereum/remix/issues/506
var
blockGasLimit
=
Math
.
floor
(
block
.
gasLimit
-
(
5
*
block
.
gasLimit
)
/
1024
)
if
(
gasEstimation
>
gasLimit
)
{
return
callback
(
'Gas required exceeds limit: '
+
gasLimit
)
}
if
(
gasEstimation
>
blockGasLimit
)
{
return
callback
(
'Gas required exceeds block gas limit: '
+
gasLimit
)
}
tx
.
gas
=
gasEstimation
var
sendTransaction
=
self
.
personalMode
?
self
.
web3
.
personal
.
sendTransaction
:
self
.
web3
.
eth
.
sendTransaction
sendTransaction
(
tx
,
function
(
err
,
resp
)
{
if
(
err
)
{
return
callback
(
err
,
resp
)
}
tryTillResponse
(
self
.
web3
,
resp
,
callback
)
})
return
callback
(
err
,
resp
)
}
tryTillResponse
(
self
.
web3
,
resp
,
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