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
7e915ee3
Unverified
Commit
7e915ee3
authored
3 years ago
by
Péter Szilágyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core, eth, miner: enforce configured mining reward post 1559 too
parent
3094e7f3
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
39 additions
and
12 deletions
+39
-12
tx_pool.go
core/tx_pool.go
+24
-5
tx_pool_test.go
core/tx_pool_test.go
+1
-1
transaction.go
core/types/transaction.go
+8
-0
api_backend.go
eth/api_backend.go
+1
-1
api.go
eth/catalyst/api.go
+1
-1
handler.go
eth/handler.go
+1
-1
handler_test.go
eth/handler_test.go
+1
-1
sync.go
eth/sync.go
+1
-1
worker.go
miner/worker.go
+1
-1
No files found.
core/tx_pool.go
View file @
7e915ee3
...
...
@@ -26,6 +26,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"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/types"
"github.com/ethereum/go-ethereum/event"
...
...
@@ -496,13 +497,30 @@ func (pool *TxPool) Content() (map[common.Address]types.Transactions, map[common
// Pending retrieves all currently processable transactions, grouped by origin
// account and sorted by nonce. The returned transaction set is a copy and can be
// 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
()
defer
pool
.
mu
.
Unlock
()
pending
:=
make
(
map
[
common
.
Address
]
types
.
Transactions
)
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
}
...
...
@@ -562,7 +580,7 @@ func (pool *TxPool) validateTx(tx *types.Transaction, local bool) error {
if
tx
.
Tip
()
.
BitLen
()
>
256
{
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
{
return
ErrTipAboveFeeCap
}
...
...
@@ -1114,8 +1132,9 @@ func (pool *TxPool) runReorg(done chan struct{}, reset *txpoolResetRequest, dirt
// because of another transaction (e.g. higher gas price).
if
reset
!=
nil
{
pool
.
demoteUnexecutables
()
if
reset
.
newHead
!=
nil
{
pool
.
priced
.
SetBaseFee
(
reset
.
newHead
.
BaseFee
)
if
reset
.
newHead
!=
nil
&&
pool
.
chainconfig
.
IsLondon
(
new
(
big
.
Int
)
.
Add
(
reset
.
newHead
.
Number
,
big
.
NewInt
(
1
)))
{
pendingBaseFee
:=
misc
.
CalcBaseFee
(
pool
.
chainconfig
,
reset
.
newHead
)
pool
.
priced
.
SetBaseFee
(
pendingBaseFee
)
}
}
// Ensure pool.queue and pool.pending sizes stay within the configured limits.
...
...
This diff is collapsed.
Click to expand it.
core/tx_pool_test.go
View file @
7e915ee3
...
...
@@ -252,7 +252,7 @@ func TestStateChangeDuringTransactionPoolReset(t *testing.T) {
trigger
=
true
<-
pool
.
requestReset
(
nil
,
nil
)
_
,
err
:=
pool
.
Pending
()
_
,
err
:=
pool
.
Pending
(
false
)
if
err
!=
nil
{
t
.
Fatalf
(
"Could not fetch pending transactions: %v"
,
err
)
}
...
...
This diff is collapsed.
Click to expand it.
core/types/transaction.go
View file @
7e915ee3
...
...
@@ -356,6 +356,14 @@ func (tx *Transaction) EffectiveTipCmp(other *Transaction, baseFee *big.Int) int
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.
func
(
tx
*
Transaction
)
Hash
()
common
.
Hash
{
if
hash
:=
tx
.
hash
.
Load
();
hash
!=
nil
{
...
...
This diff is collapsed.
Click to expand it.
eth/api_backend.go
View file @
7e915ee3
...
...
@@ -231,7 +231,7 @@ func (b *EthAPIBackend) SendTx(ctx context.Context, signedTx *types.Transaction)
}
func
(
b
*
EthAPIBackend
)
GetPoolTransactions
()
(
types
.
Transactions
,
error
)
{
pending
,
err
:=
b
.
eth
.
txPool
.
Pending
()
pending
,
err
:=
b
.
eth
.
txPool
.
Pending
(
false
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
This diff is collapsed.
Click to expand it.
eth/catalyst/api.go
View file @
7e915ee3
...
...
@@ -127,7 +127,7 @@ func (api *consensusAPI) AssembleBlock(params assembleBlockParams) (*executableD
time
.
Sleep
(
wait
)
}
pending
,
err
:=
pool
.
Pending
()
pending
,
err
:=
pool
.
Pending
(
true
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
This diff is collapsed.
Click to expand it.
eth/handler.go
View file @
7e915ee3
...
...
@@ -66,7 +66,7 @@ type txPool interface {
// Pending should return pending transactions.
// 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
// NewTxsEvent and send events to the given channel.
...
...
This diff is collapsed.
Click to expand it.
eth/handler_test.go
View file @
7e915ee3
...
...
@@ -91,7 +91,7 @@ func (p *testTxPool) AddRemotes(txs []*types.Transaction) []error {
}
// 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
()
defer
p
.
lock
.
RUnlock
()
...
...
This diff is collapsed.
Click to expand it.
eth/sync.go
View file @
7e915ee3
...
...
@@ -54,7 +54,7 @@ func (h *handler) syncTransactions(p *eth.Peer) {
//
// TODO(karalabe): Figure out if we could get away with random order somehow
var
txs
types
.
Transactions
pending
,
_
:=
h
.
txpool
.
Pending
()
pending
,
_
:=
h
.
txpool
.
Pending
(
false
)
for
_
,
batch
:=
range
pending
{
txs
=
append
(
txs
,
batch
...
)
}
...
...
This diff is collapsed.
Click to expand it.
miner/worker.go
View file @
7e915ee3
...
...
@@ -963,7 +963,7 @@ func (w *worker) commitNewWork(interrupt *int32, noempty bool, timestamp int64)
}
// Fill the block with all available pending transactions.
pending
,
err
:=
w
.
eth
.
TxPool
()
.
Pending
()
pending
,
err
:=
w
.
eth
.
TxPool
()
.
Pending
(
true
)
if
err
!=
nil
{
log
.
Error
(
"Failed to fetch pending transactions"
,
"err"
,
err
)
return
...
...
This diff is collapsed.
Click to expand it.
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