File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change 43
43
errInvalidYParity = errors .New ("'yParity' field must be 0 or 1" )
44
44
errVYParityMismatch = errors .New ("'v' and 'yParity' fields do not match" )
45
45
errVYParityMissing = errors .New ("missing 'yParity' or 'v' field in transaction" )
46
+ ErrFeeCapTooLow = errors .New ("fee cap less than base fee" )
46
47
errEmptyTypedTx = errors .New ("empty typed transaction bytes" )
47
48
errNoSigner = errors .New ("missing signing methods" )
48
49
skipNonceDestinationAddress = map [common.Address ]bool {
@@ -320,6 +321,19 @@ func (tx *Transaction) From() *common.Address {
320
321
return & from
321
322
}
322
323
324
+ // EffectiveTip returns the effective miner tip for the given base fee.
325
+ // Returns error in case of a negative effective miner tip.
326
+ func (tx * Transaction ) EffectiveTip (baseFee * big.Int ) (* big.Int , error ) {
327
+ if baseFee == nil {
328
+ return tx .Tip (), nil
329
+ }
330
+ feeCap := tx .FeeCap ()
331
+ if feeCap .Cmp (baseFee ) == - 1 {
332
+ return nil , ErrFeeCapTooLow
333
+ }
334
+ return math .BigMin (tx .Tip (), feeCap .Sub (feeCap , baseFee )), nil
335
+ }
336
+
323
337
// RawSignatureValues returns the V, R, S signature values of the transaction.
324
338
// The return values should not be modified by the caller.
325
339
func (tx * Transaction ) RawSignatureValues () (v , r , s * big.Int ) {
Original file line number Diff line number Diff line change @@ -615,6 +615,9 @@ func (self *worker) commitNewWork() {
615
615
Extra : self .extra ,
616
616
Time : big .NewInt (tstamp ),
617
617
}
618
+ // Set baseFee if we are on an EIP-1559 chain
619
+ header .BaseFee = misc .CalcBaseFee (self .config , header )
620
+
618
621
// Only set the coinbase if we are mining (avoid spurious block rewards)
619
622
if atomic .LoadInt32 (& self .mining ) == 1 {
620
623
header .Coinbase = self .coinbase
You can’t perform that action at this time.
0 commit comments