diff --git a/crates/handler/src/precompile_provider.rs b/crates/handler/src/precompile_provider.rs index b6224c6a4e..98583d6a65 100644 --- a/crates/handler/src/precompile_provider.rs +++ b/crates/handler/src/precompile_provider.rs @@ -120,6 +120,7 @@ impl PrecompileProvider for EthPrecompiles { match exec_result { Ok(output) => { + result.gas.record_refund(output.gas_refunded); let underflow = result.gas.record_cost(output.gas_used); assert!(underflow, "Gas underflow is not possible"); result.result = if output.reverted { diff --git a/crates/precompile/src/interface.rs b/crates/precompile/src/interface.rs index f05cd83bf4..3fff76b743 100644 --- a/crates/precompile/src/interface.rs +++ b/crates/precompile/src/interface.rs @@ -29,6 +29,8 @@ pub type PrecompileResult = Result; pub struct PrecompileOutput { /// Gas used by the precompile pub gas_used: u64, + /// Gas refunded by the precompile. + pub gas_refunded: i64, /// Output bytes pub bytes: Bytes, /// Whether the precompile reverted @@ -40,6 +42,7 @@ impl PrecompileOutput { pub fn new(gas_used: u64, bytes: Bytes) -> Self { Self { gas_used, + gas_refunded: 0, bytes, reverted: false, } @@ -49,6 +52,7 @@ impl PrecompileOutput { pub fn new_reverted(gas_used: u64, bytes: Bytes) -> Self { Self { gas_used, + gas_refunded: 0, bytes, reverted: true, }