From 54e69e052803882cd211d26f05388ddc5e61d55d Mon Sep 17 00:00:00 2001 From: bahadylbekov <33404905+bahadylbekov@users.noreply.github.com> Date: Sat, 31 Oct 2020 07:38:51 +0300 Subject: [PATCH] docs: task, PoS, task documentation and task structure changes --- README.md | 4 ++-- beacon/beacon.go | 6 +++--- consensus/miner.go | 4 +++- docs/proof-of-stake.md | 13 +++++++++++++ docs/randomness.md | 13 +++++++++++++ docs/task.md | 17 +++++++++++++++++ types/task.go | 3 ++- 7 files changed, 53 insertions(+), 7 deletions(-) create mode 100644 docs/proof-of-stake.md create mode 100644 docs/randomness.md create mode 100644 docs/task.md diff --git a/README.md b/README.md index ba9c931..6cfb0e3 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ Dione oracle network is solving the interoperability problem between multiple blockchain networks. Blockchains themself could be describled as deterministic state machine replicated on full-nodes that retains consensus safety. And having the network that handles state changes validation across multiple protocols is crucial for [Secured Finance](https://github.com/Secured-Finance) first-layer transactions execution. Using Dione network Secured Finance could provide completely decentralized service for it's users. -Simple explanation for Dione is a blockchain that tracks the state of another blockchains. Dione network itself has fast-finality because of the pBFT (Practical Byzantine Fault Tolerance) consensus and has a role to establish finality for the blockchain it connects (Ethereum, Bitcoin networks has probabilistic-finality). +Simple explanation for Dione is a distributed network that tracks the state of another blockchains by computing cross-chain tasks. Dione network itself has fast-finality because of the pBFT (Practical Byzantine Fault Tolerance) consensus and has a role to establish finality for the blockchain it connects (Ethereum, Bitcoin networks has probabilistic-finality). The networking layer of Dione node is based on [libp2p](https://github.com/libp2p/go-libp2p), a flexible cross-platform network framework for peer-to-peer applications. Projects like [ETH2 (Ethereum 2.0)](https://github.com/ethereum/eth2.0-specs), [Filecoin](https://github.com/filecoin-project) and Polkadot's [Substrate](https://github.com/paritytech/substrate) is based on libp2p making it's the standard for future decentralized infrastructures. @@ -53,7 +53,7 @@ DIONE token is a ERC20 token on Ethereum blockchain used as a staking token to r Staking mechanism would encourage node operators to behave correctly as well as malicious nodes would lose their stakes. In order to run Dione node the operator has to stake at least 10,000 DIONE tokens. -Total supply of DIONE tokens is 2,000,000. By that the maximum amount of nodes participating in Dione is limited to 200 at the initial start of Dione network. 30% of DIONE tokens would be allocated to Secured Finance team. +Initial supply of DIONE tokens is 2,000,000. By that the maximum amount of nodes participating in Dione is limited to 200 at the initial start of Dione network. 30% of DIONE tokens would be allocated to Secured Finance team. On every block Dione miners would get 50 DIONE tokens as the mining reward. Governance mechanism would take place on [snapshot.page](https://snapshot.page/#/). The main application of governance descision is around required amount of DIONE tokens to stake in order to run Dione node. Additional governance descision could be proposed by DIONE token holders among the way. diff --git a/beacon/beacon.go b/beacon/beacon.go index d8c59a2..e25c951 100644 --- a/beacon/beacon.go +++ b/beacon/beacon.go @@ -45,7 +45,7 @@ type RandomBeacon interface { func ValidateTaskValues(bSchedule Schedule, t *types.DioneTask, parentEpoch types.TaskEpoch, prevEntry types.BeaconEntry) error { { parentBeacon := bSchedule.BeaconForEpoch(parentEpoch) - currBeacon := bSchedule.BeaconForEpoch(t.Height) + currBeacon := bSchedule.BeaconForEpoch(t.Epoch) if parentBeacon != currBeacon { if len(t.BeaconEntries) != 2 { return fmt.Errorf("expected two beacon entries at beacon fork, got %d", len(t.BeaconEntries)) @@ -60,8 +60,8 @@ func ValidateTaskValues(bSchedule Schedule, t *types.DioneTask, parentEpoch type } // TODO: fork logic - b := bSchedule.BeaconForEpoch(t.Height) - maxRound := b.MaxBeaconRoundForEpoch(t.Height) + b := bSchedule.BeaconForEpoch(t.Epoch) + maxRound := b.MaxBeaconRoundForEpoch(t.Epoch) if maxRound == prevEntry.Round { if len(t.BeaconEntries) != 0 { return fmt.Errorf("expected not to have any beacon entries in this task, got %d", len(t.BeaconEntries)) diff --git a/consensus/miner.go b/consensus/miner.go index 448a2df..2452950 100644 --- a/consensus/miner.go +++ b/consensus/miner.go @@ -3,6 +3,7 @@ package consensus import ( "bytes" "context" + "sync" "github.com/Secured-Finance/dione/types" "github.com/ethereum/go-ethereum/common" @@ -15,6 +16,7 @@ import ( type Miner struct { address address.Address api MinerAPI + mutex sync.Mutex } type MinerAPI interface { @@ -82,7 +84,7 @@ func (m *Miner) MineTask(ctx context.Context, base *MiningBase, mb *MinerBase) ( ElectionProof: winner, BeaconEntries: mb.BeaconEntries, // TODO: signature - Height: round, + Epoch: round, }, nil } diff --git a/docs/proof-of-stake.md b/docs/proof-of-stake.md new file mode 100644 index 0000000..5f83bb4 --- /dev/null +++ b/docs/proof-of-stake.md @@ -0,0 +1,13 @@ +# Dione Proof-of-Stake mechanism + +Dione oracle network is the distributed network of nodes. And as any distributed network Dione has a risk that the majority of nodes would act maliciously. In order to reduce this risk and incentivize node operators to behave correctly Dione has Proof-of-Stake mechanism, malicious nodes in the network would lose their stakes. In order to run Dione node the operator has to stake at least 10,000 DIONE tokens. The minimum amount of DIONE tokens might be changed by governance decision. + +# DIONE token +DIONE token is a ERC20 token on Ethereum blockchain used as a staking token to run the Dione node and for decentralized governance. + +Initial supply of DIONE tokens is 2,000,000. By that the maximum amount of nodes participating in Dione is limited to 200 at the initial start of Dione network. 30% of DIONE tokens would be allocated to Secured Finance team. On every block Dione miners would get 50 DIONE tokens as the mining reward. + +# DIONE token governance + +Governance mechanism would take place on [snapshot.page](https://snapshot.page/#/). The main application of governance decision is around minimum amount of DIONE tokens to stake in order to run Dione node. Additional governance decision could be proposed by DIONE token holders among the way. + diff --git a/docs/randomness.md b/docs/randomness.md new file mode 100644 index 0000000..10c40ba --- /dev/null +++ b/docs/randomness.md @@ -0,0 +1,13 @@ +# Randomness in Dione network + +“One thing that traditional computer systems aren’t good at is coin flipping,” says Steve Ward, Professor of Computer Science and Engineering at MIT’s Computer Science and Artificial Intelligence Laboratory. + +Computers act deterministically and most of the time calculates a preudo-random numbers. + +In Dione network randomness used to calculate the winner of the consensus round on particular epoch. Using pseudo-random values for such operation could break the consensus behaviour and malicious node could predict the next round winners by flipping the numbers over and over. + +Since we can't trust preudo-random numbers generated by the node itself we have to find a way to get as random value as possible. + +Dione network uses Drand (dee-rand) - distributed randomness beacon. + +You could find more information about Drand using this [link](https://drand.love) \ No newline at end of file diff --git a/docs/task.md b/docs/task.md new file mode 100644 index 0000000..1cbbdd0 --- /dev/null +++ b/docs/task.md @@ -0,0 +1,17 @@ +# Dione network tasks + +Task is a computational unit in Dione oracle network. Miners computes the tasks by getting requests from Dione smart contracts on Ethereum chain and making cross-chain operations. + +Every task has it's own epoch, miner address who computed the task information corresponding the Dione mining operations, payload that represents the state from another blockchain network, it's own signature etc. (Task types and origin types would be added shortly) + +``` +type DioneTask struct { + Miner address.Address + Ticket *Ticket + ElectionProof *ElectionProof + BeaconEntries []BeaconEntry + Signature *crypto.Signature + Epoch TaskEpoch + Payload []byte +} +``` diff --git a/types/task.go b/types/task.go index 49bf027..662d007 100644 --- a/types/task.go +++ b/types/task.go @@ -25,7 +25,8 @@ type DioneTask struct { ElectionProof *ElectionProof BeaconEntries []BeaconEntry Signature *crypto.Signature - Height TaskEpoch + Epoch TaskEpoch + Payload []byte } var tasksPerEpoch = NewInt(config.TasksPerEpoch)