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

Update copies #128

Merged
merged 7 commits into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 shared/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ package shared

const BinaryBucket string = "/stader-node-build/permissionless"
const DockerAccount string = "staderlabs"
const StaderVersion string = "1.4.0"
const StaderVersion string = "1.4.0-dev"

const Logo string = `
_____ _ _ _ _ 𝅺
Expand Down
2 changes: 1 addition & 1 deletion stader-cli/node/deposit-sd.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func nodeDepositSd(c *cli.Context) error {
}

if allowance.Allowance.Cmp(amountWei) < 0 {
fmt.Println("Before depositing SD, you must first give the collateral contract approval to interact with your SD. Amount to approve: ", amountWei)
fmt.Println("Before depositing SD, you must first give the collateral contract approval to interact with your SD. Amount to approve: ", eth.WeiToEth(amountWei))
err = nodeApproveSdWithAmount(c, staderClient, amountWei)
if err != nil {
return err
Expand Down
4 changes: 2 additions & 2 deletions stader-cli/node/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func registerNode(c *cli.Context, operatorName string) error {

operatorRewardAddressString := walletStatus.AccountAddress.String()

confirmText := "Would you wish to join the ETHx Socializing pool?\nType 'Yes' to Opt-in or 'No' to Opt-out. \nNote: The Opt-In and Opt-Out of socializing pool will have a cool-off period of 56 days.\ni.e you will have to wait for 56 days to Opt-Out of the Socializing pool once you Opt-In and vice versa.\nLearn more about the ETHx Socializing Pool here:\nhttps://staderlabs.gitbook.io/ethereum/node-operator/permissionless-node-operator/ethx-rewards-for-permissionless-node-operators/socializing-pool\n"
confirmText := "Would you wish to join the ETHx Socializing pool?\nType 'Y' to Opt-in or 'N' to Opt-out. \nNote: The Opt-In and Opt-Out of socializing pool will have a cool-off period of 56 days.\ni.e you will have to wait for 56 days to Opt-Out of the Socializing pool once you Opt-In and vice versa.\nLearn more about the ETHx Socializing Pool here:\nhttps://staderlabs.gitbook.io/ethereum/node-operator/permissionless-node-operator/ethx-rewards-for-permissionless-node-operators/socializing-pool\n"

socializeEl := cliutils.Confirm(confirmText)
// Check node can be registered
Expand Down Expand Up @@ -82,7 +82,7 @@ func registerNode(c *cli.Context, operatorName string) error {
}

// Log & return
fmt.Printf("Congratulation, your node is now registered on the stader \network. Your current Operator and Reward address is the same. We \nstrongly recommend changing your Reward address. To do so, run the \nfollowing command: 'stader-cli node set-reward-address -ora <new reward address>'.\n")
fmt.Printf("Congratulation, your node is now registered on the Stader \nnetwork. Your current Operator and Reward address is the same. We \nstrongly recommend changing your Reward address. To do so, run the \nfollowing command: ~/bin/stader-cli node set-reward-address -ora <new reward address>.\n")
return nil

}
95 changes: 87 additions & 8 deletions stader-cli/node/update-operator-reward-address.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
"fmt"

"github.com/ethereum/go-ethereum/common"
"github.com/stader-labs/stader-node/shared/services/config"

Check failure on line 7 in stader-cli/node/update-operator-reward-address.go

View workflow job for this annotation

GitHub Actions / build

import 'github.com/stader-labs/stader-node/shared/services/config' is not allowed from list 'Main' (depguard)
"github.com/stader-labs/stader-node/shared/services/gas"
"github.com/stader-labs/stader-node/shared/services/stader"
cfTypes "github.com/stader-labs/stader-node/shared/types/config"

Check failure on line 10 in stader-cli/node/update-operator-reward-address.go

View workflow job for this annotation

GitHub Actions / build

import 'github.com/stader-labs/stader-node/shared/types/config' is not allowed from list 'Main' (depguard)
cliutils "github.com/stader-labs/stader-node/shared/utils/cli"
"github.com/urfave/cli"
)
Expand All @@ -27,6 +29,10 @@
}
defer staderClient.Close()

cfg, _, err := staderClient.LoadConfig()
if err != nil {
return err
}
// check if we can update the el
res, err := staderClient.CanUpdateOperatorRewardAddress(operatorRewardAddress)
if err != nil {
Expand Down Expand Up @@ -55,9 +61,7 @@
}

if res.OperatorAddressAndRewardNotTheSame {
fmt.Printf("%sFor node security, only your existing Reward Address can \npropose a change. To propose and confirm a Reward address \nchange, please use the PermissionlessNodeRegistry Smart Contract: \n%s %s\n\n", colorLightBlue, infoResponse.PermissionlessNodeRegistry, colorReset)

promptNote()
promptHowToChangeReward(cfg, infoResponse.PermissionlessNodeRegistry)
return nil
}

Expand All @@ -66,8 +70,18 @@
return err
}

confirmMessage := `
This action will change your Reward Address. Once it's changed, all future SD and ETH rewards will be sent to the New Reward Address.

After you propose the change, your New Reward Address will initially be in a
'Confirmation pending' state until you confirm the change using your New RewardAddress on the
PermissionlessNodeRegistry Smart Contract. Please make sure that your New Reward Address
is linked to a web3-compatible wallet, such as MetaMask, to connect with the Smart Contract

Do you wish to proceed with the Reward Address change?`

if !(c.Bool("yes") || cliutils.Confirm(fmt.Sprintf(
"\n%sThis action will change your Reward address. Once it's \nchanged, all future SD and ETH reward will be sent to the new address. \n\nYour new Reward address will initially be in a \"Confirmation pending\" state. \nTo confirm the change, please use \nthe PermissionlessNodeRegistry Smart Contract: %s \n\nStader will continue to send reward to your existing address until you \nconfirm the change using your new Reward Address. To complete \nthe confirmation process, make sure you have a web3-compatible wallet like \nMetaMask. Connect your wallet with the Smart Contract using \nyour new Reward address and confirm the Reward address change \nusing the ConfirmRewardAddressChange function. \n\n%sDo you wish to processed with the Reward address change?%s", colorLightBlue, infoResponse.PermissionlessNodeRegistry, colorGreen, colorReset))) {
"\n%s %s %s", colorLightBlue, confirmMessage, colorReset))) {
fmt.Println("Cancelled.")
return nil
}
Expand All @@ -86,11 +100,76 @@
return err
}

fmt.Printf("%sYour reward address changed in pending state. Please \nconfirm the request using this contract: %s and the reward address.%s", colorLightBlue, infoResponse.PermissionlessNodeRegistry, colorReset)

promptSuccessChangedRewardAndNextStep(cfg, infoResponse.PermissionlessNodeRegistry)
return nil
}

func promptNote() {
fmt.Printf("%sFollow these steps for your Reward address change: \nStep1: Propose the Reward address change by connecting your wallet \nto the Smart Contract using your EXISTING Reward address and the ProposeRewardAddress function. \nStep2: Confirm the Reward address change by connecting your wallet \nto the Smart Contract using your NEW Reward address and the ConfirmRewardAddressChange function. \n\n%sNote: Stader will continue to send reward to your existing Reward \naddress until you confirm the change using your new Reward Address%s", colorGreen, colorRed, colorReset)
func promptSuccessChangedRewardAndNextStep(cfg *config.StaderConfig, contractAddr common.Address) {
switch cfg.StaderNode.Network.Value.(cfTypes.Network) {

Check failure on line 108 in stader-cli/node/update-operator-reward-address.go

View workflow job for this annotation

GitHub Actions / build

missing cases in switch of type config.Network: config.Network_Unknown, config.Network_All, config.Network_Devnet, config.Network_Zhejiang (exhaustive)
case cfTypes.Network_Mainnet:
msg := `
You have successfully raised a request to change your Reward Address.

To confirm the Reward Address change please follow these steps:
Step 1: Visit the PermissionlessNodeRegistry Smart Contract: https://etherscan.io/address/%s#writeProxyContract#F3
Step 2: Confirm the Reward Address change by connecting your New Reward Address wallet with the Smart Contract and execute the "ConfirmRewardAddressChange" function.

Please refer to the Reward Address change guide here - https://staderlabs.notion.site/staderlabs/Stader-ETHx-Reward-address-change-flow-Mainnet-Permissionless-8ef1137e9c2647c88db3911da1642ca2

Note: Stader will continue to send rewards to your existing Reward Address until you confirm the change using your new Reward Address.
`
msg = fmt.Sprintf(msg, contractAddr.String())
fmt.Printf("%s %s %s\n", colorLightBlue, msg, colorReset)
case cfTypes.Network_Prater:
msg := `
You have successfully raised a request to change your Reward Address.

To confirm the Reward Address change please follow these steps:
Step 1: Visit the PermissionlessNodeRegistry Smart Contract: https://goerli.etherscan.io/address/%s#writeProxyContract#F3
Step 2: Confirm the Reward Address change by connecting your New Reward Address wallet with the Smart Contract and execute the "ConfirmRewardAddressChange" function.

Please refer to the Reward Address change guide here - https://staderlabs.notion.site/staderlabs/Stader-ETHx-Reward-address-change-flow-Testnet-Permissionless-db692621a305426bab2e3ad232acbc14

Note: Stader will continue to send rewards to your existing Reward Address until you confirm the change using your new Reward Address.`
msg = fmt.Sprintf(msg, contractAddr.String())
fmt.Printf("%s %s %s\n", colorLightBlue, msg, colorReset)
default:
fmt.Println("Unsupported network")
}
}

func promptHowToChangeReward(cfg *config.StaderConfig, contractAddr common.Address) {
network := cfg.StaderNode.Network.Value.(cfTypes.Network)

Check failure on line 142 in stader-cli/node/update-operator-reward-address.go

View workflow job for this annotation

GitHub Actions / build

Error return value is not checked (errcheck)
switch network {

Check failure on line 143 in stader-cli/node/update-operator-reward-address.go

View workflow job for this annotation

GitHub Actions / build

missing cases in switch of type config.Network: config.Network_Unknown, config.Network_All, config.Network_Devnet, config.Network_Zhejiang (exhaustive)
case cfTypes.Network_Mainnet:
msg := `
For node security, only your existing Reward Address can propose a change. To propose and confirm a Reward Address change, please use the PermissionlessNodeRegistry Smart Contract: https://etherscan.io/address/%s#writeProxyContract#F10

Follow these steps for your Reward address change:
Step 1: Propose the Reward Address change by connecting your Existing Reward Address wallet with the Smart Contract and execute the "ProposeRewardAddress" function.
Step 2: Confirm the Reward Address change by connecting your New Reward Address wallet with the Smart Contract and execute the "ConfirmRewardAddressChange" function

Please refer to the Reward Address change guide here - https://staderlabs.notion.site/staderlabs/Stader-ETHx-Reward-address-change-flow-Mainnet-Permissionless-8ef1137e9c2647c88db3911da1642ca2

Note: Stader will continue to send rewards to your existing Reward Address until you confirm the change using your New Reward Address.
`
msg = fmt.Sprintf(msg, contractAddr.String())
fmt.Printf("%s %s %s\n\n", colorLightBlue, msg, colorReset)
case cfTypes.Network_Prater:
msg := `
For node security, only your existing Reward Address can propose a change. To propose and confirm a Reward Address change, please use the PermissionlessNodeRegistry Smart Contract: https://goerli.etherscan.io/address/%s#writeProxyContract#F10

Follow these steps for your Reward Address change:
Step 1: Propose the Reward Address change by connecting your Existing Reward Address wallet with the Smart Contract and execute the "ProposeRewardAddress" function.
Step 2: Confirm the Reward Address change by connecting your New Reward Address wallet with the Smart Contract and execute the "ConfirmRewardAddressChange" function

Please refer to the Reward Address change guide here - https://staderlabs.notion.site/staderlabs/Stader-ETHx-Reward-address-change-flow-Testnet-Permissionless-db692621a305426bab2e3ad232acbc14

Note: Stader will continue to send rewards to your existing Reward Address until you confirm the change using your New Reward Address.
`
msg = fmt.Sprintf(msg, contractAddr.String())
fmt.Printf("%s %s %s\n\n", colorLightBlue, msg, colorReset)
default:
fmt.Println("Unsupported network")
}
}
Loading