Skip to content
This repository has been archived by the owner on Nov 16, 2022. It is now read-only.

Remote Data Source Executor

Sawit Trisirisatayawong edited this page Jun 2, 2020 · 8 revisions

The remote data source executor executes the data source scripts that are stored on BandChain in order to retrieve data from the data providers. The executor itself is a Function-as-a-Service hosted on a cloud service provider, and is intended to separate data source script execution processes from those related to the validator node itself. From a validator's perspective, all they have to do to execute a data source is to send an executable file content in JSON format (the data source script), along with the relevant calldata, to an endpoint.

This separation of execution aims to prevent the validator nodes from being overloaded or from crashing in cases where the data sources are not working properly (e.g. infinite loop, bad code execution, etc.).

Resource

Endpoint HTTP Request Method Description
/execute POST execute data source script

Request

Headers

"content-type": “application/json”

JSON Body

Field Type Description
executable string Base64-encoded data source script that the executor will execute
calldata string Bash-encoded input parameters of data source script
timeout number Execution time limit (millisecond)
Example
{
"executable": "IyEvYmluL3NoXG5cbnN5bWJvbD0kMVxuXG4jIENyeXB0b2N1cnJlbmN5IHByaWNlIGVuZHBvaW50OiBodHRwczovL3d3dy5jb2luZ2Vja28uY29tL2FwaS9kb2N1bWVudGF0aW9ucy92M1xudXJsPVwiaHR0cHM6Ly9hcGkuY29pbmdlY2tvLmNvbS9hcGkvdjMvc2ltcGxlL3ByaWNlP2lkcz0kc3ltYm9sJnZzX2N1cnJlbmNpZXM9dXNkXCJcblxuIyBQZXJmb3JtcyBkYXRhIGZldGNoaW5nIGFuZCBwYXJzZXMgdGhlIHJlc3VsdFxuY3VybCAtcyAtWCBHRVQgJHVybCAtSCBcImFjY2VwdDogYXBwbGljYXRpb24vanNvblwiIHwganEgLWVyIFwiLltcXFwiJHN5bWJvbFxcXCJdLnVzZFwiXG4=",
"calldata": "bitcoin"
}

Response:

Headers

"content-type":  "application/json",
"access-control-allow-methods":  "OPTIONS, POST",

JSON Body

Field Type Description
returncode number exit code 0-255
stdout string data source script output
stderr string data source script error output
error string "" or error message from executor
400 Bad Request
Error Error message
Missing executable value executable field is missing from JSON request
Missing calldata value calldata field is missing from JSON request
Missing timeout value timeout field is missing from JSON request
Executable value exceed executable value exceed max size
Calldata value exceed calldata exceeded max size
Runtime value exceed Runtime exceeded max size
Invalid timeout format timeout type is invalid
200 OK
Exit code Description Error Message
0 - 255 Executable errors from data source script run successfully N/A
111 Execution timeout Execution time limit exceeded
112 Stdout exceed Stdout exceeded max size
113 Stderr exceed Stderr exceeded max sizeed
126 Execution fail Data source script could not be invoked