Skip to content

Commit

Permalink
feat: Apply our Rust builder for wasm-preview-adapter crates (#58)
Browse files Browse the repository at this point in the history
* update wasm building process

* fix some check issues

* fix byte-array-literals lints

* fix build script lints

* fix fmt

* fix lints

* add licensing

* remove verify crate

* move byte-array-literals to another dir

* update

* fix

* update hermes Earthfile

* update version

* fix

* fix

* add Readme

* fix README.md

* fix

* update build

* disable benches

* wip

* wip

* update rust-toolchain files

* update Readme

* wip

* remove Cargo.lock

* fix lints

* fix spelling

* wip

* update readme

* rename dir

* rebuild wasi-preview1-component-adapter project structure

* fix vs recommended file

* update

* fix linting

* move wasi-preview-component-adapter from hermes dir to the root

* update APACHE license

* wip

* refactor(wasm): Refactor wasm component adapter and wasi/wit code (#72)

* refactor(wasm): Refactor wasm component adapter and wasi/wit code

* fix(wasm): Fix code format

* fix(wasm): Update standard WASI .wit files to latest version

* fix(wasm): Cleanup WASM wit definitions and remove things not compatible with Hermes.

* fix(wasm): Fix code format

* fix(spelling): Fix spelling check for wasm code

* feat(spelling): Add target to help build words lists

* fix(wasm): Fix code format

* fix(wasm): Use relative path to wit files so we don;t need symlink

* feat(wasm): Rewrite cron module and introduce basic hermes modules.  Others need re-writing

* fix(spelling): Fix spellcheck errors

---------

Co-authored-by: Steven Johnson <[email protected]>
  • Loading branch information
Mr-Leshiy and stevenj authored Jan 30, 2024
1 parent 5ceca8c commit 6b8f26a
Show file tree
Hide file tree
Showing 89 changed files with 2,309 additions and 1,200 deletions.
16 changes: 16 additions & 0 deletions .config/dictionaries/project.dic
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ CEST
chainsync
chrono
ciphertext
codegen
codepoints
coti
cryptoxide
Expand All @@ -25,12 +26,15 @@ drep
dreps
encryptor
excalidraw
fmtchk
fmtfix
fontawesome
fsgr
genhtml
gmtime
hardano
ideascale
idents
Intellij
iohk
jetbrains
Expand All @@ -40,6 +44,7 @@ Jörmungandr
kroki
lcov
Leshiy
lintfix
localizable
mdlint
miniprotocols
Expand All @@ -49,9 +54,11 @@ moderations
multiera
nanos
netkey
nextest
oneshot
openapi
opentelemetry
permissioned
permissionless
pg_isready
plpgsql
Expand All @@ -62,15 +69,24 @@ pubspec
rapidoc
redoc
rustc
rustdoc
rustdocflags
rustflags
saibatizoku
seckey
slotno
stevenj
tacho
testcov
testdocs
testunit
thiserror
timelike
toolsets
Traceback
vitss
voteplan
voteplans
WASI
webasm
yoroi
3 changes: 2 additions & 1 deletion .vscode/settings.recommended.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@
"Earthfile": "earthfile"
},
"rust-analyzer.linkedProjects": [
"./hermes/bin/Cargo.toml"
"./hermes/Cargo.toml",
"./wasm/wasi-hermes-component-adapter/Cargo.toml"
],
"rust-analyzer.check.overrideCommand": [
"bash",
Expand Down
13 changes: 12 additions & 1 deletion Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,18 @@ markdown-check-fix:
# check-spelling Check spelling in this repo inside a container.
check-spelling:
DO github.com/input-output-hk/catalyst-ci/earthly/cspell:v2.0.10+CHECK


# check-spelling Check spelling in this repo inside a container.
spell-list-words:
FROM ghcr.io/streetsidesoftware/cspell:8.0.0
WORKDIR /work

COPY . .

RUN cspell-cli --words-only --unique "wasm/**" | sort -f



repo-docs:
# Create artifacts of extra files we embed inside the documentation when its built.
FROM scratch
Expand Down
3 changes: 1 addition & 2 deletions cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,6 @@
"*.excalidraw",
".vscode/**",
"**/.idea/**",
"hermes/wasm/*/**",
"hermes/crates/cardano-chain-follower/examples/snapshot_data"
]
}
}
61 changes: 11 additions & 50 deletions hermes/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
# Use MOLD linker where possible, but ONLY in CI applicable targets.
# cspell: words rustflags armv gnueabihf msvc nextest idents rustdocflags
# cspell: words rustdoc lintfix lintrestrict testfast testdocs codegen testci testunit
# cspell: words fmtchk fmtfix testcov

# Configure how Docker container targets build.

# If you want to customize these targets for a local build, then customize them in you:
# If you want to customize these targets for a local build, then customize them in your:
# $CARGO_HOME/config.toml
# NOT in the project itself.
# These targets are ONLY the targets used by CI and inside docker builds.
Expand All @@ -28,48 +25,12 @@ rustflags = [
"-C", "target-feature=-crt-static"
]

[target.wasm32-unknown-unknown]
rustflags = ["--cap-lints", "warn"]

[build]

rustflags = [
"-D",
"warnings",
"-D",
"missing_docs",
"-D",
"let_underscore_drop",
"-D",
"non_ascii_idents",
"-D",
"single_use_lifetimes",
"-D",
"trivial_casts",
"-D",
"trivial_numeric_casts",
]

rustflags = []
rustdocflags = [
"--enable-index-page",
"-Z",
"unstable-options",
"-D",
"warnings",
"-D",
"missing_docs",
"-D",
"rustdoc::broken_intra_doc_links",
"-D",
"rustdoc::invalid_codeblock_attributes",
"-D",
"rustdoc::invalid_html_tags",
"-D",
"rustdoc::invalid_rust_codeblocks",
"-D",
"rustdoc::bare_urls",
"-D",
"rustdoc::unescaped_backticks",
]

[profile.dev]
Expand All @@ -78,7 +39,7 @@ debug = true
debug-assertions = true
overflow-checks = true
lto = false
panic = 'unwind'
panic = "unwind"
incremental = true
codegen-units = 256

Expand All @@ -88,7 +49,7 @@ debug = false
debug-assertions = false
overflow-checks = false
lto = "thin"
panic = 'unwind'
panic = "unwind"
incremental = false
codegen-units = 16

Expand All @@ -110,14 +71,14 @@ incremental = false
codegen-units = 16

[alias]
lint = "clippy --all-targets -- -D warnings -D clippy::pedantic -D clippy::unwrap_used -D clippy::expect_used -D clippy::exit -D clippy::get_unwrap -D clippy::index_refutable_slice -D clippy::indexing_slicing -D clippy::match_on_vec_items -D clippy::match_wild_err_arm -D clippy::missing_panics_doc -D clippy::panic -D clippy::string_slice -D clippy::unchecked_duration_subtraction -D clippy::unreachable -D clippy::missing_docs_in_private_items"
lintfix = "clippy --all-targets --fix --allow-dirty -- -D warnings -D clippy::pedantic -D clippy::unwrap_used -D clippy::expect_used -D clippy::exit -D clippy::get_unwrap -D clippy::index_refutable_slice -D clippy::indexing_slicing -D clippy::match_on_vec_items -D clippy::match_wild_err_arm -D clippy::missing_panics_doc -D clippy::panic -D clippy::string_slice -D clippy::unchecked_duration_subtraction -D clippy::unreachable -D clippy::missing_docs_in_private_items"
lint-vscode = "clippy --message-format=json-diagnostic-rendered-ansi --all-targets -- -D warnings -D clippy::pedantic -D clippy::unwrap_used -D clippy::expect_used -D clippy::exit -D clippy::get_unwrap -D clippy::index_refutable_slice -D clippy::indexing_slicing -D clippy::match_on_vec_items -D clippy::match_wild_err_arm -D clippy::missing_panics_doc -D clippy::panic -D clippy::string_slice -D clippy::unchecked_duration_subtraction -D clippy::unreachable -D clippy::missing_docs_in_private_items"
lint = "clippy --all-targets"
lintfix = "clippy --all-targets --fix --allow-dirty"
lint-vscode = "clippy --message-format=json-diagnostic-rendered-ansi --all-targets"

docs = "doc --release --no-deps --document-private-items --bins --lib --examples"
# nightly docs build broken... when they are'nt we can enable these docs... --unit-graph --timings=html,json -Z unstable-options"
testunit = "nextest run --release --bins --lib -P ci"
testcov = "llvm-cov nextest --release --bins --lib -P ci"
testunit = "nextest run --release --bins --lib --tests --benches --no-fail-fast -P ci"
testcov = "llvm-cov nextest --release --bins --lib --tests --benches --no-fail-fast -P ci"
testdocs = "test --doc --release"

# Rust formatting, MUST be run with +nightly
Expand All @@ -127,6 +88,6 @@ fmtfix = "fmt -- -v"
[term]
quiet = false # whether cargo output is quiet
verbose = false # whether cargo provides verbose output
color = 'auto' # whether cargo colorizes output use `CARGO_TERM_COLOR="off"` to disable.
progress.when = 'never' # whether cargo shows progress bar
color = "auto" # whether cargo colorizes output use `CARGO_TERM_COLOR="off"` to disable.
progress.when = "never" # whether cargo shows progress bar
progress.width = 80 # width of progress bar
2 changes: 1 addition & 1 deletion hermes/.config/nextest.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# cspell: words nextest scrollability testcase
# cspell: words scrollability testcase
[store]
# The directory under the workspace root at which nextest-related files are
# written. Profile-specific storage is currently written to dir/<profile-name>.
Expand Down
34 changes: 34 additions & 0 deletions hermes/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,40 @@ homepage = "https://input-output-hk.github.io/hermes"
repository = "https://github.com/input-output-hk/hermes"
license = "MIT OR Apache-2.0"

[workspace.lints.rust]
warnings = "deny"
missing_docs = "deny"
let_underscore_drop = "deny"
non_ascii_idents = "deny"
single_use_lifetimes = "deny"
trivial_casts = "deny"
trivial_numeric_casts = "deny"

[workspace.lints.rustdoc]
broken_intra_doc_links = "deny"
invalid_codeblock_attributes = "deny"
invalid_html_tags = "deny"
invalid_rust_codeblocks = "deny"
bare_urls = "deny"
unescaped_backticks = "deny"

[workspace.lints.clippy]
pedantic = "deny"
unwrap_used = "deny"
expect_used = "deny"
exit = "deny"
get_unwrap = "deny"
index_refutable_slice = "deny"
indexing_slicing = "deny"
match_on_vec_items = "deny"
match_wild_err_arm = "deny"
missing_panics_doc = "deny"
panic = "deny"
string_slice = "deny"
unchecked_duration_subtraction = "deny"
unreachable = "deny"
missing_docs_in_private_items = "deny"

[workspace.dependencies]
# Stop using catalyst-pallas once pallas changes are merged.
# issue: https://github.com/input-output-hk/hermes/issues/63
Expand Down
14 changes: 6 additions & 8 deletions hermes/Earthfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
VERSION 0.7

#cspell: words rustfmt toolsets USERARCH
#cspell: words rustfmt

# Set up our target toolchains, and copy our files.
builder:
FROM github.com/input-output-hk/catalyst-ci/earthly/rust:v2.4.0+rust-base
DO github.com/input-output-hk/catalyst-ci/earthly/rust:v2.6.0+SETUP

DO github.com/input-output-hk/catalyst-ci/earthly/rust:v2.4.0+SETUP

COPY --dir .cargo .config Cargo.* clippy.toml deny.toml rustfmt.toml bin crates .
COPY --dir .cargo .config crates bin .
COPY Cargo.toml .
COPY clippy.toml deny.toml rustfmt.toml .

## -----------------------------------------------------------------------------
##
Expand All @@ -33,9 +33,7 @@ all-hosts-check:
build:
FROM +builder

RUN /scripts/std_build.py --with_test \
--with_bench \
--libs="cardano-chain-follower" \
RUN /scripts/std_build.py --libs="cardano-chain-follower" \
--bins="hermes/hermes"

SAVE ARTIFACT target/$TARGETARCH/doc doc
Expand Down
21 changes: 21 additions & 0 deletions hermes/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!-- cspell: words indexmap -->

# Hermes core

An implementation of the Hermes core engine in Rust

* [Hermes core](#hermes-core)
* [Build notes](#build-notes)

## Build notes

During the build process, you may encounter specific known issues:
[tower/issues/466](https://github.com/tower-rs/tower/issues/466)
and [indexmap/issues/151](https://github.com/indexmap-rs/indexmap/issues/151).
These issues can impede the build's success.
We recommend explicitly setting the environment variable `CARGO_FEATURE_STD=1` as a temporary solution.
This workaround has effectively bypassed the mentioned problems until a permanent fix is implemented.

```shell
CARGO_FEATURE_STD=1 cargo b
```
3 changes: 3 additions & 0 deletions hermes/bin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ authors.workspace = true
edition.workspace = true
license.workspace = true
repository.workspace = true

[lints]
workspace = true
3 changes: 3 additions & 0 deletions hermes/crates/cardano-chain-follower/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ homepage.workspace = true
repository.workspace = true
license.workspace = true

[lints]
workspace = true

[dependencies]
pallas.workspace = true
pallas-hardano.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion hermes/deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -279,4 +279,4 @@ allow-git = [
# 1 or more gitlab.com organizations to allow git sources for
#gitlab = [""]
# 1 or more bitbucket.org organizations to allow git sources for
#bitbucket = [""]
#bitbucket = [""]
3 changes: 1 addition & 2 deletions hermes/rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
[toolchain]
channel = "1.73.0"
channel = "1.75.0"
profile = "default"
components = []
targets = ["x86_64-unknown-linux-musl"]
5 changes: 0 additions & 5 deletions hermes/wasm/.cargo/config.toml

This file was deleted.

35 changes: 0 additions & 35 deletions hermes/wasm/Cargo.toml

This file was deleted.

Loading

0 comments on commit 6b8f26a

Please sign in to comment.