near / nearcore

Reference client for NEAR Protocol
https://near.org
GNU General Public License v3.0
2.31k stars 618 forks source link

Deserializer failed with "Cannot use scalar with high-bit set" #2304

Closed ilblackdragon closed 4 years ago

ilblackdragon commented 4 years ago

Received invalid data while syncing headers on betanet using nearup betanet with Docker with "Cannot use scalar with high-bit set" error:

Mar 24 14:38:16.241 ERROR network: Received invalid data [0, 4, 0, 0, 0, 0, 143, 140, 75, 64, 176, 189, 1, 159, 114, 31, 29, 167, 153, 45, 39, 17, 127, 232, 194, 237, 30, 25, 128, 173, 112, 230, 148, 0, 72, 183, 10, 255, 1, 247, 95, 7, 0, 0, 0, 116, 101, 115, 116, 110, 101, 116, 70, 4, 219, 223, 82, 190, 159, 33, 79, 238, 147, 119, 228, 136, 149, 218, 46, 17, 198, 83, 80, 94, 76, 204, 217, 135, 161, 170, 224, 125, 196, 43, 230, 101, 2, 0, 0, 0, 0, 0, 204, 203, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 202, 203, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 229, 57, 179, 250, 136, 243, 145, 170, 156, 13, 117, 189, 56, 42, 247, 181, 116, 125, 99, 122, 230, 41, 38, 32, 223, 23, 186, 150, 173, 22, 126, 10, 84, 93, 254, 151, 203, 135, 166, 248, 3, 127, 45, 152, 54, 73, 56, 49, 164, 89, 98, 247, 110, 97, 162, 104, 138, 245, 212, 51, 72, 102, 56, 6] from None: Cannot use scalar with high-bit set

We probably should add more information for this errors, e.g. which peer sent it.

MaksymZavershynskyi commented 4 years ago

Haven't seen this one before. Could it be: https://github.com/dalek-cryptography/ed25519-dalek/blob/master/src/errors.rs#L52 ?

MaksymZavershynskyi commented 4 years ago

Probably caused here: https://github.com/nearprotocol/nearcore/blob/44bf10d5f618b50195e5ad122c0247aa30dee909/core/crypto/src/signature.rs#L563

bowenwang1996 commented 4 years ago

Seems like borsh error. Assigning to @nearmax

evgenykuzyakov commented 4 years ago

@bowenwang1996 It's not Borsh error, see what @nearmax linked here: https://github.com/nearprotocol/nearcore/issues/2304#issuecomment-606287408

MaksymZavershynskyi commented 4 years ago

Was about to write, but @evgenykuzyakov was faster :) It seems to be a problem with the custom implementation of BorshDeserialize for Signature. Assigning it to @ailisp since he was the one to introduce this code.

Why exactly that code triggers https://github.com/dalek-cryptography/ed25519-dalek/blob/master/src/errors.rs#L52 is not yet known to me.

ilblackdragon commented 4 years ago

Closing this, because this probably was just an issue with older version sending some incompatible data that went this deseralization route.