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

Conversation

huangzhen1997
Copy link
Contributor

@huangzhen1997 huangzhen1997 commented Feb 13, 2025

The decodec extra data map (map[string]any) become a difficulty for ccip gRPC optimization.
https://chainlink-core.slack.com/archives/C0779R3AH8R/p1739457726431579

Step 1, use the extra codec functions inside the codec and msgHasher, and get rid of the usage of decoded map.
Step 2, this will be another PR in chainlink-ccip, remove the map.

Copy link
Contributor

github-actions bot commented Feb 13, 2025

AER Report: CI Core ran successfully ✅

aer_workflow , commit

AER Report: Operator UI CI ran successfully ✅

aer_workflow , commit

Comment on lines +27 to 28
func NewMessageHasherV1(lggr logger.Logger, extraDataCodec cciptypes.ExtraDataCodec) *MessageHasherV1 {
return &MessageHasherV1{
Copy link
Contributor

Choose a reason for hiding this comment

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

not sure we need to pass this in, how about initializing it automatically

Suggested change
func NewMessageHasherV1(lggr logger.Logger, extraDataCodec cciptypes.ExtraDataCodec) *MessageHasherV1 {
return &MessageHasherV1{
func NewMessageHasherV1(lggr logger.Logger) *MessageHasherV1 {
extraDataCodec := ccipcommon.NewExtraDataCodec()
return &MessageHasherV1{

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This does make mocking easier

Copy link
Contributor

Choose a reason for hiding this comment

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

Do you need to mock the encoder? It looks like the test is doing the full borsh encoding of the extra args, so the real one might work

Copy link
Contributor Author

@huangzhen1997 huangzhen1997 Feb 13, 2025

Choose a reason for hiding this comment

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

If it's EVM->Solana, we would need ABI encoding, which will introduce some evm related logic in under the ccipsolana.

@@ -20,12 +20,14 @@ import (
// Compatible with:
// - "OnRamp 1.6.0-dev"
type MessageHasherV1 struct {
lggr logger.Logger
lggr logger.Logger
extraDataCodec cciptypes.ExtraDataCodec
Copy link
Contributor

Choose a reason for hiding this comment

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

Lets get rid of the public interface too

Suggested change
extraDataCodec cciptypes.ExtraDataCodec
extraDataCodec 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.

I assume Will meant "extraDataCodec ccipcommon.ExtraDataCodec". Use the type from this repo itself.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is also because of the mocking, cciptypes.ExtraDataCodec interface gives more flexibility

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, if we are going to remove the one from chainlink-ccip repo, perhaps just create it inside ccipcommon in this repo

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh true

Copy link
Contributor

@prashantkumar1982 prashantkumar1982 left a comment

Choose a reason for hiding this comment

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

Looks good!

@@ -20,12 +20,14 @@ import (
// Compatible with:
// - "OnRamp 1.6.0-dev"
type MessageHasherV1 struct {
lggr logger.Logger
lggr logger.Logger
extraDataCodec cciptypes.ExtraDataCodec
Copy link
Contributor

Choose a reason for hiding this comment

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

I assume Will meant "extraDataCodec ccipcommon.ExtraDataCodec". Use the type from this repo itself.

ExecutePluginCodec: ccipsolana.NewExecutePluginCodecV1(ccipcommon.NewExtraDataCodec()),
ExtraArgsCodec: ccipcommon.NewExtraDataCodec(),
MessageHasher: func(lggr logger.Logger) cciptypes.MessageHasher {
return ccipsolana.NewMessageHasherV1(lggr, 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.

nit: rather than create 2 instantiations of ExtraDataCodec, 1 for member ExtraArgsCodec, and other for member MessageHasher, I'd say, create just 1 and share it.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the other instantiation goes away completely when we remove it from the ccip reader and delete the decoded arg types.

chainsel.FamilyEVM: {
CommitPluginCodec: ccipevm.NewCommitPluginCodecV1(),
ExecutePluginCodec: ccipevm.NewExecutePluginCodecV1(),
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

@huangzhen1997 huangzhen1997 requested a review from a team as a code owner February 14, 2025 18:37
@@ -53,12 +53,12 @@ import (
)

var _ cctypes.OracleCreator = &pluginOracleCreator{}
var extraDataCodec = ccipcommon.NewExtraDataCodec()
var extraDataCodec = ccipcommon.NewExtraDataCodec(ccipevm.ExtraDataDecoder{}, ccipsolana.ExtraDataDecoder{})
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

@prashantkumar1982 prashantkumar1982 added this pull request to the merge queue Feb 14, 2025
Merged via the queue into develop with commit 13b7d5a Feb 15, 2025
200 checks passed
@prashantkumar1982 prashantkumar1982 deleted the extra-data-codec-refactor-to-support-protobuf-encoding branch February 15, 2025 00:17
ecPablo pushed a commit that referenced this pull request Feb 17, 2025
* add workflow registry view

* print instead of return from registry errors

[CAPPL-442] add workflow registry view (#16336)

* add workflow registry view

* print instead of return from registry errors

Added commit price only method config to Solana ChainWriter (#16401)

* Added commit price only method config to Solana ChainWriter

* Moved ATA config from commit method to execute

* Upgraded chainlink-ccip dependency

* Addressed feedback

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

* refactor extradata codec to unblock ccip ocr message optimization using protobuf

* goimport

* revert

* minor

* minor

* refactor

* fix import

* fix import

* add comments

* fix test

* support Solana->EVM

* fix

* update

* fix make

[NONEVM-1319] - Solana Contract Reader Dest and Source cfg (#16308)

* Implement Solana Contract Reader config and bump chainlink-solana

* Update CR config

* Resolve more TODOs from Contract Reader config

* Bump solana

* Progress on CR config

* Add comments to CR config

* Bump chainlink-ccip/chains/solana in core too

* Use feeQuoterIDL

* Fix CR config issues

* Simplify CR config and add a TODO

* Remove CR config resolved TODOs and add serialisation test

* Add MethodNameOffRampLatestConfigDetails to CR config

* Fix cfg

* Upgraded chainlink-common dependency

* Bump common and resolve OffRampLatestConfigDetails issues

* Fixed linting

---------

Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
Co-authored-by: amit-momin <amit.momin@smartcontract.com>

Add new RMN smoke test (#16385)

* Add new RMN smoke test

* Fix linting issues

[TT-1991] use github.sha in integration-tests workflow (#16396)

* use github.sha in integration-tests workflow

* more Slack message debug

* use reusable workflow sha from main branch

TT-1956 Add support for e2e docker tests in Flakeguard #16376 (#16380)

* Bump Flakeguard

* wip

* update test

* update test cmd

* bump

* bump

* bump

* bump

* fix

* bump

* fix

* bump

* bump

* bump

* bump

* fail test

* bump

* Run nightly workflow with flakeguard

* bump

* bump

* Add extraArgs input to E2E tests workflow for customizable arguments

* bump

* bump

* bump

* bump

* Add extraArgs input to nightly E2E tests workflow for customizable arguments

* bump

* bump

* bump

* bump

* bump

* revert tests

* bump

* bump

* bump

* bump

* bump

* bump

* bump

* trigger tests

* Revert "trigger tests"

This reverts commit dbb37c4.

fix: restore files go mod
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants