-
Notifications
You must be signed in to change notification settings - Fork 59
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
Add Babbage nonce/leader vrf extension #132
Conversation
pallas-traverse/src/lib.rs
Outdated
UnknownEra(u16), | ||
|
||
#[error("Invalid era for request: {0}")] | ||
InvalidEra(u16), |
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 think we could use the crate::Era
struct for this particular error since it will be thrown from methods where the Era of the data is strictly known (the UnknownEra
relies on u16 because it is used for errors during the parsing of the value).
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.
fixed
pallas-traverse/src/header.rs
Outdated
@@ -45,4 +46,57 @@ impl<'b> MultiEraHeader<'b> { | |||
MultiEraHeader::Byron(x) => x.to_hash(), | |||
} | |||
} | |||
|
|||
pub fn leader_vrf_output(&self) -> Result<ByteVec, Error> { |
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.
Could we make the fn name just leader_vrf
? Or do you think that the output
prefix provides more context?
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.
A VRF has two parts. There's the output and the proof. In this case, we only are extending to get the output part of it. If you call it something other than "output" in your code, we can maybe change it.
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.
makes sense now.
pallas-traverse/src/header.rs
Outdated
let mut leader_tagged_vrf: Vec<u8> = vec![0x4C_u8]; /* "L" */ | ||
leader_tagged_vrf.extend(&*x.header_body.vrf_result.0); | ||
let h32 = Hasher::<256>::hash(&leader_tagged_vrf); | ||
Ok(ByteVec::from(h32.to_vec())) |
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 think we can skip the ByteVec wrapper and just return a Hash<32>. The bytevec is a cbor-specific decoding struct which should remain as hidden as possible from the api surface.
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.
Went with a simple Vec<u8>
.
a66d3b8
to
7375f81
Compare
7375f81
to
2f3c243
Compare
* feat: Bump n2n protocol versions for Babbage (#125) * feat: Allow a specified timeout on tcp connection (#127) * feat: Add Babbage primitives (#128) * fix: Inaccurate header-body CDDL (#129) * fix: Babbage CBOR codec issues (#130) * feat: Include Babbage in traverse lib * Parse Babbage headers (#131) * Add Babbage nonce/leader vrf extension (#132) Co-authored-by: Andrew Westberg <andrewwestberg@gmail.com>
Please review thoroughly and give feedback. I probably didn't do this the most optimal way.