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

feat: support optimistic concurrency control headers #3462

Draft
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

Torres-ssf
Copy link
Contributor

@Torres-ssf Torres-ssf commented Dec 9, 2024

Release notes

In this release, we:

  • Implement support for configurable fuel_block_height

Summary

flowchart TD
    %% Initialization
    Initialize[Initialize currentBlockHeight= 0] --> PrepareRequest[Prepare GraphQL Request]
    
    PrepareRequest --> IsRequestBlockSensitive[Is Request Block Height Sensitive]

    IsRequestBlockSensitive --> IsSensitive[Yes]
    IsRequestBlockSensitive --> IsNotSensitive[No]

    IsSensitive --> AddBlockHeight[Add Required Block Height To Request Body]

    AddBlockHeight --> SendRequest[Send Request]

    IsNotSensitive --> SendRequest[Send Request]


    SendRequest --> WaitForResponse[Wait For Response]

    WaitForResponse --> ExtractBlockHeight[Extract Current Block Height From Response Data]

    ExtractBlockHeight --> IsHigher

    IsHigher[Is Extracted Value Higher Than currentBlockHeight?]

    IsHigher --> Higher[Yes]
    IsHigher --> NonHigher[No]

    Higher --> UpdateBlockHeight[Set New Value To currentBlockHeight]
    UpdateBlockHeight --> End[End]
    
    NonHigher --> End[End]
Loading

Checklist

  • All changes are covered by tests (or not applicable)
  • All changes are documented (or not applicable)
  • I reviewed the entire PR myself (preferably, on GH UI)
  • I described all Breaking Changes (or there's none)

Copy link

vercel bot commented Dec 9, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
fuels-template ❌ Failed (Inspect) Feb 13, 2025 6:15pm
ts-docs ❌ Failed (Inspect) Feb 13, 2025 6:15pm
ts-docs-api ❌ Failed (Inspect) Feb 13, 2025 6:15pm

@Torres-ssf

This comment was marked as resolved.

@Torres-ssf Torres-ssf force-pushed the st/feat/add-headers-for-optimistic-concurrency-control branch from d80fbd7 to cce2ba3 Compare February 12, 2025 12:06
@Torres-ssf

This comment was marked as resolved.

@Torres-ssf
Copy link
Contributor Author

Blocked by the next fuel-core minor release, probably 0.42.0

const gqlClient = new GraphQLClient(this.urlWithoutAuth, {
fetch: (input: RequestInfo | URL, requestInit?: RequestInit) =>
fetchFn(input.toString(), requestInit || {}, this.options),
responseMiddleware: (response: GraphQLClientResponse<unknown> | Error) => {
this.setCurrentBlockHeight(response as { extensions: unknown });
Copy link
Member

Choose a reason for hiding this comment

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

@Torres-ssf Because the node waiting time threshold is dynamic and can be changed or disabled at any time, we must validate the response and implement the whole timing/check/retry independently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat Issue is a feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Review and Add Special Headers for Optimistic Concurrency Control
2 participants