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

cmd,eth,server: add voting to CLI #1461

Merged
merged 3 commits into from
Apr 27, 2020
Merged

cmd,eth,server: add voting to CLI #1461

merged 3 commits into from
Apr 27, 2020

Conversation

kyriediculous
Copy link
Contributor

@kyriediculous kyriediculous commented Apr 21, 2020

What does this pull request do? Explain your changes. (required)
This PR adds the option to vote from the CLI (for orchestrators) so that they don't have to export their keys.

Specific updates (required)

  • generate poll contract abi bindings
  • create a voteHandler for the new CLI server /vote endpoint
  • add a Vote() method to LivepeerEthClient
  • Add an option to the CLI to vote

How did you test each of these updates (required)
Added & ran unit tests
Ran workflow in CLI (except for testing with a live poll on rinkeby)

Does this pull request close any open issues?
Fixes #1447

Checklist:

  • README and other documentation updated
  • Node runs in OSX and devenv
  • All tests in ./test.sh pass

Example

What would you like to do? (default = stats)
1. Get node status
2. View protocol parameters
3. List registered orchestrators
4. Invoke "initialize round"
5. Invoke "bond"
6. Invoke "unbond"
7. Invoke "rebond"
8. Invoke "withdraw stake" (LPT)
9. Invoke "withdraw fees" (ETH)
10. Invoke "claim" (for rewards and fees)
11. Invoke "transfer" (LPT)
12. Invoke "reward"
13. Invoke multi-step "become an orchestrator"
14. Set orchestrator config
15. Set Eth gas price
16. Get test LPT
17. Get test ETH
18. Sign a message
19. Vote on a poll
> 19
Enter the contract address for the poll you want to vote on> 0xf4e8Ef0763BCB2B1aF693F5970a00050a6aC7E1B
Identifier	Voting Options
0		Yes
1		No
2		Abstain
Enter the ID of the option you want to vote for> 0
Are you sure you want to vote "Yes" ? (y/n)> n
Identifier	Voting Options
0		Yes
1		No
2		Abstain
Enter the ID of the option you want to vote for> 2
Are you sure you want to vote "Abstain" ? (y/n)> n
Identifier	Voting Options
0		Yes
1		No
2		Abstain
Enter the ID of the option you want to vote for> 1
Are you sure you want to vote "No" ? (y/n)> y

 unable to submit vote transaction err=no contract code at given address
Enter the contract address for the poll you want to vote on> 0xbf790e51fa21e1515cece96975b3505350b20083
Identifier	Voting Options
0		Yes
1		No
2		Abstain
Enter the ID of the option you want to vote for> 1
Are you sure you want to vote "No" ? (y/n)> y

 success
I0422 03:30:44.191809   43457 backend.go:96]
******************************Eth Transaction******************************

Invoking transaction: "vote". Inputs: "_choiceID: 1"  Hash: "0xf6957c190f1f16fc2ca4a93846903eb435c5e08fa7f6f40b6e159aab6d74905f".

**************************************************************************

cmd/livepeer_cli/livepeer_cli.go Outdated Show resolved Hide resolved
eth/client.go Outdated Show resolved Hide resolved
server/handlers.go Outdated Show resolved Hide resolved
server/handlers.go Outdated Show resolved Hide resolved
server/handlers.go Outdated Show resolved Hide resolved
cmd/livepeer_cli/wizard_transcoder.go Outdated Show resolved Hide resolved
cmd/livepeer_cli/wizard_transcoder.go Outdated Show resolved Hide resolved
cmd/livepeer_cli/wizard_transcoder.go Show resolved Hide resolved
cmd/livepeer_cli/wizard_transcoder.go Outdated Show resolved Hide resolved
cmd/livepeer_cli/wizard_transcoder.go Outdated Show resolved Hide resolved
@kyriediculous
Copy link
Contributor Author

Addressed the change requests in their respective fixup commits

fixup! cmd: add voting option to the CLI
00b49d6

fixup! server: CLI server voting handler
70c8b1c

fixup! eth: abigen for Poll contract
c385a51

@adamsoffer
Copy link
Member

@kyriediculous @yondonfu do we want to include abstain as a choice in this first iteration? It's not currently accounted for in the spec defined in LIP-16, the subgraph, or the UI.

cmd/livepeer_cli/wizard_transcoder.go Outdated Show resolved Hide resolved
cmd/livepeer_cli/wizard_transcoder.go Show resolved Hide resolved
cmd/livepeer_cli/wizard_transcoder.go Outdated Show resolved Hide resolved
cmd/livepeer_cli/wizard_transcoder.go Outdated Show resolved Hide resolved
cmd/livepeer_cli/wizard_transcoder.go Outdated Show resolved Hide resolved
eth/types/contracts.go Outdated Show resolved Hide resolved
server/handlers.go Outdated Show resolved Hide resolved
server/handlers.go Outdated Show resolved Hide resolved
server/handlers.go Outdated Show resolved Hide resolved
eth/client.go Outdated Show resolved Hide resolved
Copy link
Member

@yondonfu yondonfu left a comment

Choose a reason for hiding this comment

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

Left 2 minor comments.

Other than that, changes look good so feel free to address the comments when rebasing.

for {
fmt.Printf("Enter the ID of the choice you want to vote for -")
choice = types.VoteChoice(w.readInt())
if ok := choice.IsValid(); ok {
Copy link
Member

Choose a reason for hiding this comment

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

Can be shortened to if choice.IsValid() { ... }


result := httpPostWithParams(fmt.Sprintf("http://%v:%v/vote", w.host, w.httpPort), data)

fmt.Printf("\n %v \n", result)
Copy link
Member

Choose a reason for hiding this comment

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

Don't think we need the leading and trailing space as it will show up as:

 vote success

rather than

vote success

@kyriediculous
Copy link
Contributor Author

Addressed the last comments and rebased

@yondonfu
Copy link
Member

Looks like CI is failing:

eth/watchers/orchestratorwatcher_test.go:25:35: cannot use lpEth (type *eth.StubClient) as type eth.LivepeerEthClient in argument to NewOrchestratorWatcher:
	*eth.StubClient does not implement eth.LivepeerEthClient (wrong type for Vote method)
		have Vote("github.com/ethereum/go-ethereum/common".Address, *big.Int) error
		want Vote("github.com/ethereum/go-ethereum/common".Address, *big.Int) (*"github.com/ethereum/go-ethereum/core/types".Transaction, error)

@kyriediculous
Copy link
Contributor Author

Apparently something went wrong in the rebase. Should be fixed.

I also added a test case for a CheckTx() error which should bring us to 100% coverage for the handler.

Copy link
Member

@yondonfu yondonfu left a comment

Choose a reason for hiding this comment

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

LGTM pending green CI

@kyriediculous kyriediculous merged commit acea1c1 into master Apr 27, 2020
@kyriediculous kyriediculous deleted the nv/cli-voting branch April 27, 2020 20:22
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.

Add voting support in livepeer_cli
3 participants