Skip to content

Commit

Permalink
update rust version (privacy-scaling-explorations#642)
Browse files Browse the repository at this point in the history
* update rust version

* fix clippy on features
  • Loading branch information
ChihChengLiang authored Jul 28, 2022
1 parent d1d07bb commit 7c759ee
Showing 17 changed files with 39 additions and 49 deletions.
6 changes: 3 additions & 3 deletions bus-mapping/src/circuit_input_builder/access.rs
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ use ethers_core::utils::get_contract_address;
use std::collections::{hash_map::Entry, HashMap, HashSet};

/// State and Code Access with "keys/index" used in the access operation.
#[derive(Debug, PartialEq)]
#[derive(Debug, PartialEq, Eq)]
pub enum AccessValue {
/// Account access
Account {
@@ -26,7 +26,7 @@ pub enum AccessValue {
}

/// State Access caused by a transaction or an execution step
#[derive(Debug, PartialEq)]
#[derive(Debug, PartialEq, Eq)]
pub struct Access {
step_index: Option<usize>,
rw: RW,
@@ -54,7 +54,7 @@ fn get_call_result(trace: &[GethExecStep]) -> Option<Word> {
}

/// State and Code Access set.
#[derive(Debug, PartialEq)]
#[derive(Debug, PartialEq, Eq)]
pub struct AccessSet {
/// Set of accounts
pub state: HashMap<Address, HashSet<Word>>,
2 changes: 1 addition & 1 deletion bus-mapping/src/circuit_input_builder/call.rs
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ use crate::{exec_trace::OperationRef, Error};
use eth_types::{evm_types::OpcodeId, Address, Hash, Word};

/// Type of a *CALL*/CREATE* Function.
#[derive(Clone, Copy, Debug, PartialEq)]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum CallKind {
/// CALL
Call,
4 changes: 2 additions & 2 deletions bus-mapping/src/circuit_input_builder/execution.rs
Original file line number Diff line number Diff line change
@@ -168,7 +168,7 @@ impl_expr!(CopyDataType);

/// Defines a single copy step in a copy event. This type is unified over the
/// source/destination row in the copy table.
#[derive(Clone, Debug, PartialEq)]
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct CopyStep {
/// Address (source/destination) for the copy step.
pub addr: u64,
@@ -191,7 +191,7 @@ pub struct CopyStep {
}

/// Defines an enum type that can hold either a number or a hash value.
#[derive(Clone, Debug, PartialEq)]
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum NumberOrHash {
/// Variant to indicate a number value.
Number(usize),
4 changes: 2 additions & 2 deletions bus-mapping/src/error.rs
Original file line number Diff line number Diff line change
@@ -59,7 +59,7 @@ impl Display for Error {
impl StdError for Error {}

/// Out of Gas errors by opcode
#[derive(Clone, Debug, PartialEq)]
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum OogError {
/// Out of Gas for opcodes which have non-zero constant gas cost
Constant,
@@ -105,7 +105,7 @@ pub enum OogError {
}

/// EVM Execution Error
#[derive(Clone, Debug, PartialEq)]
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum ExecError {
/// Invalid Opcode
InvalidOpcode,
2 changes: 1 addition & 1 deletion bus-mapping/src/state_db.rs
Original file line number Diff line number Diff line change
@@ -37,7 +37,7 @@ impl CodeDB {

/// Account of the Ethereum State Trie, which contains an in-memory key-value
/// database that represents the Account Storage Trie.
#[derive(Debug, PartialEq, Clone)]
#[derive(Debug, PartialEq, Eq, Clone)]
pub struct Account {
/// Nonce
pub nonce: Word,
4 changes: 2 additions & 2 deletions eth-types/src/bytecode.rs
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ use crate::{evm_types::OpcodeId, Bytes, Word};
use std::collections::HashMap;

/// Helper struct that represents a single element in a bytecode.
#[derive(Copy, Clone, Debug, Default, PartialEq)]
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq)]
pub struct BytecodeElement {
/// The byte value of the element.
pub value: u8,
@@ -13,7 +13,7 @@ pub struct BytecodeElement {
}

/// EVM Bytecode
#[derive(Debug, Default, Clone, PartialEq)]
#[derive(Debug, Default, Clone, PartialEq, Eq)]
pub struct Bytecode {
code: Vec<BytecodeElement>,
num_opcodes: usize,
4 changes: 2 additions & 2 deletions eth-types/src/lib.rs
Original file line number Diff line number Diff line change
@@ -194,7 +194,7 @@ impl<F: Field> ToScalar<F> for Address {
}

/// Struct used to define the storage proof
#[derive(Debug, Default, Clone, PartialEq, Deserialize)]
#[derive(Debug, Default, Clone, PartialEq, Eq, Deserialize)]
pub struct StorageProof {
/// Storage key
pub key: U256,
@@ -205,7 +205,7 @@ pub struct StorageProof {
}

/// Struct used to define the result of `eth_getProof` call
#[derive(Debug, Default, Clone, PartialEq, Deserialize)]
#[derive(Debug, Default, Clone, PartialEq, Eq, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct EIP1186ProofResponse {
/// Account address
6 changes: 3 additions & 3 deletions gadgets/src/less_than.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
//! Lt chip can be used to compare LT for two expressions LHS and RHS.
use std::array;

use eth_types::Field;
use halo2_proofs::{
arithmetic::FieldExt,
@@ -78,7 +76,9 @@ impl<F: Field, const N_BYTES: usize> LtChip<F, N_BYTES> {

let check_b = bool_check(lt);

array::IntoIter::new([check_a, check_b]).map(move |poly| q_enable.clone() * poly)
[check_a, check_b]
.into_iter()
.map(move |poly| q_enable.clone() * poly)
});

LtConfig { lt, diff, range }
2 changes: 1 addition & 1 deletion gadgets/src/util.rs
Original file line number Diff line number Diff line change
@@ -168,7 +168,7 @@ impl<F: FieldExt> Expr<F> for i32 {
#[inline]
fn expr(&self) -> Expression<F> {
Expression::Constant(
F::from(self.abs() as u64)
F::from(self.unsigned_abs() as u64)
* if self.is_negative() {
-F::one()
} else {
2 changes: 1 addition & 1 deletion keccak256/src/arith_helpers.rs
Original file line number Diff line number Diff line change
@@ -137,7 +137,7 @@ pub fn convert_b13_lane_to_b9(x: Lane13, rot: u32) -> Lane9 {
let mut chunks = x.to_radix_le(B13.into());
chunks.resize(65, 0);
// 0 and 64 was separated in Theta, we now combined them together
let special = chunks.get(0).unwrap() + chunks.get(64).unwrap();
let special = chunks.first().unwrap() + chunks.get(64).unwrap();
// middle 63 chunks
let middle = chunks.get(1..64).unwrap();
// split at offset
2 changes: 1 addition & 1 deletion keccak256/src/permutation/rho_helpers.rs
Original file line number Diff line number Diff line change
@@ -134,7 +134,7 @@ impl RhoLane {
chunks.resize(RHO_LANE_SIZE, 0);
let chunks: [u8; RHO_LANE_SIZE] = chunks.try_into().unwrap();
let special_high = *chunks.get(64).unwrap();
let special_low = *chunks.get(0).unwrap();
let special_low = *chunks.first().unwrap();
debug_assert!(special_high + special_low < B13, "invalid Rho input lane");
let output = convert_b13_lane_to_b9(input.clone(), rotation);

16 changes: 5 additions & 11 deletions prover/src/bin/prover_rpcd.rs
Original file line number Diff line number Diff line change
@@ -150,17 +150,11 @@ async fn handle_method(
let options: ProofRequestOptions =
serde_json::from_value(options.to_owned()).map_err(|e| e.to_string())?;

match shared_state.get_or_enqueue(&options).await {
// No error
None => Ok(serde_json::Value::Null),
Some(result) => {
if let Err(err) = result {
return Err(err);
}

Ok(serde_json::to_value(result.unwrap()).unwrap())
}
}
shared_state
.get_or_enqueue(&options)
.await
.map(|result| serde_json::to_value(result?).map_err(|e| e.to_string()))
.unwrap_or_else(|| Ok(serde_json::Value::Null))
}
// TODO/TBD: add method to only return the witnesses for a block.
// block table, tx table, etc...
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
nightly-2021-11-17
nightly-2022-07-26
14 changes: 5 additions & 9 deletions zkevm-circuits/src/bytecode_circuit/bytecode_unroller.rs
Original file line number Diff line number Diff line change
@@ -737,17 +737,13 @@ mod tests {
};

let prover = MockProver::<F>::run(k, &circuit, vec![]).unwrap();
let err = prover.verify();
let print_failures = true;
if err.is_err() && print_failures {
for e in err.err().iter() {
for s in e.iter() {
println!("{}", s);
}
let result = prover.verify();
if let Err(failures) = &result {
for failure in failures.iter() {
println!("{}", failure);
}
}
let err = prover.verify();
assert_eq!(err.is_ok(), success);
assert_eq!(result.is_ok(), success);
}

/// Verify unrolling code
6 changes: 3 additions & 3 deletions zkevm-circuits/src/evm_circuit.rs
Original file line number Diff line number Diff line change
@@ -584,9 +584,9 @@ mod evm_circuit_stats {
println!("| --- | --- | ---| --- | --- |");
for (state, opcode, height, gas_cost) in stats {
println!(
"| {: <14} | {: <14} | {: >2} | {: >6} | {: >1.3} |",
format!("{:?}", state),
format!("{:?}", opcode),
"| {: <14?} | {: <14?} | {: >2} | {: >6} | {: >1.3} |",
state,
opcode,
height,
gas_cost,
height as f64 / gas_cost as f64
10 changes: 5 additions & 5 deletions zkevm-circuits/src/evm_circuit/table.rs
Original file line number Diff line number Diff line change
@@ -160,15 +160,15 @@ pub enum RwTableTag {

impl RwTableTag {
pub fn is_reversible(self) -> bool {
return matches!(
matches!(
self,
RwTableTag::TxAccessListAccount
| RwTableTag::TxAccessListAccountStorage
| RwTableTag::TxRefund
| RwTableTag::Account
| RwTableTag::AccountStorage
| RwTableTag::AccountDestructed
);
)
}
}

@@ -192,21 +192,21 @@ pub enum BytecodeFieldTag {
Padding,
}

#[derive(Clone, Copy, Debug, PartialEq, EnumIter)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, EnumIter)]
pub enum TxLogFieldTag {
Address = 1,
Topic,
Data,
}

#[derive(Clone, Copy, Debug, PartialEq, EnumIter, EnumCount)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, EnumIter, EnumCount)]
pub enum TxReceiptFieldTag {
PostStateOrStatus = 1,
CumulativeGasUsed,
LogLength,
}

#[derive(Clone, Copy, Debug, PartialEq, EnumIter)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, EnumIter)]
pub enum CallContextFieldTag {
RwCounterEndOfReversion = 1,
CallerId,
2 changes: 1 addition & 1 deletion zkevm-circuits/src/state_circuit/test.rs
Original file line number Diff line number Diff line change
@@ -1009,7 +1009,7 @@ fn verify_with_overrides(
}

fn assert_error_matches(result: Result<(), Vec<VerifyFailure>>, name: &str) {
let errors = result.err().expect("result is not an error");
let errors = result.expect_err("result is not an error");
assert_eq!(errors.len(), 1, "{:?}", errors);
match &errors[0] {
VerifyFailure::ConstraintNotSatisfied { constraint, .. } => {

0 comments on commit 7c759ee

Please sign in to comment.