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

pkg/reader: enforce non-copyability of ccip reader #149

Closed
wants to merge 1 commit into from

Conversation

makramkd
Copy link
Collaborator

@makramkd makramkd commented Sep 20, 2024

The CCIP reader is a shared object used by all processors from within the plugin.

In order to enforce it always being passed by pointer ensure that it is non-copyable by embedding a mutex.

Note that trying to copy the object will not cause compilation failures but linting failures.

Copy link

Test Coverage

Branch Coverage
mk/ccip-reader-nonCopyable 71.7%
main 71.6%

@makramkd makramkd marked this pull request as ready for review September 20, 2024 15:01
@makramkd makramkd requested a review from a team as a code owner September 20, 2024 15:01
@@ -30,6 +30,9 @@ import (
// TODO: unit test the implementation when the actual contract reader and writer interfaces are finalized and mocks
// can be generated.
type ccipChainReader struct {
// to prevent copying this struct.
_ sync.Mutex
Copy link
Contributor

Choose a reason for hiding this comment

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

Are you sure this works?

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds like there are some linters that prevent the copying, so better than nothing.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, its linter based, not build based unfortunately.

@winder
Copy link
Contributor

winder commented Sep 20, 2024

Pretty sure we don't need this because ptr receivers are used everywhere.

@winder winder closed this Sep 20, 2024
@makramkd makramkd deleted the mk/ccip-reader-nonCopyable branch September 20, 2024 18:23
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.

2 participants