-
Notifications
You must be signed in to change notification settings - Fork 3
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
Unification with snet-cli #9
Comments
I just want to clarify I think the This The reason for this is that if I build an application using SNet, I should be able to bundle it up and all dependencies should be inside the project directory. I don't want to have to extract compiled protobuf/grpc files from a home directory, and I especially don't want to have to filter and find only the files related to my current project (if I'm working on multiple applications). Related issue is here: singnet/snet-cli#173 which makes it clear it should be per project. |
Essentially the same as issue singnet/snet-cli#214 My preference is the second option proposed by Vitaly, which essentially has the snet-cli built around the SDK snet-client-common Lets align on the approach and we can figure out the implementation. Eventually would like for all out client tools to be built around the SDK so that we eat our own dog food. |
I think final solution should be discussed among with discussing API which My thoughts on other items raised by @astroseger in issue description: Items 1, 3, and 5 sounds reasonable to me.
I think
It is difficult to say right now, but sounds like a good candidate for |
|
As long as this has a sensible default (e.g. file cache in a project's Customisation should take a back seat to "Everything Just Works" with minimal cognitive overhead for a developer trying to use SNet. |
Sure, just would like to emphasize that For example I don't think that sharing cache between |
I see your point on the practicality of doing this.
Sure, as you suggest lets work on pulling out common functionality into a common dependency for both the client and the SDK. 1,3,4 and 5 are clear candidates for this. With regards to the API that the SDK will support it should
I doubt that any of this is new and pardon if this is at a very high level. |
I think in the long run having the CLI built on top of the SDK is a good idea, but I also agree that's not the best short term path. We should plan for that in the medium term. I also agree with this:
|
About the "sdk cache" issue: I think first and foremost, the sdk should be completely stateless by default. You can't assume the user who runs it will have a reliable filesystem at his disposal (fargate cluster, AWS lambda, whatever). That being said, I proposed having a "pluggable cache" system where you basically specify what persistence engine you want to use, which could be things that the SDK understands like "filesystem" (based on pickle in the Python iteration of the SDK, for example), or "cli" (which means, "I have e CLI installed on my system, please leverage that for caching", which is the same thing that the AWS SDKs do if you have an AWS CLI installed and configured on your system... but you can still specify whatever authentication options you prefer and override that), or provide a class with conventional methods that do serialization and deserialization (example: persistance=DatabaseStorage or something, which would be a class with by convention a "save" and "load" method that would serialize and deserialize the cache for you). This way the developer who uses SNET CLI and has it configured could use that in his (Python) client application, while the user who runs his service on whatever distributed docker cluster could do persistency on an external database / nfs mount / dynamoDB / whatever so if he destroys / re-creates containers they can all still access and leverage the same cache for the whole cluster. There's an issue open that specifically regards this which is #7 By the way, I think we should have the same approach with authentication. Meaning: you could just specify "CLI" as an authentication method (as an alternative to "private_key" or "mnemonic" or whatever), at which point the SDK would look at your CLI configuration and use whatever authentication method you specificed there as the default identity. |
Lets get started with the refactor effort as proposed by Sergey and look to build a common dependency layer across SDK and CLI |
As a first step I will simply isolate these functions inside snet-cli without putting them in separate repo. @raamb Do you agree? |
(I've removed item 3 from my previous post because it is irrelevant now... ) |
Agree with this. We can start pulling out code.
The point here is that the caching strategy should be pluggable. The first version would be the one you describe of dynamically downloading to a project specific directory but the solution should be able to support other options as required. The point @vforvalerio87 made about Lambda is quite valid as we have seen interest in some Telegram groups on building out services on a serverless framework. We should be able to support any persistent store which is what the pluggable approach affords. |
Same... literally everybody I spoke to asked how to set it up with Lambda, and nobody will have the snet cli installed on the server where the service runs. Having the sdk share configuration / cache with the cli is just for convenience for developers who test locally on their computer. I agree about extracting all the code you mentioned so it can be used in both places. |
@vforvalerio87 @raamb |
In Docker, yes. In Lambda cache would be lost at every call (same with Azure functions or Google Cloud Functions) |
Cool. But I assume that filesystem is a common way to represent information in linux. Isn't it? If there is no means to have any persisted storage in lambda. Then the only one solution is to have "static" cache. So you simply create container with all information (including cached channels and compiled protobufs) inside. If this information became outdated it will be automatically replaced in each call but there is no magical solution for it.. Isn't it? In any case we already support it... |
Ah yes... Am I right that you are saying that as a persisted storage in lambda is better to use some kind of DB and not a filesystem? |
As I was suggesting above and in issue #7, there is a very simple solution: the user provides a class with a pre-defined interface which takes care of serializing and deserializing the application state. Example: from snet import Snet
from state_cache import MySQLCache
snet = Snet(persistence_engine=MySQLCache, ...) MySQLCache is a custom class provided by the user which must expose at least the following methods: In With this we can also offer the user the possibility to avoid asking the channel state from the daemon completely, making calls faster. You store the state locally, and even if you have multiple machines using the same private key it's not an issue because they use the same storage for things like channel state, so if client1 makes a call and the state is updated, client2 can take the information from the same storage without asking the daemon all the time. It's 1 grpc call every service call instead of 2. If something happens on the daemon side, for example the service provider makes a claim, we should have a background process (async) in the SDK that gets the logs and the channel information from the blockchain every time a new block is mined. |
Unless you use some locking mechanism, that is how you get race conditions ;-)
|
SDK
lacks some features which already exist insnet-cli
(dynamical caching of everything (channels/service metadata/compiled protobuf), time based strategies for gas price, support of different types of identities, etc). Instead of re-implemented all these features inSDK
we should isolated them in separate library and use them inSDK
and insnet-cli
together.General strategy should as following: if we need some functionality in
SDK
and this functionality is already presented insnet-cli
we should take it fromsnet-cli
. If we don't like how it is implemented insnet-cli
we re-implement it, but we also replace old functionality insnet-cli
.@vforvalerio87 @raamb do you agree with this approach?
Functionality which already present in snet-cli, but lucking in SDK
identity.py
(@vforvalerio87 if you don't like how it is implemented it should be re-implemented in such a way that snet-cli could also use it)utils_agi2cogs.py
utils_agi2cogs.py
utils_agi2cogs.py
, some functions fromutils.py
mpe_client_command.py
The text was updated successfully, but these errors were encountered: