Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is the conversion of transaction signer to stackitem implemented as intended? #2705

Closed
AnnaShaleva opened this issue Apr 26, 2022 · 6 comments · Fixed by #2708
Closed

Is the conversion of transaction signer to stackitem implemented as intended? #2705

AnnaShaleva opened this issue Apr 26, 2022 · 6 comments · Fixed by #2708
Labels
question Used in questions

Comments

@AnnaShaleva
Copy link
Member

Problem description

#2685 introduces new GetTransactionSigners method to native Ledger. Take a look at the way how each signer is converted to stackitem: the first array item is the serialized binary representation of the Signer itself:

VM.Types.StackItem IInteroperable.ToStackItem(ReferenceCounter referenceCounter)
{
return new VM.Types.Array(referenceCounter, new VM.Types.StackItem[]
{
this.ToArray(),

The binary representation is followed by a set of Signer's fields serialized to stackitem separately:

Account.ToArray(),
(byte)Scopes,
new VM.Types.Array(AllowedContracts.Select(u => new VM.Types.ByteString(u.ToArray()))),
new VM.Types.Array(AllowedGroups.Select(u => new VM.Types.ByteString(u.ToArray()))),
new VM.Types.Array(Rules.Select(u => u.ToStackItem(referenceCounter)))
});

So the first stackitem (binary Signer's representation) looks weird and redundant a bit. We have all other Signer's data available at the same stackitem, so why do we need its serialized binary representation?

The question

Do we need the Signer's binary representation to be included in its stackitem representation? If so, could you, please, explain, why?

@shargon
Copy link
Member

shargon commented Apr 27, 2022

Agree, the first version only wanted the binary, now it's not required

@erikzhang
Copy link
Member

I think we can keep the binary data for convenience.

@roman-khimov
Copy link
Contributor

To me it's just duplicating for no good reason, interpreting these bytes is time-consuming and error-prone activity that is easily avoided by using proper stack item representation (which we already have anyway).

@erikzhang
Copy link
Member

In some cases, we can use a single EQUAL instruction to determine whether it is the signer we want without traversing every field of it.

@erikzhang
Copy link
Member

In some cases, we can use a single EQUAL instruction to determine whether it is the signer we want without traversing every field of it.

What do you think? We need to decide before 3.3.0 is released.

@roman-khimov
Copy link
Contributor

roman-khimov commented May 19, 2022

Doesn't seem to be a useful scenario to me.
🚀: drop binary (merge #2708)
🎉: keep binary (close #2708)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Used in questions
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants