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

Add support for Maps to the reflect_codec #1790

Merged
merged 32 commits into from
Aug 11, 2023

Conversation

nytzuga
Copy link
Contributor

@nytzuga nytzuga commented Aug 2, 2023

Support to serialize/deserialize maps with the reflect_codec. This is needed in the subnet EMV to use it to exchange information about the upgrade configs.

This PR adds support for maps and tests it.

The internal binary format is quite simple

    [length: 4 bytes][key1][value1][key2][value2]

The length is the total number of elements and keys, therefore it should always be a pair number.

Why this should be merged

How this works

How this was tested

@nytzuga nytzuga requested a review from danlaine as a code owner August 2, 2023 00:07
@nytzuga nytzuga force-pushed the add-support-for-map-into-reflectcodec branch 3 times, most recently from 726dc65 to e526eba Compare August 2, 2023 00:53
@patrick-ogrady patrick-ogrady marked this pull request as draft August 2, 2023 04:22
@nytzuga nytzuga changed the title Draft: Add support for Maps to the reflect_codec Add support for Maps to the reflect_codec Aug 2, 2023
@nytzuga nytzuga self-assigned this Aug 2, 2023
Copy link
Contributor

@ceyonur ceyonur left a comment

Choose a reason for hiding this comment

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

A great feature for codec 💯

codec/reflectcodec/type_codec.go Show resolved Hide resolved
codec/reflectcodec/type_codec.go Show resolved Hide resolved
codec/reflectcodec/type_codec.go Outdated Show resolved Hide resolved
codec/reflectcodec/type_codec.go Show resolved Hide resolved
codec/reflectcodec/type_codec.go Outdated Show resolved Hide resolved
codec/test_codec.go Outdated Show resolved Hide resolved
Copy link

@danlaine danlaine left a comment

Choose a reason for hiding this comment

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

see comments

@nytzuga nytzuga force-pushed the add-support-for-map-into-reflectcodec branch from a7c556e to acf8c70 Compare August 2, 2023 21:11
@nytzuga nytzuga force-pushed the add-support-for-map-into-reflectcodec branch 3 times, most recently from 734c5ce to c940c9d Compare August 3, 2023 03:46
codec/reflectcodec/type_codec.go Outdated Show resolved Hide resolved
codec/reflectcodec/type_codec.go Outdated Show resolved Hide resolved
codec/reflectcodec/type_codec.go Outdated Show resolved Hide resolved
codec/reflectcodec/type_codec.go Outdated Show resolved Hide resolved
codec/test_codec.go Show resolved Hide resolved
@nytzuga nytzuga requested a review from ceyonur August 3, 2023 16:46
@nytzuga nytzuga marked this pull request as ready for review August 3, 2023 17:00
codec/reflectcodec/type_codec.go Outdated Show resolved Hide resolved
codec/reflectcodec/type_codec.go Outdated Show resolved Hide resolved
@nytzuga nytzuga force-pushed the add-support-for-map-into-reflectcodec branch from eb8fc0f to 287b05f Compare August 11, 2023 15:15
@StephenButtolph StephenButtolph changed the base branch from master to dev August 11, 2023 19:00
@StephenButtolph StephenButtolph added this to the v1.10.9 milestone Aug 11, 2023
@StephenButtolph StephenButtolph added the sdk This involves SDK tooling or frameworks label Aug 11, 2023
codec/test_codec.go Outdated Show resolved Hide resolved
Co-authored-by: Dhruba Basu <7675102+dhrubabasu@users.noreply.github.com>
Signed-off-by: Cesar <137245636+nytzuga@users.noreply.github.com>
@StephenButtolph StephenButtolph merged commit dfa3009 into dev Aug 11, 2023
14 checks passed
@StephenButtolph StephenButtolph deleted the add-support-for-map-into-reflectcodec branch August 11, 2023 22:29
nytzuga added a commit to ava-labs/subnet-evm that referenced this pull request Aug 14, 2023
The goal of the this codec is to serialize `params.UpgradeConfig` in a
deterministic way, to be hashed later. This hash is going to be share by nodes
at handshake, so they can determine if they have the same upgrade config.

This PR leverages the newly introduced support to serilize Maps
ava-labs/avalanchego#1790, which are deterministic (the
values are sorted by keys before serializing)
nytzuga added a commit to ava-labs/subnet-evm that referenced this pull request Aug 14, 2023
The goal of the this codec is to serialize `params.UpgradeConfig` in a
deterministic way, to be hashed later. This hash is going to be share by nodes
at handshake, so they can determine if they have the same upgrade config.

This PR leverages the newly introduced support to serilize Maps
ava-labs/avalanchego#1790, which are deterministic (the
values are sorted by keys before serializing)
nytzuga added a commit to ava-labs/subnet-evm that referenced this pull request Aug 14, 2023
The goal of the this codec is to serialize `params.UpgradeConfig` in a
deterministic way, to be hashed later. This hash is going to be share by nodes
at handshake, so they can determine if they have the same upgrade config.

This PR leverages the newly introduced support to serilize Maps
ava-labs/avalanchego#1790, which are deterministic (the
values are sorted by keys before serializing)
nytzuga added a commit to ava-labs/subnet-evm that referenced this pull request Aug 14, 2023
Update the reference to avalanchego@dev to test the feature. The needed feature
ava-labs/avalanchego#1790 is only supported in dev.
nytzuga added a commit to ava-labs/subnet-evm that referenced this pull request Sep 8, 2023
The goal of the this codec is to serialize `params.UpgradeConfig` in a
deterministic way, to be hashed later. This hash is going to be share by nodes
at handshake, so they can determine if they have the same upgrade config.

This PR leverages the newly introduced support to serilize Maps
ava-labs/avalanchego#1790, which are deterministic (the
values are sorted by keys before serializing)
nytzuga added a commit to ava-labs/subnet-evm that referenced this pull request Sep 14, 2023
The goal of the this codec is to serialize `params.UpgradeConfig` in a
deterministic way, to be hashed later. This hash is going to be share by nodes
at handshake, so they can determine if they have the same upgrade config.

This PR leverages the newly introduced support to serilize Maps
ava-labs/avalanchego#1790, which are deterministic (the
values are sorted by keys before serializing)
nytzuga added a commit to ava-labs/subnet-evm that referenced this pull request Sep 26, 2023
The goal of the this codec is to serialize `params.UpgradeConfig` in a
deterministic way, to be hashed later. This hash is going to be share by nodes
at handshake, so they can determine if they have the same upgrade config.

This PR leverages the newly introduced support to serilize Maps
ava-labs/avalanchego#1790, which are deterministic (the
values are sorted by keys before serializing)
nytzuga added a commit to ava-labs/subnet-evm that referenced this pull request Oct 11, 2023
The goal of the this codec is to serialize `params.UpgradeConfig` in a
deterministic way, to be hashed later. This hash is going to be share by nodes
at handshake, so they can determine if they have the same upgrade config.

This PR leverages the newly introduced support to serilize Maps
ava-labs/avalanchego#1790, which are deterministic (the
values are sorted by keys before serializing)
nytzuga added a commit to ava-labs/subnet-evm that referenced this pull request Oct 11, 2023
The goal of the this codec is to serialize `params.UpgradeConfig` in a
deterministic way, to be hashed later. This hash is going to be share by nodes
at handshake, so they can determine if they have the same upgrade config.

This PR leverages the newly introduced support to serilize Maps
ava-labs/avalanchego#1790, which are deterministic (the
values are sorted by keys before serializing)
nytzuga added a commit to ava-labs/subnet-evm that referenced this pull request Oct 13, 2023
The goal of the this codec is to serialize `params.UpgradeConfig` in a
deterministic way, to be hashed later. This hash is going to be share by nodes
at handshake, so they can determine if they have the same upgrade config.

This PR leverages the newly introduced support to serilize Maps
ava-labs/avalanchego#1790, which are deterministic (the
values are sorted by keys before serializing)
nytzuga added a commit to ava-labs/subnet-evm that referenced this pull request Nov 2, 2023
The goal of the this codec is to serialize `params.UpgradeConfig` in a
deterministic way, to be hashed later. This hash is going to be share by nodes
at handshake, so they can determine if they have the same upgrade config.

This PR leverages the newly introduced support to serilize Maps
ava-labs/avalanchego#1790, which are deterministic (the
values are sorted by keys before serializing)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sdk This involves SDK tooling or frameworks
Projects
No open projects
Archived in project
Development

Successfully merging this pull request may close these issues.

7 participants