lang: remove default space calc#1519
Conversation
|
I remember us talking about this but just wanted to check whether you still think this should be done before I continue? @armaniferrante |
I'm for it. |
|
what do you think about adding a len attribute that would then generate a impl #name {
pub const LEN: usize = #sum_lengths;
}If we do this, we'd better do it in a different PR but in the same release imo. |
Happy to discuss it in an issue. At first glance, I'm not super excited about it and would rather explicitly state the length via space. |
|
Let's wait to merge this until after the next patch release. |
| pub end_deposits: i64, | ||
| pub end_ido: i64, | ||
| pub end_escrow: i64, | ||
| pub start_ido: i64, // 8 |
There was a problem hiding this comment.
No need to change this. But generally I'm not a fan of these comments. They don't really add any useful information.
There was a problem hiding this comment.
- writing the individual parts down explicitly before summing them up reduces likelihood of mistakes
- it becomes easier to parse mentally because you dont need to go through the calculation steps again. Then again, how often do you need to parse the space of an account? probably not often.
There was a problem hiding this comment.
- the second bullet point is better solved imo by having a cumulative sum comment rather than saying the iindividual sizes.
|
Whats the reasoning for removing this? Was quite a handy feature for me? |
|
@utx0 reasoning is in the issue |
|
is there a guide on how to calculate account space? |
|
I usually have something like this: |
I am doing this: |
|
there is a guide in the book. https://book.anchor-lang.com/chapter_5/space.html @utx0 we recommend not using mem::size_of. (see the tic-tac-toe milestone project in the book for an explanation) also, going forward, please dont use issues to discuss support questions and use the discord instead. https://discord.gg/rnNpg7Ys. |
closes #1563
force usage of the
spaceconstraint withinit