Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add basic ci #732

Merged
merged 2 commits into from
Jul 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
159 changes: 81 additions & 78 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -415,7 +415,7 @@ workflows:

- "Check Basic"

- "Check Contracts"
# - "Check Contracts"

# - "Test Coverage":
# requires:
Expand All @@ -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)"
33 changes: 14 additions & 19 deletions cita-executor/core/src/cita_executive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?;
Expand Down Expand Up @@ -215,9 +215,7 @@ impl<'a, B: DB + 'static> CitaExecutive<'a, B> {
};
self.call(&params)
}
};

result
}
}

fn payment_required(&self) -> bool {
Expand Down Expand Up @@ -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(())
}
Expand All @@ -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(())
}
Expand All @@ -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(())
}
Expand Down Expand Up @@ -414,7 +412,7 @@ impl<'a, B: DB + 'static> CitaExecutive<'a, B> {

fn call_evm(&mut self, params: &VmExecParams) -> Result<ExecutedResult, ExecutionError> {
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(),
Expand All @@ -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(&params.sender, &params.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(),
Expand Down
6 changes: 3 additions & 3 deletions cita-executor/core/src/libexecutor/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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;
}
}

Expand Down
2 changes: 1 addition & 1 deletion cita-executor/core/src/libexecutor/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions cita-executor/core/src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
Expand Down Expand Up @@ -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]);
Expand All @@ -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)
}

Expand Down