-
Notifications
You must be signed in to change notification settings - Fork 16
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
support ignoring alias fields from trace registry #3
Conversation
aefa285
to
f2b5fb6
Compare
f2b5fb6
to
856e860
Compare
856e860
to
aa6c8cf
Compare
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.
When you updated aptos-core to use this, did the generate-format code now work?
@@ -243,7 +243,7 @@ where | |||
Option(format) => format!("Option<{}>", Self::quote_type(format, known_sizes)), | |||
Seq(format) => format!("Vec<{}>", Self::quote_type(format, None)), | |||
Map { key, value } => format!( | |||
"Map<{}, {}>", |
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.
What was this Map type, I can't see any type imported with that name. I suppose it's a serde specific thing?
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.
Not sure either. It was failing a unit test, so I fixed it. It was failing earlier too, but I guess nobody noticed.
@@ -243,7 +243,7 @@ where | |||
Option(format) => format!("Option<{}>", Self::quote_type(format, known_sizes)), | |||
Seq(format) => format!("Vec<{}>", Self::quote_type(format, None)), | |||
Map { key, value } => format!( | |||
"Map<{}, {}>", | |||
"std::collections::BTreeMap<{}, {}>", |
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.
Will changing to BTreeMap change any behavior?
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.
Hopefully, its deterministic.
|
||
if alias_formats.len() != aliases.len() { | ||
return Err(Error::Custom(format!( | ||
"cannot ignore alias. not all aliases are found in container: {:?}", |
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 if the user says "ignore alias x" but x isn't found, this will throw an error, is that right?
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.
Yes, this was intentional.
@@ -457,3 +457,42 @@ fn test_repeated_tracing() { | |||
)))))) | |||
); | |||
} | |||
|
|||
#[test] | |||
fn test_trace_deserialization_with_alias_types() { |
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.
Nice, looks good.
yes, it produced the same format spec as before. |
Summary
Fixes aptos-labs/aptos-core#10424
This PR adds support for ignoring aliases of fields from the trace registry via a new API. In serde-rs/serde#2387, serde allowed both field names and aliases to be considered as field names during deserialization. This breaks the serde-reflection tracer, because it can only trace one field while it expects to trace multiple fields denoted by the field names and aliases. Also, serde doesn't currently denote whether a field is an alias or not in the Deserializer trait.
To work around this issue, this PR adds a new API
ignore_aliases
that can be called to manually ignore the aliases in a struct container from the resource registry.This change maintains backwards compatibility in terms of generated format spec file.
Test Plan
Added unit test to reproduce the issue and use
ignore_aliases
to fix the issue.