Skip to content

Commit 8df0b1c

Browse files
stevenjbkioshnstanislav-tkach
authored
feat(rust/cardano-blockchain-types): add cardano-blockchain-types crate (#107)
* feat(rust): add cardano-blockchain-types crate * fix(rust): Remove unused dependencies * fix(cardano-blockchain-types): time_to_slot calculation Signed-off-by: bkioshn <[email protected]> * fix(cardano-blockchain-types): remove justfile Signed-off-by: bkioshn <[email protected]> * fix(cardano-blockchain-types): point new should take type Slot and Blake2bHash Signed-off-by: bkioshn <[email protected]> * fix(cardano-blockchain-types): Fork type Signed-off-by: bkioshn <[email protected]> * fix(cardano-blockchain-types): point and fuzzy point test Signed-off-by: bkioshn <[email protected]> * fix(cardano-blockchain-types): add Fork increment function Signed-off-by: bkioshn <[email protected]> * fix(cardano-blockchain-types): add comment on tag 259 Signed-off-by: bkioshn <[email protected]> * fix(cardano-blockchain-types): add Fork decrement function Signed-off-by: bkioshn <[email protected]> * test(rust): try earthly no-cache Signed-off-by: bkioshn <[email protected]> * test(rust): try earthly no-cache and fix doc artifact Signed-off-by: bkioshn <[email protected]> * test(rust): remove no-cache Signed-off-by: bkioshn <[email protected]> * fix(cardano-blockchain-types): expose Fork and Network Signed-off-by: bkioshn <[email protected]> * fix(cardano-blockchain-types): add partailOrd to Fork Signed-off-by: bkioshn <[email protected]> * Update rust/cardano-blockchain-types/src/point.rs Co-authored-by: Stanislav Tkach <[email protected]> * fix(cardano-blockchain-types): cleanup Signed-off-by: bkioshn <[email protected]> * fix(cardano-blockchain-types): testdoc Signed-off-by: bkioshn <[email protected]> * Update rust/cardano-blockchain-types/src/point.rs * fix(cardano-blockchain-types): cleanup Signed-off-by: bkioshn <[email protected]> * fix(cardano-blockchain-types): format * fix(cardano-blockchain-types): add validate PR title * fix(cardano-blockchain-types): comments * fix(cardano-blockchain-types): fix hash_or_default * fix(cardano-blockchain-types): redundant code * test: no cache * test: revert change * test ci * test ci * test ci * test ci * test ci * test ci * test ci * test ci * test ci * test ci * revert change * test ci * revert change * fix(rust): Bump rust version, and test everything using that version. * feat(rust): Bump more dependencies * fix(rust): Use latest cat-ci release for latest rust compiler * fix(rust): skip building the c509 crate as rust * fix(rust): Fix bad character in the file * fix(rust): Remove redundant Earthfile * fix(rust): Reduce runtime of excessively slow property tests * fix(rust): test serialized doctests in ci * fix(rust): Try and fix broken test reports after cat-ci upgraded to forge. * fix(rust): Disable code coverage in CI because its broken after cat-ci upgraded to forge. * fix(rust): Try and fix CI being totally broken now that allure reports are disabled * fix(rust): Use released cat-ci version --------- Signed-off-by: bkioshn <[email protected]> Co-authored-by: bkioshn <[email protected]> Co-authored-by: bkioshn <[email protected]> Co-authored-by: Stanislav Tkach <[email protected]>
1 parent 9851aac commit 8df0b1c

File tree

85 files changed

+3105
-143
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+3105
-143
lines changed

.config/dictionaries/project.dic

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Arissara
1010
asyncio
1111
Attributes
1212
auditability
13+
auxdata
1314
babystep
1415
backpressure
1516
bech

.github/workflows/ci.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
with:
1818
forge_version: 0.2.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 .github/workflows/generate-allure-report.yml.disabled

+11-17
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@ concurrency:
1313
cancel-in-progress: true
1414

1515
env:
16-
AWS_REGION: eu-central-1
17-
AWS_ROLE_ARN: arn:aws:iam::332405224602:role/ci
18-
EARTHLY_TARGET: docker
19-
ECR_REGISTRY: 332405224602.dkr.ecr.eu-central-1.amazonaws.com
2016
ALLURE_REPORT_PATH: allure-report
2117
COVERAGE_REPORT_PATH: coverage-report
2218
REPORT_EXT: .junit-report.xml
@@ -29,24 +25,22 @@ jobs:
2925
steps:
3026
- uses: actions/checkout@v4
3127

32-
- name: Setup CI
33-
uses: input-output-hk/catalyst-ci/actions/setup@master
28+
- name: Install Forge
29+
uses: input-output-hk/catalyst-forge/actions/install@ci/v1.5.0
3430
with:
35-
aws_role_arn: ${{ env.AWS_ROLE_ARN }}
36-
aws_region: ${{ env.AWS_REGION }}
37-
earthly_runner_secret: ${{ secrets.EARTHLY_RUNNER_SECRET }}
31+
version: 0.8.0
32+
if: always()
33+
34+
- name: Setup CI
35+
uses: input-output-hk/catalyst-forge/actions/setup@ci/v1.5.0
3836

3937
- name: Get catalyst libs unit test report
40-
uses: input-output-hk/catalyst-ci/actions/run@master
38+
uses: input-output-hk/catalyst-forge/actions/run@ci/v1.5.0
4139
if: always()
4240
continue-on-error: true
4341
with:
44-
earthfile: ./rust/
45-
flags:
46-
targets: build
47-
target_flags:
48-
runner_address: ${{ secrets.EARTHLY_SATELLITE_ADDRESS }}
49-
artifact: "false"
42+
command: run
43+
args: ./catalyst-libs+build
5044

5145
- name: Collect and upload test reports
5246
uses: actions/upload-artifact@v4
@@ -107,7 +101,7 @@ jobs:
107101

108102
- name: Comment PR with Allure report link
109103
if: ${{ always() && github.event_name == 'pull_request' && steps.allure.outputs.report_url }}
110-
uses: thollander/actions-comment-pull-request@v2
104+
uses: thollander/actions-comment-pull-request@v3
111105
with:
112106
message: |
113107
${{ 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 }}}$ |

.github/workflows/semantic_pull_request.yml

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ jobs:
2626
rust/cbork
2727
rust/hermes-ipfs
2828
rust/rbac-registration
29+
rust/cardano-blockchain-types
2930
dart
3031
docs
3132
general

Earthfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
VERSION 0.8
22

3-
IMPORT github.com/input-output-hk/catalyst-ci/earthly/mdlint:v3.2.23 AS mdlint-ci
4-
IMPORT github.com/input-output-hk/catalyst-ci/earthly/cspell:v3.2.23 AS cspell-ci
3+
IMPORT github.com/input-output-hk/catalyst-ci/earthly/mdlint:v3.2.27 AS mdlint-ci
4+
IMPORT github.com/input-output-hk/catalyst-ci/earthly/cspell:v3.2.27 AS cspell-ci
55

66

77
FROM debian:stable-slim

docs/Earthfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
VERSION 0.8
22

3-
IMPORT github.com/input-output-hk/catalyst-ci/earthly/docs:v3.2.23 AS docs-ci
3+
IMPORT github.com/input-output-hk/catalyst-ci/earthly/docs:v3.2.27 AS docs-ci
44

55

66
IMPORT .. AS repo

docs/src/architecture/08_concepts/catalyst_voting/cddl/Earthfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
VERSION 0.8
22

3-
IMPORT github.com/input-output-hk/catalyst-ci/earthly/cddl:v3.2.23 AS cddl-ci
3+
IMPORT github.com/input-output-hk/catalyst-ci/earthly/cddl:v3.2.27 AS cddl-ci
44

55
check-cddl:
66
FROM cddl-ci+cddl-base

docs/src/architecture/08_concepts/immutable_ledger/cddl/Earthfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
VERSION 0.8
22

3-
IMPORT github.com/input-output-hk/catalyst-ci/earthly/cddl:v3.2.23 AS cddl-ci
3+
IMPORT github.com/input-output-hk/catalyst-ci/earthly/cddl:v3.2.27 AS cddl-ci
44

55
check-cddl:
66
FROM cddl-ci+cddl-base

rust/.cargo/config.toml

+1-5
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,7 @@ rustflags = [
2727

2828
[build]
2929
rustflags = []
30-
rustdocflags = [
31-
"--enable-index-page",
32-
"-Z",
33-
"unstable-options",
34-
]
30+
rustdocflags = []
3531

3632
[profile.dev]
3733
opt-level = 1

rust/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
resolver = "2"
33
members = [
44
"c509-certificate",
5+
"cardano-blockchain-types",
56
"cardano-chain-follower",
67
"hermes-ipfs",
78
"cbork",

rust/Earthfile

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
VERSION 0.8
22

3-
IMPORT github.com/input-output-hk/catalyst-ci/earthly/rust:v3.2.25 AS rust-ci
3+
IMPORT github.com/input-output-hk/catalyst-ci/earthly/rust:v3.2.27 AS rust-ci
44

55
COPY_SRC:
66
FUNCTION
@@ -9,6 +9,7 @@ COPY_SRC:
99
Cargo.toml clippy.toml deny.toml rustfmt.toml \
1010
.cargo .config \
1111
c509-certificate \
12+
cardano-blockchain-types \
1213
cardano-chain-follower \
1314
catalyst-voting vote-tx-v1 vote-tx-v2 \
1415
cbork cbork-abnf-parser cbork-cddl-parser \
@@ -53,7 +54,7 @@ build:
5354

5455
DO rust-ci+EXECUTE \
5556
--cmd="/scripts/std_build.py" \
56-
--args1="--libs=c509-certificate --libs=cardano-chain-follower --libs=hermes-ipfs" \
57+
--args1="--libs=c509-certificate --libs=cardano-blockchain-types --libs=cardano-chain-follower --libs=hermes-ipfs" \
5758
--args2="--libs=cbork-cddl-parser --libs=cbork-abnf-parser" \
5859
--args3="--libs=catalyst-voting --libs=immutable-ledger --libs=vote-tx-v1 --libs=vote-tx-v2" \
5960
--args4="--bins=cbork/cbork --libs=rbac-registration --libs=signed_doc" \
@@ -63,7 +64,7 @@ build:
6364
--coverage="cat-libs.coverage.info" \
6465
--docs="true"
6566

66-
SAVE ARTIFACT target/$TARGETARCH/doc doc
67+
SAVE ARTIFACT target/doc doc
6768
SAVE ARTIFACT target/release/cbork cbork
6869

6970
# build-src-check: Check for any caching issues with the source we are building against.

rust/Justfile

+2-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ code-lint:
3030
cargo lint -r
3131

3232
# Pre Push Checks
33-
pre-push: sync-cfg code-format code-lint license-check
33+
pre-push: sync-cfg code-format code-lint
34+
# license-check
3435
# Make sure we can actually build inside Earthly which needs to happen in CI.
3536
earthly +check
3637
earthly +build

rust/c509-certificate/Cargo.toml

+11-9
Original file line numberDiff line numberDiff line change
@@ -23,26 +23,28 @@ hex = "0.4.3"
2323
oid = "0.2.1"
2424
oid-registry = "0.7.1"
2525
asn1-rs = "0.6.2"
26-
anyhow = "1.0.89"
26+
anyhow = "1.0.95"
2727
bimap = "0.6.3"
2828
once_cell = "1.20.2"
2929
strum = "0.26.3"
3030
strum_macros = "0.26.4"
31-
regex = "1.11.0"
31+
regex = "1.11.1"
3232
ed25519-dalek = { version = "2.1.1", features = ["pem"] }
33-
thiserror = "1.0.64"
34-
serde = { version = "1.0.210", features = ["derive"] }
35-
wasm-bindgen = "0.2.93"
36-
serde-wasm-bindgen = "0.6.5"
33+
thiserror = "2.0.9"
34+
serde = { version = "1.0.217", features = ["derive"] }
35+
36+
# Only re-enable when building targeting wasm is detected, should not be used in a non wasm build.
37+
#wasm-bindgen = "0.2.99"
38+
#serde-wasm-bindgen = "0.6.5"
3739

3840
[package.metadata.cargo-machete]
3941
ignored = ["strum"]
4042

4143
[dev-dependencies]
42-
clap = { version = "4.5.19", features = ["derive"] }
43-
serde_json = "1.0.128"
44+
clap = { version = "4.5.23", features = ["derive"] }
45+
serde_json = "1.0.134"
4446
rand = "0.8.5"
45-
chrono = "0.4.38"
47+
chrono = "0.4.39"
4648

4749
[[example]]
4850
name = "c509"

rust/c509-certificate/Earthfile

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
VERSION 0.8
22

3-
IMPORT github.com/input-output-hk/catalyst-ci/earthly/rust::v3.2.23 AS rust-ci
3+
IMPORT github.com/input-output-hk/catalyst-ci/earthly/rust::v3.2.27 AS rust-ci
44

55

66
IMPORT .. AS rust-local
@@ -13,7 +13,7 @@ IMPORT ../.. AS repo
1313
# - Create a publish target which can publish the library to NPM for both Web and NodeJS.
1414
# - Create a simple example web app and nodejs app which uses the library, and can be used to
1515
# test it after publishing.
16-
build-wasm:
16+
skip-build-wasm: # for now skip building wasm.
1717
FROM rust-local+build
1818

1919
COPY repo+repo-docs/repo/LICENSE-APACHE c509-certificate/.
@@ -28,6 +28,6 @@ build-wasm:
2828

2929
# js-wasm-package-locally : Generate the wasm package and save it locally
3030
js-wasm-package-locally:
31-
FROM +build-wasm
31+
FROM +skip-build-wasm
3232

3333
SAVE ARTIFACT /pkg AS LOCAL ./pkg

rust/c509-certificate/examples/cli/main.rs

+11-6
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ impl Cli {
8585
None => None,
8686
};
8787

88-
generate(&json_file, output, sk.as_ref(), &key_type)
88+
generate(&json_file, output, sk.as_ref(), key_type)
8989
},
9090
Cli::Verify { file, public_key } => verify(&file, public_key),
9191
Cli::Decode { file, output } => decode(&file, output),
@@ -143,7 +143,7 @@ const SELF_SIGNED_INT: u8 = 2;
143143
/// A function to generate C509 certificate.
144144
fn generate(
145145
file: &PathBuf, output: Option<PathBuf>, private_key: Option<&PrivateKey>,
146-
key_type: &Option<String>,
146+
key_type: Option<String>,
147147
) -> anyhow::Result<()> {
148148
let data = fs::read_to_string(file)?;
149149
let c509_json: C509Json = serde_json::from_str(&data)?;
@@ -247,10 +247,15 @@ fn parse_public_key(public_key: &str) -> anyhow::Result<PublicKey> {
247247
}
248248

249249
/// Get the key type. Currently support only Ed25519.
250-
fn get_key_type(key_type: &Option<String>) -> anyhow::Result<(Oid<'static>, Option<String>)> {
251-
match key_type.as_deref() {
252-
Some("ed25519") | None => Ok(ED25519),
253-
Some(_) => Err(anyhow::anyhow!("Currently only support Ed25519")),
250+
fn get_key_type(key_type: Option<String>) -> anyhow::Result<(Oid<'static>, Option<String>)> {
251+
match key_type {
252+
None => Err(anyhow::anyhow!("Currently only support Ed25519")),
253+
Some(key_type) => {
254+
match key_type.as_str() {
255+
"ed25519" => Ok(ED25519),
256+
_ => Err(anyhow::anyhow!("Currently only support Ed25519")),
257+
}
258+
},
254259
}
255260
}
256261

rust/c509-certificate/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ pub mod signing;
6464
pub mod subject_pub_key_algo;
6565
mod tables;
6666
pub mod time;
67-
pub mod wasm_binding;
67+
// Only re-enable when building with wasm is detected, should not be used in a non wasm
68+
// build. pub mod wasm_binding;
6869

6970
/// Generate a signed or unsigned C509 certificate.
7071
///
@@ -78,7 +79,6 @@ pub mod wasm_binding;
7879
/// # Errors
7980
///
8081
/// Returns an error if the generated data is invalid.
81-
8282
pub fn generate(tbs_cert: &TbsCert, private_key: Option<&PrivateKey>) -> anyhow::Result<Vec<u8>> {
8383
// Encode the TbsCert
8484
let encoded_tbs = {

rust/c509-certificate/src/oid.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ impl Encode<()> for C509oid {
113113
impl Decode<'_, ()> for C509oid {
114114
/// Decode an OID
115115
/// Decode the OID as unwrapped OID (~oid) - as bytes string without tag.
116-
116+
///
117117
/// # Returns
118118
///
119119
/// A C509oid instance.

rust/c509-certificate/src/signing.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use ed25519_dalek::{
77
pkcs8::{DecodePrivateKey, DecodePublicKey},
88
SigningKey, VerifyingKey,
99
};
10-
use wasm_bindgen::prelude::wasm_bindgen;
10+
// use wasm_bindgen::prelude::wasm_bindgen;
1111

1212
/// Public or private key decoding from string error.
1313
#[derive(thiserror::Error, Debug)]
@@ -17,7 +17,7 @@ struct KeyPemDecodingError;
1717
/// Ed25519 private key instance.
1818
/// Wrapper over `ed25519_dalek::SigningKey`.
1919
#[allow(dead_code)]
20-
#[wasm_bindgen]
20+
//#[wasm_bindgen]
2121
#[derive(Clone, Debug, PartialEq, Eq)]
2222
pub struct PrivateKey(SigningKey);
2323

@@ -95,7 +95,7 @@ impl FromStr for PrivateKey {
9595
/// Ed25519 public key instance.
9696
/// Wrapper over `ed25519_dalek::VerifyingKey`.
9797
#[derive(Clone, Debug, PartialEq, Eq)]
98-
#[wasm_bindgen]
98+
//#[wasm_bindgen]
9999
pub struct PublicKey(VerifyingKey);
100100

101101
#[allow(dead_code)]
+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
[package]
2+
name = "cardano-blockchain-types"
3+
description = "Common Cardano Blockchain data types for use in both applications and crates"
4+
keywords = ["cardano", "catalyst",]
5+
version = "0.0.1"
6+
authors = [
7+
"Steven Johnson <[email protected]>"
8+
]
9+
edition.workspace = true
10+
license.workspace = true
11+
homepage.workspace = true
12+
repository.workspace = true
13+
14+
[lib]
15+
crate-type = ["cdylib", "rlib"]
16+
17+
[lints]
18+
workspace = true
19+
20+
[dependencies]
21+
pallas = { version = "0.30.1", git = "https://github.com/input-output-hk/catalyst-pallas.git", rev = "9b5183c8b90b90fe2cc319d986e933e9518957b3" }
22+
pallas-crypto = { version = "0.30.1", git = "https://github.com/input-output-hk/catalyst-pallas.git", rev = "9b5183c8b90b90fe2cc319d986e933e9518957b3" }
23+
# pallas-hardano = { version = "0.30.1", git = "https://github.com/input-output-hk/catalyst-pallas.git", rev = "9b5183c8b90b90fe2cc319d986e933e9518957b3" }
24+
25+
ouroboros = "0.18.4"
26+
tracing = "0.1.41"
27+
anyhow = "1.0.94"
28+
chrono = "0.4.39"
29+
strum = { version = "0.26.3", features = ["derive"] }
30+
dirs = "5.0.1"
31+
hex = "0.4.3"
32+
dashmap = "6.1.0"
33+
blake2b_simd = "1.0.2"
34+
minicbor = { version = "0.25.1", features = ["alloc"] }
35+
num-traits = "0.2.19"
36+
ed25519-dalek = "2.1.1"
+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Improved version of Pallas Multi Era Block
2+
3+
Adds features to the Pallas Multi Era Block to allow us to re-use it between the different cardano crates,
4+
and the services that use them.
5+
6+
The original source was `cardano-chain-follower`.

0 commit comments

Comments
 (0)