Skip to content

Commit

Permalink
add storage_growth ref: rust-ethereum/evm#173
Browse files Browse the repository at this point in the history
  • Loading branch information
zjb0807 committed Jan 20, 2024
1 parent 322eca3 commit f46585e
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 12 deletions.
8 changes: 4 additions & 4 deletions Cargo.lock

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

6 changes: 3 additions & 3 deletions modules/evm-utility/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ sha3 = { workspace = true }

sp-std = { workspace = true }

evm = { git = "https://github.com/rust-blockchain/evm", rev = "b7b82c7e1fc57b7449d6dfa6826600de37cc1e65", default-features = false, features = ["with-codec"] }
evm-gasometer = { git = "https://github.com/rust-blockchain/evm", rev = "b7b82c7e1fc57b7449d6dfa6826600de37cc1e65", default-features = false }
evm-runtime = { git = "https://github.com/rust-blockchain/evm", rev = "b7b82c7e1fc57b7449d6dfa6826600de37cc1e65", default-features = false }
evm = { git = "https://github.com/rust-blockchain/evm", rev = "44bb77c27be9ee615eaa576ad914fbb461537276", default-features = false, features = ["with-codec"] }
evm-gasometer = { git = "https://github.com/rust-blockchain/evm", rev = "44bb77c27be9ee615eaa576ad914fbb461537276", default-features = false }
evm-runtime = { git = "https://github.com/rust-blockchain/evm", rev = "44bb77c27be9ee615eaa576ad914fbb461537276", default-features = false }
#evm = { version = "0.41.1", default-features = false, features = ["with-codec"] }
#evm-gasometer = { version = "0.41.0", default-features = false }
#evm-runtime = { version = "0.41.0", default-features = false }
Expand Down
7 changes: 6 additions & 1 deletion modules/evm/src/precompiles/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,12 @@ pub mod tests {
}
}

fn record_external_cost(&mut self, _ref_time: Option<u64>, _proof_size: Option<u64>) -> Result<(), ExitError> {
fn record_external_cost(
&mut self,
_ref_time: Option<u64>,
_proof_size: Option<u64>,
_storage_growth: Option<u64>,
) -> Result<(), ExitError> {
unimplemented!()
}

Expand Down
23 changes: 19 additions & 4 deletions modules/evm/src/runner/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,12 @@ pub trait StackState<'config>: Backend {
Ok(())
}

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

Expand Down Expand Up @@ -1167,9 +1172,12 @@ impl<'config, 'precompiles, S: StackState<'config>, P: PrecompileSet> StackExecu

match self.state.metadata_mut().gasometer.record_deposit(out.len()) {
Ok(()) => {
let code_len = out.len();
self.state.set_code(address, out);
let exit_result = self.exit_substate(StackExitKind::Succeeded);
if let Err(e) = self.record_external_operation(crate::ExternalOperation::Write) {
if let Err(e) =
self.record_external_operation(crate::ExternalOperation::Write(U256::from(code_len)))
{
return (e.into(), None, Vec::new());
}
if let Err(e) = exit_result {
Expand Down Expand Up @@ -1601,8 +1609,15 @@ impl<'inner, 'config, 'precompiles, S: StackState<'config>, P: PrecompileSet> Pr
}

/// Record Substrate specific cost.
fn record_external_cost(&mut self, ref_time: Option<u64>, proof_size: Option<u64>) -> Result<(), ExitError> {
self.executor.state.record_external_cost(ref_time, proof_size)
fn record_external_cost(
&mut self,
ref_time: Option<u64>,
proof_size: Option<u64>,
storage_growth: Option<u64>,
) -> Result<(), ExitError> {
self.executor
.state
.record_external_cost(ref_time, proof_size, storage_growth)
}

/// Refund Substrate specific cost.
Expand Down

0 comments on commit f46585e

Please sign in to comment.