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 and cleanup oracle creator to use plugin map #16363

Draft
wants to merge 9 commits into
base: develop
Choose a base branch
from

Conversation

huangzhen1997
Copy link
Contributor

@huangzhen1997 huangzhen1997 commented Feb 12, 2025

Cleanup and refactoring several functions to follow the plugin convention introduced in PR.

chainFamily string,
offrampProgramAddress []byte,
destChainSelector uint64,
) (types.ContractWriter, error)
}

var plugins = map[string]plugin{
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like this is statically initializing the plugin struct, thus we are forced to have some types take in func which later on takes params like logger.

Does it make sense to NOT have this declared statically, and instead have the plugins as a member field in pluginOracleCreator, which is then initialized from within NewPluginOracleCreator(). Here we can create the plugin instances for all chain families.

Copy link
Contributor

Choose a reason for hiding this comment

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

And once we do that, then all the actual init for individual members inside plugin struct can just stay in their own chain package like ccipevm or ccipsolana.

This way, this package only imports ccipevm or ccipsolana packages, instantiates each component needed, like say NewCommitPluginCodec(), newExecPluginCodec(), NewCRConfig(), NewCWConfig() and so on.
Each of these above functions should live inside their own chain family package.

That would clean this package completely of chain families, except for just initially initializing the plugin struct for all chain families.

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah we can later clean this up further for sure, the current implementation was just a way to add non-EVM support in a small diff

TokenDataEncoder cciptypes.TokenDataEncoder
GasEstimateProvider cciptypes.EstimateProvider
RMNCrypto func(lggr logger.Logger) cciptypes.RMNCrypto
EncodedOfframpAddr func([]byte, bool) string
Copy link
Contributor

Choose a reason for hiding this comment

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

This function is just serializing an address to string. So better to rename it AddressToString()

Copy link
Contributor

Choose a reason for hiding this comment

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

chainlink-ccip also has these helpers I had to patch on my branch, they're currently marked as internal but maybe we could import them: https://github.com/smartcontractkit/chainlink-ccip/blob/main/internal/libs/typeconv/address.go

"chainlink": minor
---

Cleanup and refactoring several functions to use the plugin map #added
Copy link
Contributor

Choose a reason for hiding this comment

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

Note: the changeset check is technically not required. I usually skip changeset notes unless it's a larger user impacting change

Copy link
Contributor

github-actions bot commented Feb 14, 2025

AER Report: CI Core

aer_workflow , commit , Clean Go Tidy & Generate , Detect Changes , Scheduled Run Frequency , GolangCI Lint (.) , Core Tests (go_core_tests) , Core Tests (go_core_tests_integration) , Core Tests (go_core_fuzz) , test-scripts , Core Tests (go_core_race_tests) , Core Tests (go_core_ccip_deployment_tests) , lint , SonarQube Scan

1. GolangCI Lint job failed due to linting errors: Check Golangci-lint Matrix Results

Source of Error:
Check Golangci-lint Matrix Results	2025-03-12T04:18:53.1580349Z ##[error]Process completed with exit code 1.

Why: The GolangCI Lint job encountered linting errors in the codebase, which caused the job to fail. The specific errors include improper formatting and a performance issue.

Suggested fix: Review and fix the linting errors reported by GolangCI Lint. Ensure all files are properly formatted and address any performance issues as indicated by the linter.

2. File is not properly formatted (goimports): Golang Lint (.)

Source of Error:
Golang Lint (.)	2025-03-12T04:18:40.5079135Z ##[error]core/capabilities/ccip/common/pluginconfig.go:6:1: File is not properly formatted (goimports)
Golang Lint (.)	2025-03-12T04:18:40.5080246Z 	chainsel "github.com/smartcontractkit/chain-selectors"
Golang Lint (.)	2025-03-12T04:18:40.5080826Z ^

Why: The file core/capabilities/ccip/common/pluginconfig.go is not formatted according to goimports standards.

Suggested fix: Run goimports on the file to automatically format it correctly.

3. File is not properly formatted (goimports): Golang Lint (.)

Source of Error:
Golang Lint (.)	2025-03-12T04:18:40.5082365Z ##[error]core/capabilities/ccip/ccipsolana/helpers.go:8:1: File is not properly formatted (goimports)
Golang Lint (.)	2025-03-12T04:18:40.5083412Z 	"github.com/gagliardetto/solana-go"
Golang Lint (.)	2025-03-12T04:18:40.5083837Z ^

Why: The file core/capabilities/ccip/ccipsolana/helpers.go is not formatted according to goimports standards.

Suggested fix: Run goimports on the file to automatically format it correctly.

4. File is not properly formatted (goimports): Golang Lint (.)

Source of Error:
Golang Lint (.)	2025-03-12T04:18:40.5084972Z ##[error]core/capabilities/ccip/oraclecreator/plugin.go:31:1: File is not properly formatted (goimports)
Golang Lint (.)	2025-03-12T04:18:40.5085868Z 	"github.com/smartcontractkit/libocr/commontypes"
Golang Lint (.)	2025-03-12T04:18:40.5086340Z ^

Why: The file core/capabilities/ccip/oraclecreator/plugin.go is not formatted according to goimports standards.

Suggested fix: Run goimports on the file to automatically format it correctly.

5. fmt.Errorf can be replaced with errors.New (perfsprint): Golang Lint (.)

Source of Error:
Golang Lint (.)	2025-03-12T04:18:40.5087453Z ##[error]core/capabilities/ccip/oraclecreator/plugin.go:449:36: fmt.Errorf can be replaced with errors.New (perfsprint)
Golang Lint (.)	2025-03-12T04:18:40.5088872Z 		return cctypes.OffChainConfig{}, fmt.Errorf("invalid offchain config: both commit and exec configs are either set or unset")
Golang Lint (.)	2025-03-12T04:18:40.5089917Z 		 ^

Why: The code uses fmt.Errorf where errors.New would be more appropriate for performance reasons.

Suggested fix: Replace fmt.Errorf with errors.New for the specified error message.

6. Uncommitted changes after generate step: Ensure clean after generate

Source of Error:
Ensure clean after generate	2025-03-12T04:21:52.7008095Z ##[error]Process completed with exit code 1.

Why: The Ensure clean after generate step found uncommitted changes in the repository after running the generate step, indicating that the generate step modified files that were not committed.

Suggested fix: Review the changes made by the generate step, commit them if they are correct, or adjust the generate step to avoid making unnecessary changes.

AER Report: Operator UI CI ran successfully ✅

aer_workflow , commit

@huangzhen1997 huangzhen1997 marked this pull request as draft February 14, 2025 21:47
@archseer
Copy link
Contributor

Let's delay merging this until some of the fixes from #15965 are merged or it'll cause conflicts on my branch

@cl-sonarqube-production
Copy link

Quality Gate failed Quality Gate failed

Failed conditions
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube

Catch issues before they fail your Quality Gate with our IDE extension SonarQube IDE SonarQube IDE

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