-
Notifications
You must be signed in to change notification settings - Fork 11
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
Introduce Request Id for binary port communication #315
Introduce Request Id for binary port communication #315
Conversation
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.
lgtm
Cargo.toml
Outdated
@@ -31,3 +31,7 @@ toml = "0.5.8" | |||
tracing = { version = "0", default-features = false } | |||
tracing-subscriber = "0" | |||
serde = { version = "1", default-features = false } | |||
|
|||
[patch.'https://github.com/casper-network/casper-node.git'] | |||
casper-binary-port = { path = "../casper-node/binary_port" } |
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 won't work in CI, or in any workspace that doesn't have ../casper-node
, right?
Wouldn't it be more universal if you pushed your casper-node changes to a branch and refer casper-binary-port to a github branch?
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.
Updated in c1af7cf
@@ -116,6 +118,14 @@ fn resolve_address(address: &str) -> anyhow::Result<SocketAddr> { | |||
.ok_or_else(|| anyhow::anyhow!("failed to resolve address")) | |||
} | |||
|
|||
fn encode_request(req: &BinaryRequest, id: u16) -> Result<Vec<u8>, bytesrepr::Error> { | |||
let header = BinaryRequestHeader::new(SUPPORTED_PROTOCOL_VERSION, req.tag(), id); |
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.
So this is a header that has both SUPPORTED_PROTOCOL_VERSION and the request id? Shouldn't it be a wrapper over a vector of headers? A tuple (u8, bytes[]) where the u8 would be a header tag? That would give us flexibility of adding more headers in the future. If we don't do it like that - we're painting ourselves into a corner, aren't we?
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 dodged the issue by introducing the "header version" field which is a single u16
. Upon handling the request, the binary port component will reject the requests that come with different header version. When we change the header again post 2.0 release, users will need to also upgrade their sidecar installations.
I decided not to support multiple headers because when we're adding a field it usually means that we actually need it for further processing. For example, if we added request id, but we get request w/o request id (from legacy sidecar) we can't properly handle it anyway.
4726: Introduce Request Id for binary port communication r=rafal-ch a=rafal-ch Heads-up: There are several functional changes in this single PR just because each breaking change to the sidecar requires some coordinated merging effort between node and sidecar. Hence, it's more convenient to deliver such changes in one go. This PR introduces: 1. the concept of "request id" to the binary port. This is used to dodge an edge case where it may happen that a response which has not been consumed is incorrectly served as a request to the next request. The corresponding PR in casper-sidecar is [here](casper-network/casper-sidecar#315). 2. Binary request header version - this will prevent binary port from trying to parse binary message headers of incompatible types 3. Promote binary port error code from `u8` to `u16`, because we already have nearly 60 error codes 4. Additional unit tests verifying whether the binary message codec can properly handle large quantities of messages. 5. Additional tests to see if protocol version check is respected Fixes: casper-network/casper-sidecar#312 Co-authored-by: Rafał Chabowski <[email protected]>
4726: Introduce Request Id for binary port communication r=rafal-ch a=rafal-ch Heads-up: There are several functional changes in this single PR just because each breaking change to the sidecar requires some coordinated merging effort between node and sidecar. Hence, it's more convenient to deliver such changes in one go. This PR introduces: 1. the concept of "request id" to the binary port. This is used to dodge an edge case where it may happen that a response which has not been consumed is incorrectly served as a request to the next request. The corresponding PR in casper-sidecar is [here](casper-network/casper-sidecar#315). 2. Binary request header version - this will prevent binary port from trying to parse binary message headers of incompatible types 3. Promote binary port error code from `u8` to `u16`, because we already have nearly 60 error codes 4. Additional unit tests verifying whether the binary message codec can properly handle large quantities of messages. 5. Additional tests to see if protocol version check is respected Fixes: casper-network/casper-sidecar#312 Co-authored-by: Rafał Chabowski <[email protected]>
4726: Introduce Request Id for binary port communication r=rafal-ch a=rafal-ch Heads-up: There are several functional changes in this single PR just because each breaking change to the sidecar requires some coordinated merging effort between node and sidecar. Hence, it's more convenient to deliver such changes in one go. This PR introduces: 1. the concept of "request id" to the binary port. This is used to dodge an edge case where it may happen that a response which has not been consumed is incorrectly served as a request to the next request. The corresponding PR in casper-sidecar is [here](casper-network/casper-sidecar#315). 2. Binary request header version - this will prevent binary port from trying to parse binary message headers of incompatible types 3. Promote binary port error code from `u8` to `u16`, because we already have nearly 60 error codes 4. Additional unit tests verifying whether the binary message codec can properly handle large quantities of messages. 5. Additional tests to see if protocol version check is respected Fixes: casper-network/casper-sidecar#312 Co-authored-by: Rafał Chabowski <[email protected]>
4726: Introduce Request Id for binary port communication r=rafal-ch a=rafal-ch Heads-up: There are several functional changes in this single PR just because each breaking change to the sidecar requires some coordinated merging effort between node and sidecar. Hence, it's more convenient to deliver such changes in one go. This PR introduces: 1. the concept of "request id" to the binary port. This is used to dodge an edge case where it may happen that a response which has not been consumed is incorrectly served as a request to the next request. The corresponding PR in casper-sidecar is [here](casper-network/casper-sidecar#315). 2. Binary request header version - this will prevent binary port from trying to parse binary message headers of incompatible types 3. Promote binary port error code from `u8` to `u16`, because we already have nearly 60 error codes 4. Additional unit tests verifying whether the binary message codec can properly handle large quantities of messages. 5. Additional tests to see if protocol version check is respected Fixes: casper-network/casper-sidecar#312 Co-authored-by: Rafał Chabowski <[email protected]>
This PR introduces the concept of "request id" to the binary port. This is used to dodge an edge case where it may happen that a response which has not been consumed is incorrectly served as a request to the next request.
The corresponding PR in casper-node is here.
Fixes: #312