Skip to content

Commit 9142501

Browse files
authored
feat(rust/vote-tx-v2): Feat add initial CBOR decoding/encoding implementation of the generalised vote tx (#81)
* add vote-tx-v2 crate * rename jormungandr-vote-tx to vote-tx-v1 * add Vote CBOR encoding/decoding * wip * wip * wip * wip * add proptest for Vote type * replace ciborium usage with minicbor * add new TxBody struct, cleanup gen_vote_tx.cddl * add TxBody CBOR decoding/encoding impl * add Cbor trait * add GeneralisedTx struct * wip * wip * fix spelling * fix doctest * add array lenth validation
1 parent 8f9f071 commit 9142501

File tree

12 files changed

+448
-11
lines changed

12 files changed

+448
-11
lines changed

.github/workflows/semantic_pull_request.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ jobs:
1919
rust/c509-certificate
2020
rust/cardano-chain-follower
2121
rust/catalyst-voting
22+
rust/vote-tx-v1
23+
rust/vote-tx-v2
2224
rust/cbork
2325
rust/hermes-ipfs
2426
dart

docs/src/architecture/08_concepts/catalyst_voting/cddl/gen_vote_tx.cddl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ tx-body<choice-t, proof-t, prop-id-t> = [
77
vote-type
88
event,
99
votes<choice-t, proof-t, prop-id-t>,
10-
voters-data,
10+
voter-data,
1111
]
1212

1313
vote-type = UUID ; e.g. Public or Private vote
@@ -25,7 +25,7 @@ choice<choice-t> = #6.24(bytes .cbor choice-t) ; encoded-cbor
2525
proof<proof-t> = #6.24(bytes .cbor proof-t) ; encoded-cbor
2626
prop-id<prop-id-t> = #6.24(bytes .cbor prop-id-t) ; encoded-cbor
2727

28-
voters-data = encoded-cbor
28+
voter-data = encoded-cbor
2929

3030
UUID = #6.37(bytes) ; UUID type
3131
signature = #6.98(cose.COSE_Sign) ; COSE signature

docs/src/architecture/08_concepts/catalyst_voting/gen_vote_tx.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Vote:
4242
so it's redundant to provide an additional identifier for the proposal,
4343
so it could be placed `null`.
4444

45-
`voters-data` - an any additional voter's specific data.
45+
`voter-data` - an any additional voter's specific data.
4646

4747
### Transaction signing
4848

rust/Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ members = [
77
"cbork",
88
"cbork-abnf-parser",
99
"cbork-cddl-parser",
10-
"catalyst-voting", "jormungandr-vote-tx",
10+
"catalyst-voting",
11+
"vote-tx-v1",
12+
"vote-tx-v2",
1113
]
1214

1315
[workspace.package]

rust/Earthfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ COPY_SRC:
1010
.cargo .config \
1111
c509-certificate \
1212
cardano-chain-follower \
13-
catalyst-voting jormungandr-vote-tx \
13+
catalyst-voting vote-tx-v1 vote-tx-v2 \
1414
cbork cbork-abnf-parser cbork-cddl-parser \
1515
hermes-ipfs \
1616
.
@@ -53,7 +53,7 @@ build:
5353
--cmd="/scripts/std_build.py" \
5454
--args1="--libs=c509-certificate --libs=cardano-chain-follower --libs=hermes-ipfs" \
5555
--args2="--libs=cbork-cddl-parser --libs=cbork-abnf-parser" \
56-
--args3="--libs=catalyst-voting --libs=jormungandr-vote-tx" \
56+
--args3="--libs=catalyst-voting --libs=vote-tx-v1 --libs=vote-tx-v2" \
5757
--args4="--bins=cbork/cbork" \
5858
--args5="--cov_report=$HOME/build/coverage-report.info" \
5959
--output="release/[^\./]+" \

rust/jormungandr-vote-tx/Cargo.toml renamed to rust/vote-tx-v1/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[package]
2-
name = "jormungandr-vote-tx"
2+
name = "vote-tx-v1"
33
version = "0.0.1"
44
edition.workspace = true
55
authors.workspace = true
File renamed without changes.

rust/jormungandr-vote-tx/src/lib.rs renamed to rust/vote-tx-v1/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
//! A Jörmungandr transaction object structured following this
2-
//! [spec](https://input-output-hk.github.io/catalyst-libs/architecture/08_concepts/catalyst_voting/jorm/)
1+
//! A Catalyst v1 (Jörmungandr) vote transaction object, structured following this
2+
//! [spec](https://input-output-hk.github.io/catalyst-libs/architecture/08_concepts/catalyst_voting/v1/)
33
//!
44
//! ```rust
55
//! use catalyst_voting::{
66
//! crypto::{ed25519::PrivateKey, rng::default_rng},
77
//! vote_protocol::committee::ElectionSecretKey,
88
//! };
9-
//! use jormungandr_vote_tx::Tx;
9+
//! use vote_tx_v1::Tx;
1010
//!
1111
//! let vote_plan_id = [0u8; 32];
1212
//! let proposal_index = 0u8;
@@ -65,7 +65,7 @@ use catalyst_voting::{
6565
},
6666
};
6767

68-
/// A v1 (Jörmungandr) transaction struct
68+
/// A v1 (Jörmungandr) vote transaction struct
6969
#[derive(Debug, Clone, PartialEq, Eq)]
7070
#[must_use]
7171
pub struct Tx {
File renamed without changes.

rust/vote-tx-v2/Cargo.toml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
[package]
2+
name = "vote-tx-v2"
3+
version = "0.1.0"
4+
edition.workspace = true
5+
authors.workspace = true
6+
homepage.workspace = true
7+
repository.workspace = true
8+
license.workspace = true
9+
10+
[lib]
11+
crate-type = ["lib", "cdylib"]
12+
13+
[lints]
14+
workspace = true
15+
16+
[dependencies]
17+
anyhow = "1.0.89"
18+
proptest = { version = "1.5.0" }
19+
minicbor = { version = "0.25.1", features = ["alloc"] }
20+
21+
[dev-dependencies]
22+
# Potentially it could be replaced with using `proptest::property_test` attribute macro,
23+
# after this PR will be merged https://github.com/proptest-rs/proptest/pull/523
24+
test-strategy = "0.4.0"

0 commit comments

Comments
 (0)