rust-ethereum / evm

Pure Rust implementation of Ethereum Virtual Machine
Apache License 2.0
1.17k stars 360 forks source link

Question about `ApplyBackend` for v1.0.0 #270

Open mrLSD opened 9 months ago

mrLSD commented 9 months ago

Question

In the previous versions (for example v0.41) was trait:

/// EVM backend that can apply changes.
pub trait ApplyBackend {
    /// Apply given values and logs at backend.
    fn apply<A, I, L>(&mut self, values: A, logs: L, delete_empty: bool)
    where
        A: IntoIterator<Item = Apply<I>>,
        I: IntoIterator<Item = (H256, H256)>,
        L: IntoIterator<Item = Log>;
}

Current version v1.0.0-alpha.2 completely rafactored.

❓ Question is: as far as we will need to transfer from v0.x ➡️ v1.0 we need to understand clearly how to do that. Actually for ApplyBackend it's unclear. It seems apply logic was completely changed. I would be pleased for some advice on that point.

mrLSD commented 9 months ago

As it is provided new trait: https://github.com/rust-ethereum/evm/blob/master/src/backend/mod.rs

And it is really unclear, because previously: https://github.com/rust-ethereum/evm/blob/v0.36.0/src/backend/mod.rs#L30C13-L30C13

for apply operation was provided:

pub enum Apply<I> {
    /// Modify or create at address.
    Modify {
        /// Address.
        address: H160,
        /// Basic information of the address.
        basic: Basic,
        /// Code. `None` means leaving it unchanged.
        code: Option<Vec<u8>>,
        /// Storage iterator.
        storage: I,
        /// Whether storage should be wiped empty before applying the storage
        /// iterator.
        reset_storage: bool,
    },
    /// Delete address.
    Delete {
        /// Address.
        address: H160,
    },
}