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

fixed vote options serialization #560

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

yamijuan
Copy link
Collaborator

Fixed vote type serialization on Multiple choice vote type. It was using 16 bits but only sending one data, now it sends 2 option in the same 16 bits.

We also found a couple of inconsistencies!

@vercel
Copy link

vercel bot commented Oct 19, 2022

@yamijuan is attempting to deploy a commit to the Solana Team on Vercel.

A member of the Team first needs to authorize it.

@tyirenkyi
Copy link

Fixed vote type serialization on Multiple choice vote type. It was using 16 bits but only sending one data, now it sends 2 option in the same 16 bits.

We also found a couple of inconsistencies!

Deserialisation should work with this fix because of the VoteTypeKind enum. Also by setting both max_voter_options and max_winning_options to the value of choiceCount this validation will pass

@vercel
Copy link

vercel bot commented Oct 20, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
oyster-governance ✅ Ready (Inspect) Visit Preview Oct 20, 2022 at 4:40PM (UTC)

@@ -111,8 +111,10 @@ import { deserializeBorsh } from '../tools/borsh';
writer.length += 1;

if (value.type === VoteTypeKind.MultiChoice) {
writer.buf.writeUInt16LE(value.choiceCount!, writer.length);
writer.length += 2;
writer.buf.writeUInt8(value.choiceCount!, writer.length);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import { GoverningTokenConfigAccountArgs, GoverningTokenType } from '../../src';
import { BenchBuilder } from '../tools/builders';

test('setRealmConfig', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests should be in V2.V3 because they should work for spl-gov V2 and V3 and there is no V4 yet

import { GoverningTokenConfigAccountArgs, GoverningTokenType } from '../../src';
import { BenchBuilder } from '../tools/builders';

test('setRealmConfig', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the difference between this test and the one which already exists?

expect(governance.account.realm).toEqual(realm.realmPk);
});

test('createProposal', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make the test name more specific

@SebastianBor
Copy link
Contributor

Fixed vote type serialization on Multiple choice vote type. It was using 16 bits but only sending one data, now it sends 2 option in the same 16 bits.

Are you planning to use or already using multi choice voting? I'm asking because we are planing to make some breaking changes to it and it would be better to wait. More details here solana-labs/solana-program-library#3721

@tyirenkyi
Copy link

We aren't using multiple choice right now

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

Successfully merging this pull request may close these issues.

None yet

3 participants