Skip to content
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

chore: bump rust version to latest nightly #3571

Merged
merged 20 commits into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
d2d9cda
chore: support rust 1.76
StackOverflowExcept1on Dec 7, 2023
6605cfa
small fix
StackOverflowExcept1on Dec 8, 2023
aa1f8c8
update version
StackOverflowExcept1on Dec 9, 2023
ad341b8
fix clippy
StackOverflowExcept1on Dec 9, 2023
a571f9a
[skip-ci] fix new lints
StackOverflowExcept1on Dec 9, 2023
4f86ffd
Merge remote-tracking branch 'origin/master' into av/rust-1.76-support
StackOverflowExcept1on Dec 12, 2023
bf474e9
rm this file
StackOverflowExcept1on Dec 12, 2023
849dbb3
Merge remote-tracking branch 'origin/master' into av/rust-1.76-support
StackOverflowExcept1on Dec 30, 2023
e1a0498
try nightly-2024-01-25
StackOverflowExcept1on Jan 25, 2024
9f4742e
Merge remote-tracking branch 'origin/master' into av/rust-1.76-support
StackOverflowExcept1on Jan 25, 2024
bbc73fe
fix errors after merge
StackOverflowExcept1on Jan 25, 2024
00f0ac0
fix wasm builder
StackOverflowExcept1on Jan 25, 2024
93ab5a8
fix gstd tests
StackOverflowExcept1on Jan 25, 2024
7fc9671
fix fuzzer test
StackOverflowExcept1on Jan 25, 2024
bfe5ac2
Merge remote-tracking branch 'origin/master' into av/rust-1.76-support
StackOverflowExcept1on Jan 28, 2024
5317fc6
Merge remote-tracking branch 'origin/master' into av/rust-1.76-support
StackOverflowExcept1on Feb 1, 2024
26c1919
remove ptr::addr_of
StackOverflowExcept1on Feb 1, 2024
bf15a93
Merge remote-tracking branch 'origin/master' into av/rust-1.76-support
StackOverflowExcept1on Feb 2, 2024
e42c08e
remove gear_calls.rs after merge...
StackOverflowExcept1on Feb 2, 2024
9a9a157
some fixes
StackOverflowExcept1on Feb 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions common/numerated/src/interval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ mod tests {
#[test]
fn size() {
assert_eq!(Interval::<u8>::try_from(11..111).unwrap().size(), Some(100),);
assert_eq!(Interval::<u8>::try_from(..1).unwrap().size(), Some(1),);
assert_eq!(Interval::<u8>::from(..1).size(), Some(1),);
assert_eq!(Interval::<u8>::from(..=1).size(), Some(2));
assert_eq!(Interval::<u8>::from(1..).size(), Some(255));
assert_eq!(Interval::<u8>::from(0..).size(), None);
Expand All @@ -452,15 +452,15 @@ mod tests {
Interval::<u8>::try_from(11..111).unwrap().raw_size(),
Some(100),
);
assert_eq!(Interval::<u8>::try_from(..1).unwrap().raw_size(), Some(1),);
assert_eq!(Interval::<u8>::from(..1).raw_size(), Some(1),);
assert_eq!(Interval::<u8>::from(..=1).raw_size(), Some(2));
assert_eq!(Interval::<u8>::from(1..).raw_size(), Some(255));
assert_eq!(Interval::<u8>::from(0..).raw_size(), None);
assert_eq!(Interval::<u8>::from(..).raw_size(), None);
assert_eq!(Interval::<u8>::try_from(1..1).unwrap().raw_size(), Some(0));

assert_eq!(Interval::<i8>::try_from(-1..99).unwrap().size(), Some(-28)); // corresponds to 100 numeration
assert_eq!(Interval::<i8>::try_from(..1).unwrap().size(), Some(1)); // corresponds to 129 numeration
assert_eq!(Interval::<i8>::from(..1).size(), Some(1)); // corresponds to 129 numeration
assert_eq!(Interval::<i8>::from(..=1).size(), Some(2)); // corresponds to 130 numeration
assert_eq!(Interval::<i8>::from(1..).size(), Some(-1)); // corresponds to 127 numeration
assert_eq!(Interval::<i8>::from(0..).size(), Some(0)); // corresponds to 128 numeration
Expand All @@ -471,7 +471,7 @@ mod tests {
Interval::<i8>::try_from(-1..99).unwrap().raw_size(),
Some(100)
);
assert_eq!(Interval::<i8>::try_from(..1).unwrap().raw_size(), Some(129));
assert_eq!(Interval::<i8>::from(..1).raw_size(), Some(129));
assert_eq!(Interval::<i8>::from(..=1).raw_size(), Some(130));
assert_eq!(Interval::<i8>::from(1..).raw_size(), Some(127));
assert_eq!(Interval::<i8>::from(0..).raw_size(), Some(128));
Expand Down
4 changes: 2 additions & 2 deletions common/src/gas_provider/property_tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ type Balance = u64;
type Funds = u128;

std::thread_local! {
static TOTAL_ISSUANCE: RefCell<Option<Balance>> = RefCell::new(None);
static TOTAL_ISSUANCE: RefCell<Option<Balance>> = const { RefCell::new(None) };
}

#[derive(Debug, PartialEq, Eq)]
Expand Down Expand Up @@ -177,7 +177,7 @@ impl<T> From<ReservationKey> for GasNodeId<T, ReservationKey> {
}

std::thread_local! {
static GAS_TREE_NODES: RefCell<BTreeMap<Key, GasNode>> = RefCell::new(BTreeMap::new());
static GAS_TREE_NODES: RefCell<BTreeMap<Key, GasNode>> = const { RefCell::new(BTreeMap::new()) };
}

struct GasTreeNodesWrap;
Expand Down
4 changes: 2 additions & 2 deletions examples/calc-hash/over-blocks/src/wasm.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::Method;
use gstd::{exec, msg};
use gstd::{exec, msg, prelude::*};
use types::Package;

#[no_mangle]
Expand All @@ -11,7 +11,7 @@ extern "C" fn init() {
extern "C" fn handle() {
let threshold = unsafe { state::THRESHOLD.expect("Threshold has not been set.") };
let method = msg::load::<Method>().expect("Invalid program method.");
let registry = unsafe { &mut state::REGISTRY };
let registry = unsafe { &mut *ptr::addr_of_mut!(state::REGISTRY) };

match method {
Method::Start { expected, id, src } => {
Expand Down
2 changes: 0 additions & 2 deletions examples/constructor/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ impl Calls {
self
}

// TODO #3452: remove this on next rust update
#[allow(clippy::useless_conversion)]
pub fn add_from_iter(mut self, calls: impl Iterator<Item = Call>) -> Self {
self.0.extend(calls.into_iter());
self
Expand Down
2 changes: 1 addition & 1 deletion examples/constructor/src/wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ static mut SCHEME: Option<Scheme> = None;
fn process_fn<'a>(f: impl Fn(&'a Scheme) -> Option<&'a Vec<Call>>) {
let scheme = unsafe { SCHEME.as_ref() }.expect("Should be set before access");
let calls = f(scheme)
.map(Clone::clone)
.cloned()
.unwrap_or_else(|| msg::load().expect("Failed to load payload"));

let mut res = None;
Expand Down
4 changes: 2 additions & 2 deletions examples/fungible-token/src/wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,10 @@ extern "C" fn state() {
decimals,
} = state;

let balances = balances.into_iter().map(|(k, v)| (k, v)).collect();
let balances = balances.into_iter().collect();
let allowances = allowances
.into_iter()
.map(|(id, allowance)| (id, allowance.into_iter().map(|(k, v)| (k, v)).collect()))
.map(|(id, allowance)| (id, allowance.into_iter().collect()))
.collect();
let payload = IoFungibleToken {
name,
Expand Down
4 changes: 2 additions & 2 deletions examples/fungible-token/tests/benchmarks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ async fn stress_test() -> Result<()> {
.encode();

let (message_id, program_id, _hash) = api
.upload_program_bytes(WASM_BINARY.to_vec(), [137u8], init_msg, MAX_GAS_LIMIT, 0)
.upload_program_bytes(WASM_BINARY, [137u8], init_msg, MAX_GAS_LIMIT, 0)
.await?;

assert!(listener.message_processed(message_id).await?.succeed());
Expand Down Expand Up @@ -229,7 +229,7 @@ async fn stress_transfer() -> Result<()> {

let salt: u8 = rng.gen();
let (message_id, program_id, _hash) = api
.upload_program_bytes(WASM_BINARY.to_vec(), [salt], init_msg, MAX_GAS_LIMIT, 0)
.upload_program_bytes(WASM_BINARY, [salt], init_msg, MAX_GAS_LIMIT, 0)
.await
.unwrap();

Expand Down
4 changes: 2 additions & 2 deletions examples/init-wait/src/wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

use gstd::{collections::BTreeMap, exec, msg, MessageId};
use gstd::{collections::BTreeMap, exec, msg, prelude::*, MessageId};

#[derive(PartialEq, Debug)]
enum State {
Expand All @@ -40,7 +40,7 @@ extern "C" fn handle() {

#[no_mangle]
extern "C" fn init() {
let state = unsafe { &mut STATE };
let state = unsafe { &mut *ptr::addr_of_mut!(STATE) };
match state {
State::NotInited => {
for k in 0..20 {
Expand Down
4 changes: 2 additions & 2 deletions examples/new-meta/src/wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ extern "C" fn init() {
extern "C" fn handle() {
let message_in: MessageIn = msg::load().unwrap();

let res = unsafe { &WALLETS }
let res = unsafe { &*ptr::addr_of!(WALLETS) }
.iter()
.find(|w| w.id.decimal == message_in.id.decimal)
.map(Clone::clone);
.cloned();

let message_out = MessageOut { res };

Expand Down
4 changes: 2 additions & 2 deletions examples/node/src/wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ fn process(request: Request) -> Reply {
transition.query_list = state().sub_nodes.iter().cloned().collect();
let first_sub_node = *transition
.query_list
.get(0)
.first()
.expect("Checked above that sub_nodes is not empty; qed");
transition.last_sent_message_id =
msg::send(first_sub_node, request, 0).unwrap();
Expand Down Expand Up @@ -176,7 +176,7 @@ fn process(request: Request) -> Reply {
if let TransitionState::Ready = transition.state {
let first_sub_node = *transition
.query_list
.get(0)
.first()
.expect("Checked above that sub_nodes is not empty; qed");

transition.query_index = 0;
Expand Down
4 changes: 2 additions & 2 deletions examples/reserve-gas/src/wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ extern "C" fn init() {
)
};
}
InitAction::Wait => match unsafe { &WAKE_STATE } {
InitAction::Wait => match unsafe { &*ptr::addr_of!(WAKE_STATE) } {
WakeState::Initial => {
let _reservation = ReservationId::reserve(50_000, 10);
// to find message to reply to in test
Expand Down Expand Up @@ -152,7 +152,7 @@ extern "C" fn handle() {
}
}
HandleAction::ConsumeReservationsFromList => {
let reservations = unsafe { mem::take(&mut RESERVATIONS) };
let reservations = unsafe { mem::take(&mut *ptr::addr_of_mut!(RESERVATIONS)) };
for reservation_id in reservations {
msg::send_from_reservation(
reservation_id,
Expand Down
4 changes: 2 additions & 2 deletions examples/signal-entry/src/wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ extern "C" fn init() {
#[no_mangle]
extern "C" fn handle() {
unsafe { HANDLE_MSG = Some(msg::id()) };
let do_panic = unsafe { &mut DO_PANIC };
let do_panic = unsafe { &mut *ptr::addr_of_mut!(DO_PANIC) };

let action: HandleAction = msg::load().unwrap();
match action {
Expand Down Expand Up @@ -234,7 +234,7 @@ extern "C" fn handle() {

#[no_mangle]
extern "C" fn handle_signal() {
match unsafe { &HANDLE_SIGNAL_STATE } {
match unsafe { &*ptr::addr_of!(HANDLE_SIGNAL_STATE) } {
HandleSignalState::Normal => {
msg::send(unsafe { INITIATOR }, b"handle_signal", 0).unwrap();
let signal_code = msg::signal_code()
Expand Down
5 changes: 3 additions & 2 deletions examples/state-rollback/src/wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ extern "C" fn handle() {
let payload = msg::load_bytes().expect("Failed to load payload");

// Previous value
msg::send(msg::source(), unsafe { &PAYLOAD }, 0).expect("Failed to send message");
msg::send(msg::source(), unsafe { &*ptr::addr_of!(PAYLOAD) }, 0)
.expect("Failed to send message");

let is_panic = payload == b"panic";
let is_leave = payload == b"leave";
Expand All @@ -34,7 +35,7 @@ extern "C" fn handle() {
unsafe { PAYLOAD = Some(payload) };

// Newly set value
msg::reply(unsafe { &PAYLOAD }, 0).expect("Failed to send reply");
msg::reply(unsafe { &*ptr::addr_of!(PAYLOAD) }, 0).expect("Failed to send reply");

// Stop execution with panic.
is_panic.then(|| panic!());
Expand Down
3 changes: 2 additions & 1 deletion examples/wait/src/wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
// for panic/oom handlers
extern crate gstd;

use core::ptr;
use gcore::{exec, msg, MessageId};

static mut STATE: u32 = 0;
Expand All @@ -27,7 +28,7 @@ static mut MSG_ID_2: MessageId = MessageId::zero();

#[no_mangle]
extern "C" fn handle() {
let state = unsafe { &mut STATE };
let state = unsafe { &mut *ptr::addr_of_mut!(STATE) };
gstd::debug!("{state}");

match *state {
Expand Down
23 changes: 16 additions & 7 deletions examples/waiter/src/wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use crate::{
use core::ops::{Deref, DerefMut};
use futures::future;
use gstd::{
exec, format, msg,
exec, format, msg, ptr,
sync::{Mutex, MutexGuard, RwLock, RwLockReadGuard, RwLockWriteGuard},
};

Expand Down Expand Up @@ -117,21 +117,24 @@ async fn main() {
};
let lock_guard = lock.await;
process_mx_lock_continuation(
unsafe { &mut MUTEX_LOCK_GUARD },
unsafe { &mut *ptr::addr_of_mut!(MUTEX_LOCK_GUARD) },
lock_guard,
continuation,
)
.await;
}
Command::MxLockStaticAccess(subcommand) => {
process_lock_static_access_subcommand_mut(unsafe { &mut MUTEX_LOCK_GUARD }, subcommand);
process_lock_static_access_subcommand_mut(
unsafe { &mut *ptr::addr_of_mut!(MUTEX_LOCK_GUARD) },
subcommand,
);
}
Command::RwLock(lock_type, continuation) => {
match lock_type {
RwLockType::Read => {
let lock_guard = unsafe { RW_LOCK.read().await };
process_rw_lock_continuation(
unsafe { &mut R_LOCK_GUARD },
unsafe { &mut *ptr::addr_of_mut!(R_LOCK_GUARD) },
lock_guard,
continuation,
)
Expand All @@ -140,7 +143,7 @@ async fn main() {
RwLockType::Write => {
let lock_guard = unsafe { RW_LOCK.write().await };
process_rw_lock_continuation(
unsafe { &mut W_LOCK_GUARD },
unsafe { &mut *ptr::addr_of_mut!(W_LOCK_GUARD) },
lock_guard,
continuation,
)
Expand All @@ -150,10 +153,16 @@ async fn main() {
}
Command::RwLockStaticAccess(lock_type, subcommand) => match lock_type {
RwLockType::Read => {
process_lock_static_access_subcommand(unsafe { &mut R_LOCK_GUARD }, subcommand);
process_lock_static_access_subcommand(
unsafe { &mut *ptr::addr_of_mut!(R_LOCK_GUARD) },
subcommand,
);
}
RwLockType::Write => {
process_lock_static_access_subcommand_mut(unsafe { &mut W_LOCK_GUARD }, subcommand);
process_lock_static_access_subcommand_mut(
unsafe { &mut *ptr::addr_of_mut!(W_LOCK_GUARD) },
subcommand,
);
}
},
}
Expand Down
7 changes: 1 addition & 6 deletions gcli/tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,12 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.

//! Common utils for integration tests
pub use self::{
args::Args,
node::{Convert, NodeExec},
result::{Error, Result},
};
pub use self::{args::Args, node::NodeExec, result::Result};
use gear_core::ids::{CodeId, ProgramId};
use gsdk::{
ext::{sp_core::crypto::Ss58Codec, sp_runtime::AccountId32},
testing::Node,
};
pub use scale_info::scale::Encode;
use std::{
iter::IntoIterator,
process::{Command, Output},
Expand Down
1 change: 0 additions & 1 deletion gclient/src/api/listener/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ mod subscription;

pub use gsdk::metadata::{gear::Event as GearEvent, Event};
pub use iterator::*;
pub use subscription::*;

use crate::{Error, Result};
use async_trait::async_trait;
Expand Down
2 changes: 0 additions & 2 deletions gclient/src/api/storage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
pub(crate) mod account_id;
mod block;

pub use block::*;

use super::{GearApi, Result};
use crate::Error;
use account_id::IntoAccountId32;
Expand Down
2 changes: 1 addition & 1 deletion gclient/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ mod api;
mod utils;
mod ws;

pub use api::{calls::*, error::*, listener::*, GearApi};
pub use api::{error::*, listener::*, GearApi};
pub use gsdk::metadata::errors;
pub use utils::*;
pub use ws::WSAddress;
3 changes: 1 addition & 2 deletions gsdk/src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,7 @@ impl Api {
],
);

let data: Option<(UserStoredMessage, Interval<u32>)> = self.fetch_storage(&addr).await.ok();
Ok(data.map(|(m, i)| (m, i)))
Ok(self.fetch_storage(&addr).await.ok())
}

/// Get all mailbox messages or for the provided `address`.
Expand Down
7 changes: 5 additions & 2 deletions gsdk/src/testing/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,10 @@ impl Node {
return Err(Error::EmptyStderr);
};

for line in BufReader::new(stderr).lines().flatten() {
for line in BufReader::new(stderr)
.lines()
.map_while(|result| result.ok())
{
if line.contains(log) {
return Ok(line);
}
Expand All @@ -91,7 +94,7 @@ impl Node {
pub fn print_logs(&mut self) {
let stderr = self.process.stderr.as_mut();
let reader = BufReader::new(stderr.expect("Unable to get stderr"));
for line in reader.lines().flatten() {
for line in reader.lines().map_while(|result| result.ok()) {
println!("{line}");
}
}
Expand Down
2 changes: 1 addition & 1 deletion gstd/src/async_runtime/signals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ impl WakeSignals {
self.signals.contains_key(&reply_to)
}

pub fn poll(&mut self, reply_to: MessageId, cx: &Context<'_>) -> ReplyPoll {
pub fn poll(&mut self, reply_to: MessageId, cx: &mut Context<'_>) -> ReplyPoll {
match self.signals.remove(&reply_to) {
None => ReplyPoll::None,
Some(mut signal @ WakeSignal { payload: None, .. }) => {
Expand Down
Loading
Loading