good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
bor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
bor
Commits
26c6e3b2
Commit
26c6e3b2
authored
Aug 3, 2015
by
Gustav Simonsson
Browse files
Options
Downloads
Patches
Plain Diff
miner: gas limit strategy, target 3141592 & def gas price 50 Shannon
parent
ff66e8fa
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
cmd/utils/flags.go
+3
-3
3 additions, 3 deletions
cmd/utils/flags.go
core/chain_util.go
+15
-2
15 additions, 2 deletions
core/chain_util.go
eth/fetcher/fetcher_test.go
+2
-1
2 additions, 1 deletion
eth/fetcher/fetcher_test.go
params/protocol_params.go
+2
-2
2 additions, 2 deletions
params/protocol_params.go
with
22 additions
and
8 deletions
cmd/utils/flags.go
+
3
−
3
View file @
26c6e3b2
...
...
@@ -158,7 +158,7 @@ var (
GasPriceFlag
=
cli
.
StringFlag
{
Name
:
"gasprice"
,
Usage
:
"Sets the minimal gasprice when mining transactions"
,
Value
:
new
(
big
.
Int
)
.
Mul
(
big
.
NewInt
(
50
0
),
common
.
Shannon
)
.
String
(),
Value
:
new
(
big
.
Int
)
.
Mul
(
big
.
NewInt
(
50
),
common
.
Shannon
)
.
String
(),
}
UnlockedAccountFlag
=
cli
.
StringFlag
{
...
...
@@ -318,12 +318,12 @@ var (
GpoMinGasPriceFlag
=
cli
.
StringFlag
{
Name
:
"gpomin"
,
Usage
:
"Minimum suggested gas price"
,
Value
:
new
(
big
.
Int
)
.
Mul
(
big
.
NewInt
(
1
),
common
.
S
zabo
)
.
String
(),
Value
:
new
(
big
.
Int
)
.
Mul
(
big
.
NewInt
(
50
),
common
.
S
hannon
)
.
String
(),
}
GpoMaxGasPriceFlag
=
cli
.
StringFlag
{
Name
:
"gpomax"
,
Usage
:
"Maximum suggested gas price"
,
Value
:
new
(
big
.
Int
)
.
Mul
(
big
.
NewInt
(
1
00
),
common
.
S
zabo
)
.
String
(),
Value
:
new
(
big
.
Int
)
.
Mul
(
big
.
NewInt
(
5
00
),
common
.
S
hannon
)
.
String
(),
}
GpoFullBlockRatioFlag
=
cli
.
IntFlag
{
Name
:
"gpofull"
,
...
...
This diff is collapsed.
Click to expand it.
core/chain_util.go
+
15
−
2
View file @
26c6e3b2
...
...
@@ -69,17 +69,30 @@ func CalcTD(block, parent *types.Block) *big.Int {
// CalcGasLimit computes the gas limit of the next block after parent.
// The result may be modified by the caller.
// This is miner strategy, not consensus protocol.
func
CalcGasLimit
(
parent
*
types
.
Block
)
*
big
.
Int
{
decay
:=
new
(
big
.
Int
)
.
Div
(
parent
.
Gas
Limit
(),
params
.
GasLimitBoundDivisor
)
// contrib =
(parentGas
Used * 3 / 2) / 1024
contrib
:=
new
(
big
.
Int
)
.
Mul
(
parent
.
GasUsed
(),
big
.
NewInt
(
3
))
contrib
=
contrib
.
Div
(
contrib
,
big
.
NewInt
(
2
))
contrib
=
contrib
.
Div
(
contrib
,
params
.
GasLimitBoundDivisor
)
// decay = parentGasLimit / 1024 -1
decay
:=
new
(
big
.
Int
)
.
Div
(
parent
.
GasLimit
(),
params
.
GasLimitBoundDivisor
)
decay
.
Sub
(
decay
,
big
.
NewInt
(
1
))
/*
strategy: gasLimit of block-to-mine is set based on parent's
gasUsed value. if parentGasUsed > parentGasLimit * (2/3) then we
increase it, otherwise lower it (or leave it unchanged if it's right
at that usage) the amount increased/decreased depends on how far away
from parentGasLimit * (2/3) parentGasUsed is.
*/
gl
:=
new
(
big
.
Int
)
.
Sub
(
parent
.
GasLimit
(),
decay
)
gl
=
gl
.
Add
(
gl
,
contrib
)
gl
=
gl
.
Add
(
gl
,
big
.
NewInt
(
1
))
gl
.
Set
(
common
.
BigMax
(
gl
,
params
.
MinGasLimit
))
// however, if we're now below the target (GenesisGasLimit) we increase the
// limit as much as we can (parentGasLimit / 1024 -1)
if
gl
.
Cmp
(
params
.
GenesisGasLimit
)
<
0
{
gl
.
Add
(
parent
.
GasLimit
(),
decay
)
gl
.
Set
(
common
.
BigMin
(
gl
,
params
.
GenesisGasLimit
))
...
...
This diff is collapsed.
Click to expand it.
eth/fetcher/fetcher_test.go
+
2
−
1
View file @
26c6e3b2
...
...
@@ -28,12 +28,13 @@ import (
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/params"
)
var
(
testdb
,
_
=
ethdb
.
NewMemDatabase
()
genesis
=
core
.
GenesisBlockForTesting
(
testdb
,
common
.
Address
{},
big
.
NewInt
(
0
))
unknownBlock
=
types
.
NewBlock
(
&
types
.
Header
{},
nil
,
nil
,
nil
)
unknownBlock
=
types
.
NewBlock
(
&
types
.
Header
{
GasLimit
:
params
.
GenesisGasLimit
},
nil
,
nil
,
nil
)
)
// makeChain creates a chain of n blocks starting at and including parent.
...
...
This diff is collapsed.
Click to expand it.
params/protocol_params.go
+
2
−
2
View file @
26c6e3b2
...
...
@@ -40,7 +40,7 @@ var (
Sha256WordGas
=
big
.
NewInt
(
12
)
//
MinGasLimit
=
big
.
NewInt
(
5000
)
// Minimum the gas limit may ever be.
GenesisGasLimit
=
big
.
NewInt
(
5000
)
// Gas limit of the Genesis block.
GenesisGasLimit
=
big
.
NewInt
(
3141592
)
// Gas limit of the Genesis block.
Sha3Gas
=
big
.
NewInt
(
30
)
// Once per SHA3 operation.
Sha256Gas
=
big
.
NewInt
(
60
)
//
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment