Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix deploy #1206

Merged
merged 2 commits into from
Jun 17, 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
12 changes: 7 additions & 5 deletions deployments/kakarot-staging/declarations.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
{
"kakarot": "0x701a9ab6675823700bb14629c63683f720ffbb57dc445d6c87ebfea8e55904a",
"account_contract": "0x1276d0b017701646f8646b69de6c3b3584edce71879678a679f28c07a9971cf",
"account_contract_fixture": "0x3a247bfdb923a0e950871336d9ffd9d1d052ef79ce31909954f5c2e81e77e00",
"kakarot": "0x12c4a5828b8b5b064887e3d64212fed5202e9c0bda53ec8b4a21343c3f648cc",
"account_contract": "0x5cc0b4057c56a0dce4c9c1cf85c1b93f84761f4ae25fd79ba417ad185e00b29",
"account_contract_fixture": "0x1af49e06ad938cdd61dba6e511147a4a5f95ee4900c34b8afeee5abb973b620",
"uninitialized_account": "0x600f6862938312a05a0cfecba0dcaf37693efc9e4075a6adfb62e196022678e",
"EVM": "0x76157e8119e18e6df44c7f7511857136898480104422510463462e1b1c149e5",
"EVM": "0x707c874e36af5741dc7a5e9caa8a8c3aca13093e5d5597153011a101cbaa60c",
"OpenzeppelinAccount": "0x6153ccf69fd20f832c794df36e19135f0070d0576144f0b47f75a226e4be530",
"Cairo1Helpers": "0x28ece3751ecf5bdf2d791eb64a65bfb6a8816432b698870dba2f38a36101d58",
"Cairo1HelpersFixture": "0x4e7811d9bbba41193bd3c77d05c16f7aaa55dd1d601686b50f6fa0e3766a712",
"replace_class": "0xa187318c5e79b010cf45975f589f0a8d441fadde5b1e7ccad46501568437b5"
"replace_class": "0xa187318c5e79b010cf45975f589f0a8d441fadde5b1e7ccad46501568437b5",
"Counter": "0x2abf5b9916d3c6ae6000ab239bf5aba8b40d9a1750ffc54b6d281ac83137382",
"MockPragmaOracle": "0x675f00328ff84f127d71b179b3f3a3a06ce8432054770cddd5729c8d62866da"
}
9 changes: 7 additions & 2 deletions deployments/kakarot-staging/deployments.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,18 @@
"artifact": "build/kakarot.json"
},
"EVM": {
"address": "0x4a64f9b67916a4496dd3ca2321dd1f5739d0dff33c0930684da1c695691c88f",
"tx": "0x7a805d7b596283b7d56afaded869f0384379cd99faf28ba6ca1e1aa098497d2",
"address": "0x685d79c2693fc41217ef827597eb6f0f846b8b1bf41e4658febe5535cd151d9",
"tx": "0x3b5decc491ac7cbeed16928826423cf6bd7c6788afd8a7e8b52013f82302c4a",
"artifact": "build/fixtures/EVM.json"
},
"Counter": {
"address": "0x3735b9c1dfd45b40149c0227b9981b6dbd14168d5f0f9a1c7a7b3faad9cd630",
"tx": "0x4b135a5df36ac6446be7a8b6bed8ba991377db19c9b375c19434ff6c25ef1f1",
"artifact": "build/fixtures/Counter.json"
},
"MockPragmaOracle": {
"address": "0xd5acd9ad298fd564cf71d1c7c9a4b1ca37b45a5a8bd4b3d88ba6d1ebf87618",
"tx": "0x27f878dbcff30f3d0a031bd5af2af6feb269f5e41df545b92f2ef875bcd385f",
"artifact": "build/ssj/contracts_MockPragmaOracle"
}
}
24 changes: 12 additions & 12 deletions kakarot_scripts/deploy_kakarot.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,13 @@ async def main():
if NETWORK["type"] is NetworkType.STAGING:
deployments["EVM"] = await upgrade(
"EVM",
[
account.address, # owner
ETH_TOKEN_ADDRESS, # native_token_address_
class_hash["account_contract"], # account_contract_class_hash_
class_hash[
"uninitialized_account"
], # uninitialized_account_class_hash_
class_hash["Cairo1Helpers"],
COINBASE,
BLOCK_GAS_LIMIT,
],
account.address, # owner
ETH_TOKEN_ADDRESS, # native_token_address_
class_hash["account_contract"], # account_contract_class_hash_
class_hash["uninitialized_account"], # uninitialized_account_class_hash_
class_hash["Cairo1Helpers"],
COINBASE,
BLOCK_GAS_LIMIT,
)
deployments["Counter"] = await upgrade("Counter")
deployments["MockPragmaOracle"] = await upgrade("MockPragmaOracle")
Expand All @@ -114,7 +110,11 @@ async def main():
logger.info(f"ℹ️ Found default EVM address {EVM_ADDRESS}")
from kakarot_scripts.utils.kakarot import get_eoa

amount = 0.02 if NETWORK["type"] is not NetworkType.DEV else 100
amount = (
0.02
if NETWORK["type"] is not (NetworkType.DEV or NetworkType.STAGING)
else 100
)
await get_eoa(amount=amount)


Expand Down
4 changes: 3 additions & 1 deletion kakarot_scripts/utils/kakarot.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,9 @@ async def eth_send_transaction(

if WEB3.is_connected():
tx_hash = WEB3.eth.send_raw_transaction(evm_tx.rawTransaction)
receipt = WEB3.eth.wait_for_transaction_receipt(tx_hash)
receipt = WEB3.eth.wait_for_transaction_receipt(
tx_hash, timeout=NETWORK["max_wait"], poll_latency=NETWORK["check_interval"]
)
return receipt, [], receipt.status, receipt.gasUsed

encoded_unsigned_tx = rlp_encode_signed_data(typed_transaction.as_dict())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import pytest
import pytest_asyncio

from kakarot_scripts.utils.kakarot import EvmTransactionError
from kakarot_scripts.utils.starknet import get_deployments, wait_for_transaction
from tests.utils.errors import evm_error

ENTRY_TYPE_INDEX = {"SpotEntry": 0, "FutureEntry": 1, "GenericEntry": 2}

Expand Down Expand Up @@ -162,7 +162,7 @@ async def test_should_return_data_median_for_query(
],
)
async def test_should_fail_unauthorized_caller(
self, get_contract, pragma_caller, invoke, data_type, max_fee, mocked_values
self, get_contract, pragma_caller, invoke, data_type
):
await invoke(
"kakarot",
Expand All @@ -171,9 +171,8 @@ async def test_should_fail_unauthorized_caller(
False,
)
cairo_pragma = get_contract("MockPragmaOracle")
(cairo_res,) = await cairo_pragma.functions["get_data_median"].call(data_type)
await cairo_pragma.functions["get_data_median"].call(data_type)
solidity_input = serialize_data_type(data_type)

with pytest.raises(EvmTransactionError) as e:
with evm_error("CairoLib: call_contract failed"):
await pragma_caller.getDataMedianSpot(solidity_input)
assert "CairoLib: call_contract failed" in str(e.value)
8 changes: 4 additions & 4 deletions tests/end_to_end/CairoPrecompiles/test_cairo_precompiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import pytest_asyncio

from kakarot_scripts.utils.starknet import get_deployments, wait_for_transaction
from tests.utils.errors import evm_error


@pytest.fixture(autouse=True)
Expand Down Expand Up @@ -36,11 +37,11 @@ async def cairo_counter_caller(deploy_contract, invoke, owner):
class TestCairoPrecompiles:
class TestCounterPrecompiles:
async def test_should_get_cairo_counter(
self, get_contract, cairo_counter_caller, max_fee
self, get_contract, cairo_counter_caller, invoke
):
cairo_counter = get_contract("Counter")
cairo_count = (await cairo_counter.functions["get"].call()).count
await cairo_counter.functions["inc"].invoke_v1(max_fee=max_fee)
await invoke("Counter", "inc")
evm_count = await cairo_counter_caller.getCairoCounter()
assert evm_count == cairo_count + 1

Expand Down Expand Up @@ -70,6 +71,5 @@ async def test_should_fail_precompile_caller_not_whitelisted(
cairo_counter_caller = await deploy_contract(
"CairoPrecompiles", "CairoCounterCaller", cairo_counter.address
)
with pytest.raises(Exception) as e:
with evm_error("CairoLib: call_contract failed"):
await cairo_counter_caller.incrementCairoCounter(max_fee=max_fee)
assert "CairoLib: call_contract failed" in str(e.value)
2 changes: 1 addition & 1 deletion tests/utils/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

# TRANSACTION
# TODO: handle tx gas limit properly and remove this constant
# Temporarily set tx gas limit to 20M gas (= block gas limit)
# Temporarily set tx gas limit to 7M gas (= block gas limit)
TRANSACTION_GAS_LIMIT = BLOCK_GAS_LIMIT

# PRECOMPILES
Expand Down
Loading