factor(*): return consensus status when vp node is un-ready
This commit is contained in:
parent
1d28c012ba
commit
13a933ff61
|
@ -14,8 +14,9 @@ import (
|
|||
// SendTransaction handles transaction sent by the client.
|
||||
// If the transaction is valid, it will return the transaction hash.
|
||||
func (cbs *ChainBrokerService) SendTransaction(ctx context.Context, tx *pb.Transaction) (*pb.TransactionHashMsg, error) {
|
||||
if !cbs.api.Broker().OrderReady() {
|
||||
return nil, fmt.Errorf("the system is temporarily unavailable")
|
||||
err := cbs.api.Broker().OrderReady()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("the system is temporarily unavailable, err: %s", err.Error())
|
||||
}
|
||||
|
||||
if err := cbs.checkTransaction(tx); err != nil {
|
||||
|
|
|
@ -36,7 +36,7 @@ server_key_path = "certs/server.key"
|
|||
report_caller = false
|
||||
[log.module]
|
||||
p2p = "info"
|
||||
consensus = "info"
|
||||
consensus = "debug"
|
||||
executor = "info"
|
||||
router = "info"
|
||||
api = "info"
|
||||
|
@ -47,7 +47,7 @@ server_key_path = "certs/server.key"
|
|||
verify = true
|
||||
|
||||
[order]
|
||||
plugin = "plugins/raft.so"
|
||||
plugin = "plugins/rbft.so"
|
||||
|
||||
[executor]
|
||||
type = "serial" # opensource version only supports serial type, commercial version supports serial and parallel types
|
||||
|
|
|
@ -18,21 +18,25 @@ disable_proposal_forwarding = true # This prevents blocks from being accidentall
|
|||
fetch_timeout = "3s" # How long to wait before fetching missing transactions finished
|
||||
|
||||
[rbft] #RBFT configurations
|
||||
set_size = 100 # How many transactions should the node broadcast at once
|
||||
set_size = 25 # How many transactions should the node broadcast at once
|
||||
batch_size = 500 # How many transactions should the primary pack before sending pre-prepare
|
||||
pool_size = 50000 # How many transactions could the txPool stores in total
|
||||
vc_resend_limit = 10 # How many times of same vc from self before a replica start recovery
|
||||
vc_period = 0 # After how many checkpoint periods( Blocks = 10 * vcperiod ) the primary gets cycled automatically. ( Set 0 to disable )
|
||||
check_interval = "3m" # interval of the check loop
|
||||
tolerance_time = "5m" # The max tolerance time duration (in seconds) of out-of-date
|
||||
batch_mem_limit = false # Indicates whether limit batch mem size or not
|
||||
batch_max_mem = 10000 # The max memory size of one batch
|
||||
|
||||
[rbft.timeout]
|
||||
nego_view = "6s" # How long to wait for N-f responses after send negotiate view
|
||||
recovery = "15s" # How long to wait before recovery finished(This is for release1.2)
|
||||
first_request = "30s" # How long to wait before first request should come
|
||||
batch = "0.5s"# Primary send a pre-prepare if there are pending requests, although batchsize isn't reached yet,
|
||||
request = "6s" # How long may a request(transaction batch) take between reception and execution, must be greater than the batch timeout
|
||||
validate = "1s" # How long may a validate (transaction batch) process will take by local Validation
|
||||
null_request = "6s" # Primary send it to inform aliveness, must be greater than request timeout
|
||||
viewchange = "8s" # How long may a view change take
|
||||
resend_viewchange= "10s" # How long to wait for a view change quorum before resending (the same) view change
|
||||
clean_viewchange = "60s" # How long to clean out-of-data view change message
|
||||
update = "4s" # How long may a update-n take
|
||||
set = "0.1s" # Node broadcasts transactions if there are cached transactions, although set_size isn't reached yet,
|
||||
sync_state = "3s" # How long to wait quorum sync state response
|
||||
sync_interval = "1m" # How long to restart sync state process
|
||||
recovery = "15s" # How long to wait before recovery finished(This is for release1.2)
|
||||
first_request = "30s" # How long to wait before first request should come
|
||||
batch = "0.5s"# Primary send a pre-prepare if there are pending requests, although batchsize isn't reached yet,
|
||||
request = "6s" # How long may a request(transaction batch) take between reception and execution, must be greater than the batch timeout
|
||||
null_request = "9s" # Primary send it to inform aliveness, must be greater than request timeout
|
||||
viewchange = "8s" # How long may a view change take
|
||||
resend_viewchange = "10s" # How long to wait for a view change quorum before resending (the same) view change
|
||||
clean_viewchange = "60s" # How long to clean out-of-data view change message
|
||||
update = "4s" # How long may a update-n take
|
||||
set = "0.1s" # Node broadcasts transactions if there are cached transactions, although set_size isn't reached yet
|
|
@ -279,7 +279,8 @@ func (bxh *BitXHub) Stop() error {
|
|||
func (bxh *BitXHub) printLogo() {
|
||||
for {
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
if bxh.Order.Ready() {
|
||||
err :=bxh.Order.Ready()
|
||||
if err == nil {
|
||||
bxh.logger.WithFields(logrus.Fields{
|
||||
"plugin_path": bxh.repo.Config.Order.Plugin,
|
||||
}).Info("Order is ready")
|
||||
|
|
|
@ -38,7 +38,7 @@ type BrokerAPI interface {
|
|||
GetInterchainTxWrappers(pid string, begin, end uint64, ch chan<- *pb.InterchainTxWrappers) error
|
||||
|
||||
// OrderReady
|
||||
OrderReady() bool
|
||||
OrderReady() error
|
||||
|
||||
FetchSignsFromOtherPeers(content string, typ pb.GetMultiSignsRequest_Type) map[string][]byte
|
||||
GetSign(content string, typ pb.GetMultiSignsRequest_Type) (string, []byte, error)
|
||||
|
|
|
@ -109,7 +109,7 @@ func (b *BrokerAPI) RemovePier(pid string, isUnion bool) {
|
|||
b.bxh.Router.RemovePier(pid, isUnion)
|
||||
}
|
||||
|
||||
func (b *BrokerAPI) OrderReady() bool {
|
||||
func (b *BrokerAPI) OrderReady() error {
|
||||
return b.bxh.Order.Ready()
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ package etcdraft
|
|||
import (
|
||||
"context"
|
||||
"encoding/binary"
|
||||
"errors"
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"sync"
|
||||
|
@ -161,7 +162,8 @@ func (n *Node) Stop() {
|
|||
|
||||
// Add the transaction into txpool and broadcast it to other nodes
|
||||
func (n *Node) Prepare(tx *pb.Transaction) error {
|
||||
if !n.Ready() {
|
||||
err := n.Ready()
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
return n.mempool.RecvTransaction(tx)
|
||||
|
@ -248,8 +250,12 @@ func (n *Node) IsLeader() bool {
|
|||
return n.leader == n.id
|
||||
}
|
||||
|
||||
func (n *Node) Ready() bool {
|
||||
return n.leader != 0
|
||||
func (n *Node) Ready() error {
|
||||
hashLeader := n.leader != 0
|
||||
if !hashLeader {
|
||||
return errors.New("in leader election status")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// main work loop
|
||||
|
|
|
@ -25,7 +25,7 @@ type Order interface {
|
|||
Step(ctx context.Context, msg []byte) error
|
||||
|
||||
// Ready means whether order has finished electing leader
|
||||
Ready() bool
|
||||
Ready() error
|
||||
|
||||
// ReportState means block was persisted and report it to the consensus engine
|
||||
ReportState(height uint64, hash types.Hash)
|
||||
|
|
|
@ -72,8 +72,8 @@ func (n *Node) Step(ctx context.Context, msg []byte) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (n *Node) Ready() bool {
|
||||
return true
|
||||
func (n *Node) Ready() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (n *Node) ReportState(height uint64, hash types.Hash) {
|
||||
|
|
|
@ -21,10 +21,11 @@ func TestTester(t *testing.T) {
|
|||
node4 := setupNode(t, "./test_data/config/node4")
|
||||
|
||||
for {
|
||||
if node1.Broker().OrderReady() &&
|
||||
node2.Broker().OrderReady() &&
|
||||
node3.Broker().OrderReady() &&
|
||||
node4.Broker().OrderReady() {
|
||||
err1 := node1.Broker().OrderReady()
|
||||
err2 := node2.Broker().OrderReady()
|
||||
err3 := node3.Broker().OrderReady()
|
||||
err4 := node4.Broker().OrderReady()
|
||||
if err1 != nil && err2 != nil && err3 != nil && err4 != nil {
|
||||
break
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue