Skip to content

Commit

Permalink
use offset range and resolve makram's comments
Browse files Browse the repository at this point in the history
  • Loading branch information
dimkouv committed Nov 4, 2024
1 parent 05e0820 commit a5dce6e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
8 changes: 7 additions & 1 deletion commit/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
16 changes: 12 additions & 4 deletions commit/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down Expand Up @@ -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)
}

Expand Down Expand Up @@ -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)
}

Expand Down Expand Up @@ -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)
}

Expand Down

0 comments on commit a5dce6e

Please sign in to comment.