Skip to content

Commit

Permalink
Revert "Release V0.4.4 (#1588)"
Browse files Browse the repository at this point in the history
This reverts commit bd348d8.
  • Loading branch information
bowenwang1996 authored Oct 30, 2019
1 parent bd348d8 commit 1285ac1
Show file tree
Hide file tree
Showing 142 changed files with 64,940 additions and 80,231 deletions.
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Generated by Cargo
# will have compiled files and executables
target
docker-build
**/target/
/storage/
/test-utils/node/storage
Expand Down Expand Up @@ -42,6 +41,3 @@ tmp/

# Logs
*.log

# Vim tmp files
*.swp
1 change: 0 additions & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ test_cargo:
- *setup_cache
script:
- rustc --version && cargo --version
- cargo fmt --all -- --check
- cargo check --all --tests --benches --all-features
- cargo test --all --verbose

Expand Down
2 changes: 0 additions & 2 deletions CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,3 @@
/chain/ @ilblackdragon @SkidanovAlex

/runtime/ @nearmax @evgenykuzyakov

/genesis-tools/ @nearmax
2,285 changes: 1,196 additions & 1,089 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,14 @@ members = [
"test-utils/loadtester",
"test-utils/state-viewer",
"near/",
"genesis-tools/genesis-csv-to-json",
"genesis-tools/genesis-populate",
"genesis-tools/keypair-generator",
]

[dev-dependencies]
actix = "0.8.2"
lazy_static = "1.4.0"
log = "0.4.6"
rand = "0.7"
rand = "0.6"
serde_json = "1.0.0"
reqwest = "0.9"
futures = "0.1.25"
Expand Down
6 changes: 1 addition & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,7 @@ RUN --mount=type=cache,target=/tmp/target \
--mount=type=cache,target=/usr/local/cargo/git \
--mount=type=cache,target=/usr/local/cargo/registry \
cargo build -p near --release && \
cargo build -p keypair-generator --release && \
cargo build -p genesis-csv-to-json --release && \
cp /tmp/target/release/near /usr/local/bin/ && \
cp /tmp/target/release/keypair-generator /usr/local/bin && \
cp /tmp/target/release/genesis-csv-to-json /usr/local/bin
cp /tmp/target/release/near /usr/local/bin/

EXPOSE 3030 24567

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.prod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ FROM phusion/baseimage:0.11
EXPOSE 3030 24567

COPY scripts/run_docker.sh /usr/local/bin/run.sh
COPY docker-build/* /usr/local/bin/
COPY docker-build/near /usr/local/bin/near

ENTRYPOINT ["/sbin/my_init", "--"]

Expand Down
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@ docker-nearcore:
DOCKER_BUILDKIT=1 docker build -t nearcore-dev -f Dockerfile .
mkdir -p docker-build
docker run -v ${PWD}/docker-build:/opt/mount --rm --entrypoint cp nearcore-dev /usr/local/bin/near /opt/mount/near
docker run -v ${PWD}/docker-build:/opt/mount --rm --entrypoint cp nearcore-dev /usr/local/bin/genesis-csv-to-json /opt/mount/genesis-csv-to-json
docker run -v ${PWD}/docker-build:/opt/mount --rm --entrypoint cp nearcore-dev /usr/local/bin/keypair-generator /opt/mount/keypair-generator
docker build -t nearcore -f Dockerfile.prod .
rm -rf docker-build
2 changes: 1 addition & 1 deletion async-utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ authors = ["Near Inc <[email protected]>"]
edition = "2018"

[dependencies]
futures03 = { package = "futures-preview", version = "0.3.0-alpha.19", features = ["compat", "async-await"] }
futures03 = { package = "futures-preview", version = "0.3.0-alpha.16", features = ["compat", "async-await", "nightly"] }
tokio = "0.1.15"
4 changes: 3 additions & 1 deletion async-utils/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![feature(await_macro, async_await)]

use std::time::{Duration, Instant};

use futures03::{compat::Future01CompatExt as _, FutureExt as _};
Expand All @@ -8,7 +10,7 @@ use futures03::{compat::Future01CompatExt as _, FutureExt as _};
/// It is useful when the `futures-preview` is imported as `futures03`.
macro_rules! select { // replace `::futures_util` with `::futures03` as the crate path
($($tokens:tt)*) => {
futures03::inner_macro::select! {
futures03::inner_select::select! {
futures_crate_path ( ::futures03 )
$( $tokens )*
}
Expand Down
2 changes: 1 addition & 1 deletion chain/chain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ serde_derive = "1.0"
cached = "0.9.0"
lazy_static = "1.4"

borsh = "0.2.9"
borsh = "0.2.7"

near-crypto = { path = "../../core/crypto" }
near-primitives = { path = "../../core/primitives" }
Expand Down
78 changes: 2 additions & 76 deletions chain/chain/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use near_primitives::receipt::Receipt;
use near_primitives::sharding::{
ChunkHash, ChunkHashHeight, ReceiptProof, ShardChunk, ShardChunkHeader, ShardProof,
};
use near_primitives::transaction::{ExecutionOutcome, ExecutionStatus};
use near_primitives::transaction::ExecutionOutcome;
use near_primitives::types::{AccountId, Balance, BlockIndex, ChunkExtra, Gas, ShardId};
use near_store::{Store, COL_STATE_HEADERS};

Expand All @@ -27,10 +27,6 @@ use crate::types::{
ReceiptProofResponse, ReceiptResponse, RootProof, RuntimeAdapter, ShardStateSyncResponseHeader,
ShardStateSyncResponsePart, StateHeaderKey, Tip, ValidatorSignatureVerificationResult,
};
use near_primitives::views::{
ExecutionOutcomeView, ExecutionOutcomeWithIdView, ExecutionStatusView,
FinalExecutionOutcomeView, FinalExecutionStatus,
};

/// Maximum number of orphans chain can store.
pub const MAX_ORPHAN_SIZE: usize = 1024;
Expand Down Expand Up @@ -1312,72 +1308,6 @@ impl Chain {

Ok(())
}

pub fn get_transaction_execution_result(
&mut self,
hash: &CryptoHash,
) -> Result<ExecutionOutcomeView, String> {
match self.get_transaction_result(hash) {
Ok(result) => Ok(result.clone().into()),
Err(err) => match err.kind() {
ErrorKind::DBNotFoundErr(_) => {
Ok(ExecutionOutcome { status: ExecutionStatus::Unknown, ..Default::default() }
.into())
}
_ => Err(err.to_string()),
},
}
}

fn get_recursive_transaction_results(
&mut self,
hash: &CryptoHash,
) -> Result<Vec<ExecutionOutcomeWithIdView>, String> {
let outcome = self.get_transaction_execution_result(hash)?;
let receipt_ids = outcome.receipt_ids.clone();
let mut transactions = vec![ExecutionOutcomeWithIdView { id: (*hash).into(), outcome }];
for hash in &receipt_ids {
transactions
.extend(self.get_recursive_transaction_results(&hash.clone().into())?.into_iter());
}
Ok(transactions)
}

pub fn get_final_transaction_result(
&mut self,
hash: &CryptoHash,
) -> Result<FinalExecutionOutcomeView, String> {
let mut outcomes = self.get_recursive_transaction_results(hash)?;
let mut looking_for_id = (*hash).into();
let num_outcomes = outcomes.len();
let status = outcomes
.iter()
.find_map(|outcome_with_id| {
if outcome_with_id.id == looking_for_id {
match &outcome_with_id.outcome.status {
ExecutionStatusView::Unknown if num_outcomes == 1 => {
Some(FinalExecutionStatus::NotStarted)
}
ExecutionStatusView::Unknown => Some(FinalExecutionStatus::Started),
ExecutionStatusView::Failure(e) => {
Some(FinalExecutionStatus::Failure(e.clone()))
}
ExecutionStatusView::SuccessValue(v) => {
Some(FinalExecutionStatus::SuccessValue(v.clone()))
}
ExecutionStatusView::SuccessReceiptId(id) => {
looking_for_id = id.clone();
None
}
}
} else {
None
}
})
.expect("results should resolve to a final outcome");
let receipts = outcomes.split_off(1);
Ok(FinalExecutionOutcomeView { status, transaction: outcomes.pop().unwrap(), receipts })
}
}

/// Various chain getters.
Expand Down Expand Up @@ -1507,7 +1437,7 @@ impl Chain {

/// Returns underlying RuntimeAdapter.
#[inline]
pub fn runtime_adapter(&self) -> Arc<dyn RuntimeAdapter> {
pub fn runtime_adapter(&self) -> Arc<RuntimeAdapter> {
self.runtime_adapter.clone()
}

Expand Down Expand Up @@ -2035,10 +1965,6 @@ impl<'a> ChainUpdate<'a> {
return Err(ErrorKind::InvalidEpochHash.into());
}

if header.inner.chunk_mask.len() as u64 != self.runtime_adapter.num_shards() {
return Err(ErrorKind::InvalidChunkMask.into());
}

// Prevent time warp attacks and some timestamp manipulations by forcing strict
// time progression.
if header.inner.timestamp <= prev_header.inner.timestamp {
Expand Down
7 changes: 3 additions & 4 deletions chain/chain/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,6 @@ pub enum ErrorKind {
/// Invalid chunk.
#[fail(display = "Invalid Chunk")]
InvalidChunk,
/// Invalid chunk mask
#[fail(display = "Invalid Chunk Mask")]
InvalidChunkMask,
/// Invalid epoch hash
#[fail(display = "Invalid Epoch Hash")]
InvalidEpochHash,
Expand Down Expand Up @@ -159,7 +156,6 @@ impl Error {
| ErrorKind::InvalidBlockConfirmation
| ErrorKind::InvalidBlockWeight
| ErrorKind::InvalidChunk
| ErrorKind::InvalidChunkMask
| ErrorKind::InvalidStateRoot
| ErrorKind::InvalidTxRoot
| ErrorKind::InvalidChunkReceiptsRoot
Expand Down Expand Up @@ -203,3 +199,6 @@ impl From<String> for Error {
}

impl std::error::Error for Error {}

unsafe impl Send for Error {}
unsafe impl Sync for Error {}
9 changes: 5 additions & 4 deletions chain/chain/src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ use near_primitives::transaction::{
TransferAction,
};
use near_primitives::types::{
AccountId, Balance, BlockIndex, EpochId, MerkleHash, Nonce, ShardId, StateRoot, ValidatorStake,
AccountId, Balance, BlockIndex, EpochId, MerkleHash, Nonce, ShardId, StateRoot,
ValidatorStake,
};
use near_primitives::views::QueryResponse;
use near_store::test_utils::create_test_store;
Expand All @@ -31,7 +32,7 @@ use crate::types::{
ValidatorSignatureVerificationResult, Weight,
};
use crate::{Chain, ChainGenesis, ValidTransaction};
use near_primitives::errors::RuntimeError;
use near_primitives::errors::InvalidTxErrorOrStorageError;
use near_primitives::merkle::{merklize, verify_path, MerklePath};

pub const DEFAULT_STATE_NUM_PARTS: u64 = 17; /* TODO MOO */
Expand Down Expand Up @@ -178,7 +179,7 @@ impl KeyValueRuntime {
}
let prev_block_header = self
.get_block_header(prev_hash)?
.ok_or_else(|| format!("Missing block {} when computing the epoch", prev_hash))?;
.ok_or(format!("Missing block {} when computing the epoch", prev_hash))?;
Ok(prev_block_header.inner.height)
}

Expand Down Expand Up @@ -440,7 +441,7 @@ impl RuntimeAdapter for KeyValueRuntime {
_gas_price: Balance,
_state_root: StateRoot,
transaction: SignedTransaction,
) -> Result<ValidTransaction, RuntimeError> {
) -> Result<ValidTransaction, InvalidTxErrorOrStorageError> {
Ok(ValidTransaction { transaction })
}

Expand Down
4 changes: 2 additions & 2 deletions chain/chain/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use borsh::{BorshDeserialize, BorshSerialize};

use near_crypto::{Signature, Signer};
pub use near_primitives::block::{Block, BlockHeader, Weight};
use near_primitives::errors::RuntimeError;
use near_primitives::errors::InvalidTxErrorOrStorageError;
use near_primitives::hash::{hash, CryptoHash};
use near_primitives::merkle::{merklize, MerklePath};
use near_primitives::receipt::Receipt;
Expand Down Expand Up @@ -141,7 +141,7 @@ pub trait RuntimeAdapter: Send + Sync {
gas_price: Balance,
state_root: StateRoot,
transaction: SignedTransaction,
) -> Result<ValidTransaction, RuntimeError>;
) -> Result<ValidTransaction, InvalidTxErrorOrStorageError>;

/// Filter transactions by verifying each one by one in the given order. Every successful
/// verification stores the updated account balances to be used by next transactions.
Expand Down
9 changes: 7 additions & 2 deletions chain/chunks/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,20 @@ edition = "2018"

[dependencies]
actix = "0.8.1"
typed-arena = "1.4.1"
futures = "0.1.25"
tokio = "0.1"
rand = "0.7"
rand = "0.6"
rand_xorshift = "0.1"
chrono = "0.4.6"
log = "0.4"
borsh = "0.2.9"
borsh = "0.2.2"
serde = "1.0"
serde_derive = "1.0"
elapsed = "0.1"
protobuf = "2.4"
reed-solomon-erasure = "3.1.1"
crossbeam = "0.3.0"
cached = "0.9.0"

near-crypto = { path = "../../core/crypto" }
Expand Down
4 changes: 2 additions & 2 deletions chain/client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ authors = ["Near Inc <[email protected]>"]
edition = "2018"

[dependencies]
ansi_term = "0.12"
ansi_term = "0.11.0"
actix = "0.8.1"
futures = "0.1"
chrono = { version = "0.4.4", features = ["serde"] }
kvdb = "0.1"
log = "0.4"
rand = "0.7"
rand = "0.6.5"
serde = { version = "1.0", features = ["derive"] }
serde_derive = "1.0"
serde_json = "1.0"
Expand Down
Loading

0 comments on commit 1285ac1

Please sign in to comment.