diff options
-rw-r--r-- | cmd/gdex/main.go | 4 | ||||
-rw-r--r-- | cmd/gdex/usage.go | 4 | ||||
-rw-r--r-- | cmd/utils/flags.go | 8 | ||||
-rw-r--r-- | dex/backend.go | 11 | ||||
-rw-r--r-- | dex/handler.go | 4 | ||||
-rwxr-xr-x | test/run_test.sh | 27 |
6 files changed, 39 insertions, 19 deletions
diff --git a/cmd/gdex/main.go b/cmd/gdex/main.go index 270c8f7b4..376559ef3 100644 --- a/cmd/gdex/main.go +++ b/cmd/gdex/main.go @@ -97,7 +97,7 @@ var ( utils.ListenPortFlag, utils.MaxPeersFlag, utils.MaxPendingPeersFlag, - utils.ProposingEnabledFlag, + utils.BlockProposerEnabledFlag, utils.MiningEnabledFlag, utils.MinerThreadsFlag, utils.MinerLegacyThreadsFlag, @@ -357,7 +357,7 @@ func startNode(ctx *cli.Context, stack *node.Node) { } } - if ctx.GlobalBool(utils.ProposingEnabledFlag.Name) { + if ctx.GlobalBool(utils.BlockProposerEnabledFlag.Name) { if ctx.GlobalString(utils.SyncModeFlag.Name) == "light" { utils.Fatalf("Light clients do not support proposing") } diff --git a/cmd/gdex/usage.go b/cmd/gdex/usage.go index e8c2201ed..b9d4d1833 100644 --- a/cmd/gdex/usage.go +++ b/cmd/gdex/usage.go @@ -183,9 +183,9 @@ var AppHelpFlagGroups = []flagGroup{ }, }, { - Name: "PROPOSER", + Name: "BLOCK PROPOSER", Flags: []cli.Flag{ - utils.ProposingEnabledFlag, + utils.BlockProposerEnabledFlag, }, }, { diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index e814044d7..d41f298e8 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -316,10 +316,10 @@ var ( Usage: "Number of trie node generations to keep in memory", Value: int(state.MaxTrieCacheGen), } - // Proposer settings - ProposingEnabledFlag = cli.BoolFlag{ - Name: "propose", - Usage: "Enable proposing", + // Nodeset settings + BlockProposerEnabledFlag = cli.BoolFlag{ + Name: "bp", + Usage: "Enable block proposer mode (node set)", } // Miner settings MiningEnabledFlag = cli.BoolFlag{ diff --git a/dex/backend.go b/dex/backend.go index 3a50eb649..74aea8325 100644 --- a/dex/backend.go +++ b/dex/backend.go @@ -249,12 +249,6 @@ func (s *Dexon) Start(srvr *p2p.Server) error { // Start the networking layer and the light server if requested s.protocolManager.Start(srvr, maxPeers) s.protocolManager.addSelfMeta() - - go func() { - time.Sleep(10 * time.Second) - // TODO: Run with the latest confirmed block in compaction chain. - s.consensus.Run(&coreTypes.Block{}) - }() return nil } @@ -263,9 +257,8 @@ func (s *Dexon) Stop() error { } func (s *Dexon) StartProposing() error { - // TODO(sonic): - // enable dispatch vote, agreement result, finalization result.. msg to consensus core. - log.Debug("###############start proposing") + // TODO: Run with the latest confirmed block in compaction chain. + s.consensus.Run(&coreTypes.Block{}) return nil } diff --git a/dex/handler.go b/dex/handler.go index 68c682eda..00d2fb78c 100644 --- a/dex/handler.go +++ b/dex/handler.go @@ -1046,7 +1046,9 @@ func (pm *ProtocolManager) peerSetLoop() { for { select { - case <-pm.chainHeadCh: + case event := <-pm.chainHeadCh: + pm.BroadcastBlock(event.Block, true) + newRound := pm.gov.LenCRS() - 1 log.Trace("new round", "round", newRound) if newRound == round { diff --git a/test/run_test.sh b/test/run_test.sh index 91742ca4b..c07da0f8e 100755 --- a/test/run_test.sh +++ b/test/run_test.sh @@ -2,18 +2,43 @@ GDEX=../build/bin/gdex +# Kill all previous instances. pkill -9 -f gdex +# Start bootnode. bootnode -nodekey bootnode.key --verbosity=9 > bootnode.log 2>&1 & logsdir=$PWD/log-$(date '+%Y-%m-%d-%H:%M:%S') mkdir $logsdir +rm -f log-latest +ln -s $logsdir log-latest + +# A standalone RPC server for accepting RPC requests. +datadir=$PWD/Dexon.rpc +rm -rf $datadir +$GDEX --datadir=$datadir init genesis.json +$GDEX --verbosity=4 --gcmode=archive --datadir=$datadir \ + --rpc --rpcapi=eth,net,web3,debug --rpcaddr=0.0.0.0 --rpcport=8543 \ + --ws --wsapi=eth,net,web3,debug --wsaddr=0.0.0.0 --wsport=8544 \ + --wsorigins='*' --rpcvhosts='*' --rpccorsdomain="*" \ + > $logsdir/gdex.rpc.log 2>&1 & + +# Nodes for i in $(seq 0 3); do datadir=$PWD/Dexon.$i rm -rf $datadir $GDEX --datadir=$datadir init genesis.json - $GDEX --verbosity=4 --gcmode=archive --datadir=$datadir --nodekey=test$i.nodekey --port=$((28000 + $i)) --rpc --rpcaddr=0.0.0.0 --rpcport=$((8545 + $i * 2)) --rpcapi=eth,net,web3,debug --ws --wsapi=eth,net,web3,debug --wsaddr=0.0.0.0 --wsport=$((8546 + $i * 2)) --wsorigins='*' --rpcvhosts='*' --rpccorsdomain="*" > $logsdir/gdex.$i.log 2>&1 & + $GDEX --verbosity=4 --gcmode=archive \ + --bp \ + --datadir=$datadir --nodekey=test$i.nodekey \ + --port=$((30305 + $i)) \ + --rpc --rpcapi=eth,net,web3,debug \ + --rpcaddr=0.0.0.0 --rpcport=$((8545 + $i * 2)) \ + --ws --wsapi=eth,net,web3,debug \ + --wsaddr=0.0.0.0 --wsport=$((8546 + $i * 2)) \ + --wsorigins='*' --rpcvhosts='*' --rpccorsdomain="*" \ + > $logsdir/gdex.$i.log 2>&1 & done tail -f $logsdir/gdex.*.log |