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
API 2.0 #149
API 2.0 #149
Conversation
proto/spacemesh/v1/app_types.proto
Outdated
// Information about an app template in the global state store | ||
message Template { | ||
TemplateAddress address = 1; // template address | ||
string name = 2; // template name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comment in issue, I don't understand why this is required
proto/spacemesh/v1/app_types.proto
Outdated
// but is convenient to return them directly as part of apps' metadata. | ||
message App { | ||
AccountId address = 1; // App's address in global space | ||
string name = 2; // short descriptive name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is good to have a short app name that describes it. I think that it is something that is set by spwaner and spawn time per app.
proto/spacemesh/v1/app_types.proto
Outdated
AccountId address = 1; // App's address in global space | ||
string name = 2; // short descriptive name | ||
TemplateAddress template_address = 3; // App's template address | ||
LayerNumber spawn_layer = 4; // Layer in which app was spawned |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which field? These are all meta-data about an app which is useful. It is useful to know in which layer an app was deployed to the mesh although this info can be obtained from the spawn transaction - it is just convince to include some metadata that can be obtained from transactions about the app in response to this call because the intent of the caller is to get this data.
repeated Template templates = 2; | ||
} | ||
|
||
// A request to get an app's variable by var id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of "variable" can we give these a more descriptive name, e.g., state entry?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@YaronWittenstein said these are called "storage variables" in SVM
// A request to get an app's variable by var id | ||
message GetVariableRequest { | ||
AccountId address = 1; // app's address | ||
LayerNumber layer_number = 2; // requested value as of a layer. Pass MAX_UI32 to get latest value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As noted in the issue, will only work for archival nodes! What do non-archival nodes do if this is specified? Error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my comment there - full nodes will hold state for n layers back and archive nodes since genesis but from an api level it is good to have this like this and nodes will return not_found status if they can't satisfy this specific request for a layer which is not recent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that works, but for the record, we cannot force full nodes to hold intermediate state for any minimum number of layers since this is extraprotocol
proto/spacemesh/v1/app_types.proto
Outdated
message GetVariableRequest { | ||
AccountId address = 1; // app's address | ||
LayerNumber layer_number = 2; // requested value as of a layer. Pass MAX_UI32 to get latest value | ||
uint32 id = 3; // app's var id - var's unique identifier |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where does the caller look this up?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Caller has the app's schema which includes the variable ids.
Add name to log entry
Co-authored-by: Lane Rettig <lanerettig@gmail.com>
@lrettig @YaronWittenstein - I've updated the api to reflect the design review session feedback. I still believe we should have a strongly typed GetVariable() method which is very useful for quick access to app state by dapps. Perhaps we can proceed before another review session by you guys just reviewing the most recent changes? The relent types are in app_types.proto, var_types.proto and global_state.proto |
@YaronWittenstein @lrettig - please check the code - I think I've incorporated everything we talked about and removed non-app related changes from this pr. |
string target_svm_version = 4; // at deploy time | ||
string kind = 5; // e.g. WASM | ||
repeated bytes code = 6; // wasm code | ||
string target_svm_version = 1; // at deploy time |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be an int not a string
string kind = 5; // e.g. WASM | ||
repeated bytes code = 6; // wasm code | ||
string target_svm_version = 1; // at deploy time | ||
string kind = 2; // e.g. WASM |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be an enum not a string
Code code = 2; // template wasm code. Provided if caller specified to get code. | ||
bytes metadata = 3; // storage layout, api, header. Provided if caller specified to get metadata and template include metadata. | ||
Code code = 1; // template wasm code. Provided if caller specified to get code. | ||
bytes metadata = 2; // storage layout, api, header. Provided if caller specified to get metadata and template include metadata. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bytes metadata = 2; // storage layout, api, header. Provided if caller specified to get metadata and template include metadata. | |
bytes metadata = 2; // storage layout, api, header. Provided if caller specified to get metadata and template including metadata. Caller is responsible for decoding. |
} | ||
|
||
enum TemplateDataFlags { | ||
TEMPLATE_DATA_FLAGS_UNSPECIFIED = 0; | ||
TEMPLATE_DATA_FLAGS_CODE = 1; | ||
TEMPLATE_DATA_FLAGS_METADATA = 2; | ||
// may need deploy data section - tbd - based on deploy tx format. Understand eth one. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// may need deploy data section - tbd - based on deploy tx format. Understand eth one. | |
// TODO: may need deploy data section - tbd - based on deploy tx format. Understand eth one. |
AccountId address = 1; // App's address in global space | ||
string name = 2; // short descriptive name (optional) | ||
TemplateAddress template_address = 3; // App's template address | ||
LayerNumber spawn_layer = 4; // Layer in which app was spawned |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as discussed today, these also belong in metadata, as they're not required by SVM. they can optionally be automatically populated at deploy time if the deployer requests this, and pays for it.
repeated Template templates = 2; | ||
} | ||
|
||
// A request to get an app's variable by var id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@YaronWittenstein said these are called "storage variables" in SVM
TRANSACTION_RESULT_INSTANTIATION_FAILED = 9; // error creating an instance from a template | ||
TRANSACTION_RESULT_DEPLOY_FAILED = 10; // error deploying a template to the mesh | ||
TRANSACTION_RESULT_RUNTIME_EXCEPTION = 2; // app code execution exception= | ||
TRANSACTION_RESULT_VALIDATION_FAILED = 3; // TBD |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TRANSACTION_RESULT_VALIDATION_FAILED = 3; // TBD | |
TRANSACTION_RESULT_VALIDATION_FAILED = 3; // TODO: do we need this? can an invalid tx ever make it into a superblock? |
Renamed pr to api 2.0 as it is not going to be backward compatible with 1.x api due to some breaking changes. |
I think we need to update this so the output proto files go into |
Draft PR to review and discuss GlobalState service changes to support Spacemesh Apps in release 0.3.