Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
e29c2e43
Unverified
Commit
e29c2e43
authored
Aug 29, 2018
by
Péter Szilágyi
Committed by
GitHub
Aug 29, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #17546 from karalabe/miner-max-limit
cmd, core, eth, miner, params: configurable gas floor and ceil
parents
c1c003e4
e8f229b8
Changes
20
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
88 additions
and
49 deletions
+88
-49
main.go
cmd/geth/main.go
+1
-1
usage.go
cmd/geth/usage.go
+1
-0
module_node.go
cmd/puppeth/module_node.go
+9
-2
wizard_node.go
cmd/puppeth/wizard_node.go
+5
-1
flags.go
cmd/utils/flags.go
+16
-11
bench_test.go
core/bench_test.go
+2
-1
block_validator.go
core/block_validator.go
+14
-8
chain_makers.go
core/chain_makers.go
+1
-1
backend.go
eth/backend.go
+1
-1
config.go
eth/config.go
+5
-1
gasprice.go
eth/gasprice/gasprice.go
+1
-1
gen_config.go
eth/gen_config.go
+12
-0
api.go
internal/ethapi/api.go
+1
-1
miner.go
miner/miner.go
+2
-2
stress_clique.go
miner/stress_clique.go
+2
-0
stress_ethash.go
miner/stress_ethash.go
+2
-0
worker.go
miner/worker.go
+7
-2
worker_test.go
miner/worker_test.go
+1
-1
denomination.go
params/denomination.go
+5
-11
protocol_params.go
params/protocol_params.go
+0
-4
No files found.
cmd/geth/main.go
View file @
e29c2e43
...
...
@@ -101,6 +101,7 @@ var (
utils
.
MinerNotifyFlag
,
utils
.
MinerGasTargetFlag
,
utils
.
MinerLegacyGasTargetFlag
,
utils
.
MinerGasLimitFlag
,
utils
.
MinerGasPriceFlag
,
utils
.
MinerLegacyGasPriceFlag
,
utils
.
MinerEtherbaseFlag
,
...
...
@@ -236,7 +237,6 @@ func init() {
// Start system runtime metrics collection
go
metrics
.
CollectProcessMetrics
(
3
*
time
.
Second
)
utils
.
SetupNetwork
(
ctx
)
return
nil
}
...
...
cmd/geth/usage.go
View file @
e29c2e43
...
...
@@ -189,6 +189,7 @@ var AppHelpFlagGroups = []flagGroup{
utils
.
MinerNotifyFlag
,
utils
.
MinerGasPriceFlag
,
utils
.
MinerGasTargetFlag
,
utils
.
MinerGasLimitFlag
,
utils
.
MinerEtherbaseFlag
,
utils
.
MinerExtraDataFlag
,
utils
.
MinerRecommitIntervalFlag
,
...
...
cmd/puppeth/module_node.go
View file @
e29c2e43
...
...
@@ -42,7 +42,7 @@ ADD genesis.json /genesis.json
RUN \
echo 'geth --cache 512 init /genesis.json' > geth.sh && \{{if .Unlock}}
echo 'mkdir -p /root/.ethereum/keystore/ && cp /signer.json /root/.ethereum/keystore/' >> geth.sh && \{{end}}
echo $'exec geth --networkid {{.NetworkID}} --cache 512 --port {{.Port}} --maxpeers {{.Peers}} {{.LightFlag}} --ethstats \'{{.Ethstats}}\' {{if .Bootnodes}}--bootnodes {{.Bootnodes}}{{end}} {{if .Etherbase}}--miner.etherbase {{.Etherbase}} --mine --miner.threads 1{{end}} {{if .Unlock}}--unlock 0 --password /signer.pass --mine{{end}} --miner.gastarget {{.GasTarget}} --miner.gasprice {{.GasPrice}}' >> geth.sh
echo $'exec geth --networkid {{.NetworkID}} --cache 512 --port {{.Port}} --maxpeers {{.Peers}} {{.LightFlag}} --ethstats \'{{.Ethstats}}\' {{if .Bootnodes}}--bootnodes {{.Bootnodes}}{{end}} {{if .Etherbase}}--miner.etherbase {{.Etherbase}} --mine --miner.threads 1{{end}} {{if .Unlock}}--unlock 0 --password /signer.pass --mine{{end}} --miner.gastarget {{.GasTarget}} --miner.gas
limit {{.GasLimit}} --miner.gas
price {{.GasPrice}}' >> geth.sh
ENTRYPOINT ["/bin/sh", "geth.sh"]
`
...
...
@@ -68,6 +68,7 @@ services:
- STATS_NAME={{.Ethstats}}
- MINER_NAME={{.Etherbase}}
- GAS_TARGET={{.GasTarget}}
- GAS_LIMIT={{.GasLimit}}
- GAS_PRICE={{.GasPrice}}
logging:
driver: "json-file"
...
...
@@ -104,6 +105,7 @@ func deployNode(client *sshClient, network string, bootnodes []string, config *n
"Ethstats"
:
config
.
ethstats
,
"Etherbase"
:
config
.
etherbase
,
"GasTarget"
:
uint64
(
1000000
*
config
.
gasTarget
),
"GasLimit"
:
uint64
(
1000000
*
config
.
gasLimit
),
"GasPrice"
:
uint64
(
1000000000
*
config
.
gasPrice
),
"Unlock"
:
config
.
keyJSON
!=
""
,
})
...
...
@@ -122,6 +124,7 @@ func deployNode(client *sshClient, network string, bootnodes []string, config *n
"Ethstats"
:
config
.
ethstats
[
:
strings
.
Index
(
config
.
ethstats
,
":"
)],
"Etherbase"
:
config
.
etherbase
,
"GasTarget"
:
config
.
gasTarget
,
"GasLimit"
:
config
.
gasLimit
,
"GasPrice"
:
config
.
gasPrice
,
})
files
[
filepath
.
Join
(
workdir
,
"docker-compose.yaml"
)]
=
composefile
.
Bytes
()
...
...
@@ -160,6 +163,7 @@ type nodeInfos struct {
keyJSON
string
keyPass
string
gasTarget
float64
gasLimit
float64
gasPrice
float64
}
...
...
@@ -175,8 +179,9 @@ func (info *nodeInfos) Report() map[string]string {
}
if
info
.
gasTarget
>
0
{
// Miner or signer node
report
[
"Gas limit (baseline target)"
]
=
fmt
.
Sprintf
(
"%0.3f MGas"
,
info
.
gasTarget
)
report
[
"Gas price (minimum accepted)"
]
=
fmt
.
Sprintf
(
"%0.3f GWei"
,
info
.
gasPrice
)
report
[
"Gas floor (baseline target)"
]
=
fmt
.
Sprintf
(
"%0.3f MGas"
,
info
.
gasTarget
)
report
[
"Gas ceil (target maximum)"
]
=
fmt
.
Sprintf
(
"%0.3f MGas"
,
info
.
gasLimit
)
if
info
.
etherbase
!=
""
{
// Ethash proof-of-work miner
...
...
@@ -217,6 +222,7 @@ func checkNode(client *sshClient, network string, boot bool) (*nodeInfos, error)
totalPeers
,
_
:=
strconv
.
Atoi
(
infos
.
envvars
[
"TOTAL_PEERS"
])
lightPeers
,
_
:=
strconv
.
Atoi
(
infos
.
envvars
[
"LIGHT_PEERS"
])
gasTarget
,
_
:=
strconv
.
ParseFloat
(
infos
.
envvars
[
"GAS_TARGET"
],
64
)
gasLimit
,
_
:=
strconv
.
ParseFloat
(
infos
.
envvars
[
"GAS_LIMIT"
],
64
)
gasPrice
,
_
:=
strconv
.
ParseFloat
(
infos
.
envvars
[
"GAS_PRICE"
],
64
)
// Container available, retrieve its node ID and its genesis json
...
...
@@ -256,6 +262,7 @@ func checkNode(client *sshClient, network string, boot bool) (*nodeInfos, error)
keyJSON
:
keyJSON
,
keyPass
:
keyPass
,
gasTarget
:
gasTarget
,
gasLimit
:
gasLimit
,
gasPrice
:
gasPrice
,
}
stats
.
enode
=
fmt
.
Sprintf
(
"enode://%s@%s:%d"
,
id
,
client
.
address
,
stats
.
port
)
...
...
cmd/puppeth/wizard_node.go
View file @
e29c2e43
...
...
@@ -50,7 +50,7 @@ func (w *wizard) deployNode(boot bool) {
if
boot
{
infos
=
&
nodeInfos
{
port
:
30303
,
peersTotal
:
512
,
peersLight
:
256
}
}
else
{
infos
=
&
nodeInfos
{
port
:
30303
,
peersTotal
:
50
,
peersLight
:
0
,
gasTarget
:
4.7
,
gasPrice
:
18
}
infos
=
&
nodeInfos
{
port
:
30303
,
peersTotal
:
50
,
peersLight
:
0
,
gasTarget
:
7.5
,
gasLimit
:
10
,
gasPrice
:
1
}
}
}
existed
:=
err
==
nil
...
...
@@ -152,6 +152,10 @@ func (w *wizard) deployNode(boot bool) {
fmt
.
Printf
(
"What gas limit should empty blocks target (MGas)? (default = %0.3f)
\n
"
,
infos
.
gasTarget
)
infos
.
gasTarget
=
w
.
readDefaultFloat
(
infos
.
gasTarget
)
fmt
.
Println
()
fmt
.
Printf
(
"What gas limit should full blocks target (MGas)? (default = %0.3f)
\n
"
,
infos
.
gasLimit
)
infos
.
gasLimit
=
w
.
readDefaultFloat
(
infos
.
gasLimit
)
fmt
.
Println
()
fmt
.
Printf
(
"What gas price should the signer require (GWei)? (default = %0.3f)
\n
"
,
infos
.
gasPrice
)
infos
.
gasPrice
=
w
.
readDefaultFloat
(
infos
.
gasPrice
)
...
...
cmd/utils/flags.go
View file @
e29c2e43
...
...
@@ -329,12 +329,17 @@ var (
MinerGasTargetFlag
=
cli
.
Uint64Flag
{
Name
:
"miner.gastarget"
,
Usage
:
"Target gas floor for mined blocks"
,
Value
:
params
.
GenesisGasLimit
,
Value
:
eth
.
DefaultConfig
.
MinerGasFloor
,
}
MinerLegacyGasTargetFlag
=
cli
.
Uint64Flag
{
Name
:
"targetgaslimit"
,
Usage
:
"Target gas floor for mined blocks (deprecated, use --miner.gastarget)"
,
Value
:
params
.
GenesisGasLimit
,
Value
:
eth
.
DefaultConfig
.
MinerGasFloor
,
}
MinerGasLimitFlag
=
cli
.
Uint64Flag
{
Name
:
"miner.gaslimit"
,
Usage
:
"Target gas ceiling for mined blocks"
,
Value
:
eth
.
DefaultConfig
.
MinerGasCeil
,
}
MinerGasPriceFlag
=
BigFlag
{
Name
:
"miner.gasprice"
,
...
...
@@ -1146,6 +1151,15 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *eth.Config) {
if
ctx
.
GlobalIsSet
(
MinerExtraDataFlag
.
Name
)
{
cfg
.
MinerExtraData
=
[]
byte
(
ctx
.
GlobalString
(
MinerExtraDataFlag
.
Name
))
}
if
ctx
.
GlobalIsSet
(
MinerLegacyGasTargetFlag
.
Name
)
{
cfg
.
MinerGasFloor
=
ctx
.
GlobalUint64
(
MinerLegacyGasTargetFlag
.
Name
)
}
if
ctx
.
GlobalIsSet
(
MinerGasTargetFlag
.
Name
)
{
cfg
.
MinerGasFloor
=
ctx
.
GlobalUint64
(
MinerGasTargetFlag
.
Name
)
}
if
ctx
.
GlobalIsSet
(
MinerGasLimitFlag
.
Name
)
{
cfg
.
MinerGasCeil
=
ctx
.
GlobalUint64
(
MinerGasLimitFlag
.
Name
)
}
if
ctx
.
GlobalIsSet
(
MinerLegacyGasPriceFlag
.
Name
)
{
cfg
.
MinerGasPrice
=
GlobalBig
(
ctx
,
MinerLegacyGasPriceFlag
.
Name
)
}
...
...
@@ -1270,15 +1284,6 @@ func RegisterEthStatsService(stack *node.Node, url string) {
}
}
// SetupNetwork configures the system for either the main net or some test network.
func
SetupNetwork
(
ctx
*
cli
.
Context
)
{
// TODO(fjl): move target gas limit into config
params
.
TargetGasLimit
=
ctx
.
GlobalUint64
(
MinerLegacyGasTargetFlag
.
Name
)
if
ctx
.
GlobalIsSet
(
MinerGasTargetFlag
.
Name
)
{
params
.
TargetGasLimit
=
ctx
.
GlobalUint64
(
MinerGasTargetFlag
.
Name
)
}
}
func
SetupMetrics
(
ctx
*
cli
.
Context
)
{
if
metrics
.
Enabled
{
log
.
Info
(
"Enabling metrics collection"
)
...
...
core/bench_test.go
View file @
e29c2e43
...
...
@@ -111,7 +111,8 @@ func init() {
func
genTxRing
(
naccounts
int
)
func
(
int
,
*
BlockGen
)
{
from
:=
0
return
func
(
i
int
,
gen
*
BlockGen
)
{
gas
:=
CalcGasLimit
(
gen
.
PrevBlock
(
i
-
1
))
block
:=
gen
.
PrevBlock
(
i
-
1
)
gas
:=
CalcGasLimit
(
block
,
block
.
GasLimit
(),
block
.
GasLimit
())
for
{
gas
-=
params
.
TxGas
if
gas
<
params
.
TxGas
{
...
...
core/block_validator.go
View file @
e29c2e43
...
...
@@ -101,9 +101,11 @@ func (v *BlockValidator) ValidateState(block, parent *types.Block, statedb *stat
return
nil
}
// CalcGasLimit computes the gas limit of the next block after parent.
// This is miner strategy, not consensus protocol.
func
CalcGasLimit
(
parent
*
types
.
Block
)
uint64
{
// CalcGasLimit computes the gas limit of the next block after parent. It aims
// to keep the baseline gas above the provided floor, and increase it towards the
// ceil if the blocks are full. If the ceil is exceeded, it will always decrease
// the gas allowance.
func
CalcGasLimit
(
parent
*
types
.
Block
,
gasFloor
,
gasCeil
uint64
)
uint64
{
// contrib = (parentGasUsed * 3 / 2) / 1024
contrib
:=
(
parent
.
GasUsed
()
+
parent
.
GasUsed
()
/
2
)
/
params
.
GasLimitBoundDivisor
...
...
@@ -121,12 +123,16 @@ func CalcGasLimit(parent *types.Block) uint64 {
if
limit
<
params
.
MinGasLimit
{
limit
=
params
.
MinGasLimit
}
// however, if we're now below the target (TargetGasLimit) we increase the
// limit as much as we can (parentGasLimit / 1024 -1)
if
limit
<
params
.
TargetGasLimit
{
// If we're outside our allowed gas range, we try to hone towards them
if
limit
<
gasFloor
{
limit
=
parent
.
GasLimit
()
+
decay
if
limit
>
params
.
TargetGasLimit
{
limit
=
params
.
TargetGasLimit
if
limit
>
gasFloor
{
limit
=
gasFloor
}
}
else
if
limit
>
gasCeil
{
limit
=
parent
.
GasLimit
()
-
decay
if
limit
<
gasCeil
{
limit
=
gasCeil
}
}
return
limit
...
...
core/chain_makers.go
View file @
e29c2e43
...
...
@@ -240,7 +240,7 @@ func makeHeader(chain consensus.ChainReader, parent *types.Block, state *state.S
Difficulty
:
parent
.
Difficulty
(),
UncleHash
:
parent
.
UncleHash
(),
}),
GasLimit
:
CalcGasLimit
(
parent
),
GasLimit
:
CalcGasLimit
(
parent
,
parent
.
GasLimit
(),
parent
.
GasLimit
()
),
Number
:
new
(
big
.
Int
)
.
Add
(
parent
.
Number
(),
common
.
Big1
),
Time
:
time
,
}
...
...
eth/backend.go
View file @
e29c2e43
...
...
@@ -173,7 +173,7 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) {
return
nil
,
err
}
eth
.
miner
=
miner
.
New
(
eth
,
eth
.
chainConfig
,
eth
.
EventMux
(),
eth
.
engine
,
config
.
MinerRecommit
)
eth
.
miner
=
miner
.
New
(
eth
,
eth
.
chainConfig
,
eth
.
EventMux
(),
eth
.
engine
,
config
.
MinerRecommit
,
config
.
MinerGasFloor
,
config
.
MinerGasCeil
)
eth
.
miner
.
SetExtra
(
makeExtraData
(
config
.
MinerExtraData
))
eth
.
APIBackend
=
&
EthAPIBackend
{
eth
,
nil
}
...
...
eth/config.go
View file @
e29c2e43
...
...
@@ -48,7 +48,9 @@ var DefaultConfig = Config{
DatabaseCache
:
768
,
TrieCache
:
256
,
TrieTimeout
:
60
*
time
.
Minute
,
MinerGasPrice
:
big
.
NewInt
(
18
*
params
.
Shannon
),
MinerGasFloor
:
8000000
,
MinerGasCeil
:
8000000
,
MinerGasPrice
:
big
.
NewInt
(
params
.
GWei
),
MinerRecommit
:
3
*
time
.
Second
,
TxPool
:
core
.
DefaultTxPoolConfig
,
...
...
@@ -99,6 +101,8 @@ type Config struct {
Etherbase
common
.
Address
`toml:",omitempty"`
MinerNotify
[]
string
`toml:",omitempty"`
MinerExtraData
[]
byte
`toml:",omitempty"`
MinerGasFloor
uint64
MinerGasCeil
uint64
MinerGasPrice
*
big
.
Int
MinerRecommit
time
.
Duration
MinerNoverify
bool
...
...
eth/gasprice/gasprice.go
View file @
e29c2e43
...
...
@@ -29,7 +29,7 @@ import (
"github.com/ethereum/go-ethereum/rpc"
)
var
maxPrice
=
big
.
NewInt
(
500
*
params
.
Shannon
)
var
maxPrice
=
big
.
NewInt
(
500
*
params
.
GWei
)
type
Config
struct
{
Blocks
int
...
...
eth/gen_config.go
View file @
e29c2e43
...
...
@@ -33,6 +33,8 @@ func (c Config) MarshalTOML() (interface{}, error) {
Etherbase
common
.
Address
`toml:",omitempty"`
MinerNotify
[]
string
`toml:",omitempty"`
MinerExtraData
hexutil
.
Bytes
`toml:",omitempty"`
MinerGasFloor
uint64
MinerGasCeil
uint64
MinerGasPrice
*
big
.
Int
MinerRecommit
time
.
Duration
MinerNoverify
bool
...
...
@@ -57,6 +59,8 @@ func (c Config) MarshalTOML() (interface{}, error) {
enc
.
Etherbase
=
c
.
Etherbase
enc
.
MinerNotify
=
c
.
MinerNotify
enc
.
MinerExtraData
=
c
.
MinerExtraData
enc
.
MinerGasFloor
=
c
.
MinerGasFloor
enc
.
MinerGasCeil
=
c
.
MinerGasCeil
enc
.
MinerGasPrice
=
c
.
MinerGasPrice
enc
.
MinerRecommit
=
c
.
MinerRecommit
enc
.
MinerNoverify
=
c
.
MinerNoverify
...
...
@@ -85,6 +89,8 @@ func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error {
Etherbase
*
common
.
Address
`toml:",omitempty"`
MinerNotify
[]
string
`toml:",omitempty"`
MinerExtraData
*
hexutil
.
Bytes
`toml:",omitempty"`
MinerGasFloor
*
uint64
MinerGasCeil
*
uint64
MinerGasPrice
*
big
.
Int
MinerRecommit
*
time
.
Duration
MinerNoverify
*
bool
...
...
@@ -140,6 +146,12 @@ func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error {
if
dec
.
MinerExtraData
!=
nil
{
c
.
MinerExtraData
=
*
dec
.
MinerExtraData
}
if
dec
.
MinerGasFloor
!=
nil
{
c
.
MinerGasFloor
=
*
dec
.
MinerGasFloor
}
if
dec
.
MinerGasCeil
!=
nil
{
c
.
MinerGasCeil
=
*
dec
.
MinerGasCeil
}
if
dec
.
MinerGasPrice
!=
nil
{
c
.
MinerGasPrice
=
dec
.
MinerGasPrice
}
...
...
internal/ethapi/api.go
View file @
e29c2e43
...
...
@@ -47,7 +47,7 @@ import (
)
const
(
defaultGasPrice
=
50
*
params
.
Shannon
defaultGasPrice
=
params
.
GWei
)
// PublicEthereumAPI provides an API to access Ethereum related information.
...
...
miner/miner.go
View file @
e29c2e43
...
...
@@ -52,13 +52,13 @@ type Miner struct {
shouldStart
int32
// should start indicates whether we should start after sync
}
func
New
(
eth
Backend
,
config
*
params
.
ChainConfig
,
mux
*
event
.
TypeMux
,
engine
consensus
.
Engine
,
recommit
time
.
Duration
)
*
Miner
{
func
New
(
eth
Backend
,
config
*
params
.
ChainConfig
,
mux
*
event
.
TypeMux
,
engine
consensus
.
Engine
,
recommit
time
.
Duration
,
gasFloor
,
gasCeil
uint64
)
*
Miner
{
miner
:=
&
Miner
{
eth
:
eth
,
mux
:
mux
,
engine
:
engine
,
exitCh
:
make
(
chan
struct
{}),
worker
:
newWorker
(
config
,
engine
,
eth
,
mux
,
recommit
),
worker
:
newWorker
(
config
,
engine
,
eth
,
mux
,
recommit
,
gasFloor
,
gasCeil
),
canStart
:
1
,
}
go
miner
.
update
()
...
...
miner/stress_clique.go
View file @
e29c2e43
...
...
@@ -206,6 +206,8 @@ func makeSealer(genesis *core.Genesis, nodes []string) (*node.Node, error) {
DatabaseHandles
:
256
,
TxPool
:
core
.
DefaultTxPoolConfig
,
GPO
:
eth
.
DefaultConfig
.
GPO
,
MinerGasFloor
:
genesis
.
GasLimit
*
9
/
10
,
MinerGasCeil
:
genesis
.
GasLimit
*
11
/
10
,
MinerGasPrice
:
big
.
NewInt
(
1
),
MinerRecommit
:
time
.
Second
,
})
...
...
miner/stress_ethash.go
View file @
e29c2e43
...
...
@@ -186,6 +186,8 @@ func makeMiner(genesis *core.Genesis, nodes []string) (*node.Node, error) {
TxPool
:
core
.
DefaultTxPoolConfig
,
GPO
:
eth
.
DefaultConfig
.
GPO
,
Ethash
:
eth
.
DefaultConfig
.
Ethash
,
MinerGasFloor
:
genesis
.
GasLimit
*
9
/
10
,
MinerGasCeil
:
genesis
.
GasLimit
*
11
/
10
,
MinerGasPrice
:
big
.
NewInt
(
1
),
MinerRecommit
:
time
.
Second
,
})
...
...
miner/worker.go
View file @
e29c2e43
...
...
@@ -127,6 +127,9 @@ type worker struct {
eth
Backend
chain
*
core
.
BlockChain
gasFloor
uint64
gasCeil
uint64
// Subscriptions
mux
*
event
.
TypeMux
txsCh
chan
core
.
NewTxsEvent
...
...
@@ -171,13 +174,15 @@ type worker struct {
resubmitHook
func
(
time
.
Duration
,
time
.
Duration
)
// Method to call upon updating resubmitting interval.
}
func
newWorker
(
config
*
params
.
ChainConfig
,
engine
consensus
.
Engine
,
eth
Backend
,
mux
*
event
.
TypeMux
,
recommit
time
.
Duration
)
*
worker
{
func
newWorker
(
config
*
params
.
ChainConfig
,
engine
consensus
.
Engine
,
eth
Backend
,
mux
*
event
.
TypeMux
,
recommit
time
.
Duration
,
gasFloor
,
gasCeil
uint64
)
*
worker
{
worker
:=
&
worker
{
config
:
config
,
engine
:
engine
,
eth
:
eth
,
mux
:
mux
,
chain
:
eth
.
BlockChain
(),
gasFloor
:
gasFloor
,
gasCeil
:
gasCeil
,
possibleUncles
:
make
(
map
[
common
.
Hash
]
*
types
.
Block
),
unconfirmed
:
newUnconfirmedBlocks
(
eth
.
BlockChain
(),
miningLogAtDepth
),
pendingTasks
:
make
(
map
[
common
.
Hash
]
*
task
),
...
...
@@ -807,7 +812,7 @@ func (w *worker) commitNewWork(interrupt *int32, noempty bool) {
header
:=
&
types
.
Header
{
ParentHash
:
parent
.
Hash
(),
Number
:
num
.
Add
(
num
,
common
.
Big1
),
GasLimit
:
core
.
CalcGasLimit
(
parent
),
GasLimit
:
core
.
CalcGasLimit
(
parent
,
w
.
gasFloor
,
w
.
gasCeil
),
Extra
:
w
.
extra
,
Time
:
big
.
NewInt
(
tstamp
),
}
...
...
miner/worker_test.go
View file @
e29c2e43
...
...
@@ -119,7 +119,7 @@ func (b *testWorkerBackend) PostChainEvents(events []interface{}) {
func
newTestWorker
(
t
*
testing
.
T
,
chainConfig
*
params
.
ChainConfig
,
engine
consensus
.
Engine
)
(
*
worker
,
*
testWorkerBackend
)
{
backend
:=
newTestWorkerBackend
(
t
,
chainConfig
,
engine
)
backend
.
txPool
.
AddLocals
(
pendingTxs
)
w
:=
newWorker
(
chainConfig
,
engine
,
backend
,
new
(
event
.
TypeMux
),
time
.
Second
)
w
:=
newWorker
(
chainConfig
,
engine
,
backend
,
new
(
event
.
TypeMux
),
time
.
Second
,
params
.
GenesisGasLimit
,
params
.
GenesisGasLimit
)
w
.
setEtherbase
(
testBankAddress
)
return
w
,
backend
}
...
...
params/denomination.go
View file @
e29c2e43
...
...
@@ -17,18 +17,12 @@
package
params
// These are the multipliers for ether denominations.
// Example: To get the wei value of an amount in '
douglas
', use
// Example: To get the wei value of an amount in '
gwei
', use
//
// new(big.Int).Mul(value, big.NewInt(params.
Douglas
))
// new(big.Int).Mul(value, big.NewInt(params.
GWei
))
//
const
(
Wei
=
1
Ada
=
1e3
Babbage
=
1e6
Shannon
=
1e9
Szabo
=
1e12
Finney
=
1e15
Ether
=
1e18
Einstein
=
1e21
Douglas
=
1e42
Wei
=
1
GWei
=
1e9
Ether
=
1e18
)
params/protocol_params.go
View file @
e29c2e43
...
...
@@ -18,10 +18,6 @@ package params
import
"math/big"
var
(
TargetGasLimit
=
GenesisGasLimit
// The artificial target
)
const
(
GasLimitBoundDivisor
uint64
=
1024
// The bound divisor of the gas limit, used in update calculations.
MinGasLimit
uint64
=
5000
// Minimum the gas limit may ever be.
...
...
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