Skip to content

Commit

Permalink
blockhistory config + allow disable bumping
Browse files Browse the repository at this point in the history
  • Loading branch information
aalu1418 committed May 28, 2024
1 parent cbe294d commit cc51a84
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 8 deletions.
9 changes: 8 additions & 1 deletion pkg/solana/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -49,6 +50,7 @@ type Config interface {
ComputeUnitPriceMin() uint64
ComputeUnitPriceDefault() uint64
FeeBumpPeriod() time.Duration
BlockHistoryPollPeriod() time.Duration
}

// opt: remove
Expand All @@ -69,6 +71,7 @@ type configSet struct {
ComputeUnitPriceMin uint64
ComputeUnitPriceDefault uint64
FeeBumpPeriod time.Duration
BlockHistoryPollPeriod time.Duration
}

type Chain struct {
Expand All @@ -87,6 +90,7 @@ type Chain struct {
ComputeUnitPriceMin *uint64
ComputeUnitPriceDefault *uint64
FeeBumpPeriod *config.Duration
BlockHistoryPollPeriod *config.Duration
}

func (c *Chain) SetDefaults() {
Expand Down Expand Up @@ -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 {
Expand Down
14 changes: 14 additions & 0 deletions pkg/solana/config/mocks/config.go

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

7 changes: 7 additions & 0 deletions pkg/solana/config/toml.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
}
Expand Down
6 changes: 1 addition & 5 deletions pkg/solana/fees/block_history.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -70,7 +66,7 @@ func (bhe *blockHistoryEstimator) run() {
}
}

tick = time.After(utils.WithJitter(feePolling))
tick = time.After(utils.WithJitter(bhe.cfg.BlockHistoryPollPeriod()))
}
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/solana/txm/txm.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit cc51a84

Please sign in to comment.