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

New Smesher API #145

Merged
merged 13 commits into from
Jul 26, 2021
Merged

New Smesher API #145

merged 13 commits into from
Jul 26, 2021

Conversation

moshababo
Copy link
Contributor

@moshababo moshababo commented May 24, 2021

Main remarks:

  • Most methods which were directly dealing with the PoST setup were removed.
  • Changed IsSmeshing() -> bool with SmeshingStatus() -> [IDLE, CREATING_POST_DATA, ACTIVE]. Since Smeshing now triggers the PoST setup, we have an intermediate stage in which we are neither idle or Smeshing (NOTE: ACTIVE is probably a bad name because it has nothing to do with the activation status of the miner).
  • As previously discussed, PostStatus() query is no longer supported (because a status can be evaluated only in relation to aPostInitOpts arg), besides within PostDataCreationProgressStream, which is supported only when a PoST data creation session is active. For this reason I changed the status message name to SessionStatus and removed most of its fields (files_status, init_in_progress, error_type, error_message), while keeping only num_labels_written (instead of bytes_written). We can rethink this and decide whether we want to expose errors within the stream or elsewhere, asynchronously.
  • Within PostInitOpts the user is now to select its commitment size via num_units instead of data_size. For evaluating the size in bytes, clients are expected to query Config() which specifies labels_per_unit and bits_per_label.
  • PostComputeProviders() now have bool benchmark, to avoid imposing the benchmark procedure delay by default (for example when a client wants to enumerate the providers for ID validation purposes).

# Conflicts:
#	proto/spacemesh/v1/smesher.proto
#	release/go/spacemesh/v1/smesher.pb.go
#	release/go/spacemesh/v1/smesher_types.pb.go
@moshababo moshababo requested review from avive and lrettig May 24, 2021 04:05
proto/spacemesh/v1/smesher_types.proto Outdated Show resolved Hide resolved
proto/spacemesh/v1/smesher_types.proto Outdated Show resolved Hide resolved
proto/spacemesh/v1/smesher_types.proto Outdated Show resolved Hide resolved
@moshababo
Copy link
Contributor Author

Changes:

  • Returned SmeshingStatus() -> [IDLE, CREATING_POST_DATA, ACTIVE] to IsSmeshing() -> bool.
    It’s referring solely to the phase in which post setup completed and ATX creation started.
  • Returned PostStatus() on a limited-scope. If setup started, it’s referring to the current/latest PostInitOpts, otherwise to none. Its response is identical to PostDataCreationProgressStream's.
  • The error in PostStatus() is not mutually-exclusive with other fields, so I did not use the Oneof protobuf pattern.
    It can be made mutually-exclusive in PostDataCreationProgressStream, but I thought it’s not necessary, and keeping it identical to PostStatus()'s response is preferred.

We need to conclude the terminology dicsussion so I could finalize the documentation and how we name things. Currently, “pos”, “pos setup”, “post data creation”, “post init”, “post setup” are used interchangeably. I vote for the later.

@avive
Copy link
Contributor

avive commented Jun 5, 2021

We need to conclude the terminology dicsussion so I could finalize the documentation and how we name things. Currently, “pos”, “pos setup”, “post data creation”, “post init”, “post setup” are used interchangeably. I vote for the later.

For now I see you call its Post and not Pos on the API level. We can use post setup in stead of pos setup on the ui level as well to make you and tal happy.

@avive
Copy link
Contributor

avive commented Jun 5, 2021

Changes:

Q: are you updating cli-wallet to work with these changes as well?

@avive
Copy link
Contributor

avive commented Jun 5, 2021

Can you please remove the status field from all smesher api responses? They are not needed as a grcp api response always has built-in status code and message fields.

@avive
Copy link
Contributor

avive commented Jun 5, 2021

Changes:

  • Returned SmeshingStatus() -> [IDLE, CREATING_POST_DATA, ACTIVE] to IsSmeshing() -> bool.
    It’s referring solely to the phase in which post setup completed and ATX creation started.
  • Returned PostStatus() on a limited-scope. If setup started, it’s referring to the current/latest PostInitOpts, otherwise to none. Its response is identical to PostDataCreationProgressStream's.

LGTM but it will be nice to add these notes to the doc comments of the methods in smesher.proto so the intent is clearer there for all users and this will be used as base for higher-level api docs.

@moshababo
Copy link
Contributor Author

Q: are you updating cli-wallet to work with these changes as well?

Updated here: spacemeshos/smrepl#23 (comment).

Can you please remove the status field from all smesher api responses? They are not needed as a grcp api response always has built-in status code and message fields.

This pattern is used in other services as well, so I'd rather keep it following the general API design, and discuss it with @lrettig.

LGTM but it will be nice to add these notes to the doc comments of the methods in smesher.proto so the intent is clearer there for all users and this will be used as base for higher-level api docs.

I planned to finish the docs once the design and the implementation is accepted.

rpc IsSmeshing (google.protobuf.Empty) returns (IsSmeshingResponse);

// Start smeshing. If the post data is incomplete or missing, data creation
// session will be preceded. Changing of the post potions (e.g., number of labels),
Copy link
Member

Choose a reason for hiding this comment

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

"will be preceded"

What does this mean? is it a typo?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It means that if the data is incomplete or missing, data creation session will occur and must complete before smeshing can start. Feel free to fix my english, but I plan to revise all the documentation anyway.

uint32 num_units = 2; // Number of PoST data commitment units to generate
uint32 num_files = 3; // Number of files to equally distribute the labels among
uint32 compute_provider_id = 4; // A PostProvider id
bool throttle = 5; // Throttle down setup phase computations while user is interactive on system
Copy link
Member

Choose a reason for hiding this comment

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

Couldn't this be an int, to allow more fine-tuned throttling? E.g., max CPU percentage?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's referring to the utilization of GPU cores, not CPU time. The API complies with the internal API of gpu-post lib, so we should consider changing it there first.

Copy link
Contributor

Choose a reason for hiding this comment

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

For the release of gpu-post lib for post it is indeed a boolean and it is not going to change to an int. Let's consider this feature for next release. We need to finalize and ship and we shouldn't change features so late in the cycle.

message StopPostDataCreationSessionRequest {
bool delete_files = 1;
message PostComputeProvidersRequest {
bool benchmark = 1;
Copy link
Member

Choose a reason for hiding this comment

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

What does benchmark mean here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Request to run a short benchmarking session for each provider, so that the performance field of PoSTSetupComputeProvider will be assigned with the num of hashes per sec.

Documentation is still missing and will be complete soon.

@lrettig
Copy link
Member

lrettig commented Jun 12, 2021

Can you please remove the status field from all smesher api responses? They are not needed as a grcp api response always has built-in status code and message fields.

This pattern is used in other services as well, so I'd rather keep it following the general API design, and discuss it with @lrettig.

We use this pattern for responses that would otherwise be empty. It's a way to explicitly specify success/failure.

@avive
Copy link
Contributor

avive commented Jun 13, 2021

Can you please remove the status field from all smesher api responses? They are not needed as a grcp api response always has built-in status code and message fields.

This pattern is used in other services as well, so I'd rather keep it following the general API design, and discuss it with @lrettig.

We use this pattern for responses that would otherwise be empty. It's a way to explicitly specify success/failure.

@lrettig - didn't you just comment on another issue that we should get rid of these statuses in empty responses? There you agreed this is unnecessary. In the current pattern - 2 distinct statuses are returned for these methods - the built in one (which is always returned) and the explicit one - not a great way to return results to api users.

@lrettig
Copy link
Member

lrettig commented Jun 18, 2021

Yes, I agree, I think we should make this change

@avive
Copy link
Contributor

avive commented Jun 27, 2021

The smesher api generally looks fine.
I have 2 relatively minor comments.

  1. there's a bit of duplication that can go away between PostInitOpts and ConfigResponse data items. Consider having a shareג object for post config params that is returned in ConfigResponse and is also passed by caller of CreatePostDataRequest. Something like this:
message PostParams {
    uint32 bits_per_label = 1;
    uint64 labels_per_unit = 2;
    uint32 min_num_units = 3;
    uint32 max_num_units = 4;
}

message ConfigResponse {
    PostParams post_params = 1;
}

message PostInitOpts {
    PostPramas post_params = 1;
    uint32 compute_provider_id = 2; // A PostProvider id
    bool throttle = 3; // Throttle down setup phase computations while user is interactive on system
}

Also, perhaps the computer_provider_id and throttle should be included in the post params as well and not separate so we get:

message PostInitOptions {
    uint32 bits_per_label = 1;
    uint64 labels_per_unit = 2;
    uint32 min_num_units = 3;
    uint32 max_num_units = 4;
    uint32 compute_provider_id = 5; // A PostProvider id
    bool throttle = 6; // Throttle down setup phase computations while user is interactive on system
}

message ConfigResponse {
    PostInitOptions post_init_options = 1;
}

message StartSmeshingRequest {
    AccountId coinbase = 1;
    PostInitOptions post_init_options = 2;
}
  1. I would make this commit breaking and get rid of all the responses that have only status in them, e.g. StopSmeshingResponse - the sooner we do this the better and it is a non-backward compatible change anyhow.

@moshababo
Copy link
Contributor Author

moshababo commented Jun 27, 2021

  1. there's a bit of duplication that can go away between PostInitOpts and ConfigResponse data items. Consider having a shareג object for post config params that is returned in ConfigResponse and is also passed by caller of CreatePostDataRequest.

The naming you specified are outdated, so plz use the latest. After some revisions, we now have 2 distinct configurations:

  • PoSTConfig (currently defined in PoSTConfigResponse) — protocol params only, defined via the node configuration. That’s why it's read-only.
  • PoSTSetupOpts — params for the local PoST setup (triggered only via StartSmeshing.

Considering this, your suggestion doesn’t make sense to me, so let me know if I missed something.

  1. I would make this commit breaking and get rid of all the responses that have only status in them, e.g. StopSmeshingResponse - the sooner we do this the better and it is a non-backward compatible change anyhow.

I'd like to do it in a follow-up PR, because it doesn't involve solely the Smesher API.

@avive
Copy link
Contributor

avive commented Jun 27, 2021

Considering this, you suggestion doesn’t make sense to me, so let me know if I missed something.

Ok, this makes sense for both items.

COMPUTE_API_CLASS_UNSPECIFIED = 0;
COMPUTE_API_CLASS_CPU = 1; // useful for testing on systems without a cuda or vulkan GPU
COMPUTE_API_CLASS_CUDA = 2;
COMPUTE_API_CLASS_VULKAN = 3;
Copy link
Member

Choose a reason for hiding this comment

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

Should we maybe add a COMPUTE_API_CLASS_OTHER?

Copy link
Contributor

Choose a reason for hiding this comment

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

For what reason? These value correspond to the type of providers supported by the gpu-post lib. If/when we'll add new supported types of providers to gpu-post then we'll add them to the enum in future api releases. Don't see how other is useful here.

proto/spacemesh/v1/smesher_types.proto Outdated Show resolved Hide resolved
Copy link
Member

@lrettig lrettig left a comment

Choose a reason for hiding this comment

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

I'm definitely not a fan of the PoST capitalization, e.g., PoSTConfig. I think PostConfig is much easier and less error prone.

@avive
Copy link
Contributor

avive commented Jul 6, 2021

I'm definitely not a fan of the PoST capitalization, e.g., PoSTConfig. I think PostConfig is much easier and less error prone.

Same with me - we don't use this naming pattern anywhere in the Api and I agree that Post and PostConfig are better.

@moshababo moshababo force-pushed the new_smesher_api branch 2 times, most recently from 0631982 to 7e631f5 Compare July 18, 2021 07:59
# Conflicts:
#	release/go/spacemesh/v1/types.pb.go
# Conflicts:
#	release/go/spacemesh/v1/types.pb.go
@moshababo
Copy link
Contributor Author

I'm definitely not a fan of the PoST capitalization, e.g., PoSTConfig. I think PostConfig is much easier and less error prone.

Same with me - we don't use this naming pattern anywhere in the Api and I agree that Post and PostConfig are better.

Fixed (7e631f5, and in the implementation as well).

Copy link
Contributor

@avive avive left a comment

Choose a reason for hiding this comment

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

LGTM

@avive avive self-requested a review July 26, 2021 05:10
Copy link
Contributor

@avive avive left a comment

Choose a reason for hiding this comment

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

As requested, dealing with empty GRPC responses will be done in another PR.

@moshababo moshababo merged commit 9474f58 into master Jul 26, 2021
@moshababo moshababo deleted the new_smesher_api branch July 26, 2021 06:44
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.

4 participants