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

Implement pdao status and signalling address commands #599

Merged
merged 29 commits into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
1cbc298
Init rocketpool-cli pdao status
thomaspanf Jul 10, 2024
7f264f9
Init rocketpool-daemon pdao status
thomaspanf Jul 10, 2024
05b8a8f
Init RocketSignerRegistry binding
thomaspanf Jul 10, 2024
5c5fc4b
Add RocketSignerRegistry to ServiceProvider
thomaspanf Jul 11, 2024
59cf695
Add registry binding
thomaspanf Jul 11, 2024
f0c1ddc
Populating fields in API response
thomaspanf Jul 12, 2024
9cecead
Init ParseEIP712 helper function
thomaspanf Jul 13, 2024
83b7318
Init signalling address commands
thomaspanf Jul 14, 2024
2095587
Register routes for set/clear signalling address
thomaspanf Jul 15, 2024
4606c10
Add voteCount response
thomaspanf Jul 15, 2024
701c37a
Fixed issue in registry binding
thomaspanf Jul 16, 2024
3f4e01d
Add api route for clear signalling address
thomaspanf Jul 16, 2024
4dddd20
Add cli and api route for set/clear signalling address
thomaspanf Jul 17, 2024
5ff02e2
Remove unused structs
thomaspanf Jul 17, 2024
c03878e
Fix print statements and terminal escape codes
thomaspanf Jul 18, 2024
8a91b72
Add PrintNetwork and error handling for unregistered nodes
thomaspanf Jul 18, 2024
33a089c
Remove else after return and unused fields
thomaspanf Jul 18, 2024
32a7c96
Remove const, fix message and nil pointer
thomaspanf Jul 18, 2024
276d4ef
Add api call to grab active snapshot proposals
thomaspanf Jul 19, 2024
6fce08c
Edit response to improve error output
thomaspanf Jul 19, 2024
fee1e68
Moved eip712 signature validation logic into its own package
thomaspanf Jul 19, 2024
0d690b6
Refactor package eip712 to use Decode and Encode, added unit tests fo…
thomaspanf Jul 22, 2024
05e2934
Update shared/eip712/eip712.go
thomaspanf Jul 22, 2024
cab82dd
Add Validate to eip712 package
thomaspanf Jul 22, 2024
8b4317d
Add test for decoding invalid length signature, fix linter issues
thomaspanf Jul 22, 2024
a6cde79
Refactor Decode/Encode to fulfil TextMarshaler interface
thomaspanf Jul 23, 2024
edb9fc3
Add String method and unit tests for Validate
thomaspanf Jul 23, 2024
5895fce
Fix test case names
thomaspanf Jul 23, 2024
b669d2e
Refactor UnmarshalText and MarshalText
thomaspanf Jul 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion rocketpool-cli/commands/pdao/signalling-address.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func setSignallingAddress(c *cli.Context, signallingAddress common.Address, sign

validated, err := tx.HandleTx(c, rp, response.Data.TxInfo,
"Are you sure you want to set your signalling address?",
"setting signalling",
"setting signalling address",
"Setting signalling address...",
)
if err != nil {
Expand Down
66 changes: 23 additions & 43 deletions rocketpool-cli/commands/pdao/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ import (
"github.com/rocket-pool/rocketpool-go/v2/types"
"github.com/rocket-pool/smartnode/v2/rocketpool-cli/client"
"github.com/rocket-pool/smartnode/v2/rocketpool-cli/utils"
"github.com/rocket-pool/smartnode/v2/rocketpool-cli/utils/terminal"
"github.com/rocket-pool/smartnode/v2/shared/types/api"
)

const (
colorBlue string = "\033[36m"
colorReset string = "\033[0m"
colorGreen string = "\033[32m"
colorBlue string = terminal.ColorBlue
colorReset string = terminal.ColorReset
colorGreen string = terminal.ColorGreen

thomaspanf marked this conversation as resolved.
Show resolved Hide resolved
signallingAddressLink string = "https://docs.rocketpool.net/guides/houston/participate#setting-your-snapshot-signalling-address"
thomaspanf marked this conversation as resolved.
Show resolved Hide resolved
)

Expand Down Expand Up @@ -49,88 +51,66 @@ func getStatus(c *cli.Context) error {
}
claimableBonds := claimableBondsResponse.Data.ClaimableBonds

// Test Strings
fmt.Printf("Resp %v\n", response)
fmt.Printf("block number: %d\n", response.Data.BlockNumber)
fmt.Printf("Voting initialized: %t\n", response.Data.IsVotingInitialized)
fmt.Printf("Node Registered: %t\n", response.Data.IsNodeRegistered)
fmt.Printf("Voting power %d\n", response.Data.VotingPower)
fmt.Printf("Delegated voting power %d\n", response.Data.TotalDelegatedVp)
fmt.Printf("On chain delegate formatted: %s\n", response.Data.OnchainVotingDelegateFormatted)
fmt.Printf("Account Address formatted: %s\n", response.Data.AccountAddressFormatted)
fmt.Printf("Signalling Address formatted %s\n", response.Data.SignallingAddressFormatted)
fmt.Printf("Is RPL locking allowed %t\n", response.Data.IsRPLLockingAllowed)

// Signalling Status
fmt.Printf("%s=== Signalling on Snapshot ===%s\n", colorGreen, colorReset)
blankAddress := common.Address{}
if response.Data.SignallingAddress == blankAddress {
fmt.Printf("The node does not currently have a snapshot signalling address set.\nTo learn more about snapshot signalling, please visit %s.\n", signallingAddressLink)
fmt.Println("The node does not currently have a snapshot signalling address set.")
fmt.Printf("To learn more about snapshot signalling, please visit %s.\n", signallingAddressLink)
} else {
fmt.Printf("The node has a signalling address of %s%s%s which can represent it when voting on Rocket Pool Snapshot governance proposals.\n", colorBlue, response.Data.SignallingAddressFormatted, colorReset)
}

if response.Data.SnapshotResponse.Error != "" {
fmt.Printf("Unable to fetch latest voting information from snapshot.org: %s\n", response.Data.SnapshotResponse.Error)
} else {
voteCount := response.Data.SnapshotResponse.VoteCount()
if len(response.Data.SnapshotResponse.ActiveSnapshotProposals) == 0 {
fmt.Printf("Rocket Pool has no Snapshot governance proposals being voted on.")
fmt.Println()
fmt.Println("Rocket Pool has no Snapshot governance proposals being voted on.")
} else {
fmt.Printf("Rocket Pool has %d Snapshot governance proposal(s) being voted on. You have voted on %d of those. See details using 'rocketpool network dao-proposals'.\n", len(response.Data.SnapshotResponse.ActiveSnapshotProposals), voteCount)
}
fmt.Println()
}
fmt.Println()

// Onchain Voting Status
fmt.Printf("%s=== Onchain Voting ===%s\n", colorGreen, colorReset)
if response.Data.IsVotingInitialized {
fmt.Printf("The node %s%s%s has been initialized for onchain voting.", colorBlue, response.Data.AccountAddressFormatted, colorReset)
fmt.Println()
fmt.Printf("The node %s%s%s has been initialized for onchain voting.\n", colorBlue, response.Data.AccountAddressFormatted, colorReset)
} else {
fmt.Printf("The node %s%s%s has NOT been initialized for onchain voting. You need to run `rocketpool pdao initialize-voting` to participate in onchain votes.", colorBlue, response.Data.AccountAddressFormatted, colorReset)
fmt.Println()
fmt.Printf("The node %s%s%s has NOT been initialized for onchain voting. You need to run `rocketpool pdao initialize-voting` to participate in onchain votes.\n", colorBlue, response.Data.AccountAddressFormatted, colorReset)
}

if response.Data.OnchainVotingDelegate == blankAddress {
fmt.Println("The node doesn't have a delegate, which means it can vote directly on onchain proposals after it initializes voting.")
} else if response.Data.OnchainVotingDelegate == response.Data.AccountAddress {
fmt.Println("The node doesn't have a delegate, which means it can vote directly on onchain proposals. You can have another node represent you by running `rocketpool p svd <address>`.")
} else {
fmt.Printf("The node has a voting delegate of %s%s%s which can represent it when voting on Rocket Pool onchain governance proposals.", colorBlue, response.Data.OnchainVotingDelegateFormatted, colorReset)
fmt.Println()
fmt.Printf("The node has a voting delegate of %s%s%s which can represent it when voting on Rocket Pool onchain governance proposals.\n", colorBlue, response.Data.OnchainVotingDelegateFormatted, colorReset)
}
fmt.Printf("The node's local voting power: %.10f\n", eth.WeiToEth(response.Data.VotingPower))
if response.Data.IsNodeRegistered {
fmt.Printf("Total voting power delegated to the node: %.10f", eth.WeiToEth(response.Data.TotalDelegatedVp))
fmt.Println()
fmt.Printf("Total voting power delegated to the node: %.10f\n", eth.WeiToEth(response.Data.TotalDelegatedVp))
} else {
fmt.Print("The node must register using 'rocketpool node register' to be eligible to receive delegated voting power")
fmt.Println()
fmt.Println("The node must register using 'rocketpool node register' to be eligible to receive delegated voting power")
}
fmt.Printf("Network total initialized voting power: %.10f\n", eth.WeiToEth(response.Data.SumVotingPower))
fmt.Println("")
fmt.Println()

// Claimable Bonds Status:
fmt.Printf("%s=== Claimable RPL Bonds ===%s", colorGreen, colorReset)
fmt.Println()
fmt.Printf("%s=== Claimable RPL Bonds ===%s\n", colorGreen, colorReset)
if response.Data.IsRPLLockingAllowed {
fmt.Println("The node is allowed to lock RPL to create governance proposals/challenges.")
if response.Data.NodeRPLLocked.Cmp(big.NewInt(0)) != 0 {
fmt.Printf("The node currently has %.6f RPL locked.",
utilsMath.RoundDown(eth.WeiToEth(response.Data.NodeRPLLocked), 6))
fmt.Println()
fmt.Printf("The node currently has %.6f RPL locked.\n", utilsMath.RoundDown(eth.WeiToEth(response.Data.NodeRPLLocked), 6))
}
} else {
fmt.Print("The node is NOT allowed to lock RPL to create governance proposals/challenges. Use 'rocketpool node allow-rpl-locking, to allow RPL locking.\n")
fmt.Println("The node is NOT allowed to lock RPL to create governance proposals/challenges. Use 'rocketpool node allow-rpl-locking, to allow RPL locking.")
}
if len(claimableBonds) == 0 {
fmt.Println("You do not have any unlockable bonds or claimable rewards.")
fmt.Println("The node does not have any unlockable bonds or claimable rewards.")
} else {
fmt.Println("The node has unlockable bonds or claimable rewards available. Use 'rocketpool pdao claim-bonds' to view and claim.")
}
fmt.Println("")
fmt.Println()

// Check if PDAO proposal checking duty is enabled
fmt.Printf("%s=== PDAO Proposal Checking Duty ===%s\n", colorGreen, colorReset)
Expand All @@ -140,7 +120,7 @@ func getStatus(c *cli.Context) error {
} else {
fmt.Println("The node does not have PDAO proposal checking duties enabled (See https://docs.rocketpool.net/guides/houston/pdao#challenge-process to learn more about this duty).")
}
fmt.Println("")
fmt.Println()

// Claimable Bonds Status:
fmt.Printf("%s=== Pending, Active and Succeeded Proposals ===%s\n", colorGreen, colorReset)
Expand Down Expand Up @@ -175,12 +155,12 @@ func getStatus(c *cli.Context) error {
// Print message for Succeeded Proposals
if stateName == "Succeeded" {
succeededExists = true
fmt.Printf("%sThe following proposal(s) have succeeded and are waiting to be executed. Use `rocketpool pdao proposals execute` to execute.%s\n\n", colorBlue, colorReset)
fmt.Printf("%sThe following proposal(s) have succeeded and are waiting to be executed. Use `rocketpool pdao proposals execute` to execute.%s\n", colorBlue, colorReset)
}

// Proposal state count
fmt.Printf("%d %s proposal(s):\n", len(proposals), stateName)
fmt.Println("")
fmt.Println()

// Proposals
for _, proposal := range proposals {
Expand Down
Loading