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

Write request decode validation as async fn #1901

Merged
merged 3 commits into from
Dec 18, 2020

Conversation

dapplion
Copy link
Contributor

  • Move validation logic out of the async generator into a standalone function
  • Use LodestarError pattern for validation errors
  • Use RequestDecodeErrorCode in tests instead of asserting raw strings

@github-actions github-actions bot added the scope-networking All issues related to networking, gossip, and libp2p. label Dec 18, 2020
@codeclimate
Copy link

codeclimate bot commented Dec 18, 2020

Code Climate has analyzed commit 7cb87c4 and detected 2 issues on this pull request.

Here's the issue category breakdown:

Category Count
Complexity 2

View more on Code Climate.

@dapplion dapplion changed the title Write eth2RequestDecode in async function form Write request decode validation in async function form Dec 18, 2020
@dapplion dapplion changed the title Write request decode validation in async function form Write request decode validation as async fn Dec 18, 2020
@wemeetagain wemeetagain merged commit f538279 into master Dec 18, 2020
@wemeetagain wemeetagain deleted the dapplion/eth2RequestDecode branch December 18, 2020 21:08
if (sszDataLength === null) {
sszDataLength = decode(chunk.slice());
if (decode.bytes > 10) {
logger.error("eth2RequestDecode: Invalid number of bytes for protobuf varint", {
Copy link
Member

Choose a reason for hiding this comment

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

IMO having method in log could be useful


// only one request body accepted, so return
try {
return type.deserialize(buffer.slice(0, sszDataLength));
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if you don't break when reading from source, do you even close stream. It's been a while,
but I remember that it could hang open if you don't read everything or break. libp2p handles open and closes in post loop cleanup. I know we had some issues because if you don't finish reading that post iteration cleanup did not occur.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope-networking All issues related to networking, gossip, and libp2p.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants