Skip to content

Conversation

@ekpyron
Copy link
Collaborator

@ekpyron ekpyron commented Dec 14, 2022

Not meant as proper fix, but just to demonstrate the issue.

@ekpyron ekpyron added the takeover Can be taken over by someone other than label giver label Dec 14, 2022
@ekpyron ekpyron added this to the 0.8.18 milestone Dec 19, 2022
@NunoFilipeSantos NunoFilipeSantos modified the milestones: 0.8.18, 0.8.19 Jan 23, 2023
@NunoFilipeSantos NunoFilipeSantos added bug 🐛 low effort There is not much implementation work to be done. The task is very easy or tiny. labels Feb 6, 2023
@NunoFilipeSantos NunoFilipeSantos removed the takeover Can be taken over by someone other than label giver label Feb 6, 2023
@nikola-matic nikola-matic force-pushed the duplicatedSubAssembly branch from 2688442 to 9d7e5ae Compare February 6, 2023 21:07
@ekpyron
Copy link
Collaborator Author

ekpyron commented Feb 7, 2023

https://github.com/ethereum/solidity/pull/13825/files#r1098546344 already has a version that uses hashes to recognize duplicates instead - but we need to carefully check that it behaves properly wrt link references in all cases (especially if the duplicates are only due to subassemblies having the same code, but potentially coming from different source yul objects/contracts).

Do you see in the linked test files how to reproduce cases for which any of this happens or do you need some examples :-)?

@nikola-matic nikola-matic marked this pull request as ready for review February 20, 2023 14:55
@nikola-matic nikola-matic force-pushed the duplicatedSubAssembly branch 3 times, most recently from fb3d638 to 5103a7d Compare February 20, 2023 20:28
// Opcodes: PUSH1 0x0 PUSH1 0x99 PUSH1 0x45 PUSH1 0x3F PUSH1 0x86 PUSH1 0x13 PUSH1 0x85 PUSH1 0x1 PUSH1 0x84 PUSH1 0x1 DUP10 PUSH1 0x0 SSTORE DUP9 PUSH1 0x20 SSTORE DUP8 PUSH1 0x40 SSTORE DUP7 PUSH1 0x60 SSTORE DUP6 PUSH1 0x80 SSTORE DUP5 PUSH1 0xA0 SSTORE DUP4 PUSH1 0xC0 SSTORE DUP3 PUSH1 0xE0 SSTORE DUP2 PUSH2 0x100 SSTORE DUP1 PUSH2 0x120 SSTORE PUSH2 0x140 PUSH1 0x0 RETURN INVALID PUSH1 0x2A PUSH1 0x13 PUSH1 0x3D PUSH1 0x1 PUSH1 0x3E PUSH1 0x1 DUP6 PUSH1 0x0 SSTORE DUP5 PUSH1 0x20 SSTORE DUP4 PUSH1 0x40 SSTORE DUP3 PUSH1 0x60 SSTORE DUP2 PUSH1 0x80 SSTORE DUP1 PUSH1 0xA0 SSTORE PUSH1 0xC0 PUSH1 0x0 RETURN INVALID PUSH1 0x12 PUSH1 0x1 DUP2 PUSH1 0x0 SSTORE DUP1 PUSH1 0x20 SSTORE PUSH1 0x40 PUSH1 0x0 RETURN INVALID INVALID INVALID INVALID INVALID INVALID PUSH1 0x12 PUSH1 0x1 DUP2 PUSH1 0x0 SSTORE DUP1 PUSH1 0x20 SSTORE PUSH1 0x40 PUSH1 0x0 RETURN INVALID INVALID
// Bytecode: 600060976045603e60846013608360016083600189600055886020558760405586606055856080558460a0558360c0558260e055816101005580610120556101406000f3fe602a6013603d6001603d600185600055846020558360405582606055816080558060a05560c06000f3fe60126001816000558060205560406000f3fefefefe60126001816000558060205560406000f3fefe
// Opcodes: PUSH1 0x0 PUSH1 0x97 PUSH1 0x45 PUSH1 0x3E PUSH1 0x84 PUSH1 0x13 PUSH1 0x83 PUSH1 0x1 PUSH1 0x83 PUSH1 0x1 DUP10 PUSH1 0x0 SSTORE DUP9 PUSH1 0x20 SSTORE DUP8 PUSH1 0x40 SSTORE DUP7 PUSH1 0x60 SSTORE DUP6 PUSH1 0x80 SSTORE DUP5 PUSH1 0xA0 SSTORE DUP4 PUSH1 0xC0 SSTORE DUP3 PUSH1 0xE0 SSTORE DUP2 PUSH2 0x100 SSTORE DUP1 PUSH2 0x120 SSTORE PUSH2 0x140 PUSH1 0x0 RETURN INVALID PUSH1 0x2A PUSH1 0x13 PUSH1 0x3D PUSH1 0x1 PUSH1 0x3D PUSH1 0x1 DUP6 PUSH1 0x0 SSTORE DUP5 PUSH1 0x20 SSTORE DUP4 PUSH1 0x40 SSTORE DUP3 PUSH1 0x60 SSTORE DUP2 PUSH1 0x80 SSTORE DUP1 PUSH1 0xA0 SSTORE PUSH1 0xC0 PUSH1 0x0 RETURN INVALID PUSH1 0x12 PUSH1 0x1 DUP2 PUSH1 0x0 SSTORE DUP1 PUSH1 0x20 SSTORE PUSH1 0x40 PUSH1 0x0 RETURN INVALID INVALID INVALID INVALID PUSH1 0x12 PUSH1 0x1 DUP2 PUSH1 0x0 SSTORE DUP1 PUSH1 0x20 SSTORE PUSH1 0x40 PUSH1 0x0 RETURN INVALID INVALID
// SourceMappings: 37:15:0:-:0;68:13;97:15;128:13;158:17;192:15;224:17;258:15;291:19;328:17;361:3;358:1;351:14;381:3;377:2;370:15;401:3;397:2;390:15;421:3;417:2;410:15;442:4;437:3;430:17;464:4;459:3;452:17;486:4;481:3;474:17;508:4;503:3;496:17;530:5;525:3;518:18;553:5;548:3;541:18;574:3;571:1;564:14
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

In case anyone wonders: it's a bit curious that the source mappings here don't change... but they only cover the outermost assembly and the change is only the subassemblies being collapsed, so it's good.

Copy link
Collaborator Author

@ekpyron ekpyron left a comment

Choose a reason for hiding this comment

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

Since I'm the original author, I actually can't approve this :-). But let this comment serve as approval.

Add LinkerObject check and more tests
@nikola-matic nikola-matic merged commit c203608 into develop Feb 21, 2023
@nikola-matic nikola-matic deleted the duplicatedSubAssembly branch February 21, 2023 06:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug 🐛 low effort There is not much implementation work to be done. The task is very easy or tiny.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants