Skip to content

Commit 012601e

Browse files
Merge branch 'main' into rbac-registration-improvements
2 parents a5af8a8 + 768ecd5 commit 012601e

File tree

21 files changed

+1465
-17
lines changed

21 files changed

+1465
-17
lines changed

.config/dictionaries/project.dic

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ dbsync
5858
dcbor
5959
decompressor
6060
delegators
61+
displaydoc
6162
dleq
6263
dlog
6364
dockerhub
@@ -254,6 +255,7 @@ Traceback
254255
txmonitor
255256
txns
256257
typenum
258+
uncategorized
257259
unfinalized
258260
unixfs
259261
unlinkat

.github/workflows/ci.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ permissions:
1313

1414
jobs:
1515
ci:
16-
uses: input-output-hk/catalyst-forge/.github/workflows/ci.yml@ci/v1.1.0
16+
uses: input-output-hk/catalyst-forge/.github/workflows/ci.yml@ci/v1.5.0
1717
with:
18-
forge_version: 0.2.0
18+
forge_version: 0.8.0
1919

20-
#test_reporting:
21-
# if: always()
22-
# needs: ci
23-
# uses: ./.github/workflows/generate-allure-report.yml
20+
test_reporting:
21+
if: always()
22+
needs: ci
23+
uses: ./.github/workflows/generate-allure-report.yml

.github/workflows/generate-allure-report.yml.disabled renamed to .github/workflows/generate-allure-report.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
continue-on-error: true
4141
with:
4242
command: run
43-
args: ./catalyst-libs+build
43+
args: ./rust+build
4444

4545
- name: Collect and upload test reports
4646
uses: actions/upload-artifact@v4
@@ -105,7 +105,6 @@ jobs:
105105
with:
106106
message: |
107107
${{ steps.allure.outputs.test_result_icon }} [Test Report](${{ steps.allure.outputs.report_url }}) | ${\color{lightgreen}Pass: ${{ steps.allure.outputs.test_result_passed }}/${{ steps.allure.outputs.test_result_total }}}$ | ${\color{red}Fail: ${{ steps.allure.outputs.test_result_failed }}/${{ steps.allure.outputs.test_result_total }}}$ |
108-
comment_tag: allure_report
109108
mode: upsert
110109

111110
generate-coverage-report:

.github/workflows/semantic_pull_request.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ jobs:
1818
rust
1919
rust/c509-certificate
2020
rust/cardano-chain-follower
21+
rust/catalyst-types
2122
rust/catalyst-voting
2223
rust/immutable-ledger
2324
rust/vote-tx-v1

blueprint.cue

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,14 @@ global: {
66
"^build(-.*)?$",
77
"^package(-.*)?$",
88
"^test(-.*)?$",
9-
"^release(-.*)?$",
10-
"^publish(-.*)?$",
119
]
1210
registries: [
13-
ci.providers.aws.registry,
11+
ci.providers.aws.ecr.registry,
1412
]
1513
providers: {
1614
aws: {
1715
region: "eu-central-1"
18-
registry: "332405224602.dkr.ecr.eu-central-1.amazonaws.com"
16+
ecr: registry: "332405224602.dkr.ecr.eu-central-1.amazonaws.com"
1917
role: "arn:aws:iam::332405224602:role/ci"
2018
}
2119

@@ -44,8 +42,9 @@ global: {
4442
path: "GITHUB_TOKEN"
4543
},
4644
]
47-
tagging: {
48-
strategy: "commit"
49-
}
45+
}
46+
repo: {
47+
defaultBranch: "main"
48+
name: "input-output-hk/catalyst-libs"
5049
}
5150
}

rust/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ members = [
1010
"cbork-cddl-parser",
1111
"cbork-utils",
1212
"catalyst-voting",
13-
"catalyst-voting",
13+
"catalyst-types",
1414
"immutable-ledger",
1515
"vote-tx-v1",
1616
"vote-tx-v2",

rust/Earthfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ COPY_SRC:
99
Cargo.toml clippy.toml deny.toml rustfmt.toml \
1010
.cargo .config \
1111
c509-certificate \
12+
catalyst-types \
1213
cardano-blockchain-types \
1314
cardano-chain-follower \
1415
catalyst-voting vote-tx-v1 vote-tx-v2 \
@@ -55,7 +56,7 @@ build:
5556
DO rust-ci+EXECUTE \
5657
--cmd="/scripts/std_build.py" \
5758
--args1="--libs=c509-certificate --libs=cardano-blockchain-types --libs=cardano-chain-follower --libs=hermes-ipfs" \
58-
--args2="--libs=cbork-cddl-parser --libs=cbork-abnf-parser --libs=cbork-utils" \
59+
--args2="--libs=cbork-cddl-parser --libs=cbork-abnf-parser --libs=cbork-utils --libs=catalyst-types" \
5960
--args3="--libs=catalyst-voting --libs=immutable-ledger --libs=vote-tx-v1 --libs=vote-tx-v2" \
6061
--args4="--bins=cbork/cbork --libs=rbac-registration --libs=signed_doc" \
6162
--args5="--cov_report=$HOME/build/coverage-report.info" \

rust/catalyst-types/Cargo.toml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
[package]
2+
name = "catalyst-types"
3+
version = "0.0.1"
4+
edition.workspace = true
5+
license.workspace = true
6+
authors.workspace = true
7+
homepage.workspace = true
8+
repository.workspace = true
9+
10+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
11+
12+
[lints]
13+
workspace = true
14+
15+
[lib]
16+
name = "catalyst_types"
17+
18+
[dependencies]
19+
blake2b_simd = "1.0.2"
20+
coset = "0.3.8"
21+
displaydoc = "0.2.5"
22+
ed25519-dalek = "2.1.1"
23+
fluent-uri = "0.3.2"
24+
hex = "0.4.3"
25+
minicbor = { version = "0.25.1", features = ["std"] }
26+
num-traits = "0.2.19"
27+
orx-concurrent-vec = "3.1.0"
28+
pallas-crypto = { version = "0.30.1", git = "https://github.com/input-output-hk/catalyst-pallas.git", rev = "9b5183c8b90b90fe2cc319d986e933e9518957b3" }
29+
serde = { version = "1.0.217", features = ["derive"] }
30+
thiserror = "2.0.9"
31+
base64-url = "3.0.0"
32+
uuid = { version = "1.11.0", features = ["v4", "v7", "serde"] }
33+
34+
[dev-dependencies]
35+
ed25519-dalek = { version = "2.1.1", features = ["rand_core"] }
36+
rand = "0.8.5"

rust/catalyst-types/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Catalyst Types
2+
3+
This library is designed to streamline the organization and sharing of types across multiple crates.
4+
It provides a centralized location for reusable, enhanced types that are not specific to a particular domain, such as Cardano.
5+
6+
## Purpose
7+
8+
* To enhance types that can be utilized across different libraries or projects.
9+
* To provide utility functions related to types and conversion between types.
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
//! Conversion functions
2+
3+
use displaydoc::Display;
4+
use thiserror::Error;
5+
6+
/// Errors that can occur when converting bytes to an Ed25519 verifying key.
7+
#[derive(Display, Debug, Error)]
8+
pub enum VKeyFromBytesError {
9+
/// Invalid byte length: expected {expected} bytes, got {actual}
10+
InvalidLength {
11+
/// The expected number of bytes (must be 32).
12+
expected: usize,
13+
/// The actual number of bytes in the provided input.
14+
actual: usize,
15+
},
16+
/// Failed to parse Ed25519 public key: {source}
17+
ParseError {
18+
/// The underlying error from `ed25519_dalek`.
19+
#[from]
20+
source: ed25519_dalek::SignatureError,
21+
},
22+
}
23+
24+
/// Convert an `<T>` to `<R>` (saturate if out of range).
25+
/// Note can convert any int to float, or f32 to f64 as well.
26+
/// can not convert from float to int, or f64 to f32.
27+
pub fn from_saturating<
28+
R: Copy + num_traits::identities::Zero + num_traits::Bounded,
29+
T: Copy
30+
+ TryInto<R>
31+
+ std::ops::Sub<Output = T>
32+
+ std::cmp::PartialOrd<T>
33+
+ num_traits::identities::Zero,
34+
>(
35+
value: T,
36+
) -> R {
37+
match value.try_into() {
38+
Ok(value) => value,
39+
Err(_) => {
40+
// If we couldn't convert, its out of range for the destination type.
41+
if value > T::zero() {
42+
// If the number is positive, its out of range in the positive direction.
43+
R::max_value()
44+
} else {
45+
// Otherwise its out of range in the negative direction.
46+
R::min_value()
47+
}
48+
},
49+
}
50+
}
51+
52+
/// Try and convert a byte array into an Ed25519 verifying key.
53+
///
54+
/// # Errors
55+
///
56+
/// Fails if the bytes are not a valid ED25519 Public Key
57+
pub fn vkey_from_bytes(bytes: &[u8]) -> Result<ed25519_dalek::VerifyingKey, VKeyFromBytesError> {
58+
if bytes.len() != ed25519_dalek::PUBLIC_KEY_LENGTH {
59+
return Err(VKeyFromBytesError::InvalidLength {
60+
expected: ed25519_dalek::PUBLIC_KEY_LENGTH,
61+
actual: bytes.len(),
62+
});
63+
}
64+
65+
let mut ed25519 = [0u8; ed25519_dalek::PUBLIC_KEY_LENGTH];
66+
ed25519.copy_from_slice(bytes); // Can't panic because we already validated its size.
67+
68+
ed25519_dalek::VerifyingKey::from_bytes(&ed25519)
69+
.map_err(|source| VKeyFromBytesError::ParseError { source })
70+
}

0 commit comments

Comments
 (0)