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
08959bbc
Unverified
Commit
08959bbc
authored
May 26, 2017
by
Péter Szilágyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cmd, core, eth: configurable txpool parameters
parent
dd5ed01f
Changes
10
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
241 additions
and
105 deletions
+241
-105
main.go
cmd/geth/main.go
+7
-0
usage.go
cmd/geth/usage.go
+12
-0
flags.go
cmd/utils/flags.go
+91
-29
tx_list.go
core/tx_list.go
+2
-2
tx_list_test.go
core/tx_list_test.go
+1
-1
tx_pool.go
core/tx_pool.go
+73
-28
tx_pool_test.go
core/tx_pool_test.go
+44
-44
backend.go
eth/backend.go
+1
-1
config.go
eth/config.go
+4
-0
gen_config.go
eth/gen_config.go
+6
-0
No files found.
cmd/geth/main.go
View file @
08959bbc
...
...
@@ -66,6 +66,13 @@ var (
utils
.
EthashDatasetDirFlag
,
utils
.
EthashDatasetsInMemoryFlag
,
utils
.
EthashDatasetsOnDiskFlag
,
utils
.
TxPoolPriceLimitFlag
,
utils
.
TxPoolPriceBumpFlag
,
utils
.
TxPoolAccountSlotsFlag
,
utils
.
TxPoolGlobalSlotsFlag
,
utils
.
TxPoolAccountQueueFlag
,
utils
.
TxPoolGlobalQueueFlag
,
utils
.
TxPoolLifetimeFlag
,
utils
.
FastSyncFlag
,
utils
.
LightModeFlag
,
utils
.
SyncModeFlag
,
...
...
cmd/geth/usage.go
View file @
08959bbc
...
...
@@ -92,6 +92,18 @@ var AppHelpFlagGroups = []flagGroup{
utils
.
EthashDatasetsOnDiskFlag
,
},
},
{
Name
:
"TRANSACTION POOL"
,
Flags
:
[]
cli
.
Flag
{
utils
.
TxPoolPriceLimitFlag
,
utils
.
TxPoolPriceBumpFlag
,
utils
.
TxPoolAccountSlotsFlag
,
utils
.
TxPoolGlobalSlotsFlag
,
utils
.
TxPoolAccountQueueFlag
,
utils
.
TxPoolGlobalQueueFlag
,
utils
.
TxPoolLifetimeFlag
,
},
},
{
Name
:
"PERFORMANCE TUNING"
,
Flags
:
[]
cli
.
Flag
{
...
...
cmd/utils/flags.go
View file @
08959bbc
...
...
@@ -123,35 +123,6 @@ var (
Name
:
"nousb"
,
Usage
:
"Disables monitoring for and managine USB hardware wallets"
,
}
EthashCacheDirFlag
=
DirectoryFlag
{
Name
:
"ethash.cachedir"
,
Usage
:
"Directory to store the ethash verification caches (default = inside the datadir)"
,
}
EthashCachesInMemoryFlag
=
cli
.
IntFlag
{
Name
:
"ethash.cachesinmem"
,
Usage
:
"Number of recent ethash caches to keep in memory (16MB each)"
,
Value
:
eth
.
DefaultConfig
.
EthashCachesInMem
,
}
EthashCachesOnDiskFlag
=
cli
.
IntFlag
{
Name
:
"ethash.cachesondisk"
,
Usage
:
"Number of recent ethash caches to keep on disk (16MB each)"
,
Value
:
eth
.
DefaultConfig
.
EthashCachesOnDisk
,
}
EthashDatasetDirFlag
=
DirectoryFlag
{
Name
:
"ethash.dagdir"
,
Usage
:
"Directory to store the ethash mining DAGs (default = inside home folder)"
,
Value
:
DirectoryString
{
eth
.
DefaultConfig
.
EthashDatasetDir
},
}
EthashDatasetsInMemoryFlag
=
cli
.
IntFlag
{
Name
:
"ethash.dagsinmem"
,
Usage
:
"Number of recent ethash mining DAGs to keep in memory (1+GB each)"
,
Value
:
eth
.
DefaultConfig
.
EthashDatasetsInMem
,
}
EthashDatasetsOnDiskFlag
=
cli
.
IntFlag
{
Name
:
"ethash.dagsondisk"
,
Usage
:
"Number of recent ethash mining DAGs to keep on disk (1+GB each)"
,
Value
:
eth
.
DefaultConfig
.
EthashDatasetsOnDisk
,
}
NetworkIdFlag
=
cli
.
Uint64Flag
{
Name
:
"networkid"
,
Usage
:
"Network identifier (integer, 1=Frontier, 2=Morden (disused), 3=Ropsten, 4=Rinkeby)"
,
...
...
@@ -207,6 +178,72 @@ var (
Name
:
"lightkdf"
,
Usage
:
"Reduce key-derivation RAM & CPU usage at some expense of KDF strength"
,
}
// Ethash settings
EthashCacheDirFlag
=
DirectoryFlag
{
Name
:
"ethash.cachedir"
,
Usage
:
"Directory to store the ethash verification caches (default = inside the datadir)"
,
}
EthashCachesInMemoryFlag
=
cli
.
IntFlag
{
Name
:
"ethash.cachesinmem"
,
Usage
:
"Number of recent ethash caches to keep in memory (16MB each)"
,
Value
:
eth
.
DefaultConfig
.
EthashCachesInMem
,
}
EthashCachesOnDiskFlag
=
cli
.
IntFlag
{
Name
:
"ethash.cachesondisk"
,
Usage
:
"Number of recent ethash caches to keep on disk (16MB each)"
,
Value
:
eth
.
DefaultConfig
.
EthashCachesOnDisk
,
}
EthashDatasetDirFlag
=
DirectoryFlag
{
Name
:
"ethash.dagdir"
,
Usage
:
"Directory to store the ethash mining DAGs (default = inside home folder)"
,
Value
:
DirectoryString
{
eth
.
DefaultConfig
.
EthashDatasetDir
},
}
EthashDatasetsInMemoryFlag
=
cli
.
IntFlag
{
Name
:
"ethash.dagsinmem"
,
Usage
:
"Number of recent ethash mining DAGs to keep in memory (1+GB each)"
,
Value
:
eth
.
DefaultConfig
.
EthashDatasetsInMem
,
}
EthashDatasetsOnDiskFlag
=
cli
.
IntFlag
{
Name
:
"ethash.dagsondisk"
,
Usage
:
"Number of recent ethash mining DAGs to keep on disk (1+GB each)"
,
Value
:
eth
.
DefaultConfig
.
EthashDatasetsOnDisk
,
}
// Transaction pool settings
TxPoolPriceLimitFlag
=
cli
.
Uint64Flag
{
Name
:
"txpool.pricelimit"
,
Usage
:
"Minimum gas price limit to enforce for acceptance into the pool"
,
Value
:
eth
.
DefaultConfig
.
TxPool
.
PriceLimit
,
}
TxPoolPriceBumpFlag
=
cli
.
Uint64Flag
{
Name
:
"txpool.pricebump"
,
Usage
:
"Price bump percentage to replace an already existing transaction"
,
Value
:
eth
.
DefaultConfig
.
TxPool
.
PriceBump
,
}
TxPoolAccountSlotsFlag
=
cli
.
Uint64Flag
{
Name
:
"txpool.accountslots"
,
Usage
:
"Minimum number of executable transaction slots guaranteed per account"
,
Value
:
eth
.
DefaultConfig
.
TxPool
.
AccountSlots
,
}
TxPoolGlobalSlotsFlag
=
cli
.
Uint64Flag
{
Name
:
"txpool.globalslots"
,
Usage
:
"Maximum number of executable transaction slots for all accounts"
,
Value
:
eth
.
DefaultConfig
.
TxPool
.
GlobalSlots
,
}
TxPoolAccountQueueFlag
=
cli
.
Uint64Flag
{
Name
:
"txpool.accountqueue"
,
Usage
:
"Maximum number of non-executable transaction slots permitted per account"
,
Value
:
eth
.
DefaultConfig
.
TxPool
.
AccountQueue
,
}
TxPoolGlobalQueueFlag
=
cli
.
Uint64Flag
{
Name
:
"txpool.globalqueue"
,
Usage
:
"Maximum number of non-executable transaction slots for all accounts"
,
Value
:
eth
.
DefaultConfig
.
TxPool
.
GlobalQueue
,
}
TxPoolLifetimeFlag
=
cli
.
DurationFlag
{
Name
:
"txpool.lifetime"
,
Usage
:
"Maximum amount of time non-executable transaction are queued"
,
Value
:
eth
.
DefaultConfig
.
TxPool
.
Lifetime
,
}
// Performance tuning settings
CacheFlag
=
cli
.
IntFlag
{
Name
:
"cache"
,
...
...
@@ -784,6 +821,30 @@ func setGPO(ctx *cli.Context, cfg *gasprice.Config) {
}
}
func
setTxPool
(
ctx
*
cli
.
Context
,
cfg
*
core
.
TxPoolConfig
)
{
if
ctx
.
GlobalIsSet
(
TxPoolPriceLimitFlag
.
Name
)
{
cfg
.
PriceLimit
=
ctx
.
GlobalUint64
(
TxPoolPriceLimitFlag
.
Name
)
}
if
ctx
.
GlobalIsSet
(
TxPoolPriceBumpFlag
.
Name
)
{
cfg
.
PriceBump
=
ctx
.
GlobalUint64
(
TxPoolPriceBumpFlag
.
Name
)
}
if
ctx
.
GlobalIsSet
(
TxPoolAccountSlotsFlag
.
Name
)
{
cfg
.
AccountSlots
=
ctx
.
GlobalUint64
(
TxPoolAccountSlotsFlag
.
Name
)
}
if
ctx
.
GlobalIsSet
(
TxPoolGlobalSlotsFlag
.
Name
)
{
cfg
.
GlobalSlots
=
ctx
.
GlobalUint64
(
TxPoolGlobalSlotsFlag
.
Name
)
}
if
ctx
.
GlobalIsSet
(
TxPoolAccountQueueFlag
.
Name
)
{
cfg
.
AccountQueue
=
ctx
.
GlobalUint64
(
TxPoolAccountQueueFlag
.
Name
)
}
if
ctx
.
GlobalIsSet
(
TxPoolGlobalQueueFlag
.
Name
)
{
cfg
.
GlobalQueue
=
ctx
.
GlobalUint64
(
TxPoolGlobalQueueFlag
.
Name
)
}
if
ctx
.
GlobalIsSet
(
TxPoolLifetimeFlag
.
Name
)
{
cfg
.
Lifetime
=
ctx
.
GlobalDuration
(
TxPoolLifetimeFlag
.
Name
)
}
}
func
setEthash
(
ctx
*
cli
.
Context
,
cfg
*
eth
.
Config
)
{
if
ctx
.
GlobalIsSet
(
EthashCacheDirFlag
.
Name
)
{
cfg
.
EthashCacheDir
=
ctx
.
GlobalString
(
EthashCacheDirFlag
.
Name
)
...
...
@@ -826,6 +887,7 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *eth.Config) {
ks
:=
stack
.
AccountManager
()
.
Backends
(
keystore
.
KeyStoreType
)[
0
]
.
(
*
keystore
.
KeyStore
)
setEtherbase
(
ctx
,
ks
,
cfg
)
setGPO
(
ctx
,
&
cfg
.
GPO
)
setTxPool
(
ctx
,
&
cfg
.
TxPool
)
setEthash
(
ctx
,
cfg
)
switch
{
...
...
core/tx_list.go
View file @
08959bbc
...
...
@@ -246,11 +246,11 @@ func (l *txList) Overlaps(tx *types.Transaction) bool {
//
// If the new transaction is accepted into the list, the lists' cost threshold
// is also potentially updated.
func
(
l
*
txList
)
Add
(
tx
*
types
.
Transaction
)
(
bool
,
*
types
.
Transaction
)
{
func
(
l
*
txList
)
Add
(
tx
*
types
.
Transaction
,
priceBump
uint64
)
(
bool
,
*
types
.
Transaction
)
{
// If there's an older better transaction, abort
old
:=
l
.
txs
.
Get
(
tx
.
Nonce
())
if
old
!=
nil
{
threshold
:=
new
(
big
.
Int
)
.
Div
(
new
(
big
.
Int
)
.
Mul
(
old
.
GasPrice
(),
big
.
NewInt
(
100
+
minPriceBumpPercent
)),
big
.
NewInt
(
100
))
threshold
:=
new
(
big
.
Int
)
.
Div
(
new
(
big
.
Int
)
.
Mul
(
old
.
GasPrice
(),
big
.
NewInt
(
100
+
int64
(
priceBump
)
)),
big
.
NewInt
(
100
))
if
threshold
.
Cmp
(
tx
.
GasPrice
())
>=
0
{
return
false
,
nil
}
...
...
core/tx_list_test.go
View file @
08959bbc
...
...
@@ -38,7 +38,7 @@ func TestStrictTxListAdd(t *testing.T) {
// Insert the transactions in a random order
list
:=
newTxList
(
true
)
for
_
,
v
:=
range
rand
.
Perm
(
len
(
txs
))
{
list
.
Add
(
txs
[
v
])
list
.
Add
(
txs
[
v
]
,
DefaultTxPoolConfig
.
PriceBump
)
}
// Verify internal state
if
len
(
list
.
txs
.
items
)
!=
len
(
txs
)
{
...
...
core/tx_pool.go
View file @
08959bbc
This diff is collapsed.
Click to expand it.
core/tx_pool_test.go
View file @
08959bbc
This diff is collapsed.
Click to expand it.
eth/backend.go
View file @
08959bbc
...
...
@@ -150,7 +150,7 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) {
core
.
WriteChainConfig
(
chainDb
,
genesisHash
,
chainConfig
)
}
newPool
:=
core
.
NewTxPool
(
eth
.
chainConfig
,
eth
.
EventMux
(),
eth
.
blockchain
.
State
,
eth
.
blockchain
.
GasLimit
)
newPool
:=
core
.
NewTxPool
(
config
.
TxPool
,
eth
.
chainConfig
,
eth
.
EventMux
(),
eth
.
blockchain
.
State
,
eth
.
blockchain
.
GasLimit
)
eth
.
txPool
=
newPool
maxPeers
:=
config
.
MaxPeers
...
...
eth/config.go
View file @
08959bbc
...
...
@@ -44,6 +44,7 @@ var DefaultConfig = Config{
DatabaseCache
:
128
,
GasPrice
:
big
.
NewInt
(
18
*
params
.
Shannon
),
TxPool
:
core
.
DefaultTxPoolConfig
,
GPO
:
gasprice
.
Config
{
Blocks
:
10
,
Percentile
:
50
,
...
...
@@ -99,6 +100,9 @@ type Config struct {
EthashDatasetsInMem
int
EthashDatasetsOnDisk
int
// Transaction pool options
TxPool
core
.
TxPoolConfig
// Gas Price Oracle options
GPO
gasprice
.
Config
...
...
eth/gen_config.go
View file @
08959bbc
...
...
@@ -33,6 +33,7 @@ func (c Config) MarshalTOML() (interface{}, error) {
EthashDatasetDir
string
EthashDatasetsInMem
int
EthashDatasetsOnDisk
int
TxPool
core
.
TxPoolConfig
GPO
gasprice
.
Config
EnablePreimageRecording
bool
DocRoot
string
`toml:"-"`
...
...
@@ -60,6 +61,7 @@ func (c Config) MarshalTOML() (interface{}, error) {
enc
.
EthashDatasetDir
=
c
.
EthashDatasetDir
enc
.
EthashDatasetsInMem
=
c
.
EthashDatasetsInMem
enc
.
EthashDatasetsOnDisk
=
c
.
EthashDatasetsOnDisk
enc
.
TxPool
=
c
.
TxPool
enc
.
GPO
=
c
.
GPO
enc
.
EnablePreimageRecording
=
c
.
EnablePreimageRecording
enc
.
DocRoot
=
c
.
DocRoot
...
...
@@ -90,6 +92,7 @@ func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error {
EthashDatasetDir
*
string
EthashDatasetsInMem
*
int
EthashDatasetsOnDisk
*
int
TxPool
*
core
.
TxPoolConfig
GPO
*
gasprice
.
Config
EnablePreimageRecording
*
bool
DocRoot
*
string
`toml:"-"`
...
...
@@ -158,6 +161,9 @@ func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error {
if
dec
.
EthashDatasetsOnDisk
!=
nil
{
c
.
EthashDatasetsOnDisk
=
*
dec
.
EthashDatasetsOnDisk
}
if
dec
.
TxPool
!=
nil
{
c
.
TxPool
=
*
dec
.
TxPool
}
if
dec
.
GPO
!=
nil
{
c
.
GPO
=
*
dec
.
GPO
}
...
...
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