Skip to content

Commit

Permalink
Added very basic gas for opcodes
Browse files Browse the repository at this point in the history
  • Loading branch information
mrLSD committed Mar 29, 2024
1 parent b5cc743 commit 57c4d77
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
17 changes: 16 additions & 1 deletion gasometer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ pub fn static_opcode_cost(opcode: Opcode) -> Option<u32> {
}

/// Calculate the opcode cost.
#[allow(clippy::nonminimal_bool)]
#[allow(clippy::nonminimal_bool, clippy::cognitive_complexity)]
pub fn dynamic_opcode_cost<H: Handler>(
address: H160,
opcode: Opcode,
Expand Down Expand Up @@ -548,6 +548,21 @@ pub fn dynamic_opcode_cost<H: Handler>(
Opcode::BASEFEE if config.has_base_fee => GasCost::Base,
Opcode::BASEFEE => GasCost::Invalid(opcode),

Opcode::BLOBBASEFEE if config.has_blob_base_fee => GasCost::Base,
Opcode::BLOBBASEFEE => GasCost::Invalid(opcode),

Opcode::BLOBHASH if config.has_shard_blob_transactions => GasCost::VeryLow,
Opcode::BLOBHASH => GasCost::Invalid(opcode),

Opcode::TLOAD if config.has_transient_storage => todo!(),
Opcode::TLOAD => GasCost::Invalid(opcode),

Opcode::TSTORE if config.has_transient_storage => todo!(),
Opcode::TSTORE => GasCost::Invalid(opcode),

Opcode::MCOPY if config.has_mcopy => todo!(),
Opcode::MCOPY => GasCost::Invalid(opcode),

Opcode::EXTCODESIZE => {
let target = stack.peek_h256(0)?.into();
storage_target = StorageTarget::Address(target);
Expand Down
5 changes: 5 additions & 0 deletions runtime/src/eval/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ pub fn eval<H: Handler>(state: &mut Runtime, opcode: Opcode, handler: &mut H) ->
Opcode::STATICCALL => system::call(state, CallScheme::StaticCall, handler),
Opcode::CHAINID => system::chainid(state, handler),
Opcode::BASEFEE => system::base_fee(state, handler),
Opcode::BLOBBASEFEE => todo!(),
Opcode::BLOBHASH => todo!(),
Opcode::TLOAD => todo!(),
Opcode::TSTORE => todo!(),
Opcode::MCOPY => todo!(),
_ => handle_other(state, opcode, handler),
}
}
Expand Down

0 comments on commit 57c4d77

Please sign in to comment.