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

hack: restore JSON API compatibility #6844

Merged
merged 3 commits into from
May 24, 2022
Merged

Conversation

@matklad matklad requested a review from a team as a code owner May 20, 2022 09:26
@matklad matklad requested a review from mina86 May 20, 2022 09:26
@matklad
Copy link
Contributor Author

matklad commented May 20, 2022

@frol could you make a judgement call from the perspective of the clients whether this is a sufficient and necessary fix?

From the server perspective, this looks good to me (as in, cheap to support in the future)

Copy link
Contributor

@miraclx miraclx left a comment

Choose a reason for hiding this comment

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

From a client perspective, I think this is better.

Comment on lines +394 to +395
#[serde(default, rename = "contract_compile_base")]
pub _unused1: Gas,
Copy link
Contributor

Choose a reason for hiding this comment

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

How about we do this instead?

Suggested change
#[serde(default, rename = "contract_compile_base")]
pub _unused1: Gas,
#[serde(default)]
pub contract_compile_base: Option<Gas>,

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I rather like that _unused1 very clearly signals that you shouldn't use that. The Option would also get serialized as null, which I think might break somebody?

Copy link
Contributor

Choose a reason for hiding this comment

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

Why don’t we set the values to be the same as contract_loading_base and contract_loading_bytes respectively? To me it seems like a proper way to rename a field is to keep the old one for a couple releases to give people time to migrate.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can do that, but that requires writing custom code which might contain bugs. The current solution is significantly simpler than that.

My understanding that for this code we want to prioritize simplicity over compatibility. I think the problem here is just that the Rust code fails with deserialization error, rather than that someone actually looks at the old field.

Copy link
Collaborator

@frol frol 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 to me

Copy link
Contributor

@mina86 mina86 left a comment

Choose a reason for hiding this comment

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

I’m not thrilled that we’re start returning zeros to people to be honest.

@matklad
Copy link
Contributor Author

matklad commented May 24, 2022

I can see that :)

My overall hope is that there's some movement to fix #5516 (#6851, #6853), so hopefully this class of errors will be soon fixed by virtue of having a well-defined and separate API layer.

@near-bulldozer near-bulldozer bot merged commit 4c6adff into near:master May 24, 2022
near-bulldozer bot pushed a commit that referenced this pull request May 31, 2022
Tagged: https://github.com/near/nearcore/releases/tag/crates-0.14.0

Notable changes:

  - #6844
  - #6853
  - #6902
  - #6917
  - #6916

Check here for a full changelog: crates-0.13.0...crates-0.14.0

Tested `cargo package` on each public crate locally, they all compile independently of the workspace. We should be good to go.
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.

4 participants