Skip to content

Commit

Permalink
use copyed baseGp to update (okx#197)
Browse files Browse the repository at this point in the history
* use copyed baseGp

* init claimGp
giskook authored Apr 29, 2024
1 parent ea26c05 commit 0490418
Showing 3 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion sequencer/sequencer.go
Original file line number Diff line number Diff line change
@@ -231,7 +231,8 @@ func (s *Sequencer) addTxToWorker(ctx context.Context, tx pool.Transaction) erro
_, l2gp := s.pool.GetL1AndL2GasPrice()
defaultGp := new(big.Int).SetUint64(l2gp)
baseGp := s.worker.getBaseClaimGp(defaultGp)
txTracker.GasPrice = baseGp.Mul(baseGp, new(big.Int).SetUint64(uint64(getGasPriceMultiple(s.cfg.GasPriceMultiple))))
copyBaseGp := new(big.Int).Set(baseGp)
txTracker.GasPrice = copyBaseGp.Mul(copyBaseGp, new(big.Int).SetUint64(uint64(getGasPriceMultiple(s.cfg.GasPriceMultiple))))
}

replacedTx, dropReason := s.worker.AddTxTracker(ctx, txTracker)
3 changes: 2 additions & 1 deletion sequencer/txsorted_list.go
Original file line number Diff line number Diff line change
@@ -58,7 +58,8 @@ func (e *txSortedList) delete(tx *TxTracker) bool {

if (e.sorted[i].GasPrice.Cmp(tx.GasPrice)) != 0 {
// we have a tx with different (lower) GasPrice than the tx we are looking for, therefore we haven't found the tx
log.Warnf("error deleting tx %s from txSortedList, not found in the list of txs with same gasPrice: %s", tx.HashStr)
log.Warnf("error deleting tx %s from txSortedList %s, not found in the list of txs with same gasPrice: %s - %s",
tx.HashStr, e.sorted[i].HashStr, tx.GasPrice.String(), e.sorted[i].GasPrice.String())
return false
}

1 change: 1 addition & 0 deletions sequencer/worker.go
Original file line number Diff line number Diff line change
@@ -33,6 +33,7 @@ func NewWorker(state stateInterface, constraints state.BatchConstraintsCfg, read
state: state,
batchConstraints: constraints,
readyTxsCond: readyTxsCond,
claimGp: new(big.Int),
}

return &w

0 comments on commit 0490418

Please sign in to comment.