Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
whqwjb
go-ethereum
提交
6d175460
G
go-ethereum
项目概览
whqwjb
/
go-ethereum
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
go-ethereum
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
6d175460
编写于
8月 10, 2021
作者:
G
gary rong
提交者:
GitHub
8月 10, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
cmd, core, eth, miner: deprecate miner.gastarget flag (#23213)
上级
520f2568
变更
13
隐藏空白更改
内联
并排
Showing
13 changed file
with
32 addition
and
71 deletion
+32
-71
cmd/geth/main.go
cmd/geth/main.go
+1
-1
cmd/geth/usage.go
cmd/geth/usage.go
+1
-1
cmd/utils/flags.go
cmd/utils/flags.go
+3
-8
cmd/utils/flags_legacy.go
cmd/utils/flags_legacy.go
+13
-3
core/block_validator.go
core/block_validator.go
+3
-38
core/block_validator_test.go
core/block_validator_test.go
+6
-7
core/chain_makers.go
core/chain_makers.go
+2
-3
eth/ethconfig/config.go
eth/ethconfig/config.go
+0
-1
miner/stress/1559/main.go
miner/stress/1559/main.go
+0
-1
miner/stress/clique/main.go
miner/stress/clique/main.go
+0
-1
miner/stress/ethash/main.go
miner/stress/ethash/main.go
+0
-1
miner/worker.go
miner/worker.go
+3
-5
miner/worker_test.go
miner/worker_test.go
+0
-1
未找到文件。
cmd/geth/main.go
浏览文件 @
6d175460
...
...
@@ -118,7 +118,7 @@ var (
utils
.
MiningEnabledFlag
,
utils
.
MinerThreadsFlag
,
utils
.
MinerNotifyFlag
,
utils
.
MinerGasTargetFlag
,
utils
.
Legacy
MinerGasTargetFlag
,
utils
.
MinerGasLimitFlag
,
utils
.
MinerGasPriceFlag
,
utils
.
MinerEtherbaseFlag
,
...
...
cmd/geth/usage.go
浏览文件 @
6d175460
...
...
@@ -182,7 +182,6 @@ var AppHelpFlagGroups = []flags.FlagGroup{
utils
.
MinerNotifyFlag
,
utils
.
MinerNotifyFullFlag
,
utils
.
MinerGasPriceFlag
,
utils
.
MinerGasTargetFlag
,
utils
.
MinerGasLimitFlag
,
utils
.
MinerEtherbaseFlag
,
utils
.
MinerExtraDataFlag
,
...
...
@@ -226,6 +225,7 @@ var AppHelpFlagGroups = []flags.FlagGroup{
utils
.
LegacyRPCCORSDomainFlag
,
utils
.
LegacyRPCVirtualHostsFlag
,
utils
.
LegacyRPCApiFlag
,
utils
.
LegacyMinerGasTargetFlag
,
},
},
{
...
...
cmd/utils/flags.go
浏览文件 @
6d175460
...
...
@@ -444,11 +444,6 @@ var (
Name
:
"miner.notify.full"
,
Usage
:
"Notify with pending block headers instead of work packages"
,
}
MinerGasTargetFlag
=
cli
.
Uint64Flag
{
Name
:
"miner.gastarget"
,
Usage
:
"Target gas floor for mined blocks"
,
Value
:
ethconfig
.
Defaults
.
Miner
.
GasFloor
,
}
MinerGasLimitFlag
=
cli
.
Uint64Flag
{
Name
:
"miner.gaslimit"
,
Usage
:
"Target gas ceiling for mined blocks"
,
...
...
@@ -1386,9 +1381,6 @@ func setMiner(ctx *cli.Context, cfg *miner.Config) {
if
ctx
.
GlobalIsSet
(
MinerExtraDataFlag
.
Name
)
{
cfg
.
ExtraData
=
[]
byte
(
ctx
.
GlobalString
(
MinerExtraDataFlag
.
Name
))
}
if
ctx
.
GlobalIsSet
(
MinerGasTargetFlag
.
Name
)
{
cfg
.
GasFloor
=
ctx
.
GlobalUint64
(
MinerGasTargetFlag
.
Name
)
}
if
ctx
.
GlobalIsSet
(
MinerGasLimitFlag
.
Name
)
{
cfg
.
GasCeil
=
ctx
.
GlobalUint64
(
MinerGasLimitFlag
.
Name
)
}
...
...
@@ -1401,6 +1393,9 @@ func setMiner(ctx *cli.Context, cfg *miner.Config) {
if
ctx
.
GlobalIsSet
(
MinerNoVerfiyFlag
.
Name
)
{
cfg
.
Noverify
=
ctx
.
GlobalBool
(
MinerNoVerfiyFlag
.
Name
)
}
if
ctx
.
GlobalIsSet
(
LegacyMinerGasTargetFlag
.
Name
)
{
log
.
Warn
(
"The generic --miner.gastarget flag is deprecated and will be removed in the future!"
)
}
}
func
setWhitelist
(
ctx
*
cli
.
Context
,
cfg
*
ethconfig
.
Config
)
{
...
...
cmd/utils/flags_legacy.go
浏览文件 @
6d175460
...
...
@@ -20,6 +20,7 @@ import (
"fmt"
"strings"
"github.com/ethereum/go-ethereum/eth/ethconfig"
"github.com/ethereum/go-ethereum/node"
"gopkg.in/urfave/cli.v1"
)
...
...
@@ -33,7 +34,9 @@ var ShowDeprecated = cli.Command{
Description
:
"Show flags that have been deprecated and will soon be removed"
,
}
var
DeprecatedFlags
=
[]
cli
.
Flag
{}
var
DeprecatedFlags
=
[]
cli
.
Flag
{
LegacyMinerGasTargetFlag
,
}
var
(
// (Deprecated May 2020, shown in aliased flags section)
...
...
@@ -66,6 +69,12 @@ var (
Usage
:
"API's offered over the HTTP-RPC interface (deprecated and will be removed June 2021, use --http.api)"
,
Value
:
""
,
}
// (Deprecated July 2021, shown in aliased flags section)
LegacyMinerGasTargetFlag
=
cli
.
Uint64Flag
{
Name
:
"miner.gastarget"
,
Usage
:
"Target gas floor for mined blocks (deprecated)"
,
Value
:
ethconfig
.
Defaults
.
Miner
.
GasFloor
,
}
)
// showDeprecated displays deprecated flags that will be soon removed from the codebase.
...
...
@@ -74,7 +83,8 @@ func showDeprecated(*cli.Context) {
fmt
.
Println
(
"The following flags are deprecated and will be removed in the future!"
)
fmt
.
Println
(
"--------------------------------------------------------------------"
)
fmt
.
Println
()
// TODO remove when there are newly deprecated flags
fmt
.
Println
(
"no deprecated flags to show at this time"
)
for
_
,
flag
:=
range
DeprecatedFlags
{
fmt
.
Println
(
flag
.
String
())
}
fmt
.
Println
()
}
core/block_validator.go
浏览文件 @
6d175460
...
...
@@ -103,44 +103,9 @@ func (v *BlockValidator) ValidateState(block *types.Block, statedb *state.StateD
}
// 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
(
parentGasUsed
,
parentGasLimit
,
gasFloor
,
gasCeil
uint64
)
uint64
{
// contrib = (parentGasUsed * 3 / 2) / 1024
contrib
:=
(
parentGasUsed
+
parentGasUsed
/
2
)
/
params
.
GasLimitBoundDivisor
// decay = parentGasLimit / 1024 -1
decay
:=
parentGasLimit
/
params
.
GasLimitBoundDivisor
-
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.
*/
limit
:=
parentGasLimit
-
decay
+
contrib
if
limit
<
params
.
MinGasLimit
{
limit
=
params
.
MinGasLimit
}
// If we're outside our allowed gas range, we try to hone towards them
if
limit
<
gasFloor
{
limit
=
parentGasLimit
+
decay
if
limit
>
gasFloor
{
limit
=
gasFloor
}
}
else
if
limit
>
gasCeil
{
limit
=
parentGasLimit
-
decay
if
limit
<
gasCeil
{
limit
=
gasCeil
}
}
return
limit
}
// CalcGasLimit1559 calculates the next block gas limit under 1559 rules.
func
CalcGasLimit1559
(
parentGasLimit
,
desiredLimit
uint64
)
uint64
{
// to keep the baseline gas close to the provided target, and increase it towards
// the target if the baseline gas is lower.
func
CalcGasLimit
(
parentGasLimit
,
desiredLimit
uint64
)
uint64
{
delta
:=
parentGasLimit
/
params
.
GasLimitBoundDivisor
-
1
limit
:=
parentGasLimit
if
desiredLimit
<
params
.
MinGasLimit
{
...
...
core/block_validator_test.go
浏览文件 @
6d175460
...
...
@@ -198,8 +198,7 @@ func testHeaderConcurrentAbortion(t *testing.T, threads int) {
}
}
func
TestCalcGasLimit1559
(
t
*
testing
.
T
)
{
func
TestCalcGasLimit
(
t
*
testing
.
T
)
{
for
i
,
tc
:=
range
[]
struct
{
pGasLimit
uint64
max
uint64
...
...
@@ -209,23 +208,23 @@ func TestCalcGasLimit1559(t *testing.T) {
{
40000000
,
40039061
,
39960939
},
}
{
// Increase
if
have
,
want
:=
CalcGasLimit
1559
(
tc
.
pGasLimit
,
2
*
tc
.
pGasLimit
),
tc
.
max
;
have
!=
want
{
if
have
,
want
:=
CalcGasLimit
(
tc
.
pGasLimit
,
2
*
tc
.
pGasLimit
),
tc
.
max
;
have
!=
want
{
t
.
Errorf
(
"test %d: have %d want <%d"
,
i
,
have
,
want
)
}
// Decrease
if
have
,
want
:=
CalcGasLimit
1559
(
tc
.
pGasLimit
,
0
),
tc
.
min
;
have
!=
want
{
if
have
,
want
:=
CalcGasLimit
(
tc
.
pGasLimit
,
0
),
tc
.
min
;
have
!=
want
{
t
.
Errorf
(
"test %d: have %d want >%d"
,
i
,
have
,
want
)
}
// Small decrease
if
have
,
want
:=
CalcGasLimit
1559
(
tc
.
pGasLimit
,
tc
.
pGasLimit
-
1
),
tc
.
pGasLimit
-
1
;
have
!=
want
{
if
have
,
want
:=
CalcGasLimit
(
tc
.
pGasLimit
,
tc
.
pGasLimit
-
1
),
tc
.
pGasLimit
-
1
;
have
!=
want
{
t
.
Errorf
(
"test %d: have %d want %d"
,
i
,
have
,
want
)
}
// Small increase
if
have
,
want
:=
CalcGasLimit
1559
(
tc
.
pGasLimit
,
tc
.
pGasLimit
+
1
),
tc
.
pGasLimit
+
1
;
have
!=
want
{
if
have
,
want
:=
CalcGasLimit
(
tc
.
pGasLimit
,
tc
.
pGasLimit
+
1
),
tc
.
pGasLimit
+
1
;
have
!=
want
{
t
.
Errorf
(
"test %d: have %d want %d"
,
i
,
have
,
want
)
}
// No change
if
have
,
want
:=
CalcGasLimit
1559
(
tc
.
pGasLimit
,
tc
.
pGasLimit
),
tc
.
pGasLimit
;
have
!=
want
{
if
have
,
want
:=
CalcGasLimit
(
tc
.
pGasLimit
,
tc
.
pGasLimit
),
tc
.
pGasLimit
;
have
!=
want
{
t
.
Errorf
(
"test %d: have %d want %d"
,
i
,
have
,
want
)
}
}
...
...
core/chain_makers.go
浏览文件 @
6d175460
...
...
@@ -273,11 +273,10 @@ func makeHeader(chain consensus.ChainReader, parent *types.Block, state *state.S
}
if
chain
.
Config
()
.
IsLondon
(
header
.
Number
)
{
header
.
BaseFee
=
misc
.
CalcBaseFee
(
chain
.
Config
(),
parent
.
Header
())
parentGasLimit
:=
parent
.
GasLimit
()
if
!
chain
.
Config
()
.
IsLondon
(
parent
.
Number
())
{
parentGasLimit
=
parent
.
GasLimit
()
*
params
.
ElasticityMultiplier
parentGasLimit
:=
parent
.
GasLimit
()
*
params
.
ElasticityMultiplier
header
.
GasLimit
=
CalcGasLimit
(
parentGasLimit
,
parentGasLimit
)
}
header
.
GasLimit
=
CalcGasLimit1559
(
parentGasLimit
,
parentGasLimit
)
}
return
header
}
...
...
eth/ethconfig/config.go
浏览文件 @
6d175460
...
...
@@ -83,7 +83,6 @@ var Defaults = Config{
TrieTimeout
:
60
*
time
.
Minute
,
SnapshotCache
:
102
,
Miner
:
miner
.
Config
{
GasFloor
:
8000000
,
GasCeil
:
8000000
,
GasPrice
:
big
.
NewInt
(
params
.
GWei
),
Recommit
:
3
*
time
.
Second
,
...
...
miner/stress/1559/main.go
浏览文件 @
6d175460
...
...
@@ -242,7 +242,6 @@ func makeMiner(genesis *core.Genesis) (*node.Node, *eth.Ethereum, error) {
GPO
:
ethconfig
.
Defaults
.
GPO
,
Ethash
:
ethconfig
.
Defaults
.
Ethash
,
Miner
:
miner
.
Config
{
GasFloor
:
genesis
.
GasLimit
*
9
/
10
,
GasCeil
:
genesis
.
GasLimit
*
11
/
10
,
GasPrice
:
big
.
NewInt
(
1
),
Recommit
:
time
.
Second
,
...
...
miner/stress/clique/main.go
浏览文件 @
6d175460
...
...
@@ -193,7 +193,6 @@ func makeSealer(genesis *core.Genesis) (*node.Node, *eth.Ethereum, error) {
TxPool
:
core
.
DefaultTxPoolConfig
,
GPO
:
ethconfig
.
Defaults
.
GPO
,
Miner
:
miner
.
Config
{
GasFloor
:
genesis
.
GasLimit
*
9
/
10
,
GasCeil
:
genesis
.
GasLimit
*
11
/
10
,
GasPrice
:
big
.
NewInt
(
1
),
Recommit
:
time
.
Second
,
...
...
miner/stress/ethash/main.go
浏览文件 @
6d175460
...
...
@@ -171,7 +171,6 @@ func makeMiner(genesis *core.Genesis) (*node.Node, *eth.Ethereum, error) {
GPO
:
ethconfig
.
Defaults
.
GPO
,
Ethash
:
ethconfig
.
Defaults
.
Ethash
,
Miner
:
miner
.
Config
{
GasFloor
:
genesis
.
GasLimit
*
9
/
10
,
GasCeil
:
genesis
.
GasLimit
*
11
/
10
,
GasPrice
:
big
.
NewInt
(
1
),
Recommit
:
time
.
Second
,
...
...
miner/worker.go
浏览文件 @
6d175460
...
...
@@ -897,19 +897,17 @@ func (w *worker) commitNewWork(interrupt *int32, noempty bool, timestamp int64)
header
:=
&
types
.
Header
{
ParentHash
:
parent
.
Hash
(),
Number
:
num
.
Add
(
num
,
common
.
Big1
),
GasLimit
:
core
.
CalcGasLimit
(
parent
.
Gas
Used
(),
parent
.
GasLimit
(),
w
.
config
.
GasFloor
,
w
.
config
.
GasCeil
),
GasLimit
:
core
.
CalcGasLimit
(
parent
.
Gas
Limit
()
,
w
.
config
.
GasCeil
),
Extra
:
w
.
extra
,
Time
:
uint64
(
timestamp
),
}
// Set baseFee and GasLimit if we are on an EIP-1559 chain
if
w
.
chainConfig
.
IsLondon
(
header
.
Number
)
{
header
.
BaseFee
=
misc
.
CalcBaseFee
(
w
.
chainConfig
,
parent
.
Header
())
parentGasLimit
:=
parent
.
GasLimit
()
if
!
w
.
chainConfig
.
IsLondon
(
parent
.
Number
())
{
// Bump by 2x
parentGasLimit
=
parent
.
GasLimit
()
*
params
.
ElasticityMultiplier
parentGasLimit
:=
parent
.
GasLimit
()
*
params
.
ElasticityMultiplier
header
.
GasLimit
=
core
.
CalcGasLimit
(
parentGasLimit
,
w
.
config
.
GasCeil
)
}
header
.
GasLimit
=
core
.
CalcGasLimit1559
(
parentGasLimit
,
w
.
config
.
GasCeil
)
}
// Only set the coinbase if our consensus engine is running (avoid spurious block rewards)
if
w
.
isRunning
()
{
...
...
miner/worker_test.go
浏览文件 @
6d175460
...
...
@@ -67,7 +67,6 @@ var (
testConfig
=
&
Config
{
Recommit
:
time
.
Second
,
GasFloor
:
params
.
GenesisGasLimit
,
GasCeil
:
params
.
GenesisGasLimit
,
}
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录