-
Notifications
You must be signed in to change notification settings - Fork 153
-
Web3.js(1.44.0) byte array after serializeMessage() is not equal to compileMessage() in solnet(5.0.6).
Account order is different. Debugging further.
let tx = Transaction.from(data) let compiled = tx.serializeMessage();
var txDeserialized = Solnet.Rpc.Models.Transaction.Deserialize(data); var compiled = txDeserialized.CompileMessage();
Same operation success in web3.js, tx sent successfully.
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 2 comments 3 replies
-
This caused by x.pubkey.toBase58().localeCompare(y.pubkey.toBase58()); additional check. Link
// Sort. Prioritizing first by signer, then by writable uniqueMetas.sort(function (x, y) { if (x.isSigner !== y.isSigner) { // Signers always come before non-signers return x.isSigner ? -1 : 1; } if (x.isWritable !== y.isWritable) { // Writable accounts always come before read-only accounts return x.isWritable ? -1 : 1; } // Otherwise, sort by pubkey, stringwise. return x.pubkey.toBase58().localeCompare(y.pubkey.toBase58()); });
Beta Was this translation helpful? Give feedback.
All reactions
-
I think this should be easily fixed.
The problem was web3.js had issues with partial signing and order of keys changing. We were kinda compatible, but there were edge cases. Looking at git blame, that was changed this past week to have deterministic order of keys!
Will create an issue and work on this during the weekend!
Beta Was this translation helpful? Give feedback.
All reactions
-
👍 1
-
Now bytes are same, added sort by pubkey as in web3.js
internal IList<AccountMeta> AccountList { get { List<AccountMeta> res = _accounts.Select(acc => acc).ToList(); res.Sort((x, y) => { if (x.IsSigner != y.IsSigner) { // Signers always come before non-signers return x.IsSigner ? -1 : 1; } if (x.IsWritable != y.IsWritable) { // Writable accounts always come before read-only accounts return x.IsWritable ? -1 : 1; } // Otherwise, sort by pubkey, stringwise. return x.PublicKey.CompareTo(y.PublicKey); }); return res; } }
Beta Was this translation helpful? Give feedback.
All reactions
-
@timaiv do you mind opening a PR for this? there's an associated issue at #397, if not then we'll open up a PR later
Beta Was this translation helpful? Give feedback.
All reactions
-
@murlokito Sorry, no, Also I would be thankful for adding "PartialSign" method, that finds corresponding account in signatures.
Beta Was this translation helpful? Give feedback.