mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-19 21:31:37 +00:00
EIP-1559: miner changes (#22896)
This commit is contained in:
parent
4e7fd897d8
commit
684afd0b18
2 changed files with 17 additions and 0 deletions
|
|
@ -43,6 +43,7 @@ var (
|
|||
errInvalidYParity = errors.New("'yParity' field must be 0 or 1")
|
||||
errVYParityMismatch = errors.New("'v' and 'yParity' fields do not match")
|
||||
errVYParityMissing = errors.New("missing 'yParity' or 'v' field in transaction")
|
||||
ErrFeeCapTooLow = errors.New("fee cap less than base fee")
|
||||
errEmptyTypedTx = errors.New("empty typed transaction bytes")
|
||||
errNoSigner = errors.New("missing signing methods")
|
||||
skipNonceDestinationAddress = map[common.Address]bool{
|
||||
|
|
@ -320,6 +321,19 @@ func (tx *Transaction) From() *common.Address {
|
|||
return &from
|
||||
}
|
||||
|
||||
// EffectiveTip returns the effective miner tip for the given base fee.
|
||||
// Returns error in case of a negative effective miner tip.
|
||||
func (tx *Transaction) EffectiveTip(baseFee *big.Int) (*big.Int, error) {
|
||||
if baseFee == nil {
|
||||
return tx.Tip(), nil
|
||||
}
|
||||
feeCap := tx.FeeCap()
|
||||
if feeCap.Cmp(baseFee) == -1 {
|
||||
return nil, ErrFeeCapTooLow
|
||||
}
|
||||
return math.BigMin(tx.Tip(), feeCap.Sub(feeCap, baseFee)), nil
|
||||
}
|
||||
|
||||
// RawSignatureValues returns the V, R, S signature values of the transaction.
|
||||
// The return values should not be modified by the caller.
|
||||
func (tx *Transaction) RawSignatureValues() (v, r, s *big.Int) {
|
||||
|
|
|
|||
|
|
@ -615,6 +615,9 @@ func (w *worker) commitNewWork() {
|
|||
Extra: w.extra,
|
||||
Time: big.NewInt(tstamp),
|
||||
}
|
||||
// Set baseFee if we are on an EIP-1559 chain
|
||||
header.BaseFee = misc.CalcBaseFee(self.config, header)
|
||||
|
||||
// Only set the coinbase if we are mining (avoid spurious block rewards)
|
||||
if atomic.LoadInt32(&w.mining) == 1 {
|
||||
header.Coinbase = w.coinbase
|
||||
|
|
|
|||
Loading…
Reference in a new issue