Skip to content

Commit

Permalink
Fix Review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
vldm committed Jan 12, 2022
1 parent d157e35 commit a6a127e
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 137 deletions.
28 changes: 14 additions & 14 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,39 +14,39 @@ jobs:
runs-on: build
steps:
- uses: actions/checkout@v2
- name: install dependencies
run: |
apt-get update
DEBIAN_FRONTEND=noninteractive apt-get -q -y install curl git libssl-dev libudev-dev make pkg-config zlib1g-dev llvm clang
- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
toolchain: 1.55
components: clippy
- name: install dependencies
run: |
apt-get update
apt-get -y install curl git libssl-dev libudev-dev make pkg-config zlib1g-dev llvm clang
- name: Run cargo clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: -- -Dwarnings
test:
name: test
container:
image: ubuntu:20.04
runs-on: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: install dependencies
run: |
sudo apt-get update
DEBIAN_FRONTEND=noninteractive sudo apt-get -q -y install curl git libssl-dev libudev-dev make pkg-config zlib1g-dev llvm clang
- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: install dependencies
toolchain: 1.55
- name: Setting limits
run: |
apt-get update
apt-get -y install curl git libssl-dev libudev-dev make pkg-config zlib1g-dev llvm clang
sudo sysctl -w fs.file-max=5000000
sudo sysctl -w vm.max_map_count=5000000
- name: Run cargo test
uses: actions-rs/cargo@v1
with:
Expand Down
127 changes: 19 additions & 108 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 15 additions & 7 deletions core/src/evm_rpc_impl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use evm_rpc::error::EvmStateError;
use evm_rpc::{
basic::BasicERPC,
chain_mock::ChainMockERPC,
error::{into_native_error, BlockNotFound, Error},
error::{into_native_error, BlockNotFound, Error, StateNotFoundForBlock},
trace::TraceMeta,
BlockId, BlockRelId, Bytes, Either, Hex, RPCBlock, RPCLog, RPCLogFilter, RPCReceipt,
RPCTopicFilter, RPCTransaction,
Expand Down Expand Up @@ -49,9 +49,13 @@ impl StateRootWithBank {
return Ok(evm.get_account_state(address));
}
let archive_evm_state = meta.evm_state_archive().ok_or(Error::ArchiveNotSupported)?;
archive_evm_state
ensure!(
archive_evm_state.kvs().check_root_exist(root),
StateNotFoundForBlock { block: self.block }
);
Ok(archive_evm_state
.get_account_state_at(root, address)
.map_err(|_| Error::StateNotFoundForBlock { block: self.block }) // wrap error to typed
.unwrap_or_default())
}

pub fn get_storage_at(
Expand All @@ -73,9 +77,13 @@ impl StateRootWithBank {
return Ok(evm.get_storage(address, idx));
}
let archive_evm_state = meta.evm_state_archive().ok_or(Error::ArchiveNotSupported)?;
archive_evm_state
ensure!(
archive_evm_state.kvs().check_root_exist(root),
StateNotFoundForBlock { block: self.block }
);
Ok(archive_evm_state
.get_storage_at(root, address, idx)
.map_err(|_| Error::StateNotFoundForBlock { block: self.block }) // wrap error to typed
.unwrap_or_default())
}
}

Expand All @@ -100,7 +108,7 @@ fn block_to_state_root(
};
}
BlockId::RelativeId(BlockRelId::Earliest) | BlockId::Num(Hex(0)) => {
meta.get_frist_available_evm_block()
meta.get_first_available_evm_block()
}
BlockId::Num(num) => num.0,
BlockId::BlockHash { block_hash } => {
Expand Down Expand Up @@ -139,7 +147,7 @@ fn block_parse_confirmed_num(
let block = block.unwrap_or_default();
match block {
BlockId::BlockHash { .. } => None,
BlockId::RelativeId(BlockRelId::Earliest) => Some(meta.get_frist_available_evm_block()),
BlockId::RelativeId(BlockRelId::Earliest) => Some(meta.get_first_available_evm_block()),
BlockId::RelativeId(BlockRelId::Pending) | BlockId::RelativeId(BlockRelId::Latest) => {
Some(meta.get_last_available_evm_block().unwrap_or_else(|| {
let bank = meta.bank(Some(CommitmentConfig::processed()));
Expand Down
Loading

0 comments on commit a6a127e

Please sign in to comment.