-
Notifications
You must be signed in to change notification settings - Fork 175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Access] Make RegisterID request size configurable #5067
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #5067 +/- ##
==========================================
- Coverage 56.28% 56.22% -0.07%
==========================================
Files 976 977 +1
Lines 90985 91176 +191
==========================================
+ Hits 51212 51260 +48
- Misses 35966 36105 +139
- Partials 3807 3811 +4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
if builder.stateStreamConf.HeartbeatInterval == 0 { | ||
return errors.New("state-stream-max-register-values must be greater than or equal to 0") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if builder.stateStreamConf.HeartbeatInterval == 0 { | |
return errors.New("state-stream-max-register-values must be greater than or equal to 0") | |
if builder.stateStreamConf.MaxRegisterIdsPerMsg == 0 { | |
return errors.New("state-stream-max-register-values must be greater than 0") |
@@ -38,6 +38,9 @@ type Config struct { | |||
// MaxGlobalStreams defines the global max number of streams that can be open at the same time. | |||
MaxGlobalStreams uint32 | |||
|
|||
// MaxRegisterIdsPerMsg defines the max number of register IDs that can be received in a single request. | |||
MaxRegisterIdsPerMsg uint32 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: go capitalizes acronyms by convention
MaxRegisterIdsPerMsg uint32 | |
MaxRegisterIDsPerMsg uint32 |
@@ -30,6 +30,9 @@ const ( | |||
|
|||
// DefaultHeartbeatInterval specifies the block interval at which heartbeat messages should be sent. | |||
DefaultHeartbeatInterval = 1 | |||
|
|||
// DefaultMaxRegisterIdsPerMsg defines the default max number of register IDs that can be received in a single request. | |||
DefaultMaxRegisterIdsPerMsg = 100 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DefaultMaxRegisterIdsPerMsg = 100 | |
DefaultMaxRegisterIDsPerMsg = 100 |
@@ -541,18 +541,6 @@ func TestGetRegisterValues(t *testing.T) { | |||
require.Equal(t, status.Code(err), codes.InvalidArgument) | |||
}) | |||
|
|||
t.Run("too many register IDs", func(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should keep this test. how about creating it in backend_test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
few small comments, but otherwise looks good
@@ -988,6 +990,9 @@ func (builder *FlowAccessNodeBuilder) extraFlags() { | |||
if builder.stateStreamConf.ResponseLimit < 0 { | |||
return errors.New("state-stream-response-limit must be greater than or equal to 0") | |||
} | |||
if builder.stateStreamConf.MaxRegisterIDsPerMsg == 0 { | |||
return errors.New("state-stream-max-register-values must be greater than or equal to 0") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this check returns an error if the setting is equal to 0, but the error message says must be greater than or equal to 0
. which is correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed to just greater than 0
values, err := b.registers.RegisterValues(ids, height) | ||
print(err.Error()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
print(err.Error()) |
@@ -423,3 +437,21 @@ func (s *BackendExecutionDataSuite) TestSubscribeExecutionDataHandlesErrors() { | |||
assert.Equal(s.T(), codes.NotFound, status.Code(sub.Err())) | |||
}) | |||
} | |||
|
|||
func (s *BackendExecutionDataSuite) TestGetRegisterValuesErrors() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a happy path test in the backend suite? If not, can you add one?
@@ -202,6 +202,7 @@ func DefaultAccessNodeConfig() *AccessNodeConfig { | |||
EventFilterConfig: state_stream.DefaultEventFilterConfig, | |||
ResponseLimit: state_stream.DefaultResponseLimit, | |||
HeartbeatInterval: state_stream.DefaultHeartbeatInterval, | |||
MaxRegisterIDsPerMsg: state_stream.DefaultMaxRegisterIdsPerMsg, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find the PerMsg
a bit confusing, how about?
MaxRegisterIDsPerMsg: state_stream.DefaultMaxRegisterIdsPerMsg, | |
RegisterIDsRequestLimit: state_stream.DefaultMaxRegisterIdsPerMsg, |
@@ -931,6 +932,7 @@ func (builder *FlowAccessNodeBuilder) extraFlags() { | |||
flags.UintVar(&builder.stateStreamConf.ClientSendBufferSize, "state-stream-send-buffer-size", defaultConfig.stateStreamConf.ClientSendBufferSize, "maximum number of responses to buffer within a stream") | |||
flags.Float64Var(&builder.stateStreamConf.ResponseLimit, "state-stream-response-limit", defaultConfig.stateStreamConf.ResponseLimit, "max number of responses per second to send over streaming endpoints. this helps manage resources consumed by each client querying data not in the cache e.g. 3 or 0.5. 0 means no limit") | |||
flags.Uint64Var(&builder.stateStreamConf.HeartbeatInterval, "state-stream-heartbeat-interval", defaultConfig.stateStreamConf.HeartbeatInterval, "default interval in blocks at which heartbeat messages should be sent. applied when client did not specify a value.") | |||
flags.Uint32Var(&builder.stateStreamConf.MaxRegisterIdsPerMsg, "state-stream-max-register-values", defaultConfig.stateStreamConf.MaxRegisterIdsPerMsg, "maximum number of register ids to include in a single request to the GetRegisters endpoint") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
flags.Uint32Var(&builder.stateStreamConf.MaxRegisterIdsPerMsg, "state-stream-max-register-values", defaultConfig.stateStreamConf.MaxRegisterIdsPerMsg, "maximum number of register ids to include in a single request to the GetRegisters endpoint") | |
flags.Uint32Var(&builder.stateStreamConf.MaxRegisterIdsPerMsg, "state-stream-register-ids-limit", defaultConfig.stateStreamConf.MaxRegisterIdsPerMsg, "limit of register IDs for a single request to the get register endpoint") |
@@ -30,6 +30,9 @@ const ( | |||
|
|||
// DefaultHeartbeatInterval specifies the block interval at which heartbeat messages should be sent. | |||
DefaultHeartbeatInterval = 1 | |||
|
|||
// DefaultMaxRegisterIDsPerMsg defines the default max number of register IDs that can be received in a single request. | |||
DefaultMaxRegisterIDsPerMsg = 100 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DefaultMaxRegisterIDsPerMsg = 100 | |
DefaultRegisterIDsLimit = 100 |
…gisters [Access] Make RegisterID request size configurable
Closes #1408