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

bug about "Tic-Tac-Toe" project. #95

Open
oulaoba opened this issue Jan 11, 2024 · 0 comments
Open

bug about "Tic-Tac-Toe" project. #95

oulaoba opened this issue Jan 11, 2024 · 0 comments

Comments

@oulaoba
Copy link

oulaoba commented Jan 11, 2024

When i code flow this example Milestone Project - Tic-Tac-Toe.

I got an error " Error: AnchorError caused by account: game. Error Code: AccountDidNotSerialize. Error Number: 3004. Error Message: Failed to serialize the account." at anchor test.

I also see the notice.

(What about using mem::size_of()? This almost works but not quite. The issue is that borsh will always serialize an option as 1 byte for the variant identifier and then additional x bytes for the content if it's Some. Rust uses null-pointer optimization to make Option's variant identifier 0 bytes when it can, so an option is sometimes just as big as its contents. This is the case with Sign. This means the MAXIMUM_SIZE could also be expressed as mem::size_of() + 9.)

but it seems like lose 4 bit of borsh space. Maybe the MAXIMUM_SIZE need change to pub const MAXIMUM_SIZE: usize = 4 + (32 * 2) + 1 + (9 * (1 + 1)) + (32 + 1);

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

No branches or pull requests

1 participant