Skip to content
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

refactor extradata codec to unblock ccip ocr message optimization using protobuf #16402

Merged
66 changes: 33 additions & 33 deletions core/capabilities/ccip/oraclecreator/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,45 @@ import (
)

var _ cctypes.OracleCreator = &pluginOracleCreator{}
var extraDataCodec = ccipcommon.NewExtraDataCodec()
var plugins = map[string]plugin{
chainsel.FamilyEVM: {
CommitPluginCodec: ccipevm.NewCommitPluginCodecV1(),
ExecutePluginCodec: ccipevm.NewExecutePluginCodecV1(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So EVM's ExecutePluginCodec and MessageHasher should also need access to extraDataCodec, similar to how solana is needing them right?

I think currently it is not there, because we haven't supported Solana -> EVM side codecs.
In EVM codec, I see we are decoding extraArgs and destinationGas directly, assuming ABI encoding, and not using the extraDataCodec.

Could we make the change here itself?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we discussed offline, the evm changes can happen in another PR

ExtraArgsCodec: ccipcommon.NewExtraDataCodec(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This too should be extraDataCodec

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: ccipsolana.NewCommitPluginCodecV1(),
ExecutePluginCodec: ccipsolana.NewExecutePluginCodecV1(extraDataCodec),
ExtraArgsCodec: extraDataCodec,
MessageHasher: func(lggr logger.Logger) cciptypes.MessageHasher {
return ccipsolana.NewMessageHasherV1(lggr, extraDataCodec)
},
TokenDataEncoder: ccipsolana.NewSolanaTokenDataEncoder(),
GasEstimateProvider: ccipsolana.NewGasEstimateProvider(),
RMNCrypto: func(lggr logger.Logger) cciptypes.RMNCrypto { return nil },
},
}

const (
defaultCommitGasLimit = 500_000
defaultExecGasLimit = 6_500_000
)

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
}

// pluginOracleCreator creates oracles that reference plugins running
// in the same process as the chainlink node, i.e not LOOPPs.
type pluginOracleCreator struct {
Expand Down Expand Up @@ -238,39 +271,6 @@ func encodeOffRampAddr(addr []byte, chainFamily string, checkSum bool) string {
return offRampAddr
}

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: ccipcommon.NewExtraDataCodec(),
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: ccipsolana.NewCommitPluginCodecV1(),
ExecutePluginCodec: ccipsolana.NewExecutePluginCodecV1(ccipcommon.NewExtraDataCodec()),
ExtraArgsCodec: ccipcommon.NewExtraDataCodec(),
MessageHasher: func(lggr logger.Logger) cciptypes.MessageHasher {
return ccipsolana.NewMessageHasherV1(lggr, ccipcommon.NewExtraDataCodec())
},
TokenDataEncoder: ccipsolana.NewSolanaTokenDataEncoder(),
GasEstimateProvider: ccipsolana.NewGasEstimateProvider(),
RMNCrypto: func(lggr logger.Logger) cciptypes.RMNCrypto { return nil },
},
}

func (i *pluginOracleCreator) createFactoryAndTransmitter(
donID uint32,
config cctypes.OCR3ConfigWithMeta,
Expand Down
Loading