Skip to content

Commit

Permalink
Parameterize token info (#15426)
Browse files Browse the repository at this point in the history
* parameterize token info

* update logger

* more fixes

* change TokenPriceBatchWriteFrequency

* move test setups

* fix flakey test
  • Loading branch information
AnieeG authored Nov 26, 2024
1 parent ae63cc6 commit ad29794
Show file tree
Hide file tree
Showing 16 changed files with 45 additions and 33 deletions.
1 change: 0 additions & 1 deletion deployment/ccip/changeset/active_candidate.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ func SetCandidatePluginChangeset(
ccipOCRParams := DefaultOCRParams(
feedChainSel,
tokenConfig.GetTokenInfo(e.Logger, state.Chains[newChainSel].LinkToken, state.Chains[newChainSel].Weth9),
nil,
)
newDONArgs, err := internal.BuildOCR3ConfigForCCIPHome(
ocrSecrets,
Expand Down
1 change: 0 additions & 1 deletion deployment/ccip/changeset/active_candidate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ func TestActiveCandidate(t *testing.T) {
ccipOCRParams := DefaultOCRParams(
tenv.FeedChainSel,
tokenConfig.GetTokenInfo(e.Logger, state.Chains[tenv.FeedChainSel].LinkToken, state.Chains[tenv.FeedChainSel].Weth9),
nil,
)
ocr3ConfigMap, err := internal.BuildOCR3ConfigForCCIPHome(
deployment.XXXGenerateTestOCRSecrets(),
Expand Down
1 change: 0 additions & 1 deletion deployment/ccip/changeset/add_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ func AddDonAndSetCandidateChangeset(
ccipOCRParams := DefaultOCRParams(
feedChainSel,
tokenConfig.GetTokenInfo(e.Logger, state.Chains[newChainSel].LinkToken, state.Chains[newChainSel].Weth9),
nil,
)
newDONArgs, err := internal.BuildOCR3ConfigForCCIPHome(
ocrSecrets,
Expand Down
6 changes: 1 addition & 5 deletions deployment/ccip/changeset/add_chain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,13 @@ func TestAddChainInbound(t *testing.T) {
require.NoError(t, e.Env.ExistingAddresses.Merge(out.AddressBook))
newAddresses = deployment.NewMemoryAddressBook()
tokenConfig := NewTestTokenConfig(state.Chains[e.FeedChainSel].USDFeeds)
ocrParams := make(map[uint64]CCIPOCRParams)
for _, chain := range initialDeploy {
ocrParams[chain] = DefaultOCRParams(e.FeedChainSel, nil, nil)
}

err = deployCCIPContracts(e.Env, newAddresses, NewChainsConfig{
HomeChainSel: e.HomeChainSel,
FeedChainSel: e.FeedChainSel,
ChainsToDeploy: initialDeploy,
TokenConfig: tokenConfig,
OCRSecrets: deployment.XXXGenerateTestOCRSecrets(),
OCRParams: ocrParams,
})
require.NoError(t, err)

Expand Down
16 changes: 13 additions & 3 deletions deployment/ccip/changeset/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -384,8 +384,6 @@ func configureChain(
if chainState.OffRamp == nil {
return fmt.Errorf("off ramp not found for chain %d", chain.Selector)
}
// TODO : better handling - need to scale this for more tokens
ocrParams.CommitOffChainConfig.TokenInfo = c.TokenConfig.GetTokenInfo(e.Logger, existingState.Chains[chainSel].LinkToken, existingState.Chains[chainSel].Weth9)
_, err = AddChainConfig(
e.Logger,
e.Chains[c.HomeChainSel],
Expand All @@ -396,7 +394,7 @@ func configureChain(
return err
}
if enabled, ok := c.USDCConfig.EnabledChainMap()[chainSel]; ok && enabled {
ocrParams.ExecuteOffChainConfig.TokenDataObservers = append(ocrParams.ExecuteOffChainConfig.TokenDataObservers, c.USDCConfig.ToTokenDataObserverConfig()...)
ocrParams.ExecuteOffChainConfig.TokenDataObservers = c.USDCConfig.ToTokenDataObserverConfig()
}
ocrParams.CommitOffChainConfig.PriceFeedChainSelector = cciptypes.ChainSelector(c.FeedChainSel)
// For each chain, we create a DON on the home chain (2 OCR instances)
Expand Down Expand Up @@ -443,6 +441,18 @@ func deployCCIPContracts(
e.Logger.Errorw("Failed to merge address book", "err", err)
return err
}
state, err := LoadOnchainState(e)
if err != nil {
e.Logger.Errorw("Failed to load existing onchain state", "err", err)
return err
}

ocrParams := make(map[uint64]CCIPOCRParams)
for _, chain := range c.ChainsToDeploy {
tokenInfo := c.TokenConfig.GetTokenInfo(e.Logger, state.Chains[chain].LinkToken, state.Chains[chain].Weth9)
ocrParams[chain] = DefaultOCRParams(c.FeedChainSel, tokenInfo)
}
c.OCRParams = ocrParams
err = configureChain(e, c)
if err != nil {
e.Logger.Errorw("Failed to add chain", "err", err)
Expand Down
2 changes: 0 additions & 2 deletions deployment/ccip/changeset/initial_add_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ func (c NewChainsConfig) Validate() error {
func DefaultOCRParams(
feedChainSel uint64,
tokenInfo map[ccipocr3.UnknownEncodedAddress]pluginconfig.TokenInfo,
dataObserverConfig []pluginconfig.TokenDataObserverConfig,
) CCIPOCRParams {
return CCIPOCRParams{
OCRParameters: types.OCRParameters{
Expand All @@ -192,7 +191,6 @@ func DefaultOCRParams(
RootSnoozeTime: *config.MustNewDuration(internal.RootSnoozeTime),
MessageVisibilityInterval: *config.MustNewDuration(internal.FirstBlockAge),
BatchingStrategyID: internal.BatchingStrategyID,
TokenDataObservers: dataObserverConfig,
},
CommitOffChainConfig: pluginconfig.CommitOffchainConfig{
RemoteGasPriceBatchWriteFrequency: *config.MustNewDuration(internal.RemoteGasPriceBatchWriteFrequency),
Expand Down
2 changes: 1 addition & 1 deletion deployment/ccip/changeset/internal/deploy_home_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const (

FirstBlockAge = 8 * time.Hour
RemoteGasPriceBatchWriteFrequency = 30 * time.Minute
TokenPriceBatchWriteFrequency = 3 * time.Second
TokenPriceBatchWriteFrequency = 30 * time.Minute
BatchGasLimit = 6_500_000
RelativeBoostPerWaitHour = 1.5
InflightCacheExpiry = 10 * time.Minute
Expand Down
25 changes: 14 additions & 11 deletions deployment/ccip/changeset/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,13 @@ func NewMemoryEnvironmentWithJobsAndContracts(t *testing.T, lggr logger.Logger,
Changeset: commonchangeset.WrapChangeSet(commonchangeset.DeployMCMSWithTimelock),
Config: mcmsCfg,
},
{
Changeset: commonchangeset.WrapChangeSet(DeployChainContracts),
Config: DeployChainContractsConfig{
ChainSelectors: allChains,
HomeChainSelector: e.HomeChainSel,
},
},
})
require.NoError(t, err)

Expand All @@ -307,10 +314,8 @@ func NewMemoryEnvironmentWithJobsAndContracts(t *testing.T, lggr logger.Logger,
SourceMessageTransmitterAddr: state.Chains[chain].MockUSDCTransmitter.Address().String(),
}
}
for _, chain := range allChains {
timelocksPerChain[chain] = state.Chains[chain].Timelock
ocrParams[chain] = DefaultOCRParams(e.FeedChainSel, nil, nil)
}
require.NotNil(t, state.Chains[e.FeedChainSel].LinkToken)
require.NotNil(t, state.Chains[e.FeedChainSel].Weth9)
var usdcCfg USDCAttestationConfig
if len(usdcChains) > 0 {
server := mockAttestationResponse()
Expand All @@ -325,15 +330,13 @@ func NewMemoryEnvironmentWithJobsAndContracts(t *testing.T, lggr logger.Logger,
})
}

for _, chain := range allChains {
timelocksPerChain[chain] = state.Chains[chain].Timelock
tokenInfo := tokenConfig.GetTokenInfo(e.Env.Logger, state.Chains[chain].LinkToken, state.Chains[chain].Weth9)
ocrParams[chain] = DefaultOCRParams(e.FeedChainSel, tokenInfo)
}
// Deploy second set of changesets to deploy and configure the CCIP contracts.
e.Env, err = commonchangeset.ApplyChangesets(t, e.Env, timelocksPerChain, []commonchangeset.ChangesetApplication{
{
Changeset: commonchangeset.WrapChangeSet(DeployChainContracts),
Config: DeployChainContractsConfig{
ChainSelectors: allChains,
HomeChainSelector: e.HomeChainSel,
},
},
{
Changeset: commonchangeset.WrapChangeSet(ConfigureNewChains),
Config: NewChainsConfig{
Expand Down
1 change: 1 addition & 0 deletions deployment/ccip/changeset/token_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package changeset
import (
"github.com/smartcontractkit/chainlink-ccip/pkg/types/ccipocr3"
"github.com/smartcontractkit/chainlink-ccip/pluginconfig"

"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/weth9"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/aggregator_v3_interface"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/shared/generated/burn_mint_erc677"
Expand Down
4 changes: 3 additions & 1 deletion integration-tests/smoke/ccip/ccip_batching_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ import (

"github.com/smartcontractkit/chainlink-ccip/pkg/types/ccipocr3"
"github.com/smartcontractkit/chainlink-common/pkg/merklemulti"

"github.com/smartcontractkit/chainlink/deployment"
"github.com/smartcontractkit/chainlink/deployment/ccip/changeset"
"github.com/smartcontractkit/chainlink/integration-tests/testsetups"
testsetups "github.com/smartcontractkit/chainlink/integration-tests/testsetups/ccip"
"github.com/smartcontractkit/chainlink/v2/core/chains/evm/assets"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/offramp"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/onramp"
Expand Down Expand Up @@ -237,6 +238,7 @@ func Test_CCIPBatching(t *testing.T) {
})

t.Run("max evm batch size", func(t *testing.T) {
t.Skipf("This test is flaky, skipping until the issue related to fee calculation is resolved")
var (
sourceChain = sourceChain1
otherSender = mustNewTransactor(t, e.Env.Chains[sourceChain])
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/smoke/ccip/ccip_messaging_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (

"github.com/smartcontractkit/chainlink/deployment"
"github.com/smartcontractkit/chainlink/deployment/ccip/changeset"
"github.com/smartcontractkit/chainlink/integration-tests/testsetups"
testsetups "github.com/smartcontractkit/chainlink/integration-tests/testsetups/ccip"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/offramp"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/onramp"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/router"
Expand Down
3 changes: 2 additions & 1 deletion integration-tests/smoke/ccip/ccip_rmn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@ import (

"github.com/smartcontractkit/chainlink-testing-framework/lib/utils/osutil"
"github.com/smartcontractkit/chainlink-testing-framework/lib/utils/testcontext"

"github.com/smartcontractkit/chainlink/deployment/ccip/changeset"

"github.com/smartcontractkit/chainlink/deployment"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/rmn_home"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/rmn_remote"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/router"

"github.com/smartcontractkit/chainlink/integration-tests/testsetups"
testsetups "github.com/smartcontractkit/chainlink/integration-tests/testsetups/ccip"
"github.com/smartcontractkit/chainlink/v2/core/logger"
)

Expand Down
2 changes: 1 addition & 1 deletion integration-tests/smoke/ccip/ccip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/smartcontractkit/chainlink-testing-framework/lib/utils/testcontext"

"github.com/smartcontractkit/chainlink/deployment/ccip/changeset"
"github.com/smartcontractkit/chainlink/integration-tests/testsetups"
testsetups "github.com/smartcontractkit/chainlink/integration-tests/testsetups/ccip"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/onramp"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/router"
"github.com/smartcontractkit/chainlink/v2/core/logger"
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/smoke/ccip/ccip_usdc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (

"github.com/smartcontractkit/chainlink/deployment"
"github.com/smartcontractkit/chainlink/deployment/ccip/changeset"
"github.com/smartcontractkit/chainlink/integration-tests/testsetups"
testsetups "github.com/smartcontractkit/chainlink/integration-tests/testsetups/ccip"
"github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/onramp"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/router"
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/smoke/ccip/fee_boosting_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

"github.com/smartcontractkit/chainlink/deployment"
"github.com/smartcontractkit/chainlink/deployment/ccip/changeset"
"github.com/smartcontractkit/chainlink/integration-tests/testsetups"
testsetups "github.com/smartcontractkit/chainlink/integration-tests/testsetups/ccip"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/router"
"github.com/smartcontractkit/chainlink/v2/core/logger"
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package testsetups
package ccip

import (
"bytes"
Expand Down Expand Up @@ -217,9 +217,13 @@ func NewLocalDevEnvironment(
APIInterval: commonconfig.MustNewDuration(500 * time.Millisecond),
}
}
require.NotNil(t, state.Chains[feedSel].LinkToken)
require.NotNil(t, state.Chains[feedSel].Weth9)

for _, chain := range allChains {
timelocksPerChain[chain] = state.Chains[chain].Timelock
ocrParams[chain] = changeset.DefaultOCRParams(feedSel, nil, nil)
tokenInfo := tokenConfig.GetTokenInfo(env.Logger, state.Chains[chain].LinkToken, state.Chains[chain].Weth9)
ocrParams[chain] = changeset.DefaultOCRParams(feedSel, tokenInfo)
}
// Deploy second set of changesets to deploy and configure the CCIP contracts.
env, err = commonchangeset.ApplyChangesets(t, env, timelocksPerChain, []commonchangeset.ChangesetApplication{
Expand Down

0 comments on commit ad29794

Please sign in to comment.