Skip to content

Commit

Permalink
runtime-sdk/evm/precompile: Split standard precompiles into submodules
Browse files Browse the repository at this point in the history
  • Loading branch information
peternose committed Jul 26, 2023
1 parent e904dcb commit 5b3b604
Show file tree
Hide file tree
Showing 7 changed files with 766 additions and 710 deletions.
14 changes: 14 additions & 0 deletions Cargo.lock

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

12 changes: 11 additions & 1 deletion runtime-sdk/modules/evm/src/precompile/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! EVM precompiles.

use std::marker::PhantomData;
use std::{cmp::min, marker::PhantomData};

use evm::{
executor::stack::{PrecompileFailure, PrecompileHandle, PrecompileOutput, PrecompileSet},
Expand Down Expand Up @@ -60,6 +60,16 @@ fn record_multilinear_cost(
Ok(())
}

/// Copies bytes from source to target.
fn read_input(source: &[u8], target: &mut [u8], offset: usize) {
if source.len() <= offset {
return;
}

let len = min(target.len(), source.len() - offset);
target[..len].copy_from_slice(&source[offset..offset + len]);
}

pub(crate) struct Precompiles<'a, Cfg: Config, B: EVMBackendExt> {
backend: &'a B,
config: PhantomData<Cfg>,
Expand Down
Loading

0 comments on commit 5b3b604

Please sign in to comment.