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 back in Protocol 22 non-breaking changes for a transition period #317

Merged
merged 5 commits into from
Oct 25, 2024

Conversation

Shaptic
Copy link
Contributor

@Shaptic Shaptic commented Oct 23, 2024

What

This PR smooths out the breaking changes to Stellar RPC's API to make it possible for users to upgrade SDKs without experiencing breakage. Namely,

  • Previously, in RC2, getTransaction would encode createdAt as a string instead of number. This change has been reverted. We will continue to encode it as a number (specifically, a uint32).
  • Previously, getEvents replaced pagingToken with cursor within each event for pagination. This change is now additive, and the response schema will now include both fields.
  • Previously, getVersionInfo would now use camelCasing over snake_case. This change is now additive. The response schema will contain both variants:
interface GetVersionInfoResponse {
  version: string;
  commitHash: string;
  buildTimestamp: string;
  captiveCoreVersion: string;
  protocolVersion: number; // uint32
  /// Deprecated field names:
  commit_hash: string;
  build_timestamp: string;
  captive_core_version: string;
  protocol_version: number; // uint32
}

Why

When a user upgrades to the latest version of your SDK, their code will now only be compatible with a v22.* version of the backend services they're connected to. This means they can only upgrade exactly when their RPC/Horizon provider upgrades, which is a violation of the previous compatibility guarantees we provide the ecosystem.

A concrete example: someone with an existing codebase may have code written that uses the createdAt field returned by rpc.getTransaction. If they upgrade to the latest version, their code will break because the field is now strictly typed as a string. And yet, if they were to update their code accordingly, their code would not function unless they pointed at a v22 RPC. This is the lockstep upgrade we are trying to avoid. This is in contrast to a change like cost being removed, because they can write code that works on both v21 and v22 RPCs by using the existing transactionData field to migrate.

This PR smooths those things out.

@Shaptic Shaptic requested a review from aditya1702 October 24, 2024 19:23
@Shaptic Shaptic assigned 2opremio and unassigned 2opremio Oct 24, 2024
@Shaptic Shaptic requested review from tamirms and 2opremio October 24, 2024 19:24
@Shaptic Shaptic added api-change Any changes to existing API or addition of new API bug Something isn't working labels Oct 24, 2024
@Shaptic Shaptic marked this pull request as ready for review October 24, 2024 19:24
@Shaptic Shaptic merged commit 5932852 into protocol22 Oct 25, 2024
17 checks passed
@Shaptic Shaptic deleted the p22-non-breaking branch October 25, 2024 19:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-change Any changes to existing API or addition of new API bug Something isn't working
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants