Skip to content

Commit

Permalink
Add commit offchain config in OracleCreator (#14423)
Browse files Browse the repository at this point in the history
* Use commitOffChainConfig to initialize FeedReaderConfig

Add FeedReaderConfig to
Bind all feed addresses for each token in the offchain config

* Add TODOs for commit off chain config in homechain deployment

* Refactor oracelcreator/plugin

* Use functions instead of methods

* Remove token feed chain bindings - going to bind in chainlink-ccip

* Use commitOffChainConfig to initialize FeedReaderConfig

Add FeedReaderConfig to
Bind all feed addresses for each token in the offchain config

* Add TODOs for commit off chain config in homechain deployment

* Refactor oracelcreator/plugin

* Fix go mods

* Add changeset

* Remove missing things from fixing merge conflicts

* pnpm changeset
  • Loading branch information
asoliman92 authored Sep 16, 2024
1 parent 4be0665 commit 0187f18
Show file tree
Hide file tree
Showing 14 changed files with 489 additions and 277 deletions.
5 changes: 5 additions & 0 deletions .changeset/curvy-points-grin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": patch
---

#updated refactor ccip oracle creator
103 changes: 68 additions & 35 deletions core/capabilities/ccip/configs/evm/contract_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ import (
"github.com/ethereum/go-ethereum/accounts/abi"

"github.com/smartcontractkit/chainlink-ccip/pkg/consts"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/nonce_manager"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/onramp"

evmtypes "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/ccip_config"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/fee_quoter"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/nonce_manager"
"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/generated/aggregator_v3_interface"
kcr "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/keystone/generated/capabilities_registry"
evmrelaytypes "github.com/smartcontractkit/chainlink/v2/core/services/relay/evm/types"
)
Expand All @@ -22,8 +23,9 @@ var (
onrampABI = evmtypes.MustGetABI(onramp.OnRampABI)
capabilitiesRegsitryABI = evmtypes.MustGetABI(kcr.CapabilitiesRegistryABI)
ccipConfigABI = evmtypes.MustGetABI(ccip_config.CCIPConfigABI)
priceRegistryABI = evmtypes.MustGetABI(fee_quoter.FeeQuoterABI)
feeQuoterABI = evmtypes.MustGetABI(fee_quoter.FeeQuoterABI)
nonceManagerABI = evmtypes.MustGetABI(nonce_manager.NonceManagerABI)
priceFeedABI = evmtypes.MustGetABI(aggregator_v3_interface.AggregatorV3InterfaceABI)
)

// MustSourceReaderConfig returns a ChainReaderConfig that can be used to read from the onramp.
Expand All @@ -50,6 +52,17 @@ func MustDestReaderConfig() []byte {
return encoded
}

func MergeReaderConfigs(configs ...evmrelaytypes.ChainReaderConfig) evmrelaytypes.ChainReaderConfig {
allContracts := make(map[string]evmrelaytypes.ChainContractReader)
for _, c := range configs {
for contractName, contractReader := range c.Contracts {
allContracts[contractName] = contractReader
}
}

return evmrelaytypes.ChainReaderConfig{Contracts: allContracts}
}

// DestReaderConfig returns a ChainReaderConfig that can be used to read from the offramp.
var DestReaderConfig = evmrelaytypes.ChainReaderConfig{
Contracts: map[string]evmrelaytypes.ChainContractReader{
Expand Down Expand Up @@ -109,6 +122,47 @@ var DestReaderConfig = evmrelaytypes.ChainReaderConfig{
},
},
},
consts.ContractNameFeeQuoter: {
ContractABI: fee_quoter.FeeQuoterABI,
Configs: map[string]*evmrelaytypes.ChainReaderDefinition{
consts.MethodNameFeeQuoterGetStaticConfig: {
ChainSpecificName: mustGetMethodName("getStaticConfig", feeQuoterABI),
ReadType: evmrelaytypes.Method,
},
consts.MethodNameFeeQuoterGetTokenPrices: {
ChainSpecificName: mustGetMethodName("getTokenPrices", feeQuoterABI),
ReadType: evmrelaytypes.Method,
},
consts.MethodNameGetDestChainConfig: {
ChainSpecificName: mustGetMethodName("getDestChainConfig", feeQuoterABI),
ReadType: evmrelaytypes.Method,
},
consts.MethodNameGetPremiumMultiplierWeiPerEth: {
ChainSpecificName: mustGetMethodName("getPremiumMultiplierWeiPerEth", feeQuoterABI),
ReadType: evmrelaytypes.Method,
},
consts.MethodNameGetTokenTransferFeeConfig: {
ChainSpecificName: mustGetMethodName("getTokenTransferFeeConfig", feeQuoterABI),
ReadType: evmrelaytypes.Method,
},
consts.MethodNameProcessMessageArgs: {
ChainSpecificName: mustGetMethodName("processMessageArgs", feeQuoterABI),
ReadType: evmrelaytypes.Method,
},
consts.MethodNameProcessPoolReturnData: {
ChainSpecificName: mustGetMethodName("processPoolReturnData", feeQuoterABI),
ReadType: evmrelaytypes.Method,
},
consts.MethodNameGetValidatedTokenPrice: {
ChainSpecificName: mustGetMethodName("getValidatedTokenPrice", feeQuoterABI),
ReadType: evmrelaytypes.Method,
},
consts.MethodNameGetFeeTokens: {
ChainSpecificName: mustGetMethodName("getFeeTokens", feeQuoterABI),
ReadType: evmrelaytypes.Method,
},
},
},
},
}

Expand Down Expand Up @@ -148,40 +202,19 @@ var SourceReaderConfig = evmrelaytypes.ChainReaderConfig{
},
},
},
consts.ContractNamePriceRegistry: {
ContractABI: fee_quoter.FeeQuoterABI,
},
}

var FeedReaderConfig = evmrelaytypes.ChainReaderConfig{
Contracts: map[string]evmrelaytypes.ChainContractReader{
consts.ContractNamePriceAggregator: {
ContractABI: aggregator_v3_interface.AggregatorV3InterfaceABI,
Configs: map[string]*evmrelaytypes.ChainReaderDefinition{
consts.MethodNamePriceRegistryGetStaticConfig: {
ChainSpecificName: mustGetMethodName("getStaticConfig", priceRegistryABI),
ReadType: evmrelaytypes.Method,
},
consts.MethodNameGetDestChainConfig: {
ChainSpecificName: mustGetMethodName("getDestChainConfig", priceRegistryABI),
ReadType: evmrelaytypes.Method,
consts.MethodNameGetLatestRoundData: {
ChainSpecificName: mustGetMethodName(consts.MethodNameGetLatestRoundData, priceFeedABI),
},
consts.MethodNameGetPremiumMultiplierWeiPerEth: {
ChainSpecificName: mustGetMethodName("getPremiumMultiplierWeiPerEth", priceRegistryABI),
ReadType: evmrelaytypes.Method,
},
consts.MethodNameGetTokenTransferFeeConfig: {
ChainSpecificName: mustGetMethodName("getTokenTransferFeeConfig", priceRegistryABI),
ReadType: evmrelaytypes.Method,
},
consts.MethodNameProcessMessageArgs: {
ChainSpecificName: mustGetMethodName("processMessageArgs", priceRegistryABI),
ReadType: evmrelaytypes.Method,
},
consts.MethodNameProcessPoolReturnData: {
ChainSpecificName: mustGetMethodName("processPoolReturnData", priceRegistryABI),
ReadType: evmrelaytypes.Method,
},
consts.MethodNameGetValidatedTokenPrice: {
ChainSpecificName: mustGetMethodName("getValidatedTokenPrice", priceRegistryABI),
ReadType: evmrelaytypes.Method,
},
consts.MethodNameGetFeeTokens: {
ChainSpecificName: mustGetMethodName("getFeeTokens", priceRegistryABI),
ReadType: evmrelaytypes.Method,
consts.MethodNameGetDecimals: {
ChainSpecificName: mustGetMethodName(consts.MethodNameGetDecimals, priceFeedABI),
},
},
},
Expand Down
Loading

0 comments on commit 0187f18

Please sign in to comment.