Skip to content

Commit

Permalink
Moved EVM.TransactionManagerEnabled config to EVM.Transactions.Enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
amit-momin committed Dec 19, 2024
1 parent 1d8500a commit 2e0a39a
Show file tree
Hide file tree
Showing 22 changed files with 118 additions and 117 deletions.
2 changes: 1 addition & 1 deletion .changeset/wild-cats-think.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
"chainlink": minor
---

Added the `TransactionManagerEnabled` config to enable or disable the transaction manager. #added
Added the `EVM.Transactions.Enabled` config to enable or disable the transaction manager. #added
4 changes: 0 additions & 4 deletions core/chains/evm/config/chain_scoped.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,3 @@ func (e *EVMConfig) FinalizedBlockOffset() uint32 {
func (e *EVMConfig) NoNewFinalizedHeadsThreshold() time.Duration {
return e.C.NoNewFinalizedHeadsThreshold.Duration()
}

func (e *EVMConfig) TransactionManagerEnabled() bool {
return *e.C.TransactionManagerEnabled
}
4 changes: 4 additions & 0 deletions core/chains/evm/config/chain_scoped_transactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ type transactionsConfig struct {
c toml.Transactions
}

func (t *transactionsConfig) Enabled() bool {
return *t.c.Enabled
}

func (t *transactionsConfig) ForwardersEnabled() bool {
return *t.c.ForwardersEnabled
}
Expand Down
2 changes: 1 addition & 1 deletion core/chains/evm/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ type EVM interface {
NodeNoNewHeadsThreshold() time.Duration
FinalizedBlockOffset() uint32
NoNewFinalizedHeadsThreshold() time.Duration
TransactionManagerEnabled() bool

IsEnabled() bool
TOMLString() (string, error)
Expand Down Expand Up @@ -104,6 +103,7 @@ type ClientErrors interface {
}

type Transactions interface {
Enabled() bool
ForwardersEnabled() bool
ReaperInterval() time.Duration
ResendAfterThreshold() time.Duration
Expand Down
12 changes: 6 additions & 6 deletions core/chains/evm/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,18 +221,18 @@ func TestChainScopedConfig(t *testing.T) {
})
})

t.Run("TransactionManagerEnabled", func(t *testing.T) {
t.Run("turn on TransactionManagerEnabled by default", func(t *testing.T) {
assert.True(t, cfg.EVM().TransactionManagerEnabled())
t.Run("EVM.Transactions.Enabled", func(t *testing.T) {
t.Run("turn on EVM.Transactions.Enabled by default", func(t *testing.T) {
assert.True(t, cfg.EVM().Transactions().Enabled())
})

t.Run("verify TransactionManagerEnabled is set correctly", func(t *testing.T) {
t.Run("verify EVM.Transactions.Enabled is set correctly", func(t *testing.T) {
val := false
cfg3 := testutils.NewTestChainScopedConfig(t, func(c *toml.EVMConfig) {
c.TransactionManagerEnabled = ptr(val)
c.Transactions.Enabled = ptr(val)
})

assert.False(t, cfg3.EVM().TransactionManagerEnabled())
assert.False(t, cfg3.EVM().Transactions().Enabled())
})
})
}
Expand Down
5 changes: 4 additions & 1 deletion core/chains/evm/config/toml/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,6 @@ type Chain struct {
RPCBlockQueryDelay *uint16
FinalizedBlockOffset *uint32
NoNewFinalizedHeadsThreshold *commonconfig.Duration
TransactionManagerEnabled *bool

Transactions Transactions `toml:",omitempty"`
BalanceMonitor BalanceMonitor `toml:",omitempty"`
Expand Down Expand Up @@ -473,6 +472,7 @@ func (c *Chain) ValidateConfig() (err error) {
}

type Transactions struct {
Enabled *bool
ForwardersEnabled *bool
MaxInFlight *uint32
MaxQueued *uint32
Expand All @@ -484,6 +484,9 @@ type Transactions struct {
}

func (t *Transactions) setFrom(f *Transactions) {
if v := f.Enabled; v != nil {
t.Enabled = v
}
if v := f.ForwardersEnabled; v != nil {
t.ForwardersEnabled = v
}
Expand Down
3 changes: 0 additions & 3 deletions core/chains/evm/config/toml/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,6 @@ func (c *Chain) SetFrom(f *Chain) {
if v := f.NoNewFinalizedHeadsThreshold; v != nil {
c.NoNewFinalizedHeadsThreshold = v
}
if v := f.TransactionManagerEnabled; v != nil {
c.TransactionManagerEnabled = v
}

c.Transactions.setFrom(&f.Transactions)
c.BalanceMonitor.setFrom(&f.BalanceMonitor)
Expand Down
2 changes: 1 addition & 1 deletion core/chains/evm/config/toml/defaults/fallback.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ RPCBlockQueryDelay = 1
FinalizedBlockOffset = 0
NoNewFinalizedHeadsThreshold = '0'
LogBroadcasterEnabled = true
TransactionManagerEnabled = true

[Transactions]
Enabled = true
ForwardersEnabled = false
MaxInFlight = 16
MaxQueued = 250
Expand Down
2 changes: 1 addition & 1 deletion core/chains/legacyevm/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ func newChain(ctx context.Context, cfg *evmconfig.ChainScoped, nodes []*toml.Nod
//nolint:gocritic // ignoring suggestion to convert to switch statement
if !opts.AppConfig.EVMRPCEnabled() {
txm = &txmgr.NullTxManager{ErrMsg: fmt.Sprintf("Ethereum is disabled for chain %d", chainID)}
} else if !cfg.EVM().TransactionManagerEnabled() {
} else if !cfg.EVM().Transactions().Enabled() {
txm = &txmgr.NullTxManager{ErrMsg: fmt.Sprintf("TXM disabled for chain %d", chainID)}
} else {
txm, err = newEvmTxm(opts.DS, cfg.EVM(), opts.AppConfig.Database(), opts.AppConfig.Database().Listener(), client, l, logPoller, opts, headTracker, gasEstimator)
Expand Down
4 changes: 2 additions & 2 deletions core/config/docs/chains-evm.toml
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ LogBroadcasterEnabled = true # Default
#
# Set to zero to disable.
NoNewFinalizedHeadsThreshold = '0' # Default
# TransactionManagerEnabled is a feature flag for the Transaction Manager. This flag also enables or disables the gas estimator since it is dependent on the TXM to start it.
TransactionManagerEnabled = true # Default

[EVM.Transactions]
# Enabled is a feature flag for the Transaction Manager. This flag also enables or disables the gas estimator since it is dependent on the TXM to start it.
Enabled = true # Default
# ForwardersEnabled enables or disables sending transactions through forwarder contracts.
ForwardersEnabled = false # Default
# MaxInFlight controls how many transactions are allowed to be "in-flight" i.e. broadcast but unconfirmed at any one time. You can consider this a form of transaction throttling.
Expand Down
4 changes: 2 additions & 2 deletions core/services/chainlink/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,6 @@ func TestConfig_Marshal(t *testing.T) {
FinalityTagEnabled: ptr[bool](true),
FlagsContractAddress: mustAddress("0xae4E781a6218A8031764928E88d457937A954fC3"),
FinalizedBlockOffset: ptr[uint32](16),
TransactionManagerEnabled: ptr(true),

GasEstimator: evmcfg.GasEstimator{
Mode: ptr("SuggestedPrice"),
Expand Down Expand Up @@ -655,6 +654,7 @@ func TestConfig_Marshal(t *testing.T) {
NoNewFinalizedHeadsThreshold: &hour,

Transactions: evmcfg.Transactions{
Enabled: ptr(true),
MaxInFlight: ptr[uint32](19),
MaxQueued: ptr[uint32](99),
ReaperInterval: &minute,
Expand Down Expand Up @@ -1117,9 +1117,9 @@ RPCDefaultBatchSize = 17
RPCBlockQueryDelay = 10
FinalizedBlockOffset = 16
NoNewFinalizedHeadsThreshold = '1h0m0s'
TransactionManagerEnabled = true
[EVM.Transactions]
Enabled = true
ForwardersEnabled = true
MaxInFlight = 19
MaxQueued = 99
Expand Down
2 changes: 1 addition & 1 deletion core/services/chainlink/testdata/config-full.toml
Original file line number Diff line number Diff line change
Expand Up @@ -335,9 +335,9 @@ RPCDefaultBatchSize = 17
RPCBlockQueryDelay = 10
FinalizedBlockOffset = 16
NoNewFinalizedHeadsThreshold = '1h0m0s'
TransactionManagerEnabled = true

[EVM.Transactions]
Enabled = true
ForwardersEnabled = true
MaxInFlight = 19
MaxQueued = 99
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,9 +318,9 @@ RPCDefaultBatchSize = 250
RPCBlockQueryDelay = 1
FinalizedBlockOffset = 12
NoNewFinalizedHeadsThreshold = '9m0s'
TransactionManagerEnabled = true

[EVM.Transactions]
Enabled = true
ForwardersEnabled = false
MaxInFlight = 16
MaxQueued = 250
Expand Down Expand Up @@ -429,9 +429,9 @@ RPCDefaultBatchSize = 250
RPCBlockQueryDelay = 1
FinalizedBlockOffset = 0
NoNewFinalizedHeadsThreshold = '0s'
TransactionManagerEnabled = true

[EVM.Transactions]
Enabled = true
ForwardersEnabled = false
MaxInFlight = 16
MaxQueued = 250
Expand Down Expand Up @@ -534,9 +534,9 @@ RPCDefaultBatchSize = 100
RPCBlockQueryDelay = 10
FinalizedBlockOffset = 0
NoNewFinalizedHeadsThreshold = '6m0s'
TransactionManagerEnabled = true

[EVM.Transactions]
Enabled = true
ForwardersEnabled = false
MaxInFlight = 16
MaxQueued = 5000
Expand Down
2 changes: 1 addition & 1 deletion core/web/resolver/testdata/config-full.toml
Original file line number Diff line number Diff line change
Expand Up @@ -335,9 +335,9 @@ RPCDefaultBatchSize = 17
RPCBlockQueryDelay = 10
FinalizedBlockOffset = 0
NoNewFinalizedHeadsThreshold = '15m0s'
TransactionManagerEnabled = true

[EVM.Transactions]
Enabled = true
ForwardersEnabled = true
MaxInFlight = 19
MaxQueued = 99
Expand Down
6 changes: 3 additions & 3 deletions core/web/resolver/testdata/config-multi-chain-effective.toml
Original file line number Diff line number Diff line change
Expand Up @@ -318,9 +318,9 @@ RPCDefaultBatchSize = 250
RPCBlockQueryDelay = 1
FinalizedBlockOffset = 0
NoNewFinalizedHeadsThreshold = '9m0s'
TransactionManagerEnabled = true

[EVM.Transactions]
Enabled = true
ForwardersEnabled = false
MaxInFlight = 16
MaxQueued = 250
Expand Down Expand Up @@ -429,9 +429,9 @@ RPCDefaultBatchSize = 250
RPCBlockQueryDelay = 1
FinalizedBlockOffset = 0
NoNewFinalizedHeadsThreshold = '0s'
TransactionManagerEnabled = true

[EVM.Transactions]
Enabled = true
ForwardersEnabled = false
MaxInFlight = 16
MaxQueued = 250
Expand Down Expand Up @@ -534,9 +534,9 @@ RPCDefaultBatchSize = 100
RPCBlockQueryDelay = 10
FinalizedBlockOffset = 0
NoNewFinalizedHeadsThreshold = '6m0s'
TransactionManagerEnabled = true

[EVM.Transactions]
Enabled = true
ForwardersEnabled = false
MaxInFlight = 16
MaxQueued = 5000
Expand Down
Loading

0 comments on commit 2e0a39a

Please sign in to comment.