diff --git a/.github/workflows/publish-ghcr.yaml.yml b/.github/workflows/publish-ghcr.yaml.yml index 8e671098..687f09eb 100644 --- a/.github/workflows/publish-ghcr.yaml.yml +++ b/.github/workflows/publish-ghcr.yaml.yml @@ -2,7 +2,7 @@ name: Build and Push to GHCR on: push: - branches: [master] + branches: [master, staging] env: GHCR_IMAGE: ghcr.io/${{ secrets.GHCR_USERNAME }}/${{ github.event.repository.name }} @@ -41,13 +41,12 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - - name: Checkout code - uses: actions/checkout@v6 - - name: Build and push by digest id: build uses: docker/build-push-action@v6 with: + build-args: | + BUILDKIT_CONTEXT_KEEP_GIT_DIR=1 provenance: false # Disable provenance to avoid unknown/unknown sbom: false # Disable sbom to avoid unknown/unknown platforms: ${{ matrix.platform }} @@ -98,7 +97,15 @@ jobs: - name: Generate image tag id: vars - run: echo "tag=$(awk -F'"' '/^version/{ print $2; exit; }' Cargo.toml)" >> $GITHUB_OUTPUT + run: | + version=$(awk -F'"' '/^version/{ print $2; exit; }' Cargo.toml) + if ${{ github.ref_name == 'master' }}; then + echo "version=$version" >> $GITHUB_OUTPUT + echo "tag=latest" >> $GITHUB_OUTPUT + else + echo "version=${version}-staging" >> $GITHUB_OUTPUT + echo "tag=staging" >> $GITHUB_OUTPUT + fi - name: Docker meta id: meta @@ -106,8 +113,8 @@ jobs: with: images: ${{ env.GHCR_IMAGE }} tags: | + type=raw,value=${{ steps.vars.outputs.version }},enable=true type=raw,value=${{ steps.vars.outputs.tag }},enable=true - type=raw,value=latest,enable=true - name: Create manifest list and push working-directory: ${{ runner.temp }}/digests diff --git a/Cargo.lock b/Cargo.lock index 2b8bc7c4..41694a2b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1110,6 +1110,7 @@ name = "grin_p2p" version = "5.4.0" dependencies = [ "bitflags 1.3.2", + "built", "bytes 0.5.6", "chrono", "enum_primitive", diff --git a/Cargo.toml b/Cargo.toml index b4b26e16..c8e43720 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,7 @@ keywords = [ "crypto", "grin", "mimblewimble" ] readme = "README.md" exclude = ["**/*.grin", "**/*.grin2"] build = "src/build/build.rs" -edition = "2018" +edition = "2021" [workspace] members = ["api", "chain", "config", "core", "keychain", "p2p", "servers", "store", "util", "pool"] diff --git a/api/Cargo.toml b/api/Cargo.toml index 88af1575..e87d0b4f 100644 --- a/api/Cargo.toml +++ b/api/Cargo.toml @@ -7,7 +7,7 @@ license = "Apache-2.0" repository = "https://github.com/mimblewimble/grin" keywords = [ "crypto", "grin", "mimblewimble" ] workspace = ".." -edition = "2018" +edition = "2021" [dependencies] easy-jsonrpc-mw = "0.5.4" diff --git a/api/src/types.rs b/api/src/types.rs index 4d319405..06918262 100644 --- a/api/src/types.rs +++ b/api/src/types.rs @@ -95,7 +95,7 @@ impl Status { Status { chain: global::get_chain_type().shortname(), protocol_version: ser::ProtocolVersion::local().into(), - user_agent: p2p::msg::USER_AGENT.to_string(), + user_agent: p2p::msg::user_agent().to_string(), connections: connections, tip: Tip::from_tip(current_tip), sync_status, @@ -465,7 +465,8 @@ impl<'de> serde::de::Deserialize<'de> for OutputPrintable { } if output_type.is_none() - || commit.is_none() || spent.is_none() + || commit.is_none() + || spent.is_none() || proof_hash.is_none() || mmr_index.is_none() { diff --git a/chain/Cargo.toml b/chain/Cargo.toml index c9fab243..3b930231 100644 --- a/chain/Cargo.toml +++ b/chain/Cargo.toml @@ -7,7 +7,7 @@ license = "Apache-2.0" repository = "https://github.com/mimblewimble/grin" keywords = [ "crypto", "grin", "mimblewimble" ] workspace = ".." -edition = "2018" +edition = "2021" [dependencies] bit-vec = "0.6" diff --git a/config/Cargo.toml b/config/Cargo.toml index 5700ea18..c7ea4743 100644 --- a/config/Cargo.toml +++ b/config/Cargo.toml @@ -7,7 +7,7 @@ license = "Apache-2.0" repository = "https://github.com/mimblewimble/grin" keywords = [ "crypto", "grin", "mimblewimble" ] workspace = ".." -edition = "2018" +edition = "2021" [dependencies] rand = "0.6" diff --git a/core/Cargo.toml b/core/Cargo.toml index e9229e2f..40798834 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -7,7 +7,7 @@ license = "Apache-2.0" repository = "https://github.com/mimblewimble/grin" keywords = [ "crypto", "grin", "mimblewimble" ] workspace = ".." -edition = "2018" +edition = "2021" [dependencies] blake2 = { package = "blake2-rfc", version = "0.2"} diff --git a/core/fuzz/Cargo.toml b/core/fuzz/Cargo.toml index 158391ad..1cf4ffdb 100644 --- a/core/fuzz/Cargo.toml +++ b/core/fuzz/Cargo.toml @@ -3,7 +3,7 @@ name = "grin_core-fuzz" version = "0.0.3" authors = ["Grin Developers "] publish = false -edition = "2018" +edition = "2021" [dependencies] libfuzzer-sys = "0.4.0" diff --git a/core/src/pow/cuckaroo.rs b/core/src/pow/cuckaroo.rs index 05e42f36..1cb62d7c 100644 --- a/core/src/pow/cuckaroo.rs +++ b/core/src/pow/cuckaroo.rs @@ -71,7 +71,7 @@ impl PoWContext for CuckarooContext { let mut xor0: u64 = 0; let mut xor1: u64 = 0; let mask = u64::MAX >> (size as u64).leading_zeros(); // round size up to 2-power - 1 - // the next three arrays form a linked list of nodes with matching bits 6..1 + // the next three arrays form a linked list of nodes with matching bits 6..1 let mut headu = vec![2 * size; 1 + mask as usize]; let mut headv = vec![2 * size; 1 + mask as usize]; let mut prev = vec![0usize; 2 * size]; diff --git a/core/src/pow/cuckarood.rs b/core/src/pow/cuckarood.rs index ed4c73f1..1e6e5b68 100644 --- a/core/src/pow/cuckarood.rs +++ b/core/src/pow/cuckarood.rs @@ -66,7 +66,7 @@ impl PoWContext for CuckaroodContext { let mut xor0: u64 = 0; let mut xor1: u64 = 0; let mask = u64::MAX >> (size as u64).leading_zeros(); // round size up to 2-power - 1 - // the next two arrays form a linked list of nodes with matching bits 4..0|dir + // the next two arrays form a linked list of nodes with matching bits 4..0|dir let mut headu = vec![2 * size; 1 + mask as usize]; let mut headv = vec![2 * size; 1 + mask as usize]; let mut prev = vec![0usize; 2 * size]; diff --git a/core/src/pow/cuckaroom.rs b/core/src/pow/cuckaroom.rs index 82fc031d..28fe1d56 100644 --- a/core/src/pow/cuckaroom.rs +++ b/core/src/pow/cuckaroom.rs @@ -65,7 +65,7 @@ impl PoWContext for CuckaroomContext { let mut xor_from: u64 = 0; let mut xor_to: u64 = 0; let mask = u64::MAX >> (size as u64).leading_zeros(); // round size up to 2-power - 1 - // the next two arrays form a linked list of nodes with matching bits 6..1 + // the next two arrays form a linked list of nodes with matching bits 6..1 let mut head = vec![size; 1 + mask as usize]; let mut prev = vec![0usize; size]; diff --git a/core/src/pow/cuckarooz.rs b/core/src/pow/cuckarooz.rs index 5705a530..2a179627 100644 --- a/core/src/pow/cuckarooz.rs +++ b/core/src/pow/cuckarooz.rs @@ -64,7 +64,7 @@ impl PoWContext for CuckaroozContext { let mut uvs = vec![0u64; 2 * size]; let mut xoruv: u64 = 0; let mask = u64::MAX >> (size as u64).leading_zeros(); // round size up to 2-power - 1 - // the next two arrays form a linked list of nodes with matching bits 6..1 + // the next two arrays form a linked list of nodes with matching bits 6..1 let mut head = vec![2 * size; 1 + mask as usize]; let mut prev = vec![0usize; 2 * size]; diff --git a/core/tests/core.rs b/core/tests/core.rs index f2d6d32d..b0e35ace 100644 --- a/core/tests/core.rs +++ b/core/tests/core.rs @@ -244,7 +244,6 @@ fn transaction_cut_through() { let tx1 = tx1i2o(); let tx2 = tx2i1o(); - assert!(tx1.validate(Weighting::AsTransaction).is_ok()); assert!(tx2.validate(Weighting::AsTransaction).is_ok()); @@ -277,17 +276,12 @@ fn multi_kernel_transaction_deaggregation() { assert!(tx34.validate(Weighting::AsTransaction).is_ok()); let deaggregated_tx34 = deaggregate(tx1234.clone(), &[tx12.clone()]).unwrap(); - assert!(deaggregated_tx34 - .validate(Weighting::AsTransaction) - - .is_ok()); + assert!(deaggregated_tx34.validate(Weighting::AsTransaction).is_ok()); assert_eq!(tx34, deaggregated_tx34); let deaggregated_tx12 = deaggregate(tx1234, &[tx34]).unwrap(); - assert!(deaggregated_tx12 - .validate(Weighting::AsTransaction) - .is_ok()); + assert!(deaggregated_tx12.validate(Weighting::AsTransaction).is_ok()); assert_eq!(tx12, deaggregated_tx12); } @@ -309,9 +303,7 @@ fn multi_kernel_transaction_deaggregation_2() { assert!(tx12.validate(Weighting::AsTransaction).is_ok()); let deaggregated_tx3 = deaggregate(tx123, &[tx12]).unwrap(); - assert!(deaggregated_tx3 - .validate(Weighting::AsTransaction) - .is_ok()); + assert!(deaggregated_tx3.validate(Weighting::AsTransaction).is_ok()); assert_eq!(tx3, deaggregated_tx3); } @@ -334,9 +326,7 @@ fn multi_kernel_transaction_deaggregation_3() { assert!(tx2.validate(Weighting::AsTransaction).is_ok()); let deaggregated_tx13 = deaggregate(tx123, &[tx2]).unwrap(); - assert!(deaggregated_tx13 - .validate(Weighting::AsTransaction) - .is_ok()); + assert!(deaggregated_tx13.validate(Weighting::AsTransaction).is_ok()); assert_eq!(tx13, deaggregated_tx13); } @@ -366,9 +356,7 @@ fn multi_kernel_transaction_deaggregation_4() { assert!(tx12345.validate(Weighting::AsTransaction).is_ok()); let deaggregated_tx5 = deaggregate(tx12345, &[tx1, tx2, tx3, tx4]).unwrap(); - assert!(deaggregated_tx5 - .validate(Weighting::AsTransaction) - .is_ok()); + assert!(deaggregated_tx5.validate(Weighting::AsTransaction).is_ok()); assert_eq!(tx5, deaggregated_tx5); } @@ -401,9 +389,7 @@ fn multi_kernel_transaction_deaggregation_5() { assert!(tx12345.validate(Weighting::AsTransaction).is_ok()); let deaggregated_tx5 = deaggregate(tx12345, &[tx12, tx34]).unwrap(); - assert!(deaggregated_tx5 - .validate(Weighting::AsTransaction) - .is_ok()); + assert!(deaggregated_tx5.validate(Weighting::AsTransaction).is_ok()); assert_eq!(tx5, deaggregated_tx5); } @@ -424,16 +410,12 @@ fn basic_transaction_deaggregation() { let deaggregated_tx1 = deaggregate(tx3.clone(), &[tx2.clone()]).unwrap(); - assert!(deaggregated_tx1 - .validate(Weighting::AsTransaction) - .is_ok()); + assert!(deaggregated_tx1.validate(Weighting::AsTransaction).is_ok()); assert_eq!(tx1, deaggregated_tx1); let deaggregated_tx2 = deaggregate(tx3, &[tx1]).unwrap(); - assert!(deaggregated_tx2 - .validate(Weighting::AsTransaction) - .is_ok()); + assert!(deaggregated_tx2.validate(Weighting::AsTransaction).is_ok()); assert_eq!(tx2, deaggregated_tx2); } @@ -558,8 +540,7 @@ fn reward_with_tx_block() { let tx1 = tx2i1o(); let previous_header = BlockHeader::default(); - tx1.validate(Weighting::AsTransaction) - .unwrap(); + tx1.validate(Weighting::AsTransaction).unwrap(); let block = new_block(&[tx1], &keychain, &builder, &previous_header, &key_id); block.validate(&BlindingFactor::zero()).unwrap(); diff --git a/etc/gen_gen/_Cargo.toml b/etc/gen_gen/_Cargo.toml index f053cda1..ba53139b 100644 --- a/etc/gen_gen/_Cargo.toml +++ b/etc/gen_gen/_Cargo.toml @@ -1,7 +1,7 @@ [package] name = "grin_gen_gen" version = "0.0.1" -edition = "2018" +edition = "2021" authors = ["Grin Developers "] description = "Utility to automate the generation of Grin's genesis block" license = "Apache-2.0" diff --git a/keychain/Cargo.toml b/keychain/Cargo.toml index 2d46b63d..1a7d1950 100644 --- a/keychain/Cargo.toml +++ b/keychain/Cargo.toml @@ -7,7 +7,7 @@ license = "Apache-2.0" repository = "https://github.com/mimblewimble/grin" keywords = [ "crypto", "grin", "mimblewimble" ] workspace = '..' -edition = "2018" +edition = "2021" [dependencies] byteorder = "1" diff --git a/p2p/Cargo.toml b/p2p/Cargo.toml index 274a07d4..69a2ca43 100644 --- a/p2p/Cargo.toml +++ b/p2p/Cargo.toml @@ -7,7 +7,8 @@ license = "Apache-2.0" repository = "https://github.com/mimblewimble/grin" keywords = [ "crypto", "grin", "mimblewimble" ] workspace = ".." -edition = "2018" +edition = "2021" +build = "src/build/build.rs" [dependencies] bitflags = "1" @@ -29,3 +30,6 @@ grin_chain = { path = "../chain", version = "5.4.0" } [dev-dependencies] grin_pool = { path = "../pool", version = "5.4.0" } + +[build-dependencies] +built = { version = "0.8.0", features = ["git2"]} \ No newline at end of file diff --git a/p2p/src/build/build.rs b/p2p/src/build/build.rs new file mode 100644 index 00000000..cd3cb975 --- /dev/null +++ b/p2p/src/build/build.rs @@ -0,0 +1,28 @@ +// Copyright 2026 The Grin Developers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//! Build hooks to spit out version info + +use std::env; +use std::path::Path; + +fn main() { + // build and versioning information + let out_dir_path = format!("{}{}", env::var("OUT_DIR").unwrap(), "/built.rs"); + // don't fail the build if something's missing, may just be cargo release + let _ = built::write_built_file_with_opts( + Some(Path::new(env!("CARGO_MANIFEST_DIR"))), + Path::new(&out_dir_path), + ); +} diff --git a/p2p/src/handshake.rs b/p2p/src/handshake.rs index 25855eff..c5feb345 100644 --- a/p2p/src/handshake.rs +++ b/p2p/src/handshake.rs @@ -16,7 +16,7 @@ use crate::conn::Tracker; use crate::core::core::hash::Hash; use crate::core::pow::Difficulty; use crate::core::ser::ProtocolVersion; -use crate::msg::{read_message, write_message, Hand, Msg, Shake, Type, USER_AGENT}; +use crate::msg::{read_message, user_agent, write_message, Hand, Msg, Shake, Type}; use crate::peer::Peer; use crate::types::{Capabilities, Direction, Error, P2PConfig, PeerAddr, PeerInfo, PeerLiveInfo}; use crate::util::RwLock; @@ -120,7 +120,7 @@ impl Handshake { total_difficulty, sender_addr: self_addr, receiver_addr: peer_addr, - user_agent: USER_AGENT.to_string(), + user_agent: user_agent().to_string(), }; // write and read the handshake response @@ -225,7 +225,7 @@ impl Handshake { capabilities: capab, genesis: self.genesis, total_difficulty: total_difficulty, - user_agent: USER_AGENT.to_string(), + user_agent: user_agent().to_string(), }; let msg = Msg::new(Type::Shake, shake, negotiated_version)?; diff --git a/p2p/src/msg.rs b/p2p/src/msg.rs index 3103db09..69c448e9 100644 --- a/p2p/src/msg.rs +++ b/p2p/src/msg.rs @@ -40,8 +40,19 @@ use std::io::{Read, Write}; use std::sync::Arc; use std::{fmt, thread, time::Duration}; +// include build information +pub mod built_info { + include!(concat!(env!("OUT_DIR"), "/built.rs")); +} + /// Grin's user agent with current version -pub const USER_AGENT: &str = concat!("MW/Grin ", env!("CARGO_PKG_VERSION")); +pub fn user_agent() -> String { + format!( + "MW/Grin {}{}", + env!("CARGO_PKG_VERSION"), + built_info::GIT_COMMIT_HASH_SHORT.map_or_else(|| "".to_owned(), |v| ".".to_owned() + v) + ) +} /// Magic numbers expected in the header of every message const OTHER_MAGIC: [u8; 2] = [73, 43]; diff --git a/p2p/tests/peer_handshake.rs b/p2p/tests/peer_handshake.rs index c4f16c55..e79d2e37 100644 --- a/p2p/tests/peer_handshake.rs +++ b/p2p/tests/peer_handshake.rs @@ -25,6 +25,7 @@ use std::{thread, time}; use crate::core::core::hash::Hash; use crate::core::global; use crate::core::pow::Difficulty; +use crate::p2p::msg::built_info; use crate::p2p::types::PeerAddr; use crate::p2p::Peer; @@ -88,7 +89,12 @@ fn peer_handshake() { ) .unwrap(); - assert!(peer.info.user_agent.ends_with(env!("CARGO_PKG_VERSION"))); + let git_hash = + built_info::GIT_COMMIT_HASH_SHORT.map_or_else(|| "".to_owned(), |v| ".".to_owned() + v); + assert!(peer + .info + .user_agent + .ends_with(format!("{}{}", env!("CARGO_PKG_VERSION"), git_hash).as_str())); thread::sleep(time::Duration::from_secs(1)); diff --git a/pool/Cargo.toml b/pool/Cargo.toml index 3b0f77ad..8ff37d24 100644 --- a/pool/Cargo.toml +++ b/pool/Cargo.toml @@ -7,7 +7,7 @@ license = "Apache-2.0" repository = "https://github.com/mimblewimble/grin" keywords = [ "crypto", "grin", "mimblewimble" ] workspace = '..' -edition = "2018" +edition = "2021" [dependencies] blake2-rfc = "0.2" diff --git a/pool/fuzz/Cargo.toml b/pool/fuzz/Cargo.toml index a10d61a7..c0aacd1f 100644 --- a/pool/fuzz/Cargo.toml +++ b/pool/fuzz/Cargo.toml @@ -3,7 +3,7 @@ name = "grin_pool_fuzz" version = "0.0.0" authors = ["Automatically generated"] publish = false -edition = "2018" +edition = "2021" [dependencies] chrono = "0.4.11" diff --git a/pool/src/pool.rs b/pool/src/pool.rs index 3e470b16..f0dbe389 100644 --- a/pool/src/pool.rs +++ b/pool/src/pool.rs @@ -402,9 +402,7 @@ where // Otherwise discard and let the next block pick this tx up. let bucket = &tx_buckets[pos]; - if let Ok(new_bucket) = - bucket.aggregate_with_tx(entry.tx.clone(), weighting) - { + if let Ok(new_bucket) = bucket.aggregate_with_tx(entry.tx.clone(), weighting) { if new_bucket.fee_rate >= bucket.fee_rate { // Only aggregate if it would not reduce the fee_rate ratio. tx_buckets[pos] = new_bucket; diff --git a/rustfmt.toml b/rustfmt.toml index b2b24311..c691d12a 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -1,2 +1,2 @@ hard_tabs = true -edition = "2018" +edition = "2021" diff --git a/servers/Cargo.toml b/servers/Cargo.toml index a9a6978a..9a795051 100644 --- a/servers/Cargo.toml +++ b/servers/Cargo.toml @@ -7,7 +7,7 @@ license = "Apache-2.0" repository = "https://github.com/mimblewimble/grin" keywords = [ "crypto", "grin", "mimblewimble" ] workspace = ".." -edition = "2018" +edition = "2021" [dependencies] hyper = { version = "0.14", features = ["full"] } diff --git a/servers/src/grin/seed.rs b/servers/src/grin/seed.rs index ecc496f1..3d5fe8d8 100644 --- a/servers/src/grin/seed.rs +++ b/servers/src/grin/seed.rs @@ -33,22 +33,20 @@ use crate::p2p::types::PeerAddr; use crate::p2p::ChainAdapter; use crate::util::StopState; -/// DNS Seeds with contact email associated - Mainnet +/// DNS Seeds with contacts associated - Mainnet pub const MAINNET_DNS_SEEDS: &[&str] = &[ - "mainnet.seed.grin.lesceller.com", // q.lesceller@gmail.com - "mainnet.seed.grin.prokapi.com", // hendi@prokapi.com - "grinseed.revcore.net", // yeastplume@gmail.com - "mainnet-seed.grinnode.live", // info@grinnode.live - "mainnet.grin.punksec.de", // grin@punksec.de - "grinnode.30-r.com", // trinitron@30-r.com + "mainnet-seed.grinnode.live", // info@grinnode.live + "grincoin.org", // xmpp:aglkm@conversations.im + "main.gri.mw", // admin@gri.mw + "mainnet.grinffindor.org", // support@grinffindor.org + "main-seed.grin.money", // support@grinily.com ]; -/// DNS Seeds with contact email associated - Testnet +/// DNS Seeds with contacts associated - Testnet pub const TESTNET_DNS_SEEDS: &[&str] = &[ - "floonet.seed.grin.lesceller.com", // q.lesceller@gmail.com - "floonet.seed.grin.prokapi.com", // hendi@prokapi.com - "grintestseed.revcore.net", // yeastplume@gmail.com - "testnet.grin.punksec.de", // grin@punksec.de - "testnet.grinnode.30-r.com", // trinitron@30-r.com + "testnet.grincoin.org", // xmpp:aglkm@conversations.im + "test.gri.mw", // admin@gri.mw + "testnet.grinffindor.org", // support@grinffindor.org + "test-seed.grin.money", // support@grinily.com ]; pub fn connect_and_monitor( diff --git a/src/bin/grin.rs b/src/bin/grin.rs index 8d847fec..168e5e6e 100644 --- a/src/bin/grin.rs +++ b/src/bin/grin.rs @@ -55,7 +55,7 @@ pub fn info_strings() -> (String, String) { format!( "This is Grin version {}{}, built for {} by {}.", built_info::PKG_VERSION, - built_info::GIT_VERSION.map_or_else(|| "".to_owned(), |v| format!(" (git {})", v)), + built_info::GIT_COMMIT_HASH.map_or_else(|| "".to_owned(), |v| format!(" (git {})", v)), built_info::TARGET, built_info::RUSTC_VERSION, ), diff --git a/staging-test.txt b/staging-test.txt new file mode 100644 index 00000000..bfc5aa8e --- /dev/null +++ b/staging-test.txt @@ -0,0 +1 @@ +staging test diff --git a/store/Cargo.toml b/store/Cargo.toml index 9654cc1f..f3568224 100644 --- a/store/Cargo.toml +++ b/store/Cargo.toml @@ -7,7 +7,7 @@ license = "Apache-2.0" repository = "https://github.com/mimblewimble/grin" keywords = [ "crypto", "grin", "mimblewimble" ] workspace = ".." -edition = "2018" +edition = "2021" [dependencies] byteorder = "1" diff --git a/util/Cargo.toml b/util/Cargo.toml index 978b5568..a20a9759 100644 --- a/util/Cargo.toml +++ b/util/Cargo.toml @@ -7,7 +7,7 @@ license = "Apache-2.0" repository = "https://github.com/mimblewimble/grin" keywords = [ "crypto", "grin", "mimblewimble" ] workspace = ".." -edition = "2018" +edition = "2021" [dependencies] anyhow = "1.0" diff --git a/util/src/zip.rs b/util/src/zip.rs index 967738ef..7e436c1e 100644 --- a/util/src/zip.rs +++ b/util/src/zip.rs @@ -24,16 +24,16 @@ use zip as zip_rs; // Sanitize file path for normal components, excluding '/', '..', and '.' // From private function in zip crate fn path_to_string(path: &std::path::Path) -> String { - let mut path_str = String::new(); - for component in path.components() { - if let std::path::Component::Normal(os_str) = component { - if !path_str.is_empty() { - path_str.push('/'); - } - path_str.push_str(&*os_str.to_string_lossy()); - } - } - path_str + let mut path_str = String::new(); + for component in path.components() { + if let std::path::Component::Normal(os_str) = component { + if !path_str.is_empty() { + path_str.push('/'); + } + path_str.push_str(&*os_str.to_string_lossy()); + } + } + path_str } /// Create a zip archive from source dir and list of relative file paths.