Skip to content
This repository has been archived by the owner on Jan 9, 2025. It is now read-only.

[KGA-10]: warmup all precompiles #1621

Merged
merged 9 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/cairo-zero-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ jobs:
uses: actions/checkout@v4
with:
repository: kkrt-labs/ef-tests
ref: feat/update-base-fee-state
- name: Checkout local skip file
uses: actions/checkout@v4
with:
Expand Down
3 changes: 3 additions & 0 deletions blockchain-tests-skip.yml
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,9 @@ testname:
- StaticcallToPrecompileFromCalledContract_d0g0v0_Cancun
- StaticcallToPrecompileFromContractInitialization_d0g0v0_Cancun
- StaticcallToPrecompileFromTransaction_d0g0v0_Cancun
- static_Call1024PreCalls_d1g0v0_Cancun #RunResources error
- static_Call1024PreCalls2_d1g0v0_Cancun #RunResources error
- static_Call1024PreCalls3_d1g0v0_Cancun #RunResources error
- static_Call1MB1024Calldepth_d1g0v0_Cancun #RunResources error
- static_Call1024PreCalls2_d0g0v0_Cancun #RunResources error
- static_Call50000_d0g0v0_Cancun #RunResources error
Expand Down
9 changes: 9 additions & 0 deletions cairo_zero/kakarot/state.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ namespace State {
alloc_locals;
tempvar accounts_ptr = state.accounts;
with accounts_ptr {
// EVM Precompiles
Internals._cache_precompile(1);
Internals._cache_precompile(2);
Internals._cache_precompile(3);
Expand All @@ -147,6 +148,14 @@ namespace State {
Internals._cache_precompile(8);
Internals._cache_precompile(9);
Internals._cache_precompile(10);

// RIP Precompiles
Internals._cache_precompile(Constants.P256VERIFY_PRECOMPILE);

// Kakarot Precompiles
Internals._cache_precompile(Constants.CAIRO_WHITELISTED_CALL_PRECOMPILE);
Internals._cache_precompile(Constants.CAIRO_MULTICALL_PRECOMPILE);
Internals._cache_precompile(Constants.CAIRO_CALL_PRECOMPILE);
}
tempvar state = new model.State(
accounts_start=state.accounts_start,
Expand Down
7 changes: 6 additions & 1 deletion cairo_zero/tests/src/kakarot/precompiles/test_precompiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,12 @@ def test__is_precompile_rollup_precompiles(self, cairo_run, address):
assert result == (address in ROLLUP_PRECOMPILES)

@pytest.mark.parametrize(
"address", range(KAKAROT_PRECOMPILES[0], KAKAROT_PRECOMPILES[-1] + 2)
"address",
[
KAKAROT_PRECOMPILES[0] - 1,
*KAKAROT_PRECOMPILES,
KAKAROT_PRECOMPILES[-1] + 1,
],
)
def test__is_precompile_kakarot_precompiles(self, cairo_run, address):
result = cairo_run("test__is_precompile", address=address)
Expand Down
4 changes: 2 additions & 2 deletions cairo_zero/tests/src/kakarot/test_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
TX_ACCESS_LIST_STORAGE_KEY_COST,
)

from tests.utils.constants import ETHEREUM_PRECOMPILES, TRANSACTIONS
from tests.utils.constants import ALL_PRECOMPILES, TRANSACTIONS
from tests.utils.helpers import flatten_tx_access_list, merge_access_list
from tests.utils.syscall_handler import SyscallHandler

Expand Down Expand Up @@ -90,7 +90,7 @@ def test_should_cache_precompiles(self, cairo_run):
state = cairo_run("test__cache_precompiles")
assert [
int(address, 16) for address in state["accounts"].keys()
] == ETHEREUM_PRECOMPILES
] == ALL_PRECOMPILES

@SyscallHandler.patch("IERC20.balanceOf", lambda *_: [0, 1])
@pytest.mark.parametrize("transaction", TRANSACTIONS)
Expand Down
2 changes: 2 additions & 0 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ test = 'solidity_contracts/tests'
out = 'solidity_contracts/build'
libs = ['solidity_contracts/lib']

evm_version = "cancun"

optimizer = true
optimizer_runs = 100_000

Expand Down
10 changes: 8 additions & 2 deletions kakarot_scripts/compile_kakarot.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,14 @@ def main():
cairo0_task = pool.map_async(compile_cairo_zero_contract, cairo0_contracts)
cairo1_task = pool.map_async(compile_scarb_package, cairo1_packages)

cairo0_task.wait()
cairo1_task.wait()
try:
cairo0_task.wait()
cairo1_task.wait()
cairo0_task.get()
cairo1_task.get()
except Exception as e:
logger.error(e)
raise
logger.info("ℹ️ Computing deployed class hashes")
with mp.Pool() as pool:
class_hashes = pool.map(compute_deployed_class_hash, DECLARED_CONTRACTS)
Expand Down
2 changes: 1 addition & 1 deletion kakarot_scripts/ef_tests/fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import requests

EF_TESTS_TAG = "v14.1.1-kkrt"
EF_TESTS_TAG = "v14.1.3-kkrt"
EF_TESTS_URL = (
f"https://github.com/kkrt-labs/tests/archive/refs/tags/{EF_TESTS_TAG}.tar.gz"
)
Expand Down
2 changes: 1 addition & 1 deletion kakarot_scripts/utils/starknet.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ def compile_cairo_zero_contract(contract):

if output.returncode != 0:
raise RuntimeError(
f"❌ {contract['contract_name']} raised:\n{output.stderr}.\nOutput:\n{output.stdout}"
f"❌ {contract['contract_name']} raised: {output.stderr.decode().strip()}. Output: {output.stdout.decode().strip()}"
)

elapsed = datetime.now() - start
Expand Down
2 changes: 1 addition & 1 deletion solidity_contracts/lib/kakarot-lib
Submodule kakarot-lib updated 1 files
+1 −3 src/CairoLib.sol
2 changes: 1 addition & 1 deletion tests/utils/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
int.from_bytes(address, "big") for address in PRE_COMPILED_CONTRACTS.keys()
]
ROLLUP_PRECOMPILES = [0x100]
KAKAROT_PRECOMPILES = [0x75001, 0x75002, 0x75003, 0x75004]
KAKAROT_PRECOMPILES = [0x75001, 0x75003, 0x75004]
ALL_PRECOMPILES = [*ETHEREUM_PRECOMPILES, *ROLLUP_PRECOMPILES, *KAKAROT_PRECOMPILES]

CAIRO_PRECOMPILE_GAS = 10000
Expand Down
Loading