Skip to content

Commit

Permalink
add less aggresive configs and prune dup votes
Browse files Browse the repository at this point in the history
  • Loading branch information
yan-soon authored and yan-soon committed Jun 10, 2024
1 parent c3438e4 commit d947aab
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 2 additions & 2 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -858,8 +858,8 @@ type OracleConfig struct {
// DefaultOracleConfig returns a default configuration for the CometBFT oracle service
func DefaultOracleConfig() *OracleConfig {
return &OracleConfig{
MaxOracleGossipBlocksDelayed: 2, // keep all gossipVotes from at most 2 blocks behind
MaxOracleGossipAge: 15, // keep all gossipVotes from at most 15s ago
MaxOracleGossipBlocksDelayed: 3, // keep all gossipVotes from at most 3 blocks behind
MaxOracleGossipAge: 20, // keep all gossipVotes from at most 20s ago
SignInterval: 100 * time.Millisecond, // 0.1s
GossipInterval: 100 * time.Millisecond, // 0.1s
PruneInterval: 500 * time.Millisecond, // 0.5s
Expand Down
11 changes: 11 additions & 0 deletions oracle/service/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package runner

import (
"context"
"fmt"
"sort"

"time"
Expand Down Expand Up @@ -125,7 +126,17 @@ func PruneVoteBuffers(oracleInfo *types.OracleInfo, consensusState *cs.State) {
oracleInfo.UnsignedVoteBuffer.UpdateMtx.Lock()
newVotes := []*oracleproto.Vote{}
unsignedVoteBuffer := oracleInfo.UnsignedVoteBuffer.Buffer
visitedVoteMap := make(map[string]struct{})
for _, vote := range unsignedVoteBuffer {
// check for dup votes
key := fmt.Sprintf("%v:%v", vote.Timestamp, vote.OracleId)
_, exists := visitedVoteMap[key]
if exists {
continue
}

visitedVoteMap[key] = struct{}{}

if vote.Timestamp >= latestAllowableTimestamp {
newVotes = append(newVotes, vote)
}
Expand Down

0 comments on commit d947aab

Please sign in to comment.