From 6dbd897dc31e116b1853f2c181589d3b80c2fe14 Mon Sep 17 00:00:00 2001 From: bkioshn <35752733+bkioshn@users.noreply.github.com> Date: Tue, 30 Jan 2024 18:46:26 +0700 Subject: [PATCH 1/2] fix: update poems (#220) * fix: update poems * fix: cat-gateway earthfile * fix: rust format * fix: artifact name * fix: strict test * fix: non strict test * fix(cspell): dict * fix: non strict test * fix: cargo toml * fix: workspace conflict * fix: workspace * fix: workspace edition * fix: cargo linter * fix: variant name end with enum name * fix: linter field name starts with the struct's name * fix: remove unwrap * fix: rust lint * fix: rename target * fix: typo --- .config/dictionaries/project.dic | 14 +- catalyst-gateway/.cargo/config.toml | 69 +--- catalyst-gateway/.config/nextest.toml | 6 +- catalyst-gateway/Cargo.lock | 302 +++++++++++------- catalyst-gateway/Cargo.toml | 42 ++- catalyst-gateway/Earthfile | 106 ++---- catalyst-gateway/bin/Cargo.toml | 6 +- catalyst-gateway/bin/src/event_db/error.rs | 2 +- .../bin/src/event_db/queries/event/ballot.rs | 2 +- .../bin/src/event_db/queries/event/mod.rs | 4 +- .../src/event_db/queries/event/proposal.rs | 4 +- .../bin/src/event_db/queries/registration.rs | 20 +- .../bin/src/event_db/queries/search.rs | 10 +- .../bin/src/event_db/queries/vit_ss/fund.rs | 20 +- .../bin/src/event_db/types/registration.rs | 2 +- .../src/event_db/types/vit_ss/challenge.rs | 4 +- .../bin/src/event_db/types/vit_ss/fund.rs | 8 +- .../bin/src/event_db/types/vit_ss/goal.rs | 2 +- .../bin/src/event_db/types/vit_ss/group.rs | 2 +- catalyst-gateway/bin/src/service/api/mod.rs | 4 +- .../common/objects/voter_registration.rs | 2 +- .../utilities/middleware/tracing_mw.rs | 7 +- catalyst-gateway/deny.toml | 13 +- catalyst-gateway/rust-toolchain.toml | 4 +- catalyst-gateway/tests/Cargo.toml | 8 +- catalyst-gateway/tests/Earthfile | 2 +- .../integration/catalyst_gateway_event_db.rs | 13 +- catalyst-gateway/tests/integration/main.rs | 2 - docs/Earthfile | 2 +- 29 files changed, 363 insertions(+), 319 deletions(-) diff --git a/.config/dictionaries/project.dic b/.config/dictionaries/project.dic index 73c6b017b12..922d81e62e9 100644 --- a/.config/dictionaries/project.dic +++ b/.config/dictionaries/project.dic @@ -106,4 +106,16 @@ xcodeproj xctest xctestrun xcworkspace -yoroi \ No newline at end of file +yoroi +idents +rustflags +rustdoc +rustdocflags +codegen +lintfix +testunit +nextest +testcov +testdocs +fmtchk +fmtfix \ No newline at end of file diff --git a/catalyst-gateway/.cargo/config.toml b/catalyst-gateway/.cargo/config.toml index 0eae0eb2158..2764f1df4e2 100644 --- a/catalyst-gateway/.cargo/config.toml +++ b/catalyst-gateway/.cargo/config.toml @@ -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 # 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. @@ -28,46 +25,12 @@ rustflags = [ "-C", "target-feature=-crt-static" ] - [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] @@ -76,7 +39,7 @@ debug = true debug-assertions = true overflow-checks = true lto = false -panic = 'unwind' +panic = "unwind" incremental = true codegen-units = 256 @@ -86,7 +49,7 @@ debug = false debug-assertions = false overflow-checks = false lto = "thin" -panic = 'unwind' +panic = "unwind" incremental = false codegen-units = 16 @@ -108,23 +71,23 @@ 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" -lintrestrict = "clippy -- -D warnings -D clippy::pedantic -D clippy::restriction -D clippy::missing_docs_in_private_items" -lint-vscode = "clippy --workspace --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 --workspace -r --all-features --no-deps --bins --document-private-items --examples --locked" +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" -testfast = "nextest --release --workspace --locked" -testdocs = "test --doc --release --workspace --locked" +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 fmtchk = "fmt -- --check -v --color=always" fmtfix = "fmt -- -v" [term] -quiet = false # whether cargo output is quiet -verbose = true # whether cargo provides verbose output -color = 'always' # whether cargo colorizes output use `CARGO_TERM_COLOR="off"` to disable. -progress.when = 'auto' # whether cargo shows progress bar -progress.width = 80 # width of progress bar +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 +progress.width = 80 # width of progress bar \ No newline at end of file diff --git a/catalyst-gateway/.config/nextest.toml b/catalyst-gateway/.config/nextest.toml index ebc7d73909d..de5cf9b1ef9 100644 --- a/catalyst-gateway/.config/nextest.toml +++ b/catalyst-gateway/.config/nextest.toml @@ -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/. @@ -35,7 +35,7 @@ path = "junit.xml" # The name of the top-level "report" element in JUnit report. If aggregating # reports across different test runs, it may be useful to provide separate names # for each report. -report-name = "cat-gateway" +report-name = "nextest" # Whether standard output and standard error for passing tests should be stored in the JUnit report. # Output is stored in the and elements of the element. @@ -46,4 +46,4 @@ store-success-output = true # # Note that if a description can be extracted from the output, it is always stored in the # element. -store-failure-output = true +store-failure-output = true \ No newline at end of file diff --git a/catalyst-gateway/Cargo.lock b/catalyst-gateway/Cargo.lock index c038dc65b51..9d1de423ca4 100644 --- a/catalyst-gateway/Cargo.lock +++ b/catalyst-gateway/Cargo.lock @@ -395,7 +395,6 @@ dependencies = [ "cpu-time", "cryptoxide", "dotenvy", - "hyper", "lazy_static", "panic-message", "poem", @@ -569,25 +568,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "crossbeam-channel" -version = "0.5.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a33c2bf77f2df06183c3aa30d1e96c0695a313d4f9c453cc3762a6db39f99200" -dependencies = [ - "cfg-if", - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-utils" -version = "0.8.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294" -dependencies = [ - "cfg-if", -] - [[package]] name = "crypto-common" version = "0.1.6" @@ -865,6 +845,12 @@ version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0" +[[package]] +name = "glob" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" + [[package]] name = "h2" version = "0.3.24" @@ -876,8 +862,27 @@ dependencies = [ "futures-core", "futures-sink", "futures-util", - "http", - "indexmap 2.0.2", + "http 0.2.9", + "indexmap", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "h2" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31d030e59af851932b72ceebadf4a2b5986dba4c3b99dd2493f8273a0f151943" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http 1.0.0", + "indexmap", "slab", "tokio", "tokio-util", @@ -910,14 +915,14 @@ checksum = "7dfda62a12f55daeae5015f81b0baea145391cb4520f86c248fc615d72640d12" [[package]] name = "headers" -version = "0.3.9" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06683b93020a07e3dbcf5f8c0f6d40080d725bea7936fc01ad345c01b97dc270" +checksum = "322106e6bd0cba2d5ead589ddb8150a13d7c4217cf80d7c4f682ca994ccc6aa9" dependencies = [ "base64", "bytes", "headers-core", - "http", + "http 1.0.0", "httpdate", "mime", "sha1", @@ -925,11 +930,11 @@ dependencies = [ [[package]] name = "headers-core" -version = "0.2.0" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7f66481bfee273957b1f20485a4ff3362987f85b2c236580d81b4eb7a326429" +checksum = "54b4a22553d4242c49fddb9ba998a99962b5cc6f22cb5a3482bec22522403ce4" dependencies = [ - "http", + "http 1.0.0", ] [[package]] @@ -979,6 +984,17 @@ dependencies = [ "itoa", ] +[[package]] +name = "http" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b32afd38673a8016f7c9ae69e5af41a58f81b1d31689040f2f1959594ce194ea" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + [[package]] name = "http-body" version = "0.4.5" @@ -986,7 +1002,30 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" dependencies = [ "bytes", - "http", + "http 0.2.9", + "pin-project-lite", +] + +[[package]] +name = "http-body" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cac85db508abc24a2e48553ba12a996e87244a0395ce011e62b37158745d643" +dependencies = [ + "bytes", + "http 1.0.0", +] + +[[package]] +name = "http-body-util" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41cb79eb393015dadd30fc252023adb0b2400a0caee0fa2a077e6e21a551e840" +dependencies = [ + "bytes", + "futures-util", + "http 1.0.0", + "http-body 1.0.0", "pin-project-lite", ] @@ -1012,9 +1051,9 @@ dependencies = [ "futures-channel", "futures-core", "futures-util", - "h2", - "http", - "http-body", + "h2 0.3.24", + "http 0.2.9", + "http-body 0.4.5", "httparse", "httpdate", "itoa", @@ -1026,6 +1065,25 @@ dependencies = [ "want", ] +[[package]] +name = "hyper" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb5aa53871fc917b1a9ed87b683a5d86db645e23acb32c2e0785a353e522fb75" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "h2 0.4.2", + "http 1.0.0", + "http-body 1.0.0", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "tokio", +] + [[package]] name = "hyper-rustls" version = "0.24.2" @@ -1033,13 +1091,31 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" dependencies = [ "futures-util", - "http", - "hyper", + "http 0.2.9", + "hyper 0.14.27", "rustls", "tokio", "tokio-rustls", ] +[[package]] +name = "hyper-util" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bdea9aac0dbe5a9240d68cfd9501e2db94222c6dc06843e06640b9e07f0fdc67" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "http 1.0.0", + "http-body 1.0.0", + "hyper 1.1.0", + "pin-project-lite", + "socket2 0.5.4", + "tokio", + "tracing", +] + [[package]] name = "iana-time-zone" version = "0.1.58" @@ -1079,16 +1155,6 @@ dependencies = [ "unicode-normalization", ] -[[package]] -name = "indexmap" -version = "1.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" -dependencies = [ - "autocfg", - "hashbrown 0.12.3", -] - [[package]] name = "indexmap" version = "2.0.2" @@ -1217,14 +1283,14 @@ dependencies = [ [[package]] name = "multer" -version = "2.1.0" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01acbdc23469fd8fe07ab135923371d5f5a422fbf9c522158677c8eb15bc51c2" +checksum = "a15d522be0a9c3e46fd2632e272d178f56387bdb5c9fbb3a36c649062e9b5219" dependencies = [ "bytes", "encoding_rs", "futures-util", - "http", + "http 1.0.0", "httparse", "log", "memchr", @@ -1234,6 +1300,17 @@ dependencies = [ "version_check", ] +[[package]] +name = "nix" +version = "0.27.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053" +dependencies = [ + "bitflags 2.4.1", + "cfg-if", + "libc", +] + [[package]] name = "nu-ansi-term" version = "0.46.0" @@ -1286,68 +1363,55 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" [[package]] name = "opentelemetry" -version = "0.20.0" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9591d937bc0e6d2feb6f71a559540ab300ea49955229c347a517a28d27784c54" +checksum = "1e32339a5dc40459130b3bd269e9892439f55b33e772d2a9d402a789baaf4e8a" dependencies = [ - "opentelemetry_api", - "opentelemetry_sdk", + "futures-core", + "futures-sink", + "indexmap", + "js-sys", + "once_cell", + "pin-project-lite", + "thiserror", + "urlencoding", ] [[package]] name = "opentelemetry-prometheus" -version = "0.13.0" +version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7d81bc254e2d572120363a2b16cdb0d715d301b5789be0cfc26ad87e4e10e53" +checksum = "6f8f082da115b0dcb250829e3ed0b8792b8f963a1ad42466e48422fbe6a079bd" dependencies = [ "once_cell", - "opentelemetry_api", + "opentelemetry", "opentelemetry_sdk", "prometheus", "protobuf", ] -[[package]] -name = "opentelemetry_api" -version = "0.20.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a81f725323db1b1206ca3da8bb19874bbd3f57c3bcd59471bfb04525b265b9b" -dependencies = [ - "futures-channel", - "futures-util", - "indexmap 1.9.3", - "js-sys", - "once_cell", - "pin-project-lite", - "thiserror", - "urlencoding", -] - [[package]] name = "opentelemetry_sdk" -version = "0.20.0" +version = "0.21.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa8e705a0612d48139799fcbaba0d4a90f06277153e43dd2bdc16c6f0edd8026" +checksum = "2f16aec8a98a457a52664d69e0091bac3a0abd18ead9b641cb00202ba4e0efe4" dependencies = [ "async-trait", - "crossbeam-channel", "futures-channel", "futures-executor", "futures-util", + "glob", "once_cell", - "opentelemetry_api", + "opentelemetry", "ordered-float", - "percent-encoding", - "rand", - "regex", "thiserror", ] [[package]] name = "ordered-float" -version = "3.9.2" +version = "4.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1e1c390732d15f1d48471625cd92d154e66db2c56645e29a9cd26f4699f72dc" +checksum = "a76df7075c7d4d01fdcb46c912dd17fba5b60c78ea480b475f2b6ab6f666584e" dependencies = [ "num-traits", ] @@ -1425,9 +1489,9 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "poem" -version = "1.3.58" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebc7ae19f3e791ae8108b08801abb3708d64d3a16490c720e0b81040cae87b5d" +checksum = "38a712ff53e257d60d3d22936c51cafa606552129d55539c8a400de44eff676d" dependencies = [ "async-compression", "async-trait", @@ -1437,11 +1501,14 @@ dependencies = [ "futures-util", "headers", "hex", - "http", - "hyper", + "http 1.0.0", + "http-body-util", + "hyper 1.1.0", + "hyper-util", "mime", "mime_guess", "multer", + "nix", "opentelemetry", "opentelemetry-prometheus", "parking_lot", @@ -1458,6 +1525,7 @@ dependencies = [ "serde_urlencoded", "serde_yaml", "smallvec", + "sync_wrapper", "tempfile", "thiserror", "time", @@ -1465,15 +1533,16 @@ dependencies = [ "tokio-stream", "tokio-util", "tracing", + "wildmatch", ] [[package]] name = "poem-derive" -version = "1.3.58" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2550a0bce7273b278894ef3ccc5a6869e7031b6870042f3cc6826ed9faa980a6" +checksum = "7e2bd3f82499a00ecb2d0e06bb1b9a17540aeaa28bab14336a94255ff5185f8f" dependencies = [ - "proc-macro-crate 1.3.1", + "proc-macro-crate 2.0.1", "proc-macro2", "quote", "syn 2.0.38", @@ -1481,9 +1550,9 @@ dependencies = [ [[package]] name = "poem-extensions" -version = "0.7.2" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97ba49b672c1b387c724a20fd6fd6d629a5423c17c5f1c381763b1c899fec35e" +checksum = "1cb723d94d93e11c68e5f9c1e0968948b1174a0e218115006add692da7d32fcb" dependencies = [ "poem", "poem-extensions-macro", @@ -1492,9 +1561,9 @@ dependencies = [ [[package]] name = "poem-extensions-macro" -version = "0.7.2" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f06eadfdec3a3a90626f990f2bf1668b857f0219b07eedabba3bf368620ce8e7" +checksum = "7f20d894749b3a96f5eeadc20d947a214969b000b0c68824d868576d5dd6e62d" dependencies = [ "darling", "proc-macro2", @@ -1505,16 +1574,16 @@ dependencies = [ [[package]] name = "poem-openapi" -version = "3.0.5" +version = "4.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c62659dcc7ca09a525881300646f3b28e319889072e83cd16a2865ba024a185e" +checksum = "3c7c12d9e19a0cda311f46515b819eb1e8425a4bee004540aff7b9c587e02b82" dependencies = [ "base64", "bytes", "chrono", "derive_more", "futures-util", - "indexmap 2.0.2", + "indexmap", "mime", "num-traits", "poem", @@ -1533,15 +1602,15 @@ dependencies = [ [[package]] name = "poem-openapi-derive" -version = "3.0.5" +version = "4.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e90bf699e87e95b8303f9b59684cf3b9a8fff840872b13cbe0680aa4330d5226" +checksum = "d5d485fb9cc4ca9a8364beedd4ea81294b1f028d459c8fd7bb352e38f87f8ffa" dependencies = [ "darling", - "http", - "indexmap 2.0.2", + "http 1.0.0", + "indexmap", "mime", - "proc-macro-crate 1.3.1", + "proc-macro-crate 2.0.1", "proc-macro2", "quote", "regex", @@ -1630,11 +1699,11 @@ dependencies = [ [[package]] name = "proc-macro-crate" -version = "1.3.1" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" +checksum = "97dc5fea232fc28d2f597b37c4876b348a40e33f3b02cc975c8d006d78d94b1a" dependencies = [ - "once_cell", + "toml_datetime", "toml_edit", ] @@ -1810,10 +1879,10 @@ dependencies = [ "encoding_rs", "futures-core", "futures-util", - "h2", - "http", - "http-body", - "hyper", + "h2 0.3.24", + "http 0.2.9", + "http-body 0.4.5", + "hyper 0.14.27", "hyper-rustls", "ipnet", "js-sys", @@ -2093,7 +2162,7 @@ version = "0.9.25" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1a49e178e4452f45cb61d0cd8cebc1b0fafd3e41929e996cef79aa3aca91f574" dependencies = [ - "indexmap 2.0.2", + "indexmap", "itoa", "ryu", "serde", @@ -2229,6 +2298,15 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "sync_wrapper" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" +dependencies = [ + "futures-core", +] + [[package]] name = "system-configuration" version = "0.5.1" @@ -2459,11 +2537,11 @@ checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" [[package]] name = "toml_edit" -version = "0.19.15" +version = "0.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" +checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" dependencies = [ - "indexmap 2.0.2", + "indexmap", "toml_datetime", "winnow", ] @@ -2798,6 +2876,12 @@ dependencies = [ "web-sys", ] +[[package]] +name = "wildmatch" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "495ec47bf3c1345005f40724f0269362c8556cbc43aed0526ed44cae1d35fceb" + [[package]] name = "winapi" version = "0.3.9" diff --git a/catalyst-gateway/Cargo.toml b/catalyst-gateway/Cargo.toml index a12233c17df..35fad6f767f 100644 --- a/catalyst-gateway/Cargo.toml +++ b/catalyst-gateway/Cargo.toml @@ -12,7 +12,6 @@ version = "0.0.1" authors = [ "Steven Johnson " ] -rust-version = "1.73" homepage = "https://input-output-hk.github.io/catalyst-voices" repository = "https://github.com/input-output-hk/catalyst-voices" license = "MIT OR Apache-2.0" @@ -27,9 +26,9 @@ tracing-subscriber = "0.3.16" serde = "1.0" serde_json = "1.0" -poem = "1.3.58" -poem-openapi = "3.0.4" -poem-extensions = "0.7.2" +poem = "2.0.0" +poem-openapi = "4.0.0" +poem-extensions = "0.8.0" prometheus = "0.13.0" cryptoxide = "0.4.4" @@ -40,7 +39,6 @@ cpu-time = "1.0" ulid = "1.0.1" rust-embed = "8" -hyper = "0.14" url = "2.4.1" thiserror = "1.0" @@ -58,3 +56,37 @@ tokio-postgres = "0.7.10" tokio = "1" dotenvy = "0.15" + +[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" \ No newline at end of file diff --git a/catalyst-gateway/Earthfile b/catalyst-gateway/Earthfile index e70fb1e480e..ca9c06d0707 100644 --- a/catalyst-gateway/Earthfile +++ b/catalyst-gateway/Earthfile @@ -1,112 +1,51 @@ -VERSION 0.7 +VERSION --try --global-cache 0.7 #cspell: words rustfmt toolsets USERARCH # Set up our target toolchains, and copy our files. builder: - FROM github.com/input-output-hk/catalyst-ci/earthly/rust:v2.0.14+rust-base - - DO github.com/input-output-hk/catalyst-ci/earthly/rust:v2.0.14+SETUP --toolchain=rust-toolchain.toml + DO github.com/input-output-hk/catalyst-ci/earthly/rust:v2.6.0+SETUP COPY --dir .cargo .config Cargo.* clippy.toml deny.toml rustfmt.toml bin crates tests . -# Test rust build container - Use best architecture host tools. -hosted-check: +## ----------------------------------------------------------------------------- +## +## Standard CI targets. +## +## These targets are discovered and executed automatically by CI. + +# Run check using the most efficient host tooling +# CI Automated Entry point. +check: FROM +builder - DO github.com/input-output-hk/catalyst-ci/earthly/rust:v2.0.14+CHECK + RUN /scripts/std_checks.py # Test which runs check with all supported host tooling. Needs qemu or rosetta to run. # Only used to validate tooling is working across host toolsets. all-hosts-check: - BUILD --platform=linux/amd64 --platform=linux/arm64 +hosted-check - -hosted-build: - ARG TARGETPLATFORM + BUILD --platform=linux/amd64 --platform=linux/arm64 +check +build: # Build the service FROM +builder - DO github.com/input-output-hk/catalyst-ci/earthly/rust:v2.0.14+BUILD --bins="cat-gateway/cat-gateway" - - DO github.com/input-output-hk/catalyst-ci/earthly/rust:v2.0.14+SMOKE_TEST --bin="cat-gateway" - - # generate OpenAPI docs + TRY + RUN /scripts/std_build.py --cov_report="coverage-report.info" \ + --bins="cat-gateway/cat-gateway" + FINALLY + SAVE ARTIFACT target/nextest/ci/junit.xml AS LOCAL cat-gateway.junit-report.xml + SAVE ARTIFACT coverage-report.info AS LOCAL cat-gateway.coverage-report.info + END RUN ./target/$TARGETARCH/release/cat-gateway docs ./target/$TARGETARCH/doc/cat-gateway-api.json - SAVE ARTIFACT target/$TARGETARCH/doc doc SAVE ARTIFACT target/$TARGETARCH/release/cat-gateway cat-gateway # Test which runs check with all supported host tooling. Needs qemu or rosetta to run. # Only used to validate tooling is working across host toolsets. all-hosts-build: - BUILD --platform=linux/amd64 --platform=linux/arm64 +hosted-build + BUILD --platform=linux/amd64 --platform=linux/arm64 +build -unit-test-hosted: - # Build the service - FROM +builder - - DO github.com/input-output-hk/catalyst-ci/earthly/rust:v2.0.14+UNIT_TEST - - SAVE ARTIFACT target/nextest/ci/junit.xml junit-report.xml - SAVE ARTIFACT coverage-report.info coverage-report.info - -## ----------------------------------------------------------------------------- -## -## Standard CI targets. -## -## These targets are discovered and executed automatically by CI. - -# Run check using the most efficient host tooling -# CI Automated Entry point. -check: - FROM busybox - # This is necessary to pick the correct architecture build to suit the native machine. - # It primarily ensures that Darwin/Arm builds work as expected without needing x86 emulation. - # All target implementation of this should follow this pattern. - ARG USERARCH - - IF [ "$USERARCH" == "arm64" ] - BUILD --platform=linux/arm64 +hosted-check - ELSE - BUILD --platform=linux/amd64 +hosted-check - END - -# Run build using the most efficient host tooling -# CI Automated Entry point. -build: - FROM busybox - # This is necessary to pick the correct architecture build to suit the native machine. - # It primarily ensures that Darwin/Arm builds work as expected without needing x86 emulation. - # All target implementation of this should follow this pattern. - ARG USERARCH - - IF [ "$USERARCH" == "arm64" ] - BUILD --platform=linux/arm64 +hosted-build - ELSE - BUILD --platform=linux/amd64 +hosted-build - END - - -# This step will build any packages we would intend to publish or integration test. -# package: -# FROM scratch - -# Run integration tests on all packages built during the `package` step. -test: - FROM busybox - # This is necessary to pick the correct architecture build to suit the native machine. - # It primarily ensures that Darwin/Arm builds work as expected without needing x86 emulation. - # All target implementation of this should follow this pattern. - ARG USERARCH - - IF [ "$USERARCH" == "arm64" ] - BUILD --platform=linux/arm64 +unit-test-hosted - BUILD --platform=linux/arm64 ./tests+integration-test - ELSE - BUILD --platform=linux/amd64 +unit-test-hosted - BUILD --platform=linux/amd64 ./tests+integration-test - END # Publish packages if all integration tests have passed. (Failure to pass tests will prevent packages being published.) # publish: @@ -119,5 +58,4 @@ local-ci-run: BUILD +check BUILD +build # BUILD +package - BUILD +test # BUILD +publish diff --git a/catalyst-gateway/bin/Cargo.toml b/catalyst-gateway/bin/Cargo.toml index 7eed5d26d75..800d6302651 100644 --- a/catalyst-gateway/bin/Cargo.toml +++ b/catalyst-gateway/bin/Cargo.toml @@ -11,6 +11,9 @@ repository.workspace = true # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +[lints] +workspace = true + [dependencies] async-trait = { workspace = true } @@ -62,7 +65,6 @@ lazy_static = { workspace = true } url = { workspace = true } dotenvy = { workspace = true } panic-message = { workspace = true } -hyper = { workspace = true } cpu-time = { workspace = true } ulid = { workspace = true, features = ["serde", "uuid"] } -rust-embed = { workspace = true } +rust-embed = { workspace = true } \ No newline at end of file diff --git a/catalyst-gateway/bin/src/event_db/error.rs b/catalyst-gateway/bin/src/event_db/error.rs index 12903ee4899..3e80a2c30de 100644 --- a/catalyst-gateway/bin/src/event_db/error.rs +++ b/catalyst-gateway/bin/src/event_db/error.rs @@ -28,7 +28,7 @@ pub(crate) enum Error { Unknown(String), /// Variable error #[error(transparent)] - VarError(#[from] VarError), + VarErr(#[from] VarError), } impl From> for Error { diff --git a/catalyst-gateway/bin/src/event_db/queries/event/ballot.rs b/catalyst-gateway/bin/src/event_db/queries/event/ballot.rs index 8815c0c07f8..4a8970e0279 100644 --- a/catalyst-gateway/bin/src/event_db/queries/event/ballot.rs +++ b/catalyst-gateway/bin/src/event_db/queries/event/ballot.rs @@ -77,7 +77,7 @@ impl BallotQueries for EventDB { ]) .await?; let row = rows - .get(0) + .first() .ok_or_else(|| Error::NotFound("cat not find ballot value".to_string()))?; let choices = row.try_get("objective")?; diff --git a/catalyst-gateway/bin/src/event_db/queries/event/mod.rs b/catalyst-gateway/bin/src/event_db/queries/event/mod.rs index e873768dd43..dc70fe4f38d 100644 --- a/catalyst-gateway/bin/src/event_db/queries/event/mod.rs +++ b/catalyst-gateway/bin/src/event_db/queries/event/mod.rs @@ -89,8 +89,8 @@ impl EventQueries for EventDB { let rows = conn.query(Self::EVENT_QUERY, &[&event.0]).await?; let row = rows - .get(0) - .ok_or_else(|| Error::NotFound("can not find event value".to_string()))?; + .first() + .ok_or_else(|| Error::NotFound("Cannot find event value".to_string()))?; let ends = row .try_get::<&'static str, Option>("end_time")? diff --git a/catalyst-gateway/bin/src/event_db/queries/event/proposal.rs b/catalyst-gateway/bin/src/event_db/queries/event/proposal.rs index e56e4e0433b..d58c5bd4f97 100644 --- a/catalyst-gateway/bin/src/event_db/queries/event/proposal.rs +++ b/catalyst-gateway/bin/src/event_db/queries/event/proposal.rs @@ -60,8 +60,8 @@ impl ProposalQueries for EventDB { .query(Self::PROPOSAL_QUERY, &[&event.0, &objective.0, &proposal.0]) .await?; let row = rows - .get(0) - .ok_or_else(|| Error::NotFound("cat not find proposal value".to_string()))?; + .first() + .ok_or_else(|| Error::NotFound("Cannot find proposal value".to_string()))?; let proposer = vec![ProposerDetails { name: row.try_get("proposer_name")?, diff --git a/catalyst-gateway/bin/src/event_db/queries/registration.rs b/catalyst-gateway/bin/src/event_db/queries/registration.rs index 87b4c7007f9..5198bae0f0b 100644 --- a/catalyst-gateway/bin/src/event_db/queries/registration.rs +++ b/catalyst-gateway/bin/src/event_db/queries/registration.rs @@ -97,8 +97,8 @@ impl RegistrationQueries for EventDB { .await? }; let voter = rows - .get(0) - .ok_or_else(|| Error::NotFound("can not find voter value".to_string()))?; + .first() + .ok_or_else(|| Error::NotFound("Cannot find voter value".to_string()))?; let voting_group = VoterGroupId(voter.try_get("voting_group")?); let voting_power = voter.try_get("voting_power")?; @@ -115,9 +115,9 @@ impl RegistrationQueries for EventDB { }; let total_voting_power_per_group: i64 = rows - .get(0) + .first() .ok_or_else(|| { - Error::NotFound("can not find total voting power per group value".to_string()) + Error::NotFound("Cannot find total voting power per group value".to_string()) })? .try_get("total_voting_power")?; @@ -155,7 +155,7 @@ impl RegistrationQueries for EventDB { }; Ok(Voter { - voter_info: VoterInfo { + info: VoterInfo { delegations_power: voter.try_get("delegations_power")?, delegations_count: voter.try_get("delegations_count")?, voting_power_saturation, @@ -187,8 +187,8 @@ impl RegistrationQueries for EventDB { .await? }; let delegator_snapshot_info = rows - .get(0) - .ok_or_else(|| Error::NotFound("can not find delegator value".to_string()))?; + .first() + .ok_or_else(|| Error::NotFound("Cannot find delegator value".to_string()))?; let delegation_rows = if let Some(event) = event { conn.query(Self::DELEGATIONS_BY_EVENT_QUERY, &[ @@ -204,7 +204,7 @@ impl RegistrationQueries for EventDB { .await? }; if delegation_rows.is_empty() { - return Err(Error::NotFound("can not find delegator value".to_string())); + return Err(Error::NotFound("Cannot find delegator value".to_string())); } let mut delegations = Vec::new(); @@ -225,8 +225,8 @@ impl RegistrationQueries for EventDB { .await? }; let total_power: i64 = rows - .get(0) - .ok_or_else(|| Error::NotFound("can not find total power value".to_string()))? + .first() + .ok_or_else(|| Error::NotFound("Cannot find total power value".to_string()))? .try_get("total_voting_power")?; #[allow(clippy::indexing_slicing)] // delegation_rows already checked to be not empty. diff --git a/catalyst-gateway/bin/src/event_db/queries/search.rs b/catalyst-gateway/bin/src/event_db/queries/search.rs index f6bf94442e9..8110081dac6 100644 --- a/catalyst-gateway/bin/src/event_db/queries/search.rs +++ b/catalyst-gateway/bin/src/event_db/queries/search.rs @@ -142,8 +142,8 @@ impl EventDB { .await .map_err(|e| Error::NotFound(e.to_string()))?; let row = rows - .get(0) - .ok_or_else(|| Error::NotFound("can not get row".to_string()))?; + .first() + .ok_or_else(|| Error::NotFound("Cannot get row".to_string()))?; Ok(SearchResult { total: row.try_get("total")?, @@ -187,7 +187,7 @@ impl EventDB { let total: i64 = events .len() .try_into() - .map_err(|_| Error::Unknown("can not convert to i64".to_string()))?; + .map_err(|_| Error::Unknown("Cannot convert to i64".to_string()))?; Ok(SearchResult { total, @@ -226,7 +226,7 @@ impl EventDB { let total: i64 = objectives .len() .try_into() - .map_err(|_| Error::Unknown("can not convert to i64".to_string()))?; + .map_err(|_| Error::Unknown("Cannot convert to i64".to_string()))?; Ok(SearchResult { total, @@ -263,7 +263,7 @@ impl EventDB { let total: i64 = proposals .len() .try_into() - .map_err(|_| Error::Unknown("can not convert to i64".to_string()))?; + .map_err(|_| Error::Unknown("Cannot convert to i64".to_string()))?; Ok(SearchResult { total, diff --git a/catalyst-gateway/bin/src/event_db/queries/vit_ss/fund.rs b/catalyst-gateway/bin/src/event_db/queries/vit_ss/fund.rs index 1df38dcb364..f394547e90c 100644 --- a/catalyst-gateway/bin/src/event_db/queries/vit_ss/fund.rs +++ b/catalyst-gateway/bin/src/event_db/queries/vit_ss/fund.rs @@ -118,8 +118,8 @@ impl VitSSFundQueries for EventDB { let rows = conn.query(Self::FUND_QUERY, &[]).await?; let row = rows - .get(0) - .ok_or_else(|| Error::NotFound("can not find fund value".to_string()))?; + .first() + .ok_or_else(|| Error::NotFound("Cannot find fund value".to_string()))?; let fund_id = row.try_get("id")?; @@ -165,7 +165,7 @@ impl VitSSFundQueries for EventDB { challenges.push(Challenge { id: row.try_get("id")?, internal_id: row.try_get("internal_id")?, - challenge_type: row.try_get("challenge_type")?, + c_type: row.try_get("challenge_type")?, title: row.try_get("title")?, description: row.try_get("description")?, rewards_total: row @@ -175,7 +175,7 @@ impl VitSSFundQueries for EventDB { .try_get::<_, Option>("proposers_rewards")? .unwrap_or_default(), fund_id, - challenge_url: row + url: row .try_get::<_, Option>("challenge_url")? .unwrap_or_default(), highlights: row @@ -189,7 +189,7 @@ impl VitSSFundQueries for EventDB { for row in rows { goals.push(Goal { id: row.try_get("id")?, - goal_name: row.try_get("goal_name")?, + name: row.try_get("goal_name")?, fund_id, }); } @@ -198,7 +198,7 @@ impl VitSSFundQueries for EventDB { let mut groups = Vec::new(); for row in rows { groups.push(Group { - group_id: row.try_get("group_id")?, + g_id: row.try_get("group_id")?, token_identifier: row.try_get("token_identifier")?, fund_id, }); @@ -206,14 +206,14 @@ impl VitSSFundQueries for EventDB { let fund = Fund { id: fund_id, - fund_name: row.try_get("fund_name")?, - fund_goal: row.try_get("fund_goal")?, + name: row.try_get("fund_name")?, + goal: row.try_get("fund_goal")?, voting_power_threshold: row.try_get("voting_power_threshold")?, - fund_start_time: row + start_time: row .try_get::<_, NaiveDateTime>("fund_start_time")? .and_local_timezone(Utc) .unwrap(), - fund_end_time: row + end_time: row .try_get::<_, NaiveDateTime>("fund_end_time")? .and_local_timezone(Utc) .unwrap(), diff --git a/catalyst-gateway/bin/src/event_db/types/registration.rs b/catalyst-gateway/bin/src/event_db/types/registration.rs index e38c254c976..e57059a9b50 100644 --- a/catalyst-gateway/bin/src/event_db/types/registration.rs +++ b/catalyst-gateway/bin/src/event_db/types/registration.rs @@ -26,7 +26,7 @@ pub(crate) struct VoterInfo { /// Voter pub(crate) struct Voter { /// Voter info - pub(crate) voter_info: VoterInfo, + pub(crate) info: VoterInfo, /// As at pub(crate) as_at: DateTime, /// Last updated diff --git a/catalyst-gateway/bin/src/event_db/types/vit_ss/challenge.rs b/catalyst-gateway/bin/src/event_db/types/vit_ss/challenge.rs index 77ab7254980..2600bdfe5ed 100644 --- a/catalyst-gateway/bin/src/event_db/types/vit_ss/challenge.rs +++ b/catalyst-gateway/bin/src/event_db/types/vit_ss/challenge.rs @@ -9,12 +9,12 @@ pub(crate) struct Challenge { // this is used only to retain the original insert order pub(crate) internal_id: i32, pub(crate) id: i32, - pub(crate) challenge_type: String, + pub(crate) c_type: String, pub(crate) title: String, pub(crate) description: String, pub(crate) rewards_total: i64, pub(crate) proposers_rewards: i64, pub(crate) fund_id: i32, - pub(crate) challenge_url: String, + pub(crate) url: String, pub(crate) highlights: Option, } diff --git a/catalyst-gateway/bin/src/event_db/types/vit_ss/fund.rs b/catalyst-gateway/bin/src/event_db/types/vit_ss/fund.rs index b9993a1e921..12a1d69b83e 100644 --- a/catalyst-gateway/bin/src/event_db/types/vit_ss/fund.rs +++ b/catalyst-gateway/bin/src/event_db/types/vit_ss/fund.rs @@ -20,11 +20,11 @@ pub(crate) struct FundStageDates { #[derive(Debug, Clone, PartialEq, Eq)] pub(crate) struct Fund { pub(crate) id: i32, - pub(crate) fund_name: String, - pub(crate) fund_goal: String, + pub(crate) name: String, + pub(crate) goal: String, pub(crate) voting_power_threshold: i64, - pub(crate) fund_start_time: DateTime, - pub(crate) fund_end_time: DateTime, + pub(crate) start_time: DateTime, + pub(crate) end_time: DateTime, pub(crate) next_fund_start_time: DateTime, pub(crate) registration_snapshot_time: DateTime, pub(crate) next_registration_snapshot_time: DateTime, diff --git a/catalyst-gateway/bin/src/event_db/types/vit_ss/goal.rs b/catalyst-gateway/bin/src/event_db/types/vit_ss/goal.rs index c2820577e9b..2c41f49e4b4 100644 --- a/catalyst-gateway/bin/src/event_db/types/vit_ss/goal.rs +++ b/catalyst-gateway/bin/src/event_db/types/vit_ss/goal.rs @@ -1,6 +1,6 @@ #[derive(Debug, Clone, PartialEq, Eq)] pub(crate) struct Goal { pub(crate) id: i32, - pub(crate) goal_name: String, + pub(crate) name: String, pub(crate) fund_id: i32, } diff --git a/catalyst-gateway/bin/src/event_db/types/vit_ss/group.rs b/catalyst-gateway/bin/src/event_db/types/vit_ss/group.rs index f3f9dd40426..35c2135a785 100644 --- a/catalyst-gateway/bin/src/event_db/types/vit_ss/group.rs +++ b/catalyst-gateway/bin/src/event_db/types/vit_ss/group.rs @@ -2,5 +2,5 @@ pub(crate) struct Group { pub(crate) fund_id: i32, pub(crate) token_identifier: String, - pub(crate) group_id: String, + pub(crate) g_id: String, } diff --git a/catalyst-gateway/bin/src/service/api/mod.rs b/catalyst-gateway/bin/src/service/api/mod.rs index ed573a9ae75..8eafc46b557 100644 --- a/catalyst-gateway/bin/src/service/api/mod.rs +++ b/catalyst-gateway/bin/src/service/api/mod.rs @@ -32,7 +32,7 @@ fn get_api_contact() -> ContactObject { } /// A long description of the API. Markdown is supported -const API_DESCRIPTION: &str = r#"# Catalyst Gateway API. +const API_DESCRIPTION: &str = "# Catalyst Gateway API. The Catalyst Gateway API provides realtime data for all prior, current and future Catalyst voting events. @@ -44,7 +44,7 @@ TODO: * Implement Voting API abstracting the Jormungandr API from public exposure. * Implement Audit API's (Retrieve voting blockchain records, registration/voting power audit and private tally audit. * Implement API's needed to support posting Ideas/Proposals etc.Catalyst Gateway -"#; +"; /// Get the license details for the API fn get_api_license() -> LicenseObject { diff --git a/catalyst-gateway/bin/src/service/common/objects/voter_registration.rs b/catalyst-gateway/bin/src/service/common/objects/voter_registration.rs index 4061851b4ac..756f9c580ab 100644 --- a/catalyst-gateway/bin/src/service/common/objects/voter_registration.rs +++ b/catalyst-gateway/bin/src/service/common/objects/voter_registration.rs @@ -39,7 +39,7 @@ impl TryFrom for VoterRegistration fn try_from(value: crate::event_db::types::registration::Voter) -> Result { Ok(Self { - voter_info: value.voter_info.try_into()?, + voter_info: value.info.try_into()?, as_at: value.as_at, last_updated: value.last_updated, is_final: value.is_final, diff --git a/catalyst-gateway/bin/src/service/utilities/middleware/tracing_mw.rs b/catalyst-gateway/bin/src/service/utilities/middleware/tracing_mw.rs index cfd2b0e5b5b..10e8eb0c4ca 100644 --- a/catalyst-gateway/bin/src/service/utilities/middleware/tracing_mw.rs +++ b/catalyst-gateway/bin/src/service/utilities/middleware/tracing_mw.rs @@ -3,11 +3,12 @@ use std::time::Instant; use cpu_time::ProcessTime; // ThreadTime doesn't work. use cryptoxide::{blake2b::Blake2b, digest::Digest}; -use hyper::header; use lazy_static::lazy_static; use poem::{ - async_trait, http::HeaderMap, web::RealIp, Endpoint, Error, FromRequest, IntoResponse, - Middleware, PathPattern, Request, Response, Result, + async_trait, + http::{header, HeaderMap}, + web::RealIp, + Endpoint, Error, FromRequest, IntoResponse, Middleware, PathPattern, Request, Response, Result, }; use poem_openapi::OperationId; use prometheus::{ diff --git a/catalyst-gateway/deny.toml b/catalyst-gateway/deny.toml index d28c1100d7f..926f2ef437e 100644 --- a/catalyst-gateway/deny.toml +++ b/catalyst-gateway/deny.toml @@ -98,6 +98,8 @@ ignore = [ [licenses] # The lint level for crates which do not have a detectable license unlicensed = "deny" +# Don't warn if a listed license isn't found +unused-allowed-license="allow" # List of explicitly allowed licenses # See https://spdx.org/licenses/ for list of possible licenses # [possible values: any SPDX 3.11 short identifier (+ optional exception)]. @@ -106,7 +108,8 @@ allow = [ "Apache-2.0", "Unicode-DFS-2016", "BSD-3-Clause", - "BlueOak-1.0.0" + "BlueOak-1.0.0", + "Apache-2.0 WITH LLVM-exception" ] # List of explicitly disallowed licenses # See https://spdx.org/licenses/ for list of possible licenses @@ -264,7 +267,11 @@ unknown-git = "deny" # if not specified. If it is specified but empty, no registries are allowed. allow-registry = ["https://github.com/rust-lang/crates.io-index"] # List of URLs for allowed Git repositories -allow-git = [] +allow-git = [ + # Remove this once upstream changes are merged. + # issue: https://github.com/input-output-hk/hermes/issues/63 + "https://github.com/input-output-hk/catalyst-pallas" +] [sources.allow-org] # 1 or more github.com organizations to allow git sources for @@ -272,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 = [""] \ No newline at end of file diff --git a/catalyst-gateway/rust-toolchain.toml b/catalyst-gateway/rust-toolchain.toml index 8209e4fd9a4..f175cc34180 100644 --- a/catalyst-gateway/rust-toolchain.toml +++ b/catalyst-gateway/rust-toolchain.toml @@ -1,5 +1,5 @@ [toolchain] -channel = "1.73.0" +channel = "1.75.0" profile = "default" components = [] -targets = ["x86_64-unknown-linux-musl"] +targets = ["x86_64-unknown-linux-musl"] \ No newline at end of file diff --git a/catalyst-gateway/tests/Cargo.toml b/catalyst-gateway/tests/Cargo.toml index f275f22358d..f77423ec690 100644 --- a/catalyst-gateway/tests/Cargo.toml +++ b/catalyst-gateway/tests/Cargo.toml @@ -1,12 +1,11 @@ [package] name = "tests" version = "0.1.0" -edition = "2021" +edition.workspace = true publish = false authors = [ "Stefano Cunego " ] -rust-version = "1.73" homepage = "https://input-output-hk.github.io/catalyst-voices" repository = "https://github.com/input-output-hk/catalyst-voices" license = "MIT OR Apache-2.0" @@ -18,4 +17,7 @@ unwrap = "1.2.1" [[test]] name = "integration" -path = "integration/main.rs" \ No newline at end of file +path = "integration/main.rs" + +[lints] +workspace = true \ No newline at end of file diff --git a/catalyst-gateway/tests/Earthfile b/catalyst-gateway/tests/Earthfile index fd2d89b845b..792110ce344 100644 --- a/catalyst-gateway/tests/Earthfile +++ b/catalyst-gateway/tests/Earthfile @@ -6,7 +6,7 @@ integration-test: FROM ../+builder DO github.com/earthly/lib:2.2.11+INSTALL_DIND - COPY ../+hosted-build/cat-gateway . + COPY ../+build/cat-gateway . COPY integration/docker-compose.yml . WITH DOCKER \ --compose docker-compose.yml \ diff --git a/catalyst-gateway/tests/integration/catalyst_gateway_event_db.rs b/catalyst-gateway/tests/integration/catalyst_gateway_event_db.rs index a0aba239d61..c7582fa3b20 100644 --- a/catalyst-gateway/tests/integration/catalyst_gateway_event_db.rs +++ b/catalyst-gateway/tests/integration/catalyst_gateway_event_db.rs @@ -1,15 +1,20 @@ // Integration test example // + +// TODO - move this integration test into other place, +// so it will not execute during common Rust test procedure. #[tokio::test] +#[ignore] async fn health_live() { let cat_gateway_address = "http://127.0.0.1:3030"; let client = reqwest::Client::new(); let url = format!("{cat_gateway_address}/api/health/live"); + let response = client + .get(&url) + .send() + .await + .expect("Failed to execute request to {url}."); - let response = unwrap!( - client.get(&url).send().await, - "Failed to execute request to {url}." - ); assert_eq!( response.status().as_u16(), 204, diff --git a/catalyst-gateway/tests/integration/main.rs b/catalyst-gateway/tests/integration/main.rs index e404b4899f9..e1c80eb2370 100644 --- a/catalyst-gateway/tests/integration/main.rs +++ b/catalyst-gateway/tests/integration/main.rs @@ -1,3 +1 @@ -#[macro_use] -extern crate unwrap; pub mod catalyst_gateway_event_db; diff --git a/docs/Earthfile b/docs/Earthfile index ef085413958..2aea2263b88 100644 --- a/docs/Earthfile +++ b/docs/Earthfile @@ -11,7 +11,7 @@ src: # Now copy into that any artifacts we pull from the builds. COPY --dir ../+repo-docs/repo /docs/includes # copy Rust docs - COPY ./../catalyst-gateway+hosted-build/doc /docs/src/api/cat-gateway/rust-docs + COPY ./../catalyst-gateway+build/doc /docs/src/api/cat-gateway/rust-docs # Copy docs we build in the postgres example. COPY --dir ../catalyst-gateway/event-db+build/docs src/architecture/08_concepts/event_db From 20745c91426bbdb8c5379d3e31ec627212dc0eb5 Mon Sep 17 00:00:00 2001 From: minikin Date: Tue, 30 Jan 2024 12:52:00 +0100 Subject: [PATCH 2/2] Update README.md --- catalyst_voices/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/catalyst_voices/README.md b/catalyst_voices/README.md index a6ad31ff352..39e4a61ad46 100644 --- a/catalyst_voices/README.md +++ b/catalyst_voices/README.md @@ -57,14 +57,14 @@ melos bootstrap ### Flavors -This project contains 3 flavors: +This project contains three flavors: * dev * qa * preprod * prod -To run the desired flavor either use the launch configuration in VSCode/Android Studio or use the following commands: +To run the desired flavor, either use the launch configuration in VSCode/Android Studio or use the following commands: ```sh # Development @@ -74,7 +74,7 @@ flutter run --flavor dev --target lib/configs/main_dev.dart flutter run --flavor qa --target lib/configs/main_qa.dart # Pre-Production -flutter run --flavor prod --target lib/configs/main_preprod.dart +flutter run --flavor preprod --target lib/configs/main_preprod.dart # Production flutter run --flavor prod --target lib/configs/main_prod.dart