diff --git a/.circleci/config.yml b/.circleci/config.yml index e0d6f6f34..a7a95ce52 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -141,12 +141,12 @@ jobs: name: Check Format command: make fmt - save_cache: *save-source-codes-cache - - run: *before-restore-security-audit-cache - - restore_cache: *restore-security-audit-cache - - run: - name: Check Security Audit - command: make security_audit - - save_cache: *save-security-audit-cache + # - run: *before-restore-security-audit-cache + # - restore_cache: *restore-security-audit-cache + # - run: + # name: Check Security Audit + # command: make security_audit + # - save_cache: *save-security-audit-cache "Check Contracts": docker: @@ -415,7 +415,7 @@ workflows: - "Check Basic" - - "Check Contracts" + # - "Check Contracts" # - "Test Coverage": # requires: @@ -428,81 +428,84 @@ workflows: requires: - "Check Basic" - - "Unit Test (sha3 & secp256k1)": - requires: - - "Release" + # - "Unit Test (sha3 & secp256k1)": + # requires: + # - "Release" - - "Basic Test": - requires: - - "Release" - - "Basic Tls Test": - requires: - - "Release" + # - "Basic Test": + # requires: + # - "Release" + # - "Basic Tls Test": + # requires: + # - "Release" - - "JSON-RPC Mock Test in Charge Mode": - requires: - - "Release" - - "JSON-RPC Mock Test in Quota Mode": - requires: - - "Release" - - "Test Transfer Value in Charge Mode": - requires: - - "Release" - - "Test System Features": - requires: - - "Release" - - "Test Snapshot Taking And Restoring": - requires: - - "Release" - - "Test Amend": - requires: - - "Release" - - "Test Executor Process Invalid Proof": - requires: - - "Release" + # - "JSON-RPC Mock Test in Charge Mode": + # requires: + # - "Release" + # - "JSON-RPC Mock Test in Quota Mode": + # requires: + # - "Release" + # - "Test Transfer Value in Charge Mode": + # requires: + # - "Release" + # - "Test System Features": + # requires: + # - "Release" + # - "Test Snapshot Taking And Restoring": + # requires: + # - "Release" + # - "Test Amend": + # requires: + # - "Release" + # - "Test Executor Process Invalid Proof": + # requires: + # - "Release" - - "Discovery Test for network": - requires: - - "Release" - - "Byzantine Test in Quota Mode": - requires: - - "Release" - - "Byzantine Test in Charge Mode": - requires: - - "Release" - - "Crosschain Test": - requires: - - "Release" - - "Robustness Test": - requires: - - "Release" - - "Genesis Test": - requires: - - "Release" + # - "Discovery Test for network": + # requires: + # - "Release" + # - "Byzantine Test in Quota Mode": + # requires: + # - "Release" + # - "Byzantine Test in Charge Mode": + # requires: + # - "Release" + # - "Crosschain Test": + # requires: + # - "Release" + # - "Robustness Test": + # requires: + # - "Release" + # - "Genesis Test": + # requires: + # - "Release" - - "Unit Test (blake2b & ed25519)": - requires: - - "Unit Test (sha3 & secp256k1)" - - "Unit Test (sm3 & sm2)": - requires: - - "Unit Test (sha3 & secp256k1)" + # - "Unit Test (blake2b & ed25519)": + # requires: + # - "Unit Test (sha3 & secp256k1)" + # - "Unit Test (sm3 & sm2)": + # requires: + # - "Unit Test (sha3 & secp256k1)" - "Passed": requires: - - "Basic Test" - - "Basic Tls Test" - - "JSON-RPC Mock Test in Charge Mode" - - "JSON-RPC Mock Test in Quota Mode" - - "Test Transfer Value in Charge Mode" - - "Test System Features" - - "Test Snapshot Taking And Restoring" - - "Test Amend" - - "Test Executor Process Invalid Proof" - - "Discovery Test for network" - - "Byzantine Test in Quota Mode" - - "Byzantine Test in Charge Mode" - - "Crosschain Test" - - "Robustness Test" - - "Genesis Test" - - "Unit Test (blake2b & ed25519)" - - "Unit Test (sm3 & sm2)" + - "Check Basic" + - "Check Clippy" + - "Release" + # - "Basic Test" + # - "Basic Tls Test" + # - "JSON-RPC Mock Test in Charge Mode" + # - "JSON-RPC Mock Test in Quota Mode" + # - "Test Transfer Value in Charge Mode" + # - "Test System Features" + # - "Test Snapshot Taking And Restoring" + # - "Test Amend" + # - "Test Executor Process Invalid Proof" + # - "Discovery Test for network" + # - "Byzantine Test in Quota Mode" + # - "Byzantine Test in Charge Mode" + # - "Crosschain Test" + # - "Robustness Test" + # - "Genesis Test" + # - "Unit Test (blake2b & ed25519)" + # - "Unit Test (sm3 & sm2)" diff --git a/cita-executor/core/src/cita_executive.rs b/cita-executor/core/src/cita_executive.rs index a7b2153b9..a12170f50 100644 --- a/cita-executor/core/src/cita_executive.rs +++ b/cita-executor/core/src/cita_executive.rs @@ -112,7 +112,7 @@ impl<'a, B: DB + 'static> CitaExecutive<'a, B> { let init_gas = t.gas - U256::from(base_gas_required); - let result = match t.action { + match t.action { Action::Store | Action::AbiStore => { // Prepaid t.gas for the transaction. self.prepaid(t.sender(), t.gas, t.gas_price, t.value)?; @@ -215,9 +215,7 @@ impl<'a, B: DB + 'static> CitaExecutive<'a, B> { }; self.call(¶ms) } - }; - - result + } } fn payment_required(&self) -> bool { @@ -253,7 +251,7 @@ impl<'a, B: DB + 'static> CitaExecutive<'a, B> { self.state_provider .borrow_mut() .add_balance(address, value) - .map_err(|e| ExecutionError::State(e)) + .map_err(ExecutionError::State) } else { Ok(()) } @@ -268,7 +266,7 @@ impl<'a, B: DB + 'static> CitaExecutive<'a, B> { self.state_provider .borrow_mut() .add_balance(coin_base, fee_value) - .map_err(|e| ExecutionError::State(e)) + .map_err(ExecutionError::State) } else { Ok(()) } @@ -284,7 +282,7 @@ impl<'a, B: DB + 'static> CitaExecutive<'a, B> { self.state_provider .borrow_mut() .transfer_balance(from, to, value) - .map_err(|e| ExecutionError::State(e)) + .map_err(ExecutionError::State) } else { Ok(()) } @@ -414,7 +412,7 @@ impl<'a, B: DB + 'static> CitaExecutive<'a, B> { fn call_evm(&mut self, params: &VmExecParams) -> Result { let evm_transaction = build_evm_transaction(params); - let evm_config = build_evm_config(self.env_info.gas_limit.clone().as_u64()); + let evm_config = build_evm_config(self.env_info.gas_limit.as_u64()); let evm_context = build_evm_context(&self.env_info); let result = match cita_vm::exec( self.block_provider.clone(), @@ -441,23 +439,20 @@ impl<'a, B: DB + 'static> CitaExecutive<'a, B> { self.state_provider.borrow_mut().checkpoint(); // At first, transfer value to destination. - if self.payment_required() { - if self + if self.payment_required() + && self .transfer_balance(¶ms.sender, ¶ms.to_address.unwrap(), params.value) .is_err() - { - // Discard the checkpoint - self.state_provider.borrow_mut().revert_checkpoint(); - return Err(ExecutionError::Internal( - "Transfer balance failed while calling native contract.".to_string(), - )); - } + { + // Discard the checkpoint + self.state_provider.borrow_mut().revert_checkpoint(); + return Err(ExecutionError::Internal( + "Transfer balance failed while calling native contract.".to_string(), + )); } let store = VmSubState::default(); - let store = Arc::new(RefCell::new(store)); - let mut vm_data_provider = DataProvider::new( self.block_provider.clone(), self.state_provider.clone(), diff --git a/cita-executor/core/src/libexecutor/block.rs b/cita-executor/core/src/libexecutor/block.rs index 3a1dfcfd0..678e8e4de 100644 --- a/cita-executor/core/src/libexecutor/block.rs +++ b/cita-executor/core/src/libexecutor/block.rs @@ -156,7 +156,7 @@ impl ExecutedBlock { if (*conf).check_options.fee_back_platform { // Set coin_base to chain_owner if check_fee_back_platform is true, and chain_owner is set. if (*conf).chain_owner != Address::from(0) { - env_info.coin_base = (*conf).chain_owner.clone(); + env_info.coin_base = (*conf).chain_owner; } } let block_data_provider = EVMBlockDataProvider::new(env_info.clone()); @@ -175,10 +175,10 @@ impl ExecutedBlock { // FIXME: logic from old cita, but there is some confuse about this logic. let quota_used = U256::from(ret.quota_used); let transaction_quota_used = quota_used - self.current_quota_used; - self.current_quota_used = U256::from(quota_used); + self.current_quota_used = quota_used; if conf.check_options.quota { if let Some(value) = self.account_gas.get_mut(t.sender()) { - *value = *value - transaction_quota_used; + *value -= transaction_quota_used; } } diff --git a/cita-executor/core/src/libexecutor/command.rs b/cita-executor/core/src/libexecutor/command.rs index 464a0929f..d797ef103 100644 --- a/cita-executor/core/src/libexecutor/command.rs +++ b/cita-executor/core/src/libexecutor/command.rs @@ -301,7 +301,7 @@ impl Commander for Executor { let native_factory = NativeFactory::default(); let state_root = if let Some(h) = self.block_header(block_id) { - (*h.state_root()).clone() + (*h.state_root()) } else { error!("Can not get state rott from trie db!"); return Err(CallError::StatePruned); diff --git a/cita-executor/core/src/storage.rs b/cita-executor/core/src/storage.rs index fcd0f25c2..bee68053c 100644 --- a/cita-executor/core/src/storage.rs +++ b/cita-executor/core/src/storage.rs @@ -100,7 +100,7 @@ impl Scalar { for chunk in encoded.chunks(32) { let value = H256::from(chunk); data_provider.set_storage(addr, H256::from(key), value); - key = key + U256::one(); + key += U256::one(); } } Ok(()) @@ -129,7 +129,7 @@ impl Scalar { let v = data_provider.get_storage(addr, &H256::from(key)); if len > 32 { bytes.extend_from_slice(v.as_ref()); - key = key + U256::one(); + key += U256::one(); len -= 32; } else { bytes.extend_from_slice(&v[0..len]); @@ -153,7 +153,7 @@ impl Array { #[inline] fn key(&self, index: u64) -> H256 { let mut key = U256::from(H256::from_slice(&sha3::keccak256(&self.position))); - key = key + U256::from(index); + key += U256::from(index); H256::from(key) }