Skip to content

Commit

Permalink
Merge branch 'main' into BCFR-967
Browse files Browse the repository at this point in the history
  • Loading branch information
jmank88 authored Nov 4, 2024
2 parents c2c9a94 + 3072d4c commit f184abd
Show file tree
Hide file tree
Showing 26 changed files with 3,039 additions and 367 deletions.
13 changes: 7 additions & 6 deletions pkg/capabilities/consensus/ocr3/aggregators/identical.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ import (
ocrcommon "github.com/smartcontractkit/libocr/commontypes"
)

// Aggregates by the most frequent observation for each index of a data set
type identicalAggregator struct {
config aggregatorConfig
config identicalAggConfig
}

type aggregatorConfig struct {
type identicalAggConfig struct {
// Length of the list of observations that each node is expected to provide.
// Aggregator's output (i.e. EncodableOutcome) will be a values.Map with the same
// number of elements and keyed by indices 0,1,2,... (unless KeyOverrides are provided).
Expand Down Expand Up @@ -102,7 +103,7 @@ func (a *identicalAggregator) collectHighestCounts(counters []map[[32]byte]*coun
}

func NewIdenticalAggregator(config values.Map) (*identicalAggregator, error) {
parsedConfig, err := ParseConfig(config)
parsedConfig, err := ParseConfigIdenticalAggregator(config)
if err != nil {
return nil, fmt.Errorf("failed to parse config (%+v): %w", config, err)
}
Expand All @@ -111,10 +112,10 @@ func NewIdenticalAggregator(config values.Map) (*identicalAggregator, error) {
}, nil
}

func ParseConfig(config values.Map) (aggregatorConfig, error) {
parsedConfig := aggregatorConfig{}
func ParseConfigIdenticalAggregator(config values.Map) (identicalAggConfig, error) {
parsedConfig := identicalAggConfig{}
if err := config.UnwrapTo(&parsedConfig); err != nil {
return aggregatorConfig{}, err
return identicalAggConfig{}, err
}
if parsedConfig.ExpectedObservationsLen == 0 {
parsedConfig.ExpectedObservationsLen = 1
Expand Down
8 changes: 4 additions & 4 deletions pkg/capabilities/consensus/ocr3/aggregators/identical_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
)

func TestDataFeedsAggregator_Aggregate(t *testing.T) {
config := getConfig(t, nil)
config := getConfigIdenticalAggregator(t, nil)
agg, err := aggregators.NewIdenticalAggregator(*config)
require.NoError(t, err)

Expand All @@ -37,7 +37,7 @@ func TestDataFeedsAggregator_Aggregate(t *testing.T) {
}

func TestDataFeedsAggregator_Aggregate_OverrideWithKeys(t *testing.T) {
config := getConfig(t, []string{"outcome"})
config := getConfigIdenticalAggregator(t, []string{"outcome"})
agg, err := aggregators.NewIdenticalAggregator(*config)
require.NoError(t, err)

Expand All @@ -61,7 +61,7 @@ func TestDataFeedsAggregator_Aggregate_OverrideWithKeys(t *testing.T) {
}

func TestDataFeedsAggregator_Aggregate_NoConsensus(t *testing.T) {
config := getConfig(t, []string{"outcome"})
config := getConfigIdenticalAggregator(t, []string{"outcome"})
agg, err := aggregators.NewIdenticalAggregator(*config)
require.NoError(t, err)

Expand All @@ -81,7 +81,7 @@ func TestDataFeedsAggregator_Aggregate_NoConsensus(t *testing.T) {
require.ErrorContains(t, err, "can't reach consensus on observations with index 0")
}

func getConfig(t *testing.T, overrideKeys []string) *values.Map {
func getConfigIdenticalAggregator(t *testing.T, overrideKeys []string) *values.Map {
unwrappedConfig := map[string]any{
"expectedObservationsLen": len(overrideKeys),
"keyOverrides": overrideKeys,
Expand Down
Loading

0 comments on commit f184abd

Please sign in to comment.