Skip to content

Commit def7811

Browse files
committed
Fix fee per gas calculation.
1 parent e6bcaae commit def7811

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ import (
5656
)
5757

5858
// ReleaseVersion is the release version for the code.
59-
var ReleaseVersion = "0.4.7"
59+
var ReleaseVersion = "0.4.8"
6060

6161
func main() {
6262
os.Exit(main2())

services/blocks/batch/handler.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -303,11 +303,11 @@ func (s *Service) compileTransaction(ctx context.Context,
303303
maxPriorityFeePerGas := tx.MaxPriorityFeePerGas()
304304
dbTransaction.MaxPriorityFeePerGas = &maxPriorityFeePerGas
305305
// Calculate the gas price.
306-
feePerGas := maxPriorityFeePerGas
307-
if maxPriorityFeePerGas > maxFeePerGas-block.BaseFeePerGas() {
308-
feePerGas = maxFeePerGas - block.BaseFeePerGas()
306+
priorityFeePerGas := maxFeePerGas - block.BaseFeePerGas()
307+
if priorityFeePerGas > maxPriorityFeePerGas {
308+
priorityFeePerGas = maxPriorityFeePerGas
309309
}
310-
dbTransaction.GasPrice = feePerGas
310+
dbTransaction.GasPrice = block.BaseFeePerGas() + priorityFeePerGas
311311
}
312312

313313
return dbTransaction

services/blocks/individual/handler.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -250,11 +250,11 @@ func (s *Service) compileTransaction(ctx context.Context,
250250
maxPriorityFeePerGas := tx.MaxPriorityFeePerGas()
251251
dbTransaction.MaxPriorityFeePerGas = &maxPriorityFeePerGas
252252
// Calculate the gas price.
253-
feePerGas := maxPriorityFeePerGas
254-
if maxPriorityFeePerGas > maxFeePerGas-block.BaseFeePerGas() {
255-
feePerGas = maxFeePerGas - block.BaseFeePerGas()
253+
priorityFeePerGas := maxFeePerGas - block.BaseFeePerGas()
254+
if priorityFeePerGas > maxPriorityFeePerGas {
255+
priorityFeePerGas = maxPriorityFeePerGas
256256
}
257-
dbTransaction.GasPrice = feePerGas
257+
dbTransaction.GasPrice = block.BaseFeePerGas() + priorityFeePerGas
258258
}
259259

260260
return dbTransaction

0 commit comments

Comments
 (0)