diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index b55b7abe2888..f3ef0cdf4c4e 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,5 +1,5 @@ { - "image": "ghcr.io/dfinity/ic-build@sha256:cb3a6693a10777d16c301d98f5b67e23db405bf962d0eb8cec74082916c17bc7", + "image": "ghcr.io/dfinity/ic-build@sha256:685920086805a9354cfe8a0c582ed6b66b546966a9be1f5a054fe2cb14584b4c", "remoteUser": "ubuntu", "privileged": true, "runArgs": [ diff --git a/.github/workflows/ci-main.yml b/.github/workflows/ci-main.yml index 2bad12ab13e8..43ff265eb483 100644 --- a/.github/workflows/ci-main.yml +++ b/.github/workflows/ci-main.yml @@ -26,7 +26,7 @@ jobs: runs-on: &dind-large-setup labels: dind-large container: &container-setup - image: ghcr.io/dfinity/ic-build@sha256:cb3a6693a10777d16c301d98f5b67e23db405bf962d0eb8cec74082916c17bc7 + image: ghcr.io/dfinity/ic-build@sha256:685920086805a9354cfe8a0c582ed6b66b546966a9be1f5a054fe2cb14584b4c options: >- -e NODE_NAME --privileged --cgroupns host --mount type=tmpfs,target="/home/buildifier/.local/share/containers" timeout-minutes: 90 diff --git a/.github/workflows/ci-pr-only.yml b/.github/workflows/ci-pr-only.yml index 5032785cd5e8..7051fec45d2a 100644 --- a/.github/workflows/ci-pr-only.yml +++ b/.github/workflows/ci-pr-only.yml @@ -32,7 +32,7 @@ jobs: runs-on: &dind-small-setup labels: dind-small container: &container-setup - image: ghcr.io/dfinity/ic-build@sha256:cb3a6693a10777d16c301d98f5b67e23db405bf962d0eb8cec74082916c17bc7 + image: ghcr.io/dfinity/ic-build@sha256:685920086805a9354cfe8a0c582ed6b66b546966a9be1f5a054fe2cb14584b4c options: >- -e NODE_NAME --mount type=tmpfs,target="/home/buildifier/.local/share/containers" steps: diff --git a/.github/workflows/pocket-ic-tests-windows.yml b/.github/workflows/pocket-ic-tests-windows.yml index 8c497bdf514d..a26efcc49d05 100644 --- a/.github/workflows/pocket-ic-tests-windows.yml +++ b/.github/workflows/pocket-ic-tests-windows.yml @@ -45,7 +45,7 @@ jobs: bazel-build-pocket-ic: name: Bazel Build PocketIC container: - image: ghcr.io/dfinity/ic-build@sha256:cb3a6693a10777d16c301d98f5b67e23db405bf962d0eb8cec74082916c17bc7 + image: ghcr.io/dfinity/ic-build@sha256:685920086805a9354cfe8a0c582ed6b66b546966a9be1f5a054fe2cb14584b4c options: >- -e NODE_NAME --privileged --cgroupns host --mount type=tmpfs,target="/home/buildifier/.local/share/containers" timeout-minutes: 90 diff --git a/.github/workflows/rate-limits-backend-release.yml b/.github/workflows/rate-limits-backend-release.yml index c5317ad59b9a..8a2570853a1f 100644 --- a/.github/workflows/rate-limits-backend-release.yml +++ b/.github/workflows/rate-limits-backend-release.yml @@ -32,7 +32,7 @@ jobs: labels: dind-large container: - image: ghcr.io/dfinity/ic-build@sha256:cb3a6693a10777d16c301d98f5b67e23db405bf962d0eb8cec74082916c17bc7 + image: ghcr.io/dfinity/ic-build@sha256:685920086805a9354cfe8a0c582ed6b66b546966a9be1f5a054fe2cb14584b4c options: >- -e NODE_NAME --privileged --cgroupns host -v /var/tmp:/var/tmp -v /ceph-s3-info:/ceph-s3-info --mount type=tmpfs,target="/home/buildifier/.local/share/containers" diff --git a/.github/workflows/release-testing.yml b/.github/workflows/release-testing.yml index 465fb23dd708..207b28829dd6 100644 --- a/.github/workflows/release-testing.yml +++ b/.github/workflows/release-testing.yml @@ -32,7 +32,7 @@ jobs: runs-on: &dind-large-setup labels: dind-large container: &container-setup - image: ghcr.io/dfinity/ic-build@sha256:cb3a6693a10777d16c301d98f5b67e23db405bf962d0eb8cec74082916c17bc7 + image: ghcr.io/dfinity/ic-build@sha256:685920086805a9354cfe8a0c582ed6b66b546966a9be1f5a054fe2cb14584b4c options: >- -e NODE_NAME --privileged --cgroupns host --mount type=tmpfs,target="/home/buildifier/.local/share/containers" timeout-minutes: 180 diff --git a/.github/workflows/rosetta-release.yml b/.github/workflows/rosetta-release.yml index b8a7ac154ce2..852b336b6264 100644 --- a/.github/workflows/rosetta-release.yml +++ b/.github/workflows/rosetta-release.yml @@ -22,7 +22,7 @@ jobs: runs-on: labels: dind-large container: - image: ghcr.io/dfinity/ic-build@sha256:cb3a6693a10777d16c301d98f5b67e23db405bf962d0eb8cec74082916c17bc7 + image: ghcr.io/dfinity/ic-build@sha256:685920086805a9354cfe8a0c582ed6b66b546966a9be1f5a054fe2cb14584b4c options: >- -e NODE_NAME --privileged --cgroupns host --mount type=tmpfs,target="/home/buildifier/.local/share/containers" environment: DockerHub diff --git a/.github/workflows/salt-sharing-canister-release.yml b/.github/workflows/salt-sharing-canister-release.yml index bcca69e67cf7..2bcf2f4cf895 100644 --- a/.github/workflows/salt-sharing-canister-release.yml +++ b/.github/workflows/salt-sharing-canister-release.yml @@ -32,7 +32,7 @@ jobs: labels: dind-large container: - image: ghcr.io/dfinity/ic-build@sha256:cb3a6693a10777d16c301d98f5b67e23db405bf962d0eb8cec74082916c17bc7 + image: ghcr.io/dfinity/ic-build@sha256:685920086805a9354cfe8a0c582ed6b66b546966a9be1f5a054fe2cb14584b4c options: >- -e NODE_NAME --privileged --cgroupns host -v /var/tmp:/var/tmp -v /ceph-s3-info:/ceph-s3-info --mount type=tmpfs,target="/home/buildifier/.local/share/containers" diff --git a/.github/workflows/schedule-daily.yml b/.github/workflows/schedule-daily.yml index f5074f95e33a..e0ab6f0fb04c 100644 --- a/.github/workflows/schedule-daily.yml +++ b/.github/workflows/schedule-daily.yml @@ -20,7 +20,7 @@ jobs: runs-on: &dind-large-setup labels: dind-large container: &container-setup - image: ghcr.io/dfinity/ic-build@sha256:cb3a6693a10777d16c301d98f5b67e23db405bf962d0eb8cec74082916c17bc7 + image: ghcr.io/dfinity/ic-build@sha256:685920086805a9354cfe8a0c582ed6b66b546966a9be1f5a054fe2cb14584b4c options: >- -e NODE_NAME --privileged --cgroupns host --mount type=tmpfs,target="/home/buildifier/.local/share/containers" timeout-minutes: 720 # 12 hours diff --git a/.github/workflows/schedule-rust-bench.yml b/.github/workflows/schedule-rust-bench.yml index 21f90a6a6b49..2385f166ac78 100644 --- a/.github/workflows/schedule-rust-bench.yml +++ b/.github/workflows/schedule-rust-bench.yml @@ -24,7 +24,7 @@ jobs: # see linux-x86-64 runner group labels: rust-benchmarks container: - image: ghcr.io/dfinity/ic-build@sha256:cb3a6693a10777d16c301d98f5b67e23db405bf962d0eb8cec74082916c17bc7 + image: ghcr.io/dfinity/ic-build@sha256:685920086805a9354cfe8a0c582ed6b66b546966a9be1f5a054fe2cb14584b4c # running on bare metal machine using ubuntu user options: --user ubuntu --mount type=tmpfs,target="/home/ubuntu/.local/share/containers" timeout-minutes: 720 # 12 hours diff --git a/.github/workflows/schedule-weekly.yml b/.github/workflows/schedule-weekly.yml index 5fc4e369d9a0..f7ce7ae86911 100644 --- a/.github/workflows/schedule-weekly.yml +++ b/.github/workflows/schedule-weekly.yml @@ -10,7 +10,7 @@ jobs: runs-on: labels: dind-large container: - image: ghcr.io/dfinity/ic-build@sha256:cb3a6693a10777d16c301d98f5b67e23db405bf962d0eb8cec74082916c17bc7 + image: ghcr.io/dfinity/ic-build@sha256:685920086805a9354cfe8a0c582ed6b66b546966a9be1f5a054fe2cb14584b4c options: >- -e NODE_NAME --mount type=tmpfs,target="/home/buildifier/.local/share/containers" timeout-minutes: 60 # 1 hour diff --git a/.github/workflows/update-mainnet-canister-revisions.yaml b/.github/workflows/update-mainnet-canister-revisions.yaml index 338364e76006..41e976edf504 100644 --- a/.github/workflows/update-mainnet-canister-revisions.yaml +++ b/.github/workflows/update-mainnet-canister-revisions.yaml @@ -21,7 +21,7 @@ jobs: labels: dind-small environment: CREATE_PR container: - image: ghcr.io/dfinity/ic-build@sha256:cb3a6693a10777d16c301d98f5b67e23db405bf962d0eb8cec74082916c17bc7 + image: ghcr.io/dfinity/ic-build@sha256:685920086805a9354cfe8a0c582ed6b66b546966a9be1f5a054fe2cb14584b4c options: >- -e NODE_NAME --privileged --cgroupns host -v /var/tmp:/var/tmp -v /ceph-s3-info:/ceph-s3-info --mount type=tmpfs,target="/home/buildifier/.local/share/containers" env: diff --git a/Cargo.Bazel.json.lock b/Cargo.Bazel.json.lock index b1e916be3438..2c03235c1f3d 100644 --- a/Cargo.Bazel.json.lock +++ b/Cargo.Bazel.json.lock @@ -1,5 +1,5 @@ { - "checksum": "971e5d282607108262108ca673f422f2836eabfcb73687aedd1d7aeade59afa4", + "checksum": "b4acf73f327c9480df503755398c1f3e0270f16d50c7de7f3fa85d6a6b94a714", "crates": { "abnf 0.12.0": { "name": "abnf", @@ -21952,7 +21952,7 @@ "target": "num_bigint" }, { - "id": "num-bigint-dig 0.8.4", + "id": "num-bigint-dig 0.9.1", "target": "num_bigint_dig" }, { @@ -51506,12 +51506,9 @@ ], "crate_features": { "common": [ - "default", "i128", "prime", "rand", - "serde", - "std", "u64_digit", "zeroize" ], @@ -51551,10 +51548,6 @@ "id": "rand 0.8.5", "target": "rand" }, - { - "id": "serde 1.0.228", - "target": "serde" - }, { "id": "smallvec 1.15.1", "target": "smallvec" @@ -51587,6 +51580,120 @@ ], "license_file": "LICENSE-APACHE" }, + "num-bigint-dig 0.9.1": { + "name": "num-bigint-dig", + "version": "0.9.1", + "package_url": "https://github.com/dignifiedquire/num-bigint", + "repository": { + "Http": { + "url": "https://static.crates.io/crates/num-bigint-dig/0.9.1/download", + "sha256": "a7f9a86e097b0d187ad0e65667c2f58b9254671e86e7dbb78036b16692eae099" + } + }, + "targets": [ + { + "Library": { + "crate_name": "num_bigint_dig", + "crate_root": "src/lib.rs", + "srcs": { + "allow_empty": true, + "include": [ + "**/*.rs" + ] + } + } + }, + { + "BuildScript": { + "crate_name": "build_script_build", + "crate_root": "build.rs", + "srcs": { + "allow_empty": true, + "include": [ + "**/*.rs" + ] + } + } + } + ], + "library_target_name": "num_bigint_dig", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "crate_features": { + "common": [ + "default", + "prime", + "rand", + "serde", + "std", + "u64_digit" + ], + "selects": {} + }, + "deps": { + "common": [ + { + "id": "libm 0.2.15", + "target": "libm" + }, + { + "id": "num-bigint-dig 0.9.1", + "target": "build_script_build" + }, + { + "id": "num-integer 0.1.46", + "target": "num_integer" + }, + { + "id": "num-iter 0.1.45", + "target": "num_iter" + }, + { + "id": "num-traits 0.2.19", + "target": "num_traits" + }, + { + "id": "once_cell 1.21.3", + "target": "once_cell" + }, + { + "id": "rand 0.9.0", + "target": "rand" + }, + { + "id": "serde 1.0.228", + "target": "serde" + }, + { + "id": "smallvec 1.15.1", + "target": "smallvec" + } + ], + "selects": {} + }, + "edition": "2021", + "version": "0.9.1" + }, + "build_script_attrs": { + "compile_data_glob": [ + "**" + ], + "compile_data_glob_excludes": [ + "**/*.rs" + ], + "data_glob": [ + "**" + ] + }, + "license": "MIT/Apache-2.0", + "license_ids": [ + "Apache-2.0", + "MIT" + ], + "license_file": "LICENSE-APACHE" + }, "num-cmp 0.1.0": { "name": "num-cmp", "version": "0.1.0", @@ -97820,7 +97927,7 @@ "nftables 0.4.1", "nix 0.24.3", "num-bigint 0.4.6", - "num-bigint-dig 0.8.4", + "num-bigint-dig 0.9.1", "num-rational 0.2.4", "num-traits 0.2.19", "num_cpus 1.16.0", diff --git a/Cargo.Bazel.toml.lock b/Cargo.Bazel.toml.lock index b43ea32d5c63..87bfeb5dcb23 100644 --- a/Cargo.Bazel.toml.lock +++ b/Cargo.Bazel.toml.lock @@ -3777,7 +3777,7 @@ dependencies = [ "nftables", "nix 0.24.3", "num-bigint 0.4.6", - "num-bigint-dig", + "num-bigint-dig 0.9.1", "num-rational 0.2.4", "num-traits", "num_cpus", @@ -8844,11 +8844,26 @@ dependencies = [ "num-iter", "num-traits", "rand 0.8.5", - "serde", "smallvec", "zeroize", ] +[[package]] +name = "num-bigint-dig" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7f9a86e097b0d187ad0e65667c2f58b9254671e86e7dbb78036b16692eae099" +dependencies = [ + "libm", + "num-integer", + "num-iter", + "num-traits", + "once_cell", + "rand 0.9.0", + "serde", + "smallvec", +] + [[package]] name = "num-cmp" version = "0.1.0" @@ -11484,7 +11499,7 @@ checksum = "5d0e5124fcb30e76a7e79bfee683a2746db83784b86289f6251b54b7950a0dfc" dependencies = [ "const-oid", "digest 0.10.7", - "num-bigint-dig", + "num-bigint-dig 0.8.4", "num-integer", "num-traits", "pkcs1", diff --git a/Cargo.lock b/Cargo.lock index 74f5be52110c..e4c3c004584a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4812,7 +4812,7 @@ name = "fe-derive" version = "0.9.0" dependencies = [ "hex", - "num-bigint-dig", + "num-bigint-dig 0.9.1", "num-traits", "proc-macro2", "quote", @@ -18699,11 +18699,26 @@ dependencies = [ "num-iter", "num-traits", "rand 0.8.5", - "serde", "smallvec", "zeroize", ] +[[package]] +name = "num-bigint-dig" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7f9a86e097b0d187ad0e65667c2f58b9254671e86e7dbb78036b16692eae099" +dependencies = [ + "libm", + "num-integer", + "num-iter", + "num-traits", + "once_cell", + "rand 0.9.0", + "serde", + "smallvec", +] + [[package]] name = "num-cmp" version = "0.1.0" @@ -21820,7 +21835,7 @@ checksum = "47c75d7c5c6b673e58bf54d8544a9f432e3a925b0e80f7cd3602ab5c50c55519" dependencies = [ "const-oid", "digest 0.10.7", - "num-bigint-dig", + "num-bigint-dig 0.8.4", "num-integer", "num-traits", "pkcs1", diff --git a/bazel/rust.MODULE.bazel b/bazel/rust.MODULE.bazel index 11d26bed732f..f36f6492d9f4 100644 --- a/bazel/rust.MODULE.bazel +++ b/bazel/rust.MODULE.bazel @@ -2,23 +2,23 @@ # Run `./bin/bazel-pin.sh` from the top-level directory of the working tree after changing this file # to regenerate Cargo Bazel lockfiles. -bazel_dep(name = "rules_rust", version = "0.67.0") +bazel_dep(name = "rules_rust", version = "0.68.1") archive_override( module_name = "rules_rust", - integrity = "sha256-3Ch+PsqAsp1cyV4mHK4nPu3xr0oAqWrpN+I0U02tskw=", + integrity = "sha256-yKqAbPYGZnmsI0YyQe6ArWkiZdrQRl9RERy74wuJA1I=", patch_strip = 1, patches = [ "//bazel:rules_rust_strip_level.patch", "//bazel:rules_rust_package_alias.patch", "//bazel:rules_rust_rust_test.patch", ], - urls = ["https://github.com/bazelbuild/rules_rust/releases/download/0.67.0/rules_rust-0.67.0.tar.gz"], + urls = ["https://github.com/bazelbuild/rules_rust/releases/download/0.68.1/rules_rust-0.68.1.tar.gz"], ) rust = use_extension("@rules_rust//rust:extensions.bzl", "rust") rust.toolchain( edition = "2024", - versions = ["1.90.0"], + versions = ["1.91.1"], ) # Repin with `CARGO_BAZEL_REPIN=true bazel build @crate_index//...` @@ -991,7 +991,7 @@ crate.spec( crate.spec( features = ["prime"], package = "num-bigint-dig", - version = "^0.8", + version = "^0.9", ) crate.spec( package = "num-rational", diff --git a/ci/container/TAG b/ci/container/TAG index d2da3fdf2103..1189c0a741a5 100644 --- a/ci/container/TAG +++ b/ci/container/TAG @@ -1 +1 @@ -d88b0bd827eb97cc1638efdb41846c3dbdcad4eca43891216fef16dc72d07092 +9c3e262973508c067ce10e21b61b18876114d1278f1edc456d604df73156582e diff --git a/rs/consensus/idkg/src/signer.rs b/rs/consensus/idkg/src/signer.rs index 8f4ddadf75dd..6541b71ab5bc 100644 --- a/rs/consensus/idkg/src/signer.rs +++ b/rs/consensus/idkg/src/signer.rs @@ -1031,7 +1031,7 @@ mod tests { // Set up the IDKG pool. Pool has shares for requests 0, 1, 2. // Only the share for request 0 is issued by us - let shares = vec![ + let shares = [ create_signature_share(&key_id, NODE_1, ids[0]), create_signature_share(&key_id, NODE_2, ids[1]), create_signature_share(&key_id, NODE_3, ids[2]), diff --git a/rs/consensus/src/consensus/batch_delivery.rs b/rs/consensus/src/consensus/batch_delivery.rs index 2735148761b2..dd1ab0e79268 100644 --- a/rs/consensus/src/consensus/batch_delivery.rs +++ b/rs/consensus/src/consensus/batch_delivery.rs @@ -570,7 +570,7 @@ mod tests { const TARGET_ID: NiDkgTargetId = NiDkgTargetId::new([8; 32]); // Build some transcipts with matching ids and tags - let transcripts_for_remote_subnets = vec![ + let transcripts_for_remote_subnets = [ ( NiDkgId { start_block_height: Height::from(0), @@ -624,7 +624,7 @@ mod tests { }); // Build some transcipts with matching ids and tags - let transcripts_for_remote_subnets = vec![( + let transcripts_for_remote_subnets = [( NiDkgId { start_block_height: Height::from(0), dealer_subnet: subnet_test_id(0), diff --git a/rs/criterion_time/src/lib.rs b/rs/criterion_time/src/lib.rs index 08cebe2de948..93120ad5ecd4 100644 --- a/rs/criterion_time/src/lib.rs +++ b/rs/criterion_time/src/lib.rs @@ -16,19 +16,15 @@ use std::time::Duration; /// by the background load. /// /// This implementation uses getrusage system call to obtain the timings. +#[derive(Default)] pub enum ProcessTime { /// User time used by this process. UserTime, /// User + System time used by this process. + #[default] UserAndSystemTime, } -impl Default for ProcessTime { - fn default() -> Self { - Self::UserAndSystemTime - } -} - impl ProcessTime { fn now(&self) -> Duration { let usage = resource_usage(); diff --git a/rs/crypto/internal/crypto_lib/threshold_sig/canister_threshold_sig/fe-derive/Cargo.toml b/rs/crypto/internal/crypto_lib/threshold_sig/canister_threshold_sig/fe-derive/Cargo.toml index 1edbc16e4c33..5b1bc227167c 100644 --- a/rs/crypto/internal/crypto_lib/threshold_sig/canister_threshold_sig/fe-derive/Cargo.toml +++ b/rs/crypto/internal/crypto_lib/threshold_sig/canister_threshold_sig/fe-derive/Cargo.toml @@ -11,7 +11,7 @@ proc-macro = true [dependencies] hex = { workspace = true } -num-bigint-dig = { version = "0.8", features = ["prime"] } +num-bigint-dig = { version = "0.9", features = ["prime"] } num-traits = { workspace = true } proc-macro2 = { workspace = true } quote = { workspace = true } diff --git a/rs/crypto/internal/crypto_lib/threshold_sig/canister_threshold_sig/src/utils/group.rs b/rs/crypto/internal/crypto_lib/threshold_sig/canister_threshold_sig/src/utils/group.rs index 6fa28755b740..84f61669a792 100644 --- a/rs/crypto/internal/crypto_lib/threshold_sig/canister_threshold_sig/src/utils/group.rs +++ b/rs/crypto/internal/crypto_lib/threshold_sig/canister_threshold_sig/src/utils/group.rs @@ -850,7 +850,7 @@ impl EccPoint { /// and performs one step for the scalar-point multiplication. /// This function must be called as many times as the length of /// the NAF representation of the scalar. - /// + /// /// Warning: this function leaks information about the scalars via /// side channels. Do not use this function with secret scalars. fn scalar_mul_step_vartime( @@ -1060,6 +1060,7 @@ impl EccPoint { let mut buckets: Vec = (0..Window::MAX).map(|_| id.clone()).collect(); + #[allow(clippy::needless_range_loop)] for i in 0..num_windows { for j in 0..point_scalar_pairs.len() { let bucket_index = windows[j][i] as usize; diff --git a/rs/crypto/internal/crypto_service_provider/src/vault/api/tests.rs b/rs/crypto/internal/crypto_service_provider/src/vault/api/tests.rs index 797d8fc81011..249c11485022 100644 --- a/rs/crypto/internal/crypto_service_provider/src/vault/api/tests.rs +++ b/rs/crypto/internal/crypto_service_provider/src/vault/api/tests.rs @@ -667,7 +667,7 @@ mod node_keys_errors_to_key_counts_conversions { #[test] fn should_collect_key_counts_for_single_external_malformed_key() { - let tests = vec![ + let tests = [ ParameterizedTest { input: NodeKeysErrors { node_signing_key_error: Some(NodeKeysError { diff --git a/rs/ethereum/cketh/minter/src/dashboard/tests.rs b/rs/ethereum/cketh/minter/src/dashboard/tests.rs index 667a74d2bd3f..94bd892e5239 100644 --- a/rs/ethereum/cketh/minter/src/dashboard/tests.rs +++ b/rs/ethereum/cketh/minter/src/dashboard/tests.rs @@ -510,7 +510,7 @@ fn should_display_pending_transactions_sorted_by_decreasing_cketh_ledger_burn_in let dashboard = { let mut state = initial_state_with_usdc_support(); - for (req, tx, _signed_tx, _receipt) in vec![ + for (req, tx, _signed_tx, _receipt) in [ cketh_withdrawal_flow( LedgerBurnIndex::new(15), TransactionNonce::from(0_u8), @@ -536,7 +536,7 @@ fn should_display_pending_transactions_sorted_by_decreasing_cketh_ledger_burn_in ); } - for (req, tx, signed_tx, _receipt) in vec![ + for (req, tx, signed_tx, _receipt) in [ cketh_withdrawal_flow( LedgerBurnIndex::new(17), TransactionNonce::from(2_u8), @@ -645,7 +645,7 @@ fn should_display_finalized_transactions_sorted_by_decreasing_cketh_ledger_burn_ mint_block_index: LedgerMintIndex::new(43), }, ); - for (req, tx, signed_tx, receipt) in vec![ + for (req, tx, signed_tx, receipt) in [ cketh_withdrawal_flow( LedgerBurnIndex::new(15), TransactionNonce::from(0_u8), @@ -785,7 +785,7 @@ fn should_display_reimbursed_requests() { }, ); - for ((req, tx, signed_tx, receipt), is_reimbursed) in vec![ + for ((req, tx, signed_tx, receipt), is_reimbursed) in [ ( cketh_withdrawal_flow( LedgerBurnIndex::new(15), diff --git a/rs/ethereum/cketh/minter/src/state/transactions/tests.rs b/rs/ethereum/cketh/minter/src/state/transactions/tests.rs index 195fe1c90624..dd1f350d9058 100644 --- a/rs/ethereum/cketh/minter/src/state/transactions/tests.rs +++ b/rs/ethereum/cketh/minter/src/state/transactions/tests.rs @@ -1443,7 +1443,7 @@ mod eth_transactions { &mut transactions, sent_tx_0_0.transaction().clone(), ); - let hashes_0: BTreeMap<_, _> = vec![sent_tx_0_0, sent_tx_0_1] + let hashes_0: BTreeMap<_, _> = [sent_tx_0_0, sent_tx_0_1] .iter() .map(|tx| (tx.hash(), first_cketh_ledger_burn_index)) .collect(); @@ -1458,7 +1458,7 @@ mod eth_transactions { &mut transactions, sent_tx_1_1.transaction().clone(), ); - let hashes_1: BTreeMap<_, _> = vec![sent_tx_1_0, sent_tx_1_1, sent_tx_1_2] + let hashes_1: BTreeMap<_, _> = [sent_tx_1_0, sent_tx_1_1, sent_tx_1_2] .iter() .map(|tx| (tx.hash(), second_cketh_ledger_burn_index)) .collect(); diff --git a/rs/ethereum/cketh/minter/tests/ckerc20.rs b/rs/ethereum/cketh/minter/tests/ckerc20.rs index 2f1a1f217a85..ad5a39a3eb39 100644 --- a/rs/ethereum/cketh/minter/tests/ckerc20.rs +++ b/rs/ethereum/cketh/minter/tests/ckerc20.rs @@ -80,14 +80,14 @@ fn should_add_ckusdc_and_ckusdt_to_minter_via_orchestrator() { .ledger .unwrap(); - ckerc20 = ckerc20 - .check_events() - .assert_has_unique_events_in_order(&vec![EventPayload::AddedCkErc20Token { + ckerc20 = ckerc20.check_events().assert_has_unique_events_in_order(&[ + EventPayload::AddedCkErc20Token { chain_id: token.contract.chain_id, address: format_ethereum_address_to_eip_55(&token.contract.address), ckerc20_token_symbol: token.ledger_init_arg.token_symbol, ckerc20_ledger_id: new_ledger_id, - }]); + }, + ]); } } @@ -128,7 +128,7 @@ fn should_retry_to_add_usdc_when_minter_stopped() { ckerc20 .cketh - .assert_has_unique_events_in_order(&vec![EventPayload::AddedCkErc20Token { + .assert_has_unique_events_in_order(&[EventPayload::AddedCkErc20Token { chain_id: usdc.contract.chain_id, address: format_ethereum_address_to_eip_55(&usdc.contract.address), ckerc20_token_symbol: usdc.ledger_init_arg.token_symbol, @@ -449,16 +449,14 @@ mod withdraw_erc20 { balance_before_withdrawal - Nat::from(transaction_fee), ); let reimbursed_amount = Nat::from(transaction_fee - CKETH_TRANSFER_FEE); - ckerc20 = ckerc20 - .check_events() - .assert_has_unique_events_in_order(&vec![ - EventPayload::FailedErc20WithdrawalRequest { - withdrawal_id: cketh_burn_index.into(), - reimbursed_amount: reimbursed_amount.clone(), - to: caller, - to_subaccount: None, - }, - ]); + ckerc20 = ckerc20.check_events().assert_has_unique_events_in_order(&[ + EventPayload::FailedErc20WithdrawalRequest { + withdrawal_id: cketh_burn_index.into(), + reimbursed_amount: reimbursed_amount.clone(), + to: caller, + to_subaccount: None, + }, + ]); ckerc20.env.advance_time(PROCESS_REIMBURSEMENT); ckerc20.env.tick(); @@ -469,7 +467,7 @@ mod withdraw_erc20 { ); ckerc20 .check_events() - .assert_has_unique_events_in_order(&vec![EventPayload::ReimbursedEthWithdrawal { + .assert_has_unique_events_in_order(&[EventPayload::ReimbursedEthWithdrawal { withdrawal_id: cketh_burn_index.into(), reimbursed_in_block: Nat::from(cketh_burn_index) + 1_u8, reimbursed_amount: reimbursed_amount.clone(), @@ -775,60 +773,54 @@ mod withdraw_erc20 { let estimated_max_fee_per_gas = Nat::from(33_003_708_258_u64); let estimated_gas_limit = Nat::from(65_000_u64); - let ckerc20 = ckerc20 - .check_events() - .assert_has_unique_events_in_order(&vec![ - EventPayload::AcceptedErc20WithdrawalRequest { - max_transaction_fee: ckerc20_tx_fee.into(), - withdrawal_amount: ckerc20_withdrawal_amount.into(), - erc20_contract_address: deposit_params - .token() - .erc20_contract_address - .clone(), - destination: DEFAULT_ERC20_WITHDRAWAL_DESTINATION_ADDRESS.to_string(), - cketh_ledger_burn_index: cketh_block_index.clone(), - ckerc20_ledger_id: deposit_params.token().ledger_canister_id, - ckerc20_ledger_burn_index: ckerc20_block_index.clone(), - from: ckerc20_account.owner, - from_subaccount: ckerc20_account.subaccount, - created_at: time, - }, - EventPayload::CreatedTransaction { - withdrawal_id: cketh_block_index.clone(), - transaction: UnsignedTransaction { - chain_id: Nat::from(1_u8), - nonce: Nat::from(0_u8), - max_priority_fee_per_gas: 1_500_000_000_u64.into(), - max_fee_per_gas: estimated_max_fee_per_gas.clone(), - gas_limit: estimated_gas_limit.clone(), - destination: deposit_params.token().erc20_contract_address.clone(), - value: 0_u8.into(), - data: ByteBuf::from(erc20_transfer_data( - &DEFAULT_ERC20_WITHDRAWAL_DESTINATION_ADDRESS - .parse() - .unwrap(), - &ckerc20_withdrawal_amount.into(), - )), - access_list: vec![], - }, - }, - EventPayload::SignedTransaction { - withdrawal_id: cketh_block_index.clone(), - raw_transaction: DEFAULT_CKERC20_WITHDRAWAL_TRANSACTION.to_string(), + let ckerc20 = ckerc20.check_events().assert_has_unique_events_in_order(&[ + EventPayload::AcceptedErc20WithdrawalRequest { + max_transaction_fee: ckerc20_tx_fee.into(), + withdrawal_amount: ckerc20_withdrawal_amount.into(), + erc20_contract_address: deposit_params.token().erc20_contract_address.clone(), + destination: DEFAULT_ERC20_WITHDRAWAL_DESTINATION_ADDRESS.to_string(), + cketh_ledger_burn_index: cketh_block_index.clone(), + ckerc20_ledger_id: deposit_params.token().ledger_canister_id, + ckerc20_ledger_burn_index: ckerc20_block_index.clone(), + from: ckerc20_account.owner, + from_subaccount: ckerc20_account.subaccount, + created_at: time, + }, + EventPayload::CreatedTransaction { + withdrawal_id: cketh_block_index.clone(), + transaction: UnsignedTransaction { + chain_id: Nat::from(1_u8), + nonce: Nat::from(0_u8), + max_priority_fee_per_gas: 1_500_000_000_u64.into(), + max_fee_per_gas: estimated_max_fee_per_gas.clone(), + gas_limit: estimated_gas_limit.clone(), + destination: deposit_params.token().erc20_contract_address.clone(), + value: 0_u8.into(), + data: ByteBuf::from(erc20_transfer_data( + &DEFAULT_ERC20_WITHDRAWAL_DESTINATION_ADDRESS + .parse() + .unwrap(), + &ckerc20_withdrawal_amount.into(), + )), + access_list: vec![], }, - EventPayload::FinalizedTransaction { - withdrawal_id: cketh_block_index.clone(), - transaction_receipt: TransactionReceipt { - block_hash: DEFAULT_BLOCK_HASH.to_string(), - block_number: Nat::from(DEFAULT_BLOCK_NUMBER), - effective_gas_price: Nat::from(4_277_923_390_u64), - gas_used: Nat::from(21_000_u64), - status: transaction_status.clone(), - transaction_hash: DEFAULT_CKERC20_WITHDRAWAL_TRANSACTION_HASH - .to_string(), - }, + }, + EventPayload::SignedTransaction { + withdrawal_id: cketh_block_index.clone(), + raw_transaction: DEFAULT_CKERC20_WITHDRAWAL_TRANSACTION.to_string(), + }, + EventPayload::FinalizedTransaction { + withdrawal_id: cketh_block_index.clone(), + transaction_receipt: TransactionReceipt { + block_hash: DEFAULT_BLOCK_HASH.to_string(), + block_number: Nat::from(DEFAULT_BLOCK_NUMBER), + effective_gas_price: Nat::from(4_277_923_390_u64), + gas_used: Nat::from(21_000_u64), + status: transaction_status.clone(), + transaction_hash: DEFAULT_CKERC20_WITHDRAWAL_TRANSACTION_HASH.to_string(), }, - ]); + }, + ]); ckerc20.env.advance_time(PROCESS_REIMBURSEMENT); let cketh_balance_after_reimbursement = ckerc20.wait_for_updated_ledger_balance( @@ -853,18 +845,16 @@ mod withdraw_erc20 { ); ckerc20 .check_events() - .assert_has_unique_events_in_order(&vec![ - EventPayload::ReimbursedErc20Withdrawal { - withdrawal_id: cketh_block_index.clone(), - burn_in_block: ckerc20_block_index.clone(), - reimbursed_in_block: Nat::from(3_u8), - ledger_id: deposit_params.token().ledger_canister_id, - reimbursed_amount: ckerc20_withdrawal_amount.into(), - transaction_hash: Some( - DEFAULT_CKERC20_WITHDRAWAL_TRANSACTION_HASH.to_string(), - ), - }, - ]) + .assert_has_unique_events_in_order(&[EventPayload::ReimbursedErc20Withdrawal { + withdrawal_id: cketh_block_index.clone(), + burn_in_block: ckerc20_block_index.clone(), + reimbursed_in_block: Nat::from(3_u8), + ledger_id: deposit_params.token().ledger_canister_id, + reimbursed_amount: ckerc20_withdrawal_amount.into(), + transaction_hash: Some( + DEFAULT_CKERC20_WITHDRAWAL_TRANSACTION_HASH.to_string(), + ), + }]) .call_ckerc20_ledger_get_transaction( deposit_params.token().ledger_canister_id, 3_u8, @@ -1149,7 +1139,7 @@ mod withdraw_erc20 { resubmitted_tx_sig, ) .check_events() - .assert_has_unique_events_in_order(&vec![ + .assert_has_unique_events_in_order(&[ EventPayload::ReplacedTransaction { withdrawal_id: cketh_block_index.clone(), transaction: UnsignedTransaction { @@ -1503,7 +1493,7 @@ fn should_deposit_cketh_and_ckerc20_when_ledger_temporary_offline() { let ckerc20 = deposit_flow .setup .check_events() - .assert_has_unique_events_in_order(&vec![ + .assert_has_unique_events_in_order(&[ EventPayload::AcceptedDeposit { transaction_hash: DEFAULT_DEPOSIT_TRANSACTION_HASH.to_string(), block_number: Nat::from(DEFAULT_DEPOSIT_BLOCK_NUMBER), @@ -1543,26 +1533,24 @@ fn should_deposit_cketh_and_ckerc20_when_ledger_temporary_offline() { ckerc20.env.advance_time(MINT_RETRY_DELAY); ckerc20.env.tick(); - let ckerc20 = ckerc20 - .check_events() - .assert_has_unique_events_in_order(&vec![ - EventPayload::MintedCkEth { - event_source: EventSource { - transaction_hash: DEFAULT_DEPOSIT_TRANSACTION_HASH.to_string(), - log_index: Nat::from(DEFAULT_DEPOSIT_LOG_INDEX), - }, - mint_block_index: Nat::from(0_u8), + let ckerc20 = ckerc20.check_events().assert_has_unique_events_in_order(&[ + EventPayload::MintedCkEth { + event_source: EventSource { + transaction_hash: DEFAULT_DEPOSIT_TRANSACTION_HASH.to_string(), + log_index: Nat::from(DEFAULT_DEPOSIT_LOG_INDEX), }, - EventPayload::MintedCkErc20 { - event_source: EventSource { - transaction_hash: DEFAULT_ERC20_DEPOSIT_TRANSACTION_HASH.to_string(), - log_index: Nat::from(DEFAULT_ERC20_DEPOSIT_LOG_INDEX), - }, - ckerc20_token_symbol: ckusdc.ckerc20_token_symbol, - erc20_contract_address: ckusdc.erc20_contract_address, - mint_block_index: Nat::from(0_u8), + mint_block_index: Nat::from(0_u8), + }, + EventPayload::MintedCkErc20 { + event_source: EventSource { + transaction_hash: DEFAULT_ERC20_DEPOSIT_TRANSACTION_HASH.to_string(), + log_index: Nat::from(DEFAULT_ERC20_DEPOSIT_LOG_INDEX), }, - ]); + ckerc20_token_symbol: ckusdc.ckerc20_token_symbol, + erc20_contract_address: ckusdc.erc20_contract_address, + mint_block_index: Nat::from(0_u8), + }, + ]); assert_eq!( call_ledger_icrc1_total_supply(&ckerc20.env, ckerc20.cketh.ledger_id,), @@ -1590,7 +1578,7 @@ fn should_block_deposit_from_blocked_address() { }) .expect_no_mint() .check_events() - .assert_has_unique_events_in_order(&vec![EventPayload::InvalidDeposit { + .assert_has_unique_events_in_order(&[EventPayload::InvalidDeposit { event_source: EventSource { transaction_hash: DEFAULT_ERC20_DEPOSIT_TRANSACTION_HASH.to_string(), log_index: Nat::from(DEFAULT_ERC20_DEPOSIT_LOG_INDEX), @@ -1613,7 +1601,7 @@ fn should_block_deposit_from_corrupted_principal() { }) .expect_no_mint() .check_events() - .assert_has_unique_events_in_order(&vec![EventPayload::InvalidDeposit { + .assert_has_unique_events_in_order(&[EventPayload::InvalidDeposit { event_source: EventSource { transaction_hash: DEFAULT_ERC20_DEPOSIT_TRANSACTION_HASH.to_string(), log_index: Nat::from(DEFAULT_ERC20_DEPOSIT_LOG_INDEX), @@ -1823,16 +1811,14 @@ fn should_scrape_from_last_scraped_after_upgrade() { ckerc20 .cketh .check_audit_logs_and_upgrade_as_ref(Default::default()); - ckerc20 = ckerc20 - .check_events() - .assert_has_unique_events_in_order(&vec![ - EventPayload::SyncedToBlock { - block_number: latest_finalized_block.into(), - }, - EventPayload::SyncedErc20ToBlock { - block_number: latest_finalized_block.into(), - }, - ]); + ckerc20 = ckerc20.check_events().assert_has_unique_events_in_order(&[ + EventPayload::SyncedToBlock { + block_number: latest_finalized_block.into(), + }, + EventPayload::SyncedErc20ToBlock { + block_number: latest_finalized_block.into(), + }, + ]); // Advance block height and scrape again let latest_finalized_block = @@ -2044,7 +2030,7 @@ fn should_skip_single_block_containing_too_many_events() { } => address.to_lowercase() == ETH_HELPER_CONTRACT_ADDRESS, _ => false, }) - .assert_has_unique_events_in_order(&vec![ + .assert_has_unique_events_in_order(&[ EventPayload::SkippedBlock { contract_address: Some( ERC20_HELPER_CONTRACT_ADDRESS diff --git a/rs/ethereum/cketh/minter/tests/cketh.rs b/rs/ethereum/cketh/minter/tests/cketh.rs index b19ea1e99744..8d487b82cceb 100644 --- a/rs/ethereum/cketh/minter/tests/cketh.rs +++ b/rs/ethereum/cketh/minter/tests/cketh.rs @@ -130,7 +130,7 @@ fn should_deposit_and_withdraw() { }); assert_eq!(cketh.balance_of(account), Nat::from(0_u8)); - cketh.assert_has_unique_events_in_order(&vec![ + cketh.assert_has_unique_events_in_order(&[ EventPayload::AcceptedEthWithdrawalRequest { withdrawal_amount: withdrawal_amount.clone(), destination: destination.clone(), @@ -227,7 +227,7 @@ fn should_block_deposit_from_blocked_address() { ..Default::default() }) .expect_no_mint() - .assert_has_unique_events_in_order(&vec![EventPayload::InvalidDeposit { + .assert_has_unique_events_in_order(&[EventPayload::InvalidDeposit { event_source: EventSource { transaction_hash: DEFAULT_DEPOSIT_TRANSACTION_HASH.to_string(), log_index: Nat::from(DEFAULT_DEPOSIT_LOG_INDEX), @@ -550,7 +550,7 @@ fn should_reimburse() { created_at_time: None, fee: None, }) - .assert_has_unique_events_in_order(&vec![ + .assert_has_unique_events_in_order(&[ EventPayload::AcceptedEthWithdrawalRequest { withdrawal_amount: withdrawal_amount.clone(), destination: destination.clone(), @@ -664,7 +664,7 @@ fn should_resubmit_new_transaction_when_price_increased() { resubmitted_tx.clone(), resubmitted_tx_sig, ) - .assert_has_unique_events_in_order(&vec![ + .assert_has_unique_events_in_order(&[ EventPayload::ReplacedTransaction { withdrawal_id: withdrawal_id.clone(), transaction: UnsignedTransaction { @@ -744,7 +744,7 @@ fn should_not_overlap_when_scrapping_logs() { cketh .check_audit_logs_and_upgrade(Default::default()) - .assert_has_unique_events_in_order(&vec![EventPayload::SyncedToBlock { + .assert_has_unique_events_in_order(&[EventPayload::SyncedToBlock { block_number: second_to_block.into(), }]); } @@ -780,7 +780,7 @@ fn should_retry_from_same_block_when_scrapping_fails() { .check_audit_logs_and_upgrade(Default::default()) .check_events() .skip(prev_events_len) - .assert_has_unique_events_in_order(&vec![EventPayload::SyncedToBlock { + .assert_has_unique_events_in_order(&[EventPayload::SyncedToBlock { block_number: LAST_SCRAPED_BLOCK_NUMBER_AT_INSTALL.into(), }]); @@ -802,7 +802,7 @@ fn should_retry_from_same_block_when_scrapping_fails() { cketh .check_audit_logs_and_upgrade(Default::default()) - .assert_has_unique_events_in_order(&vec![EventPayload::SyncedToBlock { + .assert_has_unique_events_in_order(&[EventPayload::SyncedToBlock { block_number: Nat::from(to_block), }]); } @@ -970,7 +970,7 @@ fn should_panic_when_last_finalized_block_in_the_past() { .check_audit_logs_and_upgrade(Default::default()) .check_events() .skip(prev_events_len) - .assert_has_unique_events_in_order(&vec![EventPayload::SyncedToBlock { + .assert_has_unique_events_in_order(&[EventPayload::SyncedToBlock { block_number: LAST_SCRAPED_BLOCK_NUMBER_AT_INSTALL.into(), }]); @@ -996,7 +996,7 @@ fn should_panic_when_last_finalized_block_in_the_past() { cketh .check_audit_logs_and_upgrade(Default::default()) - .assert_has_unique_events_in_order(&vec![EventPayload::SyncedToBlock { + .assert_has_unique_events_in_order(&[EventPayload::SyncedToBlock { block_number: last_finalized_block.into(), }]); } @@ -1033,7 +1033,7 @@ fn should_skip_scrapping_when_last_seen_block_newer_than_current_height() { ethereum_block_height: Some(CandidBlockTag::Finalized), ..Default::default() }) - .assert_has_unique_events_in_order(&vec![EventPayload::SyncedToBlock { + .assert_has_unique_events_in_order(&[EventPayload::SyncedToBlock { block_number: safe_block_number.into(), }]); cketh.env.tick(); @@ -1105,7 +1105,7 @@ fn should_half_range_of_scrapped_logs_when_response_over_two_mega_bytes() { cketh .check_audit_logs_and_upgrade(Default::default()) - .assert_has_unique_events_in_order(&vec![EventPayload::SyncedToBlock { + .assert_has_unique_events_in_order(&[EventPayload::SyncedToBlock { block_number: half_to_block.into(), }]) .assert_has_no_event_satisfying(|event| matches!(event, EventPayload::SkippedBlock { .. })); @@ -1182,7 +1182,7 @@ fn should_skip_single_block_containing_too_many_events() { cketh .check_audit_logs_and_upgrade(Default::default()) - .assert_has_unique_events_in_order(&vec![ + .assert_has_unique_events_in_order(&[ EventPayload::SkippedBlock { contract_address: Some( ETH_HELPER_CONTRACT_ADDRESS diff --git a/rs/ethereum/cketh/test_utils/src/ckerc20.rs b/rs/ethereum/cketh/test_utils/src/ckerc20.rs index fb9dc7b4adcd..023674311327 100644 --- a/rs/ethereum/cketh/test_utils/src/ckerc20.rs +++ b/rs/ethereum/cketh/test_utils/src/ckerc20.rs @@ -117,14 +117,14 @@ impl CkErc20Setup { .ledger .unwrap(); - self.cketh = self.cketh.assert_has_unique_events_in_order(&vec![ - EventPayload::AddedCkErc20Token { - chain_id: token.contract.chain_id.clone(), - address: format_ethereum_address_to_eip_55(&token.contract.address), - ckerc20_token_symbol: token.ledger_init_arg.token_symbol.clone(), - ckerc20_ledger_id: new_ledger_id, - }, - ]); + self.cketh = + self.cketh + .assert_has_unique_events_in_order(&[EventPayload::AddedCkErc20Token { + chain_id: token.contract.chain_id.clone(), + address: format_ethereum_address_to_eip_55(&token.contract.address), + ckerc20_token_symbol: token.ledger_init_arg.token_symbol.clone(), + ckerc20_ledger_id: new_ledger_id, + }]); } self } @@ -713,7 +713,7 @@ impl CkErc20DepositFlow { if let Some(deposit) = self.params.cketh_deposit() { let eth_tx_data = deposit.transaction_data(); - self.setup.cketh = self.setup.cketh.assert_has_unique_events_in_order(&vec![ + self.setup.cketh = self.setup.cketh.assert_has_unique_events_in_order(&[ EventPayload::AcceptedDeposit { transaction_hash: eth_tx_data.transaction_hash.to_string(), block_number: Nat::from(eth_tx_data.block_number), @@ -734,7 +734,7 @@ impl CkErc20DepositFlow { } let erc20_tx_data = self.params.transaction_data(); - self.setup.cketh = self.setup.cketh.assert_has_unique_events_in_order(&vec![ + self.setup.cketh = self.setup.cketh.assert_has_unique_events_in_order(&[ EventPayload::AcceptedErc20Deposit { transaction_hash: erc20_tx_data.transaction_hash.to_string(), block_number: Nat::from(erc20_tx_data.block_number), diff --git a/rs/ethereum/ledger-suite-orchestrator/BUILD.bazel b/rs/ethereum/ledger-suite-orchestrator/BUILD.bazel index b66d0c055d10..1395e61ecf8d 100644 --- a/rs/ethereum/ledger-suite-orchestrator/BUILD.bazel +++ b/rs/ethereum/ledger-suite-orchestrator/BUILD.bazel @@ -1,3 +1,4 @@ +load("@rules_rust//cargo:defs.bzl", "cargo_build_script") load("@rules_rust//rust:defs.bzl", "rust_doc", "rust_library", "rust_test") load("//bazel:canisters.bzl", "rust_canister") load("//bazel:defs.bzl", "rust_ic_test") @@ -100,6 +101,15 @@ rust_test( ], ) +cargo_build_script( + name = "build_script", + srcs = ["build.rs"], + build_script_env = { + "IN_BAZEL": "1", + }, + data = ["templates/dashboard.html"], +) + [ rust_canister( name = "ledger_suite_orchestrator_canister" + name_suffix, @@ -109,9 +119,6 @@ rust_test( "src/dashboard/tests.rs", "src/main.rs", ], - compile_data = [ - "templates/dashboard.html", - ], crate_name = "ic_ledger_suite_orchestrator_canister" + name_suffix, opt = "z", proc_macro_deps = [ @@ -120,6 +127,7 @@ rust_test( service_file = "ledger_suite_orchestrator.did", deps = [ # Keep sorted. + ":build_script", ":ledger_suite_orchestrator" + name_suffix, "//packages/ic-http-types", "@crate_index//:askama", diff --git a/rs/ethereum/ledger-suite-orchestrator/build.rs b/rs/ethereum/ledger-suite-orchestrator/build.rs index f446128ee398..34ce411269bc 100644 --- a/rs/ethereum/ledger-suite-orchestrator/build.rs +++ b/rs/ethereum/ledger-suite-orchestrator/build.rs @@ -1,29 +1,68 @@ use std::env::{self}; +use std::fs::File; +use std::io::Write; use std::path::PathBuf; fn main() { - let cargo_manifest_dir = PathBuf::from(env::var_os("CARGO_MANIFEST_DIR").unwrap()); - let compile_time_env_variables = [ - "LEDGER_CANISTER_WASM_PATH", - "INDEX_CANISTER_WASM_PATH", - "LEDGER_ARCHIVE_NODE_CANISTER_WASM_PATH", - ]; - for env_var in compile_time_env_variables { - let archive_path = match env::var_os(env_var) { - Some(wasm_path) => PathBuf::from(wasm_path), - None => cargo_manifest_dir - // This is a hack. - // Cargo is called on CI via ci/src/rust_lint/lint.sh. - // The included WASMS binary for ledger, index and archive canisters are built by BAZEL tasks - // which would need here to be somehow spawned by Cargo. To avoid this, we just use a wasm binary that - // happens to be already checked-in in the repo. - .join("../../ledger_suite/icrc1/wasm/ic-icrc1-archive.wasm.gz") - .canonicalize() - .expect("failed to canonicalize a path"), - }; + if env::var_os("IN_BAZEL").is_none() { + let cargo_manifest_dir = PathBuf::from(env::var_os("CARGO_MANIFEST_DIR").unwrap()); + let compile_time_env_variables = [ + "LEDGER_CANISTER_WASM_PATH", + "INDEX_CANISTER_WASM_PATH", + "LEDGER_ARCHIVE_NODE_CANISTER_WASM_PATH", + ]; + for env_var in compile_time_env_variables { + let archive_path = match env::var_os(env_var) { + Some(wasm_path) => PathBuf::from(wasm_path), + None => cargo_manifest_dir + // This is a hack. + // Cargo is called on CI via ci/src/rust_lint/lint.sh. + // The included WASMS binary for ledger, index and archive canisters are built by BAZEL tasks + // which would need here to be somehow spawned by Cargo. To avoid this, we just use a wasm binary that + // happens to be already checked-in in the repo. + .join("../../ledger_suite/icrc1/wasm/ic-icrc1-archive.wasm.gz") + .canonicalize() + .expect("failed to canonicalize a path"), + }; - println!("cargo:rerun-if-changed={}", archive_path.display()); - println!("cargo:rerun-if-env-changed={env_var}"); - println!("cargo:rustc-env={}={}", env_var, archive_path.display()); + println!("cargo:rerun-if-changed={}", archive_path.display()); + println!("cargo:rerun-if-env-changed={env_var}"); + println!("cargo:rustc-env={}={}", env_var, archive_path.display()); + } } + + // Build reproducibility. askama adds a include_bytes! call when it's generating + // a template impl so that rustc will recompile the module when the file changes + // on disk. See https://github.com/djc/askama/blob/180696053833147a61b3348646a953e7d92ae582/askama_shared/src/generator.rs#L141 + // The stringified output of every proc-macro is added to the metadata hash for + // a crate. That output includes the full filepath to include_bytes!. It may be + // different on two machines, if they use different tempdir paths for the build. + // The metadata hash is an input to generated symbol names. + // So using the askama proc-macro could result in slightly different symbols. + // However, if we include the html source directly in the output, no + // inconsistency is introduced. + // + // This should really be fixed in askama. See: + // https://github.com/askama-rs/askama/issues/461 + println!("cargo:rerun-if-changed=templates/dashboard.html"); + let mut f = File::create( + PathBuf::from(std::env::var("OUT_DIR").unwrap()).join("dashboard_template.rs"), + ) + .unwrap(); + f.write_all( + format!( + r#" +#[derive(Template)] +#[template(escape = "html", source = {:?}, ext = "html")] +pub struct DashboardTemplate {{ + managed_canisters: BTreeMap, + other_canisters: BTreeMap>, + wasm_store: Vec, +}} + "#, + std::fs::read_to_string("templates/dashboard.html").unwrap() + ) + .as_bytes(), + ) + .unwrap(); } diff --git a/rs/ethereum/ledger-suite-orchestrator/src/dashboard/mod.rs b/rs/ethereum/ledger-suite-orchestrator/src/dashboard/mod.rs index 6a2bd3fc7b21..e89f3cf9f136 100644 --- a/rs/ethereum/ledger-suite-orchestrator/src/dashboard/mod.rs +++ b/rs/ethereum/ledger-suite-orchestrator/src/dashboard/mod.rs @@ -43,13 +43,8 @@ mod filters { } } -#[derive(Template)] -#[template(path = "dashboard.html")] -pub struct DashboardTemplate { - managed_canisters: BTreeMap, - other_canisters: BTreeMap>, - wasm_store: Vec, -} +// See build-canister.rs +include!(concat!(env!("OUT_DIR"), "/dashboard_template.rs")); #[derive(Clone, PartialEq, Debug, Default)] pub struct CanistersDashboardData { diff --git a/rs/ethereum/ledger-suite-orchestrator/src/scheduler/tests.rs b/rs/ethereum/ledger-suite-orchestrator/src/scheduler/tests.rs index 5dc211e2a00a..02fb280d2320 100644 --- a/rs/ethereum/ledger-suite-orchestrator/src/scheduler/tests.rs +++ b/rs/ethereum/ledger-suite-orchestrator/src/scheduler/tests.rs @@ -1023,7 +1023,7 @@ mod upgrade_ledger_suite { s.record_created_canister::(&usdc, LEDGER_PRINCIPAL); }); - for (task, canister_id) in vec![ + for (task, canister_id) in [ (update_index_task, INDEX_PRINCIPAL), (update_ledger_task, LEDGER_PRINCIPAL), ] { diff --git a/rs/execution_environment/tests/history.rs b/rs/execution_environment/tests/history.rs index 7dc1e3bd87e8..d5fe2132f888 100644 --- a/rs/execution_environment/tests/history.rs +++ b/rs/execution_environment/tests/history.rs @@ -216,7 +216,7 @@ fn test_invalid_transitions() { }) .collect::>(); - let all_statuses = vec![Unknown, received(), processing(), completed(), failed()]; + let all_statuses = [Unknown, received(), processing(), completed(), failed()]; // creates the cartesian product of all states and filters out the valid // transitions diff --git a/rs/ingress_manager/src/ingress_selector.rs b/rs/ingress_manager/src/ingress_selector.rs index fe2419cee745..5f60762fc9ff 100644 --- a/rs/ingress_manager/src/ingress_selector.rs +++ b/rs/ingress_manager/src/ingress_selector.rs @@ -812,7 +812,7 @@ mod tests { .expiry_time(time) .build(); - let ingress_messages = vec![m1.clone(), m2, m3]; + let ingress_messages = [m1.clone(), m2, m3]; for m in ingress_messages.iter() { let message_id = IngressMessageId::from(m); access_ingress_pool(&ingress_pool, |ingress_pool| { @@ -1534,7 +1534,7 @@ mod tests { certified_height: Height::from(0), }; - let ingress_messages = vec![m1.clone(), m2.clone(), m3, m4]; + let ingress_messages = [m1.clone(), m2.clone(), m3, m4]; for m in ingress_messages.iter() { let message_id = IngressMessageId::from(m); diff --git a/rs/ledger_suite/icrc1/archive/tests/tests.rs b/rs/ledger_suite/icrc1/archive/tests/tests.rs index 6c0bd75a8a5f..b25043ad8230 100644 --- a/rs/ledger_suite/icrc1/archive/tests/tests.rs +++ b/rs/ledger_suite/icrc1/archive/tests/tests.rs @@ -187,7 +187,7 @@ fn test_icrc3_get_blocks() { block2.encode(), block3.encode(), ]; - let blockids = vec![blockid0, blockid1, blockid2, blockid3]; + let blockids = [blockid0, blockid1, blockid2, blockid3]; let _ = setup.append_blocks(blocks); let check_icrc3_get_blocks = diff --git a/rs/ledger_suite/icrc1/ledger/src/lib.rs b/rs/ledger_suite/icrc1/ledger/src/lib.rs index e75378d145d1..0d52629bc3cc 100644 --- a/rs/ledger_suite/icrc1/ledger/src/lib.rs +++ b/rs/ledger_suite/icrc1/ledger/src/lib.rs @@ -556,18 +556,13 @@ pub enum LedgerField { Blocks, } -#[derive(Copy, Clone, Serialize, Deserialize, Debug)] +#[derive(Copy, Clone, Serialize, Deserialize, Debug, Default)] pub enum LedgerState { Migrating(LedgerField), + #[default] Ready, } -impl Default for LedgerState { - fn default() -> Self { - Self::Ready - } -} - type StableLedgerBalances = Balances; #[derive(Debug, Deserialize, Serialize)] diff --git a/rs/nns/governance/canbench/canbench_results.yml b/rs/nns/governance/canbench/canbench_results.yml index 2d32b6fb9c4d..4bd04d2f736a 100644 --- a/rs/nns/governance/canbench/canbench_results.yml +++ b/rs/nns/governance/canbench/canbench_results.yml @@ -2,206 +2,206 @@ benches: add_neuron_active_maximum: total: calls: 1 - instructions: 61500129 + instructions: 59464201 heap_increase: 0 stable_memory_increase: 0 scopes: {} add_neuron_active_typical: total: calls: 1 - instructions: 4397745 + instructions: 4319962 heap_increase: 0 stable_memory_increase: 0 scopes: {} add_neuron_inactive_maximum: total: calls: 1 - instructions: 61500250 + instructions: 59464322 heap_increase: 0 stable_memory_increase: 0 scopes: {} add_neuron_inactive_typical: total: calls: 1 - instructions: 4397866 + instructions: 4320083 heap_increase: 0 stable_memory_increase: 0 scopes: {} cascading_vote_stable_everything: total: calls: 1 - instructions: 106307790 + instructions: 103056446 heap_increase: 0 stable_memory_increase: 128 scopes: {} centralized_following_all: total: calls: 1 - instructions: 42125388 + instructions: 41330458 heap_increase: 0 stable_memory_increase: 128 scopes: {} compute_ballots_for_new_proposal_with_stable_neurons: total: calls: 1 - instructions: 1777765 + instructions: 1806549 heap_increase: 0 stable_memory_increase: 256 scopes: {} distribute_rewards_with_stable_neurons: total: calls: 1 - instructions: 2788359 + instructions: 2815904 heap_increase: 0 stable_memory_increase: 256 scopes: {} draw_maturity_from_neurons_fund: total: calls: 1 - instructions: 7564743 + instructions: 7611679 heap_increase: 0 stable_memory_increase: 0 scopes: {} list_active_neurons_fund_neurons: total: calls: 1 - instructions: 2194821 + instructions: 2148691 heap_increase: 0 stable_memory_increase: 0 scopes: {} list_neurons: total: calls: 1 - instructions: 64143895 + instructions: 63464384 heap_increase: 9 stable_memory_increase: 0 scopes: {} list_neurons_by_subaccount: total: calls: 1 - instructions: 63240563 + instructions: 62386107 heap_increase: 5 stable_memory_increase: 0 scopes: {} list_proposals: total: calls: 1 - instructions: 79657 + instructions: 78249 heap_increase: 0 stable_memory_increase: 0 scopes: {} list_ready_to_spawn_neuron_ids: total: calls: 1 - instructions: 36832813 + instructions: 37032683 heap_increase: 0 stable_memory_increase: 0 scopes: {} neuron_data_validation: total: calls: 1 - instructions: 206304392 + instructions: 195281915 heap_increase: 0 stable_memory_increase: 0 scopes: {} neuron_metrics_calculation: total: calls: 1 - instructions: 2683225 + instructions: 2704999 heap_increase: 0 stable_memory_increase: 0 scopes: {} range_neurons_performance: total: calls: 1 - instructions: 51683572 + instructions: 51119791 heap_increase: 0 stable_memory_increase: 0 scopes: {} record_known_neuron_vote: total: calls: 1 - instructions: 182534 + instructions: 183172 heap_increase: 0 stable_memory_increase: 128 scopes: {} record_neuron_vote_known_neuron_voting_history: total: calls: 1 - instructions: 142560 + instructions: 143333 heap_increase: 0 stable_memory_increase: 0 scopes: {} single_vote_all: total: calls: 1 - instructions: 278483 + instructions: 274837 heap_increase: 0 stable_memory_increase: 128 scopes: {} unstake_maturity_of_dissolved_neurons: total: calls: 1 - instructions: 63745188 + instructions: 63704195 heap_increase: 0 stable_memory_increase: 0 scopes: list_neuron_ids: calls: 1 - instructions: 38189482 + instructions: 38361301 heap_increase: 0 stable_memory_increase: 0 unstake_maturity: calls: 1 - instructions: 25553547 + instructions: 25340736 heap_increase: 0 stable_memory_increase: 0 voting_power_snapshots_is_latest_snapshot_a_spike_false: total: calls: 1 - instructions: 30194 + instructions: 30221 heap_increase: 0 stable_memory_increase: 0 scopes: {} voting_power_snapshots_is_latest_snapshot_a_spike_true: total: calls: 1 - instructions: 30205 + instructions: 30232 heap_increase: 0 stable_memory_increase: 0 scopes: {} voting_power_snapshots_latest_snapshot_timestamp_seconds: total: calls: 1 - instructions: 7608 + instructions: 7632 heap_increase: 0 stable_memory_increase: 0 scopes: {} with_neuron_mut_all_sections_maximum: total: calls: 1 - instructions: 4221086 + instructions: 4105991 heap_increase: 0 stable_memory_increase: 0 scopes: {} with_neuron_mut_all_sections_typical: total: calls: 1 - instructions: 838750 + instructions: 824778 heap_increase: 0 stable_memory_increase: 0 scopes: {} with_neuron_mut_main_section_maximum: total: calls: 1 - instructions: 2330589 + instructions: 2261182 heap_increase: 0 stable_memory_increase: 0 scopes: {} with_neuron_mut_main_section_typical: total: calls: 1 - instructions: 392586 + instructions: 389060 heap_increase: 0 stable_memory_increase: 0 scopes: {} diff --git a/rs/rosetta-api/common/rosetta_core/src/objects.rs b/rs/rosetta-api/common/rosetta_core/src/objects.rs index 34eac2e31c14..ed8444c8a537 100644 --- a/rs/rosetta-api/common/rosetta_core/src/objects.rs +++ b/rs/rosetta-api/common/rosetta_core/src/objects.rs @@ -443,9 +443,12 @@ pub struct BalanceExemption { /// ExemptionType is used to indicate if the live balance for an account subject to a BalanceExemption could increase above, /// decrease below, or equal the computed balance. -#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Deserialize, Serialize)] +#[derive( + Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Deserialize, Serialize, Default, +)] pub enum ExemptionType { /// The live balance may increase above or equal the computed balance. This typically occurs with staking rewards that accrue on each block. + #[default] GreaterOrEqual, /// The live balance may decrease below or equal the computed balance. This typically occurs as balance moves from locked to spendable on a vesting account. LessOrEqual, @@ -453,12 +456,6 @@ pub enum ExemptionType { Dynamic, } -impl Default for ExemptionType { - fn default() -> ExemptionType { - Self::GreaterOrEqual - } -} - /// Case specifies the expected case for strings and hashes. #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Deserialize, Serialize)] pub enum Case { diff --git a/rs/rosetta-api/icp/src/models.rs b/rs/rosetta-api/icp/src/models.rs index 267596f6ec1d..ed80e63ea44d 100644 --- a/rs/rosetta-api/icp/src/models.rs +++ b/rs/rosetta-api/icp/src/models.rs @@ -73,10 +73,11 @@ impl EnvelopePair { } } -#[derive(Clone, Eq, PartialEq, Debug, Deserialize, Serialize)] +#[derive(Clone, Eq, PartialEq, Debug, Deserialize, Serialize, Default)] #[serde(rename_all = "snake_case")] #[serde(tag = "account_type")] pub enum AccountType { + #[default] Ledger, Neuron { #[serde(default)] @@ -84,12 +85,6 @@ pub enum AccountType { }, } -impl Default for AccountType { - fn default() -> Self { - Self::Ledger - } -} - #[derive(Clone, Eq, PartialEq, Debug, Deserialize, Serialize)] pub struct ConstructionDeriveRequestMetadata { #[serde(flatten)] @@ -355,10 +350,11 @@ pub struct NeuronSubaccountComponents { /// We use this type to make query to the governance /// canister about the current neuron information. -#[derive(Clone, Eq, PartialEq, Debug, Deserialize, Serialize)] +#[derive(Clone, Eq, PartialEq, Debug, Deserialize, Serialize, Default)] #[serde(tag = "account_type")] pub enum BalanceAccountType { #[serde(rename = "ledger")] + #[default] Ledger, #[serde(rename = "neuron")] Neuron { @@ -379,12 +375,6 @@ pub enum BalanceAccountType { }, } -impl Default for BalanceAccountType { - fn default() -> Self { - Self::Ledger - } -} - /// The type of metadata for the /account/balance endpoint. #[derive(Clone, Eq, PartialEq, Debug, Default, Deserialize, Serialize)] pub struct AccountBalanceMetadata { diff --git a/rs/sns/governance/src/proposal/minting_tests.rs b/rs/sns/governance/src/proposal/minting_tests.rs index a09da899fca9..7a1b3ec14d5c 100644 --- a/rs/sns/governance/src/proposal/minting_tests.rs +++ b/rs/sns/governance/src/proposal/minting_tests.rs @@ -125,7 +125,7 @@ fn test_total_minting_amount_tokens() { } }; - let proposals = vec![ + let proposals = [ // Skip because not of type MintSnsTokens. ProposalData { proposal: Some(Proposal { diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 493a18ec0baf..dc68e91f0bcf 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,5 +1,5 @@ [toolchain] -channel = "1.90.0" +channel = "1.91.1" targets = ["wasm32-unknown-unknown"] profile = "default" components = []