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

[x/programs] pass error messages from host functions #666

Closed
samliok opened this issue Jan 6, 2024 · 4 comments
Closed

[x/programs] pass error messages from host functions #666

samliok opened this issue Jan 6, 2024 · 4 comments
Assignees

Comments

@samliok
Copy link
Contributor

samliok commented Jan 6, 2024

Currently if our host function throws an error we propagate it up the runtime and stop executing the program.

Defining a common hostResponse in the host and guest would provide a more descriptive error handling framework. A potential struct like this would give us more programability and allow us to better handle different responses in the guest.

type  MsgLevel  int
const (
	None MsgLevel  =  iota
	Info
	Error
	Panic
)
type hostResponse struct {
	value int64
	level MsgLevel
	message []byte
}

the host function would convert a hostResponse to a smartPtr and then return as *types.Val in order to match the required function signature. Or it can stop program execution by throwing an error.

For example, the getFn host function returns -1 if it cannot find a key in its db. It also returns a -1 if it cannot grab bytes from memory(a more serious error). These errors are not descriptive. Even with the new refactor of #660, some errors should still be passed to the host while others can stop the runtime.

@richardpringle
Copy link
Contributor

Seems like this is linked with #595?

@richardpringle
Copy link
Contributor

See specific comment from the above PR here
#737 (comment)

Copy link

This issue has become stale because it has been open 60 days with no activity. Adding the lifecycle/frozen label will exempt this issue from future lifecycle events.

@richardpringle
Copy link
Contributor

Closing this in favour of #595. Host functions (with the exception of external calls) should not return Result.

@github-project-automation github-project-automation bot moved this from Backlog 🗄️ to Done ✅ in Platform Engineering Group Jun 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants