diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7b65fb9..d662a56 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -42,6 +42,21 @@ jobs: - run: cargo test --package dynamic-fee-sharing shell: bash + clippy: + runs-on: ubuntu-latest + needs: program_changed_files + if: needs.program_changed_files.outputs.program == 'true' + steps: + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0 + - uses: dtolnay/rust-toolchain@683b588c487a69d01f6c6ddf40f036ff682cc2c8 # master (2026-10-16) + with: + toolchain: ${{ env.TOOLCHAIN }} + components: clippy + # Cache rust, cargo + - uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2 + - run: cargo clippy --locked --all-targets -- -D warnings + shell: bash + program_test: runs-on: ubuntu-latest needs: program_changed_files diff --git a/.github/workflows/dependency-audit.yml b/.github/workflows/dependency-audit.yml new file mode 100644 index 0000000..114cf64 --- /dev/null +++ b/.github/workflows/dependency-audit.yml @@ -0,0 +1,44 @@ +name: Dependency audit + +# Runs on every PR, whatever the base branch or the files changed: new advisories are published +# against dependencies that are already in the lockfile +on: + pull_request: + +permissions: + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + # advisories, licenses, bans and sources, see deny.toml + cargo_deny: + name: Cargo Deny + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0 + + - name: Check advisories, licenses, bans and sources + uses: EmbarkStudios/cargo-deny-action@3c6349835b2b7b196a839186cb8b78e02f7b5f25 # v2.1.1 + with: + command: check + + # advisories of every dependency in bun.lock, dev ones included, ignored ones are in osv-scanner.toml + osv_scanner: + name: OSV Scanner + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0 + + - name: Scan bun.lock + uses: google/osv-scanner-action/osv-scanner-action@b1d267aea5211fa648d9d442fa64b90dbdcbdd36 # v2.7.0 + with: + scan-args: |- + scan + source + -L + bun.lock diff --git a/Cargo.lock b/Cargo.lock index d1c6674..7d71947 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -311,6 +311,26 @@ dependencies = [ "zeroize", ] +[[package]] +name = "ark-ff" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a177aba0ed1e0fbb62aa9f6d0502e9b46dad8c2eab04c14258a1212d2557ea70" +dependencies = [ + "ark-ff-asm 0.5.0", + "ark-ff-macros 0.5.0", + "ark-serialize 0.5.0", + "ark-std 0.5.0", + "arrayvec", + "digest 0.10.7", + "educe", + "itertools 0.13.0", + "num-bigint", + "num-traits", + "paste", + "zeroize", +] + [[package]] name = "ark-ff-asm" version = "0.3.0" @@ -331,6 +351,16 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "ark-ff-asm" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62945a2f7e6de02a31fe400aa489f0e0f5b2502e69f95f853adb82a96c7a6b60" +dependencies = [ + "quote", + "syn 2.0.117", +] + [[package]] name = "ark-ff-macros" version = "0.3.0" @@ -356,6 +386,19 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "ark-ff-macros" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09be120733ee33f7693ceaa202ca41accd5653b779563608f1234f78ae07c4b3" +dependencies = [ + "num-bigint", + "num-traits", + "proc-macro2", + "quote", + "syn 2.0.117", +] + [[package]] name = "ark-serialize" version = "0.3.0" @@ -377,6 +420,18 @@ dependencies = [ "num-bigint", ] +[[package]] +name = "ark-serialize" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f4d068aaf107ebcd7dfb52bc748f8030e0fc930ac8e360146ca54c1203088f7" +dependencies = [ + "ark-std 0.5.0", + "arrayvec", + "digest 0.10.7", + "num-bigint", +] + [[package]] name = "ark-std" version = "0.3.0" @@ -397,6 +452,16 @@ dependencies = [ "rand 0.8.5", ] +[[package]] +name = "ark-std" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "246a225cc6131e9ee4f24619af0f19d67761fff15d7ccc22e42b80846e69449a" +dependencies = [ + "num-traits", + "rand 0.8.5", +] + [[package]] name = "arrayref" version = "0.3.9" @@ -792,12 +857,44 @@ dependencies = [ "static_assertions", ] +[[package]] +name = "educe" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d7bc049e1bd8cdeb31b68bbd586a9464ecf9f3944af3958a7a9d0f8b9799417" +dependencies = [ + "enum-ordinalize", + "proc-macro2", + "quote", + "syn 2.0.117", +] + [[package]] name = "either" version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" +[[package]] +name = "enum-ordinalize" +version = "4.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89dd01549b09589510cf0647475075d12071456586d70f5c75c98ae2a5537677" +dependencies = [ + "enum-ordinalize-derive", +] + +[[package]] +name = "enum-ordinalize-derive" +version = "4.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a65863d15a4ce2888bd2f0f543cc963d3879c3a022c8ee43f6141d479a3ac815" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", +] + [[package]] name = "equivalent" version = "1.0.0" @@ -1030,6 +1127,15 @@ dependencies = [ "either", ] +[[package]] +name = "itertools" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "1.0.8" @@ -1501,13 +1607,14 @@ dependencies = [ [[package]] name = "ruint" -version = "1.14.0" +version = "1.17.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78a46eb779843b2c4f21fac5773e25d6d5b7c8f0922876c91541790d2ca27eef" +checksum = "c141e807189ad38a07276942c6623032d3753c8859c146104ac2e4d68865945a" dependencies = [ "alloy-rlp", "ark-ff 0.3.0", "ark-ff 0.4.2", + "ark-ff 0.5.0", "bytes", "fastrlp 0.3.1", "fastrlp 0.4.0", @@ -1521,7 +1628,7 @@ dependencies = [ "rand 0.9.1", "rlp", "ruint-macro", - "serde", + "serde_core", "valuable", "zeroize", ] @@ -2602,6 +2709,17 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "syn" +version = "3.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d78c8dee4c7bf0e14673097256fed6142ce9d3b85a408189d07482442145823b" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + [[package]] name = "tap" version = "1.0.1" @@ -2772,9 +2890,9 @@ checksum = "eaea85b334db583fe3274d12b4cd1880032beab409c0d774be044d4480ab9a94" [[package]] name = "unicode-ident" -version = "1.0.10" +version = "1.0.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22049a19f4a68748a168c0fc439f9516686aa045927ff767eca0a85101fb6e73" +checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563" [[package]] name = "unicode-segmentation" diff --git a/bun.lock b/bun.lock index eded075..94217ea 100644 --- a/bun.lock +++ b/bun.lock @@ -115,7 +115,7 @@ "borsh": ["borsh@0.7.0", "", { "dependencies": { "bn.js": "^5.2.0", "bs58": "^4.0.0", "text-encoding-utf-8": "^1.0.2" } }, "sha512-CLCsZGIBCFnPtkNnieW/a8wmreDmfUtjU2m9yHrzPXIlNbqVs0AQrSatSG6vdNYUqdc83tkQi2eHfF98ubzQLA=="], - "brace-expansion": ["brace-expansion@1.1.14", "", { "dependencies": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" } }, "sha512-MWPGfDxnyzKU7rNOW9SP/c50vi3xrmrua/+6hfPbCS2ABNWfx24vPidzvC7krjU/RTo235sV776ymlsMtGKj8g=="], + "brace-expansion": ["brace-expansion@1.1.21", "", { "dependencies": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" } }, "sha512-9zeA+KLZNNzglF2TPKRQEDyx6Yby7daAkuy8MiPzpXPsYDWi/DRM8jmwUDxokQjYqBpv5DgPiwD4h4ZZSy1Ujw=="], "braces": ["braces@3.0.3", "", { "dependencies": { "fill-range": "^7.1.1" } }, "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA=="], @@ -367,7 +367,7 @@ "wrappy": ["wrappy@1.0.2", "", {}, "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ=="], - "ws": ["ws@7.5.10", "", { "peerDependencies": { "bufferutil": "^4.0.1", "utf-8-validate": "^5.0.2" }, "optionalPeers": ["bufferutil", "utf-8-validate"] }, "sha512-+dbF1tHwZpXcbOJdVOkzLDxZP1ailvSxM6ZweXTegylPny803bFhA+vqBYw4s31NSAk4S2Qz+AKXK9a4wkdjcQ=="], + "ws": ["ws@7.5.13", "", { "peerDependencies": { "bufferutil": "^4.0.1", "utf-8-validate": "^5.0.2" }, "optionalPeers": ["bufferutil", "utf-8-validate"] }, "sha512-rsKI6xDBFVf4r/x8XyChGK04QR/XHroxs/jUcoWvtEZM8TPU/X/uIY9B1CsSzYws9ZJb/6bbBu7dPhFW00CAoA=="], "y18n": ["y18n@5.0.8", "", {}, "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA=="], @@ -419,9 +419,9 @@ "rpc-websockets/eventemitter3": ["eventemitter3@5.0.4", "", {}, "sha512-mlsTRyGaPBjPedk6Bvw+aqbsXDtoAyAzm5MO7JgU+yVRyMQ5O8bD4Kcci7BS85f93veegeCPkL8R4GLClnjLFw=="], - "rpc-websockets/uuid": ["uuid@11.1.0", "", { "bin": { "uuid": "dist/esm/bin/uuid" } }, "sha512-0/A9rDy9P7cJ+8w1c9WD9V//9Wj15Ce2MPz8Ri6032usz+NfePxx5AcN3bN+r6ZL6jEo066/yNYB3tn4pQEx+A=="], + "rpc-websockets/uuid": ["uuid@11.1.1", "", { "bin": { "uuid": "dist/esm/bin/uuid" } }, "sha512-vIYxrBCC/N/K+Js3qSN88go7kIfNPssr/hHCesKCQNAjmgvYS2oqr69kIufEG+O4+PfezOH4EbIeHCfFov8ZgQ=="], - "rpc-websockets/ws": ["ws@8.20.0", "", { "peerDependencies": { "bufferutil": "^4.0.1", "utf-8-validate": ">=5.0.2" }, "optionalPeers": ["bufferutil", "utf-8-validate"] }, "sha512-sAt8BhgNbzCtgGbt2OxmpuryO63ZoDk/sqaB/znQm94T4fCEsy/yV+7CdC1kJhOU9lboAEU7R3kquuycDoibVA=="], + "rpc-websockets/ws": ["ws@8.22.0", "", { "peerDependencies": { "bufferutil": "^4.0.1", "utf-8-validate": ">=5.0.2" }, "optionalPeers": ["bufferutil", "utf-8-validate"] }, "sha512-Ydggc987+RO0AnWtZ/7Wq9FtNvcrL1b/RO0ud9mWjUPgDrsAAwQSF51sm2hm1XofbU/4jkpGEsLFsZZxU+1DOg=="], "ts-node/diff": ["diff@3.5.1", "", {}, "sha512-Z3u54A8qGyqFOSr2pk0ijYs8mOE9Qz8kTvtKeBI+upoG9j04Sq+oI7W8zAJiQybDcESET8/uIdHzs0p3k4fZlw=="], diff --git a/bunfig.toml b/bunfig.toml new file mode 100644 index 0000000..bcb08eb --- /dev/null +++ b/bunfig.toml @@ -0,0 +1,4 @@ +[install] +# only resolve versions published at least a week ago (in seconds), a compromised release is +# usually caught and unpublished within days +minimumReleaseAge = 604800 diff --git a/deny.toml b/deny.toml new file mode 100644 index 0000000..333ad58 --- /dev/null +++ b/deny.toml @@ -0,0 +1,249 @@ +# This template contains all of the possible sections and their default values + +# Note that all fields that take a lint level have these possible values: +# * deny - An error will be produced and the check will fail +# * warn - A warning will be produced, but the check will not fail +# * allow - No warning or error will be produced, though in some cases a note +# will be + +# The values provided in this template are the default values that will be used +# when any section or field is not specified in your own configuration + +# Root options + +# The graph table configures how the dependency graph is constructed and thus +# which crates the checks are performed against +[graph] +# If 1 or more target triples (and optionally, target_features) are specified, +# only the specified targets will be checked when running `cargo deny check`. +# This means, if a particular package is only ever used as a target specific +# dependency, such as, for example, the `nix` crate only being used via the +# `target_family = "unix"` configuration, that only having windows targets in +# this list would mean the nix crate, as well as any of its exclusive +# dependencies not shared by any other crates, would be ignored, as the target +# list here is effectively saying which targets you are building for. +targets = [ + # The triple can be any string, but only the target triples built in to + # rustc (as of 1.40) can be checked against actual config expressions + #"x86_64-unknown-linux-musl", + # You can also specify which target_features you promise are enabled for a + # particular target. target_features are currently not validated against + # the actual valid features supported by the target architecture. + #{ triple = "wasm32-unknown-unknown", features = ["atomics"] }, +] +# When creating the dependency graph used as the source of truth when checks are +# executed, this field can be used to prune crates from the graph, removing them +# from the view of cargo-deny. This is an extremely heavy hammer, as if a crate +# is pruned from the graph, all of its dependencies will also be pruned unless +# they are connected to another crate in the graph that hasn't been pruned, +# so it should be used with care. The identifiers are [Package ID Specifications] +# (https://doc.rust-lang.org/cargo/reference/pkgid-spec.html) +#exclude = [] +# If true, metadata will be collected with `--all-features`. Note that this can't +# be toggled off if true, if you want to conditionally enable `--all-features` it +# is recommended to pass `--all-features` on the cmd line instead +all-features = false +# If true, metadata will be collected with `--no-default-features`. The same +# caveat with `all-features` applies +no-default-features = false +# If set, these feature will be enabled when collecting metadata. If `--features` +# is specified on the cmd line they will take precedence over this option. +#features = [] + +# The output table provides options for how/if diagnostics are outputted +[output] +# When outputting inclusion graphs in diagnostics that include features, this +# option can be used to specify the depth at which feature edges will be added. +# This option is included since the graphs can be quite large and the addition +# of features from the crate(s) to all of the graph roots can be far too verbose. +# This option can be overridden via `--feature-depth` on the cmd line +feature-depth = 1 + +# This section is considered when running `cargo deny check advisories` +# More documentation for the advisories section can be found here: +# https://embarkstudios.github.io/cargo-deny/checks/advisories/cfg.html +[advisories] +# The path where the advisory databases are cloned/fetched into +#db-path = "$CARGO_HOME/advisory-dbs" +# The url(s) of the advisory databases to use +#db-urls = ["https://github.com/rustsec/advisory-db"] +# A list of advisory IDs to ignore. Note that ignored advisories will still +# output a note when they are encountered. +ignore = [ + #"RUSTSEC-0000-0000", + #{ id = "RUSTSEC-0000-0000", reason = "you can specify a reason the advisory is ignored" }, + #"a-crate-that-is-yanked@0.1.1", # you can also ignore yanked crate versions if you wish + #{ crate = "a-crate-that-is-yanked@0.1.1", reason = "you can specify why you are ignoring the yanked crate" }, + { id = "RUSTSEC-2025-0141", reason = "bincode is unmaintained, no fix. Pulled in by anchor-lang, waiting for upstream to replace it" }, + { id = "RUSTSEC-2026-0220", reason = "ruint shift overflow flags, fixed in 1.20.0, which needs rustc 1.90. The program is built with platform-tools v1.52 (rustc 1.89), anchor 1.0.2's default, so ruint stays on 1.17.2. The program's only ruint shift is the overflowing_shr in mul_shr, which discards the flag, and the shifted value was always correct" }, +] +# If this is true, then cargo deny will use the git executable to fetch advisory database. +# If this is false, then it uses a built-in git library. +# Setting this to true can be helpful if you have special authentication requirements that cargo-deny does not support. +# See Git Authentication for more information about setting up git authentication. +#git-fetch-with-cli = true + +# This section is considered when running `cargo deny check licenses` +# More documentation for the licenses section can be found here: +# https://embarkstudios.github.io/cargo-deny/checks/licenses/cfg.html +[licenses] +# 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)]. +allow = [ + "Apache-2.0", + "Apache-2.0 WITH LLVM-exception", + "BSD-1-Clause", + "BSD-2-Clause", + "BSD-3-Clause", + "BSL-1.0", + "MIT", + "Unicode-3.0", + "Unlicense", + "Zlib", +] +# The confidence threshold for detecting a license from license text. +# The higher the value, the more closely the license text must be to the +# canonical license text of a valid SPDX license file. +# [possible values: any between 0.0 and 1.0]. +confidence-threshold = 0.8 +# Allow 1 or more licenses on a per-crate basis, so that particular licenses +# aren't accepted for every possible crate as with the normal allow list +exceptions = [ + # Each entry is the crate and version constraint, and its specific allow + # list + #{ allow = ["Zlib"], crate = "adler32" }, +] + +# Some crates don't have (easily) machine readable licensing information, +# adding a clarification entry for it allows you to manually specify the +# licensing information +#[[licenses.clarify]] +# The package spec the clarification applies to +#crate = "ring" +# The SPDX expression for the license requirements of the crate +#expression = "MIT AND ISC AND OpenSSL" +# One or more files in the crate's source used as the "source of truth" for +# the license expression. If the contents match, the clarification will be used +# when running the license check, otherwise the clarification will be ignored +# and the crate will be checked normally, which may produce warnings or errors +# depending on the rest of your configuration +#license-files = [ +# Each entry is a crate relative path, and the (opaque) hash of its contents +#{ path = "LICENSE", hash = 0xbd0eed23 } +#] + +[licenses.private] +# If true, ignores workspace crates that aren't published, or are only +# published to private registries. +# To see how to mark a crate as unpublished (to the official registry), +# visit https://doc.rust-lang.org/cargo/reference/manifest.html#the-publish-field. +ignore = true +# One or more private registries that you might publish crates to, if a crate +# is only published to private registries, and ignore is true, the crate will +# not have its license(s) checked +registries = [ + #"https://sekretz.com/registry +] + +# This section is considered when running `cargo deny check bans`. +# More documentation about the 'bans' section can be found here: +# https://embarkstudios.github.io/cargo-deny/checks/bans/cfg.html +[bans] +# Lint level for when multiple versions of the same crate are detected +multiple-versions = "warn" +# Lint level for when a crate version requirement is `*` +wildcards = "allow" +# The graph highlighting used when creating dotgraphs for crates +# with multiple versions +# * lowest-version - The path to the lowest versioned duplicate is highlighted +# * simplest-path - The path to the version with the fewest edges is highlighted +# * all - Both lowest-version and simplest-path are used +highlight = "all" +# The default lint level for `default` features for crates that are members of +# the workspace that is being checked. This can be overridden by allowing/denying +# `default` on a crate-by-crate basis if desired. +workspace-default-features = "allow" +# The default lint level for `default` features for external crates that are not +# members of the workspace. This can be overridden by allowing/denying `default` +# on a crate-by-crate basis if desired. +external-default-features = "allow" +# List of crates that are allowed. Use with care! +allow = [ + #"ansi_term@0.11.0", + #{ crate = "ansi_term@0.11.0", reason = "you can specify a reason it is allowed" }, +] +# If true, workspace members are automatically allowed even when using deny-by-default +# This is useful for organizations that want to deny all external dependencies by default +# but allow their own workspace crates without having to explicitly list them +allow-workspace = false +# List of crates to deny +deny = [ + #"ansi_term@0.11.0", + #{ crate = "ansi_term@0.11.0", reason = "you can specify a reason it is banned" }, + # Wrapper crates can optionally be specified to allow the crate when it + # is a direct dependency of the otherwise banned crate + #{ crate = "ansi_term@0.11.0", wrappers = ["this-crate-directly-depends-on-ansi_term"] }, +] + +# List of features to allow/deny +# Each entry the name of a crate and a version range. If version is +# not specified, all versions will be matched. +#[[bans.features]] +#crate = "reqwest" +# Features to not allow +#deny = ["json"] +# Features to allow +#allow = [ +# "rustls", +# "__rustls", +# "__tls", +# "hyper-rustls", +# "rustls", +# "rustls-pemfile", +# "rustls-tls-webpki-roots", +# "tokio-rustls", +# "webpki-roots", +#] +# If true, the allowed features must exactly match the enabled feature set. If +# this is set there is no point setting `deny` +#exact = true + +# Certain crates/versions that will be skipped when doing duplicate detection. +skip = [ + #"ansi_term@0.11.0", + #{ crate = "ansi_term@0.11.0", reason = "you can specify a reason why it can't be updated/removed" }, +] +# Similarly to `skip` allows you to skip certain crates during duplicate +# detection. Unlike skip, it also includes the entire tree of transitive +# dependencies starting at the specified crate, up to a certain depth, which is +# by default infinite. +skip-tree = [ + #"ansi_term@0.11.0", # will be skipped along with _all_ of its direct and transitive dependencies + #{ crate = "ansi_term@0.11.0", depth = 20 }, +] + +# This section is considered when running `cargo deny check sources`. +# More documentation about the 'sources' section can be found here: +# https://embarkstudios.github.io/cargo-deny/checks/sources/cfg.html +[sources] +# Lint level for what to happen when a crate from a crate registry that is not +# in the allow list is encountered +unknown-registry = "warn" +# Lint level for what to happen when a crate from a git repository that is not +# in the allow list is encountered +unknown-git = "warn" +# List of URLs for allowed crate registries. Defaults to the crates.io index +# 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 = [ +] + +[sources.allow-org] +# github.com organizations to allow git sources for +github = ["MeteoraAg"] +# gitlab.com organizations to allow git sources for +gitlab = [] +# bitbucket.org organizations to allow git sources for +bitbucket = [] diff --git a/libs/damm-v2/Cargo.toml b/libs/damm-v2/Cargo.toml index e0ec518..d70e7ed 100644 --- a/libs/damm-v2/Cargo.toml +++ b/libs/damm-v2/Cargo.toml @@ -3,6 +3,7 @@ name = "damm-v2" version = "0.1.3" authors = [""] edition = "2021" +publish = false [lib] doctest = false diff --git a/libs/dynamic-bonding-curve/Cargo.toml b/libs/dynamic-bonding-curve/Cargo.toml index e4fd0e5..42ba0ea 100644 --- a/libs/dynamic-bonding-curve/Cargo.toml +++ b/libs/dynamic-bonding-curve/Cargo.toml @@ -3,6 +3,7 @@ name = "dynamic-bonding-curve" version = "0.1.6" authors = [""] edition = "2021" +publish = false [lib] doctest = false diff --git a/osv-scanner.toml b/osv-scanner.toml new file mode 100644 index 0000000..340e8ac --- /dev/null +++ b/osv-scanner.toml @@ -0,0 +1,114 @@ +# Advisories OSV-Scanner ignores in CI. It can't tell dev dependencies apart in bun.lock, so +# dev only ones are listed too. Drop an entry once upstream moves to the patched version. + +[[IgnoredVulns]] +id = "GHSA-3gc7-fjrx-p6mg" +reason = "bigint-buffer has no patched version. @solana/spl-token > @solana/buffer-layout-utils only passes it the fixed length buffers of its u64/u128 layouts" + +[[IgnoredVulns]] +id = "GHSA-528h-pc64-c93x" +reason = "stream-json 1 (fixed in 3): @solana/web3.js > jayson only uses it in its server and stream utils, web3.js loads `jayson/lib/client/browser`" + +[[IgnoredVulns]] +id = "GHSA-hqr4-qq8f-hg3x" +reason = "stream-json 1 (fixed in 3): @solana/web3.js > jayson only uses it in its server and stream utils, web3.js loads `jayson/lib/client/browser`" + +[[IgnoredVulns]] +id = "GHSA-mjw6-4jj6-33hc" +reason = "stream-json 1 (fixed in 3): @solana/web3.js > jayson only uses it in its server and stream utils, web3.js loads `jayson/lib/client/browser`" + +[[IgnoredVulns]] +id = "GHSA-4qx8-w7c3-pj3p" +reason = "toml 3 (fixed in 5): @anchor-lang/core only parses Anchor.toml in `workspace`, which the tests don't use" + +[[IgnoredVulns]] +id = "GHSA-82x6-q7mm-w9cf" +reason = "toml 3 (fixed in 5): @anchor-lang/core only parses Anchor.toml in `workspace`, which the tests don't use" + +[[IgnoredVulns]] +id = "GHSA-9j65-hcg3-gc64" +reason = "toml 3 (fixed in 5): @anchor-lang/core only parses Anchor.toml in `workspace`, which the tests don't use" + +[[IgnoredVulns]] +id = "GHSA-9qmh-m7c6-f92p" +reason = "toml 3 (fixed in 5): @anchor-lang/core only parses Anchor.toml in `workspace`, which the tests don't use" + +[[IgnoredVulns]] +id = "GHSA-h895-cgqg-jf52" +reason = "toml 3 (fixed in 5): @anchor-lang/core only parses Anchor.toml in `workspace`, which the tests don't use" + +[[IgnoredVulns]] +id = "GHSA-v5mp-jgw5-2x6j" +reason = "toml 3 (fixed in 5): @anchor-lang/core only parses Anchor.toml in `workspace`, which the tests don't use" + +[[IgnoredVulns]] +id = "GHSA-w5hq-g745-h8pq" +reason = "uuid 8 (fixed in 11): jayson only calls v4, the advisory is v3/v5/v6 with `buf`" + +[[IgnoredVulns]] +id = "GHSA-73rr-hh4g-fpgx" +reason = "diff 5.0.0 (dev), pinned by mocha 9: mocha only calls createPatch to print failed assertions, the advisory is in parsePatch and applyPatch" + +[[IgnoredVulns]] +id = "GHSA-2883-xcg3-v3hh" +reason = "js-yaml 4.1.0 (dev), pinned by mocha 9: mocha only loads .mocharc.yml config files with it, the repo has none" + +[[IgnoredVulns]] +id = "GHSA-52cp-r559-cp3m" +reason = "js-yaml 4.1.0 (dev), pinned by mocha 9: mocha only loads .mocharc.yml config files with it, the repo has none" + +[[IgnoredVulns]] +id = "GHSA-5p4m-2wfm-xmqj" +reason = "js-yaml 4.1.0 (dev), pinned by mocha 9: mocha only loads .mocharc.yml config files with it, the repo has none" + +[[IgnoredVulns]] +id = "GHSA-h67p-54hq-rp68" +reason = "js-yaml 4.1.0 (dev), pinned by mocha 9: mocha only loads .mocharc.yml config files with it, the repo has none" + +[[IgnoredVulns]] +id = "GHSA-mh29-5h37-fv8m" +reason = "js-yaml 4.1.0 (dev), pinned by mocha 9: mocha only loads .mocharc.yml config files with it, the repo has none" + +[[IgnoredVulns]] +id = "GHSA-23c5-xmqv-rm74" +reason = "minimatch 4.2.1 (dev), pinned by mocha 9: mocha only matches `--ignore` patterns with it, and the test script passes none" + +[[IgnoredVulns]] +id = "GHSA-3ppc-4f35-3m26" +reason = "minimatch 4.2.1 (dev), pinned by mocha 9: mocha only matches `--ignore` patterns with it, and the test script passes none" + +[[IgnoredVulns]] +id = "GHSA-7r86-cg39-jmmj" +reason = "minimatch 4.2.1 (dev), pinned by mocha 9: mocha only matches `--ignore` patterns with it, and the test script passes none" + +[[IgnoredVulns]] +id = "GHSA-28wg-ghj8-5hjv" +reason = "nanoid 3.3.1 (dev), pinned by mocha 9: mocha only calls nanoid() with the default size, the advisory needs a negative size" + +[[IgnoredVulns]] +id = "GHSA-2v37-7h3g-55p8" +reason = "nanoid 3.3.1 (dev), pinned by mocha 9: mocha only calls nanoid() with the default size, the advisory is custom generators with size 0" + +[[IgnoredVulns]] +id = "GHSA-mwcw-c2x4-8c55" +reason = "nanoid 3.3.1 (dev), pinned by mocha 9: mocha only calls nanoid() with the default size, the advisory needs a non-integer size" + +[[IgnoredVulns]] +id = "GHSA-xwg4-73v4-xw9w" +reason = "nanoid 3.3.1 (dev), pinned by mocha 9: mocha only calls nanoid() with the default size, the advisory needs a size of 2^31 or more" + +[[IgnoredVulns]] +id = "GHSA-5c6j-r48x-rmvq" +reason = "serialize-javascript 6.0.0 (dev), pinned by mocha 9: mocha only uses it in --parallel mode, which the test script doesn't use" + +[[IgnoredVulns]] +id = "GHSA-76p7-773f-r4q5" +reason = "serialize-javascript 6.0.0 (dev), pinned by mocha 9: mocha only uses it in --parallel mode, which the test script doesn't use" + +[[IgnoredVulns]] +id = "GHSA-m5mm-p8h7-m29v" +reason = "serialize-javascript 6.0.0 (dev), pinned by mocha 9: mocha only uses it in --parallel mode, which the test script doesn't use" + +[[IgnoredVulns]] +id = "GHSA-qj8w-gfj5-8c6v" +reason = "serialize-javascript 6.0.0 (dev), pinned by mocha 9: mocha only uses it in --parallel mode, which the test script doesn't use" diff --git a/programs/dynamic-fee-sharing/Cargo.toml b/programs/dynamic-fee-sharing/Cargo.toml index 61ff6ae..11da6ab 100644 --- a/programs/dynamic-fee-sharing/Cargo.toml +++ b/programs/dynamic-fee-sharing/Cargo.toml @@ -3,6 +3,7 @@ name = "dynamic-fee-sharing" version = "0.1.2" description = "Created with Anchor" edition = "2021" +publish = false [lib] crate-type = ["cdylib", "lib"] diff --git a/programs/dynamic-fee-sharing/src/instructions/ix_fund_by_claiming_fee.rs b/programs/dynamic-fee-sharing/src/instructions/ix_fund_by_claiming_fee.rs index a495fbf..0043f6d 100644 --- a/programs/dynamic-fee-sharing/src/instructions/ix_fund_by_claiming_fee.rs +++ b/programs/dynamic-fee-sharing/src/instructions/ix_fund_by_claiming_fee.rs @@ -73,7 +73,7 @@ pub fn handle_fund_by_claiming_fee( FeeVaultError::InvalidAction ); - validate_payload(ctx.accounts.source_program.key, &discriminator, &payload)?; + validate_payload(ctx.accounts.source_program.key, discriminator, &payload)?; let fee_vault = ctx.accounts.fee_vault.load()?; @@ -97,7 +97,7 @@ pub fn handle_fund_by_claiming_fee( let is_signer = acc.key == &ctx.accounts.fee_vault.key(); AccountMeta { pubkey: *acc.key, - is_signer: is_signer, + is_signer, is_writable: acc.is_writable, } }) diff --git a/programs/dynamic-fee-sharing/src/instructions/ix_initialize_fee_vault.rs b/programs/dynamic-fee-sharing/src/instructions/ix_initialize_fee_vault.rs index dadd994..a6ecde4 100644 --- a/programs/dynamic-fee-sharing/src/instructions/ix_initialize_fee_vault.rs +++ b/programs/dynamic-fee-sharing/src/instructions/ix_initialize_fee_vault.rs @@ -26,7 +26,7 @@ impl InitializeFeeVaultParameters { pub fn validate(&self) -> Result<()> { let number_of_user = self.users.len(); require!( - number_of_user >= 2 && number_of_user <= MAX_USER, + (2..=MAX_USER).contains(&number_of_user), FeeVaultError::ExceededUser ); for i in 0..number_of_user { @@ -58,7 +58,7 @@ pub struct InitializeFeeVaultCtx<'info> { /// CHECK: pool authority #[account( seeds = [ - FEE_VAULT_AUTHORITY_PREFIX.as_ref(), + FEE_VAULT_AUTHORITY_PREFIX, ], bump, )] @@ -67,7 +67,7 @@ pub struct InitializeFeeVaultCtx<'info> { #[account( init, seeds = [ - TOKEN_VAULT_PREFIX.as_ref(), + TOKEN_VAULT_PREFIX, fee_vault.key().as_ref(), ], token::mint = token_mint, @@ -121,8 +121,9 @@ pub fn handle_initialize_fee_vault( Ok(()) } +#[allow(clippy::too_many_arguments)] pub fn create_fee_vault<'info>( - token_mint: &Box>, + token_mint: &InterfaceAccount<'info, Mint>, params: &InitializeFeeVaultParameters, fee_vault: &AccountLoader<'info, FeeVault>, owner: &Pubkey, @@ -131,14 +132,14 @@ pub fn create_fee_vault<'info>( fee_vault_bump: u8, fee_vault_type: u8, ) -> Result<()> { - require!(is_supported_mint(&token_mint)?, FeeVaultError::InvalidMint); + require!(is_supported_mint(token_mint)?, FeeVaultError::InvalidMint); params.validate()?; let mut fee_vault = fee_vault.load_init()?; fee_vault.initialize( owner, - get_token_program_flags(&token_mint).into(), + get_token_program_flags(token_mint).into(), &token_mint.key(), token_vault, base, diff --git a/programs/dynamic-fee-sharing/src/instructions/ix_initialize_fee_vault_pda.rs b/programs/dynamic-fee-sharing/src/instructions/ix_initialize_fee_vault_pda.rs index 0a34e98..14c34e0 100644 --- a/programs/dynamic-fee-sharing/src/instructions/ix_initialize_fee_vault_pda.rs +++ b/programs/dynamic-fee-sharing/src/instructions/ix_initialize_fee_vault_pda.rs @@ -15,7 +15,7 @@ pub struct InitializeFeeVaultPdaCtx<'info> { #[account( init, seeds = [ - FEE_VAULT_PREFIX.as_ref(), + FEE_VAULT_PREFIX, base.key().as_ref(), token_mint.key().as_ref(), ], @@ -28,7 +28,7 @@ pub struct InitializeFeeVaultPdaCtx<'info> { /// CHECK: pool authority #[account( seeds = [ - FEE_VAULT_AUTHORITY_PREFIX.as_ref(), + FEE_VAULT_AUTHORITY_PREFIX, ], bump, )] @@ -37,7 +37,7 @@ pub struct InitializeFeeVaultPdaCtx<'info> { #[account( init, seeds = [ - TOKEN_VAULT_PREFIX.as_ref(), + TOKEN_VAULT_PREFIX, fee_vault.key().as_ref(), ], token::mint = token_mint, @@ -77,7 +77,7 @@ pub fn handle_initialize_fee_vault_pda( &ctx.accounts.fee_vault, ctx.accounts.owner.key, &ctx.accounts.token_vault.key(), - &ctx.accounts.base.key, + ctx.accounts.base.key, ctx.bumps.fee_vault, FeeVaultType::PdaAccount.into(), )?; diff --git a/programs/dynamic-fee-sharing/src/instructions/mod.rs b/programs/dynamic-fee-sharing/src/instructions/mod.rs index 44af05a..7eebab1 100644 --- a/programs/dynamic-fee-sharing/src/instructions/mod.rs +++ b/programs/dynamic-fee-sharing/src/instructions/mod.rs @@ -1,10 +1,17 @@ +// `#[event_cpi]` adds `AccountInfo` fields, which anchor 1.0.2 itself flags as deprecated in the +// generated `Accounts` impl +#[allow(deprecated)] pub mod ix_initialize_fee_vault; pub use ix_initialize_fee_vault::*; +#[allow(deprecated)] pub mod ix_fund_fee; pub use ix_fund_fee::*; +#[allow(deprecated)] pub mod ix_claim_fee; pub use ix_claim_fee::*; +#[allow(deprecated)] pub mod ix_initialize_fee_vault_pda; pub use ix_initialize_fee_vault_pda::*; +#[allow(deprecated)] pub mod ix_fund_by_claiming_fee; pub use ix_fund_by_claiming_fee::*; diff --git a/programs/dynamic-fee-sharing/src/lib.rs b/programs/dynamic-fee-sharing/src/lib.rs index f44c227..b8433e8 100644 --- a/programs/dynamic-fee-sharing/src/lib.rs +++ b/programs/dynamic-fee-sharing/src/lib.rs @@ -1,3 +1,6 @@ +// `#[program]` type checks the instruction arguments with `let _: T = panic!();` in the handlers +// it generates next to the program module +#![allow(clippy::diverging_sub_expression)] use anchor_lang::prelude::*; #[macro_use] pub mod macros; diff --git a/programs/dynamic-fee-sharing/src/math/safe_math.rs b/programs/dynamic-fee-sharing/src/math/safe_math.rs index cc8a9ec..d9c5704 100644 --- a/programs/dynamic-fee-sharing/src/math/safe_math.rs +++ b/programs/dynamic-fee-sharing/src/math/safe_math.rs @@ -119,43 +119,43 @@ mod tests { #[test] fn safe_add() { - assert_eq!(u64::MAX.safe_add(u64::MAX).is_err(), true); - assert_eq!(100u64.safe_add(100u64).is_ok(), true); + assert!(u64::MAX.safe_add(u64::MAX).is_err()); + assert!(100u64.safe_add(100u64).is_ok()); assert_eq!(100u64.safe_add(100u64).unwrap(), 200u64); } #[test] fn safe_sub() { - assert_eq!(0u64.safe_sub(u64::MAX).is_err(), true); - assert_eq!(200u64.safe_sub(100u64).is_ok(), true); + assert!(0u64.safe_sub(u64::MAX).is_err()); + assert!(200u64.safe_sub(100u64).is_ok()); assert_eq!(200u64.safe_sub(100u64).unwrap(), 100u64); } #[test] fn safe_mul() { - assert_eq!(u64::MAX.safe_mul(u64::MAX).is_err(), true); - assert_eq!(100u64.safe_mul(100u64).is_ok(), true); + assert!(u64::MAX.safe_mul(u64::MAX).is_err()); + assert!(100u64.safe_mul(100u64).is_ok()); assert_eq!(100u64.safe_mul(100u64).unwrap(), 10000u64); } #[test] fn safe_div() { - assert_eq!(100u64.safe_div(0u64).is_err(), true); - assert_eq!(200u64.safe_div(100u64).is_ok(), true); + assert!(100u64.safe_div(0u64).is_err()); + assert!(200u64.safe_div(100u64).is_ok()); assert_eq!(200u64.safe_div(100u64), Ok(2u64)); } #[test] fn safe_shl() { - assert_eq!(1u128.safe_shl(8).is_ok(), true); - assert_eq!(100u128.safe_shl(128).is_err(), true); + assert!(1u128.safe_shl(8).is_ok()); + assert!(100u128.safe_shl(128).is_err()); assert_eq!(100u128.safe_shl(8), Ok(25600)) } #[test] fn safe_shr() { - assert_eq!(100u128.safe_shr(1).is_ok(), true); - assert_eq!(200u128.safe_shr(129).is_err(), true); + assert!(100u128.safe_shr(1).is_ok()); + assert!(200u128.safe_shr(129).is_err()); assert_eq!(200u128.safe_shr(1), Ok(100)) } } diff --git a/programs/dynamic-fee-sharing/src/state/fee_vault.rs b/programs/dynamic-fee-sharing/src/state/fee_vault.rs index a9c9519..7610338 100644 --- a/programs/dynamic-fee-sharing/src/state/fee_vault.rs +++ b/programs/dynamic-fee-sharing/src/state/fee_vault.rs @@ -57,6 +57,7 @@ pub struct UserFee { const_assert_eq!(UserFee::INIT_SPACE, 80); impl FeeVault { + #[allow(clippy::too_many_arguments)] pub fn initialize( &mut self, owner: &Pubkey, @@ -73,13 +74,13 @@ impl FeeVault { self.token_mint = *token_mint; self.token_vault = *token_vault; let mut total_share = 0; - for i in 0..users.len() { + for (i, user) in users.iter().enumerate() { self.users[i] = UserFee { - address: users[i].address, - share: users[i].share, + address: user.address, + share: user.share, ..Default::default() }; - total_share = total_share.safe_add(users[i].share)?; + total_share = total_share.safe_add(user.share)?; } self.total_share = total_share; self.base = *base; @@ -93,7 +94,7 @@ impl FeeVault { self.total_funded_fee = self.total_funded_fee.safe_add(amount)?; let fee_per_share = shl_div(amount, self.total_share.into(), PRECISION_SCALE) - .ok_or_else(|| FeeVaultError::MathOverflow)?; + .ok_or(FeeVaultError::MathOverflow)?; self.fee_per_share = self.fee_per_share.safe_add(fee_per_share)?; @@ -104,13 +105,13 @@ impl FeeVault { let user = self .users .get_mut(index as usize) - .ok_or_else(|| FeeVaultError::InvalidUserIndex)?; + .ok_or(FeeVaultError::InvalidUserIndex)?; require!(user.address.eq(signer), FeeVaultError::InvalidUserAddress); let reward_per_share_delta = self.fee_per_share.safe_sub(user.fee_per_share_checkpoint)?; let fee_being_claimed = mul_shr(user.share.into(), reward_per_share_delta, PRECISION_SCALE) - .ok_or_else(|| FeeVaultError::MathOverflow)? + .ok_or(FeeVaultError::MathOverflow)? .try_into() .map_err(|_| FeeVaultError::MathOverflow)?; diff --git a/programs/dynamic-fee-sharing/src/tests/fund_fee.rs b/programs/dynamic-fee-sharing/src/tests/fund_fee.rs index 7b5f22f..e65a88d 100644 --- a/programs/dynamic-fee-sharing/src/tests/fund_fee.rs +++ b/programs/dynamic-fee-sharing/src/tests/fund_fee.rs @@ -1,5 +1,3 @@ -use std::u32; - use crate::state::FeeVault; use proptest::prelude::*; diff --git a/programs/dynamic-fee-sharing/src/utils/token.rs b/programs/dynamic-fee-sharing/src/utils/token.rs index 8f42261..9717e95 100644 --- a/programs/dynamic-fee-sharing/src/utils/token.rs +++ b/programs/dynamic-fee-sharing/src/utils/token.rs @@ -67,10 +67,10 @@ pub fn calculate_transfer_fee_excluded_amount<'info>( if let Some(epoch_transfer_fee) = get_epoch_transfer_fee(token_mint)? { let transfer_fee = epoch_transfer_fee .calculate_fee(transfer_fee_included_amount) - .ok_or_else(|| FeeVaultError::MathOverflow)?; + .ok_or(FeeVaultError::MathOverflow)?; let transfer_fee_excluded_amount = transfer_fee_included_amount .checked_sub(transfer_fee) - .ok_or_else(|| FeeVaultError::MathOverflow)?; + .ok_or(FeeVaultError::MathOverflow)?; return Ok(TransferFeeExcludedAmount { amount: transfer_fee_excluded_amount, transfer_fee, @@ -98,7 +98,7 @@ pub fn get_epoch_transfer_fee<'info>( token_mint_unpacked.get_extension::() { let epoch = Clock::get()?.epoch; - return Ok(Some(transfer_fee_config.get_epoch_fee(epoch).clone())); + return Ok(Some(*transfer_fee_config.get_epoch_fee(epoch))); } Ok(None)