anza-xyz / move

Move compiler targeting llvm supported backends
https://discord.gg/wFgfjG9J
Apache License 2.0
108 stars 33 forks source link

[Bug] 0x1::bcs_tests::bcs_address fails on unexpected serialization. #329

Closed dmakarov closed 1 year ago

dmakarov commented 1 year ago

🐛 Bug

Move addresses are 16 byte vectors. Solana addresses are 32 byte vectors. In addition Solana addresses are little endian, i.e. an address @0x000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f is represented in memory as 1f1e1d1c1b1a1918171615141312100f0e0d0c0b0a09080706050403020100. The stdlib test fails because its expected serialization of a test address doesn't match serialized Solana address.

The address in the test is @0x89b9f9d1fadc027cf9532d6f99041522 and it's expected to serialize to a string "89b9f9d1fadc027cf9532d6f99041522", while Solana's address is serialized to the string "221504996f2d53f97c02dcfad1f9b98900000000000000000000000000000000"

Is our serialization correct and should the test be updated to match the serialization?

To reproduce

Run stdlib unit test bcs_address

cargo run -p move-cli --features solana-backend --bin move -- test --solana -p language/move-stdlib -t 1 -s bcs_address