Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(rust/cardano-blockchain-types): add cardano-blockchain-types crate #107

Merged
merged 57 commits into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
dba341c
feat(rust): add cardano-blockchain-types crate
stevenj Dec 17, 2024
f3871a8
fix(rust): Remove unused dependencies
stevenj Dec 17, 2024
23a5138
fix(cardano-blockchain-types): time_to_slot calculation
bkioshn Dec 17, 2024
0662020
fix(cardano-blockchain-types): remove justfile
bkioshn Dec 17, 2024
c9185b5
Merge branch 'main' into feat/cardano-blockchain-types
bkioshn Dec 17, 2024
aa6bd36
fix(cardano-blockchain-types): point new should take type Slot and Bl…
bkioshn Dec 17, 2024
e027d8b
fix(cardano-blockchain-types): Fork type
bkioshn Dec 17, 2024
7efac20
fix(cardano-blockchain-types): point and fuzzy point test
bkioshn Dec 17, 2024
8ddebf5
Merge branch 'main' into feat/cardano-blockchain-types
stevenj Dec 17, 2024
1d600bd
fix(cardano-blockchain-types): add Fork increment function
bkioshn Dec 18, 2024
bfc2e15
fix(cardano-blockchain-types): add comment on tag 259
bkioshn Dec 18, 2024
d48e32b
fix(cardano-blockchain-types): add Fork decrement function
bkioshn Dec 18, 2024
349642c
test(rust): try earthly no-cache
bkioshn Dec 18, 2024
8583611
test(rust): try earthly no-cache and fix doc artifact
bkioshn Dec 18, 2024
42f71d7
test(rust): remove no-cache
bkioshn Dec 18, 2024
c267593
fix(cardano-blockchain-types): expose Fork and Network
bkioshn Dec 18, 2024
5eb13da
Merge branch 'main' into feat/cardano-blockchain-types
bkioshn Dec 18, 2024
c80fa33
fix(cardano-blockchain-types): add partailOrd to Fork
bkioshn Dec 18, 2024
0b0152d
Update rust/cardano-blockchain-types/src/point.rs
stevenj Dec 19, 2024
347045a
fix(cardano-blockchain-types): cleanup
bkioshn Dec 19, 2024
8d04f53
fix(cardano-blockchain-types): testdoc
bkioshn Dec 19, 2024
e48399a
Update rust/cardano-blockchain-types/src/point.rs
stevenj Dec 19, 2024
d17adf7
Merge branch 'main' into feat/cardano-blockchain-types
bkioshn Dec 19, 2024
48ca937
fix(cardano-blockchain-types): cleanup
bkioshn Dec 20, 2024
60802ce
fix(cardano-blockchain-types): format
bkioshn Dec 20, 2024
ea19d3e
fix(cardano-blockchain-types): add validate PR title
bkioshn Dec 20, 2024
4e2bdc6
fix(cardano-blockchain-types): comments
bkioshn Dec 20, 2024
519c415
fix(cardano-blockchain-types): fix hash_or_default
bkioshn Dec 20, 2024
e9b8ee3
fix(cardano-blockchain-types): redundant code
bkioshn Dec 20, 2024
0d964fd
test: no cache
bkioshn Dec 20, 2024
b553132
test: revert change
bkioshn Dec 20, 2024
881f07c
test ci
bkioshn Dec 23, 2024
be14a11
test ci
bkioshn Dec 23, 2024
c68a4a5
test ci
bkioshn Dec 23, 2024
b082ccc
test ci
bkioshn Dec 23, 2024
e5a1c53
test ci
bkioshn Dec 23, 2024
02cea97
test ci
bkioshn Dec 23, 2024
87b7aa7
test ci
bkioshn Dec 23, 2024
5150b0c
test ci
bkioshn Dec 23, 2024
7b51b80
test ci
bkioshn Dec 23, 2024
1ccf814
test ci
bkioshn Dec 23, 2024
6178014
revert change
bkioshn Dec 23, 2024
4291806
test ci
bkioshn Dec 23, 2024
fe48d5a
revert change
bkioshn Dec 23, 2024
aed622e
Merge branch 'main' into feat/cardano-blockchain-types
bkioshn Dec 27, 2024
a4e8ecd
fix(rust): Bump rust version, and test everything using that version.
stevenj Jan 2, 2025
58b5f7a
feat(rust): Bump more dependencies
stevenj Jan 2, 2025
0f13a52
fix(rust): Use latest cat-ci release for latest rust compiler
stevenj Jan 2, 2025
434bd83
fix(rust): skip building the c509 crate as rust
stevenj Jan 2, 2025
a259fc1
fix(rust): Fix bad character in the file
stevenj Jan 2, 2025
e6e3759
fix(rust): Remove redundant Earthfile
stevenj Jan 2, 2025
f8408dc
fix(rust): Reduce runtime of excessively slow property tests
stevenj Jan 3, 2025
381f970
fix(rust): test serialized doctests in ci
stevenj Jan 3, 2025
e3e2e98
fix(rust): Try and fix broken test reports after cat-ci upgraded to f…
stevenj Jan 3, 2025
0ac183d
fix(rust): Disable code coverage in CI because its broken after cat-c…
stevenj Jan 3, 2025
4adadb3
fix(rust): Try and fix CI being totally broken now that allure report…
stevenj Jan 3, 2025
a61c87c
fix(rust): Use released cat-ci version
stevenj Jan 3, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .config/dictionaries/project.dic
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Arissara
asyncio
Attributes
auditability
auxdata
babystep
backpressure
bech
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
with:
forge_version: 0.2.0

test_reporting:
if: always()
needs: ci
uses: ./.github/workflows/generate-allure-report.yml
#test_reporting:
# if: always()
# needs: ci
# uses: ./.github/workflows/generate-allure-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ concurrency:
cancel-in-progress: true

env:
AWS_REGION: eu-central-1
AWS_ROLE_ARN: arn:aws:iam::332405224602:role/ci
EARTHLY_TARGET: docker
ECR_REGISTRY: 332405224602.dkr.ecr.eu-central-1.amazonaws.com
ALLURE_REPORT_PATH: allure-report
COVERAGE_REPORT_PATH: coverage-report
REPORT_EXT: .junit-report.xml
Expand All @@ -29,24 +25,22 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Setup CI
uses: input-output-hk/catalyst-ci/actions/setup@master
- name: Install Forge
uses: input-output-hk/catalyst-forge/actions/install@ci/v1.5.0
with:
aws_role_arn: ${{ env.AWS_ROLE_ARN }}
aws_region: ${{ env.AWS_REGION }}
earthly_runner_secret: ${{ secrets.EARTHLY_RUNNER_SECRET }}
version: 0.8.0
if: always()

- name: Setup CI
uses: input-output-hk/catalyst-forge/actions/setup@ci/v1.5.0

- name: Get catalyst libs unit test report
uses: input-output-hk/catalyst-ci/actions/run@master
uses: input-output-hk/catalyst-forge/actions/run@ci/v1.5.0
if: always()
continue-on-error: true
with:
earthfile: ./rust/
flags:
targets: build
target_flags:
runner_address: ${{ secrets.EARTHLY_SATELLITE_ADDRESS }}
artifact: "false"
command: run
args: ./catalyst-libs+build

- name: Collect and upload test reports
uses: actions/upload-artifact@v4
Expand Down Expand Up @@ -107,7 +101,7 @@ jobs:

- name: Comment PR with Allure report link
if: ${{ always() && github.event_name == 'pull_request' && steps.allure.outputs.report_url }}
uses: thollander/actions-comment-pull-request@v2
uses: thollander/actions-comment-pull-request@v3
with:
message: |
${{ 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 }}}$ |
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/semantic_pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ jobs:
rust/cbork
rust/hermes-ipfs
rust/rbac-registration
rust/cardano-blockchain-types
dart
docs
general
4 changes: 2 additions & 2 deletions Earthfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
VERSION 0.8

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


FROM debian:stable-slim
Expand Down
2 changes: 1 addition & 1 deletion docs/Earthfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
VERSION 0.8

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


IMPORT .. AS repo
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
VERSION 0.8

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

check-cddl:
FROM cddl-ci+cddl-base
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
VERSION 0.8

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

check-cddl:
FROM cddl-ci+cddl-base
Expand Down
6 changes: 1 addition & 5 deletions rust/.cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,7 @@ rustflags = [

[build]
rustflags = []
rustdocflags = [
"--enable-index-page",
"-Z",
"unstable-options",
]
rustdocflags = []

[profile.dev]
opt-level = 1
Expand Down
1 change: 1 addition & 0 deletions rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
resolver = "2"
members = [
"c509-certificate",
"cardano-blockchain-types",
"cardano-chain-follower",
"hermes-ipfs",
"cbork",
Expand Down
7 changes: 4 additions & 3 deletions rust/Earthfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
VERSION 0.8

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

COPY_SRC:
FUNCTION
Expand All @@ -9,6 +9,7 @@ COPY_SRC:
Cargo.toml clippy.toml deny.toml rustfmt.toml \
.cargo .config \
c509-certificate \
cardano-blockchain-types \
cardano-chain-follower \
catalyst-voting vote-tx-v1 vote-tx-v2 \
cbork cbork-abnf-parser cbork-cddl-parser \
Expand Down Expand Up @@ -53,7 +54,7 @@ build:

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

SAVE ARTIFACT target/$TARGETARCH/doc doc
SAVE ARTIFACT target/doc doc
SAVE ARTIFACT target/release/cbork cbork

# build-src-check: Check for any caching issues with the source we are building against.
Expand Down
3 changes: 2 additions & 1 deletion rust/Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ code-lint:
cargo lint -r

# Pre Push Checks
pre-push: sync-cfg code-format code-lint license-check
pre-push: sync-cfg code-format code-lint
# license-check
# Make sure we can actually build inside Earthly which needs to happen in CI.
earthly +check
earthly +build
Expand Down
20 changes: 11 additions & 9 deletions rust/c509-certificate/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,28 @@ hex = "0.4.3"
oid = "0.2.1"
oid-registry = "0.7.1"
asn1-rs = "0.6.2"
anyhow = "1.0.89"
anyhow = "1.0.95"
bimap = "0.6.3"
once_cell = "1.20.2"
strum = "0.26.3"
strum_macros = "0.26.4"
regex = "1.11.0"
regex = "1.11.1"
ed25519-dalek = { version = "2.1.1", features = ["pem"] }
thiserror = "1.0.64"
serde = { version = "1.0.210", features = ["derive"] }
wasm-bindgen = "0.2.93"
serde-wasm-bindgen = "0.6.5"
thiserror = "2.0.9"
serde = { version = "1.0.217", features = ["derive"] }

# Only re-enable when building targeting wasm is detected, should not be used in a non wasm build.
#wasm-bindgen = "0.2.99"
#serde-wasm-bindgen = "0.6.5"

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

[dev-dependencies]
clap = { version = "4.5.19", features = ["derive"] }
serde_json = "1.0.128"
clap = { version = "4.5.23", features = ["derive"] }
serde_json = "1.0.134"
rand = "0.8.5"
chrono = "0.4.38"
chrono = "0.4.39"

[[example]]
name = "c509"
Expand Down
6 changes: 3 additions & 3 deletions rust/c509-certificate/Earthfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
VERSION 0.8

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


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

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

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

SAVE ARTIFACT /pkg AS LOCAL ./pkg
17 changes: 11 additions & 6 deletions rust/c509-certificate/examples/cli/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ impl Cli {
None => None,
};

generate(&json_file, output, sk.as_ref(), &key_type)
generate(&json_file, output, sk.as_ref(), key_type)
},
Cli::Verify { file, public_key } => verify(&file, public_key),
Cli::Decode { file, output } => decode(&file, output),
Expand Down Expand Up @@ -143,7 +143,7 @@ const SELF_SIGNED_INT: u8 = 2;
/// A function to generate C509 certificate.
fn generate(
file: &PathBuf, output: Option<PathBuf>, private_key: Option<&PrivateKey>,
key_type: &Option<String>,
key_type: Option<String>,
) -> anyhow::Result<()> {
let data = fs::read_to_string(file)?;
let c509_json: C509Json = serde_json::from_str(&data)?;
Expand Down Expand Up @@ -247,10 +247,15 @@ fn parse_public_key(public_key: &str) -> anyhow::Result<PublicKey> {
}

/// Get the key type. Currently support only Ed25519.
fn get_key_type(key_type: &Option<String>) -> anyhow::Result<(Oid<'static>, Option<String>)> {
match key_type.as_deref() {
Some("ed25519") | None => Ok(ED25519),
Some(_) => Err(anyhow::anyhow!("Currently only support Ed25519")),
fn get_key_type(key_type: Option<String>) -> anyhow::Result<(Oid<'static>, Option<String>)> {
match key_type {
None => Err(anyhow::anyhow!("Currently only support Ed25519")),
Some(key_type) => {
match key_type.as_str() {
"ed25519" => Ok(ED25519),
_ => Err(anyhow::anyhow!("Currently only support Ed25519")),
}
},
}
}

Expand Down
4 changes: 2 additions & 2 deletions rust/c509-certificate/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ pub mod signing;
pub mod subject_pub_key_algo;
mod tables;
pub mod time;
pub mod wasm_binding;
// Only re-enable when building with wasm is detected, should not be used in a non wasm
// build. pub mod wasm_binding;

/// Generate a signed or unsigned C509 certificate.
///
Expand All @@ -78,7 +79,6 @@ pub mod wasm_binding;
/// # Errors
///
/// Returns an error if the generated data is invalid.

pub fn generate(tbs_cert: &TbsCert, private_key: Option<&PrivateKey>) -> anyhow::Result<Vec<u8>> {
// Encode the TbsCert
let encoded_tbs = {
Expand Down
2 changes: 1 addition & 1 deletion rust/c509-certificate/src/oid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ impl Encode<()> for C509oid {
impl Decode<'_, ()> for C509oid {
/// Decode an OID
/// Decode the OID as unwrapped OID (~oid) - as bytes string without tag.

///
/// # Returns
///
/// A C509oid instance.
Expand Down
6 changes: 3 additions & 3 deletions rust/c509-certificate/src/signing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use ed25519_dalek::{
pkcs8::{DecodePrivateKey, DecodePublicKey},
SigningKey, VerifyingKey,
};
use wasm_bindgen::prelude::wasm_bindgen;
// use wasm_bindgen::prelude::wasm_bindgen;

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

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

#[allow(dead_code)]
Expand Down
36 changes: 36 additions & 0 deletions rust/cardano-blockchain-types/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
[package]
name = "cardano-blockchain-types"
description = "Common Cardano Blockchain data types for use in both applications and crates"
keywords = ["cardano", "catalyst",]
version = "0.0.1"
authors = [
"Steven Johnson <[email protected]>"
]
edition.workspace = true
license.workspace = true
homepage.workspace = true
repository.workspace = true

[lib]
crate-type = ["cdylib", "rlib"]

[lints]
workspace = true

[dependencies]
pallas = { version = "0.30.1", git = "https://github.com/input-output-hk/catalyst-pallas.git", rev = "9b5183c8b90b90fe2cc319d986e933e9518957b3" }
pallas-crypto = { version = "0.30.1", git = "https://github.com/input-output-hk/catalyst-pallas.git", rev = "9b5183c8b90b90fe2cc319d986e933e9518957b3" }
# pallas-hardano = { version = "0.30.1", git = "https://github.com/input-output-hk/catalyst-pallas.git", rev = "9b5183c8b90b90fe2cc319d986e933e9518957b3" }
stevenj marked this conversation as resolved.
Show resolved Hide resolved

ouroboros = "0.18.4"
tracing = "0.1.41"
anyhow = "1.0.94"
chrono = "0.4.39"
strum = { version = "0.26.3", features = ["derive"] }
dirs = "5.0.1"
hex = "0.4.3"
dashmap = "6.1.0"
blake2b_simd = "1.0.2"
minicbor = { version = "0.25.1", features = ["alloc"] }
num-traits = "0.2.19"
ed25519-dalek = "2.1.1"
6 changes: 6 additions & 0 deletions rust/cardano-blockchain-types/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Improved version of Pallas Multi Era Block

Adds features to the Pallas Multi Era Block to allow us to re-use it between the different cardano crates,
and the services that use them.

The original source was `cardano-chain-follower`.
Loading
Loading