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: struct packing #503

Merged
merged 3 commits into from
Aug 21, 2023
Merged

feat: struct packing #503

merged 3 commits into from
Aug 21, 2023

Conversation

pscott
Copy link
Contributor

@pscott pscott commented Aug 17, 2023

Implement struct packing (for Proposal, as the Storage struct will not be modified as much) using the StorePacking trait

Closes #483

@pscott pscott requested a review from Orland0x August 17, 2023 20:15
timestamps_and_finalization_status: u128, // In order: start, min, max, finalization_status
execution_payload_hash: felt252,
execution_strategy: ContractAddress,
author: UserAddress,
Copy link
Contributor

Choose a reason for hiding this comment

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

Annoying that the UserAddress adds storage overhead. one solution could be to store a felt252 hash of it that we then compute when neeeded. probably unnecessary complexity though

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Technically, most of the time the UserAddress will be ethereum / starknet and will felt in a single felt so the storage will not move (will stay 0) so i don't think it will cost that much?

active_voting_strategies: u256,
}

impl ProposalStorePacking of StorePacking<Proposal, PackedProposal> {
Copy link
Contributor

Choose a reason for hiding this comment

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

really like cairo's approach to packing. super clean and efficient

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! agreed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

one thing is make sure you #[derive(starknet::Store)] and not #[derive(Store)]. Found out the hard way...

Copy link
Contributor

@Orland0x Orland0x left a comment

Choose a reason for hiding this comment

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

uTACK

@pscott pscott merged commit 0366d0e into develop Aug 21, 2023
2 checks passed
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.

refactor: struct packing
2 participants