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

Flow API Script Execution Integration with DPS #2573

Closed
AliSMAmin opened this issue Jun 8, 2022 · 3 comments
Closed

Flow API Script Execution Integration with DPS #2573

AliSMAmin opened this issue Jun 8, 2022 · 3 comments

Comments

@AliSMAmin
Copy link

Problem Definition

On Flow, scripts query (read) the blockchain state, unlike transactions (write calls) which mutate blockchain state.
Without DPS, Access Nodes delegate script execution to Execution Nodes. This is very read-heavy and poses numerous scalability concerns. When deployed, DPS provides access to the execution state at any block height and does not increase main network load.

The Flow API Service will serve as an entry-point API for both transactions and Cadence scripts. While transactions will still make their way to the network through an Access Node, ExecuteScript requests should be sent to DPS for local script execution.

Proposed Solution

• Interface on Flow API translates script execution requests into DPS API calls
• Flow API handles routing of scripts (read-only) to the corresponding target
• Flow API communicates with DPS API for local script execution, running against indexed state data
• Leverage DPS for state indexing and local script execution, reducing load on Execution Nodes
• Integration with the Cadence Client Library, so that clients can execute scripts

Step Definitions

• Implement DPS API-Access API translation interface for script execution on the Flow API
• Endpoints for Cadence scripts should use the DPS client to execute against the DPS API and return the results

Definition of Done

• Read-only Cadence script against the latest sealed execution state rpc ExecuteScriptAtLatestBlock (ExecuteScriptAtLatestBlockRequest) returns (ExecuteScriptResponse)
• Read-only Cadence script against the execution state of a block with a given ID, to read account state, rpc ExecuteScriptAtBlockID (ExecuteScriptAtBlockIDRequest) returns (ExecuteScriptResponse)
• Read-only Cadence script against the execution state at a particular block height rpc ExecuteScriptAtBlockHeight (ExecuteScriptAtBlockHeightRequest) returns (ExecuteScriptResponse)
• Calls for read-only scripts are routed from Flow API Service to DPS
• Results returned from DPS API are served to clients
• If there is no downstream DPS, an error is returned
• DPS executes scripts locally, runs state queries from its local IndexDB, and returns results through the DPS API.
• DPS indexed blockchain state is used to answer script execution requests from the DPS API.
• Those answers and synced state data are cached for timely future access.

@AliSMAmin
Copy link
Author

All relevant method mappings are delineated in: https://github.com/optakt/flow-dps-access

@szegedim
Copy link
Contributor

szegedim commented Aug 1, 2022

Here is the passing test for this change on the Access APi: https://github.com/GetElastech/api-service/actions/runs/2776003280
@A-town21, what needs to be added is that clientExecution() should include a call to clientDPS(), if a DPS node is configured.

@szegedim
Copy link
Contributor

szegedim commented Aug 1, 2022

This is in src/cmd/proxy/proxy.go

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants
@franklywatson @j1010001 @szegedim @A-town21 @AliSMAmin and others