-
Notifications
You must be signed in to change notification settings - Fork 649
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
Custom operations plugin #1926
Custom operations plugin #1926
Conversation
I think, we can provide an object, just store the key-value data structure for the account, it can be easily used for other purposes. We can provide standards for many general purposes, but I think we can also provide some custom data reading and storage. So I wonder if we can provide an operation like the following:
In this way, we can satisfy specific purposes and some more general purposes. |
I will add this functionality as an |
@oxarbitrage It should be me thank you, I just put forward some requirements, and you need to implement it. Another question. |
For easier expanding, we can define an operation to update data stored in a generic account-data map, which takes a string as key, and another string as value. We can have multiple key-value pairs in the operation. The operation replaces values in the map. For use cases like white-listing, a string is not enough for the value, ideally we need a set, because it's inconvenient to replace a whole list, the operation should add/remove items to/from the set with a given key. I think it's better to define this as a new operation. I think having these 2 operations will fit most of data-storage needs. By the way, we can probably (ab)use the |
New
Operations to manage them were added, this are:
Test cases were added at
There is a limitation of only update the map or the account list with 10 rows of data at a time. I am thinking on limiting the overall map and set in the object to 100 values or similar. I am wondering now if we should just host Wallet calls are not added yet. |
After a discussion with @abitmore about the last commit there are some issues with the underlying object implementation that we decided to change.
This will allow us to create indexes and search by key, instead of one big object per account with map and set, we will have multiple key-value objects per account. Operations will remain unchanged if possible, one to add data in the form of key-value and another to add just a key for a list. Will submit those changes as soon as possible, working on them now. |
This is confusing. My idea is something like this:
So, query for (acc1,key1) will get a unique item, query for (acc1,key2) will get a list. I'm not sure whether it's a good idea to store key-value data and key-list data together. For key-value data, we need
Some of the operations listed above can be combined. Using
For key-list data, we need
For dedupe, we need to index values as well; for performance, we need to limit values' length, but this is not ideal. Perhaps a better approach for key-list data is to store it as (account, key, sub-key, value), set limitations on key and sub-key, and index them, but don't index values; also, for some use cases, value can be empty. |
I think this structure can satisfy most situations.
In this way, we implement most of the data structures: map, vector (the element can be repeated), set (the element can not be repeated, all map keys). |
@syalon the "does not exist" key is not the way to store a vector. For storing data, the tuple An optional key in DB is hard for designing API, because an optional parameter in API usually means something else. If change the key type away from optional, then the data structure is the same to my conclusion in the last comment (I mentioned (account, key, sub-key, value)). By the way, personally I think "category" is a better word than "catalog" here. I could be wrong though. |
What is the use case of storing a vector that we cant do with a set or map as we have now ? |
Maybe, we only consider set and map. I haven't thought of any scenes that need a vector. @oxarbitrage |
How about storing values as |
Using Strings are easier for client apps to integrate so far, IIRC |
I have the code to change the |
I also think that string is ok. We should keep it simple. |
I want to verify that conceptually I have the desired outcome correct. Please fix what I have wrong. The idea here is to use custom operations to store data on the chain. We have some examples of the type of data in this PR (i.e. account holder data, htlc data). The API nodes with the plugin enabled will be able to serve the information. API nodes without the plugin enabled will reject the request. If the above two statements are correct, I worry about the pollution of the API. With this PR, we are asking those hosting nodes to support an ever expanding list of specialized API calls, and developers to maintain it. If the API could be more "generic", whereby changes to the data structure are unrelated to a small list of API methods, I would imagine required maintenance would be much less. Otherwise I see each new use case needing additions to api.hpp. I realize this shifts development efforts elsewhere, but I believe it also provides those that want truly custom data on the chain to get it there and retrieve it without changes in core. But before I go about redesigning everything that everyone else has worked on, perhaps I should wait on the BSIP, and get a clear picture of the desired outcome. Please feel free to school me on why this was done this way. |
We had done that. There are 2 specific use cases of additional account data information and htlc offers that were the first scenarios we had in mind. This should cover the use cases we can think of right now and with the general storage there should be no need to add more api calls, the ones we currently have will probably need to be refined but they will not grow with each case. We always have the option to add more objects and operations if an specific use case came in just as we did for htlc and contact info but ideally we will like to cover the generic use cases with the account storage operations and objects where possible. The account data case can be achieved by using the storage map so we could remove if we want, however by now we are keeping it as a way to have a standard mean to add this data specifically. We will not want that some wallet adds a The htlc use case can not be done by the generic storage options as it is now. Hope it clarifies. |
Yes. I think almost everything would be much simpler with the The API could be completely generic. Clients would see the content as JSON, which is more powerful than strings and therefore simpler to use for any use-case requiring structured data. Both htlc offers and account info are specific applications of the generic functionality. Their dedicated API calls can simply be removed. Well-known keys and value structures can be specified in The only thing that gets more complicated is the serialization of |
The We have now only 2 operations to manage the object by manipulating account Commit is here e4f0d76 but as many stuff was removed i think it will be easier to check the whole thing again. For HTLC offers we cant do the previous functionality(create-take offers) with general storage, basically because we cant modify an object created by another account. So, for that to happen we need to plugin to be listening to |
libraries/plugins/custom_operations/include/graphene/custom_operations/custom_operations.hpp
Outdated
Show resolved
Hide resolved
...es/plugins/custom_operations/include/graphene/custom_operations/custom_operations_plugin.hpp
Outdated
Show resolved
Hide resolved
libraries/plugins/custom_operations/custom_operations_plugin.cpp
Outdated
Show resolved
Hide resolved
libraries/plugins/custom_operations/custom_operations_plugin.cpp
Outdated
Show resolved
Hide resolved
libraries/plugins/custom_operations/custom_operations_plugin.cpp
Outdated
Show resolved
Hide resolved
...es/plugins/custom_operations/include/graphene/custom_operations/custom_operations_plugin.hpp
Outdated
Show resolved
Hide resolved
Hello bitshares community, I have some queries regarding the As I had found it somewhere that these operations were renamed to - How its supposed to work : Return the See the below example with images :- Step-1 : Storing data using -
Step-2 : However, when I try to retrieve data using PS: I would also like to contribute towards this community. I find it really amazing how bitshares facilitates very less average transaction time compared to any other blockchain. I am eager to play a part in contributing towards this community. Please do consider the issue with |
FWIW I think the above question was solved here: https://github.com/orgs/bitshares/discussions/2804#discussioncomment-8242384. |
New object type:
New (embedded) operation type:
account_storage_map
operation (in binary form) and store it as thedata
field ofcustom_operation
; therequired_auths
andid
fields ofcustom_operation
are ignored.optional<string>
) inkey_values
is in JSON format.New node API set
custom_operations
:Wallet command / API:
-- below is the original (stale) message --
For issue #1847
Specifically for the issue operation `account_contact_operation` was created.For HTLC orderbook(unrelated to the initial issue) operations
create_htlc_order_operation
andtake_htlc_order_operation
were created.@abitmore helped with directions, we decided it is good enough for a draft pull request.
Open to feedback and questions, more details and how to use will be provided in an information BSIP i am starting to write.