Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move KeySpecific field #9694

Merged
merged 7 commits into from
Jul 10, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion core/chains/evm/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ type EVM interface {
ChainType() config.ChainType
FinalityDepth() uint32
FlagsContractAddress() string
KeySpecificMaxGasPriceWei(addr gethcommon.Address) *assets.Wei
LinkContractAddress() string
LogBackfillBatchSize() uint32
LogKeepBlocksDepth() uint32
Expand Down Expand Up @@ -74,6 +73,7 @@ type Transactions interface {
MaxQueued() uint64
}

//go:generate mockery --quiet --name GasEstimator --output ./mocks/ --case=underscore
type GasEstimator interface {
BlockHistory() BlockHistory
LimitJobType() LimitJobType
Expand All @@ -94,6 +94,7 @@ type GasEstimator interface {
PriceMax() *assets.Wei
PriceMin() *assets.Wei
Mode() string
KeySpecificMaxPrice(gethcommon.Address) *assets.Wei
}

type LimitJobType interface {
Expand Down
18 changes: 9 additions & 9 deletions core/chains/evm/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func TestChainScopedConfig(t *testing.T) {
})
})

t.Run("KeySpecificMaxGasPriceWei", func(t *testing.T) {
t.Run("KeySpecificMaxPrice", func(t *testing.T) {
addr := testutils.NewAddress()
randomOtherAddr := testutils.NewAddress()
gcfg2 := configtest.NewGeneralConfig(t, func(c *chainlink.Config, s *chainlink.Secrets) {
Expand All @@ -97,7 +97,7 @@ func TestChainScopedConfig(t *testing.T) {
cfg2 := evmtest.NewChainScopedConfig(t, gcfg2)

t.Run("uses chain-specific default value when nothing is set", func(t *testing.T) {
assert.Equal(t, assets.NewWeiI(100000000000000), cfg2.EVM().KeySpecificMaxGasPriceWei(addr))
assert.Equal(t, assets.NewWeiI(100000000000000), cfg2.EVM().GasEstimator().KeySpecificMaxPrice(addr))
})

t.Run("uses chain-specific override value when that is set", func(t *testing.T) {
Expand All @@ -107,7 +107,7 @@ func TestChainScopedConfig(t *testing.T) {
})
cfg3 := evmtest.NewChainScopedConfig(t, gcfg3)

assert.Equal(t, val.String(), cfg3.EVM().KeySpecificMaxGasPriceWei(addr).String())
assert.Equal(t, val.String(), cfg3.EVM().GasEstimator().KeySpecificMaxPrice(addr).String())
})
t.Run("uses key-specific override value when set", func(t *testing.T) {
val := assets.GWei(250)
Expand All @@ -122,7 +122,7 @@ func TestChainScopedConfig(t *testing.T) {
})
cfg3 := evmtest.NewChainScopedConfig(t, gcfg3)

assert.Equal(t, val.String(), cfg3.EVM().KeySpecificMaxGasPriceWei(addr).String())
assert.Equal(t, val.String(), cfg3.EVM().GasEstimator().KeySpecificMaxPrice(addr).String())
})
t.Run("uses key-specific override value when set and lower than chain specific config", func(t *testing.T) {
keySpecificPrice := assets.GWei(900)
Expand All @@ -139,7 +139,7 @@ func TestChainScopedConfig(t *testing.T) {
})
cfg3 := evmtest.NewChainScopedConfig(t, gcfg3)

assert.Equal(t, keySpecificPrice.String(), cfg3.EVM().KeySpecificMaxGasPriceWei(addr).String())
assert.Equal(t, keySpecificPrice.String(), cfg3.EVM().GasEstimator().KeySpecificMaxPrice(addr).String())
})
t.Run("uses chain-specific value when higher than key-specific value", func(t *testing.T) {
keySpecificPrice := assets.GWei(1400)
Expand All @@ -156,7 +156,7 @@ func TestChainScopedConfig(t *testing.T) {
})
cfg3 := evmtest.NewChainScopedConfig(t, gcfg3)

assert.Equal(t, chainSpecificPrice.String(), cfg3.EVM().KeySpecificMaxGasPriceWei(addr).String())
assert.Equal(t, chainSpecificPrice.String(), cfg3.EVM().GasEstimator().KeySpecificMaxPrice(addr).String())
})
t.Run("uses key-specific override value when set and lower than global config", func(t *testing.T) {
keySpecificPrice := assets.GWei(900)
Expand All @@ -171,7 +171,7 @@ func TestChainScopedConfig(t *testing.T) {
})
cfg3 := evmtest.NewChainScopedConfig(t, gcfg3)

assert.Equal(t, keySpecificPrice.String(), cfg3.EVM().KeySpecificMaxGasPriceWei(addr).String())
assert.Equal(t, keySpecificPrice.String(), cfg3.EVM().GasEstimator().KeySpecificMaxPrice(addr).String())
})
t.Run("uses global value when higher than key-specific value", func(t *testing.T) {
keySpecificPrice := assets.GWei(1400)
Expand All @@ -188,7 +188,7 @@ func TestChainScopedConfig(t *testing.T) {
})
cfg3 := evmtest.NewChainScopedConfig(t, gcfg3)

assert.Equal(t, chainSpecificPrice.String(), cfg3.EVM().KeySpecificMaxGasPriceWei(addr).String())
assert.Equal(t, chainSpecificPrice.String(), cfg3.EVM().GasEstimator().KeySpecificMaxPrice(addr).String())
})
t.Run("uses global value when there is no key-specific price", func(t *testing.T) {
val := assets.NewWeiI(rand.Int63())
Expand All @@ -198,7 +198,7 @@ func TestChainScopedConfig(t *testing.T) {
})
cfg3 := evmtest.NewChainScopedConfig(t, gcfg3)

assert.Equal(t, val.String(), cfg3.EVM().KeySpecificMaxGasPriceWei(unsetAddr).String())
assert.Equal(t, val.String(), cfg3.EVM().GasEstimator().KeySpecificMaxPrice(unsetAddr).String())
})
})

Expand Down
Loading
Loading