Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions crates/handler/src/precompile_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ impl<CTX: ContextTr> PrecompileProvider<CTX> 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 {
Expand Down
4 changes: 4 additions & 0 deletions crates/precompile/src/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ pub type PrecompileResult = Result<PrecompileOutput, PrecompileError>;
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
Expand All @@ -40,6 +42,7 @@ impl PrecompileOutput {
pub fn new(gas_used: u64, bytes: Bytes) -> Self {
Self {
gas_used,
gas_refunded: 0,
bytes,
reverted: false,
}
Expand All @@ -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,
}
Expand Down
Loading