Skip to content

Commit

Permalink
feat: blobbasefee return ONE (#972)
Browse files Browse the repository at this point in the history
  • Loading branch information
enitrat authored Sep 25, 2024
1 parent 8706363 commit 01641a7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions crates/contracts/src/cairo1_helpers.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ pub trait IPrecompiles<T> {
/// # Returns
///
/// * A tuple containing:
/// * A boolean indicating the success or failure of the execution.
/// * The gas cost of the execution.
/// * True if the execution was successful, false otherwise.
/// * The gas cost of the execution if successful, otherwise 0.
/// * The output data from the execution.
fn exec_precompile(self: @T, address: felt252, data: Span<u8>) -> (bool, u64, Span<u8>);
}
Expand Down
9 changes: 5 additions & 4 deletions crates/evm/src/instructions/block_information.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use evm::gas;
use evm::model::vm::{VM, VMTrait};
use evm::stack::StackTrait;
use evm::state::StateTrait;
use utils::constants::MIN_BASE_FEE_PER_BLOB_GAS;
use utils::traits::{EthAddressTryIntoResultContractAddress, EthAddressIntoU256};

#[generate_trait]
Expand Down Expand Up @@ -131,7 +132,7 @@ pub impl BlockInformation of BlockInformationTrait {
fn exec_blobbasefee(ref self: VM) -> Result<(), EVMError> {
self.charge_gas(gas::BASE)?;

self.stack.push(0)
self.stack.push(MIN_BASE_FEE_PER_BLOB_GAS.into())
}
}

Expand Down Expand Up @@ -336,16 +337,16 @@ mod tests {


#[test]
fn test_blobbasefee_should_return_zero() {
fn test_blobbasefee_should_return_one() {
// 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');
assert_eq!(vm.stack.len(), 1);
assert_eq!(vm.stack.peek().unwrap(), 1);
}


Expand Down
1 change: 1 addition & 0 deletions crates/utils/src/constants.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ pub const CONTRACT_ADDRESS_PREFIX: felt252 = 'STARKNET_CONTRACT_ADDRESS';

// BLOCK
pub const BLOCK_GAS_LIMIT: u64 = 7_000_000;
pub const MIN_BASE_FEE_PER_BLOB_GAS: u64 = 1;
// CHAIN_ID = KKRT (0x4b4b5254) in ASCII
pub const CHAIN_ID: u64 = 1263227476;

Expand Down

0 comments on commit 01641a7

Please sign in to comment.