From af08d7cb7866266957cc8ec773017f03f0c77551 Mon Sep 17 00:00:00 2001 From: 0xgleb Date: Wed, 21 May 2025 20:04:12 +0400 Subject: [PATCH 1/4] add direnv --- .envrc | 10 ++++++++++ .gitignore | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 .envrc diff --git a/.envrc b/.envrc new file mode 100644 index 00000000..a3693d2d --- /dev/null +++ b/.envrc @@ -0,0 +1,10 @@ +if ! has nix_direnv_version || ! nix_direnv_version 3.0.6; then + URL=https://raw.githubusercontent.com/nix-community/nix-direnv/3.0.6/direnvrc + HASH=sha256-RYcUJaRMf8oF5LznDrlCXbkOQrywm0HDv1VjYGaJGdM= + source_url "$URL" "$HASH" +fi + +watch_file flake.lock +watch_file flake.nix + +use flake . --verbose --show-trace \ No newline at end of file diff --git a/.gitignore b/.gitignore index 1cbcdbbe..1570ab1e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,8 @@ out cache .DS_Store - .vscode +.direnv/ # Rust target \ No newline at end of file From 338e7e89c0f0be376e36d43e659eec1cfebf5fe6 Mon Sep 17 00:00:00 2001 From: 0xgleb Date: Wed, 21 May 2025 20:04:29 +0400 Subject: [PATCH 2/4] upd nix flake --- flake.lock | 37 +++++++++++++++++++------------------ flake.nix | 27 ++++++++++++--------------- 2 files changed, 31 insertions(+), 33 deletions(-) diff --git a/flake.lock b/flake.lock index 18d153f1..ebf170a9 100644 --- a/flake.lock +++ b/flake.lock @@ -104,11 +104,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1741078842, - "narHash": "sha256-585m711y0v7B2PEMjh69r0WUBPaH5fTQZKwz8yjJOEo=", + "lastModified": 1747828570, + "narHash": "sha256-tv8R4Z/69GC8zogsb5TNDRj5tkhMeHpyYIzRl1cJigo=", "owner": "nixos", "repo": "nixpkgs", - "rev": "5aeeed52dfcf14c2021628cce169da8d6a6f5e41", + "rev": "040a62f13f40879a05578a66dd4ae0d284c55a5b", "type": "github" }, "original": { @@ -119,11 +119,11 @@ }, "nixpkgs_3": { "locked": { - "lastModified": 1736320768, - "narHash": "sha256-nIYdTAiKIGnFNugbomgBJR+Xv5F1ZQU+HfaBqJKroC0=", + "lastModified": 1744536153, + "narHash": "sha256-awS2zRgF4uTwrOKwwiJcByDzDOdo3Q1rPZbiHQg/N38=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "4bc9c909d9ac828a039f288cf872d16d38185db8", + "rev": "18dd725c29603f582cf1900e0d25f9f1063dbf11", "type": "github" }, "original": { @@ -158,16 +158,17 @@ "solc": "solc" }, "locked": { - "lastModified": 1742967497, - "narHash": "sha256-A34SKRGWMgd392bOsrcEltJwIO7ANMu17RoLeCSaYq0=", + "lastModified": 1747832348, + "narHash": "sha256-5t7vMuMk5zZBwaxQudSh0ohKx8SFftlrTKXVojNCqSk=", "owner": "rainprotocol", "repo": "rainix", - "rev": "6ce0d465018c6bfa750c1465afb4cbc6137120b4", + "rev": "4e87c16f3abcb4e9e309609f452669f5a85bb558", "type": "github" }, "original": { "owner": "rainprotocol", "repo": "rainix", + "rev": "4e87c16f3abcb4e9e309609f452669f5a85bb558", "type": "github" } }, @@ -182,11 +183,11 @@ "nixpkgs": "nixpkgs_3" }, "locked": { - "lastModified": 1741055476, - "narHash": "sha256-52vwEV0oS2lCnx3c/alOFGglujZTLmObit7K8VblnS8=", + "lastModified": 1747795013, + "narHash": "sha256-c7i0xJ+xFhgjO9SWHYu5dF/7lq63RPDvwKAdjc6VCE4=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "aefb7017d710f150970299685e8d8b549d653649", + "rev": "6b1cf12374361859242a562e1933a7930649131a", "type": "github" }, "original": { @@ -202,11 +203,11 @@ "solc-macos-amd64-list-json": "solc-macos-amd64-list-json" }, "locked": { - "lastModified": 1731758759, - "narHash": "sha256-NX4+V6Q8bwopah0oza/Dpf6UsYNGbokW2kE9qT3wdHY=", + "lastModified": 1742758229, + "narHash": "sha256-FrU9rhab/0vOjjeFoQF+Ej43zRLv3enUIYjgLrH3Gd8=", "owner": "hellwolf", "repo": "solc.nix", - "rev": "0714c24cd521b9eb3ee435818c5d743ac6179176", + "rev": "6885b61bac89da19a6e3c70b89fdd592e2cef884", "type": "github" }, "original": { @@ -218,13 +219,13 @@ "solc-macos-amd64-list-json": { "flake": false, "locked": { - "narHash": "sha256-KBEEpcDeKtVvCeguRP0D499yg9O5Jef9Nxn3yfrmw9g=", + "narHash": "sha256-U5ckttxwKO13gIKggel6iybG5oTDbSidPR5nH3Gs+kY=", "type": "file", - "url": "https://github.com/ethereum/solc-bin/raw/67f45d8/macosx-amd64/list.json" + "url": "https://github.com/ethereum/solc-bin/raw/30a3695/macosx-amd64/list.json" }, "original": { "type": "file", - "url": "https://github.com/ethereum/solc-bin/raw/67f45d8/macosx-amd64/list.json" + "url": "https://github.com/ethereum/solc-bin/raw/30a3695/macosx-amd64/list.json" } }, "systems": { diff --git a/flake.nix b/flake.nix index 1e4499af..d3836d92 100644 --- a/flake.nix +++ b/flake.nix @@ -2,7 +2,8 @@ description = "Flake for development workflows."; inputs = { - rainix.url = "github:rainprotocol/rainix"; + rainix.url = + "github:rainprotocol/rainix?rev=4e87c16f3abcb4e9e309609f452669f5a85bb558"; flake-utils.url = "github:numtide/flake-utils"; }; @@ -11,9 +12,9 @@ let pkgs = rainix.pkgs.${system}; rust-toolchain = rainix.rust-toolchain.${system}; - in rec { - packages = rec { - mkBin = (pkgs.makeRustPlatform{ + in { + packages = { + mkBin = (pkgs.makeRustPlatform { rustc = rust-toolchain; cargo = rust-toolchain; }).buildRustPackage { @@ -30,23 +31,19 @@ mkdir -p $out/bin cp target/release/rain-metadata $out/bin/ ''; - buildInputs = with pkgs; [ - openssl - ]; - nativeBuildInputs = with pkgs; [ - pkg-config - ] ++ lib.optionals stdenv.isDarwin [ - darwin.apple_sdk.frameworks.SystemConfiguration - ]; + buildInputs = with pkgs; [ openssl ]; + nativeBuildInputs = with pkgs; + [ pkg-config ] ++ lib.optionals stdenv.isDarwin + [ darwin.apple_sdk.frameworks.SystemConfiguration ]; }; } // rainix.packages.${system}; devShells.default = pkgs.mkShell { shellHook = rainix.devShells.${system}.default.shellHook; buildInputs = rainix.devShells.${system}.default.buildInputs; - nativeBuildInputs = rainix.devShells.${system}.default.nativeBuildInputs; + nativeBuildInputs = + rainix.devShells.${system}.default.nativeBuildInputs; }; - } - ); + }); } From 1bc940211ceafa1d7c9dd7b115236463e685476e Mon Sep 17 00:00:00 2001 From: 0xgleb Date: Wed, 28 May 2025 22:00:37 +0400 Subject: [PATCH 3/4] fix build config files --- .github/workflows/deploy-subgraph.yaml | 20 +++++++++++++--- .github/workflows/manual-rs-release.yml | 18 +++++++++++++-- .github/workflows/manual-sol-artifacts.yml | 24 ++++++++++++++++---- .github/workflows/manual-subgraph-deploy.yml | 19 +++++++++++++--- .github/workflows/rainix.yaml | 21 +++++++++++++---- .github/workflows/subgraph-test.yaml | 19 +++++++++++++--- Cargo.toml | 7 +----- crates/bindings/Cargo.toml | 1 - crates/cli/Cargo.toml | 1 - crates/metaboard/Cargo.toml | 3 +-- flake.lock | 7 +++--- flake.nix | 3 +-- 12 files changed, 107 insertions(+), 36 deletions(-) diff --git a/.github/workflows/deploy-subgraph.yaml b/.github/workflows/deploy-subgraph.yaml index 83e324b3..353fe1c0 100644 --- a/.github/workflows/deploy-subgraph.yaml +++ b/.github/workflows/deploy-subgraph.yaml @@ -3,7 +3,7 @@ on: workflow_dispatch: inputs: network: - description: 'Network to deploy to' + description: "Network to deploy to" required: true type: choice options: @@ -32,8 +32,22 @@ jobs: submodules: recursive fetch-depth: 0 - - uses: DeterminateSystems/nix-installer-action@main - - uses: DeterminateSystems/magic-nix-cache-action@main + - uses: nixbuild/nix-quick-install-action@v30 + with: + nix_conf: | + keep-env-derivations = true + keep-outputs = true + - name: Restore and save Nix store + uses: nix-community/cache-nix-action@v6 + with: + # restore and save a cache using this key + primary-key: nix-${{ runner.os }}-${{ hashFiles('**/*.nix', '**/flake.lock') }} + # if there's no cache hit, restore a cache by this prefix + restore-prefixes-first-match: nix-${{ runner.os }}- + # collect garbage until the Nix store size (in bytes) is at most this number + # before trying to save a new cache + # 1G = 1073741824 + gc-max-store-size-linux: 1G - run: nix develop -c rainix-sol-prelude diff --git a/.github/workflows/manual-rs-release.yml b/.github/workflows/manual-rs-release.yml index 0b561445..f33f5ac1 100644 --- a/.github/workflows/manual-rs-release.yml +++ b/.github/workflows/manual-rs-release.yml @@ -10,8 +10,22 @@ jobs: fetch-depth: 0 submodules: recursive - - uses: DeterminateSystems/nix-installer-action@v4 - - uses: DeterminateSystems/magic-nix-cache-action@v2 + - uses: nixbuild/nix-quick-install-action@v30 + with: + nix_conf: | + keep-env-derivations = true + keep-outputs = true + - name: Restore and save Nix store + uses: nix-community/cache-nix-action@v6 + with: + # restore and save a cache using this key + primary-key: nix-${{ runner.os }}-${{ hashFiles('**/*.nix', '**/flake.lock') }} + # if there's no cache hit, restore a cache by this prefix + restore-prefixes-first-match: nix-${{ runner.os }}- + # collect garbage until the Nix store size (in bytes) is at most this number + # before trying to save a new cache + # 1G = 1073741824 + gc-max-store-size-linux: 1G - run: | git config --global user.email "${{ secrets.CI_GIT_EMAIL }}" diff --git a/.github/workflows/manual-sol-artifacts.yml b/.github/workflows/manual-sol-artifacts.yml index 1f34f38c..49fcb2f2 100644 --- a/.github/workflows/manual-sol-artifacts.yml +++ b/.github/workflows/manual-sol-artifacts.yml @@ -3,7 +3,7 @@ on: workflow_dispatch: inputs: network: - description: 'Network to deploy to' + description: "Network to deploy to" required: true type: choice options: @@ -41,14 +41,28 @@ jobs: submodules: recursive fetch-depth: 0 - - uses: DeterminateSystems/nix-installer-action@main - - uses: DeterminateSystems/magic-nix-cache-action@main + - uses: nixbuild/nix-quick-install-action@v30 + with: + nix_conf: | + keep-env-derivations = true + keep-outputs = true + - name: Restore and save Nix store + uses: nix-community/cache-nix-action@v6 + with: + # restore and save a cache using this key + primary-key: nix-${{ runner.os }}-${{ hashFiles('**/*.nix', '**/flake.lock') }} + # if there's no cache hit, restore a cache by this prefix + restore-prefixes-first-match: nix-${{ runner.os }}- + # collect garbage until the Nix store size (in bytes) is at most this number + # before trying to save a new cache + # 1G = 1073741824 + gc-max-store-size-linux: 1G - # - run: nix develop --command rainix-sol-prelude + # - run: nix develop --command rainix-sol-prelude - name: deploy to ${{ inputs.network }} run: nix develop --command rainix-sol-artifacts env: - DEPLOY_BROADCAST: '1' + DEPLOY_BROADCAST: "1" DEPLOYMENT_KEY: ${{ github.ref == 'refs/heads/main' && secrets.PRIVATE_KEY || secrets.PRIVATE_KEY_DEV }} ETH_RPC_URL: ${{ secrets[env.rpc_secret_name] || vars[env.rpc_secret_name] || '' }} ETHERSCAN_API_KEY: ${{ secrets[env.etherscan_api_key_secret_name] || vars[env.etherscan_api_key_secret_name] || ''}} diff --git a/.github/workflows/manual-subgraph-deploy.yml b/.github/workflows/manual-subgraph-deploy.yml index 5a73f4a0..c8f4899b 100644 --- a/.github/workflows/manual-subgraph-deploy.yml +++ b/.github/workflows/manual-subgraph-deploy.yml @@ -12,9 +12,22 @@ jobs: fetch-depth: 0 submodules: recursive - - name: Install Nix - uses: DeterminateSystems/nix-installer-action@v4 - - uses: DeterminateSystems/magic-nix-cache-action@v2 + - uses: nixbuild/nix-quick-install-action@v30 + with: + nix_conf: | + keep-env-derivations = true + keep-outputs = true + - name: Restore and save Nix store + uses: nix-community/cache-nix-action@v6 + with: + # restore and save a cache using this key + primary-key: nix-${{ runner.os }}-${{ hashFiles('**/*.nix', '**/flake.lock') }} + # if there's no cache hit, restore a cache by this prefix + restore-prefixes-first-match: nix-${{ runner.os }}- + # collect garbage until the Nix store size (in bytes) is at most this number + # before trying to save a new cache + # 1G = 1073741824 + gc-max-store-size-linux: 1G - run: nix develop --command subgraph-deploy env: diff --git a/.github/workflows/rainix.yaml b/.github/workflows/rainix.yaml index 826bd6d9..a4c369b5 100644 --- a/.github/workflows/rainix.yaml +++ b/.github/workflows/rainix.yaml @@ -29,9 +29,22 @@ jobs: fetch-depth: 0 submodules: recursive - - name: Install Nix - uses: DeterminateSystems/nix-installer-action@v4 - - uses: DeterminateSystems/magic-nix-cache-action@v2 + - uses: nixbuild/nix-quick-install-action@v30 + with: + nix_conf: | + keep-env-derivations = true + keep-outputs = true + - name: Restore and save Nix store + uses: nix-community/cache-nix-action@v6 + with: + # restore and save a cache using this key + primary-key: nix-${{ runner.os }}-${{ hashFiles('**/*.nix', '**/flake.lock') }} + # if there's no cache hit, restore a cache by this prefix + restore-prefixes-first-match: nix-${{ runner.os }}- + # collect garbage until the Nix store size (in bytes) is at most this number + # before trying to save a new cache + # 1G = 1073741824 + gc-max-store-size-linux: 1G - run: nix develop -c rainix-sol-prelude - run: nix develop -c rainix-rs-prelude @@ -42,4 +55,4 @@ jobs: run: nix develop -c ${{ matrix.task }} - name: Build for wasm target - run: nix develop -c cargo build --target wasm32-unknown-unknown \ No newline at end of file + run: nix develop -c cargo build --target wasm32-unknown-unknown diff --git a/.github/workflows/subgraph-test.yaml b/.github/workflows/subgraph-test.yaml index 142f92d6..88f0ee85 100644 --- a/.github/workflows/subgraph-test.yaml +++ b/.github/workflows/subgraph-test.yaml @@ -12,9 +12,22 @@ jobs: fetch-depth: 0 submodules: recursive - - name: Install Nix - uses: DeterminateSystems/nix-installer-action@v4 - - uses: DeterminateSystems/magic-nix-cache-action@v2 + - uses: nixbuild/nix-quick-install-action@v30 + with: + nix_conf: | + keep-env-derivations = true + keep-outputs = true + - name: Restore and save Nix store + uses: nix-community/cache-nix-action@v6 + with: + # restore and save a cache using this key + primary-key: nix-${{ runner.os }}-${{ hashFiles('**/*.nix', '**/flake.lock') }} + # if there's no cache hit, restore a cache by this prefix + restore-prefixes-first-match: nix-${{ runner.os }}- + # collect garbage until the Nix store size (in bytes) is at most this number + # before trying to save a new cache + # 1G = 1073741824 + gc-max-store-size-linux: 1G - name: Build subgraph run: nix develop -c subgraph-build diff --git a/Cargo.toml b/Cargo.toml index f4fd9c62..66473b3e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,13 +1,8 @@ [workspace] resolver = "2" -members = [ - "crates/bindings", - "crates/cli", - "crates/metaboard", -] +members = ["crates/bindings", "crates/cli", "crates/metaboard"] [workspace.package] -author = "Rain Open Source Software Ltd" license = "LicenseRef-DCL-1.0" [workspace.dependencies] diff --git a/crates/bindings/Cargo.toml b/crates/bindings/Cargo.toml index b0a99b58..03cdbdf9 100644 --- a/crates/bindings/Cargo.toml +++ b/crates/bindings/Cargo.toml @@ -4,7 +4,6 @@ version = "0.1.0" edition = "2021" description = "Solidity bindings for rain metadata." license.workspace = true -author.workspace = true repository = "https://github.com/rainlanguage/rain.metadata" [dependencies] diff --git a/crates/cli/Cargo.toml b/crates/cli/Cargo.toml index 57b3b24a..838f5ba3 100644 --- a/crates/cli/Cargo.toml +++ b/crates/cli/Cargo.toml @@ -4,7 +4,6 @@ version = "0.0.2-alpha.6" edition = "2021" description = "Tooling and utilities for RainLanguage metadata." license.workspace = true -author.workspace = true repository = "https://github.com/rainlanguage/rain.metadata" [features] diff --git a/crates/metaboard/Cargo.toml b/crates/metaboard/Cargo.toml index 35d40e3f..3fd60c2a 100644 --- a/crates/metaboard/Cargo.toml +++ b/crates/metaboard/Cargo.toml @@ -4,7 +4,6 @@ version = "0.1.0" edition = "2021" description = "A subgraph client for the Rain Metaboard." license.workspace = true -author.workspace = true repository = "https://github.com/rainlanguage/rain.metadata" [dependencies] @@ -21,4 +20,4 @@ tokio = { workspace = true } serde_json = { workspace = true } [build-dependencies] -cynic-codegen = { version = "3" } \ No newline at end of file +cynic-codegen = { version = "3" } diff --git a/flake.lock b/flake.lock index ebf170a9..09614c3d 100644 --- a/flake.lock +++ b/flake.lock @@ -158,17 +158,16 @@ "solc": "solc" }, "locked": { - "lastModified": 1747832348, - "narHash": "sha256-5t7vMuMk5zZBwaxQudSh0ohKx8SFftlrTKXVojNCqSk=", + "lastModified": 1748346550, + "narHash": "sha256-Rlaj/hHHACo0blFKane6/arqIXWUCGe/sCNgqX8VfZ8=", "owner": "rainprotocol", "repo": "rainix", - "rev": "4e87c16f3abcb4e9e309609f452669f5a85bb558", + "rev": "a1a5c321f356cb5006d16dd2d1a2242c183b7e96", "type": "github" }, "original": { "owner": "rainprotocol", "repo": "rainix", - "rev": "4e87c16f3abcb4e9e309609f452669f5a85bb558", "type": "github" } }, diff --git a/flake.nix b/flake.nix index d3836d92..2f1e63f6 100644 --- a/flake.nix +++ b/flake.nix @@ -2,8 +2,7 @@ description = "Flake for development workflows."; inputs = { - rainix.url = - "github:rainprotocol/rainix?rev=4e87c16f3abcb4e9e309609f452669f5a85bb558"; + rainix.url = "github:rainprotocol/rainix"; flake-utils.url = "github:numtide/flake-utils"; }; From c77cdaee3a378f49191586ffa397d06128721b69 Mon Sep 17 00:00:00 2001 From: 0xgleb Date: Wed, 28 May 2025 22:12:24 +0400 Subject: [PATCH 4/4] fix linting errors --- crates/cli/src/lib.rs | 14 +++++++------- crates/cli/src/meta/mod.rs | 10 +++++----- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/crates/cli/src/lib.rs b/crates/cli/src/lib.rs index 6c66900a..bb9a6621 100644 --- a/crates/cli/src/lib.rs +++ b/crates/cli/src/lib.rs @@ -17,15 +17,15 @@ //! building the binary. //! //! - `cli`: A [mod@clap] based CLI app module for functionalities of this library, this feature -//! has [mod@tokio] dependency with features enabled that are compatible for `wasm` family target builds, -//! Enabling this feature will also enable `json-schema` feature. -//! This feature is required for building the binary crate. +//! has [mod@tokio] dependency with features enabled that are compatible for `wasm` family target builds, +//! Enabling this feature will also enable `json-schema` feature. +//! This feature is required for building the binary crate. //! - `json-schema`: Enables implementation of [Json Schema](schemars::JsonSchema) for different [types] of Rain meta. //! - `tokio-full`: Installs [mod@tokio] with full features which is a dependency of `cli` feature, this -//! allows for multi-threading of the CLI app (binary), however it results in erroneous builds for `wasm` target family -//! as explained in [tokio docs](https://docs.rs/tokio/latest/tokio/#wasm-support).this feature is only effective for -//! binary crate and using it for lib crate just installs a [mod@tokio] with full feature as a dependency as the entire -//! lib crate doesn't depend on [mod@tokio]. This is because [mod@tokio] is only used as a runtime for binray crate. +//! allows for multi-threading of the CLI app (binary), however it results in erroneous builds for `wasm` target family +//! as explained in [tokio docs](https://docs.rs/tokio/latest/tokio/#wasm-support).this feature is only effective for +//! binary crate and using it for lib crate just installs a [mod@tokio] with full feature as a dependency as the entire +//! lib crate doesn't depend on [mod@tokio]. This is because [mod@tokio] is only used as a runtime for binray crate. //! //! ## Example //! ```ignore diff --git a/crates/cli/src/meta/mod.rs b/crates/cli/src/meta/mod.rs index fffbb2f2..ad2872f6 100644 --- a/crates/cli/src/meta/mod.rs +++ b/crates/cli/src/meta/mod.rs @@ -336,7 +336,7 @@ impl<'de> Deserialize<'de> for RainMetaDocumentV1Item { 2 => content_type = Some(map.next_value()?), 3 => content_encoding = Some(map.next_value()?), 4 => content_language = Some(map.next_value()?), - other => Err(serde::de::Error::custom(&format!( + other => Err(serde::de::Error::custom(format!( "found unexpected key in the map: {other}" )))?, }; @@ -805,7 +805,7 @@ impl Store { if let Ok(meta) = search(&hex::encode_prefixed(hash), &self.subgraphs).await { self.store_content(&meta.bytes); self.cache.insert(hash.to_vec(), meta.bytes); - return self.get_meta(hash); + self.get_meta(hash) } else { None } @@ -816,7 +816,7 @@ impl Store { if !self.cache.contains_key(hash) { self.update(hash).await } else { - return self.get_meta(hash); + self.get_meta(hash) } } @@ -827,12 +827,12 @@ impl Store { if keccak256(bytes).0 == hash { self.store_content(bytes); self.cache.insert(hash.to_vec(), bytes.to_vec()); - return self.cache.get(hash); + self.cache.get(hash) } else { None } } else { - return self.get_meta(hash); + self.get_meta(hash) } }