diff --git a/pkg/solana/config/config.go b/pkg/solana/config/config.go index df5be635f..9d5cdc5a9 100644 --- a/pkg/solana/config/config.go +++ b/pkg/solana/config/config.go @@ -27,7 +27,8 @@ var defaultConfigSet = configSet{ ComputeUnitPriceMax: 1_000, ComputeUnitPriceMin: 0, ComputeUnitPriceDefault: 0, - FeeBumpPeriod: 3 * time.Second, + FeeBumpPeriod: 3 * time.Second, // set to 0 to disable fee bumping + BlockHistoryPollPeriod: 5 * time.Second, } //go:generate mockery --name Config --output ./mocks/ --case=underscore --filename config.go @@ -49,6 +50,7 @@ type Config interface { ComputeUnitPriceMin() uint64 ComputeUnitPriceDefault() uint64 FeeBumpPeriod() time.Duration + BlockHistoryPollPeriod() time.Duration } // opt: remove @@ -69,6 +71,7 @@ type configSet struct { ComputeUnitPriceMin uint64 ComputeUnitPriceDefault uint64 FeeBumpPeriod time.Duration + BlockHistoryPollPeriod time.Duration } type Chain struct { @@ -87,6 +90,7 @@ type Chain struct { ComputeUnitPriceMin *uint64 ComputeUnitPriceDefault *uint64 FeeBumpPeriod *config.Duration + BlockHistoryPollPeriod *config.Duration } func (c *Chain) SetDefaults() { @@ -136,6 +140,9 @@ func (c *Chain) SetDefaults() { if c.FeeBumpPeriod == nil { c.FeeBumpPeriod = config.MustNewDuration(defaultConfigSet.FeeBumpPeriod) } + if c.BlockHistoryPollPeriod == nil { + c.BlockHistoryPollPeriod = config.MustNewDuration(defaultConfigSet.BlockHistoryPollPeriod) + } } type Node struct { diff --git a/pkg/solana/config/mocks/config.go b/pkg/solana/config/mocks/config.go index f9f35c3a5..cf1c985a6 100644 --- a/pkg/solana/config/mocks/config.go +++ b/pkg/solana/config/mocks/config.go @@ -28,6 +28,20 @@ func (_m *Config) BalancePollPeriod() time.Duration { return r0 } +// BlockHistoryPollPeriod provides a mock function with given fields: +func (_m *Config) BlockHistoryPollPeriod() time.Duration { + ret := _m.Called() + + var r0 time.Duration + if rf, ok := ret.Get(0).(func() time.Duration); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(time.Duration) + } + + return r0 +} + // Commitment provides a mock function with given fields: func (_m *Config) Commitment() rpc.CommitmentType { ret := _m.Called() diff --git a/pkg/solana/config/toml.go b/pkg/solana/config/toml.go index 04cf0a08f..e5eb705e6 100644 --- a/pkg/solana/config/toml.go +++ b/pkg/solana/config/toml.go @@ -176,6 +176,9 @@ func setFromChain(c, f *Chain) { if f.FeeBumpPeriod != nil { c.FeeBumpPeriod = f.FeeBumpPeriod } + if f.BlockHistoryPollPeriod != nil { + c.BlockHistoryPollPeriod = f.BlockHistoryPollPeriod + } } func (c *TOMLConfig) ValidateConfig() (err error) { @@ -268,6 +271,10 @@ func (c *TOMLConfig) FeeBumpPeriod() time.Duration { return c.Chain.FeeBumpPeriod.Duration() } +func (c *TOMLConfig) BlockHistoryPollPeriod() time.Duration { + return c.Chain.BlockHistoryPollPeriod.Duration() +} + func (c *TOMLConfig) ListNodes() Nodes { return c.Nodes } diff --git a/pkg/solana/fees/block_history.go b/pkg/solana/fees/block_history.go index d10dd1a04..214612e90 100644 --- a/pkg/solana/fees/block_history.go +++ b/pkg/solana/fees/block_history.go @@ -15,10 +15,6 @@ import ( "github.com/smartcontractkit/chainlink-solana/pkg/solana/config" ) -var ( - feePolling = 5 * time.Second // TODO: make configurable -) - var _ Estimator = &blockHistoryEstimator{} type blockHistoryEstimator struct { @@ -70,7 +66,7 @@ func (bhe *blockHistoryEstimator) run() { } } - tick = time.After(utils.WithJitter(feePolling)) + tick = time.After(utils.WithJitter(bhe.cfg.BlockHistoryPollPeriod())) } } diff --git a/pkg/solana/txm/txm.go b/pkg/solana/txm/txm.go index e333f9bbd..6824cef7f 100644 --- a/pkg/solana/txm/txm.go +++ b/pkg/solana/txm/txm.go @@ -237,8 +237,8 @@ func (txm *Txm) sendWithRetry(chanCtx context.Context, baseTx solanaGo.Transacti return case <-tick: var shouldBump bool - // TODO: be able to enable / disable bumping - if time.Since(bumpTime) > txm.cfg.FeeBumpPeriod() { + // bump if period > 0 and past time + if txm.cfg.FeeBumpPeriod() != 0 && time.Since(bumpTime) > txm.cfg.FeeBumpPeriod() { bumpCount++ bumpTime = time.Now() shouldBump = true