Skip to content
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

Merged
merged 5 commits into from
Nov 29, 2023

Conversation

koko1123
Copy link
Contributor

Closes #1408

@koko1123 koko1123 requested review from zhangchiqing, sideninja and peterargue and removed request for peterargue November 27, 2023 21:53
@codecov-commenter
Copy link

codecov-commenter commented Nov 27, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (c344c88) 56.28% compared to head (bc6ebab) 56.22%.
Report is 35 commits behind head on master.

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     
Flag Coverage Δ
unittests 56.22% <100.00%> (-0.07%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment on lines 993 to 994
if builder.stateStreamConf.HeartbeatInterval == 0 {
return errors.New("state-stream-max-register-values must be greater than or equal to 0")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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
Copy link
Contributor

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

Suggested change
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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) {
Copy link
Contributor

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

Copy link
Contributor

@peterargue peterargue left a 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")
Copy link
Contributor

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?

Copy link
Contributor Author

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())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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() {
Copy link
Contributor

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,
Copy link
Member

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?

Suggested change
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")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
DefaultMaxRegisterIDsPerMsg = 100
DefaultRegisterIDsLimit = 100

@koko1123 koko1123 added this pull request to the merge queue Nov 29, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 29, 2023
@peterargue peterargue added this pull request to the merge queue Nov 29, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 29, 2023
@peterargue peterargue added this pull request to the merge queue Nov 29, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 29, 2023
@koko1123 koko1123 added this pull request to the merge queue Nov 29, 2023
Merged via the queue into master with commit 9577079 Nov 29, 2023
54 checks passed
@koko1123 koko1123 deleted the amlandeep/refactor-state-sync-registers branch November 29, 2023 23:57
koko1123 added a commit that referenced this pull request Nov 30, 2023
…gisters

[Access] Make RegisterID request size configurable
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add size limit to GetRegisters API
4 participants