Skip to content

[DataAvailability] Implement fork-aware Script Endpoints#7952

Merged
peterargue merged 118 commits intofeature/optimistic-syncfrom
UlianaAndrukhiv/7651-fork-aware-script-endpoints
Nov 20, 2025
Merged

[DataAvailability] Implement fork-aware Script Endpoints#7952
peterargue merged 118 commits intofeature/optimistic-syncfrom
UlianaAndrukhiv/7651-fork-aware-script-endpoints

Conversation

@UlyanaAndrukhiv
Copy link
Copy Markdown
Contributor

@UlyanaAndrukhiv UlyanaAndrukhiv commented Sep 24, 2025

Note:

Closes: #7651

Related PR:

Context

  • Refactored ScriptExecutor interface and impl (according to suggestion in comment).
  • Create a new storage interface RegisterSnapshotReader to handle the range checks.
  • Updated backend endpoints (ExecuteScriptAtLatestBlock, ExecuteScriptAtBlockHeight, ExecuteScriptAtBlockID).
  • Added arguments to backend implementation to specify user query criteria.
  • Updated gRPC and REST handlers to extract and pass criteria from requests.
  • Updated test according to changes.
  • Updated error handling to use the new [Access] Add draft of access api error framework #7106
  • Updated and added missed godoc for related files and types.

… nodes, added mocked version for Registers in snapshot. Linted
…ub.com:onflow/flow-go into UlianaAndrukhiv/7651-fork-aware-script-endpoints
Co-authored-by: Peter Argue <89119817+peterargue@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

@peterargue peterargue left a comment

Choose a reason for hiding this comment

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

mostly small comments. this is probably the last set of comments.

Comment on lines 145 to 148
var failure fvmerrors.CodedFailure
if fvmerrors.As(err, &failure) {
return rpc.ConvertError(err, "failed to execute script", codes.Internal)
return access.NewInternalError(err)
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

CodedFailures are actually exceptions.

Copy link
Copy Markdown
Contributor Author

@UlyanaAndrukhiv UlyanaAndrukhiv Nov 11, 2025

Choose a reason for hiding this comment

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

I’m not fully sure I follow - do you mean that fvmerrors.CodedFailure represents an irrecoverable condition rather than a normal, expected internal error? (I’m asking because of the FailureCodeLedgerFailure, which is a FailureCode)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yes. For instance FailureCodeLedgerFailure means that the script failed to read data from the db. since the reads within scripts do not return an error for not found, this means there was an exception.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Got it! Updated in 13868e2

// A result value is returned encoded as byte array. An error will be returned if script
// doesn't successfully execute.
// Expected errors:
// - Script execution related errors
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

looking at the error handling, I think we already handle these properly for script execution. we just need to adjust the error docs

Copy link
Copy Markdown
Contributor

@illia-malachyn illia-malachyn 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!


// ExecuteScriptAtBlockID executes provided script at the provided block ID.
//
// CAUTION: this layer SIMPLIFIES the ERROR HANDLING convention
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't like the fact that we repeat this wording everywhere. I understand it might be useful if you use these functions from a different module (e.g. while working on sth on execution node). However, I don't think the protocol code would ever depend on abstractions from an access node. It also feels like either: a) package/file level comment. b) contract in access node with which everyone in the team is aware of (which also could be documented in package/file level godoc)

Perhaps, we can have wth like access/doc.go with the explanation about error handling?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I agree. This seems useful only at the API interface level, so I’ve removed it in 4319e83

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

please add this back. Alex requested we include this for all endpoint methods (implementation and interface definitions).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sure, added back in 322e12a

@peterargue peterargue merged commit d0fba52 into feature/optimistic-sync Nov 20, 2025
57 checks passed
@peterargue peterargue deleted the UlianaAndrukhiv/7651-fork-aware-script-endpoints branch November 20, 2025 15:06
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.

[DataAvailability] Implement fork-aware Script Endpoints

4 participants