Skip to content

Commit ec50b62

Browse files
feat: introducing lazy chain loading
Chains are loaded lazily instead of eager, this means chains will only be loaded when it is being used, this means users are not forced to provide any secrets for chains if they are not used upfront and avoid loading huge amount of chains that are never used. This change also means we can deprecate `ChainOverrides` feature as we no longer have to tell CLD what chains to load. This lazy loading is hidden under the feature flag CLD_LAZY_BLOCKCHAINS
1 parent d03f511 commit ec50b62

File tree

11 files changed

+1720
-51
lines changed

11 files changed

+1720
-51
lines changed

.changeset/empty-words-tickle.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"chainlink-deployments-framework": minor
3+
---
4+
5+
feat(chain): introduce lazy chain loading
6+
7+
feature toggle under CLD_LAZY_BLOCKCHAINS environment variable to enable lazy loading of chains.

chain/blockchain.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ var _ BlockChain = sui.Chain{}
2424
var _ BlockChain = ton.Chain{}
2525
var _ BlockChain = tron.Chain{}
2626

27+
// Compile-time checks that both BlockChains and LazyBlockChains implement BlockChainCollection
28+
var _ BlockChainCollection = BlockChains{}
29+
var _ BlockChainCollection = (*LazyBlockChains)(nil)
30+
2731
// BlockChain is an interface that represents a chain.
2832
// A chain can be an EVM chain, Solana chain Aptos chain or others.
2933
type BlockChain interface {
@@ -35,6 +39,22 @@ type BlockChain interface {
3539
Family() string
3640
}
3741

42+
// BlockChainCollection defines the common interface for accessing blockchain instances.
43+
// Both BlockChains and LazyBlockChains implement this interface.
44+
type BlockChainCollection interface {
45+
GetBySelector(selector uint64) (BlockChain, error)
46+
Exists(selector uint64) bool
47+
ExistsN(selectors ...uint64) bool
48+
All() iter.Seq2[uint64, BlockChain]
49+
EVMChains() map[uint64]evm.Chain
50+
SolanaChains() map[uint64]solana.Chain
51+
AptosChains() map[uint64]aptos.Chain
52+
SuiChains() map[uint64]sui.Chain
53+
TonChains() map[uint64]ton.Chain
54+
TronChains() map[uint64]tron.Chain
55+
ListChainSelectors(options ...ChainSelectorsOption) []uint64
56+
}
57+
3858
// BlockChains represents a collection of chains.
3959
// It provides querying capabilities for different types of chains.
4060
type BlockChains struct {

0 commit comments

Comments
 (0)