matter-labs / zksync

zkSync: trustless scaling and privacy engine for Ethereum
https://zksync.io
Apache License 2.0
4.88k stars 2.68k forks source link

zk server failed #596

Open dengshuaige opened 7 months ago

dengshuaige commented 7 months ago

When I use zk server,it returns failed, I used rust 1.66 1.70 1.72 1.74 1.75 1.76 How to compile success?

error[E0277]: the size for values of type [u8] cannot be known at compilation time --> core/lib/storage/src/chain/operations_ext/mod.rs:1444:15 1444 .map( account (start_account, Address::from_slice(&account))) ^^^^^^^ doesn't have a size known at compile-time
 = help: the trait `Sized` is not implemented for `[u8]`
 = note: all function arguments must have a statically known size
error[E0282]: type annotations needed for Vec<T> --> core/lib/storage/src/chain/state/mod.rs:623:17 623 let mut account_diff = Vec::new(); ^^^^^^^^^^^^^^^^ ... 642 .map( acc acc.block_number()) ------------ type must be known at this point

help: consider giving account_diff an explicit type, where the type for type parameter T is specified | 623 | let mut account_diff: Vec = Vec::new(); | ++++++++

error[E0609]: no field from_block on type &_ --> core/lib/storage/src/ethereum/mod.rs:520:46 | 520 | ... let (from_block, to_block) = (op.from_block as u32, op.to_block a... | ^^^^^^^^^^

warning: unused import: num::bigint::ToBigInt --> core/lib/storage/src/chain/account/mod.rs:24:5 | 24 | use num::bigint::ToBigInt; | ^^^^^^^^^^^^^^^^^^^^^

warning: unused import: num::ToPrimitive --> core/lib/storage/src/misc/mod.rs:9:5 | 9 | use num::ToPrimitive; | ^^^^^^^^^^^^^^^^

Some errors have detailed explanations: E0277, E0282, E0609. For more information about an error, try rustc --explain E0277. warning: zksync_storage (lib) generated 21 warnings error: could not compile zksync_storage (lib) due to 319 previous errors; 21 warnings emitted

kdai-910hr commented 6 months ago

Try rust 1.77.1 (7cf61ebde 2024-03-27), it works on my machine.

nathanlwb commented 5 months ago
  1. Error about [u8] not being Sized: You’re trying to use an array slice (&[u8]) in a way that requires its size to be known at compile time, but Rust doesn't know the size of slices ahead of time. To fix this, make sure the function Address::from_slice is expecting a slice (&[u8]) instead of an array. If you can edit Address::from_slice, change its parameter to accept a slice. The corrected function would look something like:

rust Copy code impl Address { pub fn from_slice(slice: &[u8]) -> Self { // Implementation goes here } } And you’d use it like this in your map:

rust Copy code .map(|account| (start_account, Address::from_slice(account)))

  1. Error about needing type annotations for Vec: When you initialize a vector with Vec::new(), Rust needs to know what type of elements it will hold. If the type isn't specified elsewhere, you need to declare it when creating the vector. For example, if your vector is supposed to hold integers:

rust Copy code let mut account_diff: Vec = Vec::new(); This specifies that account_diff will hold values of type u32.

  1. Error about no field from_block: This error means you're trying to access a field (from_block) that Rust doesn't recognize for the given data type. Double-check the type of the variable op. Ensure it’s the correct type that should have the from_block field. If op is indeed the correct type but still causing errors, there might be an issue with how it’s defined or used.

  2. Warnings about unused imports: Rust is telling you that you've imported some modules or functions (ToBigInt, ToPrimitive) that you're not using anywhere in your code. You can safely remove these imports to clean up your code:

rust Copy code // Remove or comment out these lines // use num::bigint::ToBigInt; // use num::ToPrimitive; If any of these issues persist after you make changes, try running cargo check to get a quick overview of errors without compiling the whole project. This can help you catch issues faster.