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

create new codec with correct type #752

Merged
merged 3 commits into from
Jan 17, 2025
Merged

Conversation

ceyonur
Copy link
Collaborator

@ceyonur ceyonur commented Jan 16, 2025

Why this should be merged

Replaces error-prone sync summary type registration with a initializer that returns codec.

How this works

Codec Management Refactoring:

Updates to Atomic Sync Summary:

Test Updates:

Minor Changes:

How this was tested

Existing tests should cover this

Need to be documented?

No

Need to update RELEASES.md?

No

@ceyonur ceyonur requested review from darioush and a team as code owners January 16, 2025 19:54
plugin/evm/message/syncable.go Show resolved Hide resolved

func init() {
var err error
networkCodec, err = message.NewCodec(message.BlockSyncSummary{})
Copy link
Collaborator

@darioush darioush Jan 16, 2025

Choose a reason for hiding this comment

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

nit: should we name this testCodec? (or have a package we could import and use like messagetest.Codec?)
we could also have a function like newTestCodec(t), but I don't know if it is worth this change here given the other code follows the pattern with init

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

hmm it could be a bit weird to export it for tests but not for prod code.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I intentionally avoided to export it so that it won't be mistakenly imported from message pkg everytime.

warp/service.go Show resolved Hide resolved
// codecWithAtomicSync is the codec manager that contains the codec for AtomicBlockSyncSummary and
// other message types that are used in the network protocol. This is to ensure that the codec
// version is consistent across all message types and includes the codec for AtomicBlockSyncSummary.
var codecWithAtomicSync codec.Manager
Copy link
Collaborator

@darioush darioush Jan 16, 2025

Choose a reason for hiding this comment

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

this was a little confusing to me since it's not used in the production code path, could we move it to the test file?

(should ParseFromBytes use this instead of atomic.Codec?)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I got even more confused why and how this was not a problem and put up a UT. Seems we don't really care about if a type is registered or not in linearcodec unless we marshal/unmarshal with an interface.

@darioush darioush mentioned this pull request Jan 16, 2025
@ceyonur ceyonur merged commit bd65190 into move-atomic-sync Jan 17, 2025
6 checks passed
@ceyonur ceyonur deleted the sync-type-codec branch January 17, 2025 16:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants