Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
8 changes: 8 additions & 0 deletions CONFIG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ FlagsContractAddress = '0xae4E781a6218A8031764928E88d457937A954fC3' # Example
LinkContractAddress = '0x538aAaB4ea120b2bC2fe5D296852D948F07D849e' # Example
LogBackfillBatchSize = 1000 # Default
LogPollInterval = '15s' # Default
LogPollerSkipEmptyBlocks = false # Default
LogKeepBlocksDepth = 100000 # Default
LogPrunePageSize = 0 # Default
BackupLogPollerBlockDelay = 100 # Default
Expand Down Expand Up @@ -172,6 +173,13 @@ LogPollInterval = '15s' # Default
```
LogPollInterval works in conjunction with Feature.LogPoller. Controls how frequently the log poller polls for logs. Defaults to the block production rate.

### LogPollerSkipEmptyBlocks
:warning: **_ADVANCED_**: _Do not change this setting unless you know what you are doing._
```toml
LogPollerSkipEmptyBlocks = false # Default
```
LogPollerSkipEmptyBlocks works in conjunction with Feature.LogPoller. Controls whether the log poller skips blocks with no logs. Setting this to true can reduce DB load, however it can affect product performance. Consult with specific Chainlink product team before changing this setting.

### LogKeepBlocksDepth
:warning: **_ADVANCED_**: _Do not change this setting unless you know what you are doing._
```toml
Expand Down
7 changes: 7 additions & 0 deletions pkg/.mockery.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,13 @@ packages:
github.com/smartcontractkit/chainlink-evm/pkg/logpoller:
interfaces:
LogPoller:
ORM:
config:
dir: "{{ .InterfaceDir }}"
outpkg: logpoller
filename: "mock_orm_test.go"
mockname: "MockORM"
inpackage: true
github.com/smartcontractkit/chainlink-evm/pkg/round:
interfaces:
RequestRoundDB:
Expand Down
1 change: 1 addition & 0 deletions pkg/chains/legacyevm/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ func newChain(cfg *config.ChainScoped, nodes []*toml.Node, opts ChainRelayOpts,
LogPrunePageSize: int64(cfg.EVM().LogPrunePageSize()),
BackupPollerBlockDelay: int64(cfg.EVM().BackupLogPollerBlockDelay()),
ClientErrors: cfg.EVM().NodePool().Errors(),
SkipEmptyBlocks: cfg.EVM().LogPollerSkipEmptyBlocks(),
}

lpORM, err := logpoller.NewObservedORM(chainID, opts.DS, l)
Expand Down
4 changes: 4 additions & 0 deletions pkg/config/chain_scoped.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ func (e *EVMConfig) LogPollInterval() time.Duration {
return e.C.LogPollInterval.Duration()
}

func (e *EVMConfig) LogPollerSkipEmptyBlocks() bool {
return *e.C.LogPollerSkipEmptyBlocks
}

func (e *EVMConfig) FinalityDepth() uint32 {
return *e.C.FinalityDepth
}
Expand Down
1 change: 1 addition & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ type EVM interface {
LogKeepBlocksDepth() uint32
BackupLogPollerBlockDelay() uint64
LogPollInterval() time.Duration
LogPollerSkipEmptyBlocks() bool
LogPrunePageSize() uint32
MinContractPayment() *commonassets.Link
MinIncomingConfirmations() uint32
Expand Down
45 changes: 45 additions & 0 deletions pkg/config/mocks/evm.go

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

1 change: 1 addition & 0 deletions pkg/config/toml/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,7 @@ type Chain struct {
LinkContractAddress *types.EIP55Address
LogBackfillBatchSize *uint32
LogPollInterval *commonconfig.Duration
LogPollerSkipEmptyBlocks *bool
LogKeepBlocksDepth *uint32
LogPrunePageSize *uint32
BackupLogPollerBlockDelay *uint64
Expand Down
1 change: 1 addition & 0 deletions pkg/config/toml/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ var fullConfig = EVMConfig{
LinkContractAddress: ptr(types.MustEIP55Address("0x538aAaB4ea120b2bC2fe5D296852D948F07D849e")),
LogBackfillBatchSize: ptr[uint32](17),
LogPollInterval: config.MustNewDuration(time.Minute),
LogPollerSkipEmptyBlocks: ptr(false),
LogKeepBlocksDepth: ptr[uint32](100000),
LogPrunePageSize: ptr[uint32](0),
BackupLogPollerBlockDelay: ptr[uint64](532),
Expand Down
3 changes: 3 additions & 0 deletions pkg/config/toml/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,9 @@ func (c *Chain) SetFrom(f *Chain) {
if v := f.LogPollInterval; v != nil {
c.LogPollInterval = v
}
if v := f.LogPollerSkipEmptyBlocks; v != nil {
c.LogPollerSkipEmptyBlocks = v
}
if v := f.LogKeepBlocksDepth; v != nil {
c.LogKeepBlocksDepth = v
}
Expand Down
1 change: 1 addition & 0 deletions pkg/config/toml/defaults/fallback.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ FinalityTagEnabled = false
SafeTagSupported = true
LogBackfillBatchSize = 1000
LogPollInterval = '15s'
LogPollerSkipEmptyBlocks = false
LogKeepBlocksDepth = 100000
LogPrunePageSize = 0
BackupLogPollerBlockDelay = 100
Expand Down
3 changes: 3 additions & 0 deletions pkg/config/toml/docs.toml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ LogBackfillBatchSize = 1000 # Default
# LogPollInterval works in conjunction with Feature.LogPoller. Controls how frequently the log poller polls for logs. Defaults to the block production rate.
LogPollInterval = '15s' # Default
# **ADVANCED**
# LogPollerSkipEmptyBlocks works in conjunction with Feature.LogPoller. Controls whether the log poller skips blocks with no logs. Setting this to true can reduce DB load, however it can affect product performance. Consult with specific Chainlink product team before changing this setting.
LogPollerSkipEmptyBlocks = false # Default
# **ADVANCED**
# LogKeepBlocksDepth works in conjunction with Feature.LogPoller. Controls how many blocks the poller will keep, must be greater than FinalityDepth+1.
LogKeepBlocksDepth = 100000 # Default
# **ADVANCED**
Expand Down
1 change: 1 addition & 0 deletions pkg/config/toml/testdata/config-full.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ FlagsContractAddress = '0xae4E781a6218A8031764928E88d457937A954fC3'
LinkContractAddress = '0x538aAaB4ea120b2bC2fe5D296852D948F07D849e'
LogBackfillBatchSize = 17
LogPollInterval = '1m0s'
LogPollerSkipEmptyBlocks = false
LogKeepBlocksDepth = 100000
LogPrunePageSize = 0
BackupLogPollerBlockDelay = 532
Expand Down
12 changes: 1 addition & 11 deletions pkg/logpoller/helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ func (th *TestHarness) AdjustTime(t *testing.T, d time.Duration) {
}

func (th *TestHarness) PollAndSaveLogs(ctx context.Context, currentBlockNumber int64) int64 {
th.LogPoller.PollAndSaveLogs(ctx, currentBlockNumber)
th.LogPoller.PollAndSaveLogs(ctx, currentBlockNumber, false)
latest, _ := th.LogPoller.LatestBlock(ctx)
return latest.BlockNumber + 1
}
Expand All @@ -176,16 +176,6 @@ func (th *TestHarness) assertDontHave(t *testing.T, start, end int) {
}
}

func (th *TestHarness) assertHaveCanonical(t *testing.T, start, end int) {
for i := start; i < end; i++ {
blk, err := th.ORM.SelectBlockByNumber(testutils.Context(t), int64(i))
require.NoError(t, err, "block %v", i)
chainBlk, err := th.Client.BlockByNumber(testutils.Context(t), big.NewInt(int64(i)))
require.NoError(t, err)
assert.Equal(t, chainBlk.Hash().Bytes(), blk.BlockHash.Bytes(), "block %v", i)
}
}

// Simulates an RPC failover event to an alternate rpc server. This can also be used to
// simulate switching back to the primary rpc after it recovers.
func (th *TestHarness) SetActiveClient(backend evmtypes.Backend, chainType chaintype.ChainType) {
Expand Down
Loading
Loading