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

feat(cli): allow static arrays as abi types in store config and tablegen #509

Merged
merged 6 commits into from
Mar 27, 2023

Conversation

dk1a
Copy link
Contributor

@dk1a dk1a commented Mar 20, 2023

Now that schema types are strings of abi types, I can make e.g. uint32[2] just work, without user types
Also added some more tests

An annoying regression here is a bunch of function mutability can be restricted to pure warnings. Memory.copy uses identity precompile, which forces view. And detecting which vars use such memory copying is a lot of needless complexity I'd rather avoid.
This can be solved by changing Memory.copy (would likely cost more gas), or generalizing TightCoder to be usable directly for static arrays (would sidestep the need for copying altogether).
Regardless, for Memory.copy it would be best to use the native MCOPY if it ever happens: https://eips.ethereum.org/EIPS/eip-5656
related: ethereum/solidity#12127

Also fixed a type inference bug which would happen in some complex configs with multiple user types

@dk1a dk1a requested review from alvrs and holic as code owners March 20, 2023 17:20
@dk1a dk1a mentioned this pull request Mar 24, 2023
47 tasks
alvrs
alvrs previously approved these changes Mar 27, 2023
Copy link
Member

@alvrs alvrs left a comment

Choose a reason for hiding this comment

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

Very cool! Nothing blocking, just two questions.

Comment on lines +13 to +17
// When type inference sees multiple uses of 1 generic, it can only guess
// which of those are supposed to define the generic (and it will be wrong in complex situations).
// This helper explicitly makes a type that's dependent on some generic,
// and will not be inferred as the generic's definition.
export type AsDependent<T> = T extends infer P ? P : never;
Copy link
Member

Choose a reason for hiding this comment

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

What's an example for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Comment on lines +58 to +59
// WARNING: ensure this still works if changing major solidity versions!
// (the memory layout for static arrays may change)
Copy link
Member

Choose a reason for hiding this comment

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

How can we remind ourselves of this when changing major solidity versions? Maybe a comment in cli's foundry.toml?

@alvrs alvrs merged commit 588d037 into main Mar 27, 2023
@dk1a dk1a deleted the dk1a/tablegen-static-arrays branch May 9, 2023 16:27
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.

2 participants