File tree Expand file tree Collapse file tree
pkg/chain/ethereum/ethutil Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -104,17 +104,22 @@ func (mw MiningWaiter) ForceMining(
104104 return
105105 }
106106
107- // transaction not yet mined, add 20% to the previous gas price
107+ // transaction not yet mined, if the previous gas price was the maximum
108+ // one, we no longer resubmit
108109 gasPrice := transaction .GasPrice ()
110+ if gasPrice .Cmp (mw .maxGasPrice ) == 0 {
111+ logger .Infof ("reached the maximum allowed gas price; stopping resubmissions" )
112+ return
113+ }
114+
115+ // if we still have some margin, add 20% to the previous gas price
109116 twentyPercent := new (big.Int ).Div (gasPrice , big .NewInt (5 ))
110117 gasPrice = new (big.Int ).Add (gasPrice , twentyPercent )
111118
112- // transaction not yet mined but we reached the maximum allowed gas
113- // price; giving up, we need to wait for the last submitted TX to be
114- // mined
119+ // if we reached the maximum allowed gas price, submit one more time
120+ // with the maximum
115121 if gasPrice .Cmp (mw .maxGasPrice ) > 0 {
116- logger .Infof ("reached the maximum allowed gas price; stopping resubmissions" )
117- return
122+ gasPrice = mw .maxGasPrice
118123 }
119124
120125 // transaction not yet mined and we are still under the maximum allowed
Original file line number Diff line number Diff line change @@ -126,14 +126,13 @@ func TestForceMining_MaxAllowedPriceReached(t *testing.T) {
126126
127127 var resubmissionGasPrices []* big.Int
128128
129- expectedAttempts := 4
129+ expectedAttempts := 5
130130 expectedResubmissionGasPrices := []* big.Int {
131131 big .NewInt (24000000000 ), // + 20%
132132 big .NewInt (28800000000 ), // + 20%
133133 big .NewInt (34560000000 ), // + 20%
134134 big .NewInt (41472000000 ), // + 20%
135- // the next one would be 49766400000 but since maxGasPrice = 45 Gwei
136- // resubmissions should stop here
135+ big .NewInt (45000000000 ), // max allowed
137136 }
138137
139138 resubmitFn := func (gasPrice * big.Int ) (* types.Transaction , error ) {
You can’t perform that action at this time.
0 commit comments