This repository was archived by the owner on Aug 19, 2025. It is now read-only.
forked from 0xPolygon/zkevm-node
-
Notifications
You must be signed in to change notification settings - Fork 230
Expand file tree
/
Copy pathsequencer_xlayer.go
More file actions
67 lines (57 loc) · 1.9 KB
/
sequencer_xlayer.go
File metadata and controls
67 lines (57 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package sequencer
import (
"context"
"math/big"
"time"
"github.com/0xPolygonHermez/zkevm-node/log"
"github.com/0xPolygonHermez/zkevm-node/pool"
pmetric "github.com/0xPolygonHermez/zkevm-node/sequencer/metrics"
"github.com/0xPolygonHermez/zkevm-node/state"
"github.com/ethereum/go-ethereum/common"
)
var countinterval = 10
func (s *Sequencer) countPendingTx() {
for {
<-time.After(time.Second * time.Duration(countinterval))
transactions, err := s.pool.CountPendingTransactions(context.Background())
if err != nil {
log.Errorf("load pending tx from pool: %v", err)
continue
}
pmetric.PendingTxCount(int(transactions))
}
}
func (s *Sequencer) updateReadyTxCount() {
err := s.pool.UpdateReadyTxCount(context.Background(), getPoolReadyTxCounter().getReadyTxCount())
if err != nil {
log.Errorf("error adding ready tx count: %v", err)
}
}
func (s *Sequencer) countReadyTx() {
state.InfiniteSafeRun(s.updateReadyTxCount, "error counting ready tx", time.Second)
}
func (s *Sequencer) checkFreeGas(tx pool.Transaction, txTracker *TxTracker) (freeGp, claimTx bool, gpMul float64) {
// check if tx is init-free-gas and if it can be prior pack
freeGp = tx.GasPrice().Cmp(big.NewInt(0)) == 0
gpMul = getInitGasPriceMultiple(s.cfg.InitGasPriceMultiple)
// check if tx is bridge-claim
addrs := getPackBatchSpacialList(s.cfg.PackBatchSpacialList)
if addrs[txTracker.FromStr] {
claimTx = true
gpMul = getGasPriceMultiple(s.cfg.GasPriceMultiple)
return
}
// check if tx is from special project
if pool.GetEnableSpecialFreeGasList(s.poolCfg.EnableFreeGasList) {
fromToName, freeGpList := pool.GetSpecialFreeGasList(s.poolCfg.FreeGasList)
info := freeGpList[fromToName[txTracker.FromStr]]
if info != nil &&
tx.To() != nil &&
pool.Contains(info.ToList, *tx.To()) &&
pool.ContainsMethod("0x"+common.Bytes2Hex(tx.Data()), info.MethodSigs) {
gpMul = info.GasPriceMultiple
return
}
}
return
}