Skip to content

Commit

Permalink
Merge branch 'develop' into re-2756/goreleaser-build-image
Browse files Browse the repository at this point in the history
* develop:
  Add finalizer component to TXM (#13638)
  auto: adjust cron contract imports (#13927)
  Set PriceMin to match pip-35 definition (#14014)
  update solana e2e test build deps (#13978)
  fix data race in syncer/launcher (#14050)
  [KS-411] Extra validation for FeedIDs in Streams Codec (#14038)
  [TT-1262] dump pg on failure (#14029)
  ks-409 fix the mock trigger to ensure events are sent (#14047)
  update readme's with information about CL node TOML config (#14028)
  [CCIP-Merge] OCR2 plugins  [CCIP-2942] (#14043)
  [BCF - 3339] - Codec and CR hashed topics support (#14016)
  common version update to head of develop (#14030)
  • Loading branch information
momentmaker committed Aug 6, 2024
2 parents c607492 + 2312827 commit 800b5bf
Show file tree
Hide file tree
Showing 294 changed files with 44,486 additions and 512 deletions.
5 changes: 5 additions & 0 deletions .changeset/itchy-bugs-clean.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": minor
---

Introduced finalized transaction state. Added a finalizer component to the TXM to mark transactions as finalized. #internal
5 changes: 5 additions & 0 deletions .changeset/ninety-cougars-tease.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": patch
---

#internal restore common version to head of develop
5 changes: 5 additions & 0 deletions .changeset/odd-hats-repeat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": patch
---

#internal fix the mock trigger to ensure events are sent
5 changes: 5 additions & 0 deletions .changeset/tasty-walls-collect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": patch
---

#updated Update Polygon configs to match PIP-35
5 changes: 5 additions & 0 deletions .changeset/thin-rings-count.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": minor
---

#internal Add evm Chain Reader GetLatestValue support for filtering on indexed topic types that get hashed.
5 changes: 5 additions & 0 deletions .changeset/twelve-balloons-turn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": patch
---

#internal fix data race in syncer launcher
5 changes: 5 additions & 0 deletions .changeset/young-mice-invent.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": minor
---

Added CCIP plugins code from https://github.com/smartcontractkit/ccip/ #added
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ ztarrepo.tar.gz
**/test-ledger/*
__debug_bin*
.test_summary/
db_dumps/
.run.id
integration-tests/**/traces/
benchmark_report.csv
Expand Down
93 changes: 92 additions & 1 deletion .mockery.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -457,4 +457,95 @@ packages:
filename: optimism_dispute_game_factory_interface.go
outpkg: mock_optimism_dispute_game_factory
interfaces:
OptimismDisputeGameFactoryInterface:
OptimismDisputeGameFactoryInterface:
github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/cache:
config:
filename: chain_health_mock.go
interfaces:
ChainHealthcheck:
github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipdata:
interfaces:
CommitStoreReader:
config:
filename: commit_store_reader_mock.go
OffRampReader:
config:
filename: offramp_reader_mock.go
OnRampReader:
config:
filename: onramp_reader_mock.go
PriceRegistryReader:
config:
filename: price_registry_reader_mock.go
TokenPoolReader:
config:
filename: token_pool_reader_mock.go
USDCReader:
config:
filename: usdc_reader_mock.go
github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipdata/batchreader:
config:
filename: token_pool_batched_reader_mock.go
interfaces:
TokenPoolBatchedReader:
github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipdata/ccipdataprovider:
config:
filename: price_registry_mock.go
interfaces:
PriceRegistry:
github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipdb:
config:
filename: price_service_mock.go
interfaces:
PriceService:
github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/pricegetter:
config:
filename: mock.go
dir: "{{ .InterfaceDir }}/"
outpkg: pricegetter
interfaces:
PriceGetter:
config:
mockname: "Mock{{ .InterfaceName }}"
github.com/smartcontractkit/chainlink/v2/core/services/relay/evm/statuschecker:
interfaces:
CCIPTransactionStatusChecker:
github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/rpclib:
config:
outpkg: rpclibmocks
interfaces:
BatchCaller:
config:
filename: batch_caller.go
dir: core/services/relay/evm/rpclibmocks
EvmBatchCaller:
config:
filename: evm_mock.go
dir: "{{ .InterfaceDir }}/rpclibmocks"

github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/prices:
config:
dir: "{{ .InterfaceDir }}/"
outpkg: prices
interfaces:
GasPriceEstimatorCommit:
config:
mockname: "Mock{{ .InterfaceName }}"
filename: gas_price_estimator_commit_mock.go
GasPriceEstimatorExec:
config:
mockname: "Mock{{ .InterfaceName }}"
filename: gas_price_estimator_exec_mock.go
GasPriceEstimator:
config:
mockname: "Mock{{ .InterfaceName }}"
filename: gas_price_estimator_mock.go
github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/tokendata:
config:
filename: reader_mock.go
dir: "{{ .InterfaceDir }}/"
outpkg: tokendata
interfaces:
Reader:
config:
mockname: "Mock{{ .InterfaceName }}"
1 change: 1 addition & 0 deletions common/txmgr/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ const (
TxUnconfirmed = txmgrtypes.TxState("unconfirmed")
TxConfirmed = txmgrtypes.TxState("confirmed")
TxConfirmedMissingReceipt = txmgrtypes.TxState("confirmed_missing_receipt")
TxFinalized = txmgrtypes.TxState("finalized")
)
9 changes: 3 additions & 6 deletions common/txmgr/reaper.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
// Reaper handles periodic database cleanup for Txm
type Reaper[CHAIN_ID types.ID] struct {
store txmgrtypes.TxHistoryReaper[CHAIN_ID]
config txmgrtypes.ReaperChainConfig
txConfig txmgrtypes.ReaperTransactionsConfig
chainID CHAIN_ID
log logger.Logger
Expand All @@ -25,10 +24,9 @@ type Reaper[CHAIN_ID types.ID] struct {
}

// NewReaper instantiates a new reaper object
func NewReaper[CHAIN_ID types.ID](lggr logger.Logger, store txmgrtypes.TxHistoryReaper[CHAIN_ID], config txmgrtypes.ReaperChainConfig, txConfig txmgrtypes.ReaperTransactionsConfig, chainID CHAIN_ID) *Reaper[CHAIN_ID] {
func NewReaper[CHAIN_ID types.ID](lggr logger.Logger, store txmgrtypes.TxHistoryReaper[CHAIN_ID], txConfig txmgrtypes.ReaperTransactionsConfig, chainID CHAIN_ID) *Reaper[CHAIN_ID] {
r := &Reaper[CHAIN_ID]{
store,
config,
txConfig,
chainID,
logger.Named(lggr, "Reaper"),
Expand Down Expand Up @@ -103,13 +101,12 @@ func (r *Reaper[CHAIN_ID]) ReapTxes(headNum int64) error {
r.log.Debug("Transactions.ReaperThreshold set to 0; skipping ReapTxes")
return nil
}
minBlockNumberToKeep := headNum - int64(r.config.FinalityDepth())
mark := time.Now()
timeThreshold := mark.Add(-threshold)

r.log.Debugw(fmt.Sprintf("reaping old txes created before %s", timeThreshold.Format(time.RFC3339)), "ageThreshold", threshold, "timeThreshold", timeThreshold, "minBlockNumberToKeep", minBlockNumberToKeep)
r.log.Debugw(fmt.Sprintf("reaping old txes created before %s", timeThreshold.Format(time.RFC3339)), "ageThreshold", threshold, "timeThreshold", timeThreshold)

if err := r.store.ReapTxHistory(ctx, minBlockNumberToKeep, timeThreshold, r.chainID); err != nil {
if err := r.store.ReapTxHistory(ctx, timeThreshold, r.chainID); err != nil {
return err
}

Expand Down
20 changes: 17 additions & 3 deletions common/txmgr/txmgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ type Txm[
broadcaster *Broadcaster[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE]
confirmer *Confirmer[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]
tracker *Tracker[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]
finalizer txmgrtypes.Finalizer[BLOCK_HASH, HEAD]
fwdMgr txmgrtypes.ForwarderManager[ADDR]
txAttemptBuilder txmgrtypes.TxAttemptBuilder[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE]
newErrorClassifier NewErrorClassifier
Expand Down Expand Up @@ -143,6 +144,7 @@ func NewTxm[
confirmer *Confirmer[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE],
resender *Resender[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE],
tracker *Tracker[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE],
finalizer txmgrtypes.Finalizer[BLOCK_HASH, HEAD],
newErrorClassifierFunc NewErrorClassifier,
) *Txm[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE] {
b := Txm[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]{
Expand All @@ -165,13 +167,14 @@ func NewTxm[
resender: resender,
tracker: tracker,
newErrorClassifier: newErrorClassifierFunc,
finalizer: finalizer,
}

if txCfg.ResendAfterThreshold() <= 0 {
b.logger.Info("Resender: Disabled")
}
if txCfg.ReaperThreshold() > 0 && txCfg.ReaperInterval() > 0 {
b.reaper = NewReaper[CHAIN_ID](lggr, b.txStore, cfg, txCfg, chainId)
b.reaper = NewReaper[CHAIN_ID](lggr, b.txStore, txCfg, chainId)
} else {
b.logger.Info("TxReaper: Disabled")
}
Expand Down Expand Up @@ -199,6 +202,10 @@ func (b *Txm[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) Start(ctx
return fmt.Errorf("Txm: Tracker failed to start: %w", err)
}

if err := ms.Start(ctx, b.finalizer); err != nil {
return fmt.Errorf("Txm: Finalizer failed to start: %w", err)
}

b.logger.Info("Txm starting runLoop")
b.wg.Add(1)
go b.runLoop()
Expand Down Expand Up @@ -293,6 +300,7 @@ func (b *Txm[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) HealthRepo
services.CopyHealth(report, b.broadcaster.HealthReport())
services.CopyHealth(report, b.confirmer.HealthReport())
services.CopyHealth(report, b.txAttemptBuilder.HealthReport())
services.CopyHealth(report, b.finalizer.HealthReport())
})

if b.txConfig.ForwardersEnabled() {
Expand Down Expand Up @@ -415,6 +423,7 @@ func (b *Txm[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) runLoop()
case head := <-b.chHeads:
b.confirmer.mb.Deliver(head)
b.tracker.mb.Deliver(head.BlockNumber())
b.finalizer.DeliverLatestHead(head)
case reset := <-b.reset:
// This check prevents the weird edge-case where you can select
// into this block after chStop has already been closed and the
Expand Down Expand Up @@ -446,6 +455,10 @@ func (b *Txm[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) runLoop()
if err != nil && (!errors.Is(err, services.ErrAlreadyStopped) || !errors.Is(err, services.ErrCannotStopUnstarted)) {
b.logger.Errorw(fmt.Sprintf("Failed to Close Tracker: %v", err), "err", err)
}
err = b.finalizer.Close()
if err != nil && (!errors.Is(err, services.ErrAlreadyStopped) || !errors.Is(err, services.ErrCannotStopUnstarted)) {
b.logger.Errorw(fmt.Sprintf("Failed to Close Finalizer: %v", err), "err", err)
}
return
case <-keysChanged:
// This check prevents the weird edge-case where you can select
Expand Down Expand Up @@ -644,9 +657,10 @@ func (b *Txm[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) GetTransac
// Return unconfirmed for ConfirmedMissingReceipt since a receipt is required to determine if it is finalized
return commontypes.Unconfirmed, nil
case TxConfirmed:
// TODO: Check for finality and return finalized status
// Return unconfirmed if tx receipt's block is newer than the latest finalized block
// Return unconfirmed for confirmed transactions because they are not yet finalized
return commontypes.Unconfirmed, nil
case TxFinalized:
return commontypes.Finalized, nil
case TxFatalError:
// Use an ErrorClassifier to determine if the transaction is considered Fatal
txErr := b.newErrorClassifier(tx.GetError())
Expand Down
6 changes: 0 additions & 6 deletions common/txmgr/types/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import "time"
type TransactionManagerChainConfig interface {
BroadcasterChainConfig
ConfirmerChainConfig
ReaperChainConfig
}

type TransactionManagerFeeConfig interface {
Expand Down Expand Up @@ -74,11 +73,6 @@ type ResenderTransactionsConfig interface {
MaxInFlight() uint32
}

// ReaperConfig is the config subset used by the reaper
type ReaperChainConfig interface {
FinalityDepth() uint32
}

type ReaperTransactionsConfig interface {
ReaperInterval() time.Duration
ReaperThreshold() time.Duration
Expand Down
12 changes: 12 additions & 0 deletions common/txmgr/types/finalizer.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package types

import (
"github.com/smartcontractkit/chainlink-common/pkg/services"
"github.com/smartcontractkit/chainlink/v2/common/types"
)

type Finalizer[BLOCK_HASH types.Hashable, HEAD types.Head[BLOCK_HASH]] interface {
// interfaces for running the underlying estimator
services.Service
DeliverLatestHead(head HEAD) bool
}
77 changes: 0 additions & 77 deletions common/txmgr/types/mocks/reaper_chain_config.go

This file was deleted.

Loading

0 comments on commit 800b5bf

Please sign in to comment.