Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BCI-3989][core] - CR methods err when service unstarted #14123

Closed
wants to merge 80 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
111057c
add isStarted check
Farber98 Aug 14, 2024
6f8ed23
move start outside getChainReader
Farber98 Aug 14, 2024
0074a33
bump common version
Farber98 Aug 14, 2024
2132bf0
Squashed commit of the following:
Farber98 Aug 14, 2024
53adad8
Revert "Squashed commit of the following:"
Farber98 Aug 15, 2024
bf588c7
Merge branch 'develop' into BCI-3989-cr-methods-error-when-unstarted
Farber98 Aug 15, 2024
2cce774
bump common version
Farber98 Aug 15, 2024
e8b366e
fix ccip failing integration tests
Farber98 Aug 15, 2024
7fa91e6
Revert "fix ccip failing integration tests"
Farber98 Aug 15, 2024
ed83615
remove check from bind
Farber98 Aug 15, 2024
fa2d416
bump common version
Farber98 Aug 15, 2024
4b2e503
fix chain reader tests
Farber98 Aug 15, 2024
7184150
StartChainReader method
Farber98 Aug 15, 2024
1e41db4
bump common version
Farber98 Aug 15, 2024
add59d8
start chain reader inside registry syncer
Farber98 Aug 15, 2024
db99f56
Revert "start chain reader inside registry syncer"
Farber98 Aug 15, 2024
7fde790
make error more clear for logging
Farber98 Aug 15, 2024
83c2559
starting cr service in write capability
Farber98 Aug 15, 2024
52e3313
starting contractReader inside registrySyncer
Farber98 Aug 15, 2024
b0c3305
idempotency if already started or already closed
Farber98 Aug 15, 2024
46d0c84
start reader in ccip delegate
Farber98 Aug 15, 2024
deb2d30
create var for err
Farber98 Aug 16, 2024
8a7054d
bump common version
Farber98 Aug 16, 2024
2aa2ee3
close chain reader after tests
Farber98 Aug 16, 2024
c63bcc6
bump common version
Farber98 Aug 16, 2024
733e0e0
Merge branch 'develop' into BCI-3989-cr-methods-error-when-unstarted
Farber98 Aug 22, 2024
894835e
bump common version
Farber98 Aug 22, 2024
d7153ac
add changeset
Farber98 Aug 22, 2024
be1d2c8
use state machine instead of flag
Farber98 Aug 22, 2024
46d7e32
Merge branch 'develop' into BCI-3989-cr-methods-error-when-unstarted
Farber98 Aug 22, 2024
4ea601d
use state machine ready method
Farber98 Aug 22, 2024
19a0268
idempotent start and close
Farber98 Aug 22, 2024
a0344e4
rename methods + bump common version
Farber98 Aug 23, 2024
5f45f15
Merge branch 'develop' into BCI-3989-cr-methods-error-when-unstarted
Farber98 Aug 23, 2024
482bb8b
Merge branch 'develop' into BCI-3989-cr-methods-error-when-unstarted
Farber98 Aug 23, 2024
5c93499
bump common version
Farber98 Aug 23, 2024
0e8f75f
bump common
Farber98 Aug 23, 2024
2eb9b0d
use state machine helpers to check if started inside methods
Farber98 Aug 24, 2024
6381bcd
Merge branch 'develop' into BCI-3989-cr-methods-error-when-unstarted
Farber98 Aug 24, 2024
f8d149d
bump common version
Farber98 Aug 24, 2024
160ea54
fix conflict
Farber98 Aug 24, 2024
0272eec
fix conflict
Farber98 Aug 24, 2024
d945744
Merge branch 'develop' into BCI-3989-cr-methods-error-when-unstarted
Farber98 Aug 26, 2024
017380c
remove start and close state check
Farber98 Aug 26, 2024
7448064
separate instantiation from starting svc in syncer tests
Farber98 Aug 26, 2024
6fc175f
remove Start and return svc started from getChainReader
Farber98 Aug 26, 2024
2a236da
bump common
Farber98 Aug 26, 2024
e42f6dd
Merge branch 'develop' into BCI-3989-cr-methods-error-when-unstarted
Farber98 Aug 28, 2024
3bff641
bump deps
Farber98 Aug 28, 2024
917add2
Merge branch 'develop' into BCI-3989-cr-methods-error-when-unstarted
Farber98 Aug 28, 2024
732f4c0
Merge branch 'develop' into BCI-3989-cr-methods-error-when-unstarted
Farber98 Aug 28, 2024
ca2124d
bump common
Farber98 Aug 28, 2024
19ac700
Merge branch 'develop' into BCI-3989-cr-methods-error-when-unstarted
Farber98 Aug 28, 2024
f13379f
Merge branch 'develop' into BCI-3989-cr-methods-error-when-unstarted
Farber98 Aug 29, 2024
ec4dcbd
Merge branch 'develop' into BCI-3989-cr-methods-error-when-unstarted
Farber98 Aug 30, 2024
3684bde
bump common
Farber98 Aug 30, 2024
eaa8149
fix tidy & generate ci
Farber98 Aug 30, 2024
e06b1d1
fix go.md error
Farber98 Aug 30, 2024
d6e2d43
Merge branch 'develop' into BCI-3989-cr-methods-error-when-unstarted
ilija42 Sep 2, 2024
cadbc0f
Merge branch 'develop' into BCI-3989-cr-methods-error-when-unstarted
Farber98 Sep 3, 2024
2715354
bump common
Farber98 Sep 3, 2024
9b8be2f
Merge branch 'develop' into BCI-3989-cr-methods-error-when-unstarted
Farber98 Sep 4, 2024
8ddc56c
add start. add start and close where needed
Farber98 Sep 4, 2024
8095ff8
bump common
Farber98 Sep 4, 2024
872fd3c
Merge branch 'develop' into BCI-3989-cr-methods-error-when-unstarted
Farber98 Sep 4, 2024
00044c6
bump common
Farber98 Sep 4, 2024
e1792e9
merge develop
Farber98 Sep 5, 2024
76ed985
merge develop
Farber98 Sep 5, 2024
218f3cd
merge develop
Farber98 Sep 5, 2024
d8e1c2b
fix conflicts with chain components pr
Farber98 Sep 5, 2024
37c892c
Merge branch 'develop' into BCI-3989-cr-methods-error-when-unstarted
Farber98 Sep 12, 2024
3fcbbf6
fix conflicts pr
Farber98 Sep 12, 2024
56b0f5f
bump common
Farber98 Sep 12, 2024
e569a69
add flag to control if we return cr started
Farber98 Sep 15, 2024
36e4489
bump common
Farber98 Sep 15, 2024
c83a850
Merge branch 'develop' into BCI-3989-cr-methods-error-when-unstarted
Farber98 Sep 15, 2024
40d2cc1
bump common
Farber98 Sep 16, 2024
e96d20c
refactor codec and chaincomponents ifaces
Farber98 Sep 16, 2024
07c8f01
Merge branch 'develop' into BCI-3989-cr-methods-error-when-unstarted
Farber98 Sep 16, 2024
b22ad6b
bump common
Farber98 Sep 16, 2024
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
5 changes: 5 additions & 0 deletions .changeset/rotten-timers-remain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": minor
---

chainReader methods return err when called and service is not started yet. #internal
5 changes: 5 additions & 0 deletions core/capabilities/ccip/delegate.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,11 @@ func (d *Delegate) getHomeChainContractReader(
return nil, types.BoundContract{}, fmt.Errorf("failed to create home chain contract reader: %w", err)
}

err = reader.Start(ctx)
if err != nil {
return nil, types.BoundContract{}, err
}

reader, ccipConfigBinding, err := bindReader(ctx, reader, d.capabilityConfig.ExternalRegistry().Address(), capabilityLabelledName, capabilityVersion)
if err != nil {
return nil, types.BoundContract{}, fmt.Errorf("failed to bind home chain contract reader: %w", err)
Expand Down
2 changes: 1 addition & 1 deletion core/scripts/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
github.com/prometheus/client_golang v1.20.0
github.com/shopspring/decimal v1.4.0
github.com/smartcontractkit/chainlink-automation v1.0.4
github.com/smartcontractkit/chainlink-common v0.2.2-0.20240913161926-ce5d667907ce
github.com/smartcontractkit/chainlink-common v0.2.2-0.20240916214706-e7280848cd7b

Check failure on line 25 in core/scripts/go.mod

View workflow job for this annotation

GitHub Actions / Validate go.mod dependencies

[./core/scripts/go.mod] dependency github.com/smartcontractkit/[email protected] not on default branch (main). Version(commit): e7280848cd7b Tree: https://github.com/smartcontractkit/chainlink-common/tree/e7280848cd7b Commit: https://github.com/smartcontractkit/chainlink-common/commit/e7280848cd7b
github.com/smartcontractkit/chainlink/v2 v2.0.0-00010101000000-000000000000
github.com/smartcontractkit/libocr v0.0.0-20240717100443-f6226e09bee7
github.com/spf13/cobra v1.8.1
Expand Down
4 changes: 2 additions & 2 deletions core/scripts/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1083,8 +1083,8 @@ github.com/smartcontractkit/chainlink-automation v1.0.4 h1:iyW181JjKHLNMnDleI8um
github.com/smartcontractkit/chainlink-automation v1.0.4/go.mod h1:u4NbPZKJ5XiayfKHD/v3z3iflQWqvtdhj13jVZXj/cM=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20240916150615-85b8aa5fa7e6 h1:cbHlV2CSphQ+ghDye21M8ym0aAO/Y649H2Mg60M2AuE=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20240916150615-85b8aa5fa7e6/go.mod h1:Lv77O13ZxOdmlvnu2vaUC0Lg+t3JAL+N+9K8dRsgmDI=
github.com/smartcontractkit/chainlink-common v0.2.2-0.20240913161926-ce5d667907ce h1:qXS0aWiDFDoLRCB+kSGnzp77iYT2luflUyzE5BnNmpY=
github.com/smartcontractkit/chainlink-common v0.2.2-0.20240913161926-ce5d667907ce/go.mod h1:sjiiPwd4KsYOCf68MwL86EKphdXeT66EY7j53WH5DCc=
github.com/smartcontractkit/chainlink-common v0.2.2-0.20240916214706-e7280848cd7b h1:7RyN8+dNTN+hjnKfgfEYdRfxqeHTnPq8ILcHn/gOe6k=
github.com/smartcontractkit/chainlink-common v0.2.2-0.20240916214706-e7280848cd7b/go.mod h1:sjiiPwd4KsYOCf68MwL86EKphdXeT66EY7j53WH5DCc=
github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240911175228-daf2600bb7b7 h1:lTGIOQYLk1Ufn++X/AvZnt6VOcuhste5yp+C157No/Q=
github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240911175228-daf2600bb7b7/go.mod h1:BMYE1vC/pGmdFSsOJdPrAA0/4gZ0Xo0SxTMdGspBtRo=
github.com/smartcontractkit/chainlink-data-streams v0.0.0-20240906125718-9f0a98d32fbc h1:tRmTlaoAt+7FakMXXgeCuRPmzzBo5jsGpeCVvcU6KMc=
Expand Down
5 changes: 5 additions & 0 deletions core/services/registrysyncer/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,11 @@ func (s *registrySyncer) Sync(ctx context.Context, isInitialSync bool) error {
return err
}

err = reader.Start(ctx)
if err != nil {
return err
}
Comment on lines +280 to +283
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't it be started in func (s *registrySyncer) Start(ctx context.Context) error {

Copy link
Contributor Author

@Farber98 Farber98 Aug 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

func (s *registrySyncer) Start(ctx context.Context) error calls func (s *registrySyncer) syncLoop() that calls func (s *registrySyncer) Sync(ctx context.Context, isInitialSync bool) error which initializes the CR.

I added these lines to start the CR service right after this initialization

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it better to have the initialization here, rather than in (*registrySyncer).Start? Isn't that just contributing to this problem in the first place?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean by this problem?

There's a note in the newReader func that says why this is achieved this way:

// NOTE: this can't be called while initializing the syncer and needs to be called in the sync loop.
// This is because Bind() makes an onchain call to verify that the contract address exists, and if
// called during initialization, this results in a "no live nodes" error.

Copy link
Contributor Author

@Farber98 Farber98 Aug 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added these lines as we are now enforcing CR service to be in Started state before calling the methods. This syncer was not starting the service previously and that's why we got some tests failing but now they are passing with this change

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean by this problem?

If all dependencies are Started before anything that uses them, then there is no need to be defensive about checking internally if Start has been called. But I see that there is a good reason to defer in this case.


s.reader = reader
}

Expand Down
2 changes: 1 addition & 1 deletion core/services/registrysyncer/syncer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func (c *crFactory) NewContractReader(ctx context.Context, cfg []byte) (types.Co
return nil, err
}

return svc, svc.Start(ctx)
return svc, nil
}

func newContractReaderFactory(t *testing.T, simulatedBackend *backends.SimulatedBackend) *crFactory {
Expand Down
44 changes: 32 additions & 12 deletions core/services/relay/evm/chain_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,17 +163,30 @@ func (cr *chainReader) HealthReport() map[string]error {
return map[string]error{cr.Name(): nil}
}

func (cr *chainReader) GetLatestValue(ctx context.Context, readName string, confidenceLevel primitives.ConfidenceLevel, params any, returnVal any) error {
binding, address, err := cr.bindings.GetReader(readName)
if err != nil {
return err
func (cr *chainReader) GetLatestValue(ctx context.Context, readName string, confidenceLevel primitives.ConfidenceLevel, params any, returnVal any) (err error) {
if ok := cr.StateMachine.IfStarted(func() {
binding, address, bindingErr := cr.bindings.GetReader(readName)
if bindingErr != nil {
err = bindingErr
return
}

err = binding.GetLatestValue(ctx, common.HexToAddress(address), confidenceLevel, params, returnVal)
}); !ok {
return fmt.Errorf("ContractReader should be in Started state before calling GetLatestValue. Current state: %s", cr.StateMachine.State())
}

return binding.GetLatestValue(ctx, common.HexToAddress(address), confidenceLevel, params, returnVal)
return err
}

func (cr *chainReader) BatchGetLatestValues(ctx context.Context, request commontypes.BatchGetLatestValuesRequest) (commontypes.BatchGetLatestValuesResult, error) {
return cr.bindings.BatchGetLatestValues(ctx, request)
func (cr *chainReader) BatchGetLatestValues(ctx context.Context, request commontypes.BatchGetLatestValuesRequest) (res commontypes.BatchGetLatestValuesResult, err error) {
if ok := cr.StateMachine.IfStarted(func() {
res, err = cr.bindings.BatchGetLatestValues(ctx, request)
}); !ok {
return nil, fmt.Errorf("ContractReader should be in Started state before calling BatchGetLatestValues. Current state: %s", cr.StateMachine.State())
}

return res, err
}

func (cr *chainReader) Bind(ctx context.Context, bindings []commontypes.BoundContract) error {
Expand All @@ -190,13 +203,20 @@ func (cr *chainReader) QueryKey(
filter query.KeyFilter,
limitAndSort query.LimitAndSort,
sequenceDataType any,
) ([]commontypes.Sequence, error) {
binding, address, err := cr.bindings.GetReader(contract.ReadIdentifier(filter.Key))
if err != nil {
return nil, err
) (seq []commontypes.Sequence, err error) {
if ok := cr.StateMachine.IfStarted(func() {
binding, address, bindingErr := cr.bindings.GetReader(contract.ReadIdentifier(filter.Key))
if bindingErr != nil {
seq, err = nil, bindingErr
return
}

seq, err = binding.QueryKey(ctx, common.HexToAddress(address), filter, limitAndSort, sequenceDataType)
}); !ok {
return nil, fmt.Errorf("ContractReader should be in Started state before calling QueryKey. Current state: %s", cr.StateMachine.State())
}

return binding.QueryKey(ctx, common.HexToAddress(address), filter, limitAndSort, sequenceDataType)
return seq, err
}

func (cr *chainReader) CreateContractType(readIdentifier string, forEncoding bool) (any, error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,36 +75,58 @@ type EVMChainComponentsInterfaceTester[T TestingT[T]] struct {
gasEstimator gas.EvmFeeEstimator
}

func (it *EVMChainComponentsInterfaceTester[T]) Setup(t T) {
func (it *EVMChainComponentsInterfaceTester[T]) Setup(t T, startCR bool) {
it.setChainReader(t, startCR)
// cw always will return started
it.setChainWriter(t)
it.deployNewContracts(t)
}

func (it *EVMChainComponentsInterfaceTester[T]) setChainReader(t T, started bool) {
t.Cleanup(func() {
// DB may be closed by the test already, ignore errors
if it.cr != nil {
if started {
_ = it.cr.Close()
}
it.cr = nil
})

if it.dirtyContracts {
it.contractTesters = nil
}
it.setChainReaderConfig(t)

if it.cw != nil {
_ = it.cw.Close()
}
it.cw = nil
})
ctx := it.Helper.Context(t)

// can re-use the same chain for tests, just make new contract for each test
if it.client != nil {
it.deployNewContracts(t)
return
lggr := logger.NullLogger
db := it.Helper.NewSqlxDB(t)
lpOpts := logpoller.Opts{
PollPeriod: time.Millisecond,
FinalityDepth: finalityDepth,
BackfillBatchSize: 1,
RpcBatchSize: 1,
KeepFinalizedBlocksDepth: 10000,
}
ht := headtracker.NewSimulatedHeadTracker(it.Helper.Client(t), lpOpts.UseFinalityTag, lpOpts.FinalityDepth)
lp := logpoller.NewLogPoller(logpoller.NewORM(it.Helper.ChainID(), db, lggr), it.Helper.Client(t), lggr, ht, lpOpts)
require.NoError(t, lp.Start(ctx))

// Need to separate accounts to ensure the nonce doesn't get misaligned after the
// contract deployments.
accounts := it.Helper.Accounts(t)
it.deployerAuth = accounts[0]
it.senderAuth = accounts[1]
// encode and decode the config to ensure the test covers type issues
confBytes, err := json.Marshal(it.chainReaderConfig)
require.NoError(t, err)

conf, err := types.ChainReaderConfigFromBytes(confBytes)
require.NoError(t, err)

it.client = it.Helper.ChainReaderEVMClient(ctx, t, ht, conf)
cr, err := evm.NewChainReaderService(ctx, lggr, lp, ht, it.client, conf)
require.NoError(t, err)

if started {
require.NoError(t, cr.Start(ctx))
}

it.cr = cr
}

func (it *EVMChainComponentsInterfaceTester[T]) setChainReaderConfig(_ T) {
testStruct := CreateTestStruct[T](0, it)

methodTakingLatestParamsReturningTestStructConfig := types.ChainReaderDefinition{
Expand Down Expand Up @@ -204,9 +226,41 @@ func (it *EVMChainComponentsInterfaceTester[T]) Setup(t T) {
},
},
}
it.GetContractReader(t)
}

func (it *EVMChainComponentsInterfaceTester[T]) GetContractReader(t T) clcommontypes.ContractReader {
return it.cr
}

func (it *EVMChainComponentsInterfaceTester[T]) setChainWriter(t T) {
t.Cleanup(func() {
// DB may be closed by the test already, ignore errors
_ = it.cw.Close()
it.cw = nil
})

it.setAccounts(t)
it.txm = it.Helper.TXM(t, it.client)
it.setChainWriterConfig(t)

ctx := it.Helper.Context(t)

cw, err := evm.NewChainWriterService(logger.NullLogger, it.client, it.txm, it.gasEstimator, it.chainWriterConfig)
require.NoError(t, err)
require.NoError(t, cw.Start(ctx))

it.cw = it.Helper.WrappedChainWriter(cw, it.client)
}

func (it *EVMChainComponentsInterfaceTester[T]) setAccounts(t T) {
// Need to separate accounts to ensure the nonce doesn't get misaligned after the
// contract deployments.
accounts := it.Helper.Accounts(t)
it.deployerAuth = accounts[0]
it.senderAuth = accounts[1]
}

func (it *EVMChainComponentsInterfaceTester[T]) setChainWriterConfig(t T) {
it.chainWriterConfig = types.ChainWriterConfig{
Contracts: map[string]*types.ContractConfig{
AnyContractName: {
Expand Down Expand Up @@ -273,7 +327,10 @@ func (it *EVMChainComponentsInterfaceTester[T]) Setup(t T) {
},
MaxGasPrice: assets.NewWei(big.NewInt(1000000000000000000)),
}
it.deployNewContracts(t)
}

func (it *EVMChainComponentsInterfaceTester[T]) GetChainWriter(t T) clcommontypes.ChainWriter {
return it.cw
}

func (it *EVMChainComponentsInterfaceTester[T]) Name() string {
Expand All @@ -287,61 +344,10 @@ func (it *EVMChainComponentsInterfaceTester[T]) GetAccountBytes(i int) []byte {
return account[:]
}

func (it *EVMChainComponentsInterfaceTester[T]) GetContractReader(t T) clcommontypes.ContractReader {
ctx := it.Helper.Context(t)
if it.cr != nil {
return it.cr
}

lggr := logger.NullLogger
db := it.Helper.NewSqlxDB(t)
lpOpts := logpoller.Opts{
PollPeriod: time.Millisecond,
FinalityDepth: finalityDepth,
BackfillBatchSize: 1,
RpcBatchSize: 1,
KeepFinalizedBlocksDepth: 10000,
}
ht := headtracker.NewSimulatedHeadTracker(it.Helper.Client(t), lpOpts.UseFinalityTag, lpOpts.FinalityDepth)
lp := logpoller.NewLogPoller(logpoller.NewORM(it.Helper.ChainID(), db, lggr), it.Helper.Client(t), lggr, ht, lpOpts)
require.NoError(t, lp.Start(ctx))

// encode and decode the config to ensure the test covers type issues
confBytes, err := json.Marshal(it.chainReaderConfig)
require.NoError(t, err)

conf, err := types.ChainReaderConfigFromBytes(confBytes)
require.NoError(t, err)

cwh := it.Helper.ChainReaderEVMClient(ctx, t, ht, conf)
it.client = cwh

cr, err := evm.NewChainReaderService(ctx, lggr, lp, ht, it.client, conf)
require.NoError(t, err)
require.NoError(t, cr.Start(ctx))
it.cr = cr
return cr
}

// This function is no longer necessary for Simulated Backend or Testnet tests.
func (it *EVMChainComponentsInterfaceTester[T]) GenerateBlocksTillConfidenceLevel(t T, contractName, readName string, confidenceLevel primitives.ConfidenceLevel) {
}

func (it *EVMChainComponentsInterfaceTester[T]) GetChainWriter(t T) clcommontypes.ChainWriter {
ctx := it.Helper.Context(t)
if it.cw != nil {
return it.cw
}

cw, err := evm.NewChainWriterService(logger.NullLogger, it.client, it.txm, it.gasEstimator, it.chainWriterConfig)
require.NoError(t, err)
it.cw = it.Helper.WrappedChainWriter(cw, it.client)

require.NoError(t, err)
require.NoError(t, cw.Start(ctx))
return it.cw
}

func (it *EVMChainComponentsInterfaceTester[T]) GetBindings(_ T) []clcommontypes.BoundContract {
return []clcommontypes.BoundContract{
{Name: AnyContractName, Address: it.address},
Expand Down Expand Up @@ -378,6 +384,12 @@ func (it *EVMChainComponentsInterfaceTester[T]) AwaitTx(t T, tx *gethtypes.Trans
}

func (it *EVMChainComponentsInterfaceTester[T]) deployNewContracts(t T) {
t.Cleanup(func() {
if it.dirtyContracts {
it.contractTesters = nil
}
})

// First test deploy both contracts, otherwise only deploy contracts if cleanup decides that we need to.
if it.address == "" || it.contractTesters == nil {
it.contractTesters = make(map[string]*chain_reader_tester.ChainReaderTester, 2)
Expand Down
8 changes: 4 additions & 4 deletions core/services/relay/evm/evmtesting/run_tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func RunContractReaderEvmTests[T TestingT[T]](t T, it *EVMChainComponentsInterfa
RunContractReaderInterfaceTests[T](t, it, false)

t.Run("Dynamically typed topics can be used to filter and have type correct in return", func(t T) {
it.Setup(t)
it.Setup(t, true)

anyString := "foo"
ctx := it.Helper.Context(t)
Expand Down Expand Up @@ -64,7 +64,7 @@ func RunContractReaderEvmTests[T TestingT[T]](t T, it *EVMChainComponentsInterfa
})

t.Run("Multiple topics can filter together", func(t T) {
it.Setup(t)
it.Setup(t, true)
ctx := it.Helper.Context(t)
cr := it.GetContractReader(t)
bindings := it.GetBindings(t)
Expand Down Expand Up @@ -95,7 +95,7 @@ func RunContractReaderEvmTests[T TestingT[T]](t T, it *EVMChainComponentsInterfa
})

t.Run("Filtering can be done on indexed topics that get hashed", func(t T) {
it.Setup(t)
it.Setup(t, true)

cr := it.GetContractReader(t)
ctx := it.Helper.Context(t)
Expand Down Expand Up @@ -130,7 +130,7 @@ func RunContractReaderEvmTests[T TestingT[T]](t T, it *EVMChainComponentsInterfa
})

t.Run("Bind returns error on missing contract at address", func(t T) {
it.Setup(t)
it.Setup(t, false)

addr := common.BigToAddress(big.NewInt(42))
reader := it.GetContractReader(t)
Expand Down
5 changes: 5 additions & 0 deletions core/services/relay/evm/write_target.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ func NewWriteTarget(ctx context.Context, relayer *Relayer, chain legacyevm.Chain
return nil, err
}

err = cr.Start(ctx)
if err != nil {
return nil, err
}

chainWriterConfig := relayevmtypes.ChainWriterConfig{
Contracts: map[string]*relayevmtypes.ContractConfig{
"forwarder": {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
github.com/smartcontractkit/chain-selectors v1.0.23
github.com/smartcontractkit/chainlink-automation v1.0.4
github.com/smartcontractkit/chainlink-ccip v0.0.0-20240916150615-85b8aa5fa7e6
github.com/smartcontractkit/chainlink-common v0.2.2-0.20240913161926-ce5d667907ce
github.com/smartcontractkit/chainlink-common v0.2.2-0.20240916214706-e7280848cd7b

Check failure on line 78 in go.mod

View workflow job for this annotation

GitHub Actions / Validate go.mod dependencies

[./go.mod] dependency github.com/smartcontractkit/[email protected] not on default branch (main). Version(commit): e7280848cd7b Tree: https://github.com/smartcontractkit/chainlink-common/tree/e7280848cd7b Commit: https://github.com/smartcontractkit/chainlink-common/commit/e7280848cd7b
github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240911175228-daf2600bb7b7
github.com/smartcontractkit/chainlink-data-streams v0.0.0-20240906125718-9f0a98d32fbc
github.com/smartcontractkit/chainlink-feeds v0.0.0-20240910155501-42f20443189f
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1044,8 +1044,8 @@ github.com/smartcontractkit/chainlink-automation v1.0.4 h1:iyW181JjKHLNMnDleI8um
github.com/smartcontractkit/chainlink-automation v1.0.4/go.mod h1:u4NbPZKJ5XiayfKHD/v3z3iflQWqvtdhj13jVZXj/cM=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20240916150615-85b8aa5fa7e6 h1:cbHlV2CSphQ+ghDye21M8ym0aAO/Y649H2Mg60M2AuE=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20240916150615-85b8aa5fa7e6/go.mod h1:Lv77O13ZxOdmlvnu2vaUC0Lg+t3JAL+N+9K8dRsgmDI=
github.com/smartcontractkit/chainlink-common v0.2.2-0.20240913161926-ce5d667907ce h1:qXS0aWiDFDoLRCB+kSGnzp77iYT2luflUyzE5BnNmpY=
github.com/smartcontractkit/chainlink-common v0.2.2-0.20240913161926-ce5d667907ce/go.mod h1:sjiiPwd4KsYOCf68MwL86EKphdXeT66EY7j53WH5DCc=
github.com/smartcontractkit/chainlink-common v0.2.2-0.20240916214706-e7280848cd7b h1:7RyN8+dNTN+hjnKfgfEYdRfxqeHTnPq8ILcHn/gOe6k=
github.com/smartcontractkit/chainlink-common v0.2.2-0.20240916214706-e7280848cd7b/go.mod h1:sjiiPwd4KsYOCf68MwL86EKphdXeT66EY7j53WH5DCc=
github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240911175228-daf2600bb7b7 h1:lTGIOQYLk1Ufn++X/AvZnt6VOcuhste5yp+C157No/Q=
github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240911175228-daf2600bb7b7/go.mod h1:BMYE1vC/pGmdFSsOJdPrAA0/4gZ0Xo0SxTMdGspBtRo=
github.com/smartcontractkit/chainlink-data-streams v0.0.0-20240906125718-9f0a98d32fbc h1:tRmTlaoAt+7FakMXXgeCuRPmzzBo5jsGpeCVvcU6KMc=
Expand Down
Loading
Loading