forked from kkrt-labs/keth
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement 0x4a: blob_base_fee (kkrt-labs#247)
Closes kkrt-labs#167
- Loading branch information
Showing
10 changed files
with
143 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
from starkware.cairo.common.alloc import alloc | ||
from starkware.cairo.common.cairo_builtins import HashBuiltin, BitwiseBuiltin, KeccakBuiltin | ||
from starkware.cairo.common.uint256 import Uint256, assert_uint256_eq | ||
from starkware.cairo.common.memcpy import memcpy | ||
from starkware.cairo.common.uint256 import ALL_ONES | ||
|
||
from src.instructions.block_information import BlockInformation | ||
from src.memory import Memory | ||
from src.model import model | ||
from src.stack import Stack | ||
from src.state import State | ||
from tests.utils.helpers import TestHelpers | ||
from src.utils.utils import Helpers | ||
|
||
func test__exec_blob_base_fee{ | ||
pedersen_ptr: HashBuiltin*, | ||
range_check_ptr, | ||
bitwise_ptr: BitwiseBuiltin*, | ||
keccak_ptr: KeccakBuiltin*, | ||
}() -> model.Stack* { | ||
alloc_locals; | ||
%{ dict_manager %} | ||
local block: model.Block*; | ||
local state: model.State*; | ||
%{ block %} | ||
%{ state %} | ||
let stack = Stack.init(); | ||
let memory = Memory.init(); | ||
let (bytecode) = alloc(); | ||
assert [bytecode] = 0x4a; // BLOBBASEFEE | ||
let address = 0xdead; | ||
let (calldata) = alloc(); | ||
let evm = TestHelpers.init_evm_from_with_block_header( | ||
state, 0, bytecode, address, 0, calldata, block.block_header | ||
); | ||
|
||
with stack, memory, state { | ||
BlockInformation.exec_block_information(evm); | ||
} | ||
|
||
return stack; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from ethereum.cancun.vm.gas import calculate_blob_gas_price | ||
from tests.utils.data import block | ||
from tests.utils.models import State | ||
|
||
|
||
class TestBlockInformation: | ||
class TestBlobBaseFee: | ||
def test_should_push_blob_base_fee(self, cairo_run): | ||
block_ = block() | ||
[blob_base_fee] = cairo_run( | ||
"test__exec_blob_base_fee", block=block_, state=State.model_validate({}) | ||
) | ||
|
||
expected = calculate_blob_gas_price( | ||
block_.block_header.excess_blob_gas_value | ||
) | ||
assert blob_base_fee == expected |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters