Skip to content

Commit

Permalink
add nonce to block vote
Browse files Browse the repository at this point in the history
otherwise it gets deduped at network layer
  • Loading branch information
jordanschalm committed Feb 7, 2020
1 parent 8632b6a commit 1eb59ff
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 2 deletions.
2 changes: 2 additions & 0 deletions cmd/consensus/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.log
data*
27 changes: 27 additions & 0 deletions cmd/consensus/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#/bin/sh

echo "Running 1"
./consensus \
--entries consensus-0000000000000000000000000000000000000000000000000000000000000001@localhost:8001=1000,consensus-0000000000000000000000000000000000000000000000000000000000000002@localhost:8002=1000,consensus-0000000000000000000000000000000000000000000000000000000000000003@localhost:8003=1000 \
--connections 2 \
--nodeid 0000000000000000000000000000000000000000000000000000000000000001 \
--datadir ./data1 \
&>./node1.log &

echo "Running 2"
./consensus \
--entries consensus-0000000000000000000000000000000000000000000000000000000000000001@localhost:8001=1000,consensus-0000000000000000000000000000000000000000000000000000000000000002@localhost:8002=1000,consensus-0000000000000000000000000000000000000000000000000000000000000003@localhost:8003=1000 \
--connections 2 \
--nodeid 0000000000000000000000000000000000000000000000000000000000000002 \
--datadir ./data2 \
&>./node2.log &

echo "Running 3"
./consensus \
--entries consensus-0000000000000000000000000000000000000000000000000000000000000001@localhost:8001=1000,consensus-0000000000000000000000000000000000000000000000000000000000000002@localhost:8002=1000,consensus-0000000000000000000000000000000000000000000000000000000000000003@localhost:8003=1000 \
--connections 2 \
--nodeid 0000000000000000000000000000000000000000000000000000000000000003 \
--datadir ./data3 \
&>./node3.log &

echo "Done"
4 changes: 2 additions & 2 deletions cmd/scaffold.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,10 @@ func (fnb *FlowNodeBuilder) enqueueNetworkInit() {

codec := json.NewCodec()

mw, err := libp2p.NewMiddleware(fnb.Logger, codec, fnb.Me.Address(), fnb.Me.NodeID())
mw, err := libp2p.NewMiddleware(fnb.Logger.Level(zerolog.Disabled), codec, fnb.Me.Address(), fnb.Me.NodeID())
fnb.MustNot(err).Msg("could not initialize flow middleware")

net, err := libp2p.NewNetwork(fnb.Logger, codec, fnb.State, fnb.Me, mw, 10e6)
net, err := libp2p.NewNetwork(fnb.Logger.Level(zerolog.Disabled), codec, fnb.State, fnb.Me, mw, 10e6)
fnb.MustNot(err).Msg("could not initialize flow network")
fnb.Network = net
return net
Expand Down
2 changes: 2 additions & 0 deletions engine/simulation/coldstuff/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package coldstuff

import (
"fmt"
"math/rand"
"time"

"github.com/dgraph-io/badger/v2"
Expand Down Expand Up @@ -480,6 +481,7 @@ func (e *Engine) voteOnProposal() error {
// send vote for proposal to leader
vote := &coldstuff.BlockVote{
BlockID: candidate.ID(),
Nonce: rand.Uint64(),
}
err := e.con.Submit(vote, e.round.Leader().NodeID)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions model/coldstuff/blockVote.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ import (
// BlockVote is a coldstuff consensus event to vote for a block.
type BlockVote struct {
BlockID flow.Identifier
Nonce uint64
}

0 comments on commit 1eb59ff

Please sign in to comment.