Skip to content

Commit 1b68ca3

Browse files
[Concept]: feat: introducing lazy chain loading (#644)
Chains can now be loaded lazily instead of eager, this means chains will only be loaded when it is being used. Hidden under the feature toggle `CLD_LAZY_BLOCKCHAINS` , off by default. Basically this solves a bunch of issues - avoid loading all the chains in the network config file even they are not used (increases loading time) - failures on loading certain chains that are not used will now not failed the changeset - users having to always specify chain overrides in input yaml in order to avoid loading all the chains (this can be tricky if the chain overrides is a long list of chains too) - basically deprecate the `ChainsOverrides` feature, simplifying the code
1 parent 3791c84 commit 1b68ca3

File tree

11 files changed

+1706
-51
lines changed

11 files changed

+1706
-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)