Skip to content
This repository has been archived by the owner on Jul 13, 2022. It is now read-only.

Commit

Permalink
Use max gas price from config for TX sending when BaseFee is above ma…
Browse files Browse the repository at this point in the history
…xGasPrice (#698)

* change maxFeePerGas to use config.maxGasPrice rather than current base fee

* updated test

* test constants fix
  • Loading branch information
vezenovm committed Aug 20, 2021
1 parent 8b1b0e0 commit 95fc717
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion connections/ethereum/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ func (c *Connection) EstimateGasLondon(ctx context.Context, baseFee *big.Int) (*

if c.maxGasPrice.Cmp(baseFee) < 0 {
maxPriorityFeePerGas = big.NewInt(1)
maxFeePerGas = new(big.Int).Add(baseFee, maxPriorityFeePerGas)
maxFeePerGas = new(big.Int).Add(c.maxGasPrice, maxPriorityFeePerGas)
return maxPriorityFeePerGas, maxFeePerGas, nil
}

Expand Down
8 changes: 4 additions & 4 deletions connections/ethereum/connection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func TestConnection_SafeEstimateGasMax(t *testing.T) {

func TestConnection_EstimateGasLondon(t *testing.T) {
// Set TestEndpoint to Goerli endpoint when testing as the current Github CI doesn't use the London version of geth
// Goerli commonly has a base fee of 7 gwei with maxPriorityFeePerGas of 4.999999993 gwei
// Goerli commonly has a base fee of 7 wei with maxPriorityFeePerGas of 4.999999993 gwei
maxGasPrice := big.NewInt(100000000000)
conn := NewConnection(TestEndpoint, false, AliceKp, log15.Root(), GasLimit, maxGasPrice, GasMultipler, "", "")
err := conn.Connect()
Expand Down Expand Up @@ -129,7 +129,7 @@ func TestConnection_EstimateGasLondon(t *testing.T) {

func TestConnection_EstimateGasLondonMax(t *testing.T) {
// Set TestEndpoint to Goerli endpoint when testing as the current Github CI doesn't use the London version of geth
// Goerli commonly has a base fee of 7 gwei with maxPriorityFeePerGas of 4.999999993 gwei
// Goerli commonly has a base fee of 7 wei with maxPriorityFeePerGas of 4.999999993 gwei
maxGasPrice := big.NewInt(100)
conn := NewConnection(TestEndpoint, false, AliceKp, log15.Root(), GasLimit, maxGasPrice, GasMultipler, "", "")
err := conn.Connect()
Expand Down Expand Up @@ -164,7 +164,7 @@ func TestConnection_EstimateGasLondonMax(t *testing.T) {

func TestConnection_EstimateGasLondonMin(t *testing.T) {
// Set TestEndpoint to Goerli endpoint when testing as the current Github CI doesn't use the London version of geth
// Goerli commonly has a base fee of 7 gwei with maxPriorityFeePerGas of 4.999999993 gwei
// Goerli commonly has a base fee of 7 wei with maxPriorityFeePerGas of 4.999999993 gwei
maxGasPrice := big.NewInt(1)
conn := NewConnection(TestEndpoint, false, AliceKp, log15.Root(), GasLimit, maxGasPrice, GasMultipler, "", "")
err := conn.Connect()
Expand All @@ -186,7 +186,7 @@ func TestConnection_EstimateGasLondonMin(t *testing.T) {
}

maxPriorityFeePerGas := big.NewInt(1)
maxFeePerGas := new(big.Int).Add(head.BaseFee, maxPriorityFeePerGas)
maxFeePerGas := new(big.Int).Add(maxGasPrice, maxPriorityFeePerGas)

if suggestedGasTip.Cmp(maxPriorityFeePerGas) != 0 {
t.Fatalf("Gas tip cap should be equal to 1. Suggested: %s Max Tip: %s", suggestedGasTip.String(), maxPriorityFeePerGas)
Expand Down

0 comments on commit 95fc717

Please sign in to comment.