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

runtime/src/protocol: Deserialize unknown rhp messages as invalid #5094

Merged
merged 1 commit into from
Dec 10, 2022

Conversation

peternose
Copy link
Contributor

@peternose peternose commented Dec 10, 2022

Before:

{"err":"unknown field","level":"error","module":"runtime/protocol","msg":"Failed to handle message","runtime_id":"c000000000000000ffffffffffffffffffffffffffffffffffffffffffffffff","runtime_name":"test-runtime","ts":"2022-12-10T14:02:38.449464523Z"}
{"level":"info","module":"runtime/protocol","msg":"Protocol reader thread is terminating","runtime_id":"c000000000000000ffffffffffffffffffffffffffffffffffffffffffffffff","runtime_name":"test-runtime","ts":"2022-12-10T14:02:38.449491013Z"}

After:

{"err":"unknown field","level":"warn","module":"runtime/protocol","msg":"Unable to decode message","runtime_id":"c000000000000000ffffffffffffffffffffffffffffffffffffffffffffffff","runtime_name":"test-runtime","ts":"2022-12-10T13:59:20.76384491Z"}
{"bytes":"[163, 98, 105, 100, 2, 100, 98, 111, 100, 121, 161, 120, 26, 82, 117, 110, 116, 105, 109, 101, 76, 111, 99, 97, 108, 82, 80, 67, 67, 97, 108, 108, 82, 101, 11
3, 117, 101, 115, 116, 161, 103, 114, 101, 113, 117, 101, 115, 116, 88, 51, 162, 100, 97, 114, 103, 115, 163, 102, 112, 111, 108, 105, 99, 121, 64, 104, 99, 104, 101, 9
9, 107, 115, 117, 109, 64, 108, 109, 97, 121, 95, 103, 101, 110, 101, 114, 97, 116, 101, 245, 102, 109, 101, 116, 104, 111, 100, 100, 105, 110, 105, 116, 108, 109, 101,
 115, 115, 97, 103, 101, 95, 116, 121, 112, 101, 1]","level":"debug","module":"runtime/protocol","msg":"Malformed message","runtime_id":"c000000000000000fffffffffffffffff
fffffffffffffffffffffffffffffff","runtime_name":"test-runtime","ts":"2022-12-10T13:59:20.76387489Z"}
{"level":"warn","module":"runtime/protocol","msg":"Received a malformed message","runtime_id":"c000000000000000ffffffffffffffffffffffffffffffffffffffffffffffff","runtime_name":"test-runtime","ts":"2022-12-10T13:59:20.763938823Z"}

@peternose peternose added c:runtime Category: runtime rust labels Dec 10, 2022
Copy link
Member

@kostko kostko left a comment

Choose a reason for hiding this comment

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

Also backport.

@peternose peternose marked this pull request as ready for review December 10, 2022 15:42
Ok(cbor::from_slice(&buffer)?)
let message = cbor::from_slice(&buffer)
.map_err(|error| {
warn!(self.logger, "Failed to decode message"; "err" => %error);
Copy link
Member

Choose a reason for hiding this comment

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

Would it be useful to also log the bytes that failed to parse? (maybe in a debug level log)

Copy link
Contributor Author

@peternose peternose Dec 10, 2022

Choose a reason for hiding this comment

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

Can do that, was not sure. I would definitely not log in warn mode, as this would log up to 16MiB.

@peternose peternose force-pushed the peternose/internal/rhp-deserialization branch from 7244bb0 to 2d47682 Compare December 10, 2022 16:45
@codecov
Copy link

codecov bot commented Dec 10, 2022

Codecov Report

Merging #5094 (2d47682) into master (12e7d6f) will decrease coverage by 0.01%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master    #5094      +/-   ##
==========================================
- Coverage   67.18%   67.16%   -0.02%     
==========================================
  Files         501      501              
  Lines       53381    53381              
==========================================
- Hits        35864    35854      -10     
- Misses      13163    13183      +20     
+ Partials     4354     4344      -10     
Impacted Files Coverage Δ
go/consensus/tendermint/apps/staking/auth.go 62.96% <0.00%> (-7.41%) ⬇️
go/runtime/host/sandbox/sandbox.go 70.00% <0.00%> (-6.56%) ⬇️
go/roothash/api/sanity_check.go 60.00% <0.00%> (-4.00%) ⬇️
go/runtime/host/multi/multi.go 74.26% <0.00%> (-2.95%) ⬇️
go/runtime/txpool/txpool.go 80.92% <0.00%> (-2.42%) ⬇️
go/runtime/host/protocol/connection.go 68.79% <0.00%> (-2.26%) ⬇️
go/consensus/api/submission.go 66.66% <0.00%> (-1.76%) ⬇️
go/oasis-node/cmd/stake/delegations.go 78.99% <0.00%> (-1.69%) ⬇️
go/worker/compute/executor/committee/node.go 69.49% <0.00%> (-1.40%) ⬇️
go/worker/client/service.go 69.87% <0.00%> (-1.29%) ⬇️
... and 19 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@peternose peternose merged commit e10c842 into master Dec 10, 2022
@peternose peternose deleted the peternose/internal/rhp-deserialization branch December 10, 2022 18:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c:runtime Category: runtime rust
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants