From 0b7f40a3710d00e19b8e3b2d7ad2c8e0fe6de9cb Mon Sep 17 00:00:00 2001 From: Denis Pisarev <denis.pisarev@parity.io> Date: Wed, 2 Jun 2021 22:21:40 +0200 Subject: [PATCH] Move CI from GitHub Actions to GitLab (#814) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * CI: do not trust this CI 1 * CI: don't want to trigger unneded statuses * CI: debug 1 * CI: new CI * CI: temp allow failure * CI: exclude paths * doc: check if docs won't trigger pipelines * doc: check hybrid changes pipeline * doc: do not push excluded files together with others * CI: undebug fmt * CI: better deny * CI: fix deny and spellcheck * CI: global backtrace * CI: deny config * CI: publishing * Dockerfile: metadata fix [skip ci] * CI: revert me * CI: debug bash * CI: mv ci.Dockerfile; fix buildah bug * CI: fix artifact name * Dockerfile: fix context * CI: separate deny check licenses * CI: when to run * CI: unneded stuff in these Dockerfiles * CI: merged test-refs and build-refs * CI: test-build optimizations * CI: changes, web, scheduled pipelines now work as intended * CI: use tested production CI image * CI: substitute GHA * Fix clippy. * Moar clippy fixes. * Fix more. * Finally fix all? Co-authored-by: Tomasz Drwięga <tomasz@parity.io> --- bridges/README.md | 9 +- bridges/modules/dispatch/src/lib.rs | 2 + bridges/modules/ethereum/src/lib.rs | 146 ++++++++---------- bridges/modules/grandpa/src/lib.rs | 2 +- bridges/modules/messages/src/inbound_lane.rs | 61 +++----- bridges/modules/messages/src/lib.rs | 2 + .../finality/src/finality_loop_tests.rs | 6 +- bridges/relays/headers/src/headers.rs | 10 +- .../messages/src/message_race_strategy.rs | 4 +- 9 files changed, 108 insertions(+), 134 deletions(-) diff --git a/bridges/README.md b/bridges/README.md index 84d776c4f8e..f8aabb5ac60 100644 --- a/bridges/README.md +++ b/bridges/README.md @@ -24,14 +24,14 @@ Substrate chains or Ethereum Proof-of-Authority chains. To get up and running you need both stable and nightly Rust. Rust nightly is used to build the Web Assembly (WASM) runtime for the node. You can configure the WASM support as so: -``` +```bash rustup install nightly rustup target add wasm32-unknown-unknown --toolchain nightly ``` Once this is configured you can build and test the repo as follows: -``` +```bash git clone https://github.com/paritytech/parity-bridges-common.git cd parity-bridges-common cargo build --all @@ -49,7 +49,7 @@ and external processes called relayers. A bridge chain is one that is able to fo of a foreign chain independently. For example, consider the case below where we want to bridge two Substrate based chains. -``` +```bash +---------------+ +---------------+ | | | | | Rialto | | Millau | @@ -77,7 +77,7 @@ Here's an overview of how the project is laid out. The main bits are the `node`, "blockchain", the `modules` which are used to build the blockchain's logic (a.k.a the runtime) and the `relays` which are used to pass messages between chains. -``` +```bash ├── bin // Node and Runtime for the various Substrate chains │ └── ... ├── deployments // Useful tools for deploying test networks @@ -103,6 +103,7 @@ To run the Bridge you need to be able to connect the bridge relay node to the RP on each side of the bridge (source and target chain). There are 3 ways to run the bridge, described below: + - building & running from source, - building or using Docker images for each individual component, - running a Docker Compose setup (recommended). diff --git a/bridges/modules/dispatch/src/lib.rs b/bridges/modules/dispatch/src/lib.rs index 7803c1e540e..3a4fb8f87a0 100644 --- a/bridges/modules/dispatch/src/lib.rs +++ b/bridges/modules/dispatch/src/lib.rs @@ -23,6 +23,8 @@ #![cfg_attr(not(feature = "std"), no_std)] #![warn(missing_docs)] +// Generated by `decl_event!` +#![allow(clippy::unused_unit)] use bp_message_dispatch::{CallOrigin, MessageDispatch, MessagePayload, SpecVersion, Weight}; use bp_runtime::{derive_account_id, ChainId, SourceAccount}; diff --git a/bridges/modules/ethereum/src/lib.rs b/bridges/modules/ethereum/src/lib.rs index aeb7d69f763..facf377d51b 100644 --- a/bridges/modules/ethereum/src/lib.rs +++ b/bridges/modules/ethereum/src/lib.rs @@ -1381,15 +1381,12 @@ pub(crate) mod tests { fn verify_transaction_finalized_works_for_best_finalized_header() { run_test_with_genesis(example_header(), TOTAL_VALIDATORS, |_| { let storage = BridgeStorage::<TestRuntime>::new(); - assert_eq!( - verify_transaction_finalized( - &storage, - example_header().compute_hash(), - 0, - &[(example_tx(), example_tx_receipt(true))], - ), - true, - ); + assert!(verify_transaction_finalized( + &storage, + example_header().compute_hash(), + 0, + &[(example_tx(), example_tx_receipt(true))], + )); }); } @@ -1400,15 +1397,12 @@ pub(crate) mod tests { insert_header(&mut storage, example_header_parent()); insert_header(&mut storage, example_header()); storage.finalize_and_prune_headers(Some(example_header().compute_id()), 0); - assert_eq!( - verify_transaction_finalized( - &storage, - example_header_parent().compute_hash(), - 0, - &[(example_tx(), example_tx_receipt(true))], - ), - true, - ); + assert!(verify_transaction_finalized( + &storage, + example_header_parent().compute_hash(), + 0, + &[(example_tx(), example_tx_receipt(true))], + )); }); } @@ -1416,10 +1410,12 @@ pub(crate) mod tests { fn verify_transaction_finalized_rejects_proof_with_missing_tx() { run_test_with_genesis(example_header(), TOTAL_VALIDATORS, |_| { let storage = BridgeStorage::<TestRuntime>::new(); - assert_eq!( - verify_transaction_finalized(&storage, example_header().compute_hash(), 1, &[],), - false, - ); + assert!(!verify_transaction_finalized( + &storage, + example_header().compute_hash(), + 1, + &[], + ),); }); } @@ -1427,10 +1423,12 @@ pub(crate) mod tests { fn verify_transaction_finalized_rejects_unknown_header() { run_test(TOTAL_VALIDATORS, |_| { let storage = BridgeStorage::<TestRuntime>::new(); - assert_eq!( - verify_transaction_finalized(&storage, example_header().compute_hash(), 1, &[],), - false, - ); + assert!(!verify_transaction_finalized( + &storage, + example_header().compute_hash(), + 1, + &[], + )); }); } @@ -1440,15 +1438,12 @@ pub(crate) mod tests { let mut storage = BridgeStorage::<TestRuntime>::new(); insert_header(&mut storage, example_header_parent()); insert_header(&mut storage, example_header()); - assert_eq!( - verify_transaction_finalized( - &storage, - example_header().compute_hash(), - 0, - &[(example_tx(), example_tx_receipt(true))], - ), - false, - ); + assert!(!verify_transaction_finalized( + &storage, + example_header().compute_hash(), + 0, + &[(example_tx(), example_tx_receipt(true))], + )); }); } @@ -1464,15 +1459,12 @@ pub(crate) mod tests { insert_header(&mut storage, example_header()); insert_header(&mut storage, finalized_header_sibling); storage.finalize_and_prune_headers(Some(example_header().compute_id()), 0); - assert_eq!( - verify_transaction_finalized( - &storage, - finalized_header_sibling_hash, - 0, - &[(example_tx(), example_tx_receipt(true))], - ), - false, - ); + assert!(!verify_transaction_finalized( + &storage, + finalized_header_sibling_hash, + 0, + &[(example_tx(), example_tx_receipt(true))], + )); }); } @@ -1488,15 +1480,12 @@ pub(crate) mod tests { insert_header(&mut storage, finalized_header_uncle); insert_header(&mut storage, example_header()); storage.finalize_and_prune_headers(Some(example_header().compute_id()), 0); - assert_eq!( - verify_transaction_finalized( - &storage, - finalized_header_uncle_hash, - 0, - &[(example_tx(), example_tx_receipt(true))], - ), - false, - ); + assert!(!verify_transaction_finalized( + &storage, + finalized_header_uncle_hash, + 0, + &[(example_tx(), example_tx_receipt(true))], + )); }); } @@ -1504,18 +1493,15 @@ pub(crate) mod tests { fn verify_transaction_finalized_rejects_invalid_transactions_in_proof() { run_test_with_genesis(example_header(), TOTAL_VALIDATORS, |_| { let storage = BridgeStorage::<TestRuntime>::new(); - assert_eq!( - verify_transaction_finalized( - &storage, - example_header().compute_hash(), - 0, - &[ - (example_tx(), example_tx_receipt(true)), - (example_tx(), example_tx_receipt(true)) - ], - ), - false, - ); + assert!(!verify_transaction_finalized( + &storage, + example_header().compute_hash(), + 0, + &[ + (example_tx(), example_tx_receipt(true)), + (example_tx(), example_tx_receipt(true)) + ], + )); }); } @@ -1523,15 +1509,12 @@ pub(crate) mod tests { fn verify_transaction_finalized_rejects_invalid_receipts_in_proof() { run_test_with_genesis(example_header(), TOTAL_VALIDATORS, |_| { let storage = BridgeStorage::<TestRuntime>::new(); - assert_eq!( - verify_transaction_finalized( - &storage, - example_header().compute_hash(), - 0, - &[(example_tx(), vec![42])], - ), - false, - ); + assert!(!verify_transaction_finalized( + &storage, + example_header().compute_hash(), + 0, + &[(example_tx(), vec![42])], + )); }); } @@ -1539,15 +1522,12 @@ pub(crate) mod tests { fn verify_transaction_finalized_rejects_failed_transaction() { run_test_with_genesis(example_header_with_failed_receipt(), TOTAL_VALIDATORS, |_| { let storage = BridgeStorage::<TestRuntime>::new(); - assert_eq!( - verify_transaction_finalized( - &storage, - example_header_with_failed_receipt().compute_hash(), - 0, - &[(example_tx(), example_tx_receipt(false))], - ), - false, - ); + assert!(!verify_transaction_finalized( + &storage, + example_header_with_failed_receipt().compute_hash(), + 0, + &[(example_tx(), example_tx_receipt(false))], + )); }); } } diff --git a/bridges/modules/grandpa/src/lib.rs b/bridges/modules/grandpa/src/lib.rs index d38f61826f9..f89950772a6 100644 --- a/bridges/modules/grandpa/src/lib.rs +++ b/bridges/modules/grandpa/src/lib.rs @@ -693,7 +693,7 @@ mod tests { CurrentAuthoritySet::<TestRuntime>::get().authorities, init_data.authority_list ); - assert_eq!(IsHalted::<TestRuntime>::get(), false); + assert!(!IsHalted::<TestRuntime>::get()); }) } diff --git a/bridges/modules/messages/src/inbound_lane.rs b/bridges/modules/messages/src/inbound_lane.rs index b5576bc30a1..f0655f8c958 100644 --- a/bridges/modules/messages/src/inbound_lane.rs +++ b/bridges/modules/messages/src/inbound_lane.rs @@ -291,23 +291,17 @@ mod tests { )); } // Fails to dispatch new message from different than latest relayer. - assert_eq!( - false, - lane.receive_message::<TestMessageDispatch>( - TEST_RELAYER_A + max_nonce + 1, - max_nonce + 1, - message_data(REGULAR_PAYLOAD).into() - ) - ); + assert!(!lane.receive_message::<TestMessageDispatch>( + TEST_RELAYER_A + max_nonce + 1, + max_nonce + 1, + message_data(REGULAR_PAYLOAD).into() + )); // Fails to dispatch new messages from latest relayer. Prevents griefing attacks. - assert_eq!( - false, - lane.receive_message::<TestMessageDispatch>( - TEST_RELAYER_A + max_nonce, - max_nonce + 1, - message_data(REGULAR_PAYLOAD).into() - ) - ); + assert!(!lane.receive_message::<TestMessageDispatch>( + TEST_RELAYER_A + max_nonce, + max_nonce + 1, + message_data(REGULAR_PAYLOAD).into() + )); }); } @@ -324,23 +318,17 @@ mod tests { )); } // Fails to dispatch new message from different than latest relayer. - assert_eq!( - false, - lane.receive_message::<TestMessageDispatch>( - TEST_RELAYER_B, - max_nonce + 1, - message_data(REGULAR_PAYLOAD).into() - ) - ); + assert!(!lane.receive_message::<TestMessageDispatch>( + TEST_RELAYER_B, + max_nonce + 1, + message_data(REGULAR_PAYLOAD).into() + )); // Fails to dispatch new messages from latest relayer. - assert_eq!( - false, - lane.receive_message::<TestMessageDispatch>( - TEST_RELAYER_A, - max_nonce + 1, - message_data(REGULAR_PAYLOAD).into() - ) - ); + assert!(!lane.receive_message::<TestMessageDispatch>( + TEST_RELAYER_A, + max_nonce + 1, + message_data(REGULAR_PAYLOAD).into() + )); }); } @@ -379,10 +367,11 @@ mod tests { 1, message_data(REGULAR_PAYLOAD).into() )); - assert_eq!( - false, - lane.receive_message::<TestMessageDispatch>(TEST_RELAYER_B, 1, message_data(REGULAR_PAYLOAD).into()) - ); + assert!(!lane.receive_message::<TestMessageDispatch>( + TEST_RELAYER_B, + 1, + message_data(REGULAR_PAYLOAD).into() + )); }); } diff --git a/bridges/modules/messages/src/lib.rs b/bridges/modules/messages/src/lib.rs index 9e2563498fe..03f4b0ed749 100644 --- a/bridges/modules/messages/src/lib.rs +++ b/bridges/modules/messages/src/lib.rs @@ -34,6 +34,8 @@ //! or some benchmarks assumptions are broken for your runtime. #![cfg_attr(not(feature = "std"), no_std)] +// Generated by `decl_event!` +#![allow(clippy::unused_unit)] pub use crate::weights_ext::{ ensure_able_to_receive_confirmation, ensure_able_to_receive_message, ensure_weights_are_correct, WeightInfoExt, diff --git a/bridges/relays/finality/src/finality_loop_tests.rs b/bridges/relays/finality/src/finality_loop_tests.rs index f7826ead730..72b3cdde3d2 100644 --- a/bridges/relays/finality/src/finality_loop_tests.rs +++ b/bridges/relays/finality/src/finality_loop_tests.rs @@ -342,7 +342,7 @@ fn read_finality_proofs_from_stream_works() { let mut stream = futures::stream::pending().into(); read_finality_proofs_from_stream::<TestFinalitySyncPipeline, _>(&mut stream, &mut recent_finality_proofs); assert_eq!(recent_finality_proofs, vec![(1, TestFinalityProof(1))]); - assert_eq!(stream.needs_restart, false); + assert!(!stream.needs_restart); // when stream has entry with target, it is added to the recent proofs container let mut stream = futures::stream::iter(vec![TestFinalityProof(4)]) @@ -353,7 +353,7 @@ fn read_finality_proofs_from_stream_works() { recent_finality_proofs, vec![(1, TestFinalityProof(1)), (4, TestFinalityProof(4))] ); - assert_eq!(stream.needs_restart, false); + assert!(!stream.needs_restart); // when stream has ended, we'll need to restart it let mut stream = futures::stream::empty().into(); @@ -362,7 +362,7 @@ fn read_finality_proofs_from_stream_works() { recent_finality_proofs, vec![(1, TestFinalityProof(1)), (4, TestFinalityProof(4))] ); - assert_eq!(stream.needs_restart, true); + assert!(stream.needs_restart); } #[test] diff --git a/bridges/relays/headers/src/headers.rs b/bridges/relays/headers/src/headers.rs index be3e2cb6e6d..63dfbe583c4 100644 --- a/bridges/relays/headers/src/headers.rs +++ b/bridges/relays/headers/src/headers.rs @@ -1505,7 +1505,7 @@ pub(crate) mod tests { let mut queue = QueuedHeaders::<TestHeadersSyncPipeline>::default(); // when we do not know header itself - assert_eq!(queue.is_parent_incomplete(&id(50)), false); + assert!(!queue.is_parent_incomplete(&id(50))); // when we do not know parent queue @@ -1514,7 +1514,7 @@ pub(crate) mod tests { .or_default() .insert(hash(100), HeaderStatus::Incomplete); queue.incomplete.entry(100).or_default().insert(hash(100), header(100)); - assert_eq!(queue.is_parent_incomplete(&id(100)), false); + assert!(!queue.is_parent_incomplete(&id(100))); // when parent is inside incomplete queue (i.e. some other ancestor is actually incomplete) queue @@ -1523,7 +1523,7 @@ pub(crate) mod tests { .or_default() .insert(hash(101), HeaderStatus::Submitted); queue.submitted.entry(101).or_default().insert(hash(101), header(101)); - assert_eq!(queue.is_parent_incomplete(&id(101)), true); + assert!(queue.is_parent_incomplete(&id(101))); // when parent is the incomplete header and we do not have completion data queue.incomplete_headers.insert(id(199), None); @@ -1533,7 +1533,7 @@ pub(crate) mod tests { .or_default() .insert(hash(200), HeaderStatus::Submitted); queue.submitted.entry(200).or_default().insert(hash(200), header(200)); - assert_eq!(queue.is_parent_incomplete(&id(200)), true); + assert!(queue.is_parent_incomplete(&id(200))); // when parent is the incomplete header and we have completion data queue.completion_data.insert(id(299), 299_299); @@ -1543,7 +1543,7 @@ pub(crate) mod tests { .or_default() .insert(hash(300), HeaderStatus::Submitted); queue.submitted.entry(300).or_default().insert(hash(300), header(300)); - assert_eq!(queue.is_parent_incomplete(&id(300)), true); + assert!(queue.is_parent_incomplete(&id(300))); } #[test] diff --git a/bridges/relays/messages/src/message_race_strategy.rs b/bridges/relays/messages/src/message_race_strategy.rs index 7088f8d74b5..394574ecb44 100644 --- a/bridges/relays/messages/src/message_race_strategy.rs +++ b/bridges/relays/messages/src/message_race_strategy.rs @@ -318,9 +318,9 @@ mod tests { #[test] fn strategy_is_empty_works() { let mut strategy = BasicStrategy::<TestMessageLane>::new(); - assert_eq!(strategy.is_empty(), true); + assert!(strategy.is_empty()); strategy.source_nonces_updated(header_id(1), source_nonces(1..=1)); - assert_eq!(strategy.is_empty(), false); + assert!(!strategy.is_empty()); } #[test] -- GitLab