Skip to content

Commit

Permalink
dev: rename precompiles class (#1081)
Browse files Browse the repository at this point in the history
<!--- Please provide a general summary of your changes in the title
above -->

<!-- Give an estimate of the time you spent on this PR in terms of work
days.
Did you spend 0.5 days on this PR or rather 2 days?  -->

Time spent on this PR:

## Pull request type

<!-- Please try to limit your pull request to one type,
submit multiple pull requests if needed. -->

Please check the type of change your PR introduces:

- [ ] Bugfix
- [ ] Feature
- [ ] Code style update (formatting, renaming)
- [ ] Refactoring (no functional changes, no api changes)
- [ ] Build related changes
- [ ] Documentation content changes
- [ ] Other (please describe):

## What is the current behavior?

<!-- Please describe the current behavior that you are modifying,
or link to a relevant issue. -->

Resolves #<Issue number>

## What is the new behavior?

<!-- Please describe the behavior or changes that are being added by
this PR. -->

-
-
-

<!-- Reviewable:start -->
- - -
This change is [<img src="https://reviewable.io/review_button.svg"
height="34" align="absmiddle"
alt="Reviewable"/>](https://reviewable.io/reviews/kkrt-labs/kakarot/1081)
<!-- Reviewable:end -->
  • Loading branch information
enitrat authored Apr 8, 2024
1 parent 241d505 commit d2732c2
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 22 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ jobs:
uses: actions/checkout@v3
with:
repository: kkrt-labs/ef-tests
ref: dev/rename-precompiles-class
- name: Checkout local skip file
uses: actions/checkout@v3
with:
Expand Down
4 changes: 2 additions & 2 deletions src/kakarot/instructions/block_information.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ from starkware.cairo.common.uint256 import Uint256
from kakarot.constants import Constants
from kakarot.evm import EVM
from kakarot.interfaces.interfaces import ICairo1Helpers
from kakarot.storages import Kakarot_precompiles_class_hash
from kakarot.storages import Kakarot_cairo1_helpers_class_hash
from kakarot.model import model
from kakarot.stack import Stack
from kakarot.state import State
Expand Down Expand Up @@ -172,7 +172,7 @@ namespace Internals {
return ();
}

let (implementation) = Kakarot_precompiles_class_hash.read();
let (implementation) = Kakarot_cairo1_helpers_class_hash.read();
let (blockhash) = ICairo1Helpers.library_call_get_block_hash(
implementation, block_number.low
);
Expand Down
4 changes: 2 additions & 2 deletions src/kakarot/instructions/environmental_information.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ from kakarot.memory import Memory
from kakarot.model import model
from kakarot.stack import Stack
from kakarot.state import State
from kakarot.storages import Kakarot_precompiles_class_hash
from kakarot.storages import Kakarot_cairo1_helpers_class_hash
from utils.array import slice
from utils.bytes import bytes_to_bytes8_little_endian
from utils.uint256 import uint256_to_uint160, uint256_add
Expand Down Expand Up @@ -481,7 +481,7 @@ namespace EnvironmentalInformation {
dst, account.code_len, account.code
);

let (implementation) = Kakarot_precompiles_class_hash.read();
let (implementation) = Kakarot_cairo1_helpers_class_hash.read();
let (code_hash) = ICairo1Helpers.library_call_keccak(
class_hash=implementation,
words_len=dst_len,
Expand Down
4 changes: 2 additions & 2 deletions src/kakarot/instructions/sha3.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ from kakarot.gas import Gas
from kakarot.memory import Memory
from kakarot.model import model
from kakarot.stack import Stack
from kakarot.storages import Kakarot_precompiles_class_hash
from kakarot.storages import Kakarot_cairo1_helpers_class_hash
from utils.bytes import bytes_to_bytes8_little_endian

namespace Sha3 {
Expand Down Expand Up @@ -61,7 +61,7 @@ namespace Sha3 {
dst, size.low, bigendian_data
);

let (implementation) = Kakarot_precompiles_class_hash.read();
let (implementation) = Kakarot_cairo1_helpers_class_hash.read();
let (result) = ICairo1Helpers.library_call_keccak(
class_hash=implementation,
words_len=dst_len,
Expand Down
6 changes: 3 additions & 3 deletions src/kakarot/instructions/system_operations.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ from kakarot.gas import Gas
from kakarot.memory import Memory
from kakarot.model import model
from kakarot.stack import Stack
from kakarot.storages import Kakarot_precompiles_class_hash
from kakarot.storages import Kakarot_cairo1_helpers_class_hash
from kakarot.state import State
from utils.utils import Helpers
from utils.array import slice
Expand Down Expand Up @@ -1011,7 +1011,7 @@ namespace CreateHelper {
message_bytes8, message_len, message
);

let (implementation) = Kakarot_precompiles_class_hash.read();
let (implementation) = Kakarot_cairo1_helpers_class_hash.read();
let (message_hash) = ICairo1Helpers.library_call_keccak(
class_hash=implementation,
words_len=message_bytes8_len,
Expand Down Expand Up @@ -1047,7 +1047,7 @@ namespace CreateHelper {
bytecode_bytes8, bytecode_len, bytecode
);

let (implementation) = Kakarot_precompiles_class_hash.read();
let (implementation) = Kakarot_cairo1_helpers_class_hash.read();
let (bytecode_hash) = ICairo1Helpers.library_call_keccak(
class_hash=implementation,
words_len=bytecode_bytes8_len,
Expand Down
4 changes: 2 additions & 2 deletions src/kakarot/kakarot.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func constructor{syscall_ptr: felt*, pedersen_ptr: HashBuiltin*, range_check_ptr
native_token_address: felt,
account_contract_class_hash: felt,
uninitialized_account_class_hash: felt,
precompiles_class_hash: felt,
cairo1_helpers_class_hash: felt,
coinbase: felt,
block_gas_limit: felt,
) {
Expand All @@ -36,7 +36,7 @@ func constructor{syscall_ptr: felt*, pedersen_ptr: HashBuiltin*, range_check_ptr
native_token_address,
account_contract_class_hash,
uninitialized_account_class_hash,
precompiles_class_hash,
cairo1_helpers_class_hash,
coinbase,
block_gas_limit,
);
Expand Down
8 changes: 4 additions & 4 deletions src/kakarot/library.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ from kakarot.storages import (
Kakarot_account_contract_class_hash,
Kakarot_base_fee,
Kakarot_native_token_address,
Kakarot_precompiles_class_hash,
Kakarot_cairo1_helpers_class_hash,
Kakarot_coinbase,
Kakarot_prev_randao,
Kakarot_block_gas_limit,
Expand All @@ -37,22 +37,22 @@ namespace Kakarot {
// @param native_token_address The ERC20 contract used to emulate ETH.
// @param account_contract_class_hash The clash hash of the contract account.
// @param uninitialized_account_class_hash The class hash of the uninitialized account used for deterministic address calculation.
// @param precompiles_class_hash The precompiles class hash for precompiles not implemented in Kakarot.
// @param cairo1_helpers_class_hash The precompiles class hash for precompiles not implemented in Kakarot.
// @param coinbase The EOA whose key is owned by the deployer (or known to be owned by Coinbase)
func constructor{syscall_ptr: felt*, pedersen_ptr: HashBuiltin*, range_check_ptr}(
owner: felt,
native_token_address,
account_contract_class_hash,
uninitialized_account_class_hash,
precompiles_class_hash,
cairo1_helpers_class_hash,
coinbase,
block_gas_limit,
) {
Ownable.initializer(owner);
Kakarot_native_token_address.write(native_token_address);
Kakarot_account_contract_class_hash.write(account_contract_class_hash);
Kakarot_uninitialized_account_class_hash.write(uninitialized_account_class_hash);
Kakarot_precompiles_class_hash.write(precompiles_class_hash);
Kakarot_cairo1_helpers_class_hash.write(cairo1_helpers_class_hash);
Kakarot_coinbase.write(coinbase);
Kakarot_block_gas_limit.write(block_gas_limit);
return ();
Expand Down
4 changes: 2 additions & 2 deletions src/kakarot/precompiles/precompiles.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ from starkware.cairo.common.alloc import alloc
from starkware.cairo.common.memcpy import memcpy

from kakarot.interfaces.interfaces import ICairo1Helpers
from kakarot.storages import Kakarot_precompiles_class_hash
from kakarot.storages import Kakarot_cairo1_helpers_class_hash
from kakarot.errors import Errors
from kakarot.precompiles.blake2f import PrecompileBlake2f
from kakarot.precompiles.datacopy import PrecompileDataCopy
Expand Down Expand Up @@ -123,7 +123,7 @@ namespace Precompiles {
output_len: felt, output: felt*, gas_used: felt, reverted: felt
) {
alloc_locals;
let (implementation) = Kakarot_precompiles_class_hash.read();
let (implementation) = Kakarot_cairo1_helpers_class_hash.read();
let (calldata: felt*) = alloc();
assert [calldata] = evm_address;
assert [calldata + 1] = input_len;
Expand Down
2 changes: 1 addition & 1 deletion src/kakarot/storages.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from starkware.cairo.common.uint256 import Uint256

@storage_var
func Kakarot_precompiles_class_hash() -> (res: felt) {
func Kakarot_cairo1_helpers_class_hash() -> (res: felt) {
}

@storage_var
Expand Down
6 changes: 3 additions & 3 deletions tests/fixtures/EVM.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ from kakarot.storages import (
Kakarot_native_token_address,
Kakarot_account_contract_class_hash,
Kakarot_uninitialized_account_class_hash,
Kakarot_precompiles_class_hash,
Kakarot_cairo1_helpers_class_hash,
Kakarot_coinbase,
Kakarot_block_gas_limit,
)
Expand All @@ -34,14 +34,14 @@ func constructor{syscall_ptr: felt*, pedersen_ptr: HashBuiltin*, range_check_ptr
native_token_address: felt,
account_contract_class_hash: felt,
uninitialized_account_class_hash: felt,
precompiles_class_hash: felt,
cairo1_helpers_class_hash: felt,
coinbase: felt,
block_gas_limit: felt,
) {
Kakarot_native_token_address.write(native_token_address);
Kakarot_account_contract_class_hash.write(account_contract_class_hash);
Kakarot_uninitialized_account_class_hash.write(uninitialized_account_class_hash);
Kakarot_precompiles_class_hash.write(precompiles_class_hash);
Kakarot_cairo1_helpers_class_hash.write(cairo1_helpers_class_hash);
Kakarot_coinbase.write(coinbase);
Kakarot_block_gas_limit.write(block_gas_limit);
return ();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def _pack_into_u64_words(self, bytecode):
EXISTING_ACCOUNT_SN_ADDR,
)
@SyscallHandler.patch(
"Kakarot_precompiles_class_hash",
"Kakarot_cairo1_helpers_class_hash",
CAIRO1_HELPERS_CLASS_HASH,
)
def test_extcodehash__should_push_hash(
Expand Down

0 comments on commit d2732c2

Please sign in to comment.