Skip to content

Commit

Permalink
Switch to stable rust and make rust debug build usable (#2207)
Browse files Browse the repository at this point in the history
* make moonnbeam compiling with stable rust

* make rust dev mode usable

* toml-sort

* macro tests: update compile error outputs

* macro tests: update expanded outputs

* rebuild cargo-expand with stable rust

* cargo expand is not supported in stable rust
  • Loading branch information
librelois authored Apr 5, 2023
1 parent 3949289 commit 66023c3
Show file tree
Hide file tree
Showing 34 changed files with 379 additions and 652 deletions.
1 change: 0 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,6 @@ jobs:
echo "$MB_VERSION" | grep $GIT_COMMIT
- name: Unit tests
run: |
cargo install cargo-expand
cargo test --release --all
# We determine whether there are unmodified Cargo.lock files by:
Expand Down
361 changes: 181 additions & 180 deletions Cargo.lock

Large diffs are not rendered by default.

60 changes: 60 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,66 @@ evm-core = { git = "https://github.com/rust-blockchain/evm", rev = "842e03d068dd
evm-gasometer = { git = "https://github.com/rust-blockchain/evm", rev = "842e03d068ddb6a3195a2dedc4a9b63caadb3355" }
evm-runtime = { git = "https://github.com/rust-blockchain/evm", rev = "842e03d068ddb6a3195a2dedc4a9b63caadb3355" }

# The list of dependencies below (which can be both direct and indirect dependencies) are crates
# that are suspected to be CPU-intensive, and that are unlikely to require debugging (as some of
# their debug info might be missing) or to require to be frequently recompiled. We compile these
# dependencies with `opt-level=3` even in "dev" mode in order to make "dev" mode more usable.
# The majority of these crates are cryptographic libraries.
#
# Note that this does **not** affect crates that depend on Moonbeam. In other words, if you add
# a dependency on Moonbeam, you have to copy-paste this list in your own `Cargo.toml` (assuming
# that you want the same list). This list is only relevant when running `cargo build` from within
# the Moonbeam workspace.
#
# If you see an error mentioning "profile package spec ... did not match any packages", it
# probably concerns this list.
#
# This list is ordered alphabetically.
[profile.dev.package]
blake2 = { opt-level = 3 }
blake2b_simd = { opt-level = 3 }
chacha20poly1305 = { opt-level = 3 }
cranelift-codegen = { opt-level = 3 }
cranelift-wasm = { opt-level = 3 }
crc32fast = { opt-level = 3 }
crossbeam-deque = { opt-level = 3 }
crypto-mac = { opt-level = 3 }
curve25519-dalek = { opt-level = 3 }
ed25519-zebra = { opt-level = 3 }
flate2 = { opt-level = 3 }
futures-channel = { opt-level = 3 }
hash-db = { opt-level = 3 }
hashbrown = { opt-level = 3 }
hmac = { opt-level = 3 }
httparse = { opt-level = 3 }
integer-sqrt = { opt-level = 3 }
k256 = { opt-level = 3 }
keccak = { opt-level = 3 }
libm = { opt-level = 3 }
librocksdb-sys = { opt-level = 3 }
libsecp256k1 = { opt-level = 3 }
libz-sys = { opt-level = 3 }
mio = { opt-level = 3 }
nalgebra = { opt-level = 3 }
num-bigint = { opt-level = 3 }
parking_lot = { opt-level = 3 }
parking_lot_core = { opt-level = 3 }
percent-encoding = { opt-level = 3 }
primitive-types = { opt-level = 3 }
ring = { opt-level = 3 }
rustls = { opt-level = 3 }
secp256k1 = { opt-level = 3 }
sha2 = { opt-level = 3 }
sha3 = { opt-level = 3 }
smallvec = { opt-level = 3 }
snow = { opt-level = 3 }
twox-hash = { opt-level = 3 }
uint = { opt-level = 3 }
wasmi = { opt-level = 3 }
x25519-dalek = { opt-level = 3 }
yamux = { opt-level = 3 }
zeroize = { opt-level = 3 }

# make sure dev builds with backtrace do
# not slow us down
[profile.dev.package.backtrace]
Expand Down
10 changes: 6 additions & 4 deletions pallets/moonbeam-orbiters/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
//! currently selected orbiter.
#![cfg_attr(not(feature = "std"), no_std)]
#![feature(step_trait)]

pub mod types;
pub mod weights;
Expand Down Expand Up @@ -108,8 +107,7 @@ pub mod pallet {
+ Default
+ sp_runtime::traits::MaybeDisplay
+ sp_runtime::traits::AtLeast32Bit
+ Copy
+ core::iter::Step;
+ Copy;

/// Weight information for extrinsics in this pallet.
type WeightInfo: WeightInfo;
Expand Down Expand Up @@ -490,14 +488,18 @@ pub mod pallet {
Some(collator.clone()),
);
writes += 1;
for i in Zero::zero()..T::RotatePeriod::get() {

let mut i = Zero::zero();
while i < T::RotatePeriod::get() {
OrbiterPerRound::<T>::insert(
round_index.saturating_add(i),
collator.clone(),
next_orbiter.clone(),
);
i += One::one();
writes += 1;
}

Self::deposit_event(Event::OrbiterRotation {
collator,
old_orbiter: maybe_old_orbiter.map(|orbiter| orbiter.account_id),
Expand Down
1 change: 0 additions & 1 deletion precompiles/assets-erc20/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
// along with Moonbeam. If not, see <http://www.gnu.org/licenses/>.

#![cfg_attr(not(feature = "std"), no_std)]
#![cfg_attr(test, feature(assert_matches))]

use core::fmt::Display;
use fp_evm::PrecompileHandle;
Expand Down
1 change: 0 additions & 1 deletion precompiles/author-mapping/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
//! Precompile to interact with pallet author mapping through an evm precompile.
#![cfg_attr(not(feature = "std"), no_std)]
#![feature(assert_matches)]

use fp_evm::PrecompileHandle;
use frame_support::{
Expand Down
1 change: 0 additions & 1 deletion precompiles/balances-erc20/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
//! Precompile to interact with pallet_balances instances using the ERC20 interface standard.
#![cfg_attr(not(feature = "std"), no_std)]
#![cfg_attr(test, feature(assert_matches))]

use fp_evm::PrecompileHandle;
use frame_support::{
Expand Down
1 change: 0 additions & 1 deletion precompiles/conviction-voting/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
// along with Moonbeam. If not, see <http://www.gnu.org/licenses/>.

#![cfg_attr(not(feature = "std"), no_std)]
#![feature(assert_matches)]

use fp_evm::PrecompileHandle;
use frame_support::dispatch::{Dispatchable, GetDispatchInfo, PostDispatchInfo};
Expand Down
1 change: 0 additions & 1 deletion precompiles/crowdloan-rewards/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
//! Precompile to call pallet-crowdloan-rewards runtime methods via the EVM
#![cfg_attr(not(feature = "std"), no_std)]
#![feature(assert_matches)]

use fp_evm::PrecompileHandle;
use frame_support::{
Expand Down
1 change: 0 additions & 1 deletion precompiles/pallet-democracy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
//! Precompile to interact with pallet democracy through an evm precompile.
#![cfg_attr(not(feature = "std"), no_std)]
#![feature(assert_matches)]

use fp_evm::PrecompileHandle;
use frame_support::dispatch::{Dispatchable, GetDispatchInfo, PostDispatchInfo};
Expand Down
1 change: 0 additions & 1 deletion precompiles/parachain-staking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
//! Precompile to call parachain-staking runtime methods via the EVM
#![cfg_attr(not(feature = "std"), no_std)]
#![cfg_attr(test, feature(assert_matches))]

#[cfg(test)]
mod mock;
Expand Down
1 change: 0 additions & 1 deletion precompiles/preimage/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
// along with Moonbeam. If not, see <http://www.gnu.org/licenses/>.

#![cfg_attr(not(feature = "std"), no_std)]
#![feature(assert_matches)]

use fp_evm::PrecompileHandle;
use frame_support::dispatch::{Dispatchable, GetDispatchInfo, PostDispatchInfo};
Expand Down
1 change: 0 additions & 1 deletion precompiles/proxy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
// along with Moonbeam. If not, see <http://www.gnu.org/licenses/>.

#![cfg_attr(not(feature = "std"), no_std)]
#![feature(assert_matches)]

use evm::ExitReason;
use fp_evm::{Context, PrecompileFailure, PrecompileHandle, Transfer};
Expand Down
1 change: 0 additions & 1 deletion precompiles/randomness/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
//! Precompile to interact with randomness through an evm precompile.
#![cfg_attr(not(feature = "std"), no_std)]
#![feature(assert_matches)]

extern crate alloc;

Expand Down
1 change: 0 additions & 1 deletion precompiles/referenda/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
// along with Moonbeam. If not, see <http://www.gnu.org/licenses/>.

#![cfg_attr(not(feature = "std"), no_std)]
#![feature(assert_matches)]

use fp_evm::PrecompileHandle;
use frame_support::dispatch::{Dispatchable, GetDispatchInfo, PostDispatchInfo};
Expand Down
1 change: 0 additions & 1 deletion precompiles/relay-encoder/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
//! Precompile to encode relay staking calls via the EVM
#![cfg_attr(not(feature = "std"), no_std)]
#![cfg_attr(test, feature(assert_matches))]

use cumulus_primitives_core::relay_chain;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ error: The discriminant function must only take the code address (H160) as param
--> tests/compile-fail/precompile/discriminant/missing-param.rs:25:2
|
25 | fn discriminant() -> Option<u64> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ error: The discriminant function must only take the code address (H160) as param
--> tests/compile-fail/precompile/discriminant/too-many-arguments.rs:25:2
|
25 | fn discriminant(address: H160, other: u32) -> Option<u32> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ error: A precompile method must have a return type of `EvmResult<_>` (exposed by
--> tests/compile-fail/precompile/evm-data/no-output.rs:24:2
|
24 | fn foo(test: &mut impl PrecompileHandle) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error[E0277]: the trait bound `String: EvmData` is not satisfied
--> tests/compile-fail/precompile/evm-data/output-dont-impl-evmdata.rs:26:46
|
26 | fn foo(test: &mut impl PrecompileHandle) -> EvmResult<String> {
| ^^^^^^^^^^^^^^^^^ the trait `EvmData` is not implemented for `String`
| ^^^^^^^^^ the trait `EvmData` is not implemented for `String`
|
= help: the following other types implement trait `EvmData`:
()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
error[E0277]: `?` couldn't convert the error to `PrecompileFailure`
--> tests/compile-fail/precompile/evm-data/output-wrong-error-result.rs:25:63
--> tests/compile-fail/precompile/evm-data/output-wrong-error-result.rs:25:51
|
25 | fn foo(test: &mut impl PrecompileHandle) -> Result<(), String> {
| ^ the trait `From<String>` is not implemented for `PrecompileFailure`
| ^ the trait `From<String>` is not implemented for `PrecompileFailure`
|
= note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait
= help: the following other types implement trait `From<T>`:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ error: Precompile methods must have at least 1 parameter (the PrecompileHandle)
--> tests/compile-fail/precompile/handle/missing.rs:24:2
|
24 | fn foo() {
| ^^^^^^^^
| ^^
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ error: PrecompileSet methods must have at least 2 parameters (the precompile ins
--> tests/compile-fail/precompile/handle/set-missing.rs:25:2
|
25 | fn foo(_: u32) {
| ^^^^^^^^^^^^^^
| ^^
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ error: Precompile methods must have at least 1 parameter (the PrecompileHandle)
--> tests/compile-fail/precompile/pre-check/no-parameter.rs:24:2
|
24 | fn pre_check() {
| ^^^^^^^^^^^^^^
| ^^
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ error: Precompile pre_check method must have exactly 1 parameter (the Precompile
--> tests/compile-fail/precompile/pre-check/too-many-parameters.rs:24:2
|
24 | fn pre_check(_: &mut impl PrecompileHandle, _: u32) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^
Loading

0 comments on commit 66023c3

Please sign in to comment.