Skip to content

Commit

Permalink
Update evm to v0.41.1 (polkadot-evm#1259)
Browse files Browse the repository at this point in the history
  • Loading branch information
sorpaas authored and boundless-forest committed Dec 29, 2023
1 parent 45d5f99 commit 2651f7b
Show file tree
Hide file tree
Showing 11 changed files with 49 additions and 46 deletions.
62 changes: 25 additions & 37 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ bn = { package = "substrate-bn", version = "0.6", default-features = false }
clap = { version = "4.4.3", features = ["derive", "deprecated"] }
derive_more = "0.99"
environmental = { version = "1.1.4", default-features = false }
ethereum = { version = "0.14.0", default-features = false }
ethereum = { version = "0.15.0", default-features = false }
ethereum-types = { version = "0.14.1", default-features = false }
evm = { git = "https://github.com/rust-blockchain/evm", rev = "b7b82c7e1fc57b7449d6dfa6826600de37cc1e65", default-features = false }
evm = { version = "0.41.1", default-features = false }
futures = "0.3.28"
hash-db = { version = "0.16.0", default-features = false }
hex = { version = "0.4.3", default-features = false, features = ["alloc"] }
Expand Down
7 changes: 5 additions & 2 deletions frame/evm/precompile/dispatch/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,11 @@ where
return Err(err);
}

handle
.record_external_cost(Some(info.weight.ref_time()), Some(info.weight.proof_size()))?;
handle.record_external_cost(
Some(info.weight.ref_time()),
Some(info.weight.proof_size()),
None,
)?;

match call.dispatch(Some(origin).into()) {
Ok(post_info) => {
Expand Down
1 change: 1 addition & 0 deletions frame/evm/precompile/dispatch/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ impl PrecompileHandle for MockHandle {
&mut self,
_ref_time: Option<u64>,
_proof_size: Option<u64>,
_storage_growth: Option<u64>,
) -> Result<(), ExitError> {
Ok(())
}
Expand Down
3 changes: 2 additions & 1 deletion frame/evm/src/runner/stack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -999,7 +999,7 @@ where
ExternalOperation::IsEmpty => {
weight_info.try_record_proof_size_or_fail(IS_EMPTY_CHECK_PROOF_SIZE)?
}
ExternalOperation::Write => {
ExternalOperation::Write(_) => {
weight_info.try_record_proof_size_or_fail(WRITE_PROOF_SIZE)?
}
};
Expand Down Expand Up @@ -1138,6 +1138,7 @@ where
&mut self,
ref_time: Option<u64>,
proof_size: Option<u64>,
_storage_growth: Option<u64>,
) -> Result<(), ExitError> {
let weight_info = if let (Some(weight_info), _) = self.info_mut() {
weight_info
Expand Down
7 changes: 6 additions & 1 deletion frame/evm/test-vector-support/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,12 @@ impl PrecompileHandle for MockHandle {
Ok(())
}

fn record_external_cost(&mut self, _: Option<u64>, _: Option<u64>) -> Result<(), ExitError> {
fn record_external_cost(
&mut self,
_: Option<u64>,
_: Option<u64>,
_: Option<u64>,
) -> Result<(), ExitError> {
Ok(())
}

Expand Down
3 changes: 2 additions & 1 deletion precompiles/src/evm/handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ impl<T: PrecompileHandle> PrecompileHandleExt for T {
) -> Result<(), evm::ExitError> {
self.record_cost(crate::prelude::RuntimeHelper::<Runtime>::db_read_gas_cost())?;
// TODO: record ref time when precompile will be benchmarked
self.record_external_cost(None, Some(data_max_encoded_len as u64))
self.record_external_cost(None, Some(data_max_encoded_len as u64), None)
}

/// Record cost of a log manualy.
Expand Down Expand Up @@ -190,6 +190,7 @@ mod tests {
&mut self,
_ref_time: Option<u64>,
_proof_size: Option<u64>,
_storage_growth: Option<u64>,
) -> Result<(), fp_evm::ExitError> {
Ok(())
}
Expand Down
4 changes: 3 additions & 1 deletion precompiles/src/precompile_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -477,8 +477,10 @@ impl<'a, H: PrecompileHandle> PrecompileHandle for RestrictiveHandle<'a, H> {
&mut self,
ref_time: Option<u64>,
proof_size: Option<u64>,
storage_growth: Option<u64>,
) -> Result<(), ExitError> {
self.handle.record_external_cost(ref_time, proof_size)
self.handle
.record_external_cost(ref_time, proof_size, storage_growth)
}

fn refund_external_cost(&mut self, ref_time: Option<u64>, proof_size: Option<u64>) {
Expand Down
2 changes: 1 addition & 1 deletion precompiles/src/substrate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ where

// Make sure there is enough remaining weight
// TODO: record ref time when precompile will be benchmarked
handle.record_external_cost(None, Some(weight.proof_size()))
handle.record_external_cost(None, Some(weight.proof_size()), None)
}

#[inline(always)]
Expand Down
1 change: 1 addition & 0 deletions precompiles/src/testing/handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ impl PrecompileHandle for MockHandle {
&mut self,
_ref_time: Option<u64>,
_proof_size: Option<u64>,
_storage_growth: Option<u64>,
) -> Result<(), ExitError> {
Ok(())
}
Expand Down
1 change: 1 addition & 0 deletions precompiles/tests-external/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ impl PrecompileHandle for MockPrecompileHandle {
&mut self,
_ref_time: Option<u64>,
_proof_size: Option<u64>,
_storage_growth: Option<u64>,
) -> Result<(), fp_evm::ExitError> {
Ok(())
}
Expand Down

0 comments on commit 2651f7b

Please sign in to comment.