Open zanicar opened 1 year ago
Kindly some additions to x/cw-registry Module with some kool new features in context of Dapp semantics, transaction traffic metric analysis, customer queries support!
Additions to x/cw-registry Module:
Types:
Msg Types:
MsgRegisterContract
Parameters:
Keeper:
Check if the contract with the given ContractName or ContractAddr is already registered. If no conflicts, store the contract details with ContractAddr as the key.
MsgAddReview
Parameters:
Keeper:
Ensure that the ContractAddr is registered. Verify that the ReviewerAddr hasn't already left a review for the given contract. Add the review details to the store with a combination of ContractAddr and ReviewerAddr as the key.
MsgRateContract
Parameters:
Keeper:
Validate that the ContractAddr exists. Ensure that the RaterAddr hasn't previously rated the contract. Validate the Rating value (within allowed range). Store the rating using a composite key of ContractAddr and RaterAddr.
MsgAddTag
Parameters:
Keeper:
Validate the ContractAddr and ensure it's registered. Check if the tag already exists for the contract. If not, add the tag to the contract's existing tags in the store.
MsgSearch
Parameters:
Keeper:
Parse the Criteria. Use an efficient search algorithm(details to be provided) to fetch contracts that match the criteria. Return the list of matching contracts.
Queries:
QueryResolveContract Parameters: ContractName Handler: Returns the address for the provided contract name.
QueryGetContractRecord Parameters: ContractAddr Handler: Returns the details of the given contract address.
Keeper:
Features: a. Search Function: Implemented using the MsgSearch message type. Users can query based on tags, name, ratings, etc.
b. Tagging System: Tags are stored in the keeper with the contract address as the key. Users can add tags using the MsgAddTag message.
c. Rating System: Ratings are stored in the keeper using a combination of contract address and user address to prevent multiple ratings by the same user for the same contract. The MsgRateContract message handles the addition of ratings.
d. Review System: Reviews are stored in the keeper using a combination of contract address and user address to prevent multiple reviews by the same user for the same contract. Reviews can be added using the MsgAddReview message.
Errors:
Store Prefixes:
Event:
Attributes:
contract_addr: Address of the newly registered contract. owner_addr: Address of the contract owner. contract_name: Name of the contract.
Attributes:
contract_addr: Address of the contract being reviewed. reviewer_addr: Address of the reviewer. comment: Brief snippet of the review comment
Attributes:
contract_addr: Address of the rated contract. rater_addr: Address of the user who provided the rating. rating_value: The numeric value of the rating.
Attributes:
contract_addr: Address of the contract being tagged. tag_name: The name of the tag added.
metadata.json:
{
"code_id": ,
"description": "MatrixBrainBattery - P2E game and NFT Minting – Ultimate choice for Archway Rewards and Photosynthesis Liquid Staking Algorithm",
"purpose": "E.g. DeFi, NFT, Gaming",
"source": {
"repository": "https://github.com/archway-network/archway",
"tag": "v1.0.2",
"license": "Apache-2.0"
},
"source_builder": {
"image": "cosmwasm/rust-optimizer",
"tag": "0.12.6",
"contract_name": "matrixbrainbattery.wasm"
},
"schema": "
],
"last_updated": "",
"deployment_cost": "in the native token, e.g. 10 arch"
}
tags.json: [ "DeFi", "NFT", "Gaming" ]
reviews.json: [ { "user": "address of the reviewer", "comment": "Great Game!! Had around 20 gaming sessions this week itself!! :)", "date": "date format" } ]
ratings.json: [ { "user": "address of the rater", "rating": 5, "date": "date format" } ]
Excellent, well detailed discussion points, thank you!
Architectural Design Considerations
One thing we have to be very considerate of is the effect / implications of any feature on blockchain state and any potential of future mutability. Blockchain by its nature is immutable, or at least constrained to monotonic state updates, thus any on-chain feature needs to benefit from this attribute or have it as a requirement. Any features that do not are probably better implemented off-chain as a support / auxiliary service... however, these services / features may be another application specific blockchain.
For example, a search feature requires indexing to make search more efficient. Indexing, especially when combined with tags / ratings, are by its nature dynamic. This translates to inefficiency when expressed in on-chain state due to the high mutability of the data and would thus be better to implement as an off-chain service from an architectural perspective.
However, a full blown rating or reputation system is useful across many different scenarios and may possibly present an opportunity for an application specific blockchain, or smart contract complex, that is solely focused on this. Utilizing the protocol it can be coupled to numerous services (both contracts and even other chains) that require a censorship-resistant, verifiable, and pseudonymous rating and reputation system. But, it will come with some serious challenges of its own... scalability springs to mind!
Separate Necessary- from Convenience Features
A great exercise in this regard is to identify each feature as necessary or convenient. A simple way to distinguish this is to simply ask what it would take to achieve the desired outcome. For example, enhanced searching only requires additional indexing to be built or provided across already existing data, thus it can be classified as a convenience feature. Conversely, you may find that a specific convenience feature needs some additional state or metadata, which in turn makes this data a requirement. At this point, examine if it can be separated into distinct necessary and convenience features.
Opportunity: From a Business Perspective
Remember that services constitutes tertiary economic activity. Thus, if a specific convenience service could be of value to a larger number of users / developers within the ecosystem, it may well present an opportunity to build such a service for benefit, just as plumbers and electricians provide services to maintain and improve infrastructure.
This is exactly the reason why Archway provides rewards mechanisms to ensure that any such services, deployed as contracts, have the opportunity to benefit both creator / maintainer, as well as the larger Archway ecosystem.
Conclusion
Hopefully the above provides some additional pointers and insights to help inspire, as well as shape thoughts and designs from an architectural perspective.
Discussed in https://github.com/orgs/archway-network/discussions/16