Skip to content

Commit 9dec865

Browse files
authored
Merge branch 'main' into feat/catid-eq
2 parents a0bf400 + 4b8a4e8 commit 9dec865

File tree

10 files changed

+37
-63
lines changed

10 files changed

+37
-63
lines changed

rust/cardano-blockchain-types/Cargo.toml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "cardano-blockchain-types"
33
description = "Common Cardano Blockchain data types for use in both applications and crates"
44
keywords = ["cardano", "catalyst", ]
5-
version = "0.0.6"
5+
version = "0.0.7"
66
authors = [
77
"Steven Johnson <[email protected]>"
88
]
@@ -41,12 +41,12 @@ thiserror = "2.0.11"
4141

4242
# TODO: Revert ALL to Upstream Pallas after <https://github.com/txpipe/pallas/pull/685> merges.
4343
# pallas related commit is from <https://github.com/input-output-hk/catalyst-pallas/pull/4>
44-
pallas-traverse = { version = "=1.0.0-alpha.2", git = "https://github.com/input-output-hk/catalyst-pallas.git", rev = "9c6322e6b51916b2cc54ba713b07bb25ef07dd00" }
45-
pallas-addresses = { version = "=1.0.0-alpha.2", git = "https://github.com/input-output-hk/catalyst-pallas.git", rev = "9c6322e6b51916b2cc54ba713b07bb25ef07dd00" }
46-
pallas-primitives = { version = "=1.0.0-alpha.2", git = "https://github.com/input-output-hk/catalyst-pallas.git", rev = "9c6322e6b51916b2cc54ba713b07bb25ef07dd00" }
47-
pallas-crypto = { version = "=1.0.0-alpha.2", git = "https://github.com/input-output-hk/catalyst-pallas.git", rev = "9c6322e6b51916b2cc54ba713b07bb25ef07dd00" }
48-
pallas-codec = { version = "=1.0.0-alpha.2", git = "https://github.com/input-output-hk/catalyst-pallas.git", rev = "9c6322e6b51916b2cc54ba713b07bb25ef07dd00" }
44+
pallas-traverse = { version = "=1.0.0-alpha.2", git = "https://github.com/input-output-hk/catalyst-pallas.git", rev = "9c6322e6b51916b2cc54ba713b07bb25ef07dd00" }
45+
pallas-addresses = { version = "=1.0.0-alpha.2", git = "https://github.com/input-output-hk/catalyst-pallas.git", rev = "9c6322e6b51916b2cc54ba713b07bb25ef07dd00" }
46+
pallas-primitives = { version = "=1.0.0-alpha.2", git = "https://github.com/input-output-hk/catalyst-pallas.git", rev = "9c6322e6b51916b2cc54ba713b07bb25ef07dd00" }
47+
pallas-crypto = { version = "=1.0.0-alpha.2", git = "https://github.com/input-output-hk/catalyst-pallas.git", rev = "9c6322e6b51916b2cc54ba713b07bb25ef07dd00" }
48+
pallas-codec = { version = "=1.0.0-alpha.2", git = "https://github.com/input-output-hk/catalyst-pallas.git", rev = "9c6322e6b51916b2cc54ba713b07bb25ef07dd00" }
4949
# Only include these for non-wasm32 targets
5050
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
51-
pallas-network = { version = "=1.0.0-alpha.2", git = "https://github.com/input-output-hk/catalyst-pallas.git", rev = "9c6322e6b51916b2cc54ba713b07bb25ef07dd00" }
52-
pallas-hardano = { version = "=1.0.0-alpha.2", git = "https://github.com/input-output-hk/catalyst-pallas.git", rev = "9c6322e6b51916b2cc54ba713b07bb25ef07dd00" }
51+
pallas-network = { version = "=1.0.0-alpha.2", git = "https://github.com/input-output-hk/catalyst-pallas.git", rev = "9c6322e6b51916b2cc54ba713b07bb25ef07dd00" }
52+
pallas-hardano = { version = "=1.0.0-alpha.2", git = "https://github.com/input-output-hk/catalyst-pallas.git", rev = "9c6322e6b51916b2cc54ba713b07bb25ef07dd00" }

rust/cardano-blockchain-types/src/metadata/cip36/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ impl Cip36 {
175175
let mut cip36 = Cip36 {
176176
key_registration,
177177
registration_witness,
178-
network,
178+
network: network.clone(),
179179
slot: slot.into(),
180180
txn_idx,
181181
is_catalyst_strict,
@@ -298,8 +298,8 @@ impl Cip36 {
298298

299299
/// Get the network of this CIP-36 registration.
300300
#[must_use]
301-
pub fn network(&self) -> Network {
302-
self.network
301+
pub fn network(&self) -> &Network {
302+
&self.network
303303
}
304304

305305
/// Get the transaction index of this CIP-36 registration.
@@ -373,7 +373,7 @@ mod tests {
373373
let res = Cip36::new(&block_1(), 1.into(), true).unwrap().unwrap();
374374
assert!(!res.err_report().is_problematic());
375375
assert!(res.is_valid());
376-
assert!(res.network() == Network::Preprod);
376+
assert!(res.network() == &Network::Preprod);
377377
assert!(res.raw_nonce() == Some(55_076_993));
378378
assert!(res.nonce() == Some(55_076_993));
379379
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,8 @@ impl MultiEraBlock {
236236
///
237237
/// - The network that this block originated on.
238238
#[must_use]
239-
pub fn network(&self) -> Network {
240-
self.inner.network
239+
pub fn network(&self) -> &Network {
240+
&self.inner.network
241241
}
242242

243243
/// Get The Metadata fora a transaction and known label from the block

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pub(crate) const ENVVAR_MITHRIL_EXE_NAME: &str = "MITHRIL_EXE_NAME";
2222

2323
/// Enum of possible Cardano networks.
2424
#[derive(
25-
Debug, Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, strum::VariantNames, strum::Display,
25+
Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, strum::VariantNames, strum::Display,
2626
)]
2727
#[strum(serialize_all = "snake_case")]
2828
#[non_exhaustive]
@@ -36,7 +36,7 @@ pub enum Network {
3636
/// Cardano devnet network.
3737
Devnet {
3838
/// Mithril signature genesis key for a blockchain.
39-
genesis_key: &'static str,
39+
genesis_key: String,
4040
/// Cardano blockchain networking magic number genesis block setting
4141
magic: u64,
4242
/// Cardano blockchain network id genesis block setting
@@ -48,7 +48,7 @@ pub enum Network {
4848
/// Cardano byron known slot genesis block setting
4949
byron_known_slot: u64,
5050
/// Cardano byron known hash genesis block setting
51-
byron_known_hash: &'static str,
51+
byron_known_hash: String,
5252
/// Cardano byron known time genesis block setting
5353
byron_known_time: u64,
5454
/// Cardano shelley epoch length genesis block setting
@@ -58,7 +58,7 @@ pub enum Network {
5858
/// Cardano shelley known slot genesis block setting
5959
shelley_known_slot: u64,
6060
/// Cardano shelley known hash genesis block setting
61-
shelley_known_hash: &'static str,
61+
shelley_known_hash: String,
6262
/// Cardano shelley known time genesis block setting
6363
shelley_known_time: u64,
6464
},
@@ -311,18 +311,18 @@ mod tests {
311311
assert_eq!(Network::Preview.to_string(), "preview");
312312
assert_eq!(
313313
Network::Devnet {
314-
genesis_key: "genesis_key",
314+
genesis_key: "genesis_key".into(),
315315
magic: 0,
316316
network_id: 0,
317317
byron_epoch_length: 0,
318318
byron_slot_length: 0,
319319
byron_known_slot: 0,
320-
byron_known_hash: "byron_known_hash",
320+
byron_known_hash: "byron_known_hash".into(),
321321
byron_known_time: 0,
322322
shelley_epoch_length: 0,
323323
shelley_slot_length: 0,
324324
shelley_known_slot: 0,
325-
shelley_known_hash: "shelley_known_hash",
325+
shelley_known_hash: "shelley_known_hash".into(),
326326
shelley_known_time: 0
327327
}
328328
.to_string(),

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ mod tests {
160160
];
161161

162162
for (network, is_script, hash, expected_header) in test_data {
163-
let stake_address = StakeAddress::new(network, is_script, hash.into());
163+
let stake_address = StakeAddress::new(network.clone(), is_script, hash.into());
164164
assert_eq!(stake_address.is_script(), is_script);
165165

166166
// Check that conversion to bytes includes the expected header value.

rust/rbac-registration/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "rbac-registration"
33
description = "Role Based Access Control Registration"
44
keywords = ["cardano", "catalyst", "rbac registration"]
5-
version = "0.0.11"
5+
version = "0.0.12"
66
authors = [
77
"Arissara Chotivichit <[email protected]>"
88
]
@@ -34,5 +34,5 @@ thiserror = "2.0.11"
3434

3535
c509-certificate = { version = "0.0.3", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "c509-certificate-v0.0.3" }
3636
cbork-utils = { version = "0.0.2", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "cbork-utils-v0.0.2" }
37-
cardano-blockchain-types = { version = "0.0.6", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "cardano-blockchain-types/v0.0.6" }
37+
cardano-blockchain-types = { version = "0.0.7", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "cardano-blockchain-types/v0.0.7" }
3838
catalyst-types = { version = "0.0.8", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "catalyst-types/v0.0.8" }

rust/rbac-registration/src/cardano/cip509/validation.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ fn validate_x509_self_signed_cert(
357357
#[allow(clippy::similar_names)]
358358
pub fn validate_role_data(
359359
metadata: &Cip509RbacMetadata,
360-
subnet: Network,
360+
subnet: &Network,
361361
report: &ProblemReport,
362362
) -> Option<CatalystId> {
363363
let context = "Role data validation";
@@ -474,7 +474,7 @@ pub fn validate_role_data(
474474
fn validate_role_0(
475475
role: &RoleData,
476476
metadata: &Cip509RbacMetadata,
477-
subnet: Network,
477+
subnet: &Network,
478478
context: &str,
479479
report: &ProblemReport,
480480
) -> Option<CatalystId> {

rust/signed_doc/src/validator/rules/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ impl Rules {
145145
collaborators: CollaboratorsRule::NotSpecified,
146146
content: ContentRule::new(&doc_spec.payload)?,
147147
kid: SignatureKidRule::new(&doc_spec.signers.roles)?,
148-
signature: SignatureRule { mutlisig: false },
148+
signature: SignatureRule {},
149149
ownership: DocumentOwnershipRule::new(&doc_spec.signers.update)?,
150150
};
151151
let doc_type = doc_spec.doc_type.parse()?;

rust/signed_doc/src/validator/rules/signature/mod.rs

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,7 @@ use crate::{
1414

1515
/// Signed Document signatures validation rule.
1616
#[derive(Debug)]
17-
pub(crate) struct SignatureRule {
18-
/// Allows multiple signatures.
19-
pub(crate) mutlisig: bool,
20-
}
17+
pub(crate) struct SignatureRule;
2118

2219
impl SignatureRule {
2320
/// Verify document signatures.
@@ -41,18 +38,6 @@ impl SignatureRule {
4138
return Ok(false);
4239
}
4340

44-
if !self.mutlisig && doc.signatures().len() > 1 {
45-
doc.report().other(
46-
format!(
47-
"Multi-signature is not allowed, found {} signatures",
48-
doc.signatures().len()
49-
)
50-
.as_str(),
51-
"During Catalyst Signed Document signature validation",
52-
);
53-
return Ok(false);
54-
}
55-
5641
let sign_rules = doc
5742
.signatures()
5843
.iter()

rust/signed_doc/src/validator/rules/signature/tests.rs

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@ fn metadata() -> serde_json::Value {
2727
})
2828
}
2929

30-
fn rule(mutlisig: bool) -> SignatureRule {
31-
SignatureRule { mutlisig }
32-
}
33-
3430
#[tokio::test]
3531
async fn single_signature_validation_test() {
3632
let (sk, pk, kid) = create_dummy_key_pair(RoleId::Role0);
@@ -51,13 +47,13 @@ async fn single_signature_validation_test() {
5147
let mut provider = TestCatalystProvider::default();
5248
provider.add_pk(kid.clone(), pk);
5349
assert!(
54-
rule(true).check(&signed_doc, &provider).await.unwrap(),
50+
SignatureRule.check(&signed_doc, &provider).await.unwrap(),
5551
"{:?}",
5652
signed_doc.problem_report()
5753
);
5854

5955
// case: empty provider
60-
assert!(!rule(true)
56+
assert!(!SignatureRule
6157
.check(&signed_doc, &TestCatalystProvider::default())
6258
.await
6359
.unwrap());
@@ -71,7 +67,7 @@ async fn single_signature_validation_test() {
7167
.unwrap()
7268
.build()
7369
.unwrap();
74-
assert!(!rule(true).check(&invalid_doc, &provider).await.unwrap());
70+
assert!(!SignatureRule.check(&invalid_doc, &provider).await.unwrap());
7571

7672
// case: missing signatures
7773
let unsigned_doc = Builder::new()
@@ -86,7 +82,7 @@ async fn single_signature_validation_test() {
8682
.unwrap()
8783
.build()
8884
.unwrap();
89-
assert!(!rule(true).check(&unsigned_doc, &provider).await.unwrap());
85+
assert!(!SignatureRule.check(&unsigned_doc, &provider).await.unwrap());
9086
}
9187

9288
#[tokio::test]
@@ -112,33 +108,26 @@ async fn multiple_signatures_validation_test() {
112108

113109
assert!(!signed_doc.problem_report().is_problematic());
114110

115-
// case: multi-sig rule disabled
116-
let mut provider = TestCatalystProvider::default();
117-
provider.add_pk(kid1.clone(), pk1);
118-
provider.add_pk(kid2.clone(), pk2);
119-
provider.add_pk(kid3.clone(), pk3);
120-
assert!(!rule(false).check(&signed_doc, &provider).await.unwrap());
121-
122111
// case: all signatures valid
123112
let mut provider = TestCatalystProvider::default();
124113
provider.add_pk(kid1.clone(), pk1);
125114
provider.add_pk(kid2.clone(), pk2);
126115
provider.add_pk(kid3.clone(), pk3);
127-
assert!(rule(true).check(&signed_doc, &provider).await.unwrap());
116+
assert!(SignatureRule.check(&signed_doc, &provider).await.unwrap());
128117

129118
// case: partially available signatures
130119
let mut provider = TestCatalystProvider::default();
131120
provider.add_pk(kid1.clone(), pk1);
132121
provider.add_pk(kid2.clone(), pk2);
133-
assert!(!rule(true).check(&signed_doc, &provider).await.unwrap());
122+
assert!(!SignatureRule.check(&signed_doc, &provider).await.unwrap());
134123

135124
// case: with unrecognized provider
136125
let mut provider = TestCatalystProvider::default();
137126
provider.add_pk(kid_n.clone(), pk_n);
138-
assert!(!rule(true).check(&signed_doc, &provider).await.unwrap());
127+
assert!(!SignatureRule.check(&signed_doc, &provider).await.unwrap());
139128

140129
// case: no valid signatures available
141-
assert!(!rule(true)
130+
assert!(!SignatureRule
142131
.check(&signed_doc, &TestCatalystProvider::default())
143132
.await
144133
.unwrap());
@@ -288,7 +277,7 @@ async fn special_cbor_cases() {
288277
.unwrap();
289278

290279
assert!(
291-
rule(true).check(&doc, &provider).await.unwrap(),
280+
SignatureRule.check(&doc, &provider).await.unwrap(),
292281
"[case: {}] {:?}",
293282
case.name,
294283
doc.problem_report()

0 commit comments

Comments
 (0)