aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWei-Ning Huang <w@dexon.org>2018-11-03 15:28:45 +0800
committerWei-Ning Huang <w@byzantine-lab.io>2019-06-12 17:27:17 +0800
commit43b14136118d600f14a4ae706557fa14401047d2 (patch)
tree9595f648b2b369913d828023b458c152c7e76d33
parentd7f599a14d89e7ce1e9f2ab44a01e0d63c428f26 (diff)
downloadgo-tangerine-43b14136118d600f14a4ae706557fa14401047d2.tar.gz
go-tangerine-43b14136118d600f14a4ae706557fa14401047d2.tar.zst
go-tangerine-43b14136118d600f14a4ae706557fa14401047d2.zip
test: start a separate RPC node for testing block sync
-rw-r--r--cmd/gdex/main.go4
-rw-r--r--cmd/gdex/usage.go4
-rw-r--r--cmd/utils/flags.go8
-rw-r--r--dex/backend.go11
-rw-r--r--dex/handler.go4
-rwxr-xr-xtest/run_test.sh27
6 files changed, 39 insertions, 19 deletions
diff --git a/cmd/gdex/main.go b/cmd/gdex/main.go
index 84a02cca4..0fb94b89e 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,
@@ -358,7 +358,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 685b5bc1c..496e20ecf 100644
--- a/cmd/gdex/usage.go
+++ b/cmd/gdex/usage.go
@@ -184,9 +184,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 b96a155ff..feb304706 100644
--- a/cmd/utils/flags.go
+++ b/cmd/utils/flags.go
@@ -317,10 +317,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