From 29034e387c2a2bcaab245da0a527af0ad7cb668d Mon Sep 17 00:00:00 2001 From: ADR!AN <111903096+adrianvrj@users.noreply.github.com> Date: Tue, 27 Aug 2024 02:44:07 -0600 Subject: [PATCH] feat: implemented BLOBBASEFEE (#872) * [feat] implemented BLOBBASEFEE * Apply suggestions from code review --------- Co-authored-by: Mathieu <60658558+enitrat@users.noreply.github.com> --- .../src/instructions/block_information.cairo | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/crates/evm/src/instructions/block_information.cairo b/crates/evm/src/instructions/block_information.cairo index 25ace5dbb..79f8ade62 100644 --- a/crates/evm/src/instructions/block_information.cairo +++ b/crates/evm/src/instructions/block_information.cairo @@ -125,6 +125,16 @@ impl BlockInformation of BlockInformationTrait { // doesn't really exists there so we just use the gas price) self.stack.push(self.env.gas_price.into()) } + + /// 0x4A - BLOBBASEFEE + /// Returns the value of the blob base-fee of the current block + /// Always returns Zero in the context of Kakarot + /// # Specification: https://www.evm.codes/#4a?fork=cancun + fn exec_blobbasefee(ref self: VM) -> Result<(), EVMError> { + self.charge_gas(gas::BASE)?; + + self.stack.push(0) + } } @@ -347,6 +357,19 @@ mod tests { assert(result == 0x00, 'stack top should be zero'); } + #[test] + fn test_blobbasefee_should_return_zero() { + // Given + let mut vm = VMBuilderTrait::new_with_presets().build(); + + // When + vm.exec_blobbasefee().unwrap(); + + // Then + assert(vm.stack.len() == 1, 'stack should have one element'); + assert(vm.stack.peek().unwrap() == 0, 'stack top should be 0'); + } + // ************************************************************************* // 0x41: COINBASE // *************************************************************************