add doc and fix conflict of merge

pull/366/head
Minh Doan 6 years ago committed by Minh Doan
parent 47f7ab1525
commit 741735b73e
  1. 5
      api/services/syncing/syncing.md
  2. 19
      cmd/beaconchain/beaconchain.md
  3. 2
      cmd/harmony.go
  4. 55
      node/service/support_client.go

@ -1,7 +1,9 @@
### Full state syncing ### Full state syncing
A node downloads all the missing blocks until it catches up with the block that is in the process of consensus. A node downloads all the missing blocks until it catches up with the block that is in the process of consensus.
### Node states ### Node states
The states of a node have the following options: The states of a node have the following options:
NodeInit, NodeWaitToJoin, NodeNotInSync, NodeOffline, NodeReadyForConsensus, NodeDoingConsensus NodeInit, NodeWaitToJoin, NodeNotInSync, NodeOffline, NodeReadyForConsensus, NodeDoingConsensus
@ -9,4 +11,5 @@ NodeInit, NodeWaitToJoin, NodeNotInSync, NodeOffline, NodeReadyForConsensus, Nod
When any node joins the network, it will join the shard and try to participate in the consensus process. It will assume its status is NodeReadyForConsensus until it finds it is not able to verify the new block. Then it will move its status into NodeNotInSync. After finish the syncing process, its status becomes NodeReadyForConsensus again. Simply speaking, most of the time, its status is jumping between these two states. When any node joins the network, it will join the shard and try to participate in the consensus process. It will assume its status is NodeReadyForConsensus until it finds it is not able to verify the new block. Then it will move its status into NodeNotInSync. After finish the syncing process, its status becomes NodeReadyForConsensus again. Simply speaking, most of the time, its status is jumping between these two states.
### Doing syncing ### Doing syncing
Syncing process consists of 3 parts: download the old blocks that have timestamps before state syncing beginning time; register to a few peers and accept new blocks that have timestampes after state syncing beginning time; catch the last mile blocks from consensus process when its latest block is only 1~2 blocks behind the current consensus block.
Syncing process consists of 3 parts: download the old blocks that have timestamps before state syncing beginning time; register to a few peers (full node) and accept new blocks that have timestampes after state syncing beginning time; catch the last mile blocks from consensus process when its latest block is only 1~2 blocks behind the current consensus block.

@ -0,0 +1,19 @@
# Nodes running at bootstrap
```
We will have N+1 shards running at bootstrap where shard 0 is considered as beacon shard. As the staking will happen in beacon shard the beaconchain block should contain accounts where the new node utilizes to register. We will keep the current node as bootstrap nodes running as beaconchain which provide with followings:
1. Provide the communication protocol with new node.
2. How staking happens.
3. Data structure for staking
4. How to update discovery with DNS Seeder (bootnodes)
5.
```
```mermaid
graph LR
A[Hard edge] -->B(Round edge)
B --> C{Decision}
C -->|One| D[Result one]
C -->|Two| E[Result two]
```

@ -150,8 +150,6 @@ func main() {
clientPeer = candidateNode.GetClientPeer() clientPeer = candidateNode.GetClientPeer()
selfPeer.PubKey = candidateNode.PubK selfPeer.PubKey = candidateNode.PubK
fmt.Println("Harmnoy", leader, selfPeer)
var role string var role string
if leader.IP == *ip && leader.Port == *port { if leader.IP == *ip && leader.Port == *port {
role = "leader" role = "leader"

@ -0,0 +1,55 @@
package service
import (
"strconv"
"github.com/ethereum/go-ethereum/common"
clientService "github.com/harmony-one/harmony/api/client/service"
"github.com/harmony-one/harmony/core/state"
"github.com/harmony-one/harmony/internal/utils"
)
const (
// ClientServicePortDiff is the positive port diff for client service
ClientServicePortDiff = 5555
)
// SupportClient ...
type SupportClient struct {
server *clientService.Server
port string
}
// NewSupportClient ...
func NewSupportClient(stateReader func() (*state.DB, error), callFaucetContract func(common.Address) common.Hash, nodePort string) *SupportClient {
port, _ := strconv.Atoi(nodePort)
return &SupportClient{server: clientService.NewServer(stateReader, callFaucetContract), port: strconv.Itoa(port + ClientServicePortDiff)}
}
// Start ...
func (sc *SupportClient) Start() {
sc.server.Start(sc.ip, sc.port)
}
// Stop ...
func (sc *SupportClient) Stop() {
}
// SupportClient initializes and starts the client service
func (node *Node) SupportClient() {
node.InitClientServer()
node.StartClientServer()
}
// InitClientServer initializes client server.
func (node *Node) InitClientServer() {
node.clientServer = clientService.NewServer(node.blockchain.State, node.CallFaucetContract)
}
// StartClientServer starts client server.
func (node *Node) StartClientServer() {
port, _ := strconv.Atoi(node.SelfPeer.Port)
utils.GetLogInstance().Info("support_client: StartClientServer on port:", "port", port+ClientServicePortDiff)
node.clientServer.Start(node.SelfPeer.IP, strconv.Itoa(port+ClientServicePortDiff))
}
Loading…
Cancel
Save