Skip to content

Commit

Permalink
chore: update rust to 1.81 (#1587)
Browse files Browse the repository at this point in the history
* chore: update rust to 1.82

And explicitly disable features we don't support.

* fix lint errors

* fix condition

* undo dead code removal

* improve precompile failure logging

This gets rid of the clippy warning, and will make actor debug logs a
bit more readable.

* downgrade to 1.81.0

Rust 1.81.0 introduces some interesting breaking changes for wasm
codegen and I'd rather not deal with those now.

See the compatibility notes section of
https://github.com/rust-lang/rust/releases/tag/1.82.0.

* update lockfile

---------

Co-authored-by: Rod Vagg <[email protected]>
  • Loading branch information
Stebalien and rvagg authored Jan 21, 2025
1 parent 09d395d commit fd6cb22
Show file tree
Hide file tree
Showing 18 changed files with 41 additions and 20 deletions.
5 changes: 5 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,10 @@ rustflags = [
rustflags = [
"-Ctarget-feature=+bulk-memory",
"-Ctarget-feature=+crt-static",
"-Ctarget-feature=+mutable-globals",
"-Ctarget-feature=+sign-ext",
"-Ctarget-feature=-reference-types",
"-Ctarget-feature=-multivalue",
"-Ctarget-feature=-atomics",
"-Clink-arg=--export-table",
]
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions actors/evm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ fil_actors_evm_shared = { workspace = true }
hex = { workspace = true }
hex-literal = { workspace = true }
substrate-bn = { workspace = true }
thiserror = { workspace = true }

[dev-dependencies]
hex = { workspace = true, features = ["serde"] }
Expand Down
9 changes: 8 additions & 1 deletion actors/evm/shared/src/address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,19 @@ impl From<U256> for EthAddress {
}
}

impl std::fmt::Debug for EthAddress {
impl std::fmt::Display for EthAddress {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str("0x")?;
f.write_str(&hex::encode(self.0))
}
}

impl std::fmt::Debug for EthAddress {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self)
}
}

impl From<EthAddress> for Address {
fn from(addr: EthAddress) -> Self {
From::from(&addr)
Expand Down
6 changes: 3 additions & 3 deletions actors/evm/src/interpreter/instructions/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ pub fn call_generic<RT: Runtime>(
match precompiles::Precompiles::call_precompile(system, &dst, input_data, context) {
Ok(return_data) => (1, return_data),
Err(err) => {
log::warn!(target: "evm", "Precompile failed: error {:?}", err);
log::warn!(target: "evm", "call to precompile {} failed: {}", &dst, err);
// precompile failed, exit with reverted and no output
(0, vec![])
}
Expand Down Expand Up @@ -291,8 +291,8 @@ pub fn call_generic<RT: Runtime>(
// this is how the EVM behaves.
ContractType::Account | ContractType::NotFound => Ok(None),
// If we're calling a "native" actor, always revert.
ContractType::Native(_) => {
log::info!("attempted to delegatecall a native actor at {dst:?}");
ContractType::Native(cid) => {
log::info!("attempted to delegatecall a native actor {cid} at {dst:?}");
Err(None)
}
ContractType::Precompile => {
Expand Down
9 changes: 8 additions & 1 deletion actors/evm/src/interpreter/precompiles/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use fil_actors_evm_shared::{address::EthAddress, uints::U256};
use fil_actors_runtime::{runtime::Runtime, ActorError};
use fvm_shared::{address::Address, econ::TokenAmount};
use substrate_bn::{CurveError, FieldError, GroupError};
use thiserror::Error;

use crate::reader::OverflowError;

Expand Down Expand Up @@ -111,15 +112,21 @@ impl<RT: Runtime> Precompiles<RT> {
}
}

#[derive(Debug)]
#[derive(Debug, Error)]
pub enum PrecompileError {
// EVM precompile errors
#[error("EC curve error in data passed to precompile: {0:?}")]
EcErr(CurveError),
#[error("incorrect input size to precompile")]
IncorrectInputSize,
// FVM precompile errors
#[error("invalid input to precompile")]
InvalidInput,
#[error("calling convention forbidden for precompile")]
CallForbidden,
#[error("transfering funds to precompile failed")]
TransferFailed,
#[error("internal evm error when calling precompile: {0}")]
VMError(ActorError),
}

Expand Down
8 changes: 2 additions & 6 deletions actors/init/tests/init_actor_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -435,11 +435,7 @@ fn construct_and_verify(rt: &MockRuntime) {
check_state(rt);
}

fn exec_and_verify<S: Serialize>(
rt: &MockRuntime,
code_id: Cid,
params: &S,
) -> Result<ExecReturn, ActorError>
fn exec_and_verify<S>(rt: &MockRuntime, code_id: Cid, params: &S) -> Result<ExecReturn, ActorError>
where
S: Serialize,
{
Expand All @@ -455,7 +451,7 @@ where
ret.and_then(|v| v.unwrap().deserialize().map_err(|e| e.into()))
}

fn exec4_and_verify<S: Serialize>(
fn exec4_and_verify<S>(
rt: &MockRuntime,
namespace: ActorID,
subaddr: &[u8],
Expand Down
2 changes: 1 addition & 1 deletion actors/market/src/testing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ pub fn check_state_invariants<BS: Blockstore>(
let deal_id: u64 = u64::decode_var(key.0.as_slice()).unwrap().0;

acc.require(
proposal_stats.get(&deal_id).is_some(),
proposal_stats.contains_key(&deal_id),
format!("pending deal allocation {} not found in proposals", deal_id),
);

Expand Down
2 changes: 1 addition & 1 deletion actors/market/tests/harness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,7 @@ pub fn publish_deals(
if deal.verified_deal {
// Expect query for the client's datacap balance, just once per client.
let client_id = deal.client.id().unwrap();
if client_verified_deals.get(&client_id).is_none() {
if !client_verified_deals.contains_key(&client_id) {
rt.expect_send_simple(
DATACAP_TOKEN_ACTOR_ADDR,
ext::datacap::BALANCE_OF_METHOD,
Expand Down
2 changes: 1 addition & 1 deletion actors/market/tests/publish_storage_deals_failures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ fn fail_when_deals_have_different_providers() {
.deserialize()
.unwrap();

let valid: Vec<u64> = psd_ret.valid_deals.bounded_iter(std::u64::MAX).unwrap().collect();
let valid: Vec<u64> = psd_ret.valid_deals.bounded_iter(u64::MAX).unwrap().collect();
assert_eq!(vec![0], valid);

rt.verify();
Expand Down
2 changes: 1 addition & 1 deletion actors/miner/tests/sector_map_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ fn create_deadline_sector_map(
}

fn create_bitfield_sequence(start: u64, end: u64) -> BitField {
let ranges = vec![Range { start, end }];
let ranges = [Range { start, end }];
let ranges = Ranges::new(ranges.iter().cloned());
BitField::from_ranges(ranges)
}
Expand Down
2 changes: 1 addition & 1 deletion actors/miner/tests/sector_number_allocation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ mod sector_number_allocation {
// Allocate widely-spaced numbers to consume the run-length encoded bytes quickly,
// until the limit is reached.
let mut limit_reached = false;
for i in 0..std::u64::MAX {
for i in 0..u64::MAX {
let (number, _) = (i + 1).overflowing_shl(50);
let res = h.allocate_sector_numbers(&[number]);
if res.is_err() {
Expand Down
2 changes: 1 addition & 1 deletion actors/paych/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use fvm_shared::MethodNum;
use super::Merge;

/// Maximum number of lanes in a channel
pub const MAX_LANE: u64 = std::i64::MAX as u64;
pub const MAX_LANE: u64 = i64::MAX as u64;

pub const SETTLE_DELAY: ChainEpoch = EPOCHS_IN_HOUR * 12;

Expand Down
2 changes: 2 additions & 0 deletions runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ short-precommit = []
min-power-2k = []
# Lower the minimum power requirement to 2g
min-power-2g = []
# Lower the minimum power requirement to 32g
min-power-32g = []

# no collateral for deals (for testing)
no-provider-deal-collateral = []
Expand Down
4 changes: 2 additions & 2 deletions runtime/src/runtime/fvm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -573,8 +573,8 @@ where
/// 2. Obtains the method number for the invocation.
/// 3. Creates an FVM runtime shim.
/// 4. Invokes the target method.
/// 5a. In case of error, aborts the execution with the emitted exit code, or
/// 5b. In case of success, stores the return data as a block and returns the latter.
/// 5. (a) In case of error, aborts the execution with the emitted exit code, or
/// 5. (b) In case of success, stores the return data as a block and returns the latter.
pub fn trampoline<C: ActorCode>(params: u32) -> u32 {
init_logging(C::name());

Expand Down
1 change: 1 addition & 0 deletions runtime/src/runtime/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ pub trait Runtime: Primitives + RuntimePolicy {
/// The circulating supply is the sum of:
/// - rewards emitted by the reward actor,
/// - funds vested from lock-ups in the genesis state,
///
/// less the sum of:
/// - funds burnt,
/// - pledge collateral locked in storage miner actors (recorded in the storage power actor)
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[toolchain]
channel = "1.76.0"
channel = "1.81.0"
components = ["clippy", "llvm-tools-preview", "rustfmt"]
targets = ["wasm32-unknown-unknown"]
1 change: 1 addition & 0 deletions vm_api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ pub trait Primitives {
/// - first header is of the same or lower epoch as the second
/// - at least one of the headers appears in the current chain at or after epoch `earliest`
/// - the headers provide evidence of a fault (see the spec for the different fault types).
///
/// The parameters are all serialized block headers. The third "extra" parameter is consulted only for
/// the "parent grinding fault", in which case it must be the sibling of h1 (same parent tipset) and one of the
/// blocks in the parent of h2 (i.e. h2's grandparent).
Expand Down

0 comments on commit fd6cb22

Please sign in to comment.