From c87f8766212ef94ed3289cd8cce164b74094d46e Mon Sep 17 00:00:00 2001 From: Andrej Zavgorodnij Date: Tue, 7 Apr 2020 21:24:35 +0300 Subject: [PATCH] feat: added specs --- docs/01_concepts.md | 5 ++ docs/02_state.md | 3 ++ docs/03_messages.md | 27 +++++++++++ docs/04_events.md | 11 +++++ docs/05_future_improvements.md | 3 ++ docs/06_appendix.md | 1 + docs/README.md | 83 ++++++++++++++++++++++++++++++++++ 7 files changed, 133 insertions(+) create mode 100644 docs/01_concepts.md create mode 100644 docs/02_state.md create mode 100644 docs/03_messages.md create mode 100644 docs/04_events.md create mode 100644 docs/05_future_improvements.md create mode 100644 docs/06_appendix.md create mode 100644 docs/README.md diff --git a/docs/01_concepts.md b/docs/01_concepts.md new file mode 100644 index 0000000..4fc7c66 --- /dev/null +++ b/docs/01_concepts.md @@ -0,0 +1,5 @@ +# Concepts + +## RandApp + +RandApp is an upgrade to BaseApp that can store DKG-related messages and provides a querying interface for those messages. If you need to track messages sent by DKG participants (e.g. for accountability), you need to store those messages on-chain; this functionality is implemented by RandApp. Saved messages are kept with information about the DKG round that they belong to. diff --git a/docs/02_state.md b/docs/02_state.md new file mode 100644 index 0000000..6ad6040 --- /dev/null +++ b/docs/02_state.md @@ -0,0 +1,3 @@ +# State + +The application just uses standard KVStores to keep its data. \ No newline at end of file diff --git a/docs/03_messages.md b/docs/03_messages.md new file mode 100644 index 0000000..d3c0d77 --- /dev/null +++ b/docs/03_messages.md @@ -0,0 +1,27 @@ +# Messages + +## MsgSendDKGData + +`MsgSendDKGData` message is the only message used by the module. It holds the seed and sender address. + +| **Field** | **Type** | **Description** | +|:----------|:---------------------------------------------------------|:-------------------------------------------------------------| +| Owner | `sdk.AccAddress` | The account address of the user sending the message. | +| Data | `github.com/corestario/dkglib/lib/alias.DKGData` | DKG data itself (see below) | + +``` go +type MsgSendDKGData struct { + Data *alias.DKGData `json:"data"` + Owner sdk.AccAddress `json:"owner"` +} + +type DKGData struct { + Type DKGDataType + Addr []byte + RoundID int + Data []byte // Data is going to keep serialized kyber objects. + ToIndex int // ID of the participant for whom the message is; might be not set + NumEntities int // Number of sub-entities in the Data array, sometimes required for unmarshaling. + Signature []byte //Signature for verifying data +} +``` \ No newline at end of file diff --git a/docs/04_events.md b/docs/04_events.md new file mode 100644 index 0000000..3c68b82 --- /dev/null +++ b/docs/04_events.md @@ -0,0 +1,11 @@ +# Events + +The reseeding module emits the following events: + +## Handlers + +### MsgSendDKGData + +| Type | Attribute Key | Attribute Value | +|-------------------------|----------------------|--------------------| +| EventAdDKGDataFailed | error | {error} | diff --git a/docs/05_future_improvements.md b/docs/05_future_improvements.md new file mode 100644 index 0000000..9e61f6a --- /dev/null +++ b/docs/05_future_improvements.md @@ -0,0 +1,3 @@ +# Future Improvements + +We might want to implement deleting messages from the application (because those messages can add up pretty fast). \ No newline at end of file diff --git a/docs/06_appendix.md b/docs/06_appendix.md new file mode 100644 index 0000000..fad5ae4 --- /dev/null +++ b/docs/06_appendix.md @@ -0,0 +1 @@ +# Appendix diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 0000000..710b110 --- /dev/null +++ b/docs/README.md @@ -0,0 +1,83 @@ +## Reseeding module + +## Contents + +1. **[Concepts](./01_concepts.md)** +2. **[State](./02_state.md)** +3. **[Messages](./03_messages.md)** +4. **[Events](./04_events.md)** +5. **[Future Improvements](./05_future_improvements.md)** + +# CoreStarIO RandApp + +CoreStarIO RandApp is Cosmos-based SDK, designed for easier building blockchain +applications using on-chain DKG algorithm in Golang. + + +More about [cosmos-sdk](https://github.com/cosmos/cosmos-sdk). + + +Notable source code files to check out about DKG: + +1. https://github.com/corestario/tendermint/blob/dcr-random/types/random.go +2. https://github.com/corestario/tendermint/blob/dcr-random/consensus/dkg.go +3. https://github.com/corestario/tendermint/blob/dcr-random/consensus/dkg_dealer.go + + +On-chain DKG works the same way as the off-chain version but writes its messages to blocks, +which allows us to slash a validator that refuses to participate in a DKG round. + +More about DKG and lib, which implements corresponding algorithm +see [dkglib](https://github.com/corestario/dkglib). + +# Requirements: +* [Tendermint (corestario fork)](https://github.com/corestario/tendermint) +* [DKGLib](https://github.com/corestario/dkglib) +* [Cosmos-utils](https://github.com/corestario/cosmos-utils) +* [Cosmos-sdk (corestario fork)](https://github.com/corestario/cosmos-sdk) +* [Cosmos-modules (corestario fork)](https://github.com/corestario/modules) + +# Running a local-testnet + +#### Ensure that you have docker! +#### Ensure that dkglib, tendermint, cosmos-sdk and cosmos-utils, modules folders are next to your randapp folder! +##### It is necessary for building docker images and starting testnet! + +Example: + +/ home + +**/ projects + +****/ randapp + +****/ dkglib + +****/ tendermint + +****/ cosmos-sdk + +****/ cosmos-utils + +****/ modules + +#### Run a local-testnet: +```shell script +sudo rm -rf ./build && sudo make build-docker-randappdnode && make build-linux && sudo make localnet-stop && sudo make localnet-start-without-bls-keys +``` + +#### How to view logs on a randapp node: +```shell script +docker logs -f randappdnode0 +``` + +### CLI commands + +Randapp has only one type of messages which could be sent from cli - seeds (implement in [Modules](https://github.com/corestario/modules)) + +#### Send seed +```shell script +randappcli reseeding send "SEED_BYTES" +``` + +Sending native MsgSendDKGData type from a cli or REST is not implemented due to unnecessary \ No newline at end of file