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

UnsignedMessage cbor encoding #174

Merged
merged 9 commits into from
Jan 21, 2020
Merged

UnsignedMessage cbor encoding #174

merged 9 commits into from
Jan 21, 2020

Conversation

austinabell
Copy link
Contributor

@austinabell austinabell commented Jan 18, 2020

Match format with one defined in Lotus.

Once these are done I will open PR

  • big int serialization (spec defines types as uints, but are being serialized as signed big ints in BE in lotus)
  • MethodParams serialization (spec defined these params as a stack, or array in cbor terms, of bytes and lotus is just deserializing them as structs encoded as tuples)

@austinabell austinabell marked this pull request as ready for review January 21, 2020 16:49
impl UnsignedMessage {
pub fn builder() -> MessageBuilder {
MessageBuilder::default()
}
}

/// Structure defines how the fields are cbor encoded as an unsigned message
#[derive(Serialize, Deserialize)]
struct CborUnsignedMessage(
Copy link
Member

Choose a reason for hiding this comment

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

Should be public, ya?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that was refactored 4 hours ago lol how did you even review that? And no, didn't need to be since it was just used in that file for consistent ser/de

@@ -7,20 +7,20 @@ use std::ops::Deref;

/// Method number indicator for calling actor methods
#[derive(Default, Clone, Copy, PartialEq, Debug, Serialize, Deserialize)]
pub struct MethodNum(i32); // TODO: add constraints to this
pub struct MethodNum(u64); // TODO: add constraints to this
Copy link
Member

Choose a reason for hiding this comment

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

Should this not be an enum? Then you can impl the From traits to convert from a number type

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nah, needs to be an integer because methods vary based on actor and needs to be future proofed for when you can initialize own actor with custom code

Copy link
Member

@ec2 ec2 left a comment

Choose a reason for hiding this comment

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

pls address comments

assert_eq!(enc_bz.as_slice(), expected);
// Assert decoding from those bytes goes back to unsigned message
assert_eq!(
&from_slice::<UnsignedMessage>(expected).expect("Should be able to deserialize cbor bytes"),
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: all .expect other than this one begins with a lowercase.

Copy link
Contributor Author

@austinabell austinabell Jan 21, 2020

Choose a reason for hiding this comment

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

ah ya, is just used for easier test debugging instead of unwrapping. I made all consistent.

@austinabell austinabell merged commit 7e524b3 into master Jan 21, 2020
@austinabell austinabell deleted the austin/message/cbor branch January 21, 2020 20:51
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.

3 participants