Skip to content

Reorganize semantic tests for calldata and abicoder#16483

Open
cameel wants to merge 5 commits intodevelopfrom
reorganize-calldata-semantic-tests
Open

Reorganize semantic tests for calldata and abicoder#16483
cameel wants to merge 5 commits intodevelopfrom
reorganize-calldata-semantic-tests

Conversation

@cameel
Copy link
Copy Markdown
Collaborator

@cameel cameel commented Feb 19, 2026

This is just a refactor in preparation for fixing a bug in calldata validation. I needed to figure out what we have coverage for and since our tests for this are all over the place, I did some renaming and reorganization of the test dirs.

Summary of changes:

  • abiEncodeDecode/, abiEncoderV1/, abiEncoderV2/, calldata/ under semanticTests/ all had random subsets of ABI encoding and calldata tests. I merged them all into a single abicoder/ dir with subdirs for validation, cleanup, structs, arrays, etc. Also moved some tests from arrays/ and structs/ there.
  • This revealed that some of the tests are almost exact duplicates. I removed these.
    • Note that tests without the abicoder pragma cover both v1 and v2 since isoltest inserts a pragma depending on whether it runs with or without --abiencoderv1. Those with v2 pragma cover only v2. Those with v1 pragma cover v1 via evmasm and v2 via Yul (since the compiler ignores the pragma via Yul).
    • There are also quite a few non-identical tests covering the same thing. I intentionally left those, as I did not want to get into figuring out which version is better and should be left in.
  • I enabled debug revert strings in tests covering validations. Otherwise it's not clear which validation failed in the test. Sometimes that required creating separate v1 and v2 versions.
  • Other minor corrections: one test no longer needs compileViaYul: false. Another mixed tabs and spaces. Etc.

@cameel cameel self-assigned this Feb 19, 2026
@cameel cameel force-pushed the reorganize-calldata-semantic-tests branch from 6095512 to f20af71 Compare February 19, 2026 19:35
Comment on lines +14 to 17
// revertStrings: debug
// ----
// f((int16,uint8,bytes2)): 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01, 0xff, "ab" -> 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01, 0xff, "ab"
// f((int16,uint8,bytes2)): 0xff010, 0xff, "ab" -> FAILURE
Copy link
Copy Markdown
Collaborator Author

@cameel cameel Feb 19, 2026

Choose a reason for hiding this comment

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

Looks like we actually have no message for this validation, so revertStrings: debug does nothing here.

templ("failure", "revert(0, 0)");

This is in validatorFunction(), used by ABI utilities. It was likely missed when error messages were added, because it sits in YulUtilFunctions. I think we should give it a message.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I agree. There is probably more case which should have a message. Maybe it would be good to scan the code looking for revert(0, 0) pattern.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I would add an issue to not forget to implement this in the future.

@cameel
Copy link
Copy Markdown
Collaborator Author

cameel commented Feb 19, 2026

copy_from_calldata_removes_bytes_data.sol is the only test I left under calldata/. It does not really test decoding, but I'm also not sure what it really tests. It comes from #12289, which extracted tests from SolidityEndToEndTest.cpp, but this does not seem to be one of them. It's as if it appeared out of nowhere. It's even weirder that I reviewed that PR and apparently did see the original back then. I suspect that something got botched when the PR was rebased.

In any case, this test could be covering some ancient, long fixed bug, but in isolation it looks a bit worthless and weird (why unused set() function?) so I'm considering just removing it.

}
}
// ====
// revertStrings: debug
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Maybe we should make it the default in tests? It's not enabled normally due to gas reasons, but I don't see a strong reason not to always have these messages in tests.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I agree. It would be much more clear what is the exact failure.

rodiazet
rodiazet previously approved these changes Feb 26, 2026
Copy link
Copy Markdown
Contributor

@rodiazet rodiazet left a comment

Choose a reason for hiding this comment

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

LGTM. Some comments or rather questions added and I proposed to move one test.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This test is a copy of test/libsolidity/semanticTests/array/calldata_array_bounds_check_nested_bytes.sol Shouldn't this be moved to test/libsolidity/semanticTests/abicoder/calldataDecoding/array

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This test is a copy of test/libsolidity/semanticTests/array/calldata_array_bounds_check_nested_bytes.sol

Yes, that's why I kept only one of them.

Shouldn't this be moved to test/libsolidity/semanticTests/abicoder/calldataDecoding/array

Well, we have many tests that would fit in more than one place. When it comes to calldata arrays, for example, there is a big overlap between array behavior and calldata decoding. This case IMO is more about the former. The test checks that accessing an element past the end of the array reverts. This is not specific to calldata and happens with all kinds of arrays (note that it's Panic, not Error).

}
}
// ====
// revertStrings: debug
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I agree. It would be much more clear what is the exact failure.

// revertStrings: debug
// ----
// f((function)): "01234567890123456789abcd" -> 1
// f((function)): "01234567890123456789abcdX" -> FAILURE
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why this failure has not message?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Same reason as in https://github.com/argotorg/solidity/pull/16483/files#r2829800249. It fails in validatorFunction().

Comment on lines +14 to 17
// revertStrings: debug
// ----
// f((int16,uint8,bytes2)): 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01, 0xff, "ab" -> 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01, 0xff, "ab"
// f((int16,uint8,bytes2)): 0xff010, 0xff, "ab" -> FAILURE
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I agree. There is probably more case which should have a message. Maybe it would be good to scan the code looking for revert(0, 0) pattern.

@cameel cameel force-pushed the reorganize-calldata-semantic-tests branch from f20af71 to d45a45e Compare March 12, 2026 16:39
@cameel cameel force-pushed the reorganize-calldata-semantic-tests branch from d45a45e to 0df51f7 Compare March 12, 2026 18:16
@cameel
Copy link
Copy Markdown
Collaborator Author

cameel commented Mar 12, 2026

copy_from_calldata_removes_bytes_data.sol is the only test I left under calldata/.

Still not sure what to do about it, but for now I decided to move it to abicoder/calldataDecoding/ to avoid having an almost empty calldata/ dir. If we keep it, things will get messy again, because people will start adding new tests there.

@cameel cameel force-pushed the reorganize-calldata-semantic-tests branch from 0df51f7 to 8b17183 Compare March 12, 2026 18:20
@cameel cameel requested a review from rodiazet March 12, 2026 18:21
Copy link
Copy Markdown
Contributor

@rodiazet rodiazet left a comment

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants