diff --git a/integration/integration_test.go b/integration/integration_test.go index 274961f8c..40c009bf9 100644 --- a/integration/integration_test.go +++ b/integration/integration_test.go @@ -293,6 +293,7 @@ func getIntegrationTestCrash(numNodes, numVotes, failingNodes int) func(*testing form, err = getForm(formFac, formID, nodes[0].GetOrdering()) t.Logf("PubsharesUnit: %v", form.PubsharesUnits) require.NoError(t, err) + // LG@240124: had some fuzzy failures when decrypting the ballots here. err = decryptBallots(m, actor, form) require.NoError(t, err) diff --git a/integration/performance_test.go b/integration/performance_test.go index 71aca31b2..34f0b6e74 100644 --- a/integration/performance_test.go +++ b/integration/performance_test.go @@ -23,11 +23,10 @@ import ( "golang.org/x/xerrors" ) -// Check the shuffled votes versus the casted votes and a few nodes +// Check the shuffled votes versus the cast votes and a few nodes func BenchmarkIntegration_CustomVotesScenario(b *testing.B) { - numNodes := 3 - numVotes := 3 + numVotes := 200 numChunksPerBallot := 3 adminID := "I am an admin" @@ -80,8 +79,11 @@ func BenchmarkIntegration_CustomVotesScenario(b *testing.B) { form, err := getForm(formFac, formID, nodes[0].GetOrdering()) require.NoError(b, err) + b.ResetTimer() castedVotes, err := castVotesNChunks(m, actor, form, numVotes) require.NoError(b, err) + durationCasting := b.Elapsed() + b.Logf("Casting %d votes took %v", numVotes, durationCasting) // ##### CLOSE FORM ##### err = closeForm(m, formID, adminID) @@ -91,7 +93,7 @@ func BenchmarkIntegration_CustomVotesScenario(b *testing.B) { // ##### SHUFFLE BALLOTS #### - //b.ResetTimer() + b.ResetTimer() b.Logf("initializing shuffle") sActor, err := initShuffle(nodes) @@ -101,20 +103,35 @@ func BenchmarkIntegration_CustomVotesScenario(b *testing.B) { err = sActor.Shuffle(formID) require.NoError(b, err) - //b.StopTimer() + durationShuffling := b.Elapsed() + + b.Logf("submitting public shares") + + b.ResetTimer() + + _, err = getForm(formFac, formID, nodes[0].GetOrdering()) + require.NoError(b, err) + err = actor.ComputePubshares() + require.NoError(b, err) + + err = waitForStatus(types.PubSharesSubmitted, formFac, formID, nodes, + numNodes, 6*time.Second*time.Duration(numNodes)) + require.NoError(b, err) + + durationPubShares := b.Elapsed() // ##### DECRYPT BALLOTS ##### time.Sleep(time.Second * 1) b.Logf("decrypting") - //b.ResetTimer() - form, err = getForm(formFac, formID, nodes[0].GetOrdering()) require.NoError(b, err) + b.ResetTimer() err = decryptBallots(m, actor, form) require.NoError(b, err) + durationDecrypt := b.Elapsed() //b.StopTimer() @@ -130,6 +147,11 @@ func BenchmarkIntegration_CustomVotesScenario(b *testing.B) { fmt.Println("Number of decrypted ballots : " + strconv.Itoa(len(form.DecryptedBallots))) fmt.Println("Chunks per ballot : " + strconv.Itoa(form.ChunksPerBallot())) + b.Logf("Casting %d votes took %v", numVotes, durationCasting) + b.Logf("Shuffling took: %v", durationShuffling) + b.Logf("Submitting shares took: %v", durationPubShares) + b.Logf("Decryption took: %v", durationDecrypt) + require.Len(b, form.DecryptedBallots, len(castedVotes)) for _, ballot := range form.DecryptedBallots { @@ -213,10 +235,10 @@ func castVotesNChunks(m txManager, actor dkg.Actor, form types.Form, ballotBuilder.Write([]byte(encodeID("bb"))) ballotBuilder.Write([]byte(":")) - textSize := 29*form.ChunksPerBallot() - ballotBuilder.Len() - 3 + ballotBuilder.Write([]byte("\n\n")) + textSize := 29*form.ChunksPerBallot() - ballotBuilder.Len() - 3 ballotBuilder.Write([]byte(strings.Repeat("=", textSize))) - ballotBuilder.Write([]byte("\n\n")) vote := ballotBuilder.String() @@ -227,6 +249,7 @@ func castVotesNChunks(m txManager, actor dkg.Actor, form types.Form, votes := make([]types.Ballot, numberOfVotes) + start := time.Now() for i := 0; i < numberOfVotes; i++ { userID := "user " + strconv.Itoa(i) @@ -251,6 +274,8 @@ func castVotesNChunks(m txManager, actor dkg.Actor, form types.Form, if err != nil { return nil, xerrors.Errorf("failed to addAndWait: %v", err) } + fmt.Printf("Got vote %d at %v after %v\n", i, time.Now(), time.Since(start)) + start = time.Now() var ballot types.Ballot err = ballot.Unmarshal(vote, form) diff --git a/integration/transaction.go b/integration/transaction.go index b33a01795..50549c269 100644 --- a/integration/transaction.go +++ b/integration/transaction.go @@ -6,6 +6,7 @@ import ( "encoding/base64" "encoding/hex" "encoding/json" + "fmt" "io" "net/http" "testing" @@ -114,9 +115,12 @@ func (m txManager) addAndWait(args ...txn.Arg) ([]byte, error) { err = m.n.GetPool().Add(sentTxn) if err != nil { - return nil, xerrors.Errorf("failed to Add: %v", err) + fmt.Printf("Failed to add transaction: %v", err) + continue } + time.Sleep(time.Second) + sentTxnID := sentTxn.GetID() accepted := isAccepted(events, sentTxnID)