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

[300 SigmaUSD] Vote for update(pool) command #26

Closed
greenhat opened this issue May 13, 2022 · 8 comments · Fixed by #68
Closed

[300 SigmaUSD] Vote for update(pool) command #26

greenhat opened this issue May 13, 2022 · 8 comments · Fixed by #68
Labels
bounty help wanted Extra attention is needed high priority

Comments

@greenhat
Copy link
Member

greenhat commented May 13, 2022

Should be done after #45 is merged.

To vote for the pool box update as per https://github.com/ergoplatform/eips/blob/bd7a6098db78d67ac2ca9ada4c09bfe709d5ac03/eip-0023.md#vote-for-update (with updates introduced in v2.0a, e.g reward tokens were moved from the refresh box to the pool box) add a new command line option --vote-update-pool with the following parameters:

  • new pool box hash (blake2b256);
  • height of the update box;

If the ballot token is locked in the existing ballot box (i.e. output of the previous update tx) it should be spent to create the new ballot box.

@greenhat greenhat added this to the v2.0 milestone May 13, 2022
@greenhat greenhat added help wanted Extra attention is needed bounty labels Jun 14, 2022
@greenhat greenhat changed the title Vote for update(pool) command [300 SigmaUSD] Vote for update(pool) command Jun 14, 2022
@kettlebell
Copy link
Collaborator

I will work on this.

@kettlebell
Copy link
Collaborator

kettlebell commented Jun 27, 2022

Hi @greenhat I have a question about this issue:

Should the owner of the ballot token have their group element stored in the oracle config? Seems like it since we will need to implement transfer ballot token.

  • An idea: we could do away with storing it in the config by scanning for local ballot box as follows:
    • Get all wallet addresses from node /wallet/addresses endpoint. For each address a, perform a scan for the box with the ballot_token_id and the group element of a in R4.

What do you reckon? Thanks.

@greenhat
Copy link
Member Author

Hi @greenhat I have a question about this issue:

Should the owner of the ballot token have their group element stored in the oracle config? Seems like it since we will need to implement transfer ballot token.

* An idea: we could do away with storing it in the config by scanning for local ballot box as follows:
  
  * Get all wallet addresses from node `/wallet/addresses` endpoint. For each address `a`, perform a scan for the box with the `ballot_token_id` and the group element of `a` in `R4`.

What do you reckon? Thanks.

I think it's ok to store it in the config. Scanning for it seems way more complex. Let's try a simple solution first. :)

@greenhat
Copy link
Member Author

There is an updated (with v2.0a changes) version of the EIP - ergoplatform/eips#41

@kettlebell
Copy link
Collaborator

Got it, thanks!

@kettlebell
Copy link
Collaborator

kettlebell commented Jul 2, 2022

I'm almost done with this issue but I ran into a problem with the case where we're spending an existing ballot box. I got the following error:
TxSigningError(ProverError(EvalError(Misc("ByIndex: index Int(0) out of bounds for collection size 0")), 0))

I tracked it down and the problem originates in this line of the contract. Now I believe we need to amend the contract because for the vote for update command there's only one fixed input (the existing ballot box) as specified in the EIP, and so INPUTS(1) has no guarantee to contain any token.

So I amended the contract by removing the line with val otherTokenId = INPUTS(1).tokens(0)._1 and replacing update with:

val update = INPUTS.size > 1                           &&
             INPUTS(1).tokens.size > 0                 &&
             INPUTS(1).tokens(0)._1 == updateNFT       && // can only update when update box is the 2nd input
             output.R4[GroupElement].get == selfPubKey && // public key is preserved
             output.value >= SELF.value                && // value preserved or increased
             ! (output.R5[Any].isDefined)                 // no more registers; prevents box from being reused as a valid vote 

Then the test passes (playground link) Am I doing this correctly?

@greenhat
Copy link
Member Author

greenhat commented Jul 3, 2022

@kettlebell Good call! I agree.
@scalahub Please check and approve the proposed update to the ballot contract above. The reason for the update is that val otherTokenId = INPUTS(1).tokens(0)._1 throws on voting, i.e. spending the ballot box without the update box.

@greenhat
Copy link
Member Author

greenhat commented Jul 7, 2022

The bounty is sent. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bounty help wanted Extra attention is needed high priority
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants