Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
whqwjb
go-ethereum
提交
7e915ee3
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 搜索 >>
未验证
提交
7e915ee3
编写于
6月 04, 2021
作者:
P
Péter Szilágyi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
core, eth, miner: enforce configured mining reward post 1559 too
上级
3094e7f3
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
39 addition
and
12 deletion
+39
-12
core/tx_pool.go
core/tx_pool.go
+24
-5
core/tx_pool_test.go
core/tx_pool_test.go
+1
-1
core/types/transaction.go
core/types/transaction.go
+8
-0
eth/api_backend.go
eth/api_backend.go
+1
-1
eth/catalyst/api.go
eth/catalyst/api.go
+1
-1
eth/handler.go
eth/handler.go
+1
-1
eth/handler_test.go
eth/handler_test.go
+1
-1
eth/sync.go
eth/sync.go
+1
-1
miner/worker.go
miner/worker.go
+1
-1
未找到文件。
core/tx_pool.go
浏览文件 @
7e915ee3
...
@@ -26,6 +26,7 @@ import (
...
@@ -26,6 +26,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/prque"
"github.com/ethereum/go-ethereum/common/prque"
"github.com/ethereum/go-ethereum/consensus/misc"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/event"
...
@@ -496,13 +497,30 @@ func (pool *TxPool) Content() (map[common.Address]types.Transactions, map[common
...
@@ -496,13 +497,30 @@ func (pool *TxPool) Content() (map[common.Address]types.Transactions, map[common
// Pending retrieves all currently processable transactions, grouped by origin
// Pending retrieves all currently processable transactions, grouped by origin
// account and sorted by nonce. The returned transaction set is a copy and can be
// account and sorted by nonce. The returned transaction set is a copy and can be
// freely modified by calling code.
// freely modified by calling code.
func
(
pool
*
TxPool
)
Pending
()
(
map
[
common
.
Address
]
types
.
Transactions
,
error
)
{
//
// The enforceTips parameter can be used to do an extra filtering on the pending
// transactions and only return those whose **effective** tip is large enough in
// the next pending execution environment.
func
(
pool
*
TxPool
)
Pending
(
enforceTips
bool
)
(
map
[
common
.
Address
]
types
.
Transactions
,
error
)
{
pool
.
mu
.
Lock
()
pool
.
mu
.
Lock
()
defer
pool
.
mu
.
Unlock
()
defer
pool
.
mu
.
Unlock
()
pending
:=
make
(
map
[
common
.
Address
]
types
.
Transactions
)
pending
:=
make
(
map
[
common
.
Address
]
types
.
Transactions
)
for
addr
,
list
:=
range
pool
.
pending
{
for
addr
,
list
:=
range
pool
.
pending
{
pending
[
addr
]
=
list
.
Flatten
()
txs
:=
list
.
Flatten
()
// If the miner requests tip enforcement, cap the lists now
if
enforceTips
&&
!
pool
.
locals
.
contains
(
addr
)
{
for
i
,
tx
:=
range
txs
{
if
tx
.
EffectiveTipIntCmp
(
pool
.
gasPrice
,
pool
.
priced
.
urgent
.
baseFee
)
<
0
{
txs
=
txs
[
:
i
]
break
}
}
}
if
len
(
txs
)
>
0
{
pending
[
addr
]
=
txs
}
}
}
return
pending
,
nil
return
pending
,
nil
}
}
...
@@ -562,7 +580,7 @@ func (pool *TxPool) validateTx(tx *types.Transaction, local bool) error {
...
@@ -562,7 +580,7 @@ func (pool *TxPool) validateTx(tx *types.Transaction, local bool) error {
if
tx
.
Tip
()
.
BitLen
()
>
256
{
if
tx
.
Tip
()
.
BitLen
()
>
256
{
return
ErrTipVeryHigh
return
ErrTipVeryHigh
}
}
// Ensure feeCap is
less
than or equal to tip.
// Ensure feeCap is
greater
than or equal to tip.
if
tx
.
FeeCapIntCmp
(
tx
.
Tip
())
<
0
{
if
tx
.
FeeCapIntCmp
(
tx
.
Tip
())
<
0
{
return
ErrTipAboveFeeCap
return
ErrTipAboveFeeCap
}
}
...
@@ -1114,8 +1132,9 @@ func (pool *TxPool) runReorg(done chan struct{}, reset *txpoolResetRequest, dirt
...
@@ -1114,8 +1132,9 @@ func (pool *TxPool) runReorg(done chan struct{}, reset *txpoolResetRequest, dirt
// because of another transaction (e.g. higher gas price).
// because of another transaction (e.g. higher gas price).
if
reset
!=
nil
{
if
reset
!=
nil
{
pool
.
demoteUnexecutables
()
pool
.
demoteUnexecutables
()
if
reset
.
newHead
!=
nil
{
if
reset
.
newHead
!=
nil
&&
pool
.
chainconfig
.
IsLondon
(
new
(
big
.
Int
)
.
Add
(
reset
.
newHead
.
Number
,
big
.
NewInt
(
1
)))
{
pool
.
priced
.
SetBaseFee
(
reset
.
newHead
.
BaseFee
)
pendingBaseFee
:=
misc
.
CalcBaseFee
(
pool
.
chainconfig
,
reset
.
newHead
)
pool
.
priced
.
SetBaseFee
(
pendingBaseFee
)
}
}
}
}
// Ensure pool.queue and pool.pending sizes stay within the configured limits.
// Ensure pool.queue and pool.pending sizes stay within the configured limits.
...
...
core/tx_pool_test.go
浏览文件 @
7e915ee3
...
@@ -252,7 +252,7 @@ func TestStateChangeDuringTransactionPoolReset(t *testing.T) {
...
@@ -252,7 +252,7 @@ func TestStateChangeDuringTransactionPoolReset(t *testing.T) {
trigger
=
true
trigger
=
true
<-
pool
.
requestReset
(
nil
,
nil
)
<-
pool
.
requestReset
(
nil
,
nil
)
_
,
err
:=
pool
.
Pending
()
_
,
err
:=
pool
.
Pending
(
false
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"Could not fetch pending transactions: %v"
,
err
)
t
.
Fatalf
(
"Could not fetch pending transactions: %v"
,
err
)
}
}
...
...
core/types/transaction.go
浏览文件 @
7e915ee3
...
@@ -356,6 +356,14 @@ func (tx *Transaction) EffectiveTipCmp(other *Transaction, baseFee *big.Int) int
...
@@ -356,6 +356,14 @@ func (tx *Transaction) EffectiveTipCmp(other *Transaction, baseFee *big.Int) int
return
tx
.
EffectiveTipValue
(
baseFee
)
.
Cmp
(
other
.
EffectiveTipValue
(
baseFee
))
return
tx
.
EffectiveTipValue
(
baseFee
)
.
Cmp
(
other
.
EffectiveTipValue
(
baseFee
))
}
}
// EffectiveTipIntCmp compares the effective tip of a transaction to the given tip.
func
(
tx
*
Transaction
)
EffectiveTipIntCmp
(
other
*
big
.
Int
,
baseFee
*
big
.
Int
)
int
{
if
baseFee
==
nil
{
return
tx
.
TipIntCmp
(
other
)
}
return
tx
.
EffectiveTipValue
(
baseFee
)
.
Cmp
(
other
)
}
// Hash returns the transaction hash.
// Hash returns the transaction hash.
func
(
tx
*
Transaction
)
Hash
()
common
.
Hash
{
func
(
tx
*
Transaction
)
Hash
()
common
.
Hash
{
if
hash
:=
tx
.
hash
.
Load
();
hash
!=
nil
{
if
hash
:=
tx
.
hash
.
Load
();
hash
!=
nil
{
...
...
eth/api_backend.go
浏览文件 @
7e915ee3
...
@@ -231,7 +231,7 @@ func (b *EthAPIBackend) SendTx(ctx context.Context, signedTx *types.Transaction)
...
@@ -231,7 +231,7 @@ func (b *EthAPIBackend) SendTx(ctx context.Context, signedTx *types.Transaction)
}
}
func
(
b
*
EthAPIBackend
)
GetPoolTransactions
()
(
types
.
Transactions
,
error
)
{
func
(
b
*
EthAPIBackend
)
GetPoolTransactions
()
(
types
.
Transactions
,
error
)
{
pending
,
err
:=
b
.
eth
.
txPool
.
Pending
()
pending
,
err
:=
b
.
eth
.
txPool
.
Pending
(
false
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
...
eth/catalyst/api.go
浏览文件 @
7e915ee3
...
@@ -127,7 +127,7 @@ func (api *consensusAPI) AssembleBlock(params assembleBlockParams) (*executableD
...
@@ -127,7 +127,7 @@ func (api *consensusAPI) AssembleBlock(params assembleBlockParams) (*executableD
time
.
Sleep
(
wait
)
time
.
Sleep
(
wait
)
}
}
pending
,
err
:=
pool
.
Pending
()
pending
,
err
:=
pool
.
Pending
(
true
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
...
eth/handler.go
浏览文件 @
7e915ee3
...
@@ -66,7 +66,7 @@ type txPool interface {
...
@@ -66,7 +66,7 @@ type txPool interface {
// Pending should return pending transactions.
// Pending should return pending transactions.
// The slice should be modifiable by the caller.
// The slice should be modifiable by the caller.
Pending
()
(
map
[
common
.
Address
]
types
.
Transactions
,
error
)
Pending
(
enforceTips
bool
)
(
map
[
common
.
Address
]
types
.
Transactions
,
error
)
// SubscribeNewTxsEvent should return an event subscription of
// SubscribeNewTxsEvent should return an event subscription of
// NewTxsEvent and send events to the given channel.
// NewTxsEvent and send events to the given channel.
...
...
eth/handler_test.go
浏览文件 @
7e915ee3
...
@@ -91,7 +91,7 @@ func (p *testTxPool) AddRemotes(txs []*types.Transaction) []error {
...
@@ -91,7 +91,7 @@ func (p *testTxPool) AddRemotes(txs []*types.Transaction) []error {
}
}
// Pending returns all the transactions known to the pool
// Pending returns all the transactions known to the pool
func
(
p
*
testTxPool
)
Pending
()
(
map
[
common
.
Address
]
types
.
Transactions
,
error
)
{
func
(
p
*
testTxPool
)
Pending
(
enforceTips
bool
)
(
map
[
common
.
Address
]
types
.
Transactions
,
error
)
{
p
.
lock
.
RLock
()
p
.
lock
.
RLock
()
defer
p
.
lock
.
RUnlock
()
defer
p
.
lock
.
RUnlock
()
...
...
eth/sync.go
浏览文件 @
7e915ee3
...
@@ -54,7 +54,7 @@ func (h *handler) syncTransactions(p *eth.Peer) {
...
@@ -54,7 +54,7 @@ func (h *handler) syncTransactions(p *eth.Peer) {
//
//
// TODO(karalabe): Figure out if we could get away with random order somehow
// TODO(karalabe): Figure out if we could get away with random order somehow
var
txs
types
.
Transactions
var
txs
types
.
Transactions
pending
,
_
:=
h
.
txpool
.
Pending
()
pending
,
_
:=
h
.
txpool
.
Pending
(
false
)
for
_
,
batch
:=
range
pending
{
for
_
,
batch
:=
range
pending
{
txs
=
append
(
txs
,
batch
...
)
txs
=
append
(
txs
,
batch
...
)
}
}
...
...
miner/worker.go
浏览文件 @
7e915ee3
...
@@ -963,7 +963,7 @@ func (w *worker) commitNewWork(interrupt *int32, noempty bool, timestamp int64)
...
@@ -963,7 +963,7 @@ func (w *worker) commitNewWork(interrupt *int32, noempty bool, timestamp int64)
}
}
// Fill the block with all available pending transactions.
// Fill the block with all available pending transactions.
pending
,
err
:=
w
.
eth
.
TxPool
()
.
Pending
()
pending
,
err
:=
w
.
eth
.
TxPool
()
.
Pending
(
true
)
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Error
(
"Failed to fetch pending transactions"
,
"err"
,
err
)
log
.
Error
(
"Failed to fetch pending transactions"
,
"err"
,
err
)
return
return
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录