regen-network / cosmos-modules Goto Github PK
View Code? Open in Web Editor NEWLicense: Other
License: Other
TlDr;: I would like to replace the following 2 Gets on tales by an index.
func (k Keeper) GetGroupByGroupAccount(ctx sdk.Context, address sdk.AccAddress) (GroupMetadata, error) {
var obj GroupAccountMetadataBase
if err := k.groupAccountTable.GetOne(ctx, address.Bytes(), &obj); err != nil {
return GroupMetadata{}, errors.Wrap(err, "load group account")
}
return k.GetGroup(ctx, obj.Group)
}
Scenario:
I have Groups and GroupAccounts.
message GroupAccount {
bytes address = 1 ;
uint64 group = 2 ;
}
When I create a new proposal we refer to a GroupAccount
in the payload. To store the group version with the proposal, I would need to load the group via reference from GroupAccount.
Instead of the 2 steps to load GroupAccount
by address and then load Group
by GroupAccount.Group
we could introduce a new index type that points to the Group
entity from an GroupAccount
.
All our current indexes are work with the RowGetter
and type of the table builder where they are registered. For this foreign key index we would need the Group
RowGetter
and type but register on the GroupAccounts
builder with and raw index key <GroupAccount.Address><Group.RowID>
@alpe currently *UInt64Index
is needed in structs which is a little odd because it isn't needed for other ORM structures like Index
. Let's either make it an interface or just not return a pointer.
Placeholder ticket to link to:
alpe/cosmos-modules#2
What routes do we want to support?
See #46
As a group member I want to submit a proposal that is executed immediately when a ExecNow
value is set and a sufficient number of group members have signed the message in order to ...?
Every signer must be part of the group. No duplicate signatures allowed. Every signer is considered a yes vote. Based on the decision policy configured the proposal will be executed or not.
Execution is an atomic operation so that it would either succeed or fail with the proposal creation.
Note:
A UInt64Index
would basically take the interface from AutoUInt64Table
and abstract it to an index:
type UInt64Index interface {
Has(ctx HasKVStore, key uint64) bool
Get(ctx HasKVStore, key uint64) (Iterator, error)
PrefixScan(ctx HasKVStore, start, end uint64) (UInt64Iterator, error)
ReversePrefixScan(ctx HasKVStore, start, end uint64) (UInt64Iterator, error)
}
type UInt64Iterator interface {
LoadNext(dest interface{}) (key uint64, err error)
io.Closer
}
with a constructor along the lines of:
NewUInt64Index(builder Indexable, prefix byte, indexer UInt64IndexerFunc)
In accordance with "Critical Path" from this document:
https://docs.google.com/document/d/1WXNomeYrnJcJgLQJ0IWWH0j3mdo8A6_RdZGvBJPRHbg/edit
PR tracking here: #24
The following messages should be supported:
The goal of this ticket is to understand the implementation process, and not to have a production ready implementation.
Github workflow for example?
As a user on the chain I want to combine cosmos addresses to a group so that I can have an electorate
that can vote on proposals.
Asssumptions: The creator of the group is the "admin" of the group.
needed-by #31
A new Go implementation was released this week:
https://blog.golang.org/a-new-go-api-for-protocol-buffers
I have not looked into the details. Just want this ticket for the discussion
As discussed in Architecture Review Meeting (2/6/2020) with Ethan, Aaron, Alex.
The current design forces every table to use a uint64
row ID regardless of what the underlying primary key actually is for index efficiency. This creates some storage inefficiency which is compounded by high gas costs for single reads and writes beyond the gas cost for bytes.
Some WIP work is in #3.
The following extension points must be documented so developers can use the group module in their own module.
MsgProposeBase
Custom modules can build on top of MsgProposeBase to create individual Proposals with custom payloads
MsgCreateGroupAccountBase
Extension point for custom decision policies
Currently only the ThresholdDecisionPolicy
is defined. The group module should provide an extension point where custom decision policies can be implemented and stored.
Follow up on #24 (comment)
The set of events to be emitted has not yet been defined, so we are making one ticket to address this on all message types.
As discussed on a previous call Threshold decision policy
is one decision policy instance, but alternative policies may be conditioned on some combination of timing, quorum requirements, or message/oracle inputs.
In https://github.com/regen-network/cosmos-modules/pull/14/files#diff-cd553207888c76d3acb6e9284c4e02e4, group member table and vote table are effectively "join tables" and their primary key is derived from two fields rather than one. Having them as natural key tables is a bit inefficient because then two indexes are needed, when this could be reduced to one with the table itself serving as an index in one direction. For example, the group member primary key is just concat(group, member)
so this is sufficient for prefix scans already (assuming we add a final length byte).
So what about a JoinTable
that instead of NaturalKeyed
takes an interface like:
type JoinKeyed interface {
JoinKeys() [][]byte
}
Then the interface for JoinTable
could be something like:
type JoinTable interface {
Table
HasRelation(joinKeys [][]byte) bool
GetOneByRelation(joinKeys [][]byte, dest interface{}) error
}
Thoughts @alpe?
NOTE: this task can only be implemented as integration test as there are no other modules using the group module yet. This is considered an extension point
NOTE: I have created a new issue to address the execute now
scenario and descoped it from this issue: #53
needed-by #31
needed-by #31
As discussed in the call we do not push the changes downstream into the cosmos/modules. This becomes an independent fork.
This includes implementing payload message execution (routing, auth)
needed-by #31
Added as a new ticket to not rebase all pending PRs.
Replace ValidateBasic()
in orm.Persistence
interface by a new optional interface.
See comment on #51 (comment)
The set of queries to be supported has not yet been defined. We should define this soon, so we know how big it is.
Q: Can only the admin of a group create an account or is it open to everybody?
needed-by #31
TBD: Placeholder ticket to define which operations we want to measure
Implement all methods for module spec, Including:
Split into new issues:
MsgUpdateGroupMembers
As an admin of a group I want to add/remove group members and modifiy their weights so that a group
reflects the real world distribution of power of my use case.
MsgUpdateGroupAdmin
As an admin of a group I want to replace the admin address so that I can rotate keys or pass admin access to somebody else
MsgUpdateGroupComment
As an admin of a group I want to update the comment metadata so that it makes sense again.
Follow up on:
#20 (comment)
Solutions that come into my mind:
before save
interceptor that receives the RowID and can modify the object before serializationRowIDSetter
interface that can be implemented and is checked + called before CreateThe merkle store of chains is exposed directly to clients for querying and ideally they can use it for generating merkle proofs. This is only useful if clients actually understand the format of the merkle store. With the ORM package, we have a formal way for organizing the merkle store. With a proper "schema manager" that tracks or even better assigns table and index prefixes to table and index types, a store introspection API could be exposed to clients.
The "schema manager" should:
Thoughts @alpe?
Currently they would increment the version number and therefore invalidate an running proposal for that group.
See #56 (comment) for discussions
MsgUpdateGroupAccountAdmin
As an admin of an group account I want to replace the admin address so that I can rotate keys or pass admin access to somebody else.
MsgUpdateGroupAccountBase
As an admin of an group account I want to replace the electorate group by another one so that ???
MsgUpdateGroupAccountDecisionPolicyStd
As an admin of an group account I want to update the decision policy so that it reflects the new rules.
MsgUpdateGroupAccountComment
As an admin of an group account I want to update the comment metata so that it makes sense again.
It should be possible to issue a sub-token that represents shareholder rights to a group. AFAIK in the current architecture this is not possible because the participating accounts must be defined in advance, correct me if I'm wrong.
Group member weights may be derived from the magnitude of personal holdings (similar to current token-weighted voting in the gov module) or from the relative contributions made to the group (like Moloch DAO).
What commands and queries do we want to support?
Add to #46
The proposal as described here: cosmos/cosmos-sdk#5694
is a blocker for @alpe's work on creating group accounts. He has copied weave's implementation, but would like confirmation that this is sufficient, or if there should be a different implementation upstream in Cosmos SDK.
Update should be in accordance with ADR019:
Example from other modules:
Blocked until full drop of amino in cosmos sdk
From review comment:
#57 (review)
This is currently not defined as a hard requirement, but possibly should be considered for a phase 2 implementation.
needed-by #31
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.