Skip to content

Commit

Permalink
Don't broadcast entry reveals if they don't validate. Add script to p…
Browse files Browse the repository at this point in the history
…ut in entries without a chain to test this bug
  • Loading branch information
PaulSnow committed Jan 31, 2018
1 parent 71f0804 commit 8804123
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 3 deletions.
61 changes: 61 additions & 0 deletions scripts/oneChain.sh
@@ -0,0 +1,61 @@
#!/bin/bash

nchains=1 # number of chains to create
nentries=15000000 # number of entries to add to each chain

#factomd=10.41.0.16:8088
factomd=localhost:8088

# This address is for a LOCAL network
fa1=$(factom-cli -s=$factomd importaddress Fs3E9gV6DXsYzf7Fqx1fVBQPQXV695eP3k5XbmHEZVRLkMdD9qCK)

# This address is for a network with a production Genesis block
#fa1=FA3RrKWJLQeDuzC9YzxcSwenU1qDzzwjR1uHMpp1SQbs8wH9Qbbr

maxsleep=15

ec1=$(factom-cli -s=$factomd importaddress Es3LB2YW9bpdWmMnNQYb31kyPzqnecsNqmg5W4K7FKp4UP6omRTa)


buyECs=$(expr $nentries \* $nchains \* 11 )
echo "Buying" $buyECs $fa1 $ec1
factom-cli -s=$factomd buyec $fa1 $ec1 $buyECs
sleep 5s


addentries() {
# create a random datafile
datalen=$(shuf -i 100-1900 -n 1)
datafile=$(mktemp)
base64 /dev/urandom | head -c $datalen > $datafile

sleep $(( ( RANDOM % $maxsleep ) + 1 ))

echo "Entry Length " $datalen " bytes, file name: " $datafile

for ((i=0; i<nentries; i++)); do
cat $datafile | factom-cli -s=$factomd addentry -f -c $1 -e test -e $i -e $RANDOM -e $RANDOM -e $RANDOM $ec1
echo "write entry Chain:" $1 $2 $i
sleep .5
done

# get rid of the random datafile
rm $datafile
}

echo "Start"

for ((i=0; i<nchains; i++)); do
echo "create chain" $i
#chainid=$(echo test $i $RANDOM | factom-cli -s=$factomd addchain -f -n test -n $i -n $RANDOM $ec1 | awk '/ChainID/{print $2}')
addentries 658c1e459b9aefca46fa10da43c3938e6b31698dcbdd2f4ad0cf35f7bf9aa6fa $i &
sleep $(( ( RANDOM % $maxsleep ) + 1 ))
done


echo SLEEP "90 seconds before doing another set of chains."
sleep $(( ( RANDOM % ($maxsleep*2) ) + 1 ))
echo About ready ...
sleep $maxsleep
sleep 10h

10 changes: 7 additions & 3 deletions state/stateConsensus.go
Expand Up @@ -909,7 +909,9 @@ func (s *State) FollowerExecuteRevealEntry(m interfaces.IMsg) {
TotalHoldingQueueInputs.Inc()

if s.Commits.Get(m.GetMsgHash().Fixed()) != nil {
m.SendOut(s, m)
if m.Validate(s) == 1 {
m.SendOut(s, m)
}
}

s.Holding[m.GetMsgHash().Fixed()] = m
Expand Down Expand Up @@ -1092,7 +1094,9 @@ func (s *State) LeaderExecuteCommitEntry(m interfaces.IMsg) {
re := s.Holding[ce.CommitEntry.EntryHash.Fixed()]
if re != nil {
s.XReview = append(s.XReview, re)
re.SendOut(s, re)
if re.Validate(s) == 1 {
re.SendOut(s, re)
}
}
}

Expand Down Expand Up @@ -1231,7 +1235,7 @@ func (s *State) ProcessCommitEntry(dbheight uint32, commitEntry interfaces.IMsg)
h := c.CommitEntry.EntryHash
s.PutCommit(h, c)
entry := s.Holding[h.Fixed()]
if entry != nil {
if entry != nil && entry.Validate(s) == 1 {
entry.FollowerExecute(s)
entry.SendOut(s, entry)
TotalXReviewQueueInputs.Inc()
Expand Down

0 comments on commit 8804123

Please sign in to comment.