Skip to content

Commit f1b22f6

Browse files
authored
fix(athena): libc header not found when build wasm-wasip2 for module that use catlib rbac-registration (ARM architect) (#556)
* fix: libc header not found when build wasm-wasip2 in arm Signed-off-by: bkioshn <[email protected]> * chore: spelling Signed-off-by: bkioshn <[email protected]> * fix: update rust ci from 3.5.14 to 3.5.17 Signed-off-by: bkioshn <[email protected]> * fix: deny.toml Signed-off-by: bkioshn <[email protected]> * fix: deny.toml Signed-off-by: bkioshn <[email protected]> * fix: license and cargo lock Signed-off-by: bkioshn <[email protected]> * update dep and fix accordingly Signed-off-by: bkioshn <[email protected]> * fix linter and format Signed-off-by: bkioshn <[email protected]> * update dep Signed-off-by: bkioshn <[email protected]> * chore: remove unnecessary clone Signed-off-by: bkioshn <[email protected]> * fix problem report json display Signed-off-by: bkioshn <[email protected]> * remove unwrap Signed-off-by: bkioshn <[email protected]> --------- Signed-off-by: bkioshn <[email protected]>
1 parent 2b4cb31 commit f1b22f6

File tree

24 files changed

+867
-909
lines changed

24 files changed

+867
-909
lines changed

hermes/Cargo.lock

Lines changed: 694 additions & 859 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

hermes/Earthfile

Lines changed: 1 addition & 1 deletion
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.5.14 AS rust-ci
3+
IMPORT github.com/input-output-hk/catalyst-ci/earthly/rust:v3.5.17 AS rust-ci
44
#IMPORT github.com/input-output-hk/catalyst-ci/earthly/rust:feat/disallow-debug-format AS rust-ci
55

66
# Use when debugging cat-ci locally.

hermes/apps/athena/modules/Earthfile

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ VERSION 0.8
77

88
# Catalyst CI Rust Environment - provides pre-configured Rust toolchain with WASM support
99
# This includes: rustc, cargo, wasm32-wasip2 target, optimization tools, and build utilities
10-
IMPORT github.com/input-output-hk/catalyst-ci/earthly/rust:v3.5.14 AS rust-ci
11-
10+
IMPORT github.com/input-output-hk/catalyst-ci/earthly/rust:v3.5.17 AS rust-ci
1211

1312
# Alternative for local catalyst-ci debugging (uncomment when needed):
1413
# IMPORT ../../../catalyst-ci/earthly/rust AS rust-ci
@@ -138,4 +137,15 @@ save-local-hermes:
138137

139138
# Save the binary to local filesystem for development use
140139
# This makes it available at ./hermes in the calling directory
141-
SAVE ARTIFACT hermes AS LOCAL ./hermes
140+
SAVE ARTIFACT hermes AS LOCAL ./hermes
141+
142+
# Build wasm32-wasip2 for each modules
143+
modules-build-wasm32-wasip2:
144+
BUILD ./rbac-registration+build-rbac-registration
145+
BUILD ./rbac-registration-indexer+build-rbac-registration-indexer
146+
BUILD ./http-proxy+build-http-proxy
147+
148+
# Run build modules wasm32-wasip2 for the specify architect
149+
# Comment this out if it take long time for CI to build.
150+
build-all-host-modules-build-wasm32-wasip2:
151+
BUILD --platform=linux/amd64 --platform=linux/arm64 +modules-build-wasm32-wasip2

hermes/apps/athena/modules/rbac-registration-indexer/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ strum = "0.27.2"
1414
strum_macros = "0.27.2"
1515

1616
cardano-blockchain-types = { version = "0.0.6", git = "https://github.com/input-output-hk/catalyst-libs", tag = "cardano-blockchain-types/v0.0.6" }
17-
rbac-registration = { version = "0.0.9", git = "https://github.com/input-output-hk/catalyst-libs", tag = "rbac-registration/v0.0.9" }
18-
catalyst-types = { version = "0.0.6", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "catalyst-types/v0.0.6" }
17+
rbac-registration = { version = "0.0.10", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "rbac-registration/v0.0.10" }
18+
catalyst-types = { version = "0.0.7", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "catalyst-types/v0.0.7" }

hermes/apps/athena/modules/rbac-registration-indexer/src/lib.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use rbac_registration::{
2929
cardano::cip509::{Cip0134UriSet, Cip509},
3030
};
3131
use serde_json::json;
32-
use utils::{cardano::block::build_block, log::log_error};
32+
use utils::{cardano::block::build_block, log::log_error, problem_report::problem_report_to_json};
3333

3434
use crate::{
3535
database::{
@@ -55,7 +55,7 @@ use crate::{
5555
utils::log::log_info,
5656
};
5757

58-
use hermes::{cardano, sqlite::api::Statement};
58+
use hermes::cardano;
5959

6060
struct RbacRegistrationComponent;
6161

@@ -121,7 +121,7 @@ impl exports::hermes::cardano::event_on_block::Guest for RbacRegistrationCompone
121121
};
122122

123123
// ------- Extract and insert RBAC registrations into DB -------
124-
for reg in registrations.clone() {
124+
for reg in registrations {
125125
// Data needed for db
126126
let txn_id: Vec<u8> = reg.txn_hash().into();
127127
let catalyst_id: Option<String> =
@@ -130,11 +130,7 @@ impl exports::hermes::cardano::event_on_block::Guest for RbacRegistrationCompone
130130
let txn_idx: u16 = reg.origin().txn_index().into();
131131
let purpose: Option<String> = reg.purpose().map(|p| p.to_string());
132132
let prv_txn_id: Option<Vec<u8>> = reg.previous_transaction().map(|p| p.into());
133-
let problem_report: Option<String> = reg
134-
.report()
135-
.is_problematic()
136-
.then(|| serde_json::to_string(&reg.report()).ok())
137-
.flatten();
133+
let problem_report: Option<String> = problem_report_to_json(reg.report());
138134
// Can contain multiple stake addresses
139135
let stake_addresses = reg
140136
.certificate_uris()
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
//! Utilities
2+
13
pub(crate) mod cardano;
24
pub(crate) mod log;
5+
pub(crate) mod problem_report;
36
pub(crate) mod value;
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
//! Problem report utils.
2+
3+
use catalyst_types::problem_report::ProblemReport;
4+
5+
/// Converts problem report to JSON.
6+
pub(crate) fn problem_report_to_json(report: &ProblemReport) -> Option<String> {
7+
if !report.is_problematic() {
8+
return None;
9+
}
10+
let mut obj = serde_json::json!({
11+
"context": report.context(),
12+
});
13+
14+
let entries: Vec<_> = report
15+
.entries()
16+
.map(|elem| {
17+
elem.map(|entry| {
18+
let mut obj = serde_json::json!({
19+
"msg": entry.context(),
20+
});
21+
22+
if let Some(map) = obj.as_object_mut() {
23+
match entry.kind() {
24+
catalyst_types::problem_report::Kind::MissingField { field } => {
25+
map.insert("kind".to_string(), serde_json::json!("MissingField"));
26+
map.insert("field".to_string(), serde_json::json!(field));
27+
},
28+
catalyst_types::problem_report::Kind::UnknownField { field, value } => {
29+
map.insert("kind".to_string(), serde_json::json!("UnknownField"));
30+
map.insert("field".to_string(), serde_json::json!(field));
31+
map.insert("value".to_string(), serde_json::json!(value));
32+
},
33+
catalyst_types::problem_report::Kind::InvalidValue {
34+
field,
35+
value,
36+
constraint,
37+
} => {
38+
map.insert("kind".to_string(), serde_json::json!("InvalidValue"));
39+
map.insert("field".to_string(), serde_json::json!(field));
40+
map.insert("value".to_string(), serde_json::json!(value));
41+
map.insert("constraint".to_string(), serde_json::json!(constraint));
42+
},
43+
catalyst_types::problem_report::Kind::InvalidEncoding {
44+
field,
45+
encoded,
46+
expected,
47+
} => {
48+
map.insert("kind".to_string(), serde_json::json!("InvalidEncoding"));
49+
map.insert("field".to_string(), serde_json::json!(field));
50+
map.insert("encoded".to_string(), serde_json::json!(encoded));
51+
map.insert("expected".to_string(), serde_json::json!(expected));
52+
},
53+
catalyst_types::problem_report::Kind::FunctionalValidation {
54+
explanation,
55+
} => {
56+
map.insert(
57+
"kind".to_string(),
58+
serde_json::json!("FunctionalValidation"),
59+
);
60+
map.insert("explanation".to_string(), serde_json::json!(explanation));
61+
},
62+
catalyst_types::problem_report::Kind::DuplicateField {
63+
field,
64+
description,
65+
} => {
66+
map.insert("kind".to_string(), serde_json::json!("DuplicateField"));
67+
map.insert("field".to_string(), serde_json::json!(field));
68+
map.insert("description".to_string(), serde_json::json!(description));
69+
},
70+
catalyst_types::problem_report::Kind::ConversionError {
71+
field,
72+
value,
73+
expected_type,
74+
} => {
75+
map.insert("kind".to_string(), serde_json::json!("ConversionError"));
76+
map.insert("field".to_string(), serde_json::json!(field));
77+
map.insert("value".to_string(), serde_json::json!(value));
78+
map.insert(
79+
"expected_type".to_string(),
80+
serde_json::json!(expected_type),
81+
);
82+
},
83+
catalyst_types::problem_report::Kind::Other { description } => {
84+
map.insert("kind".to_string(), serde_json::json!("Other"));
85+
map.insert("description".to_string(), serde_json::json!(description));
86+
},
87+
}
88+
}
89+
90+
obj
91+
})
92+
})
93+
.collect();
94+
95+
let report_json = serde_json::json!({
96+
"context": report.context(),
97+
"entries": entries
98+
});
99+
100+
serde_json::to_string(&report_json).ok()
101+
}

hermes/apps/athena/modules/rbac-registration/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ strum = "0.27.2"
1414
strum_macros = "0.27.2"
1515

1616
cardano-blockchain-types = { version = "0.0.6", git = "https://github.com/input-output-hk/catalyst-libs", tag = "cardano-blockchain-types/v0.0.6" }
17-
rbac-registration = { version = "0.0.9", git = "https://github.com/input-output-hk/catalyst-libs", tag = "rbac-registration/v0.0.9" }
18-
catalyst-types = { version = "0.0.6", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "catalyst-types/v0.0.6" }
17+
rbac-registration = { version = "0.0.10", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "rbac-registration/v0.0.10" }
18+
catalyst-types = { version = "0.0.7", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "catalyst-types/v0.0.7" }

hermes/bin/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ path = "tests/integration/tests/mod.rs"
3232
[dependencies]
3333
# Catalyst Internal Crates
3434
hermes-ipfs = { version = "0.0.5", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "hermes-ipfs/v0.0.5" }
35-
cardano-blockchain-types = { version = "0.0.5", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "cardano-blockchain-types-v0.0.5" }
36-
cardano-chain-follower = { version = "0.0.11", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "cardano-chain-follower-v0.0.11" }
37-
catalyst-types = { version = "0.0.6", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "catalyst-types-v0.0.6" }
35+
cardano-blockchain-types = { version = "0.0.6", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "cardano-blockchain-types/v0.0.6" }
36+
cardano-chain-follower = { version = "0.0.14", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "cardano-chain-follower/v0.0.14" }
37+
catalyst-types = { version = "0.0.7", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "catalyst-types/v0.0.7" }
3838

3939
# HDF5 is consumed using a git tag, because the latest release is very old, but the code is much more advanced.
4040
hdf5 = { package = "hdf5-metno", version = "0.10.1", features = [ "static", "blosc", "blosc-zstd" ] }

hermes/bin/src/logger.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ impl FromStr for LogLevel {
4242
"info" => Ok(LogLevel::Info),
4343
"debug" => Ok(LogLevel::Debug),
4444
"trace" => Ok(LogLevel::Trace),
45-
_ => Err(anyhow::anyhow!("Invalid log level string: {}", s)),
45+
_ => Err(anyhow::anyhow!("Invalid log level string: {s}")),
4646
}
4747
}
4848
}

0 commit comments

Comments
 (0)