-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Solana plugin #15820
Merged
Merged
Solana plugin #15820
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
a225863
ccip/oraclecreator: inline a couple functions
archseer cf7f1ea
ccip/oraclecreator: getKeySpecificMaxGasPrice seems unused?
archseer b703ebb
keystore: Add OCR3 support to solana OCR keys
archseer acf14bd
deployment/ccip: Declare OCR key bundles for all available chain types
archseer 5e9caf7
oraclecreator: Extract chain specific config out into a per-family de…
archseer a0511c6
Tweak logger names
archseer 1586bdb
Add in check for multiple keys
archseer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,6 @@ import ( | |
"encoding/json" | ||
"fmt" | ||
"io" | ||
"math/big" | ||
"time" | ||
|
||
"github.com/ethereum/go-ethereum/common" | ||
|
@@ -35,7 +34,6 @@ import ( | |
evmconfig "github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/configs/evm" | ||
"github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/ocrimpls" | ||
cctypes "github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/types" | ||
"github.com/smartcontractkit/chainlink/v2/core/chains/evm/config/toml" | ||
"github.com/smartcontractkit/chainlink/v2/core/logger" | ||
"github.com/smartcontractkit/chainlink/v2/core/services/job" | ||
"github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ocr2key" | ||
|
@@ -44,7 +42,6 @@ import ( | |
evmrelaytypes "github.com/smartcontractkit/chainlink/v2/core/services/relay/evm/types" | ||
"github.com/smartcontractkit/chainlink/v2/core/services/synchronization" | ||
"github.com/smartcontractkit/chainlink/v2/core/services/telemetry" | ||
"github.com/smartcontractkit/chainlink/v2/evm/assets" | ||
) | ||
|
||
var _ cctypes.OracleCreator = &pluginOracleCreator{} | ||
|
@@ -216,6 +213,37 @@ func (i *pluginOracleCreator) Create(ctx context.Context, donID uint32, config c | |
return newWrappedOracle(oracle, closers), nil | ||
} | ||
|
||
type plugin struct { | ||
CommitPluginCodec cciptypes.CommitPluginCodec | ||
ExecutePluginCodec cciptypes.ExecutePluginCodec | ||
ExtraArgsCodec cciptypes.ExtraDataCodec | ||
MessageHasher func(lggr logger.Logger) cciptypes.MessageHasher | ||
TokenDataEncoder cciptypes.TokenDataEncoder | ||
GasEstimateProvider cciptypes.EstimateProvider | ||
RMNCrypto func(lggr logger.Logger) cciptypes.RMNCrypto | ||
} | ||
|
||
var plugins = map[string]plugin{ | ||
chainsel.FamilyEVM: { | ||
CommitPluginCodec: ccipevm.NewCommitPluginCodecV1(), | ||
ExecutePluginCodec: ccipevm.NewExecutePluginCodecV1(), | ||
ExtraArgsCodec: ccipevm.ExtraArgsCodec{}, | ||
MessageHasher: func(lggr logger.Logger) cciptypes.MessageHasher { return ccipevm.NewMessageHasherV1(lggr) }, | ||
TokenDataEncoder: ccipevm.NewEVMTokenDataEncoder(), | ||
GasEstimateProvider: ccipevm.NewGasEstimateProvider(), | ||
RMNCrypto: func(lggr logger.Logger) cciptypes.RMNCrypto { return ccipevm.NewEVMRMNCrypto(lggr) }, | ||
}, | ||
chainsel.FamilySolana: { | ||
CommitPluginCodec: nil, | ||
ExecutePluginCodec: nil, | ||
ExtraArgsCodec: nil, | ||
MessageHasher: func(lggr logger.Logger) cciptypes.MessageHasher { return nil }, | ||
TokenDataEncoder: nil, | ||
GasEstimateProvider: nil, | ||
RMNCrypto: func(lggr logger.Logger) cciptypes.RMNCrypto { return nil }, | ||
}, | ||
} | ||
|
||
func (i *pluginOracleCreator) createFactoryAndTransmitter( | ||
donID uint32, | ||
config cctypes.OCR3ConfigWithMeta, | ||
|
@@ -234,6 +262,16 @@ func (i *pluginOracleCreator) createFactoryAndTransmitter( | |
return nil, nil, fmt.Errorf("unsupported chain selector %d %w", config.Config.ChainSelector, err) | ||
} | ||
|
||
chainFamily, err := chainsel.GetSelectorFamily(uint64(config.Config.ChainSelector)) | ||
if err != nil { | ||
return nil, nil, fmt.Errorf("unsupported chain selector %d %w", config.Config.ChainSelector, err) | ||
} | ||
plugin, exists := plugins[chainFamily] | ||
if !exists { | ||
return nil, nil, fmt.Errorf("unsupported chain %v", chainFamily) | ||
} | ||
messageHasher := plugin.MessageHasher(i.lggr.Named(chainFamily).Named("MessageHasherV1")) | ||
|
||
if config.Config.PluginType == uint8(cctypes.PluginTypeCCIPCommit) { | ||
if !i.peerWrapper.IsStarted() { | ||
return nil, nil, fmt.Errorf("peer wrapper is not started") | ||
|
@@ -249,7 +287,7 @@ func (i *pluginOracleCreator) createFactoryAndTransmitter( | |
publicConfig.DeltaRound, | ||
) | ||
|
||
rmnCrypto := ccipevm.NewEVMRMNCrypto(i.lggr.Named("EVMRMNCrypto")) | ||
rmnCrypto := plugin.RMNCrypto(i.lggr.Named(chainFamily).Named("RMNCrypto")) | ||
|
||
factory = commitocr3.NewPluginFactory( | ||
i.lggr. | ||
|
@@ -259,9 +297,9 @@ func (i *pluginOracleCreator) createFactoryAndTransmitter( | |
Named(hexutil.Encode(config.Config.OfframpAddress)), | ||
donID, | ||
ccipreaderpkg.OCR3ConfigWithMeta(config), | ||
ccipevm.NewCommitPluginCodecV1(), | ||
ccipevm.NewMessageHasherV1(i.lggr.Named("MessageHasherV1")), | ||
ccipevm.NewExtraArgsCodec(), | ||
plugin.CommitPluginCodec, | ||
messageHasher, | ||
plugin.ExtraArgsCodec, | ||
i.homeChainReader, | ||
i.homeChainSelector, | ||
contractReaders, | ||
|
@@ -282,12 +320,12 @@ func (i *pluginOracleCreator) createFactoryAndTransmitter( | |
Named(hexutil.Encode(config.Config.OfframpAddress)), | ||
donID, | ||
ccipreaderpkg.OCR3ConfigWithMeta(config), | ||
ccipevm.NewExecutePluginCodecV1(), | ||
ccipevm.NewMessageHasherV1(i.lggr.Named("MessageHasherV1")), | ||
ccipevm.NewExtraArgsCodec(), | ||
plugin.ExecutePluginCodec, | ||
messageHasher, | ||
plugin.ExtraArgsCodec, | ||
i.homeChainReader, | ||
ccipevm.NewEVMTokenDataEncoder(), | ||
ccipevm.NewGasEstimateProvider(), | ||
plugin.TokenDataEncoder, | ||
plugin.GasEstimateProvider, | ||
contractReaders, | ||
chainWriters, | ||
) | ||
|
@@ -328,17 +366,18 @@ func (i *pluginOracleCreator) createReadersAndWriters( | |
execBatchGasLimit = defaultExecGasLimit | ||
} | ||
|
||
homeChainID, err := i.getChainID(i.homeChainSelector) | ||
homeChainID, err := chainsel.GetChainIDFromSelector(uint64(i.homeChainSelector)) | ||
if err != nil { | ||
return nil, nil, err | ||
return nil, nil, fmt.Errorf("failed to get chain ID from chain selector %d: %w", i.homeChainSelector, err) | ||
} | ||
|
||
contractReaders := make(map[cciptypes.ChainSelector]types.ContractReader) | ||
chainWriters := make(map[cciptypes.ChainSelector]types.ContractWriter) | ||
for relayID, relayer := range i.relayers { | ||
chainID := relayID.ChainID | ||
relayChainFamily := relayID.Network | ||
chainSelector, err1 := i.getChainSelector(chainID, relayChainFamily) | ||
chainDetails, err1 := chainsel.GetChainDetailsByChainIDAndFamily(chainID, relayChainFamily) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Check |
||
chainSelector := cciptypes.ChainSelector(chainDetails.ChainSelector) | ||
if err1 != nil { | ||
return nil, nil, fmt.Errorf("failed to get chain selector from chain ID %s: %w", chainID, err1) | ||
} | ||
|
@@ -421,22 +460,6 @@ func decodeAndValidateOffchainConfig( | |
return ofc, nil | ||
} | ||
|
||
func (i *pluginOracleCreator) getChainSelector(chainID string, chainFamily string) (cciptypes.ChainSelector, error) { | ||
chainDetails, err := chainsel.GetChainDetailsByChainIDAndFamily(chainID, chainFamily) | ||
if err != nil { | ||
return 0, fmt.Errorf("failed to get chain selector from chain ID %s and family %s", chainID, chainFamily) | ||
} | ||
return cciptypes.ChainSelector(chainDetails.ChainSelector), nil | ||
} | ||
|
||
func (i *pluginOracleCreator) getChainID(chainSelector cciptypes.ChainSelector) (string, error) { | ||
chainID, err := chainsel.GetChainIDFromSelector(uint64(chainSelector)) | ||
if err != nil { | ||
return "", fmt.Errorf("failed to get chain ID from chain selector %d: %w", chainSelector, err) | ||
} | ||
return chainID, nil | ||
} | ||
|
||
func getChainReaderConfig( | ||
lggr logger.Logger, | ||
chainID string, | ||
|
@@ -520,33 +543,6 @@ func createChainWriter( | |
return cw, nil | ||
} | ||
|
||
func getKeySpecificMaxGasPrice(evmConfigs toml.EVMConfigs, chainID *big.Int, fromAddress common.Address) *assets.Wei { | ||
var maxGasPrice *assets.Wei | ||
|
||
// If a chain is enabled it should have some configuration in the TOML config | ||
// of the chainlink node. | ||
for _, config := range evmConfigs { | ||
if config.ChainID.ToInt().Cmp(chainID) != 0 { | ||
continue | ||
} | ||
|
||
// find the key-specific max gas price for the given fromAddress. | ||
for _, keySpecific := range config.KeySpecific { | ||
if keySpecific.Key.Address() == fromAddress { | ||
maxGasPrice = keySpecific.GasEstimator.PriceMax | ||
} | ||
} | ||
|
||
// if we didn't find a key-specific max gas price, use the one specified | ||
// in the gas estimator config, which should have a default value. | ||
if maxGasPrice == nil { | ||
maxGasPrice = config.GasEstimator.PriceMax | ||
} | ||
} | ||
|
||
return maxGasPrice | ||
} | ||
|
||
type offChainConfig struct { | ||
commitOffchainConfig *pluginconfig.CommitOffchainConfig | ||
execOffchainConfig *pluginconfig.ExecuteOffchainConfig | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check can still be performed by the oracle creator using something like
_, supported := oraclecreator.plugins[networkType]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've removed the check because it should be fine to declare OCR2 keys for chains that are currently unsupported, those keys will just be unused (a similar change is needed in transmitters). This way we won't even need to redeploy jobspecs when new chains with existing keys add CCIP support.
The jobspec code further down also works similarly: it simply exposes all available key types