Skip to content

Commit

Permalink
Use observed home chain reader in CCIP (#15628)
Browse files Browse the repository at this point in the history
* Switching to the observed version

* Switching to the observed version
  • Loading branch information
mateusz-sekara authored Dec 11, 2024
1 parent 9c36587 commit 6101be7
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/spotty-seals-give.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": patch
---

Switching CCIP to observed ChainReader for HomeChainReader #internal
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"fmt"
"math/big"
"sort"
"strconv"
"testing"
"time"

Expand Down Expand Up @@ -137,7 +138,7 @@ func NewTestUniverse(ctx context.Context, t *testing.T, lggr logger.Logger) Test
t.Cleanup(func() { require.NoError(t, lp.Close()) })

cr := NewReader(t, lp, headTracker, cl, ccAddress, configsevm.HomeChainReaderConfigRaw)
hcr := NewHomeChainReader(t, cr, ccAddress)
hcr := NewHomeChainReader(t, cr, ccAddress, strconv.Itoa(chainID))
return TestUniverse{
Transactor: transactor,
Backend: backend,
Expand Down Expand Up @@ -237,11 +238,22 @@ func (t *TestUniverse) AddCapability(p2pIDs [][32]byte) {
}
}

func NewHomeChainReader(t *testing.T, cr types.ContractReader, ccAddress common.Address) ccipreader.HomeChain {
hcr := ccipreader.NewHomeChainReader(cr, logger.TestLogger(t), 50*time.Millisecond, types.BoundContract{
Address: ccAddress.String(),
Name: consts.ContractNameCCIPConfig,
})
func NewHomeChainReader(
t *testing.T,
cr types.ContractReader,
ccAddress common.Address,
chainID string,
) ccipreader.HomeChain {
hcr := ccipreader.NewObservedHomeChainReader(
cr,
logger.TestLogger(t),
50*time.Millisecond,
types.BoundContract{
Address: ccAddress.String(),
Name: consts.ContractNameCCIPConfig,
},
chainID,
)
require.NoError(t, hcr.Start(testutils.Context(t)))
t.Cleanup(func() { require.NoError(t, hcr.Close()) })

Expand Down
3 changes: 2 additions & 1 deletion core/capabilities/ccip/delegate.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,12 @@ func (d *Delegate) ServicesForSpec(ctx context.Context, spec job.Job) (services
return nil, fmt.Errorf("failed to get home chain contract reader: %w", err)
}

hcr := ccipreaderpkg.NewHomeChainReader(
hcr := ccipreaderpkg.NewObservedHomeChainReader(
homeChainContractReader,
d.lggr.Named("HomeChainReader"),
100*time.Millisecond,
ccipConfigBinding,
d.capabilityConfig.ExternalRegistry().ChainID(),
)

// get the chain selector for the home chain
Expand Down

0 comments on commit 6101be7

Please sign in to comment.