Skip to content

Commit d819b8e

Browse files
authored
feat(rust): RegistrationChain additional validation, added From<TxnIndex> for u16 (#228)
* add validations * add From<TxnIndex> for u16 impl * change versions to path * fix
1 parent b9ef5c3 commit d819b8e

File tree

6 files changed

+22
-9
lines changed

6 files changed

+22
-9
lines changed

rust/cardano-blockchain-types/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ workspace = true
2020
[dependencies]
2121
pallas = { version = "0.30.1", git = "https://github.com/input-output-hk/catalyst-pallas.git", rev = "9b5183c8b90b90fe2cc319d986e933e9518957b3" }
2222
# pallas-hardano = { version = "0.30.1", git = "https://github.com/input-output-hk/catalyst-pallas.git", rev = "9b5183c8b90b90fe2cc319d986e933e9518957b3" }
23-
cbork-utils = { version = "0.0.1", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "r20250226-00" }
24-
catalyst-types = { version = "0.0.3", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "r20250226-00" }
23+
cbork-utils = { version = "0.0.1", path = "../cbork-utils" }
24+
catalyst-types = { version = "0.0.3", path = "../catalyst-types" }
2525

2626
ouroboros = "0.18.4"
2727
tracing = "0.1.41"

rust/cardano-blockchain-types/src/txn_index.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ impl From<TxnIndex> for usize {
3131
}
3232
}
3333

34+
impl From<TxnIndex> for u16 {
35+
fn from(value: TxnIndex) -> Self {
36+
value.0
37+
}
38+
}
39+
3440
#[cfg(test)]
3541
mod tests {
3642
use super::*;

rust/cardano-chain-follower/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ mithril-client = { version = "0.10.4", default-features = false, features = [
1919
"full",
2020
"num-integer-backend",
2121
] }
22-
cardano-blockchain-types = { version = "0.0.3", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "r20250226-00" }
23-
catalyst-types = { version = "0.0.3", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "r20250226-00" }
22+
cardano-blockchain-types = { version = "0.0.3", path = "../cardano-blockchain-types" }
23+
catalyst-types = { version = "0.0.3", path = "../catalyst-types" }
2424

2525

2626
thiserror = "1.0.69"

rust/rbac-registration/Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ tracing = "0.1.40"
3030
ed25519-dalek = "2.1.1"
3131
uuid = "1.11.0"
3232

33-
c509-certificate = { version = "0.0.3", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "r20250226-00" }
33+
c509-certificate = { version = "0.0.3", path = "../c509-certificate" }
3434
pallas = { version = "0.30.1", git = "https://github.com/input-output-hk/catalyst-pallas.git", rev = "9b5183c8b90b90fe2cc319d986e933e9518957b3" }
35-
cbork-utils = { version = "0.0.1", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "r20250226-00" }
36-
cardano-blockchain-types = { version = "0.0.3", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "r20250226-00" }
37-
catalyst-types = { version = "0.0.3", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "r20250226-00" }
35+
cbork-utils = { version = "0.0.1", path = "../cbork-utils" }
36+
cardano-blockchain-types = { version = "0.0.3", path = "../cardano-blockchain-types" }
37+
catalyst-types = { version = "0.0.3", path = "../catalyst-types" }

rust/rbac-registration/src/registration/cardano/mod.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,10 @@ impl RegistrationChainInner {
147147
if cip509.previous_transaction().is_some() {
148148
bail!("Invalid chain root, previous transaction ID should be None.");
149149
}
150+
// Should be chain root, return immediately if not
151+
if cip509.catalyst_id().is_none() {
152+
bail!("Invalid chain root, catalyst id should be present.");
153+
}
150154

151155
let point_tx_idx = cip509.origin().clone();
152156
let current_tx_id_hash = cip509.txn_hash();
@@ -194,6 +198,9 @@ impl RegistrationChainInner {
194198
let Some(prv_tx_id) = cip509.previous_transaction() else {
195199
bail!("Empty previous transaction ID");
196200
};
201+
if cip509.catalyst_id().is_some() {
202+
bail!("Catalyst id should be present only for chain root registration.");
203+
}
197204
// Previous transaction ID in the CIP509 should equal to the current transaction ID
198205
// or else it is not a part of the chain
199206
if prv_tx_id == self.current_tx_id_hash {

rust/signed_doc/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ license.workspace = true
1111
workspace = true
1212

1313
[dependencies]
14-
catalyst-types = { version = "0.0.3", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "r20250226-00" }
14+
catalyst-types = { version = "0.0.3", path = "../catalyst-types" }
1515

1616
anyhow = "1.0.95"
1717
serde = { version = "1.0.217", features = ["derive"] }

0 commit comments

Comments
 (0)