-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat(rust/vote-tx-v2): Public vote tx v2 CBOR decoding/encoding implementation #86
Conversation
✅ Test Report | |
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.
The only suggestion I have. To consider creating a module for vote-related types:
pub mod vote {
pub trait CborSerializable: for<'a> Cbor<'a> {}
impl<T: for<'a> Cbor<'a>> CborSerializable for T {}
pub type VoteChoice = Box<dyn CborSerializable>;
pub type VoteProof = Box<dyn CborSerializable>;
pub type ProposalId = Box<dyn CborSerializable>;
...
...
...
}
use crate::{encoded_cbor::EncodedCbor, Cbor}; | ||
|
||
/// `Vote` array struct length | ||
const VOTE_LEN: u64 = 3; |
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.
where is the 3 defined?
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.
It is defined from the cddl spec
vote<choice-t, proof-t, prop-id-t> = [
choices<choice-t>,
proof<proof-t>,
prop-id<prop-id-t>,
]
so basically, vote
type here a cbor encoded array with the 3 field in it.
Also I've discussed with @stevenj that we should allow only definite sized arrays and maps in such cases (because cbor also allows to have indefinite size arrays and maps and cddl does not specify it). I will put a note into our spec about 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.
@cong-or so probably we will also need to revisit ledger encoding implementation to double check that it encodes as a finite cbor arrays and cbor maps for the types, but its not urgent and for now its totally ok if its not strictly verifies 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.
lgtm
Description
voter-data
type generic, the same aschoice
,proof
, andprop-id
.GeneralizedTx
structure generic according to the original cddl spec.GeneralizedTx
code structured it across different Rust modules.GeneralizedTxBuilder
structure.GeneralizedTx
.PublicTx
structure with the correspondingChoice
,Proof
andPropId
types definitions according to the cddl spec.PublicTx
and all underlying types.Related Issue(s)
#84