Skip to content

Commit

Permalink
Testing
Browse files Browse the repository at this point in the history
  • Loading branch information
dimriou committed Jul 12, 2024
1 parent 1d6e223 commit 5489ba2
Show file tree
Hide file tree
Showing 7 changed files with 114 additions and 1 deletion.
1 change: 1 addition & 0 deletions core/chains/evm/client/chain_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ type Client interface {
SuggestGasPrice(ctx context.Context) (*big.Int, error)
SuggestGasTipCap(ctx context.Context) (*big.Int, error)
LatestBlockHeight(ctx context.Context) (*big.Int, error)
FeeHistory(ctx context.Context, blockCount uint64, rewardPercentiles []float64) (feeHistory *ethereum.FeeHistory, err error)

HeaderByNumber(ctx context.Context, n *big.Int) (*types.Header, error)
HeaderByHash(ctx context.Context, h common.Hash) (*types.Header, error)
Expand Down
30 changes: 30 additions & 0 deletions core/chains/evm/client/mocks/client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions core/chains/evm/client/null_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,3 +235,7 @@ func (nc *NullClient) LatestFinalizedBlock(_ context.Context) (*evmtypes.Head, e
func (nc *NullClient) CheckTxValidity(_ context.Context, _ common.Address, _ common.Address, _ []byte) *SendError {
return nil
}

func (nc *NullClient) FeeHistory(ctx context.Context, blockCount uint64, rewardPercentiles []float64) (feeHistory *ethereum.FeeHistory, err error) {
return nil, nil
}
4 changes: 4 additions & 0 deletions core/chains/evm/client/simulated_backend_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,10 @@ func (c *SimulatedBackendClient) LINKBalance(ctx context.Context, address common
panic("not implemented")
}

func (c *SimulatedBackendClient) FeeHistory(ctx context.Context, blockCount uint64, rewardPercentiles []float64) (feeHistory *ethereum.FeeHistory, err error) {
panic("not implemented")
}

// TransactionReceipt returns the transaction receipt for the given transaction hash.
func (c *SimulatedBackendClient) TransactionReceipt(ctx context.Context, receipt common.Hash) (*types.Receipt, error) {
return c.b.TransactionReceipt(ctx, receipt)
Expand Down
3 changes: 2 additions & 1 deletion core/chains/evm/config/toml/defaults/Polygon_Amoy.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ RPCDefaultBatchSize = 100
MaxQueued = 5000

[GasEstimator]
Mode = 'Universal'
EIP1559DynamicFees = true
PriceMax = '115792089237316195423570985008687907853269984665.640564039457584007913129639935 tether'
PriceMax = '600 gwei'
BumpMin = '20 gwei'
BumpThreshold = 5

Expand Down
60 changes: 60 additions & 0 deletions core/chains/evm/gas/mocks/fee_estimator_client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions core/chains/evm/gas/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"math/big"
"time"

"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/common"
Expand Down Expand Up @@ -49,6 +50,8 @@ type feeEstimatorClient interface {
CallContext(ctx context.Context, result interface{}, method string, args ...interface{}) error
ConfiguredChainID() *big.Int
HeadByNumber(ctx context.Context, n *big.Int) (*evmtypes.Head, error)
FeeHistory(ctx context.Context, blockCount uint64, rewardPercentiles []float64) (feeHistory *ethereum.FeeHistory, err error)
SuggestGasPrice(ctx context.Context) (*big.Int, error)
}

// NewEstimator returns the estimator for a given config
Expand Down Expand Up @@ -107,6 +110,16 @@ func NewEstimator(lggr logger.Logger, ethClient feeEstimatorClient, cfg Config,
newEstimator = func(l logger.Logger) EvmEstimator {
return NewSuggestedPriceEstimator(lggr, ethClient, geCfg, l1Oracle)
}
case "Universal":
newEstimator = func(l logger.Logger) EvmEstimator {
cfg := UniversalEstimatorConfig{
CacheTimeout: 4 * time.Second,
BumpPercent: geCfg.BumpPercent(),
BlockHistoryRange: 24,
RewardPercentile: 60,
}
return NewUniversalEstimator(lggr, ethClient, cfg, ethClient.ConfiguredChainID(), l1Oracle)
}
default:
lggr.Warnf("GasEstimator: unrecognised mode '%s', falling back to FixedPriceEstimator", s)
newEstimator = func(l logger.Logger) EvmEstimator {
Expand Down

0 comments on commit 5489ba2

Please sign in to comment.