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 @@ -3,11 +3,12 @@ package ethutil
33import (
44 "context"
55 "fmt"
6+ "math/big"
7+
68 "github.com/ethereum/go-ethereum"
79 "github.com/ethereum/go-ethereum/common"
810 "github.com/ethereum/go-ethereum/core/types"
911 "github.com/keep-network/keep-common/pkg/rate"
10- "math/big"
1112)
1213
1314type rateLimiter struct {
@@ -96,6 +97,18 @@ func (rl *rateLimiter) SuggestGasPrice(
9697 return rl .EthereumClient .SuggestGasPrice (ctx )
9798}
9899
100+ func (rl * rateLimiter ) SuggestGasTipCap (
101+ ctx context.Context ,
102+ ) (* big.Int , error ) {
103+ err := rl .Limiter .AcquirePermit ()
104+ if err != nil {
105+ return nil , fmt .Errorf ("cannot acquire rate limiter permit: [%v]" , err )
106+ }
107+ defer rl .Limiter .ReleasePermit ()
108+
109+ return rl .EthereumClient .SuggestGasTipCap (ctx )
110+ }
111+
99112func (rl * rateLimiter ) EstimateGas (
100113 ctx context.Context ,
101114 call ethereum.CallMsg ,
Original file line number Diff line number Diff line change @@ -2,15 +2,16 @@ package ethutil
22
33import (
44 "context"
5- "github.com/ethereum/go-ethereum"
6- "github.com/ethereum/go-ethereum/common"
7- "github.com/ethereum/go-ethereum/core/types"
8- "github.com/keep-network/keep-common/pkg/rate"
95 "math/big"
106 "strings"
117 "sync"
128 "testing"
139 "time"
10+
11+ "github.com/ethereum/go-ethereum"
12+ "github.com/ethereum/go-ethereum/common"
13+ "github.com/ethereum/go-ethereum/core/types"
14+ "github.com/keep-network/keep-common/pkg/rate"
1415)
1516
1617func TestRateLimiter (t * testing.T ) {
@@ -365,6 +366,13 @@ func (mec *mockEthereumClient) SuggestGasPrice(
365366 return nil , nil
366367}
367368
369+ func (mec * mockEthereumClient ) SuggestGasTipCap (
370+ ctx context.Context ,
371+ ) (* big.Int , error ) {
372+ mec .mockRequest ()
373+ return nil , nil
374+ }
375+
368376func (mec * mockEthereumClient ) EstimateGas (
369377 ctx context.Context ,
370378 call ethereum.CallMsg ,
@@ -530,6 +538,14 @@ func getTests(
530538 return err
531539 },
532540 },
541+ "test SuggestGasTipCap" : {
542+ function : func () error {
543+ _ , err := client .SuggestGasTipCap (
544+ context .Background (),
545+ )
546+ return err
547+ },
548+ },
533549 "test EstimateGas" : {
534550 function : func () error {
535551 _ , err := client .EstimateGas (
You can’t perform that action at this time.
0 commit comments