Skip to content

Commit fd6cb22

Browse files
Stebalienrvagg
andauthored
chore: update rust to 1.81 (#1587)
* 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]>
1 parent 09d395d commit fd6cb22

File tree

18 files changed

+41
-20
lines changed

18 files changed

+41
-20
lines changed

.cargo/config.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,10 @@ rustflags = [
88
rustflags = [
99
"-Ctarget-feature=+bulk-memory",
1010
"-Ctarget-feature=+crt-static",
11+
"-Ctarget-feature=+mutable-globals",
12+
"-Ctarget-feature=+sign-ext",
13+
"-Ctarget-feature=-reference-types",
14+
"-Ctarget-feature=-multivalue",
15+
"-Ctarget-feature=-atomics",
1116
"-Clink-arg=--export-table",
1217
]

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

actors/evm/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ fil_actors_evm_shared = { workspace = true }
3232
hex = { workspace = true }
3333
hex-literal = { workspace = true }
3434
substrate-bn = { workspace = true }
35+
thiserror = { workspace = true }
3536

3637
[dev-dependencies]
3738
hex = { workspace = true, features = ["serde"] }

actors/evm/shared/src/address.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,19 @@ impl From<U256> for EthAddress {
1919
}
2020
}
2121

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

29+
impl std::fmt::Debug for EthAddress {
30+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
31+
write!(f, "{}", self)
32+
}
33+
}
34+
2835
impl From<EthAddress> for Address {
2936
fn from(addr: EthAddress) -> Self {
3037
From::from(&addr)

actors/evm/src/interpreter/instructions/call.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ pub fn call_generic<RT: Runtime>(
191191
match precompiles::Precompiles::call_precompile(system, &dst, input_data, context) {
192192
Ok(return_data) => (1, return_data),
193193
Err(err) => {
194-
log::warn!(target: "evm", "Precompile failed: error {:?}", err);
194+
log::warn!(target: "evm", "call to precompile {} failed: {}", &dst, err);
195195
// precompile failed, exit with reverted and no output
196196
(0, vec![])
197197
}
@@ -291,8 +291,8 @@ pub fn call_generic<RT: Runtime>(
291291
// this is how the EVM behaves.
292292
ContractType::Account | ContractType::NotFound => Ok(None),
293293
// If we're calling a "native" actor, always revert.
294-
ContractType::Native(_) => {
295-
log::info!("attempted to delegatecall a native actor at {dst:?}");
294+
ContractType::Native(cid) => {
295+
log::info!("attempted to delegatecall a native actor {cid} at {dst:?}");
296296
Err(None)
297297
}
298298
ContractType::Precompile => {

actors/evm/src/interpreter/precompiles/mod.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use fil_actors_evm_shared::{address::EthAddress, uints::U256};
44
use fil_actors_runtime::{runtime::Runtime, ActorError};
55
use fvm_shared::{address::Address, econ::TokenAmount};
66
use substrate_bn::{CurveError, FieldError, GroupError};
7+
use thiserror::Error;
78

89
use crate::reader::OverflowError;
910

@@ -111,15 +112,21 @@ impl<RT: Runtime> Precompiles<RT> {
111112
}
112113
}
113114

114-
#[derive(Debug)]
115+
#[derive(Debug, Error)]
115116
pub enum PrecompileError {
116117
// EVM precompile errors
118+
#[error("EC curve error in data passed to precompile: {0:?}")]
117119
EcErr(CurveError),
120+
#[error("incorrect input size to precompile")]
118121
IncorrectInputSize,
119122
// FVM precompile errors
123+
#[error("invalid input to precompile")]
120124
InvalidInput,
125+
#[error("calling convention forbidden for precompile")]
121126
CallForbidden,
127+
#[error("transfering funds to precompile failed")]
122128
TransferFailed,
129+
#[error("internal evm error when calling precompile: {0}")]
123130
VMError(ActorError),
124131
}
125132

actors/init/tests/init_actor_test.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -435,11 +435,7 @@ fn construct_and_verify(rt: &MockRuntime) {
435435
check_state(rt);
436436
}
437437

438-
fn exec_and_verify<S: Serialize>(
439-
rt: &MockRuntime,
440-
code_id: Cid,
441-
params: &S,
442-
) -> Result<ExecReturn, ActorError>
438+
fn exec_and_verify<S>(rt: &MockRuntime, code_id: Cid, params: &S) -> Result<ExecReturn, ActorError>
443439
where
444440
S: Serialize,
445441
{
@@ -455,7 +451,7 @@ where
455451
ret.and_then(|v| v.unwrap().deserialize().map_err(|e| e.into()))
456452
}
457453

458-
fn exec4_and_verify<S: Serialize>(
454+
fn exec4_and_verify<S>(
459455
rt: &MockRuntime,
460456
namespace: ActorID,
461457
subaddr: &[u8],

actors/market/src/testing.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ pub fn check_state_invariants<BS: Blockstore>(
167167
let deal_id: u64 = u64::decode_var(key.0.as_slice()).unwrap().0;
168168

169169
acc.require(
170-
proposal_stats.get(&deal_id).is_some(),
170+
proposal_stats.contains_key(&deal_id),
171171
format!("pending deal allocation {} not found in proposals", deal_id),
172172
);
173173

actors/market/tests/harness.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -767,7 +767,7 @@ pub fn publish_deals(
767767
if deal.verified_deal {
768768
// Expect query for the client's datacap balance, just once per client.
769769
let client_id = deal.client.id().unwrap();
770-
if client_verified_deals.get(&client_id).is_none() {
770+
if !client_verified_deals.contains_key(&client_id) {
771771
rt.expect_send_simple(
772772
DATACAP_TOKEN_ACTOR_ADDR,
773773
ext::datacap::BALANCE_OF_METHOD,

actors/market/tests/publish_storage_deals_failures.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ fn fail_when_deals_have_different_providers() {
392392
.deserialize()
393393
.unwrap();
394394

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

398398
rt.verify();

0 commit comments

Comments
 (0)