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

V3 transactions in outside execution tests for argent #1554

Open
wants to merge 6 commits into
base: development
Choose a base branch
from

Conversation

baitcode
Copy link
Contributor

Closes: #1546

Introduced changes

  • Added new argent contract v0.4.0 that supports transactions v3 (casm, json and abi)
  • Registered new factory for argent v040 injection in tests
  • Updated tests logic
  • Added new test that checks for new type of errors (Reentrancy introduced in argent v0.4.0)
  • Refacttored account creation logic in tests.

I tried to keep changes to minimum, but could not help myself to introduce refactoring of a test account creation logic. For some reason those accounts were populated through dependency injection factories, which is ok, but at some point one factory got responsible for all possible types of accounts through same factory which over time got bloated with crotches.

I moved all the crotch logic into AccountToBeDeployedDetailsFactory and want to propose to get rid of that class completely (well not in this PR) replacing it with obvious calls, like create_specific_account(), prepay_account(), this will make code straighforward and easy to read. Currently to understand what is happening in a particular test one need to hop through 3-5 layers of constructor injection calls.

* Added new argent contract v0.4.0 that supports transactions v3 (casm, json and abi)
* Registered new factory for argent v040 injection in tests
* Updated tests logic
* Added new test that checks for new type of errors (Reentrancy introduced in argent v0.4.0)
* Refacttored account creation logic in tests.

I tried to keep changes to minimum, but could not help myself to introduce refactoring of a test account creation logic.
For some reason those accounts were populated through dependency injection factories, which is ok, but at some point one factory
got responsible for all possible types of accounts through same factory which over time got bloated with crotches.

I moved all the crotch logic into `AccountToBeDeployedDetailsFactory` and want to propose to get rid of that class completely (well
not in this PR) replacing it with obvious calls, like create_specific_account(), prepay_account(), this will make code straighforward
and easy to read. Currently to understand what is happening in a particular test one need to hop through 3-5 layers of constructor
injection calls.

Fixes: 1546
@baitcode
Copy link
Contributor Author

@franciszekjob there might a minor fix for test. It will be one line maximum. Besides that good for review.

@baitcode
Copy link
Contributor Author

baitcode commented Jan 14, 2025

tests on networks do not work, still. 8 (

Comment on lines 17 to 34
@pytest.mark.asyncio
async def test_argent_account_outside_execution_compatibility(
argent_account: BaseAccount,
argent_account_v040: BaseAccount,
):
result = await argent_account.supports_interface(OutsideExecutionInterfaceID.V1)
assert result is True
result = await argent_account.supports_interface(OutsideExecutionInterfaceID.V2)
assert result is False

result = await argent_account_v040.supports_interface(
OutsideExecutionInterfaceID.V1
)
assert result is True
result = await argent_account_v040.supports_interface(
OutsideExecutionInterfaceID.V2
)
assert result is True
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we change this test to be parametrized?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm afraid it's not trivial due to dependency injection. I attempted to reduce amount of statements. please check.

Comment on lines 176 to 185
assert any(
[
await argent_account_v040.supports_interface(
OutsideExecutionInterfaceID.V1
),
await argent_account_v040.supports_interface(
OutsideExecutionInterfaceID.V2
),
]
)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think yes. But I see your suggest. Removing.

caller=ANY_CALLER,
)

tx = await argent_account_v040.execute_v1(calls=[call], max_fee=MAX_FEE)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use execute_v3.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh! How did those sneak in?! Thank you for catching.

starknet_py/tests/e2e/utils.py Show resolved Hide resolved
@@ -16,13 +16,28 @@
AccountToBeDeployedDetails = Tuple[int, KeyPair, int, int]


async def get_deploy_account_details(
*,
def new_address(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That should be private function, _new_address.

@franciszekjob
Copy link
Collaborator

@baitcode thanks for quick replies 😄 will respond later today.

Copy link
Collaborator

@franciszekjob franciszekjob left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@baitcode looking good! 😄

starknet_py/tests/e2e/account/outside_execution_test.py Outdated Show resolved Hide resolved
Comment on lines 88 to 90
l1_resource_bounds=ResourceBounds(
max_amount=int(1e5), max_price_per_unit=int(1e13)
),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: We can use MAX_RESOURCE_BOUNDS_L1 (same for other occurrences).

Suggested change
l1_resource_bounds=ResourceBounds(
max_amount=int(1e5), max_price_per_unit=int(1e13)
),
l1_resource_bounds=MAX_RESOURCE_BOUNDS_L1,

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! It's good to know.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it's not applied

@@ -384,6 +384,25 @@ async def argent_account_class_hash(
)


@pytest_asyncio.fixture(scope="package")
async def argent_account_class_hash_v040(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

Suggested change
async def argent_account_class_hash_v040(
async def argent_account_v040_class_hash(

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

applied

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's stil the same 😅

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. Somehow lost that change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

Comment on lines 122 to 124
l1_resource_bounds=ResourceBounds(
max_amount=int(1e5), max_price_per_unit=int(1e13)
),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replaced in whole changeset.

@baitcode
Copy link
Contributor Author

@franciszekjob all fixed.

Copy link
Collaborator

@franciszekjob franciszekjob left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@baitcode not all nits have been applied 😅

@@ -384,6 +384,25 @@ async def argent_account_class_hash(
)


@pytest_asyncio.fixture(scope="package")
async def argent_account_class_hash_v040(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's stil the same 😅

starknet_py/tests/e2e/account/outside_execution_test.py Outdated Show resolved Hide resolved
Comment on lines 88 to 90
l1_resource_bounds=ResourceBounds(
max_amount=int(1e5), max_price_per_unit=int(1e13)
),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it's not applied

@baitcode
Copy link
Contributor Author

@franciszekjob
I don't understand how this is possible. If you look into commit you'll see the changes. Will investigate.

@baitcode
Copy link
Contributor Author

I didn't use apply on github. As the last time I did I then needed to manually add additional changes so I put everything into the commit.

@baitcode
Copy link
Contributor Author

I've checked the changeset all changes are there. I'm investigating tests now.

@baitcode
Copy link
Contributor Author

baitcode commented Jan 27, 2025

Yep. Found problem. Somehow lost one line of changes. Should be good now. @franciszekjob

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please link where exactly is this file taken from? I mean branch/tag in argent repo

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

@baitcode baitcode Feb 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

main, latest commit.

deployments/artifacts/account-0.4.0-0x036078334509b514626504edc9fb252328d1a240e4e948bef8d0c08dff45927f

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like these files are different 🤔
image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ohhhhhhh.

Copy link
Contributor Author

@baitcode baitcode Feb 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@franciszekjob
Oh yes! My bad. I compiled those myself with pythonic hints enabled. This is the only difference between those.

Copy link
Collaborator

@franciszekjob franciszekjob Feb 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@baitcode Ok, shouldn't we use these from argent then (not compiled)?

Copy link
Contributor Author

@baitcode baitcode Feb 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@franciszekjob No, starknet.py needs pythonic hints enabled (correct me if I am wrong). I wasn't able to deploy otherwise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove skipping of test_account_outside_execution_any_caller
2 participants