improve republish logic to only republish messages that can be included in the next 20 blocks
This commit is contained in:
parent
758aae8556
commit
0fcf8838cc
@ -16,7 +16,7 @@ import (
|
|||||||
|
|
||||||
const repubMsgLimit = 30
|
const repubMsgLimit = 30
|
||||||
|
|
||||||
var RepublishBatchDelay = 200 * time.Millisecond
|
var RepublishBatchDelay = 100 * time.Millisecond
|
||||||
|
|
||||||
func (mp *MessagePool) republishPendingMessages() error {
|
func (mp *MessagePool) republishPendingMessages() error {
|
||||||
mp.curTsLk.Lock()
|
mp.curTsLk.Lock()
|
||||||
@ -27,6 +27,7 @@ func (mp *MessagePool) republishPendingMessages() error {
|
|||||||
mp.curTsLk.Unlock()
|
mp.curTsLk.Unlock()
|
||||||
return xerrors.Errorf("computing basefee: %w", err)
|
return xerrors.Errorf("computing basefee: %w", err)
|
||||||
}
|
}
|
||||||
|
baseFeeLowerBound := types.BigDiv(baseFee, baseFeeLowerBoundFactor)
|
||||||
|
|
||||||
pending := make(map[address.Address]map[uint64]*types.SignedMessage)
|
pending := make(map[address.Address]map[uint64]*types.SignedMessage)
|
||||||
mp.lk.Lock()
|
mp.lk.Lock()
|
||||||
@ -70,6 +71,7 @@ func (mp *MessagePool) republishPendingMessages() error {
|
|||||||
gasLimit := int64(build.BlockGasLimit)
|
gasLimit := int64(build.BlockGasLimit)
|
||||||
minGas := int64(gasguess.MinGas)
|
minGas := int64(gasguess.MinGas)
|
||||||
var msgs []*types.SignedMessage
|
var msgs []*types.SignedMessage
|
||||||
|
loop:
|
||||||
for i := 0; i < len(chains); {
|
for i := 0; i < len(chains); {
|
||||||
chain := chains[i]
|
chain := chains[i]
|
||||||
|
|
||||||
@ -91,8 +93,18 @@ func (mp *MessagePool) republishPendingMessages() error {
|
|||||||
|
|
||||||
// does it fit in a block?
|
// does it fit in a block?
|
||||||
if chain.gasLimit <= gasLimit {
|
if chain.gasLimit <= gasLimit {
|
||||||
gasLimit -= chain.gasLimit
|
// check the baseFee lower bound -- only republish messages that can be included in the chain
|
||||||
msgs = append(msgs, chain.msgs...)
|
// within the next 20 blocks.
|
||||||
|
for _, m := range chain.msgs {
|
||||||
|
if m.Message.GasFeeCap.LessThan(baseFeeLowerBound) {
|
||||||
|
chain.Invalidate()
|
||||||
|
continue loop
|
||||||
|
}
|
||||||
|
gasLimit -= m.Message.GasLimit
|
||||||
|
msgs = append(msgs, m)
|
||||||
|
}
|
||||||
|
|
||||||
|
// we processed the whole chain, advance
|
||||||
i++
|
i++
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user