diff --git a/internal/plugincommon/transmitters.go b/internal/plugincommon/transmitters.go index 488fdd2cb..b7e8b66a4 100644 --- a/internal/plugincommon/transmitters.go +++ b/internal/plugincommon/transmitters.go @@ -2,6 +2,7 @@ package plugincommon import ( "fmt" + "sort" "time" "github.com/smartcontractkit/libocr/commontypes" @@ -33,6 +34,9 @@ func GetTransmissionSchedule( } } + // transmissionSchedule must be deterministic + sort.Slice(transmitters, func(i, j int) bool { return transmitters[i] < transmitters[j] }) + transmissionDelays := make([]time.Duration, len(transmitters)) for i := range transmissionDelays { diff --git a/internal/plugincommon/transmitters_test.go b/internal/plugincommon/transmitters_test.go index 01388304b..d7b21e293 100644 --- a/internal/plugincommon/transmitters_test.go +++ b/internal/plugincommon/transmitters_test.go @@ -50,6 +50,15 @@ func TestGetTransmissionSchedule(t *testing.T) { expectedError: true, chainSupportReturnsError: true, }, + { + name: "determinism check", + allTheOracles: []commontypes.OracleID{3, 1, 2}, // <------ not ordered + oraclesSupportingDest: []commontypes.OracleID{1, 3}, + transmissionDelayMultiplier: 5 * time.Second, + expectedTransmitters: []commontypes.OracleID{1, 3}, + expectedTransmissionDelays: []time.Duration{5 * time.Second, 10 * time.Second}, + expectedError: false, + }, } for _, tc := range testCases {