Skip to content

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

Description

@oulaoba

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);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions