Giter Site home page Giter Site logo

cosmos-modules's People

Contributors

aaronc avatar adityasripal avatar alexanderbez avatar alpe avatar okwme avatar preminem avatar tac0turtle avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

cosmos-modules's Issues

ORM: Add "foreign" key index

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>

Make UInt64Index non-pointer

@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.

Execute proposal on submission already

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:

  • There is a gas cost per signature:
    • DefaultSigVerifyCostED25519 uint64 = 590
    • DefaultSigVerifyCostSecp256k1 uint64 = 1000
  • There is a limit of max signatures allowed
    * DefaultTxSigLimit uint64 = 7

Add UInt64Index

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)

Implement MsgCreateGroup

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

Master branch - project cleanup

  • Drop incubator package and move modules up
  • Upgrade Go version to 1.14
  • Single go.mod file
  • Single Makefile
  • Update Readme to describe project better as independent fork

Gas inefficiency of current design

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.

Documentation for Group Module Extension Points

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

Support 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)

Group decision policy interface

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.

Add JoinTable

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?

Implement MsgProposeBase

  • MsgProposeBase
    As a member of a group I want to create a new proposal for one of our group accounts so that the members can vote for it in order to
    execute it on success.

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

Implement MsgExec functionality

  • MsgExec
    As a user on the chain I want to be able to execute a proposal before the timeout when it was accepted so that the group's decision becomes
    reality.

This includes implementing payload message execution (routing, auth)

needed-by #31

Implement MsgCreateGroupAccountStd

  • MsgCreateGroupAccountStd (Critical Path)
    As an admin of a group I want to create an account address for a group with a decision policy so that the group can manage tokens.
    I want to reuse an existing group as electorate for different accounts.

Q: Can only the admin of a group create an account or is it open to everybody?

needed-by #31

Add benchmarks

TBD: Placeholder ticket to define which operations we want to measure

Implement Genesis IO for sdk Module spec

Implement all methods for module spec, Including:

  • Export DB state to genesis
  • Import DB state from genesis

Split into new issues:

  • [ ] Add client cmd/ query
  • [ ] Add REST client routes

Implement UpdateGroup messages

  • 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.

Set sequence ID automatically before persisted

Follow up on:
#20 (comment)

Solutions that come into my mind:

  • Have a before save interceptor that receives the RowID and can modify the object before serialization
  • Have a RowIDSetter interface that can be implemented and is checked + called before Create

Register table and index schema with schema manager

Motivation

The 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.

Definition of Done

The "schema manager" should:

  • expose an API to clients that describes all key formats and the table/index they correspond to in protobuf format
  • automatically assign table prefixes deterministically - that is all validators of the same state machine should end up with the same prefixes

Thoughts @alpe?

Implement UpdateGroupAccount messages

  • 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.

group membership defined by fungible token

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 weights may be token balances

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).

Implement MsgVote [group phase 1]

  • MsgVote
    As a member of a group with an active proposal I want to submit my vote in order to support or prevent the proposal from being executed.

Implement MsgVote

  • MsgVote
    As a member of a group with an active proposal I want to submit my vote in order to support or prevent the proposal from being executed.

needed-by #31

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.