-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
506 switch to stable rust toolchain channel #513
Conversation
# Call `rustup show` as a hack so that the toolchain defined in rust-toolchain.toml is installed | ||
run: rustup show | ||
|
||
- name: Remove rust-toolchain.toml for nightly |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Installing the nightly (and even setting it to default) will still be overriden by the rust-toolchain.toml file, hence it needs to be removed.
See /~https://github.com/pendulum-chain/spacewalk/actions/runs/8751187110/job/24020665297#step:9:33
args: --all-features --tests --benches --examples -- -A clippy::all -W clippy::correctness -A forgetting_copy_types -A forgetting_references |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we cannot use --all-targets
here because the test
must use the nightly version, while the lib
s and bin
s must use the stable version
@@ -183,6 +183,7 @@ impl Runner { | |||
// The set permissions are: -rwx------ | |||
.mode(0o700) | |||
.create(true) | |||
.truncate(true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a warning popped up on nightly version 2024-02-09
. truncate(true)
was suggested.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a good suggestion. I just checked at the docs for this option and it will essentially ensure that the opened file is clean, which is what we want since we will save the new binary in there.
In any case at the end of the operation the checksums will be compared, just in case.
@@ -515,10 +513,6 @@ impl RunnerExt for Runner { | |||
&self.opts.download_path | |||
} | |||
|
|||
fn parachain_url(&self) -> String { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was found to be unused. I also checked, and found it unused anywhere in the code. Please confirm @gianfra-t
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We remove some logic from the original runner code, so it makes sense that some methods are not used. I think it is fine!
@@ -568,10 +562,6 @@ impl RunnerExt for Runner { | |||
Runner::try_load_downloaded_binary(self, release) | |||
} | |||
|
|||
async fn get_request_bytes_wrapper(&self, url: String) -> Result<Bytes, Error> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also I think it is fine to remove.
@@ -80,7 +80,7 @@ async fn read_message_from_stellar(connector: &mut Connector) -> Result<Xdr, Err | |||
// 1. the length of the next stellar message | |||
// 2. the remaining bytes of the previous stellar message | |||
match connector.tcp_stream.read(&mut buff_for_reading).await { | |||
Ok(size) if size == 0 => continue, | |||
Ok(0) => continue, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion from version nightly-2024-02-09
@@ -35,8 +35,7 @@ const BASE_BACKOFF_DELAY_IN_SECS: u64 = 10; | |||
pub fn horizon_url(is_public_network: bool, is_need_fallback: bool) -> &'static str { | |||
if is_public_network { | |||
if is_need_fallback { | |||
let other_urls = | |||
vec!["https://horizon.stellarx.com", "https://horizon.stellar.lobstr.co"]; | |||
let other_urls = ["https://horizon.stellarx.com", "https://horizon.stellar.lobstr.co"]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion from version nightly-2024-02-09
to use the array directly
@@ -7,7 +7,11 @@ use std::env; | |||
// previously passed to the environment. | |||
// A variable not .env but passed to the environment will not be overridden. | |||
fn get_env_variables(key: &str) -> Option<String> { | |||
dotenv::from_filename("../.env").ok(); | |||
if let None = dotenv::from_filename("../.env").ok() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
had a problem with running the example in stellar-relay-lib
.
I moved the env file to the root directory; that's why I added a condition to try looking at the current directory.
@@ -8,7 +8,7 @@ pub use task::*; | |||
mod cache; | |||
pub mod error; | |||
mod horizon; | |||
#[cfg(feature = "testing-utils")] | |||
#[cfg(any(test, feature = "testing-utils"))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
keys are also used in the unit test of this lib, so I added test
.
@@ -104,11 +102,14 @@ impl pallet_balances::Config for Test { | |||
parameter_types! { | |||
pub const GetNativeCurrencyId: CurrencyId = DEFAULT_NATIVE_CURRENCY; | |||
pub const GetRelayChainCurrencyId: CurrencyId = DEFAULT_COLLATERAL_CURRENCY; | |||
#[cfg(feature = "runtime-benchmarks")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this causes error to building/testing other features.
for example:
cargo +nightly test -p vault --features integration-test`
actually fails with a duplicate lang item issue.
cfg
macros should be done outside of parameter_types!
macros.
@@ -15,7 +15,7 @@ pub struct DataKey { | |||
|
|||
impl PartialOrd<Self> for DataKey { | |||
fn partial_cmp(&self, other: &Self) -> Option<Ordering> { | |||
self.blockchain.partial_cmp(&other.blockchain) | |||
Some(self.cmp(other)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a suggestion in version nightly-2024-02-09
Hey @b-yap, looks like a lot of work went into this. Thanks! I see that a couple of changes are also pure formatting changes. How is that? Did the formatter settings change or did we not properly use a formatter before? |
@TorstenStueber I did not touch the fmt toml file. I think these are all new preferences from the new version? Because I ran |
Hmm, is this expected that the default formatting changes between different versions of rust (and therefore rust fmt)? Or did we not properly format before the change? |
@TorstenStueber I confirmed it by running ^ In this screenshot, the differences occurred after |
Interesting and unexpected. Looking again, there seem to be only a few changes that are only due to formatting. One of them is this and it is clear that this it enacts the |
README.md
Outdated
@@ -78,7 +78,7 @@ The handling of redeem events is implemented in `clients/vault/src/redeem.rs`. | |||
## Run all tests | |||
|
|||
``` | |||
cargo test --lib --features standalone-metadata -- --nocapture | |||
cargo +nightly --lib --features standalone-metadata -- --nocapture |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be cargo +nightly test...
right? I am not sure about the order
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes you are right! 🤦🏽♀️ My bad.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CI test will be confirmed on #513
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice changes 👍
- In all the READMEs we now mention
+nightly-<some_version>
. This is okay and if we want to change it in the future, we can just do a find-and-replace search to change it without much effort. However, I'm still curious if there is a way for us to change it to+nightly
but have cargo run it with a specific version. Can we define both stable and nightly in the rust-toolchain.toml or similar so that both versions are fixed? - We also need to make sure that the changes are applied to our other compilation pipeline in the other infrastructure.
clients/README.md
Outdated
@@ -77,22 +95,24 @@ You can also find an example for setting these variables in the `.env.example` f | |||
|
|||
### Running the tests | |||
|
|||
**Note** Tests should run using Rust **_`nightly-2023-12-29`_** version. Make sure to install and add the target `wasm32-unknown-unknown`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the top-level README, you put nightly-2024-02-09
. Let's try to use the same here as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed to "nightly";
pallets/redeem/src/lib.rs
Outdated
@@ -526,12 +528,12 @@ mod self_redeem { | |||
) -> DispatchResult { | |||
// burn the tokens that the vault no longer is backing | |||
consumed_issued_tokens | |||
.lock_on(account_id) | |||
._lock_on(account_id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we find a way not to have to call functions with this underscore? I understand you created an extra trait to make this mockable. Can we move that trait next to the actual definition and unify It so that we don't need the underscore?
Otherwise, this creates some confusion and it's not easy to see without context why this is necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree; in a few weeks I will have forgotten this.
I have reverted the code to allow mocktopus
in pallet currency
's feature: testing-utils
.
That means cargo b --all-features
will not work.
I created a script build-check
cmd-all
to build all known packages for stable rust version.
testing-utils
will only compile on nightly version; or when running cargo test
.
It looks very good 👍! The only thing remaining to me is to make it work with the |
…ob/24367603763?pr=513#step:13:15, #513 (comment), #513 (comment),
ebe7d97
to
e3d0644
Compare
|
and use a variable to assign value of the nightly version in CIs
…ob/24367603763?pr=513#step:13:15, #513 (comment), #513 (comment),
…idually, instead of `--all-features`
Co-authored-by: Marcel Ebert <mail@marcel-ebert.de>
…ob/24506180390?pr=513#step:11:3011 cargo build is too heavy; opting with check instead
also added `set -e` to make sure the script exits upon the first error found
…ob/24518930774#step:11:70
…ob/24521111869?pr=513#step:14:20, cleanup the cmd-all command of clippy for `runner`
add more comments/explanations
38547a6
to
1a5c3d6
Compare
@ebma @gianfra-t I had to rebase. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can merge this now once the CI passed.
Great job @b-yap 👌
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @b-yap looks really good!
@zoveress as part of this PR, the CI workflows we do for Spacewalk changed. Do you think you are able to adjust the Gitlab testing pipeline based on the contents of this file? Otherwise please reach out and we are happy to help. The current testing pipeline will not work anymore on Gitlab because we switched to a different Rust toolchain and also had to run the CI a bit differently. |
closes #506
mocktopus
is a lib for rust nightly alone.Best to constraint its import in
test
only, until we plan to fully refactor the code and remove it entirely.build-check
cmd-all
to build (with stable) the project without thecurrency
'stesting-utils
.💥 the tests in palletredeem
is mocking functions from palletcurrency
. I had to put a wrapper to be able to mock it properly.💀 This is an ugly approach, but it works well.How to begin the review:
build-checkcmd-all:testing-utils
ofcurrency
pallet2023-12-29
2024-02-09
2023-12-29
had issues ❗ :error[E0658]: use of unstable library feature 'stdsimd'
2024-02-09
nightly
is required for testing.fmt
only works fornightly
cmd-all
script instead+nightly
or a nightly version of your choicenot used
warnings. (need your help on this @gianfra-t)stellar-relay-lib
,testing-utils
feature ofwallet
to access the functions for retrieving the secret keyswallet
(cargo test
)stellar-relay-lib
, it failed withfile not found
.pallets/currency/Cargo.toml:mocktopus
only incfg test
.pallets/currency/src/amount.rs:allowmocktopus
only incfg test
💥 pallets/redeem/src/ext.rs 💥:Again this is quite ugly butmockable
feature ofcurrency
'sAmount
is inaccessible.I wrapped it in a trait 🔻AmountExt
🔻 where we can mock the ff methods ofAmount
:fn lock_on()
fn burn_from()
fn unlock_on()
fn transfer()
implement the trait ^ by calling the actual methods ofAmount
💥 pallets/redeem/src/lib.rs 💥 :replace the call ofAmount
methods, with methods of traitAmountExt
:fn _lock_on()
fn _burn_from()
fn _unlock_on()
fn _transfer()
💥 pallets/redeem/src/tests.rs 💥 :replace the call ofAmount
methods, with methods of traitAmountExt
jsonrpsee
will need theclient
feature