Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Tx partial signed with @solana/web3.js cant be partial signed in solnet. #396

Unanswered
timaiv asked this question in Q&A
Discussion options

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.

You must be logged in to vote

Replies: 2 comments 3 replies

Comment options

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());
 });
You must be logged in to vote
0 replies
Comment options

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!

You must be logged in to vote
3 replies
Comment options

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;
 }
 }
Comment options

@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

Comment options

@murlokito Sorry, no, Also I would be thankful for adding "PartialSign" method, that finds corresponding account in signatures.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /