Skip to content

Commit

Permalink
LogBroadcaster feature flag (#14354)
Browse files Browse the repository at this point in the history
* adding feature flag for LogBroadcaster, true by default

* fix test part 1

* fix test

* fix more test

* fix test

* fix test

* one more

* edit changeset

* update changeset
  • Loading branch information
huangzhen1997 authored Sep 9, 2024
1 parent cd8be70 commit bf6618d
Show file tree
Hide file tree
Showing 21 changed files with 129 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .changeset/kind-numbers-melt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
"chainlink": minor
---

Adding feature flag for `LogBroadcaster` called `LogBroadcasterEnabled`, which is `true` by default to support backwards compatibility.
Adding `LogBroadcasterEnabled` allows certain chains to completely disable the `LogBroadcaster` feature, which is an old feature (getting replaced by logPoller) that only few products are using it:
* OCR1 Median
* *OCR2 Median when ChainReader is disabled
* *pre-OCR2 Keeper
* Flux Monitor
* Direct RequestOCR1 Median

#added
4 changes: 4 additions & 0 deletions core/chains/evm/config/chain_scoped.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,10 @@ func (e *EVMConfig) OperatorFactoryAddress() string {
return e.C.OperatorFactoryAddress.String()
}

func (e *EVMConfig) LogBroadcasterEnabled() bool {
return e.C.LogBroadcasterEnabled == nil || *e.C.LogBroadcasterEnabled
}

func (e *EVMConfig) LogPrunePageSize() uint32 {
return *e.C.LogPrunePageSize
}
Expand Down
1 change: 1 addition & 0 deletions core/chains/evm/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ type EVM interface {
MinIncomingConfirmations() uint32
NonceAutoSync() bool
OperatorFactoryAddress() string
LogBroadcasterEnabled() bool
RPCDefaultBatchSize() uint32
NodeNoNewHeadsThreshold() time.Duration
FinalizedBlockOffset() uint32
Expand Down
19 changes: 19 additions & 0 deletions core/chains/evm/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,25 @@ func TestChainScopedConfig(t *testing.T) {
assert.Equal(t, val.String(), cfg3.EVM().OperatorFactoryAddress())
})
})

t.Run("LogBroadcasterEnabled", func(t *testing.T) {
t.Run("turn on LogBroadcasterEnabled by default", func(t *testing.T) {
assert.Equal(t, true, cfg.EVM().LogBroadcasterEnabled())
})

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

assert.Equal(t, false, cfg3.EVM().LogBroadcasterEnabled())
})

t.Run("use Noop logBroadcaster when LogBroadcaster is disabled", func(t *testing.T) {

})
})
}

func TestChainScopedConfig_BlockHistory(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions core/chains/evm/config/toml/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@ type Chain struct {
NonceAutoSync *bool
NoNewHeadsThreshold *commonconfig.Duration
OperatorFactoryAddress *types.EIP55Address
LogBroadcasterEnabled *bool
RPCDefaultBatchSize *uint32
RPCBlockQueryDelay *uint16
FinalizedBlockOffset *uint32
Expand Down
3 changes: 3 additions & 0 deletions core/chains/evm/config/toml/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,9 @@ func (c *Chain) SetFrom(f *Chain) {
if v := f.OperatorFactoryAddress; v != nil {
c.OperatorFactoryAddress = v
}
if v := f.LogBroadcasterEnabled; v != nil {
c.LogBroadcasterEnabled = v
}
if v := f.RPCDefaultBatchSize; v != nil {
c.RPCDefaultBatchSize = v
}
Expand Down
1 change: 1 addition & 0 deletions core/chains/evm/config/toml/defaults/fallback.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ RPCDefaultBatchSize = 250
RPCBlockQueryDelay = 1
FinalizedBlockOffset = 0
NoNewFinalizedHeadsThreshold = '0'
LogBroadcasterEnabled = true

[Transactions]
ForwardersEnabled = false
Expand Down
2 changes: 2 additions & 0 deletions core/chains/legacyevm/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,8 @@ func newChain(ctx context.Context, cfg *evmconfig.ChainScoped, nodes []*toml.Nod
var logBroadcaster log.Broadcaster
if !opts.AppConfig.EVMRPCEnabled() {
logBroadcaster = &log.NullBroadcaster{ErrMsg: fmt.Sprintf("Ethereum is disabled for chain %d", chainID)}
} else if !cfg.EVM().LogBroadcasterEnabled() {
logBroadcaster = &log.NullBroadcaster{ErrMsg: fmt.Sprintf("LogBroadcaster disabled for chain %d", chainID)}
} else if opts.GenLogBroadcaster == nil {
logORM := log.NewORM(opts.DS, *chainID)
logBroadcaster = log.NewBroadcaster(logORM, client, cfg.EVM(), l, highestSeenHead, opts.MailMon)
Expand Down
2 changes: 2 additions & 0 deletions core/config/docs/chains-evm.toml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ RPCBlockQueryDelay = 1 # Default
# Block 64 will be treated as finalized by CL Node only when chain's latest finalized block is 65. As chain finalizes blocks in batches of 32,
# CL Node has to wait for a whole new batch to be finalized to treat block 64 as finalized.
FinalizedBlockOffset = 0 # Default
# LogBroadcasterEnabled is a feature flag for LogBroadcaster, by default it's true.
LogBroadcasterEnabled = true # Default
# NoNewFinalizedHeadsThreshold controls how long to wait for new finalized block before `NodePool` marks rpc endpoints as
# out-of-sync. Only applicable if `FinalityTagEnabled=true`
#
Expand Down
2 changes: 2 additions & 0 deletions core/services/chainlink/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,7 @@ func TestConfig_Marshal(t *testing.T) {
NonceAutoSync: ptr(true),
NoNewHeadsThreshold: &minute,
OperatorFactoryAddress: mustAddress("0xa5B85635Be42F21f94F28034B7DA440EeFF0F418"),
LogBroadcasterEnabled: ptr(true),
RPCDefaultBatchSize: ptr[uint32](17),
RPCBlockQueryDelay: ptr[uint16](10),
NoNewFinalizedHeadsThreshold: &hour,
Expand Down Expand Up @@ -1027,6 +1028,7 @@ MinContractPayment = '9.223372036854775807 link'
NonceAutoSync = true
NoNewHeadsThreshold = '1m0s'
OperatorFactoryAddress = '0xa5B85635Be42F21f94F28034B7DA440EeFF0F418'
LogBroadcasterEnabled = true
RPCDefaultBatchSize = 17
RPCBlockQueryDelay = 10
FinalizedBlockOffset = 16
Expand Down
1 change: 1 addition & 0 deletions core/services/chainlink/testdata/config-full.toml
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ MinContractPayment = '9.223372036854775807 link'
NonceAutoSync = true
NoNewHeadsThreshold = '1m0s'
OperatorFactoryAddress = '0xa5B85635Be42F21f94F28034B7DA440EeFF0F418'
LogBroadcasterEnabled = true
RPCDefaultBatchSize = 17
RPCBlockQueryDelay = 10
FinalizedBlockOffset = 16
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ MinContractPayment = '0.1 link'
NonceAutoSync = true
NoNewHeadsThreshold = '3m0s'
OperatorFactoryAddress = '0x3E64Cd889482443324F91bFA9c84fE72A511f48A'
LogBroadcasterEnabled = true
RPCDefaultBatchSize = 250
RPCBlockQueryDelay = 1
FinalizedBlockOffset = 12
Expand Down Expand Up @@ -405,6 +406,7 @@ MinContractPayment = '0.1 link'
NonceAutoSync = true
NoNewHeadsThreshold = '3m0s'
OperatorFactoryAddress = '0x8007e24251b1D2Fc518Eb843A701d9cD21fe0aA3'
LogBroadcasterEnabled = true
RPCDefaultBatchSize = 250
RPCBlockQueryDelay = 1
FinalizedBlockOffset = 0
Expand Down Expand Up @@ -506,6 +508,7 @@ MinIncomingConfirmations = 5
MinContractPayment = '0.00001 link'
NonceAutoSync = true
NoNewHeadsThreshold = '30s'
LogBroadcasterEnabled = true
RPCDefaultBatchSize = 100
RPCBlockQueryDelay = 10
FinalizedBlockOffset = 0
Expand Down
1 change: 1 addition & 0 deletions core/web/resolver/testdata/config-full.toml
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ MinContractPayment = '9.223372036854775807 link'
NonceAutoSync = true
NoNewHeadsThreshold = '1m0s'
OperatorFactoryAddress = '0xa5B85635Be42F21f94F28034B7DA440EeFF0F418'
LogBroadcasterEnabled = true
RPCDefaultBatchSize = 17
RPCBlockQueryDelay = 10
FinalizedBlockOffset = 0
Expand Down
3 changes: 3 additions & 0 deletions core/web/resolver/testdata/config-multi-chain-effective.toml
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ MinContractPayment = '0.1 link'
NonceAutoSync = true
NoNewHeadsThreshold = '3m0s'
OperatorFactoryAddress = '0x3E64Cd889482443324F91bFA9c84fE72A511f48A'
LogBroadcasterEnabled = true
RPCDefaultBatchSize = 250
RPCBlockQueryDelay = 1
FinalizedBlockOffset = 0
Expand Down Expand Up @@ -405,6 +406,7 @@ MinContractPayment = '0.1 link'
NonceAutoSync = true
NoNewHeadsThreshold = '3m0s'
OperatorFactoryAddress = '0x8007e24251b1D2Fc518Eb843A701d9cD21fe0aA3'
LogBroadcasterEnabled = true
RPCDefaultBatchSize = 250
RPCBlockQueryDelay = 1
FinalizedBlockOffset = 0
Expand Down Expand Up @@ -506,6 +508,7 @@ MinIncomingConfirmations = 5
MinContractPayment = '0.00001 link'
NonceAutoSync = true
NoNewHeadsThreshold = '30s'
LogBroadcasterEnabled = true
RPCDefaultBatchSize = 100
RPCBlockQueryDelay = 10
FinalizedBlockOffset = 0
Expand Down
Loading

0 comments on commit bf6618d

Please sign in to comment.