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

Closed

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
    Initialize[init: currentBlockHeight = 0] --> prepareRequest[prepare request]
    
    prepareRequest --> isRequestBlockSensitive[is request block height sensitive]

    isRequestBlockSensitive --> isSensitive[yes]
    isRequestBlockSensitive --> isNotSensitive[no]

    isSensitive --> addBlockHeight[inform required block height]

    addBlockHeight --> sendRequest[send request]

    isNotSensitive --> sendRequest[send request]


    sendRequest --> response[response has block height error?]

    response --> blockHeightError(yes)
    response --> noBlockHeightError(no)

    blockHeightError --> shouldRetry(should retry?)

    shouldRetry --> retry(yes)
    shouldRetry --> noRetry(no)

    retry --> wait(wait)
    wait --> sendRequest

    noRetry --> throwError(throw error)

    noBlockHeightError --> extractBlockHeight(extract block height from response)

    extractBlockHeight --> isHigher

    isHigher[is value higher than current?]

    isHigher --> higher[yes]
    isHigher --> nonHigher[no]

    higher --> updateBlockHeight[set new value]
    updateBlockHeight --> End[end]
    
    nonHigher --> 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 25, 2025 0:30am
ts-docs ❌ Failed (Inspect) Feb 25, 2025 0:30am
ts-docs-api ❌ Failed (Inspect) Feb 25, 2025 0:30am

@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.

@Torres-ssf
Copy link
Contributor Author

Closing in favor of #3741

@Torres-ssf Torres-ssf closed this Feb 27, 2025
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
3 participants