Skip to content

Commit

Permalink
Merge pull request #7 from anton-rs/refcell/upstream-sync
Browse files Browse the repository at this point in the history
chore: upstream sync
  • Loading branch information
refcell authored Sep 6, 2023
2 parents f2d59b9 + 21bba33 commit f97400f
Show file tree
Hide file tree
Showing 21 changed files with 681 additions and 277 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/book.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,26 +73,26 @@ jobs:
echo `pwd`/mdbook-template >> $GITHUB_PATH
- name: Build book
run: mdbook build
run: mdbook build documentation

- name: Build docs
run: RUSTDOCFLAGS="--enable-index-page -Zunstable-options" cargo +nightly doc --all --no-deps

- name: Move docs to book folder
run: |
mkdir -p target/book/docs
mv target/doc target/book/docs
mv target/doc documentation/book/docs
- name: Archive artifact
shell: sh
run: |
chmod -c -R +rX "target/book" |
chmod -c -R +rX "documentation/book" |
while read line; do
echo "::warning title=Invalid file permissions automatically fixed::$line"
done
tar \
--dereference --hard-dereference \
--directory "target/book" \
--directory "documentation/book" \
-cvf "$RUNNER_TEMP/artifact.tar" \
--exclude=.git \
--exclude=.github \
Expand Down
12 changes: 6 additions & 6 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions bins/revme/src/statetest/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ pub fn execute_test_suit(
));
let mut state = revm::db::StateBuilder::default()
.with_cached_prestate(cache)
.with_bundle_update()
.build();
let mut evm = revm::new();
evm.database(&mut state);
Expand Down Expand Up @@ -294,6 +295,7 @@ pub fn execute_test_suit(
));
let mut state = revm::db::StateBuilder::default()
.with_cached_prestate(cache)
.with_bundle_update()
.build();
evm.database(&mut state);
let _ =
Expand Down
2 changes: 2 additions & 0 deletions crates/interpreter/src/gas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ impl Gas {

/// Records an explicit cost.
///
/// Returns `false` if the gas limit is exceeded.
///
/// This function is called on every instruction in the interpreter if the feature
/// `no_gas_measuring` is not enabled.
#[inline(always)]
Expand Down
13 changes: 0 additions & 13 deletions crates/primitives/src/bytecode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,19 +101,6 @@ impl Bytecode {
}
}

/// Creates a new raw Bytecode with the given hash.
///
/// # Safety
///
/// The given `hash` has to be equal to the [`keccak256`] hash of the given `bytecode`.
#[inline]
pub unsafe fn new_raw_with_hash(bytecode: Bytes) -> Self {
Self {
bytecode,
state: BytecodeState::Raw,
}
}

/// Create new checked bytecode
///
/// # Safety
Expand Down
29 changes: 19 additions & 10 deletions crates/primitives/src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,32 +74,41 @@ impl<T: DatabaseRef> Database for WrapDatabaseRef<T> {
}
}

pub struct RefDBWrapper<'a, Error> {
pub db: &'a dyn DatabaseRef<Error = Error>,
/// Wraps a `dyn DatabaseRef` to provide a [`Database`] implementation.
#[doc(hidden)]
#[deprecated = "use `WrapDatabaseRef` instead"]
pub struct RefDBWrapper<'a, E> {
pub db: &'a dyn DatabaseRef<Error = E>,
}

impl<'a, Error> RefDBWrapper<'a, Error> {
pub fn new(db: &'a dyn DatabaseRef<Error = Error>) -> Self {
#[allow(deprecated)]
impl<'a, E> RefDBWrapper<'a, E> {
#[inline]
pub fn new(db: &'a dyn DatabaseRef<Error = E>) -> Self {
Self { db }
}
}

impl<'a, Error> Database for RefDBWrapper<'a, Error> {
type Error = Error;
/// Get basic account information.
#[allow(deprecated)]
impl<'a, E> Database for RefDBWrapper<'a, E> {
type Error = E;

#[inline]
fn basic(&mut self, address: B160) -> Result<Option<AccountInfo>, Self::Error> {
self.db.basic(address)
}
/// Get account code by its hash

#[inline]
fn code_by_hash(&mut self, code_hash: B256) -> Result<Bytecode, Self::Error> {
self.db.code_by_hash(code_hash)
}
/// Get storage value of address at index.

#[inline]
fn storage(&mut self, address: B160, index: U256) -> Result<U256, Self::Error> {
self.db.storage(address, index)
}

// History related
#[inline]
fn block_hash(&mut self, number: U256) -> Result<B256, Self::Error> {
self.db.block_hash(number)
}
Expand Down
10 changes: 5 additions & 5 deletions crates/primitives/src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ use crate::{
use bytes::Bytes;
use core::cmp::{min, Ordering};

#[derive(Clone, Debug, Default)]
#[derive(Clone, Debug, Default, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct Env {
pub cfg: CfgEnv,
pub block: BlockEnv,
pub tx: TxEnv,
}
#[derive(Clone, Debug, Eq, PartialEq)]
#[derive(Clone, Debug, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct BlockEnv {
pub number: U256,
Expand All @@ -30,7 +30,7 @@ pub struct BlockEnv {
pub gas_limit: U256,
}
#[cfg(feature = "optimism")]
#[derive(Clone, Debug, Default)]
#[derive(Clone, Debug, Default, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct OptimismFields {
pub source_hash: Option<B256>,
Expand All @@ -39,7 +39,7 @@ pub struct OptimismFields {
pub l1_cost: Option<U256>,
}

#[derive(Clone, Debug)]
#[derive(Clone, Debug, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct TxEnv {
/// Caller or Author or tx signer
Expand All @@ -59,7 +59,7 @@ pub struct TxEnv {
pub optimism: OptimismFields,
}

#[derive(Clone, Debug)]
#[derive(Clone, Debug, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum TransactTo {
Call(B160),
Expand Down
2 changes: 1 addition & 1 deletion crates/revm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ version = "3.3.0"
readme = "../../README.md"

[dependencies]
revm-precompile = { path = "../precompile", version = "2.0.2", default-features = false }
revm-interpreter = { path = "../interpreter", version = "1.1.2", default-features = false }
revm-precompile = { path = "../precompile", version = "2.0.2", default-features = false }

#misc
auto_impl = { version = "1.1", default-features = false }
Expand Down
2 changes: 1 addition & 1 deletion crates/revm/src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub mod states;
#[cfg(feature = "std")]
pub use states::{
AccountRevert, AccountStatus, BundleAccount, BundleState, CacheState, PlainAccount,
RevertToSlot, State, StateBuilder, StorageWithOriginalValues, TransitionAccount,
RevertToSlot, State, StateBuilder, StateDBBox, StorageWithOriginalValues, TransitionAccount,
TransitionState,
};

Expand Down
4 changes: 2 additions & 2 deletions crates/revm/src/db/states.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ pub use bundle_account::BundleAccount;
pub use bundle_state::BundleState;
pub use cache::CacheState;
pub use cache_account::CacheAccount;
pub use changes::{StateChangeset, StateReverts};
pub use changes::{PlainStateReverts, PlainStorageChangeset, PlainStorageRevert, StateChangeset};
pub use plain_account::{PlainAccount, StorageWithOriginalValues};
pub use reverts::{AccountRevert, RevertToSlot};
pub use state::State;
pub use state::{State, StateDBBox};
pub use state_builder::StateBuilder;
pub use transition_account::TransitionAccount;
pub use transition_state::TransitionState;
Loading

0 comments on commit f97400f

Please sign in to comment.