Skip to content

Commit

Permalink
Chore/devcontainer (kkrt-labs#665)
Browse files Browse the repository at this point in the history
adding support for cairo0 lsp in codespaces (fully on internet)

---------

Co-authored-by: kakarot CI <[email protected]>
  • Loading branch information
Eikix and kakarot CI authored Jul 28, 2023
1 parent 7ec7a96 commit c04cb72
Show file tree
Hide file tree
Showing 12 changed files with 57 additions and 21 deletions.
8 changes: 6 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,16 @@
"python.linting.mypyPath": "/usr/local/py-utils/bin/mypy",
"python.linting.pycodestylePath": "/usr/local/py-utils/bin/pycodestyle",
"python.linting.pydocstylePath": "/usr/local/py-utils/bin/pydocstyle",
"python.linting.pylintPath": "/usr/local/py-utils/bin/pylint"
"python.linting.pylintPath": "/usr/local/py-utils/bin/pylint",
"cairols.sourceDir": "src",
"cairols.cairoPath": ["src", "tests"]
},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"ms-python.python",
"ms-python.vscode-pylance"
"ms-python.vscode-pylance",
"starkware.cairo",
"ericglau.cairo-ls"
]
}
},
Expand Down
1 change: 0 additions & 1 deletion src/kakarot/accounts/library.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -96,5 +96,4 @@ namespace Accounts {

return (account_address=account_address);
}

}
6 changes: 5 additions & 1 deletion src/kakarot/instructions/system_operations.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ from starkware.cairo.common.math import split_felt
from starkware.cairo.common.math_cmp import is_le, is_not_zero, is_nn
from starkware.cairo.common.memcpy import memcpy
from starkware.cairo.common.uint256 import Uint256
from starkware.starknet.common.syscalls import deploy as deploy_syscall, get_contract_address, get_tx_info
from starkware.starknet.common.syscalls import (
deploy as deploy_syscall,
get_contract_address,
get_tx_info,
)

// Internal dependencies
from kakarot.constants import contract_account_class_hash, native_token_address, Constants
Expand Down
2 changes: 0 additions & 2 deletions src/kakarot/interfaces/interfaces.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ namespace IAccount {

func bytecode() -> (bytecode_len: felt, bytecode: felt*) {
}

}

@contract_interface
Expand All @@ -69,7 +68,6 @@ namespace IContractAccount {

func write_storage(key: Uint256, value: Uint256) {
}

}

@contract_interface
Expand Down
4 changes: 3 additions & 1 deletion src/kakarot/library.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,9 @@ namespace Kakarot {
let (caller_address) = get_caller_address();
let (sender_evm_address) = IAccount.get_evm_address(caller_address);
let (tx_info) = get_tx_info();
let (evm_contract_address) = CreateHelper.get_create_address(sender_evm_address, tx_info.nonce);
let (evm_contract_address) = CreateHelper.get_create_address(
sender_evm_address, tx_info.nonce
);
let (class_hash) = contract_account_class_hash.read();
let (starknet_contract_address) = Accounts.create(class_hash, evm_contract_address);
let (empty_array: felt*) = alloc();
Expand Down
1 change: 0 additions & 1 deletion src/utils/eth_transaction.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ from utils.utils import Helpers
// @notice This file contains utils for decoding eth transactions
// @custom:namespace EthTransaction
namespace EthTransaction {
// @notice Decode a legacy Ethereum transaction
// @dev This function decodes a legacy Ethereum transaction in accordance with EIP-155.
// It returns transaction details including nonce, gas price, gas limit, destination address, amount, payload,
Expand Down
11 changes: 7 additions & 4 deletions tests/integration/solidity_contracts/PlainOpcodes/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,27 @@
def counter_deployer(addresses):
return addresses[1]


@pytest_asyncio.fixture(scope="session")
def caller_deployer(addresses):
return addresses[2]


@pytest_asyncio.fixture(scope="session")
def plain_opcodes_deployer(addresses):
return addresses[3]


@pytest_asyncio.fixture(scope="session")
def safe_deployer(addresses):
return addresses[4]


@pytest_asyncio.fixture(scope="package")
async def counter(deploy_solidity_contract, counter_deployer):
return await deploy_solidity_contract("PlainOpcodes", "Counter", caller_eoa=counter_deployer)
return await deploy_solidity_contract(
"PlainOpcodes", "Counter", caller_eoa=counter_deployer
)


@pytest_asyncio.fixture(scope="package")
Expand All @@ -45,7 +50,5 @@ async def plain_opcodes(deploy_solidity_contract, plain_opcodes_deployer, counte
@pytest_asyncio.fixture(scope="package")
async def safe(deploy_solidity_contract, safe_deployer):
return await deploy_solidity_contract(
"PlainOpcodes",
"Safe",
caller_eoa=safe_deployer
"PlainOpcodes", "Safe", caller_eoa=safe_deployer
)
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ async def test_should_increase_counter(
plain_opcodes,
counter_deployer,
):
await plain_opcodes.opcodeCall(caller_address=counter_deployer.starknet_address)
await plain_opcodes.opcodeCall(
caller_address=counter_deployer.starknet_address
)
assert await counter.count() == 1

class TestBlockhash:
Expand Down Expand Up @@ -146,8 +148,12 @@ async def test_should_emit_log3(self, plain_opcodes, addresses, event):
assert log_receipt["address"] == expected_address
assert plain_opcodes.events.Log3 == [event]

async def test_should_emit_log4(self, plain_opcodes, plain_opcodes_deployer, event):
await plain_opcodes.opcodeLog4(caller_address=plain_opcodes_deployer.starknet_address)
async def test_should_emit_log4(
self, plain_opcodes, plain_opcodes_deployer, event
):
await plain_opcodes.opcodeLog4(
caller_address=plain_opcodes_deployer.starknet_address
)
# the contract address is set at deploy time, we verify that event address is
# getting correctly set by asserting equality
expected_address = plain_opcodes.address
Expand Down Expand Up @@ -259,6 +265,10 @@ async def test_should_return_owner_as_origin_and_caller_as_sender(

class TestLoop:
@pytest.mark.parametrize("steps", [0, 1, 2, 10])
async def test_loop_should_write_to_storage(self, plain_opcodes, plain_opcodes_deployer, steps):
await plain_opcodes.testLoop(steps, caller_address=plain_opcodes_deployer.starknet_address)
async def test_loop_should_write_to_storage(
self, plain_opcodes, plain_opcodes_deployer, steps
):
await plain_opcodes.testLoop(
steps, caller_address=plain_opcodes_deployer.starknet_address
)
assert await plain_opcodes.loopValue() == steps
2 changes: 2 additions & 0 deletions tests/integration/solidity_contracts/Solmate/test_erc20.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
TEST_SUPPLY = 10**18
TEST_AMOUNT = int(0.9 * 10**18)


@pytest_asyncio.fixture(scope="session")
def erc_20_deployer(addresses):
return addresses[5]


@pytest_asyncio.fixture(scope="module")
async def erc_20(deploy_solidity_contract, erc_20_deployer):
return await deploy_solidity_contract(
Expand Down
18 changes: 15 additions & 3 deletions tests/integration/solidity_contracts/Solmate/test_erc721.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,32 @@
from tests.utils.constants import ZERO_ADDRESS
from tests.utils.errors import kakarot_error


@pytest_asyncio.fixture(scope="session")
def erc_721_deployer(addresses):
return addresses[6]


@pytest_asyncio.fixture(scope="session")
def erc_721_recepient_deployer(addresses):
return addresses[7]


@pytest_asyncio.fixture(scope="session")
def erc_721_reverting_recipient_deployer(addresses):
return addresses[8]


@pytest_asyncio.fixture(scope="session")
def erc_721_recipient_with_wrong_return_data_deployer(addresses):
return addresses[9]


@pytest_asyncio.fixture(scope="session")
def erc_721_non_recipient_deployer(addresses):
return addresses[10]


@pytest_asyncio.fixture(scope="module")
async def erc_721(deploy_solidity_contract, erc_721_deployer):
return await deploy_solidity_contract(
Expand All @@ -46,7 +52,9 @@ async def erc_721_recipient(deploy_solidity_contract, erc_721_recepient_deployer


@pytest_asyncio.fixture(scope="module")
async def erc_721_reverting_recipient(deploy_solidity_contract, erc_721_reverting_recipient_deployer):
async def erc_721_reverting_recipient(
deploy_solidity_contract, erc_721_reverting_recipient_deployer
):
return await deploy_solidity_contract(
"Solmate",
"RevertingERC721Recipient",
Expand All @@ -55,7 +63,9 @@ async def erc_721_reverting_recipient(deploy_solidity_contract, erc_721_revertin


@pytest_asyncio.fixture(scope="module")
async def erc_721_recipient_with_wrong_return_data(deploy_solidity_contract, erc_721_recipient_with_wrong_return_data_deployer):
async def erc_721_recipient_with_wrong_return_data(
deploy_solidity_contract, erc_721_recipient_with_wrong_return_data_deployer
):
return await deploy_solidity_contract(
"Solmate",
"WrongReturnDataERC721Recipient",
Expand All @@ -64,7 +74,9 @@ async def erc_721_recipient_with_wrong_return_data(deploy_solidity_contract, erc


@pytest_asyncio.fixture(scope="module")
async def erc_721_non_recipient(deploy_solidity_contract, erc_721_non_recipient_deployer):
async def erc_721_non_recipient(
deploy_solidity_contract, erc_721_non_recipient_deployer
):
return await deploy_solidity_contract(
"Solmate",
"NonERC721Recipient",
Expand Down
4 changes: 4 additions & 0 deletions tests/integration/solidity_contracts/UniswapV2/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,22 @@
async def token_a_deployer(addresses):
return addresses[11]


@pytest_asyncio.fixture(scope="session")
async def token_b_deployer(addresses):
return addresses[12]


@pytest_asyncio.fixture(scope="session")
async def uniswap_factory_deployer(addresses):
return addresses[13]


@pytest_asyncio.fixture(scope="session")
async def uniswap_pair_deployer(addresses):
return addresses[14]


@pytest_asyncio.fixture(scope="module")
async def token_a(
deploy_solidity_contract: Callable,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,3 @@ func execute{
);
return (response_len, response);
}

0 comments on commit c04cb72

Please sign in to comment.