Skip to content

Commit cba5f29

Browse files
authored
Merge branch 'main' into fix/bump-blockchain-types-in-rbac
2 parents e81795b + 3d8f7cb commit cba5f29

File tree

10 files changed

+193
-16
lines changed

10 files changed

+193
-16
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ on:
44
push:
55
branches: [main]
66
pull_request:
7+
types:
8+
- synchronize
9+
- ready_for_review
10+
711

812
permissions:
913
id-token: write

docs/src/architecture/08_concepts/catalyst_docs/comment.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,38 @@ A list of used [Catalyst Signed Document protected header fields](./../signed_do
106106
"content-encoding" => "br"
107107
```
108108

109+
* [`category_id`](./../signed_doc/meta.md#category_id) (optional).
110+
A reference to the category document,
111+
which [`type`](./../signed_doc/spec.md#type) must be equal to
112+
`48c20109-362a-4d32-9bba-e0a9cf8b45be` value.
113+
114+
#### Fund 14 defined templates ids
115+
116+
* id: `0194d494-4402-7e0e-b8d6-171f8fea18b0`, ver: `0194d494-4402-7e0e-b8d6-171f8fea18b0`,
117+
category: `0194d490-30bf-7473-81c8-a0eaef369619`
118+
* id: `0194d494-4402-7444-9058-9030815eb029`, ver: `0194d494-4402-7444-9058-9030815eb029`,
119+
category: `0194d490-30bf-7043-8c5c-f0e09f8a6d8c`
120+
* id: `0194d494-4402-7351-b4f7-24938dc2c12e`, ver: `0194d494-4402-7351-b4f7-24938dc2c12e`,
121+
category: `0194d490-30bf-7e75-95c1-a6cf0e8086d9`
122+
* id: `0194d494-4402-79ad-93ba-4d7a0b65d563`, ver: `0194d494-4402-79ad-93ba-4d7a0b65d563`,
123+
category: `0194d490-30bf-7703-a1c0-83a916b001e7`
124+
* id: `0194d494-4402-7cee-a5a6-5739839b3b8a`, ver: `0194d494-4402-7cee-a5a6-5739839b3b8a`,
125+
category: `0194d490-30bf-79d1-9a0f-84943123ef38`
126+
* id: `0194d494-4402-7aee-8b24-b5300c976846`, ver: `0194d494-4402-7aee-8b24-b5300c976846`,
127+
category: `0194d490-30bf-706d-91c6-0d4707f74cdf`
128+
* id: `0194d494-4402-7d75-be7f-1c4f3471a53c`, ver: `0194d494-4402-7d75-be7f-1c4f3471a53c`,
129+
category: `0194d490-30bf-759e-b729-304306fbaa5e`
130+
* id: `0194d494-4402-7a2c-8971-1b4c255c826d`, ver: `0194d494-4402-7a2c-8971-1b4c255c826d`,
131+
category: `0194d490-30bf-7e27-b5fd-de3133b54bf6`
132+
* id: `0194d494-4402-7074-86ac-3efd097ba9b0`, ver: `0194d494-4402-7074-86ac-3efd097ba9b0`,
133+
category: `0194d490-30bf-7f9e-8a5d-91fb67c078f2`
134+
* id: `0194d494-4402-7202-8ebb-8c4c47c286d8`, ver: `0194d494-4402-7202-8ebb-8c4c47c286d8`,
135+
category: `0194d490-30bf-7676-9658-36c0b67e656e`
136+
* id: `0194d494-4402-7fb5-b680-c23fe4beb088`, ver: `0194d494-4402-7fb5-b680-c23fe4beb088`,
137+
category: `0194d490-30bf-7978-b031-7aa2ccc5e3fd`
138+
* id: `0194d494-4402-7aa5-9dbc-5fe886e60ebc`, ver: `0194d494-4402-7aa5-9dbc-5fe886e60ebc`,
139+
category: `0194d490-30bf-7d34-bba9-8498094bd627`
140+
109141
#### Content format
110142

111143
TODO

docs/src/architecture/08_concepts/catalyst_docs/proposal.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,21 @@ A list of used [Catalyst Signed Document protected header fields](./../signed_do
6060
which [`type`](./../signed_doc/spec.md#type) must be equal to
6161
`48c20109-362a-4d32-9bba-e0a9cf8b45be` value.
6262

63+
#### Fund 14 defined category ids
64+
65+
* id: `0194d490-30bf-7473-81c8-a0eaef369619`
66+
* id: `0194d490-30bf-7043-8c5c-f0e09f8a6d8c`
67+
* id: `0194d490-30bf-7e75-95c1-a6cf0e8086d9`
68+
* id: `0194d490-30bf-7703-a1c0-83a916b001e7`
69+
* id: `0194d490-30bf-79d1-9a0f-84943123ef38`
70+
* id: `0194d490-30bf-706d-91c6-0d4707f74cdf`
71+
* id: `0194d490-30bf-759e-b729-304306fbaa5e`
72+
* id: `0194d490-30bf-7e27-b5fd-de3133b54bf6`
73+
* id: `0194d490-30bf-7f9e-8a5d-91fb67c078f2`
74+
* id: `0194d490-30bf-7676-9658-36c0b67e656e`
75+
* id: `0194d490-30bf-7978-b031-7aa2ccc5e3fd`
76+
* id: `0194d490-30bf-7d34-bba9-8498094bd627`
77+
6378
#### Content format
6479

6580
TODO
@@ -97,6 +112,38 @@ A list of used [Catalyst Signed Document protected header fields](./../signed_do
97112
"content-encoding" => "br"
98113
```
99114

115+
* [`category_id`](./../signed_doc/meta.md#category_id) (optional).
116+
A reference to the category document,
117+
which [`type`](./../signed_doc/spec.md#type) must be equal to
118+
`48c20109-362a-4d32-9bba-e0a9cf8b45be` value.
119+
120+
#### Fund 14 defined templates ids
121+
122+
* id: `0194d492-1daa-75b5-b4a4-5cf331cd8d1a`, ver: `0194d492-1daa-75b5-b4a4-5cf331cd8d1a`,
123+
category: `0194d490-30bf-7473-81c8-a0eaef369619`
124+
* id: `0194d492-1daa-7371-8bd3-c15811b2b063`, ver: `0194d492-1daa-7371-8bd3-c15811b2b063`,
125+
category: `0194d490-30bf-7043-8c5c-f0e09f8a6d8c`
126+
* id: `0194d492-1daa-79c7-a222-2c3b581443a8`, ver: `0194d492-1daa-79c7-a222-2c3b581443a8`,
127+
category: `0194d490-30bf-7e75-95c1-a6cf0e8086d9`
128+
* id: `0194d492-1daa-716f-a04e-f422f08a99dc`, ver: `0194d492-1daa-716f-a04e-f422f08a99dc`,
129+
category: `0194d490-30bf-7703-a1c0-83a916b001e7`
130+
* id: `0194d492-1daa-78fc-818a-bf20fc3e9b87`, ver: `0194d492-1daa-78fc-818a-bf20fc3e9b87`,
131+
category: `0194d490-30bf-79d1-9a0f-84943123ef38`
132+
* id: `0194d492-1daa-7d98-a3aa-c57d99121f78`, ver: `0194d492-1daa-7d98-a3aa-c57d99121f78`,
133+
category: `0194d490-30bf-706d-91c6-0d4707f74cdf`
134+
* id: `0194d492-1daa-77be-a1a5-c238fe25fe4f`, ver: `0194d492-1daa-77be-a1a5-c238fe25fe4f`,
135+
category: `0194d490-30bf-759e-b729-304306fbaa5e`
136+
* id: `0194d492-1daa-7254-a512-30a4cdecfb90`, ver: `0194d492-1daa-7254-a512-30a4cdecfb90`,
137+
category: `0194d490-30bf-7e27-b5fd-de3133b54bf6`
138+
* id: `0194d492-1daa-7de9-b535-1a0b0474ed4e`, ver: `0194d492-1daa-7de9-b535-1a0b0474ed4e`,
139+
category: `0194d490-30bf-7f9e-8a5d-91fb67c078f2`
140+
* id: `0194d492-1daa-7fce-84ee-b872a4661075`, ver: `0194d492-1daa-7fce-84ee-b872a4661075`,
141+
category: `0194d490-30bf-7676-9658-36c0b67e656e`
142+
* id: `0194d492-1daa-7878-9bcc-2c79fef0fc13`, ver: `0194d492-1daa-7878-9bcc-2c79fef0fc13`,
143+
category: `0194d490-30bf-7978-b031-7aa2ccc5e3fd`
144+
* id: `0194d492-1daa-722f-94f4-687f2c068a5d`, ver: `0194d492-1daa-722f-94f4-687f2c068a5d`,
145+
category: `0194d490-30bf-7d34-bba9-8498094bd627`
146+
100147
#### Content format
101148

102149
TODO

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 = "r20250128-01" }
24-
catalyst-types = { version = "0.0.1", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "r20250128-01" }
23+
cbork-utils = { version = "0.0.1", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "r20250212-00" }
24+
catalyst-types = { version = "0.0.1", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "r20250212-00" }
2525

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

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ define_hashes!(
99
/// A transaction hash - Blake2b-256 hash of a transaction.
1010
(TransactionHash, Blake2b256Hash),
1111
/// A public key hash - raw Blake2b-224 hash of an Ed25519 public key (has no discriminator, just the hash).
12-
(PubKeyHash, Blake2b224Hash)
12+
(PubKeyHash, Blake2b224Hash),
1313
);

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ mod network;
1010
mod point;
1111
mod slot;
1212
mod txn_index;
13+
mod txn_output_offset;
1314
mod txn_witness;
1415

1516
pub use auxdata::{
@@ -29,4 +30,5 @@ pub use network::Network;
2930
pub use point::Point;
3031
pub use slot::Slot;
3132
pub use txn_index::TxnIndex;
33+
pub use txn_output_offset::TxnOutputOffset;
3234
pub use txn_witness::{TxnWitness, VKeyHash};

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ use crate::{
2424
point::Point,
2525
txn_index::TxnIndex,
2626
txn_witness::{TxnWitness, VKeyHash},
27+
Slot,
2728
};
2829

2930
/// Self-referencing CBOR encoded data of a multi-era block.
@@ -278,11 +279,25 @@ impl MultiEraBlock {
278279
self.decode().txs()
279280
}
280281

282+
/// Returns an iterator over `(TxnIndex, MultiEraTx)` pair.
283+
pub fn enumerate_txs(&self) -> impl Iterator<Item = (TxnIndex, MultiEraTx)> {
284+
self.txs()
285+
.into_iter()
286+
.enumerate()
287+
.map(|(i, t)| (i.into(), t))
288+
}
289+
281290
/// Get the auxiliary data of the block.
282291
#[must_use]
283292
pub fn aux_data(&self) -> &BlockAuxData {
284293
&self.inner.aux_data
285294
}
295+
296+
/// Returns a slot of the block.
297+
#[must_use]
298+
pub fn slot(&self) -> Slot {
299+
self.decode().slot().into()
300+
}
286301
}
287302

288303
impl Display for MultiEraBlock {

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

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
11
//! Block Slot
22
3-
use std::{
4-
cmp::Ordering,
5-
ops::{MulAssign, Sub},
6-
};
3+
use std::ops::{MulAssign, Sub};
74

85
use catalyst_types::conversion::from_saturating;
96
use num_bigint::{BigInt, Sign};
107
use serde::Serialize;
118

12-
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Default, Serialize)]
13-
149
/// Slot on the blockchain, typically one slot equals one second. However chain
1510
/// parameters can alter how long a slot is.
11+
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Default, Serialize)]
1612
pub struct Slot(u64);
1713

1814
impl Slot {
@@ -45,12 +41,6 @@ impl MulAssign<u64> for Slot {
4541
}
4642
}
4743

48-
impl PartialOrd for Slot {
49-
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
50-
self.0.partial_cmp(&other.0)
51-
}
52-
}
53-
5444
impl Sub for Slot {
5545
type Output = Slot;
5646

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use catalyst_types::conversion::from_saturating;
33

44
/// Transaction index within a block
55
/// See: <https://github.com/IntersectMBO/cardano-ledger/blob/78b32d585fd4a0340fb2b184959fb0d46f32c8d2/eras/conway/impl/cddl-files/conway.cddl#L20C1-L20C33>
6-
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
6+
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
77
pub struct TxnIndex(u16);
88

99
impl<
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
//! A transaction output offset inside the transaction.
2+
use catalyst_types::conversion::from_saturating;
3+
4+
/// A transaction output offset inside the transaction.
5+
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
6+
pub struct TxnOutputOffset(u16);
7+
8+
impl<
9+
T: Copy
10+
+ TryInto<u16>
11+
+ std::ops::Sub<Output = T>
12+
+ PartialOrd<T>
13+
+ num_traits::identities::Zero,
14+
> From<T> for TxnOutputOffset
15+
{
16+
fn from(value: T) -> Self {
17+
Self(from_saturating(value))
18+
}
19+
}
20+
21+
impl From<TxnOutputOffset> for i16 {
22+
fn from(val: TxnOutputOffset) -> Self {
23+
i16::try_from(val.0).unwrap_or(i16::MAX)
24+
}
25+
}
26+
27+
impl From<TxnOutputOffset> for usize {
28+
fn from(value: TxnOutputOffset) -> Self {
29+
value.0.into()
30+
}
31+
}
32+
33+
#[cfg(test)]
34+
mod tests {
35+
use super::*;
36+
37+
#[test]
38+
fn test_from_u8_to_txn_index() {
39+
let txn_index: TxnOutputOffset = 100u8.into(); // u8 is a valid type for conversion
40+
assert_eq!(txn_index.0, 100);
41+
}
42+
43+
#[test]
44+
fn test_from_u16_to_txn_index() {
45+
let txn_index: TxnOutputOffset = 500u16.into(); // u16 is valid and within range for `TxnOutputOffset`
46+
assert_eq!(txn_index.0, 500);
47+
}
48+
49+
#[test]
50+
fn test_from_i32_to_txn_index() {
51+
let txn_index: TxnOutputOffset = 1234i32.into(); // i32 can be converted into `TxnOutputOffset`
52+
assert_eq!(txn_index.0, 1234);
53+
}
54+
55+
#[test]
56+
fn test_from_u32_to_txn_index() {
57+
let txn_index: TxnOutputOffset = 500_000u32.into(); // u32 is larger but should be saturated to `u16::MAX`
58+
assert_eq!(txn_index.0, u16::MAX);
59+
}
60+
61+
#[test]
62+
fn test_from_large_i32_to_txn_index() {
63+
let txn_index: TxnOutputOffset = 70000i32.into(); // i32 too large for u16, should saturate to `u16::MAX`
64+
assert_eq!(txn_index.0, u16::MAX);
65+
}
66+
67+
#[test]
68+
fn test_txn_index_to_i16_within_range() {
69+
let txn_index = TxnOutputOffset(100);
70+
let result: i16 = txn_index.into(); // Should successfully convert to i16
71+
assert_eq!(result, 100);
72+
}
73+
74+
#[test]
75+
fn test_txn_index_to_i16_with_saturation() {
76+
let txn_index = TxnOutputOffset(u16::MAX); // u16::MAX = 65535, which is too large for i16
77+
let result: i16 = txn_index.into(); // Should saturate to i16::MAX
78+
assert_eq!(result, i16::MAX);
79+
}
80+
81+
#[test]
82+
fn test_txn_index_to_i16_with_zero() {
83+
let txn_index = TxnOutputOffset(0); // Should be able to convert to i16 without issue
84+
let result: i16 = txn_index.into();
85+
assert_eq!(result, 0);
86+
}
87+
}

0 commit comments

Comments
 (0)