From a5dce6efccdaf335699a1c24ff41697f04ace298 Mon Sep 17 00:00:00 2001 From: dimkouv Date: Mon, 4 Nov 2024 20:34:17 +0200 Subject: [PATCH] use offset range and resolve makram's comments --- commit/factory.go | 8 +++++++- commit/factory_test.go | 16 ++++++++++++---- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/commit/factory.go b/commit/factory.go index ff0ef2a3a..72c61a591 100644 --- a/commit/factory.go +++ b/commit/factory.go @@ -42,15 +42,21 @@ const ( estimatedMaxNumberOfPricedTokens = 10_000 // maxQueryLength is set to twice the maximum size of a theoretical merkle root processor query - // that assumes 1,000 source chains and 256 (theoretical max) RMN nodes. + // that assumes estimatedMaxNumberOfSourceChains source chains and + // estimatedMaxRmnNodesCount (theoretical max) RMN nodes. + // check factory_test for the calculation maxQueryLength = 559_320 // maxObservationLength is set to the maximum size of an observation + // check factory_test for the calculation maxObservationLength = 1_047_202 // maxOutcomeLength is set to the maximum size of an outcome + // check factory_test for the calculation maxOutcomeLength = 1_167_765 + // maxReportLength is set to an estimate of a maximum report size + // check factory_test for the calculation maxReportLength = 993_982 // maxReportCount is set to 1 because the commit plugin only generates one report per round. diff --git a/commit/factory_test.go b/commit/factory_test.go index 636054b7a..2a333d311 100644 --- a/commit/factory_test.go +++ b/commit/factory_test.go @@ -67,7 +67,9 @@ func Test_maxQueryLength(t *testing.T) { require.NoError(t, err) // We set twice the size, for extra safety while making breaking changes between oracle versions. - assert.Equal(t, 2*len(b), maxQueryLength) + const testOffset = 10 + assert.Greater(t, maxQueryLength, 2*len(b)-testOffset) + assert.Less(t, maxQueryLength, 2*len(b)+testOffset) require.Less(t, maxQueryLength, ocr3types.MaxMaxQueryLength) } @@ -152,7 +154,9 @@ func Test_maxObservationLength(t *testing.T) { b, err := maxObs.Encode() require.NoError(t, err) - assert.Equal(t, len(b), maxObservationLength) + const testOffset = 50 + assert.Greater(t, maxObservationLength, len(b)-testOffset) + assert.Less(t, maxObservationLength, len(b)+testOffset) assert.Less(t, maxObservationLength, ocr3types.MaxMaxObservationLength) } @@ -229,7 +233,9 @@ func Test_maxOutcomeLength(t *testing.T) { b, err := maxOutc.Encode() require.NoError(t, err) - assert.Equal(t, len(b), maxOutcomeLength) + const testOffset = 10 + assert.Greater(t, maxOutcomeLength, len(b)-testOffset) + assert.Less(t, maxOutcomeLength, len(b)+testOffset) assert.Less(t, maxOutcomeLength, ocr3types.MaxMaxOutcomeLength) } @@ -270,7 +276,9 @@ func Test_maxReportLength(t *testing.T) { b, err := json.Marshal(rep) require.NoError(t, err) - assert.Equal(t, len(b), maxReportLength) + const testOffset = 10 + assert.Greater(t, maxReportLength, len(b)-testOffset) + assert.Less(t, maxReportLength, len(b)+testOffset) assert.Less(t, maxReportLength, ocr3types.MaxMaxReportLength) }