Executes an accelerated precompile on [revm].
(address: Address, input: T, gas: u64)
| 21 | |
| 22 | /// Executes an accelerated precompile on [revm]. |
| 23 | pub fn execute<T: Into<Bytes>>(address: Address, input: T, gas: u64) -> Result<Vec<u8>> { |
| 24 | if let Some(precompile) = |
| 25 | ACCELERATED_PRECOMPILES.iter().find(|precompile| *precompile.address() == address) |
| 26 | { |
| 27 | let input = input.into(); |
| 28 | let output = precompile |
| 29 | .execute(&input, gas, 0) |
| 30 | .map_err(|e| HostError::PrecompileExecutionFailed(e.to_string()))?; |
| 31 | if output.is_success() { |
| 32 | Ok(output.bytes.into()) |
| 33 | } else { |
| 34 | Err(HostError::PrecompileExecutionFailed(format!( |
| 35 | "precompile returned non-success status: {:?}", |
| 36 | output.status |
| 37 | ))) |
| 38 | } |
| 39 | } else { |
| 40 | Err(HostError::PrecompileNotAccelerated) |
| 41 | } |
| 42 | } |
no test coverage detected