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

Tuple Index Into Minor Fix #663

Merged
merged 9 commits into from
Feb 10, 2023
Merged

Tuple Index Into Minor Fix #663

merged 9 commits into from
Feb 10, 2023

Conversation

ahangsu
Copy link
Contributor

@ahangsu ahangsu commented Feb 9, 2023

No description provided.

@ahangsu ahangsu marked this pull request as ready for review February 9, 2023 19:56
@tzaffi
Copy link
Contributor

tzaffi commented Feb 9, 2023

I propose an additional test for abi.Tuple2[abi.DynamicBytes, abi.StaticBytes[Literal[3]] near this case

@bbroder-algo

@@ -25,7 +25,7 @@ int 5
extract_uint64
store 2
load 19
extract 13 0
extract 13 32
Copy link
Contributor

Choose a reason for hiding this comment

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

So was the integration test giving a false negative?

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 don't think integration test (in general) is false negative, but the testcase is really a corner case we didn't account for.

Copy link
Contributor

@tzaffi tzaffi Feb 9, 2023

Choose a reason for hiding this comment

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

I think this is extracting the address which is at the end of the encoding, end therefore extract 13 0 $\equiv$ extract 13 32. Does that make sense given your changes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, this two cases are equal only under a precondition, the last element in tuple (address in this case) has no leading dynamic type(s).

If we both agree on this precondition, then yes, it makes sense given my change.

@ahangsu
Copy link
Contributor Author

ahangsu commented Feb 9, 2023

I propose an additional test for abi.Tuple2[abi.DynamicBytes, abi.StaticBytes[Literal[3]] near this case

yes, working on it

@@ -371,6 +371,15 @@ class IndexTest(NamedTuple):
encoded, start_index=pt.ExtractUint16(encoded, pt.Int(0))
),
),
IndexTest(
Copy link
Contributor

@tzaffi tzaffi Feb 9, 2023

Choose a reason for hiding this comment

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

I tried this test case against master (and also the graviton roundtrip test that I proposed) and both tests passed. I'd like to get a better understanding of why that is. For the graviton roundtrip test, I guess the test is passing because it's decoding the entire tuple as opposed to a portion of it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good point on reverse testing on master, I am also trying to replicate things on master and will get back to you what I have.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, my first find: this is INDEED an insufficient test: for we are taking from byte, rather than a static array (with static type). So the compilation will use getbyte, which makes no difference with or without length.

I propose we should introduce another type spec (like static bytes) for this testcase.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

made a change in 7bc748d, and it should be failing on master

Copy link
Contributor

@tzaffi tzaffi left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@jasonpaulos jasonpaulos left a comment

Choose a reason for hiding this comment

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

Nice improvement! I just have some small requests

pyteal/ast/abi/tuple.py Outdated Show resolved Hide resolved
pyteal/ast/abi/tuple_test.py Show resolved Hide resolved
@ahangsu ahangsu merged commit 5cd3252 into master Feb 10, 2023
@ahangsu ahangsu deleted the tuple-index-into-fix branch February 10, 2023 18:52
Copy link
Contributor

@bbroder-algo bbroder-algo left a comment

Choose a reason for hiding this comment

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

approved

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.

None yet

4 participants